Ejemplo n.º 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);
 }
Ejemplo n.º 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();
	}
Ejemplo n.º 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();
 }
Ejemplo n.º 4
0
	public Set<String> getConfigKeys()
	{
		if (config.isConfigurationSection("info"))
		{
			return config.getConfigurationSection("info").getKeys(true);
		}
		return new HashSet<String>();
	}
Ejemplo n.º 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>();
	}
Ejemplo n.º 6
0
	private Map<String, Object> _getPowertools()
	{
		if (config.isConfigurationSection("powertools"))
		{
			return config.getConfigurationSection("powertools").getValues(false);
		}
		return new HashMap<String, Object>();
	}
Ejemplo n.º 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);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 9
0
	public void setLogoutLocation(Location loc)
	{
		if (loc == null || loc.getWorld() == null)
		{
			return;
		}
		logoutLocation = loc;
		config.setProperty("logoutlocation", loc);
		config.save();
	}
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
  }
Ejemplo n.º 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();
	}
Ejemplo n.º 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();
	}
Ejemplo n.º 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();
	}
Ejemplo n.º 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();
	}
Ejemplo n.º 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);
       }
     }
   }
 }
Ejemplo n.º 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();
	}
Ejemplo n.º 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();
	}
Ejemplo n.º 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();
	}
Ejemplo n.º 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();
	}
Ejemplo n.º 21
0
	public boolean hasHome()
	{
		if (config.hasProperty("home"))
		{
			return true;
		}
		return false;
	}
Ejemplo n.º 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;
 }
Ejemplo n.º 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));
		}
	}
Ejemplo n.º 24
0
	public void setLastLogin(long time)
	{
		_setLastLogin(time);
		if (base.getAddress() != null && base.getAddress().getAddress() != null)
		{
			_setLastLoginAddress(base.getAddress().getAddress().getHostAddress());
		}
		config.save();
	}
Ejemplo n.º 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;
	}
Ejemplo n.º 26
0
	private Location _getLogoutLocation()
	{
		try
		{
			return config.getLocation("logoutlocation", getServer());
		}
		catch (Exception e)
		{
			return null;
		}
	}
Ejemplo n.º 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();
	}
Ejemplo n.º 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>();
	}
Ejemplo n.º 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;
		}
	}
Ejemplo n.º 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));
  }