Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.mdstv.bukkit.messit;
- import java.io.File;
- import org.bukkit.ChatColor;
- import org.bukkit.OfflinePlayer;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- public class MessIt extends JavaPlugin {
- private File playerOnlineData;
- private YamlConfiguration playerOnlineConfig;
- private PlayerListener pl = new PlayerListener(this);
- @Override
- public void onEnable() {
- this.playerOnlineData = new File(getDataFolder(), "playerOnline.yml");
- this.playerOnlineConfig = YamlConfiguration.loadConfiguration(this.playerOnlineData);
- // Init Listener
- this.getServer().getPluginManager().registerEvents(this.pl, this);
- }
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (label.equalsIgnoreCase("ptime")) {
- if (sender.hasPermission("messit.ptime")) {
- if (args.length == 2) {
- OfflinePlayer op = this.getServer().getOfflinePlayer(args[0]);
- String action = args[1];
- if (action.equalsIgnoreCase("session")) {
- if (op.isOnline()) {
- Player p = op.getPlayer();
- long time = this.pl.getPlayerCurrentOnlineTime(p);
- sender.sendMessage(String.format("%s ist bereits %s online", op.getName(), this.pl.formatTime(time)));
- return true;
- } else {
- sender.sendMessage(ChatColor.RED + String.format("%s ist nicht online", op.getName()));
- return true;
- }
- } else if (action.equalsIgnoreCase("entire")) {
- long entireTime = this.pl.getPlayerEntireOnlineTime(op);
- if (entireTime > 0L) {
- sender.sendMessage(String.format("%s hat bereits %s gespielt", op.getName(), this.pl.formatTime(entireTime)));
- return true;
- } else {
- sender.sendMessage(ChatColor.GOLD + "Dieser Spieler war entweder noch nie auf diesem Server oder ist noch nicht gelistet.");
- return true;
- }
- } else {
- // Show usage
- return false;
- }
- } else {
- // Show usage
- return false;
- }
- } else {
- sender.sendMessage(ChatColor.DARK_RED + "Sorry, no permission :(");
- return true;
- }
- } else {
- return super.onCommand(sender, command, label, args);
- }
- }
- /**
- * Returns the {@link YamlConfiguration} which contains the online times
- * @return A {@link YamlConfiguration} with the online times
- */
- public YamlConfiguration getTimeConf() {
- return this.playerOnlineConfig;
- }
- /**
- * Returns the {@link File} for the online time {@link YamlConfiguration}
- * @return The {@link File} for the online time {@link YamlConfiguration}
- */
- public File getTimeConfFile() {
- return this.playerOnlineData;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement