예제 #1
0
 public boolean isCommandRestricted(String label) {
   for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0))) {
     if (!c.equalsIgnoreCase(label)) continue;
     return true;
   }
   return config.getBoolean("restrict-" + label.toLowerCase(), false);
 }
예제 #2
0
	public void setHome(String name, Location loc)
	{
		//Invalid names will corrupt the yaml
		name = StringUtil.safeString(name);
		homes.put(name, loc);
		config.setProperty("homes." + name, loc);
		config.save();
	}
예제 #3
0
 private void setUser(final String username, final String address, final boolean spy) {
   final Map<String, Object> userdata = new HashMap<String, Object>();
   userdata.put(ADDRESS, address);
   userdata.put(SPY, spy);
   users.setProperty(username, userdata);
   users.save();
   reloadConfig();
 }
예제 #4
0
	public Set<String> getConfigKeys()
	{
		if (config.isConfigurationSection("info"))
		{
			return config.getConfigurationSection("info").getKeys(true);
		}
		return new HashSet<String>();
	}
예제 #5
0
	public Map<String, Object> getConfigMap(String node)
	{
		if (config.isConfigurationSection("info." + node))
		{
			return config.getConfigurationSection("info." + node).getValues(true);
		}
		return new HashMap<String, Object>();
	}
예제 #6
0
	private Map<String, Object> _getPowertools()
	{
		if (config.isConfigurationSection("powertools"))
		{
			return config.getConfigurationSection("powertools").getValues(false);
		}
		return new HashMap<String, Object>();
	}
예제 #7
0
 public boolean isCommandOverridden(String name) {
   List<String> defaultList = new ArrayList<String>(1);
   defaultList.add("god");
   for (String c : config.getStringList("overridden-commands", defaultList)) {
     if (!c.equalsIgnoreCase(name)) continue;
     return true;
   }
   return config.getBoolean("override-" + name.toLowerCase(), false);
 }
예제 #8
0
 public Map<String, String> getEpDBSettings() {
   Map<String, String> epSettings = new HashMap<String, String>();
   epSettings.put("protect.datatype", config.getString("protect.datatype", "sqlite"));
   epSettings.put("protect.username", config.getString("protect.username", "root"));
   epSettings.put("protect.password", config.getString("protect.password", "root"));
   epSettings.put(
       "protect.mysqlDb",
       config.getString("protect.mysqlDb", "jdbc:mysql://localhost:3306/minecraft"));
   return epSettings;
 }
예제 #9
0
	public void setLogoutLocation(Location loc)
	{
		if (loc == null || loc.getWorld() == null)
		{
			return;
		}
		logoutLocation = loc;
		config.setProperty("logoutlocation", loc);
		config.save();
	}
예제 #10
0
 public final String getUserByAddress(final String search) {
   final List<String> usernames = users.getKeys(null);
   for (String username : usernames) {
     final String address = users.getString(username + "." + ADDRESS, null);
     if (address != null && search.equalsIgnoreCase(address)) {
       return username;
     }
   }
   return null;
 }
예제 #11
0
  public Map<String, Boolean> getEpSettings() {
    Map<String, Boolean> epSettings = new HashMap<String, Boolean>();

    epSettings.put("protect.protect.signs", config.getBoolean("protect.protect.signs", true));
    epSettings.put("protect.protect.rails", config.getBoolean("protect.protect.rails", true));
    epSettings.put(
        "protect.protect.block-below", config.getBoolean("protect.protect.block-below", true));
    epSettings.put(
        "protect.protect.prevent-block-on-rails",
        config.getBoolean("protect.protect.prevent-block-on-rails", false));
    epSettings.put("protect.memstore", config.getBoolean("protect.memstore", false));
    return epSettings;
  }
예제 #12
0
	public void setPowertool(ItemStack stack, List<String> commandList)
	{
		if (commandList == null || commandList.isEmpty())
		{
			powertools.remove("" + stack.getTypeId());
		}
		else
		{
			powertools.put("" + stack.getTypeId(), commandList);
		}
		config.setProperty("powertools", powertools);
		config.save();
	}
예제 #13
0
	public void setUnlimited(ItemStack stack, boolean state)
	{
		if (unlimited.contains(stack.getTypeId()))
		{
			unlimited.remove(Integer.valueOf(stack.getTypeId()));
		}
		if (state)
		{
			unlimited.add(stack.getTypeId());
		}
		config.setProperty("unlimited", unlimited);
		config.save();
	}
예제 #14
0
	public void setMails(List<String> mails)
	{
		if (mails == null)
		{
			config.removeProperty("mail");
			mails = _getMails();
		}
		else
		{
			config.setProperty("mail", mails);
		}
		this.mails = mails;
		config.save();
	}
예제 #15
0
	public void setGeoLocation(String geolocation)
	{
		if (geolocation == null || geolocation.isEmpty())
		{
			this.geolocation = null;
			config.removeProperty("geolocation");
		}
		else
		{
			this.geolocation = geolocation;
			config.setProperty("geolocation", geolocation);
		}
		config.save();
	}
예제 #16
0
 @Override
 public final void reloadConfig() {
   users.load();
   spyusers.clear();
   final List<String> keys = users.getKeys(null);
   for (String key : keys) {
     if (isSpy(key)) {
       final String address = getAddress(key);
       if (address != null) {
         spyusers.add(address);
       }
     }
   }
 }
예제 #17
0
	public void setJail(String jail)
	{
		if (jail == null || jail.isEmpty())
		{
			this.jail = null;
			config.removeProperty("jail");
		}
		else
		{
			this.jail = jail;
			config.setProperty("jail", jail);
		}
		config.save();
	}
예제 #18
0
	public void setIgnoredPlayers(List<String> players)
	{
		if (players == null || players.isEmpty())
		{
			ignoredPlayers = Collections.synchronizedList(new ArrayList<String>());
			config.removeProperty("ignore");
		}
		else
		{
			ignoredPlayers = players;
			config.setProperty("ignore", players);
		}
		config.save();
	}
예제 #19
0
	@Override
	public final void reloadConfig()
	{
		config.load();
		money = _getMoney();
		unlimited = _getUnlimited();
		powertools = _getPowertools();
		homes = _getHomes();
		lastLocation = _getLastLocation();
		lastTeleportTimestamp = _getLastTeleportTimestamp();
		lastHealTimestamp = _getLastHealTimestamp();
		jail = _getJail();
		mails = _getMails();
		teleportEnabled = _getTeleportEnabled();
		godmode = _getGodModeEnabled();
		muted = _getMuted();
		muteTimeout = _getMuteTimeout();
		jailed = _getJailed();
		jailTimeout = _getJailTimeout();
		lastLogin = _getLastLogin();
		lastLogout = _getLastLogout();
		lastLoginAddress = _getLastLoginAddress();
		afk = _getAfk();
		geolocation = _getGeoLocation();
		isSocialSpyEnabled = _isSocialSpyEnabled();
		isNPC = _isNPC();
		arePowerToolsEnabled = _arePowerToolsEnabled();
		kitTimestamps = _getKitTimestamps();
		nickname = _getNickname();
		ignoredPlayers = _getIgnoredPlayers();
		logoutLocation = _getLogoutLocation();
	}
예제 #20
0
	public void setMoney(BigDecimal value)
	{
		money = value;
		BigDecimal maxMoney = ess.getSettings().getMaxMoney();
		BigDecimal minMoney = ess.getSettings().getMinMoney();
		if (money.compareTo(maxMoney) > 0)
		{
			money = maxMoney;
		}
		if (money.compareTo(minMoney) < 0)
		{
			money = minMoney;
		}
		config.setProperty("money", money);
		config.save();
	}
예제 #21
0
	public boolean hasHome()
	{
		if (config.hasProperty("home"))
		{
			return true;
		}
		return false;
	}
예제 #22
0
 public Object getKit(String name) {
   Map<String, Object> kits = (Map<String, Object>) config.getProperty("kits");
   for (Map.Entry<String, Object> entry : kits.entrySet()) {
     if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_'))) {
       return entry.getValue();
     }
   }
   return null;
 }
예제 #23
0
	public void delHome(String name) throws Exception
	{
		String search = getHomeName(name);
		if (!homes.containsKey(search))
		{
			search = StringUtil.safeString(search);
		}
		if (homes.containsKey(search))
		{
			homes.remove(search);
			config.removeProperty("homes." + search);
			config.save();
		}
		else
		{
			throw new Exception(_("invalidHome", search));
		}
	}
예제 #24
0
	public void setLastLogin(long time)
	{
		_setLastLogin(time);
		if (base.getAddress() != null && base.getAddress().getAddress() != null)
		{
			_setLastLoginAddress(base.getAddress().getAddress().getHostAddress());
		}
		config.save();
	}
예제 #25
0
	private BigDecimal _getMoney()
	{
		BigDecimal result = ess.getSettings().getStartingBalance();
		BigDecimal maxMoney = ess.getSettings().getMaxMoney();
		BigDecimal minMoney = ess.getSettings().getMinMoney();

		if (config.hasProperty("money"))
		{
			result = config.getBigDecimal("money", result);
		}
		if (result.compareTo(maxMoney) > 0)
		{
			result = maxMoney;
		}
		if (result.compareTo(minMoney) < 0)
		{
			result = minMoney;
		}
		return result;
	}
예제 #26
0
	private Location _getLogoutLocation()
	{
		try
		{
			return config.getLocation("logoutlocation", getServer());
		}
		catch (Exception e)
		{
			return null;
		}
	}
예제 #27
0
	public void setConfigProperty(String node, Object object)
	{
		final String prefix = "info.";
		node = prefix + node;
		if (object instanceof Map)
		{
			config.setProperty(node, (Map)object);
		}
		else if (object instanceof List)
		{
			config.setProperty(node, (List<String>)object);
		}
		else if (object instanceof Location)
		{
			config.setProperty(node, (Location)object);
		}
		else if (object instanceof ItemStack)
		{
			config.setProperty(node, (ItemStack)object);
		}
		else
		{
			config.setProperty(node, object);
		}
		config.save();
	}
예제 #28
0
	private Map<String, Long> _getKitTimestamps()
	{

		if (config.isConfigurationSection("timestamps.kits"))
		{
			final ConfigurationSection section = config.getConfigurationSection("timestamps.kits");
			final Map<String, Long> timestamps = new HashMap<String, Long>();
			for (String command : section.getKeys(false))
			{
				if (section.isLong(command))
				{
					timestamps.put(command.toLowerCase(Locale.ENGLISH), section.getLong(command));
				}
				else if (section.isInt(command))
				{
					timestamps.put(command.toLowerCase(Locale.ENGLISH), (long)section.getInt(command));
				}
			}
			return timestamps;
		}
		return new HashMap<String, Long>();
	}
예제 #29
0
	public Location getHome(final Location world)
	{
		try
		{
			Location loc;
			for (String home : getHomes())
			{
				loc = config.getLocation("homes." + home, getServer());
				if (world.getWorld() == loc.getWorld())
				{
					return loc;
				}

			}
			loc = config.getLocation("homes." + getHomes().get(0), getServer());
			return loc;
		}
		catch (Exception ex)
		{
			return null;
		}
	}
예제 #30
0
  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));
  }