Esempio n. 1
0
 public boolean commandUse(CommandSender sender, String[] args) {
   Variables var = Necessities.getVar();
   if (args.length == 0) {
     sender.sendMessage(
         var.getEr() + "Error: " + var.getErMsg() + "Must enter a message to send.");
     return true;
   }
   String message = "";
   for (String arg : args) message += arg + " ";
   if (ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', message.trim()))
       .equals("")) {
     sender.sendMessage(
         var.getEr() + "Error: " + var.getErMsg() + "Must enter a message to send.");
     return true;
   }
   Bukkit.broadcastMessage(
       (sender instanceof Player ? "" : Necessities.getConsole().getName() + ChatColor.WHITE + " ")
           + ChatColor.translateAlternateColorCodes('&', message.trim()));
   return true;
 }
Esempio n. 2
0
 public boolean commandUse(CommandSender sender, String[] args) {
   Variables var = Necessities.getVar();
   if (args.length == 0) {
     sender.sendMessage(
         var.getEr() + "Error: " + var.getErMsg() + "You must enter a player to view info of.");
     return true;
   }
   GetUUID get = Necessities.getUUID();
   UUID uuid = get.getID(args[0]);
   if (uuid == null) {
     uuid = get.getOfflineID(args[0]);
     if (uuid == null || !Bukkit.getOfflinePlayer(uuid).hasPlayedBefore()) {
       sender.sendMessage(
           var.getEr()
               + "Error: "
               + var.getErMsg()
               + "That player does not exist or has not joined the server. If the player is offline, please use the full and most recent name.");
       return true;
     }
   }
   User u = Necessities.getUM().getUser(uuid);
   sender.sendMessage(
       var.getMessages()
           + "===== WhoIs: "
           + var.getObj()
           + u.getName()
           + var.getMessages()
           + " =====");
   if (u.getPlayer() != null)
     sender.sendMessage(
         var.getMessages() + " - Nick: " + ChatColor.RESET + u.getPlayer().getDisplayName());
   else {
     sender.sendMessage(
         var.getMessages()
             + (u.getNick() == null
                 ? " - Name: " + ChatColor.RESET + u.getName()
                 : " - Nick: " + ChatColor.RESET + u.getNick()));
     Calendar c = Calendar.getInstance();
     c.setTimeInMillis(Bukkit.getOfflinePlayer(uuid).getLastPlayed());
     String second = Integer.toString(c.get(Calendar.SECOND));
     String minute = Integer.toString(c.get(Calendar.MINUTE));
     String hour = Integer.toString(c.get(Calendar.HOUR_OF_DAY));
     String day = Integer.toString(c.get(Calendar.DATE));
     String month = Integer.toString(c.get(Calendar.MONTH) + 1);
     String year = Integer.toString(c.get(Calendar.YEAR));
     hour = corTime(hour);
     minute = corTime(minute);
     second = corTime(second);
     sender.sendMessage(
         var.getMessages()
             + " - Seen last on "
             + ChatColor.RESET
             + month
             + "/"
             + day
             + "/"
             + year
             + " at "
             + hour
             + ":"
             + minute
             + " and "
             + second
             + " "
             + (Integer.parseInt(second) > 1 ? "seconds" : "second"));
   }
   sender.sendMessage(
       var.getMessages() + " - Time played: " + ChatColor.RESET + u.getTimePlayed());
   sender.sendMessage(var.getMessages() + " - Rank: " + ChatColor.RESET + u.getRank().getName());
   String subranks = u.getSubranks();
   if (subranks != null)
     sender.sendMessage(var.getMessages() + " - Subranks: " + ChatColor.RESET + subranks);
   String permissions = u.getPermissions();
   if (permissions != null)
     sender.sendMessage(
         var.getMessages() + " - Permission nodes: " + ChatColor.RESET + permissions);
   if (u.getPlayer() != null) {
     Player p = u.getPlayer();
     sender.sendMessage(
         var.getMessages()
             + " - Health: "
             + ChatColor.RESET
             + (int) p.getHealth()
             + "/"
             + (int) p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
     sender.sendMessage(
         var.getMessages()
             + " - Hunger: "
             + ChatColor.RESET
             + p.getFoodLevel()
             + "/20 (+"
             + (int) p.getSaturation()
             + " saturation)");
     sender.sendMessage(
         var.getMessages()
             + " - Exp: "
             + ChatColor.RESET
             + Utils.addCommas(p.getTotalExperience())
             + " (Level "
             + p.getLevel()
             + ")");
     String location =
         "("
             + p.getWorld().getName()
             + ", "
             + p.getLocation().getBlockX()
             + ", "
             + p.getLocation().getBlockY()
             + ", "
             + p.getLocation().getBlockZ()
             + ")";
     sender.sendMessage(var.getMessages() + " - Location: " + ChatColor.RESET + location);
   }
   if (u.getPlayer() != null) {
     Player p = u.getPlayer();
     sender.sendMessage(
         var.getMessages()
             + " - IP Address: "
             + ChatColor.RESET
             + p.getAddress().toString().split("/")[1].split(":")[0]);
     sender.sendMessage(
         var.getMessages()
             + " - Gamemode: "
             + ChatColor.RESET
             + Utils.capFirst(p.getGameMode().toString()));
   }
   if (u.getPlayer() != null) {
     Player p = u.getPlayer();
     sender.sendMessage(
         var.getMessages()
             + " - Banned: "
             + (p.isBanned() ? ChatColor.GREEN + "true" : ChatColor.DARK_RED + "false"));
     sender.sendMessage(
         var.getMessages()
             + " - Visible: "
             + (Necessities.getHide().isHidden(p)
                 ? ChatColor.DARK_RED + "false"
                 : ChatColor.GREEN + "true"));
     sender.sendMessage(
         var.getMessages()
             + " - OP: "
             + (p.isOp() ? ChatColor.GREEN + "true" : ChatColor.DARK_RED + "false"));
     sender.sendMessage(
         var.getMessages()
             + " - Fly mode: "
             + (p.isFlying()
                 ? ChatColor.GREEN + "true " + ChatColor.RESET + " (flying)"
                 : ChatColor.DARK_RED + "false" + ChatColor.RESET + " (not flying)"));
   } else {
     OfflinePlayer p = Bukkit.getOfflinePlayer(u.getUUID());
     sender.sendMessage(
         var.getMessages()
             + " - Banned: "
             + (p.isBanned() ? ChatColor.GREEN + "true" : ChatColor.DARK_RED + "false"));
     sender.sendMessage(
         var.getMessages()
             + " - OP: "
             + (p.isOp() ? ChatColor.GREEN + "true" : ChatColor.DARK_RED + "false"));
   }
   sender.sendMessage(
       var.getMessages()
           + " - Muted: "
           + (u.isMuted() ? ChatColor.GREEN + "true" : ChatColor.DARK_RED + "false"));
   return true;
 }
 public boolean commandUse(CommandSender sender, String[] args) {
   Variables var = Necessities.getVar();
   if (args.length < 2) {
     sender.sendMessage(
         var.getEr()
             + "Error: "
             + var.getErMsg()
             + "Format requires you enter a name for the portal and a world that it takes you to.");
     return true;
   }
   PortalManager pm = Necessities.getPM();
   if (sender instanceof Player) {
     if (pm.exists(args[0])) {
       sender.sendMessage(
           var.getEr() + "Error: " + var.getErMsg() + "That portal already exists.");
       return true;
     }
     User u = Necessities.getUM().getUser(((Player) sender).getUniqueId());
     Location left = u.getLeft();
     Location right = u.getRight();
     if (!left.getWorld().equals(right.getWorld())) {
       sender.sendMessage(
           var.getEr()
               + "Error: "
               + var.getErMsg()
               + "Please select left and right corners of portal.");
       return true;
     }
     if (!Necessities.getWM().worldExists(args[1])) {
       if (args[1].startsWith("-")
           && Necessities.getWarps().isWarp(args[1].replaceFirst("-", ""))) {
         pm.create(args[0], args[1], left, right); // TODO messages below
         sender.sendMessage(
             var.getMessages()
                 + "Created portal "
                 + var.getObj()
                 + args[0]
                 + var.getMessages()
                 + " from "
                 + var.getObj()
                 + left.getWorld().getName()
                 + var.getMessages()
                 + " to the warp "
                 + var.getObj()
                 + args[1].replaceFirst("-", "")
                 + var.getMessages()
                 + ".");
         sender.sendMessage(
             var.getMessages()
                 + "This portal is between "
                 + var.getObj()
                 + left.getBlockX()
                 + var.getMessages()
                 + ", "
                 + var.getObj()
                 + left.getBlockY()
                 + var.getMessages()
                 + ", "
                 + var.getObj()
                 + left.getBlockZ()
                 + var.getMessages()
                 + " and "
                 + var.getObj()
                 + right.getBlockX()
                 + var.getMessages()
                 + ", "
                 + var.getObj()
                 + right.getBlockY()
                 + var.getMessages()
                 + ", "
                 + var.getObj()
                 + right.getBlockZ()
                 + var.getMessages()
                 + ".");
         return true;
       }
       sender.sendMessage(
           var.getEr() + "Error: " + var.getErMsg() + "Destination world or warp is invalid.");
       return true;
     }
     pm.create(args[0], Bukkit.getWorld(args[1]).getName(), left, right);
     sender.sendMessage(
         var.getMessages()
             + "Created portal "
             + var.getObj()
             + args[0]
             + var.getMessages()
             + " from "
             + var.getObj()
             + left.getWorld().getName()
             + var.getMessages()
             + " and "
             + var.getObj()
             + Bukkit.getWorld(args[1]).getName()
             + var.getMessages()
             + ".");
     sender.sendMessage(
         var.getMessages()
             + "This portal is between "
             + var.getObj()
             + left.getBlockX()
             + var.getMessages()
             + ", "
             + var.getObj()
             + left.getBlockY()
             + var.getMessages()
             + ", "
             + var.getObj()
             + left.getBlockZ()
             + var.getMessages()
             + " and "
             + var.getObj()
             + right.getBlockX()
             + var.getMessages()
             + ", "
             + var.getObj()
             + right.getBlockY()
             + var.getMessages()
             + ", "
             + var.getObj()
             + right.getBlockZ()
             + var.getMessages()
             + ".");
   } else
     sender.sendMessage(
         var.getEr()
             + "Error: "
             + var.getErMsg()
             + "Login to perform this command because you have to click two locations.");
   return true;
 }