Exemplo n.º 1
0
 @Override
 public boolean canCommandSenderUseCommand(ICommandSender sender) {
   if (sender instanceof EntityPlayer)
     return PermissionsAPI.checkPermAllowed(
         new PermQueryPlayer((EntityPlayer) sender, getCommandPerm()));
   else return true;
 }
 public boolean checkCommandPerm(EntityPlayer player) {
   return PermissionsAPI.checkPermAllowed(new PermQueryPlayer(player, getCommandPerm()));
 }
  @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);
  }