SHARE
TWEET

Untitled

a guest Aug 19th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.desmin88.getsatisfaction;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Properties;
  5. import java.util.Set;
  6. import java.util.logging.Logger;
  7.  
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.plugin.java.JavaPlugin;
  12.  
  13. public class Main extends JavaPlugin {
  14.     Logger log = Logger.getLogger("Minecraft");
  15.     Properties p;
  16.     HashMap<Player, Boolean> playerMap = new HashMap<Player, Boolean>();
  17.  
  18.     @Override
  19.     public void onDisable() {
  20.         getServer().getScheduler().cancelTasks(this);
  21.         log.info("GetSatisfaction: Disabled");
  22.     }
  23.  
  24.     @Override
  25.     public void onEnable() {
  26.         getServer().getScheduler().scheduleSyncRepeatingTask(this,
  27.                 new masterTicket(), 6000L, 6000L);
  28.         log.info("GetSatisfaction: Enabled");
  29.     }
  30.  
  31.     public class masterTicket implements Runnable {
  32.         public void run() {
  33.             Set<Player> playerSet = playerMap.keySet();
  34.             for (Object o : playerSet) {
  35.                 if (playerMap.get(o) == false) {
  36.                     Player player = (Player) o;
  37.                     player.performCommand("gethelp");
  38.                 }
  39.             }
  40.         }
  41.     }
  42.  
  43.     public boolean onCommand(CommandSender sender, Command command,
  44.             String label, String[] args) {
  45.         String[] split = args;
  46.         if (sender instanceof Player) {
  47.             Player player = (Player) sender;
  48.             if (label.equalsIgnoreCase("gethelp")) {
  49.                 if (split.length == 0) {
  50.                     playerMap.put(player, false);
  51.                     sendMessage(player.getName());
  52.                     if (split.length == 1) {
  53.                         if (getServer().getPlayer(args[0]) instanceof Player)
  54.                             playerMap.put(getServer().getPlayer(args[0]), true);
  55.                         getServer()
  56.                                 .getPlayer(args[0])
  57.                                 .sendMessage(
  58.                                         player.getName()
  59.                                                 + " is now assissting you with your error. If they do not, resend /gethelp");
  60.                     }
  61.                 }
  62.             }
  63.         }
  64.         return false;
  65.     }
  66.  
  67.     public void sendMessage(String name) {
  68.         Player[] pList = getServer().getOnlinePlayers();
  69.         for (Player player : pList) {
  70.             if (player.isOp()) {
  71.                 player.sendMessage("Player added to help ticket!" + name
  72.                         + "needs help! Please assist him!");
  73.             }
  74.         }
  75.     }
  76.  
  77. }
RAW Paste Data
Top