public Town(
     String ID,
     String Country,
     String Mayor,
     Plot TownHallPlot,
     String TT,
     Integer TaxRate,
     Boolean PVP,
     Boolean FreeBuild,
     Location SpawnLocation,
     Integer Coffers,
     Integer Health,
     String Color,
     String MOTD,
     Integer Size) {
   super(ID);
   setCountry(Country);
   setMayor(Mayor);
   setTownHallPlot(TownHallPlot);
   setTaxType(TaxType.valueOf(TT.toUpperCase()));
   setTax(TaxRate);
   setPVPAllowed(PVP);
   setFreeBuildAllowed(FreeBuild);
   setSpawnLocation(SpawnLocation);
   setCoffers(Coffers);
   setHealth(Health);
   setColor(ChatColor.valueOf(Color));
   setMOTD(MOTD);
   setSize(Size);
   setFormattedID(this.getColor() + this.getID() + Main.messageColor);
 }
Exemple #2
0
 public static ChatColor getColor(String s) {
   ChatColor col = ChatColor.getByChar(s);
   if (col != null) return col;
   col = ChatColor.valueOf(s.toUpperCase());
   if (col != null) return col;
   return ChatColor.WHITE; // Didn't give us a proper color.
 }
 /**
  * Returns the {@link ChatColor} prefixed to the nameplate
  *
  * @return The stored {@link ChatColor}
  */
 public ChatColor getColor() {
   try {
     return ChatColor.valueOf(colors.get(DEFAULT_KEY));
   } catch (Exception e) {
     return ChatColor.YELLOW;
   }
 }
Exemple #4
0
  public void loadValues(Scavenger plug) {
    debugEnabled = config.getBoolean(DEBUG_ENABLED, false);

    economyEnabled = config.getBoolean(ECONOMY_ENABLED, false);
    restoreCost = config.getDouble(ECONOMY_RESTORECOST, 10.0);
    percent = config.getBoolean(ECONOMY_PERCENT, false);
    minCost = config.getDouble(ECONOMY_MINCOST, 5.0);
    maxCost = config.getDouble(ECONOMY_MAXCOST, 0.0);
    percentCost = config.getDouble(ECONOMY_PERCENTCOST, 5.0);
    addMin = config.getBoolean(ECONOMY_ADDMIN, false);
    chanceToDrop = config.getInt(ECONOMY_DROP_CHANCE, 0);
    slotBasedRecovery = config.getBoolean(GLOBAL_SLOT_RECOVERY, false);

    shouldNotify = config.getBoolean(SHOULD_NOTIFY, true);
    singleItemDrops = config.getBoolean(GLOBAL_SIDROPS, false);
    singleItemDropsOnly = config.getBoolean(GLOBAL_SIDROPS_ONLY, false);
    permsEnabled = config.getBoolean(GLOBAL_PERMS, true);
    wgPVPIgnore = config.getBoolean(GLOBAL_WGPVPIGNORE, false);
    wgGuardPVPOnly = config.getBoolean(GLOBAL_WGPVPONLY, false);
    opsAllPerms = config.getBoolean(GLOBAL_OPSALLPERMS, true);
    factionEnemyDrops = config.getBoolean(GLOBAL_FACTIONENEMYDROPS, false);
    offlineMode = config.getBoolean(GLOBAL_OFFLINEMODE, false);
    dungeonMaze = config.getBoolean(GLOBAL_DUNGEONMAZE, false);
    residence = config.getBoolean(GLOBAL_RESIDENCE, false);
    resFlag = config.getString(GLOBAL_RESFLAG, "noscv");
    dropOnPVPDeath = config.getBoolean(GLOBAL_DROPONPVPDEATH, false);
    headerColor = ChatColor.valueOf(config.getString(GLOBAL_COLOR, "GOLD").toUpperCase());
    textColor = ChatColor.valueOf(config.getString(GLOBAL_TEXTCOLOR, "WHITE").toUpperCase());
    languageFileName = config.getString(GLOBAL_LANGUAGE, "English.yml");
    for (String s : config.getStringList(BLACKLISTED_WORLDS)) {
      blacklistedworlds.add(s.toLowerCase());
    }
    for (String s : config.getStringList(BLACKLISTED_WGREGIONS)) {
      blacklistedWGRegions.add(s.toLowerCase());
    }
    restoreDelayTicks = config.getInt(GLOBAL_RESTOREDELAY, 10);

    initLangFiles(plug);
    loadLanguage(plug);
  }
  public ChatColor getOperatorColor() throws Exception {
    String colorName = config.getString("ops-name-color", null);

    if (colorName == null) return ChatColor.RED;
    if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty()) throw new Exception();

    try {
      return ChatColor.valueOf(colorName.toUpperCase());
    } catch (IllegalArgumentException ex) {
    }

    return ChatColor.getByCode(Integer.parseInt(colorName, 16));
  }
Exemple #6
0
  public static String getColor(Player player, LivingEntity target) {
    if ((target instanceof Player)) {
      for (String arg : default_colours.keySet()) {
        if (((arg.equals("op")) && (((Player) target).isOp()))
            || (arg.equals("default"))
            || (((Player) target).hasPermission(arg))) {
          String color = (String) default_colours.get(arg);
          if (color.matches("[0-9a-f]")) {
            return new StringBuilder().append("§").append(color).toString();
          }
          return ChatColor.valueOf(color.toUpperCase()).toString();
        }
      }
      return ((Player) target).isOp() ? ChatColor.GOLD.toString() : ChatColor.YELLOW.toString();
    }
    if ((target instanceof Monster)) {
      if ((player != null) && (player.equals(((Monster) target).getTarget()))) {
        return ChatColor.RED.toString();
      }
      return ChatColor.YELLOW.toString();
    }
    if ((target instanceof WaterMob)) return ChatColor.GREEN.toString();
    if ((target instanceof Flying)) return ChatColor.YELLOW.toString();
    if ((target instanceof Animals)) {
      if ((player != null) && (player.equals(((Animals) target).getTarget())))
        return ChatColor.RED.toString();
      if ((target instanceof Tameable)) {
        Tameable pet = (Tameable) target;
        if (pet.isTamed()) {
          return ChatColor.GREEN.toString();
        }
        return ChatColor.YELLOW.toString();
      }

      return ChatColor.GRAY.toString();
    }

    return ChatColor.GRAY.toString();
  }
 /**
  * Deserializes a fancy message from its JSON representation. This JSON representation is of the
  * format of that returned by {@link #toJSONString()}, and is compatible with vanilla inputs.
  *
  * @param json The JSON string which represents a fancy message.
  * @return A {@code FancyMessage} representing the parameterized JSON message.
  */
 public static FancyMessage deserialize(String json) {
   JsonObject serialized = _stringParser.parse(json).getAsJsonObject();
   JsonArray extra = serialized.getAsJsonArray("extra"); // Get the extra component
   FancyMessage returnVal = new FancyMessage();
   returnVal.messageParts.clear();
   for (JsonElement mPrt : extra) {
     MessagePart component = new MessagePart();
     JsonObject messagePart = mPrt.getAsJsonObject();
     for (Map.Entry<String, JsonElement> entry : messagePart.entrySet()) {
       // Deserialize text
       if (TextualComponent.isTextKey(entry.getKey())) {
         // The map mimics the YAML serialization, which has a "key" field and one or more "value"
         // fields
         Map<String, Object> serializedMapForm =
             new HashMap<
                 String, Object>(); // Must be object due to Bukkit serializer API compliance
         serializedMapForm.put("key", entry.getKey());
         if (entry.getValue().isJsonPrimitive()) {
           // Assume string
           serializedMapForm.put("value", entry.getValue().getAsString());
         } else {
           // Composite object, but we assume each element is a string
           for (Map.Entry<String, JsonElement> compositeNestedElement :
               entry.getValue().getAsJsonObject().entrySet()) {
             serializedMapForm.put(
                 "value." + compositeNestedElement.getKey(),
                 compositeNestedElement.getValue().getAsString());
           }
         }
         component.text = TextualComponent.deserialize(serializedMapForm);
       } else if (MessagePart.stylesToNames.inverse().containsKey(entry.getKey())) {
         if (entry.getValue().getAsBoolean()) {
           component.styles.add(MessagePart.stylesToNames.inverse().get(entry.getKey()));
         }
       } else if (entry.getKey().equals("color")) {
         component.color = ChatColor.valueOf(entry.getValue().getAsString().toUpperCase());
       } else if (entry.getKey().equals("clickEvent")) {
         JsonObject object = entry.getValue().getAsJsonObject();
         component.clickActionName = object.get("action").getAsString();
         component.clickActionData = object.get("value").getAsString();
       } else if (entry.getKey().equals("hoverEvent")) {
         JsonObject object = entry.getValue().getAsJsonObject();
         component.hoverActionName = object.get("action").getAsString();
         if (object.get("value").isJsonPrimitive()) {
           // Assume string
           component.hoverActionData = new JsonString(object.get("value").getAsString());
         } else {
           // Assume composite type
           // The only composite type we currently store is another FancyMessage
           // Therefore, recursion time!
           component.hoverActionData =
               deserialize(
                   object
                       .get("value")
                       .toString() /* This should properly serialize the JSON object as a JSON string */);
         }
       }
     }
     returnVal.messageParts.add(component);
   }
   return returnVal;
 }
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    // if not a player... we are done.
    if (!(sender instanceof Player)) return false;

    Player admin = null;
    if ((sender instanceof Player)) {
      admin = (Player) sender;
    }

    // Future Development!
    // Want to be able force in and force out
    //		if(cmd.getName().equalsIgnoreCase("force"))
    //		{
    //
    //
    //			if(plugin.getMetadata(admin, "cindyk.canmute", plugin)==true)
    //			{
    //
    //
    //					if (args.length < 2)
    //					{
    //
    //						 return false;
    //					}
    //
    //					if(args.length == 2)
    //					{
    //						Player player = plugin.getServer().getPlayer(args [0]);
    //						if(player != null){
    //							for(ChatChannel chname:cc.getChannelsInfo())
    //							{
    //
    //
    //								player.setMetadata("listenchannel."+chname.getName(),new
    // FixedMetadataValue(plugin,true));
    //
    //								player.setMetadata("currentchannel",new FixedMetadataValue(plugin,chname.getName()));
    //								return true;
    //							}
    //						}
    //					}
    //			}
    //
    //		}

    // Need to check for permission before checking for command
    if (cmd.getName().equalsIgnoreCase("mute")) {
      if (plugin.getMetadata(admin, "mumblechat.canmute", plugin)) {
        //	plugin.getServer().getLogger().info("Got Mute!");

        if (args.length < 2) {
          //				 plugin.getServer().getLogger().info("Command is /derpmute [player] [channel]");
          //				 if (!(admin==null))
          //				 {
          //					 admin.sendMessage("Command is /derpmute [player] [channel]");
          //
          //				 }
          admin.sendMessage(ChatColor.WHITE + "Invalid command: /mute [player] [channel]");
          return false;
        }

        Player player = null;
        player = sender.getServer().getPlayerExact(args[0]);
        if (player == null) {
          //		 plugin.getServer().getLogger().info("Can't mute. Player "+ args[0] + " doesn't
          // exist.");
          if (!(admin == null)) {
            admin.sendMessage(ChatColor.RED + "Can't mute. Player " + args[0] + " doesn't exist.");
          }
          return false;
        }

        for (ChatChannel c : cc.getChannelsInfo()) {
          if (c.getName().equalsIgnoreCase(args[1]) || c.getAlias().equalsIgnoreCase(args[1])) {
            if (c.isMuteable()) {
              plugin.logme(
                  LOG_LEVELS.INFO,
                  "Muting Player",
                  " In Channel : " + c.getName() + " Player Name: " + args[0]);
              player.setMetadata("MumbleMute." + c.getName(), new FixedMetadataValue(plugin, true));
              admin.sendMessage(
                  ChatColor.RED
                      + "Muted player: "
                      + ChatColor.WHITE
                      + " "
                      + args[0]
                      + ChatColor.RED
                      + " in: "
                      + ChatColor.valueOf(c.getColor().toUpperCase())
                      + c.getName());
              player.sendMessage(
                  ChatColor.RED
                      + "You have just been muted in "
                      + ChatColor.valueOf(c.getColor().toUpperCase())
                      + c.getName());

            } else
              admin.sendMessage(
                  ChatColor.RED + "You cannot mute players in this channel: " + c.getName());

            return true;
          }
        }

        //	 plugin.getServer().getLogger().info("Can't mute. Channel "+ args[1] + " doesn't exist.
        // global or local");
        if (!(admin == null)) {
          admin.sendMessage(ChatColor.RED + "Can't mute. Channel " + args[1] + " doesn't exist.");
        }
        return false;
      } // Has permissions...
      else {
        admin.sendMessage(ChatColor.DARK_PURPLE + "You do not have permission for this command.");
        return true;
      }
    }

    if (cmd.getName().equalsIgnoreCase("unmute")) {
      if (plugin.getMetadata(admin, "mumblechat.canmute", plugin)) {
        plugin.logme(LOG_LEVELS.DEBUG, "Unmute command", "Got Command...");

        if (args.length < 2) {
          return false;
        }

        Player player = null;
        player = sender.getServer().getPlayerExact(args[0]);
        if (player == null) {
          //		 plugin.getServer().getLogger().info("Can't mute. Player "+ args[0] + " doesn't
          // exist.");
          if (!(admin == null)) {
            admin.sendMessage(
                ChatColor.RED + "Can't unmute. Player " + args[0] + " doesn't exist.");
          }
          return false;
        }

        for (ChatChannel c : cc.getChannelsInfo()) {
          if (c.getName().equalsIgnoreCase(args[1]) || c.getAlias().equalsIgnoreCase(args[1])) {
            plugin.logme(
                LOG_LEVELS.INFO,
                "Unmuting Player",
                " In Channel : " + c.getName() + " Player Name: " + args[0]);
            player.setMetadata("MumbleMute." + c.getName(), new FixedMetadataValue(plugin, false));
            admin.sendMessage(
                ChatColor.RED
                    + "unMuted Player "
                    + args[0]
                    + " in "
                    + ChatColor.valueOf(c.getColor().toUpperCase())
                    + c.getName());
            player.sendMessage(
                ChatColor.RED
                    + "You have just been unmuted in "
                    + ChatColor.valueOf(c.getColor().toUpperCase())
                    + c.getName());
            return true;
          }
        }

        //	 plugin.getServer().getLogger().info("Can't mute. Channel "+ args[1] + " doesn't exist.
        // global or local");
        if (!(admin == null)) {
          admin.sendMessage(ChatColor.RED + "Can't unmute. Channel " + args[1] + " doesn't exist.");
        }
        return false;
      } // Has permissions...
      else {
        admin.sendMessage(ChatColor.DARK_PURPLE + "You do not have permission for this command.");
        return true;
      }
    }

    return false;
  }
Exemple #9
0
  public void finalizeItem() {

    if (!getConfig().contains("Items." + getOriginalName())) Tools.writeConfigEntries(this);

    try {
      this.itemColor =
          ChatColor.valueOf(
              Main.config.getString("Items." + getOriginalName() + ".Color").toUpperCase());
    } catch (Exception e) {
      Bukkit.getConsoleSender()
          .sendMessage(
              ChatColor.RED
                  + "[CE] The color of the Custom Item '"
                  + getOriginalName()
                  + "' is invalid, please check the official Bukkit list of ChatColors.");
      this.itemColor = ChatColor.AQUA;
    }
    this.displayName =
        itemColor + Main.config.getString("Items." + getOriginalName() + ".DisplayName");
    this.description =
        new ArrayList<String>(
            Arrays.asList(
                Main.config.getString("Items." + getOriginalName() + ".Description").split(";")));
    this.cooldownTime =
        Long.parseLong(Main.config.getString("Items." + getOriginalName() + ".Cooldown"));

    for (String s : description)
      description.set(description.indexOf(s), ChatColor.GRAY + "" + ChatColor.ITALIC + s);

    // If the item has a special line, this whitespace is required
    this.description.add("");

    try {
      for (String entry : this.configEntries) {
        String[] split = entry.split(": ");
        if (split[1].equalsIgnoreCase("true") || split[1].equalsIgnoreCase("false"))
          if (!getConfig().contains("Items." + getOriginalName() + "." + split[0])) {
            Tools.writeConfigEntries(this);
            break;
          }
      }
      initConfigEntries();
    } catch (Exception e) {
      if (!hasRetriedConfig) {
        Tools.writeConfigEntries(this);
        hasRetriedConfig = true;
        finalizeItem();
      } else {
        Bukkit.getConsoleSender()
            .sendMessage(
                ChatColor.RED
                    + "[CE] WARNING: Could not configurate the CE-Item '"
                    + getOriginalName()
                    + "',");
        Bukkit.getConsoleSender()
            .sendMessage(
                ChatColor.RED
                    + "     		 please check the config for any errors, the item is now disabled. ");
        Bukkit.getConsoleSender()
            .sendMessage(ChatColor.RED + "     	Explicit error: " + e.getMessage());
        Main.items.remove(this);
      }
    }

    // Add an empty line to the end if the last line is not already one
    // This is just for stylistic purposes
    if (this.description.get(description.size() - 1).length() > 0) this.description.add("");
  }
 /**
  * Returns the {@link ChatColor} prefixed to the nameplate for a specific player.
  *
  * @param player The player name
  * @return The stored {@link ChatColor} for the specific player
  */
 public ChatColor getColor(String player) {
   if (!colors.containsKey(player)) return getColor();
   else return ChatColor.valueOf(colors.get(player));
 }
Exemple #11
0
  public GameMap(
      FileConfiguration conf,
      int mapId,
      GameType type,
      int time,
      World world,
      String mapName,
      String author,
      String worldName,
      Location spawn,
      List<GameSpawns> spawnCoords,
      List<TeamMap> teams,
      int maxPerTeam,
      List<ItemStack> items,
      List<String> specialfeatures)
      throws IOException {

    this.mapid = mapId;
    this.world = world;
    this.time = time;
    this.worldName = worldName;
    this.type = type;
    this.mapName = mapName;
    this.author = author;
    this.X = spawn.getX();
    this.Y = spawn.getY();
    this.Z = spawn.getZ();

    this.spawnCoords = spawnCoords;
    this.mapRegions = new ArrayList<Region>();
    this.playerTeams = new HashMap<String, TeamMap>();
    // this.monuments = new HashMap<TeamMap, List<Region>>();
    this.teams = teams;
    this.items = items;
    this.maxPlayers = maxPerTeam;
    this.features = specialfeatures;

    try {

      List<Integer> regions = new ArrayList<Integer>();

      for (int i = 0; i < 20; i++) {

        if (conf.contains("Settings.Regions." + i)) {
          regions.add(i);
        }
      }

      for (int id : regions) {

        List<ChatColor> whitelist = new ArrayList<ChatColor>();

        if (!conf.contains("Settings.Regions." + id + ".TeamWhitelist")) {
          System.out.println("amg!! :o " + mapName);
        }

        for (String color : conf.getStringList("Settings.Regions." + id + ".TeamWhitelist")) {

          if (color.length() == 0 || color == null) {
            continue;
          }

          whitelist.add(ChatColor.valueOf(color));
        }

        List<Material> blocks = new ArrayList<Material>();

        for (String material : conf.getStringList("Settings.Regions." + id + ".Blocks")) {

          if (material.length() == 0 || material == null) {
            continue;
          }

          blocks.add(Material.valueOf(material));
        }

        int maxX = conf.getInt("Settings.Regions." + id + ".MaxX");
        int maxY = conf.getInt("Settings.Regions." + id + ".MaxY");
        int maxZ = conf.getInt("Settings.Regions." + id + ".MaxZ");

        int minX = conf.getInt("Settings.Regions." + id + ".MinX");
        int minY = conf.getInt("Settings.Regions." + id + ".MinY");
        int minZ = conf.getInt("Settings.Regions." + id + ".MinZ");

        String regionType = conf.getString("Settings.Regions." + id + ".Type");
        String regionAlert = conf.getString("Settings.Regions." + id + ".Alert");

        Region region =
            new Region(
                this.world,
                RegionType.toValue(regionType),
                whitelist,
                blocks,
                regionAlert,
                maxX,
                maxY,
                maxZ,
                minX,
                minY,
                minZ);
        this.mapRegions.add(region);

        /*if (region.getType() == RegionType.DTM && this.type == GameType.DTM) {

        	TeamMap map = Helpers.getTeam(region.getTeamWhitelist().get(0));

        	if (!this.monuments.containsKey(map)) {
        		this.monuments.put(map, new ArrayList<Region>());
        		this.monuments.get(map).add(region);
        	} else {
        		this.monuments.get(map).add(region);
        	}

        }*/
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }