Guest User

Untitled

a guest
May 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. package me.empirebattles.checkingame;
  2.  
  3. import java.util.logging.Logger;
  4.  
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandSender;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.plugin.Plugin;
  9. import org.bukkit.plugin.PluginManager;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11.  
  12. import com.palmergames.bukkit.towny.NotRegisteredException;
  13. import com.palmergames.bukkit.towny.TownyFormatter;
  14. import com.palmergames.bukkit.towny.object.Resident;
  15. import com.palmergames.bukkit.towny.object.TownyUniverse;
  16.  
  17. //import net.citizensnpcs.api.CitizensManager;
  18.  
  19. public class checkingame extends JavaPlugin {
  20. Logger log = Logger.getLogger("Minecraft");
  21.  
  22. public void onEnable(){
  23. PluginManager pm = this.getServer().getPluginManager();
  24. Plugin test = pm.getPlugin("Towny");
  25. if (test != null) {
  26. System.out.println("Successfully hooked into Towny!");
  27. } else {
  28. System.out.println("Towny isn't loaded.");
  29. // disable plugin because Towny was not loaded
  30. pm.disablePlugin(this);
  31. }
  32. log.info("CheckInGame has been enabled!");
  33. }
  34.  
  35. public void onDisable(){
  36.  
  37. }
  38.  
  39. private Resident getResident(Player player)
  40. {
  41. try
  42. {
  43. return TownyUniverse.plugin.getTownyUniverse().getResident(player.getName());
  44. }
  45. catch (Exception ex)
  46. {
  47. return null;
  48. }
  49. }
  50. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
  51. if(cmd.getName().equalsIgnoreCase("ebtowny")){
  52. if (args.length>0)
  53. {
  54. if(sender.hasPermission("some.pointless.permission"))
  55. {
  56. Resident resident=getResident(((Player) sender));
  57. String town = resident.getTown().getName();
  58. sender.sendMessage("Your town name: "+town);
  59. }
  60. else
  61. {
  62. //Do something else
  63. }
  64. }
  65. return true;
  66. }
  67. return false;
  68. }
  69. }
Add Comment
Please, Sign In to add comment