コード例 #1
0
  public ArrayList<String> load() {
    ArrayList<String> players = new ArrayList<String>();

    Configuration config = new Configuration(file);

    PlayerInfo info;
    for (String cat : config.categories.keySet()) {
      if (cat.contains(".")) continue;
      else if (cat.equalsIgnoreCase(PermissionsAPI.EntryPlayer)) {
        PermissionsAPI.EPPrefix = config.get(cat, "prefix", " ").value;
        PermissionsAPI.EPSuffix = config.get(cat, "suffix", " ").value;
        continue;
      }

      info = PlayerInfo.getPlayerInfo(cat);

      if (info != null) {
        info.prefix = config.get(cat, "prefix", " ").value;
        info.suffix = config.get(cat, "suffix", " ").value;
      }

      players.add(cat);
      discardInfo(info, new String[] {});
    }

    return players;
  }
コード例 #2
0
  public PacketSelectionUpdate(PlayerInfo info) {
    packet = new Packet250CustomPayload();

    ByteArrayOutputStream streambyte = new ByteArrayOutputStream();
    DataOutputStream stream = new DataOutputStream(streambyte);

    try {
      stream.write(packetID);

      if (info != null && info.getPoint1() != null) {
        Point p1 = info.getPoint1();
        stream.writeBoolean(true);
        stream.writeInt(p1.x);
        stream.writeInt(p1.y);
        stream.writeInt(p1.z);
      } else stream.writeBoolean(false);

      if (info != null && info.getPoint2() != null) {
        Point p2 = info.getPoint2();
        stream.writeBoolean(true);
        stream.writeInt(p2.x);
        stream.writeInt(p2.y);
        stream.writeInt(p2.z);
      } else stream.writeBoolean(false);

      stream.close();
      streambyte.close();

      packet.channel = FECHANNEL;
      packet.data = streambyte.toByteArray();
      packet.length = packet.data.length;
    } catch (Exception e) {
      OutputHandler.SOP("Error creating packet >> " + this.getClass());
    }
  }
コード例 #3
0
  @Override
  public void processCommandPlayer(EntityPlayer sender, String[] args) {
    if (args.length >= 1) {
      if (!PermissionsAPI.checkPermAllowed(
          new PermQueryPlayer(sender, getCommandPerm() + ".others"))) {
        OutputHandler.chatError(sender, Localization.get(Localization.ERROR_NOPERMISSION));
        return;
      }
      EntityPlayerMP player = FunctionHelper.getPlayerForName(args[0]);
      if (player != null) {
        PlayerInfo.getPlayerInfo(player.username).back = new WarpPoint(player);

        PropQueryPlayerZone query =
            new PropQueryPlayerZone(
                player, "ForgeEssentials.BasicCommands.spawnPoint", ZoneManager.getGLOBAL(), true);
        PermissionsAPI.getPermissionProp(query);

        String val = query.getStringValue();
        String[] split = val.split("[;_]");

        int dim = Integer.parseInt(split[0]);
        int x = Integer.parseInt(split[1]);
        int y = Integer.parseInt(split[2]);
        int z = Integer.parseInt(split[3]);

        WarpPoint point =
            new WarpPoint(dim, x + .5, y + 1, z + .5, player.cameraYaw, player.cameraPitch);

        // teleport
        FunctionHelper.setPlayer(player, point);
        player.sendChatToPlayer(Localization.get("command.spawn.done"));
        return;
      } else {
        OutputHandler.chatError(sender, Localization.format(Localization.ERROR_NOPLAYER, args[0]));
        return;
      }
    } else if (args.length == 0) {
      PropQueryPlayerZone query =
          new PropQueryPlayerZone(
              sender, "ForgeEssentials.BasicCommands.spawnPoint", ZoneManager.getGLOBAL(), true);
      PermissionsAPI.getPermissionProp(query);

      String val = query.getStringValue();
      String[] split = val.split("[;_]");

      int dim = Integer.parseInt(split[0]);
      int x = Integer.parseInt(split[1]);
      int y = Integer.parseInt(split[2]);
      int z = Integer.parseInt(split[3]);

      WarpPoint spawn =
          new WarpPoint(dim, x + .5, y + 1, z + .5, sender.cameraYaw, sender.cameraPitch);
      PlayerInfo.getPlayerInfo(sender.username).back = new WarpPoint(sender);
      TeleportCenter.addToTpQue(spawn, sender);
      sender.sendChatToPlayer(Localization.get("command.spawn.done"));
    }
  }
コード例 #4
0
 @Override
 public void processCommandPlayer(EntityPlayer sender, String[] args) {
   if (args.length == 0) {
     String msg = "";
     for (String warp : CommandDataManager.warps.keySet()) {
       msg = warp + ", " + msg;
     }
     sender.sendChatToPlayer(msg);
   } else if (args.length == 1) {
     if (CommandDataManager.warps.containsKey(args[0].toLowerCase())) {
       if (PermissionsAPI.checkPermAllowed(
           new PermQueryPlayer(sender, getCommandPerm() + "." + args[0].toLowerCase()))) {
         Warp warp = CommandDataManager.warps.get(args[0].toLowerCase());
         PlayerInfo playerInfo = PlayerInfo.getPlayerInfo(sender.username);
         playerInfo.back = new WarpPoint(sender);
         TeleportCenter.addToTpQue(warp.getPoint(), sender);
       } else {
         OutputHandler.chatError(sender, Localization.get(Localization.ERROR_PERMDENIED));
       }
     } else {
       OutputHandler.chatError(sender, Localization.get("command.warp.notfound"));
     }
   } else if (args.length == 2) {
     if (PermissionsAPI.checkPermAllowed(
         new PermQueryPlayer(sender, getCommandPerm() + ".admin"))) {
       if (args[0].equalsIgnoreCase("set")) {
         if (CommandDataManager.warps.containsKey(args[1].toLowerCase())) {
           OutputHandler.chatError(sender, Localization.get("command.warp.alreadyexists"));
         } else {
           CommandDataManager.addWarp(new Warp(args[1].toLowerCase(), new WarpPoint(sender)));
           OutputHandler.chatConfirmation(sender, Localization.get(Localization.DONE));
         }
       } else if (args[0].equalsIgnoreCase("del")) {
         if (CommandDataManager.warps.containsKey(args[1].toLowerCase())) {
           CommandDataManager.removeWarp(CommandDataManager.warps.get(args[1]));
           OutputHandler.chatConfirmation(sender, Localization.get(Localization.DONE));
         } else {
           OutputHandler.chatError(sender, Localization.get("command.warp.notfound"));
         }
       } else {
         OutputHandler.chatError(
             sender, Localization.get(Localization.ERROR_BADSYNTAX) + getSyntaxPlayer(sender));
       }
     } else {
       OutputHandler.chatError(sender, Localization.get(Localization.ERROR_PERMDENIED));
     }
   }
 }
コード例 #5
0
  @Override
  public void onComplete() {
    PlayerInfo.getPlayerInfo(player).addUndoAction(backup);

    String confirmMessage = "";
    switch (this.effectMode) {
      case THAW:
        confirmMessage = "thaw";
        break;
      case FREEZE:
        confirmMessage = "freeze";
        break;
      case SNOW:
        confirmMessage = "snow";
        break;
      case TILL:
        confirmMessage = "till";
        break;
      case UNTILL:
        confirmMessage = "untill";
        break;
    }
    OutputHandler.chatConfirmation(
        player, Localization.format("message.wc." + confirmMessage + "Confirm", this.changed));
  }
コード例 #6
0
  @Override
  public void processCommandConsole(ICommandSender sender, String[] args) {
    if (args.length >= 1) {
      EntityPlayerMP player = FunctionHelper.getPlayerForName(args[0]);
      if (player != null) {
        PlayerInfo.getPlayerInfo(player.username).back = new WarpPoint(player);

        WarpPoint spawn;
        ChunkCoordinates point =
            FMLCommonHandler.instance()
                .getMinecraftServerInstance()
                .worldServers[0]
                .provider
                .getSpawnPoint();
        spawn =
            new WarpPoint(
                0, point.posX, point.posY, point.posZ, player.rotationPitch, player.rotationYaw);
        TeleportCenter.addToTpQue(spawn, player);
        player.sendChatToPlayer(Localization.get("command.spawn.done"));
        return;
      } else {
        OutputHandler.chatError(sender, Localization.format(Localization.ERROR_NOPLAYER, args[0]));
        return;
      }
    }
  }
コード例 #7
0
  public void save(ArrayList<String> players) {
    // clear it.
    if (file.exists()) file.delete();

    String[] allPlayers =
        FMLCommonHandler.instance()
            .getSidedDelegate()
            .getServer()
            .getConfigurationManager()
            .getAllUsernames();

    Configuration config = new Configuration(file);

    PlayerInfo info;
    for (String name : players) {
      if (name.equalsIgnoreCase(PermissionsAPI.EntryPlayer)) {
        config.get(name, "prefix", PermissionsAPI.EPPrefix);
        config.get(name, "suffix", PermissionsAPI.EPSuffix);
        continue;
      }

      info = PlayerInfo.getPlayerInfo(name);
      config.get(name, "prefix", info.prefix == null ? "" : info.prefix);
      config.get(name, "suffix", info.suffix == null ? "" : info.suffix);
      discardInfo(info, allPlayers);
    }

    config.save();
  }
コード例 #8
0
 @Override
 public void processCommandConsole(ICommandSender sender, String[] args) {
   if (args.length == 2) {
     if (CommandDataManager.warps.containsKey(args[1].toLowerCase())) {
       EntityPlayerMP player = FunctionHelper.getPlayerForName(sender, args[0]);
       if (player != null) {
         Warp warp = CommandDataManager.warps.get(args[1].toLowerCase());
         PlayerInfo.getPlayerInfo(player.username).back = new WarpPoint(player);
         TeleportCenter.addToTpQue(warp.getPoint(), player);
       } else {
         OutputHandler.chatError(
             sender, Localization.format(Localization.ERROR_NOPLAYER, args[0]));
       }
     } else {
       OutputHandler.info("CommandBlock Error: " + Localization.get("command.warp.notfound"));
     }
   }
 }
コード例 #9
0
  @Override
  public String getResponceString(DatagramPacket packet) {
    LinkedHashMap<String, String> PlayerData = new LinkedHashMap();
    LinkedHashMap<String, String> tempMap = new LinkedHashMap();
    ArrayList<String> tempArgs = new ArrayList();

    String username = new String(Arrays.copyOfRange(packet.getData(), 11, packet.getLength()));
    EntityPlayerMP player = server.getConfigurationManager().getPlayerForUsername(username.trim());
    if (player == null) {
      return "";
    }

    PlayerInfo pi = PlayerInfo.getPlayerInfo(player);
    if (pi != null && sendhome) {
      if (pi.home != null) {
        PlayerData.put("home", TextFormatter.toJSON(pi.home));
      }
      if (pi.back != null) {
        PlayerData.put("back", TextFormatter.toJSON(pi.back));
      }
    }

    if (sendArmorAndHealth) {
      PlayerData.put("armor", "" + player.inventory.getTotalArmorValue());
      PlayerData.put("health", "" + player.getHealth());
    }

    PlayerData.put("wallet", "" + Wallet.getWallet(player));
    PlayerData.put("pos", TextFormatter.toJSON(new WorldPoint(player)));
    PlayerData.put("ping", "" + player.ping);
    PlayerData.put("gm", player.theItemInWorldManager.getGameType().getName());

    if (!player.getActivePotionEffects().isEmpty() && sendpotions) {
      PlayerData.put("potion", TextFormatter.toJSON(player.getActivePotionEffects()));
    }

    if (sendXP) {
      tempMap.clear();
      tempMap.put("lvl", "" + player.experienceLevel);
      tempMap.put("bar", "" + player.experience);
      PlayerData.put("xp", TextFormatter.toJSON(tempMap));
    }

    if (sendFood) {
      tempMap.clear();
      tempMap.put("food", "" + player.getFoodStats().getFoodLevel());
      tempMap.put("saturation", "" + player.getFoodStats().getSaturationLevel());
      PlayerData.put("foodStats", TextFormatter.toJSON(tempMap));
    }

    if (sendCapabilities) {
      tempMap.clear();
      tempMap.put("edit", "" + player.capabilities.allowEdit);
      tempMap.put("allowFly", "" + player.capabilities.allowFlying);
      tempMap.put("isFly", "" + player.capabilities.isFlying);
      tempMap.put("noDamage", "" + player.capabilities.disableDamage);
    }
    PlayerData.put("cap", TextFormatter.toJSON(tempMap));

    try {
      Group group = PermissionsAPI.getHighestGroup(player);
      PlayerData.put("group", group.name);
    } catch (Exception e) {
    }

    return dataString = TextFormatter.toJSON(PlayerData);
  }
コード例 #10
0
  private void discardInfo(PlayerInfo info, String[] allPlayers) {
    for (String name : allPlayers) if (info.username.equalsIgnoreCase(name)) return;

    // not logged in?? kill it.
    PlayerInfo.discardInfo(info.username);
  }