package pl.qotrek.terxan.commands; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import pl.qotrek.terxan.Main; import pl.qotrek.terxan.utils.ChatUtil; public class GodCommand implements CommandExecutor, Listener { static Main plugin; public GodCommand(Main pl) { plugin = pl; } @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if(cmd.getName().equalsIgnoreCase("god")) { if(!(sender instanceof Player)) { sender.sendMessage("§4Blad! §cAby wywolac ta komende musisz byc graczem!"); return false; } if(!(sender.hasPermission(Main.getPlugin().getConfig().getString("god.pex")))) { sender.sendMessage("§4Blad! §cNie masz permisji aby uzyc ta komende!"); Player p = (Player)sender; ChatUtil.sendTitle(p, "&a&lTerXan.PL", Main.getPlugin().getConfig().getString("all.errorpex"), 15, 50, 25); return false; } Player p = (Player) sender; if(args.length==0) { if(plugin.gods.contains(p.getUniqueId())) { plugin.gods.remove(p.getUniqueId()); p.sendMessage("§2Sukces! §aGod zostal §cwylaczony"); ChatUtil.sendTitle(p, "&8* &2&lTer&f&lXan &8*", "&8» &7God zostal &cwylaczony", 15, 40, 30); return true; } else { plugin.gods.add(p.getUniqueId()); p.sendMessage("§2Sukces! §aGod zostal §awlaczony"); ChatUtil.sendTitle(p, "&8* &2&lTer&f&lXan &8*", "&8» &7God zostal &awlaczony", 15, 40, 30); } } if(args.length==1 ) { Player cel = Bukkit.getPlayerExact(args[0]); if(cel!=null) { if(plugin.gods.contains(cel.getUniqueId())) { plugin.gods.remove(cel.getUniqueId()); cel.sendMessage("§aGod zostal §cwylaczony"); sender.sendMessage("§2Sukces! §aGod §cwylaczony §adla §6 "+cel.getName()); ChatUtil.sendTitle(cel, "&8* &2&lTer&f&lXan &8*", "&8» &7God zostal &awlaczony", 15, 40, 30); return true; } else { plugin.gods.add(cel.getUniqueId()); cel.sendMessage("§aGod zostal wlaczony"); sender.sendMessage("§2Sukcess! §aGod wlaczony dla §6 "+cel.getName()); ChatUtil.sendTitle(cel, "&8* &2&lTer&f&lXan &8*", "&8» &7God zostal &cwylaczony", 15, 40, 30); } } else { p.sendMessage("§4Blad! §cPodany gracz nie jest §aONLINE!"); } } } return false; } }