示例#1
0
 public void listIgnores(IgnorePlayer player) {
   if (player.isAllIgnored()) {
     player
         .getPlayer()
         .sendMessage(plugin.getStringFromConfig("ignorecraft.messages.info.ignoreall"));
   } else {
     ArrayList<UUID> ignores = (ArrayList<UUID>) player.getIgnoreList();
     if (ignores.size() <= 0) {
       player
           .getPlayer()
           .sendMessage(plugin.getStringFromConfig("ignorecraft.messages.errors.noignores"));
     } else {
       StringBuilder s = new StringBuilder();
       s.append("&2Ignoring: ");
       for (int i = 0; i < ignores.size(); i++) {
         Player p = plugin.getServer().getPlayer(ignores.get(i));
         s.append("&e");
         s.append(p.getName());
         s.append(", ");
         if (i % 8 == 0 && i != 0) {
           player.getPlayer().sendMessage(PickleCraftPlugin.Colorize(s.toString()));
           s = new StringBuilder();
         }
       }
       String d = s.toString();
       if (!d.isEmpty()) {
         // incase not enough indexs to fire the sendmessage in le loop :c
         player.getPlayer().sendMessage(PickleCraftPlugin.Colorize(d));
       }
     }
   }
 }
示例#2
0
 @Override
 public void sendCommandList(CommandSender sender) {
   Player player = null;
   if (sender instanceof Player) {
     player = (Player) sender;
   }
   if (player != null) {
     Command c = plugin.getCommand("ignore");
     if (PickleCraftPlugin.hasPerm(player, c.getPermission())) {
       player.sendMessage(
           plugin.getStringFromConfig("ignorecraft.messages.commandhelplist.header"));
       player.sendMessage(c.getUsage() + " " + c.getDescription());
       c = plugin.getCommand("ignoreall");
       player.sendMessage(c.getUsage() + " " + c.getDescription());
       c = plugin.getCommand("ignorelist");
       player.sendMessage(c.getUsage() + " " + c.getDescription());
     }
   }
 }
 @Override
 public void onEnable() {
   taPlayerListener = new TAskPlayerListener(this);
   plugin.getServer().getPluginManager().registerEvents(taPlayerListener, plugin);
   for (Player player : plugin.getServer().getOnlinePlayers()) {
     teleportPlayerList.add(new TeleportPlayer(this, player));
   }
   /* run update on teleport players..
    * 20L = 1 second worth of ticks.
    */
   new BukkitRunnable() {
     @Override
     public void run() {
       for (TeleportPlayer player : teleportPlayerList) {
         player.Update();
       }
     }
   }.runTaskTimer(plugin, 0L, UPDATE_PERIOD);
 }
示例#4
0
 public IgnoreModule(PickleCraftPlugin plugin) {
   this.plugin = plugin;
   igFile = new File(plugin.getDataFolder() + "/ignores.json");
   if (!igFile.exists()) {
     try {
       igFile.createNewFile();
     } catch (IOException ex) {
       PickleCraftPlugin.log.log(Level.SEVERE, null, ex);
     }
   }
 }
示例#5
0
  @Override
  public void onEnable() {
    igPlayerListener = new IgnorePlayerListener(this);
    plugin.getServer().getPluginManager().registerEvents(igPlayerListener, plugin);
    plugin.getServer().getPluginManager().registerEvents(this, plugin);
    Load();

    // Automatic save after time
    new BukkitRunnable() {

      @Override
      public void run() {
        Save();
      }
    }.runTaskTimer(plugin, 0L, SAVE_PERIOD);
  }
示例#6
0
 @Override
 public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
   Player player = null;
   if (sender instanceof Player) {
     player = (Player) sender;
   }
   /*
    * ignore command.
    */
   if (command.getName().equalsIgnoreCase("ignore")) {
     if (player != null) {
       if (PickleCraftPlugin.hasPerm(player, command.getPermission())) {
         if (args.length >= 1) {
           if (args.length >= 2) {
             /*
              * flags
              */
             if (args[0].equalsIgnoreCase("-r")) { // remove ignore flag
               Object[] playerAndbool = PickleCraftPlugin.getPlayer(args[1]);
               Player p = (Player) playerAndbool[0];
               if (p != null) {
                 if ((Boolean) playerAndbool[1] == false) {
                   IgnorePlayer igP = getIgnorePlayer(player);
                   if (igP != null) {
                     igP.unignorePlayer(p.getUniqueId(), true);
                   } else {
                     player.sendMessage(
                         plugin.getStringFromConfig(
                             "ignorecraft.messages.errors.isnotignored", p.getName()));
                   }
                 } else {
                   player.sendMessage(
                       plugin.getStringFromConfig(
                           "common.messages.errors.tomanyplayers", args[1]));
                 }
                 return true;
               } else {
                 player.sendMessage(
                     plugin.getStringFromConfig(
                         "common.messages.errors.playerdontexist", args[1]));
               }
             }
           } else {
             Object[] playerAndbool = PickleCraftPlugin.getPlayer(args[0]);
             Player p = (Player) playerAndbool[0];
             if (p != null) {
               if ((Boolean) playerAndbool[1] == false) {
                 IgnorePlayer igP = getIgnorePlayer(player);
                 if (igP != null) {
                   igP.ignorePlayer(p.getUniqueId(), true);
                 } else {
                   igP = new IgnorePlayer(this, player.getUniqueId());
                   igP.ignorePlayer(p.getUniqueId(), true);
                   playerIgnoreList.add(igP);
                 }
               } else {
                 player.sendMessage(
                     plugin.getStringFromConfig("common.messages.errors.tomanyplayers", args[0]));
               }
             } else {
               player.sendMessage(
                   plugin.getStringFromConfig("common.messages.errors.playerdontexist", args[0]));
             }
             return true;
           }
         }
       } else {
         player.sendMessage(plugin.getStringFromConfig("common.messages.errors.donthaveperm"));
         return true;
       }
     } else {
       sender.sendMessage("This is a player only command.");
       return true;
     }
   } /*
      * ignoreall command
      */ else if (command.getName().equalsIgnoreCase("ignoreall")) { // all ignore
     if (player != null) {
       if (PickleCraftPlugin.hasPerm(player, command.getPermission())) {
         IgnorePlayer igP = getIgnorePlayer(player);
         if (igP != null) {
           igP.toggleAllIgnore(true);
         } else {
           igP = new IgnorePlayer(this, player.getUniqueId());
           igP.toggleAllIgnore(true);
           playerIgnoreList.add(igP);
         }
       } else {
         player.sendMessage(plugin.getStringFromConfig("common.messages.errors.donthaveperm"));
       }
     } else {
       sender.sendMessage("This is a player only command.");
     }
     return true;
   }
   /*
    * display ignore list
    */
   else if (command.getName().equalsIgnoreCase("ignorelist")) { // displays ignore list
     if (player != null) {
       IgnorePlayer igP = getIgnorePlayer(player);
       if (igP != null) {
         listIgnores(igP);
       }
     } else {
       sender.sendMessage("This is a player only command.");
     }
     return true;
   }
   return false;
 }
  /*
   * Note: This needs to be broken up and reworked.
   */
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    Player player = null;
    if (sender instanceof Player) {
      player = (Player) sender;
    }
    /** send a teleport request */
    if (command.getName().equalsIgnoreCase("tpa")) {
      if (player != null) {
        if (PickleCraftPlugin.hasPerm(player, command.getPermission())) {
          /**
           * ability for playerA to send a dual request to playerB and playerC playerC to playerB
           */
          if (args.length >= 2) {
            if (PickleCraftPlugin.hasPerm(player, "PickleCraft.teleport.dualplayers")) {
              Object[] player_B_Andbool = PickleCraftPlugin.getPlayer(args[1]);
              Object[] player_C_Andbool = PickleCraftPlugin.getPlayer(args[0]);
              Player pB = (Player) player_B_Andbool[0]; // playerB
              Player pC = (Player) player_C_Andbool[0]; // playerC
              if (pB != null) {
                if (pC != null) {
                  if ((Boolean) player_C_Andbool[1] == false) {
                    if ((Boolean) player_B_Andbool[1] == false) {
                      if (pB != pC) {
                        Command c = plugin.getCommand("tpaccept");
                        if (PickleCraftPlugin.hasPerm(pB, c.getPermission())) {
                          if (PickleCraftPlugin.hasPerm(pC, c.getPermission())) {
                            getTeleportPlayer(player)
                                .DualRequest(getTeleportPlayer(pB), getTeleportPlayer(pC));
                          } else {
                            player.sendMessage(
                                plugin.getStringFromConfig(
                                    "teleportask.messages.errors.cannotaccept", pC.getName()));
                          }
                        } else {
                          player.sendMessage(
                              plugin.getStringFromConfig(
                                  "teleportask.messages.errors.cannotaccept", pB.getName()));
                        }
                      } else {
                        player.sendMessage(
                            plugin.getStringFromConfig(
                                "common.messages.errors.sameplayer", args[0], args[1]));
                      }
                    } else {
                      player.sendMessage(
                          plugin.getStringFromConfig(
                              "common.messages.errors.tomanyplayers", args[0]));
                    }
                  } else {
                    player.sendMessage(
                        plugin.getStringFromConfig(
                            "common.messages.errors.tomanyplayers", args[1]));
                  }
                } else {
                  player.sendMessage(
                      plugin.getStringFromConfig(
                          "common.messages.errors.playerdontexist", args[1]));
                }
              } else {
                player.sendMessage(
                    plugin.getStringFromConfig("common.messages.errors.playerdontexist", args[0]));
              }
            } else {
              player.sendMessage(plugin.getStringFromConfig("common.messages.errors.donthaveperm"));
            }
            return true;
          }
          /** Standard teleport. */
          else if (args.length >= 1) {
            Object[] playerAndbool = PickleCraftPlugin.getPlayer(args[0]);
            Player p = (Player) playerAndbool[0];
            if (p != null) {
              if ((Boolean) playerAndbool[1] == false) {
                Command c = plugin.getCommand("tpaccept");
                if (PickleCraftPlugin.hasPerm(p, c.getPermission())) {
                  getTeleportPlayer(p).Request(getTeleportPlayer(player), false);
                } else {
                  player.sendMessage(
                      plugin.getStringFromConfig(
                          "teleportask.messages.errors.cannotaccept", p.getName()));
                }

              } else {
                player.sendMessage(
                    plugin.getStringFromConfig("common.messages.errors.tomanyplayers", args[0]));
              }
            } else {
              player.sendMessage(
                  plugin.getStringFromConfig("common.messages.errors.playerdontexist", args[0]));
            }
            return true;
          }
        } else {
          player.sendMessage(plugin.getStringFromConfig("common.messages.errors.donthaveperm"));
          return true;
        }
      } else {
        sender.sendMessage("This is a player only command.");
        return true;
      }
    }
    /** teleport to coordinates */
    else if (command.getName().equalsIgnoreCase("tpac")) {
      if (player != null) {
        if (PickleCraftPlugin.hasPerm(player, command.getPermission())) {
          if (args.length >= 1) {
            String[] coord = args[0].split(",");
            for (int i = 0; i < coord.length; i++) {
              coord[i] = coord[i].trim();
            }

            if (coord.length >= 2) {
              try {
                int x = Integer.parseInt(coord[0]);
                int y = 0;
                int z;
                if (coord.length >= 3) {
                  y = Integer.parseInt(coord[1]);
                  z = Integer.parseInt(coord[2]);
                } else {
                  z = Integer.parseInt(coord[1]);
                }
                if (!getTeleportPlayer(player).TeleportToCoord(x, y, z)) {
                  player.sendMessage(
                      plugin.getStringFromConfig("teleportask.messages.errors.failteleport"));
                }
              } catch (NumberFormatException e) {
                player.sendMessage(
                    plugin.getStringFromConfig("common.messages.errors.parsefail", "coordinates"));
              }
              return true;
            }
          }
        } else {
          player.sendMessage(plugin.getStringFromConfig("common.messages.errors.donthaveperm"));
          return true;
        }
      } else {
        sender.sendMessage("This is a player only command.");
        return true;
      }
    }
    /** similar to TPA but teleports playerB to playerA */
    else if (command.getName().equalsIgnoreCase("tpahere")) {
      if (player != null) {
        if (PickleCraftPlugin.hasPerm(player, command.getPermission())) {
          if (args.length >= 1) {
            Object[] playerAndbool = PickleCraftPlugin.getPlayer(args[0]);
            Player p = (Player) playerAndbool[0];
            if (p != null) {
              if ((Boolean) playerAndbool[1] == false) {
                Command c = plugin.getCommand("tpaccept");
                if (PickleCraftPlugin.hasPerm(p, c.getPermission())) {
                  getTeleportPlayer(p).Request(getTeleportPlayer(player), true);
                } else {
                  player.sendMessage(
                      plugin.getStringFromConfig(
                          "teleportask.messages.errors.cannotaccept", p.getName()));
                }
              } else {
                player.sendMessage(
                    plugin.getStringFromConfig("common.messages.errors.tomanyplayers", args[0]));
              }
            } else {
              player.sendMessage(
                  plugin.getStringFromConfig("common.messages.errors.playerdontexist", args[0]));
            }
            return true;
          }
        } else {
          player.sendMessage(plugin.getStringFromConfig("common.messages.errors.donthaveperm"));
          return true;
        }
      } else {
        sender.sendMessage("This is a player only command.");
        return true;
      }
    }
    /** accept request? */
    else if (command.getName().equalsIgnoreCase("tpaccept")) {
      if (player != null) {
        if (PickleCraftPlugin.hasPerm(player, command.getPermission())) {
          getTeleportPlayer(player).Accept();
        } else {
          player.sendMessage(plugin.getStringFromConfig("common.messages.errors.donthaveperm"));
          return true;
        }
      } else {
        sender.sendMessage("This is a player only command.");
      }
      return true;
    }
    /** Nope! chuck testa! */
    else if (command.getName().equalsIgnoreCase("tpdeny")) {
      if (player != null) {
        getTeleportPlayer(player).Deny();
      } else {
        sender.sendMessage("This is a player only command.");
      }
      return true;
    }
    /** return to last location before teleport. */
    else if (command
        .getName()
        .equalsIgnoreCase("tpareturn")) { // return to last location pior to teleport
      if (player != null) {
        if (PickleCraftPlugin.hasPerm(player, command.getPermission())) {
          getTeleportPlayer(player).ReturnToLastLocation();
        } else {
          player.sendMessage(plugin.getStringFromConfig("common.messages.errors.donthaveperm"));
          return true;
        }
      } else {
        sender.sendMessage("This is a player only command.");
      }
      return true;
    }
    return false;
  }