Exemplo n.º 1
0
 public CheckCommand(ReportRTS plugin) {
   this.plugin = plugin;
   this.dbManager = DatabaseManager.getDatabase();
 }
Exemplo n.º 2
0
 public static void handleNotify(byte[] bytes) {
   try {
     DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));
     String subChannel = in.readUTF();
     if (subChannel.equals("ReportRTS")) {
       short len = in.readShort();
       byte[] msgbytes = new byte[len];
       in.readFully(msgbytes);
       DataInputStream msgin = new DataInputStream(new ByteArrayInputStream(msgbytes));
       String function = msgin.readUTF();
       if (function.equals("NotifyAndSync")) {
         int ticketId = msgin.readInt();
         NotificationType notifType = NotificationType.getTypeByCode(msgin.readInt());
         String msg = msgin.readUTF();
         if (notifType.getCode() == 0 || notifType.getCode() == 1) {
           if (RTSFunctions.syncTicket(ticketId)) {
             RTSFunctions.messageMods(msg, (notifType.getCode() == 0));
           }
         } else if (notifType.getCode() == 3 || notifType.getCode() == 4) {
           RTSFunctions.messageMods(msg, false);
         } else if (notifType.getCode() == 2 || notifType.getCode() == 5) {
           if (RTSFunctions.syncTicket(ticketId)) {
             if (notifType.getCode() == 2)
               ReportRTS.getPlugin()
                   .notificationMap
                   .put(ticketId, ReportRTS.getPlugin().requestMap.get(ticketId).getName());
             ReportRTS.getPlugin().requestMap.remove(ticketId);
             RTSFunctions.messageMods(msg, (notifType.getCode() == 0));
           }
         } else if (notifType.getCode() == 6) {
           ReportRTS.getPlugin().requestMap.remove(ticketId);
           RTSFunctions.messageMods(msg, (notifType.getCode() == 0));
         }
       } else if (function.equals("NotifyUserAndSync")) {
         int ticketId = msgin.readInt();
         String username = msgin.readUTF();
         String msg = msgin.readUTF();
         if (RTSFunctions.syncTicket(ticketId)) {
           Player player = Bukkit.getPlayerExact(username);
           if (player != null) {
             player.sendMessage(msg);
             if (!DatabaseManager.getDatabase().setNotificationStatus(ticketId, 1))
               ReportRTS.getPlugin()
                   .getLogger()
                   .warning("Unable to set notification status to 1.");
           }
         }
       } else if (function.equals("TeleportNotify")) {
         int ticketId = msgin.readInt();
         String username = msgin.readUTF();
         if (RTSFunctions.isUserOnline(username)) {
           Player player = Bukkit.getPlayerExact(username);
           if (player != null) {
             player.sendMessage(
                 Message.parse("teleportedUser", "/tp-id " + Integer.toString(ticketId)));
             Bukkit.dispatchCommand(player, "tp-id " + Integer.toString(ticketId));
           } else {
             ReportRTS.getPlugin().teleportMap.put(username, ticketId);
           }
         } else {
           ReportRTS.getPlugin().teleportMap.put(username, ticketId);
         }
       }
     } else if (subChannel.equals("GetServer")) {
       String serverName = in.readUTF();
       setServer(serverName);
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }