mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-24 11:54:35 +08:00
Added options to enable each sign type
This commit is contained in:
parent
c6aa34076a
commit
e1abdbdd37
@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -100,6 +101,8 @@ public interface ISettings extends IConf
|
||||
boolean isTradeInStacks(int id);
|
||||
|
||||
List<Integer> itemSpawnBlacklist();
|
||||
|
||||
List<EssentialsSign> enabledSigns();
|
||||
|
||||
boolean permissionBasedItemSpawn();
|
||||
|
||||
|
@ -2,6 +2,8 @@ package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import com.earth2me.essentials.signs.Signs;
|
||||
import java.io.File;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
@ -278,7 +280,7 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public boolean areSignsDisabled()
|
||||
{
|
||||
return config.getBoolean("signs-disabled", false);
|
||||
return enabledSigns.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -356,11 +358,20 @@ public class Settings implements ISettings
|
||||
{
|
||||
config.load();
|
||||
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds", Collections.<String>emptyList()));
|
||||
enabledSigns = getEnabledSigns();
|
||||
itemSpawnBl = getItemSpawnBlacklist();
|
||||
chatFormats.clear();
|
||||
}
|
||||
|
||||
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
|
||||
|
||||
@Override
|
||||
public List<Integer> itemSpawnBlacklist()
|
||||
{
|
||||
return itemSpawnBl;
|
||||
}
|
||||
|
||||
private List<Integer> getItemSpawnBlacklist()
|
||||
{
|
||||
final List<Integer> epItemSpwn = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("item-spawn-blacklist", "").split(","))
|
||||
@ -369,12 +380,11 @@ public class Settings implements ISettings
|
||||
if (itemName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
}
|
||||
try
|
||||
{
|
||||
is = ess.getItemDb().get(itemName);
|
||||
epItemSpwn.add(is.getTypeId());
|
||||
final ItemStack iStack = ess.getItemDb().get(itemName);
|
||||
epItemSpwn.add(iStack.getTypeId());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -383,6 +393,36 @@ public class Settings implements ISettings
|
||||
}
|
||||
return epItemSpwn;
|
||||
}
|
||||
|
||||
private List<EssentialsSign> enabledSigns = new ArrayList<EssentialsSign>();
|
||||
|
||||
@Override
|
||||
public List<EssentialsSign> enabledSigns()
|
||||
{
|
||||
return enabledSigns;
|
||||
}
|
||||
|
||||
private List<EssentialsSign> getEnabledSigns()
|
||||
{
|
||||
List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>();
|
||||
for (String signName : config.getString("enabledSigns", "").split(","))
|
||||
{
|
||||
signName = signName.trim();
|
||||
if (signName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
newSigns.add(Signs.valueOf(signName).getSign());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, _("unknownItemInList", signName, "enabledSigns"));
|
||||
}
|
||||
}
|
||||
return newSigns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawnIfNoHome()
|
||||
@ -559,7 +599,8 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("death-messages", true);
|
||||
}
|
||||
Set<String> noGodWorlds = new HashSet<String>();
|
||||
|
||||
private Set<String> noGodWorlds = new HashSet<String>();
|
||||
|
||||
@Override
|
||||
public Set<String> getNoGodWorlds()
|
||||
|
@ -44,9 +44,9 @@ public class SignBlockListener implements Listener
|
||||
if (mat == Material.SIGN_POST.getId() || mat == Material.WALL_SIGN.getId())
|
||||
{
|
||||
final Sign csign = (Sign)block.getState();
|
||||
for (Signs signs : Signs.values())
|
||||
|
||||
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
||||
{
|
||||
final EssentialsSign sign = signs.getSign();
|
||||
if (csign.getLine(0).equalsIgnoreCase(sign.getSuccessName())
|
||||
&& !sign.onSignBreak(block, player, ess))
|
||||
{
|
||||
@ -62,9 +62,8 @@ public class SignBlockListener implements Listener
|
||||
LOGGER.log(Level.INFO, "Prevented that a block was broken next to a sign.");
|
||||
return true;
|
||||
}
|
||||
for (Signs signs : Signs.values())
|
||||
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
||||
{
|
||||
final EssentialsSign sign = signs.getSign();
|
||||
if (sign.getBlocks().contains(block.getType())
|
||||
&& !sign.onBlockBreak(block, player, ess))
|
||||
{
|
||||
@ -91,9 +90,8 @@ public class SignBlockListener implements Listener
|
||||
event.setLine(i, event.getLine(i).replaceAll("&([0-9a-f])", "§$1"));
|
||||
}
|
||||
}
|
||||
for (Signs signs : Signs.values())
|
||||
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
||||
{
|
||||
final EssentialsSign sign = signs.getSign();
|
||||
if (event.getLine(0).equalsIgnoreCase(sign.getSuccessName()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
@ -130,9 +128,8 @@ public class SignBlockListener implements Listener
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (Signs signs : Signs.values())
|
||||
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
||||
{
|
||||
final EssentialsSign sign = signs.getSign();
|
||||
if (sign.getBlocks().contains(block.getType())
|
||||
&& !sign.onBlockPlace(block, event.getPlayer(), ess))
|
||||
{
|
||||
@ -159,9 +156,8 @@ public class SignBlockListener implements Listener
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
for (Signs signs : Signs.values())
|
||||
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
||||
{
|
||||
final EssentialsSign sign = signs.getSign();
|
||||
if (sign.getBlocks().contains(block.getType())
|
||||
&& !sign.onBlockBurn(block, ess))
|
||||
{
|
||||
@ -188,9 +184,8 @@ public class SignBlockListener implements Listener
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
for (Signs signs : Signs.values())
|
||||
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
||||
{
|
||||
final EssentialsSign sign = signs.getSign();
|
||||
if (sign.getBlocks().contains(block.getType())
|
||||
&& !sign.onBlockIgnite(block, ess))
|
||||
{
|
||||
@ -213,9 +208,8 @@ public class SignBlockListener implements Listener
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
for (Signs signs : Signs.values())
|
||||
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
||||
{
|
||||
final EssentialsSign sign = signs.getSign();
|
||||
if (sign.getBlocks().contains(block.getType())
|
||||
&& !sign.onBlockPush(block, ess))
|
||||
{
|
||||
@ -240,9 +234,8 @@ public class SignBlockListener implements Listener
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
for (Signs signs : Signs.values())
|
||||
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
||||
{
|
||||
final EssentialsSign sign = signs.getSign();
|
||||
if (sign.getBlocks().contains(block.getType())
|
||||
&& !sign.onBlockPush(block, ess))
|
||||
{
|
||||
|
@ -32,9 +32,8 @@ public class SignEntityListener implements Listener
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
for (Signs signs : Signs.values())
|
||||
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
||||
{
|
||||
final EssentialsSign sign = signs.getSign();
|
||||
if (sign.getBlocks().contains(block.getType()))
|
||||
{
|
||||
event.setCancelled(!sign.onBlockExplode(block, ess));
|
||||
@ -61,9 +60,8 @@ public class SignEntityListener implements Listener
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
for (Signs signs : Signs.values())
|
||||
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
||||
{
|
||||
final EssentialsSign sign = signs.getSign();
|
||||
if (sign.getBlocks().contains(block.getType())
|
||||
&& !sign.onBlockBreak(block, ess))
|
||||
{
|
||||
|
@ -41,9 +41,8 @@ public class SignPlayerListener implements Listener
|
||||
return;
|
||||
}
|
||||
final Sign csign = (Sign)block.getState();
|
||||
for (Signs signs : Signs.values())
|
||||
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
||||
{
|
||||
final EssentialsSign sign = signs.getSign();
|
||||
if (csign.getLine(0).equalsIgnoreCase(sign.getSuccessName()))
|
||||
{
|
||||
sign.onSignInteract(block, event.getPlayer(), ess);
|
||||
@ -54,9 +53,8 @@ public class SignPlayerListener implements Listener
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Signs signs : Signs.values())
|
||||
for (EssentialsSign sign : ess.getSettings().enabledSigns())
|
||||
{
|
||||
final EssentialsSign sign = signs.getSign();
|
||||
if (sign.getBlocks().contains(block.getType())
|
||||
&& !sign.onBlockInteract(block, event.getPlayer(), ess))
|
||||
{
|
||||
|
@ -166,8 +166,26 @@ kits:
|
||||
- 278 1
|
||||
- 279 1
|
||||
|
||||
# Disable all signs
|
||||
signs-disabled: false
|
||||
# Enable specifc signs on the server
|
||||
# See http://ess.khhq.net/wiki/Sign_Tutorial for specific instructions.
|
||||
# To enable remove # symbol.
|
||||
enabledSigns:
|
||||
- balance
|
||||
#- buy
|
||||
#- sell
|
||||
#- trade
|
||||
#- free
|
||||
- disposal
|
||||
#- warp
|
||||
#- kit
|
||||
#- mail
|
||||
#- enchant
|
||||
#- gamemode
|
||||
#- heal
|
||||
#- spawnmob
|
||||
#- time
|
||||
#- weather
|
||||
#- protection
|
||||
|
||||
# Backup runs a command while saving is disabled
|
||||
backup:
|
||||
|
Loading…
Reference in New Issue
Block a user