Better Configuration implementation and better working Limit Features
This commit is contained in:
parent
0d0a9bfaba
commit
729c186b75
11 changed files with 99 additions and 66 deletions
|
@ -1,32 +1,23 @@
|
||||||
package de.jaschastarke.minecraft.limitedcreative;
|
package de.jaschastarke.minecraft.limitedcreative;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import de.jaschastarke.bukkit.lib.Core;
|
import de.jaschastarke.bukkit.lib.Core;
|
||||||
import de.jaschastarke.bukkit.lib.configuration.PluginConfiguration;
|
import de.jaschastarke.bukkit.lib.configuration.PluginConfiguration;
|
||||||
import de.jaschastarke.configuration.annotations.IsConfigurationNode;
|
import de.jaschastarke.configuration.annotations.IsConfigurationNode;
|
||||||
import de.jaschastarke.maven.ArchiveDocComments;
|
import de.jaschastarke.maven.ArchiveDocComments;
|
||||||
import de.jaschastarke.utils.ClassDescriptorStorage;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Limited Creative - Configuration
|
* Limited Creative - Configuration
|
||||||
*
|
*
|
||||||
* (YAML-Syntax: http://en.wikipedia.org/wiki/YAML)
|
* (YAML-Syntax: http://en.wikipedia.org/wiki/YAML)
|
||||||
|
*
|
||||||
|
* This configuration-file is automatically written when changed via ingame-commands. So any manual added comments are
|
||||||
|
* removed.
|
||||||
*/
|
*/
|
||||||
@ArchiveDocComments
|
@ArchiveDocComments
|
||||||
public class Config extends PluginConfiguration {
|
public class Config extends PluginConfiguration {
|
||||||
public Config(Core plugin) {
|
public Config(Core plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public void save() {
|
|
||||||
try {
|
|
||||||
ClassDescriptorStorage.load(plugin.getResource("META-INF/descriptions.jos"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
plugin.getLog().severe("Failed to load ConfigNode-Descriptions");
|
|
||||||
}
|
|
||||||
super.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metrics
|
* Metrics
|
||||||
|
|
|
@ -21,7 +21,7 @@ import de.jaschastarke.bukkit.lib.commands.annotations.Alias;
|
||||||
import de.jaschastarke.bukkit.lib.commands.annotations.Description;
|
import de.jaschastarke.bukkit.lib.commands.annotations.Description;
|
||||||
import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand;
|
import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand;
|
||||||
import de.jaschastarke.bukkit.lib.commands.annotations.NeedsPermission;
|
import de.jaschastarke.bukkit.lib.commands.annotations.NeedsPermission;
|
||||||
import de.jaschastarke.bukkit.lib.commands.annotations.Usage;
|
import de.jaschastarke.bukkit.lib.commands.annotations.Usages;
|
||||||
import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
|
import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
|
||||||
import de.jaschastarke.minecraft.lib.permissions.IPermission;
|
import de.jaschastarke.minecraft.lib.permissions.IPermission;
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public class FeatureSwitchGameMode extends CoreModule<LimitedCreative> {
|
||||||
@Alias("s")
|
@Alias("s")
|
||||||
@Description(value = "command.switch.survival", translate = true)
|
@Description(value = "command.switch.survival", translate = true)
|
||||||
@NeedsPermission(value={"survival", "backonly"}, optional = true)
|
@NeedsPermission(value={"survival", "backonly"}, optional = true)
|
||||||
@Usage("[player]")
|
@Usages("[player]")
|
||||||
public boolean survival(CommandContext context, String player) throws MissingPermissionCommandException, CommandException {
|
public boolean survival(CommandContext context, String player) throws MissingPermissionCommandException, CommandException {
|
||||||
return changeGameMode(context, player, GameMode.SURVIVAL, SwitchGameModePermissions.SURVIVAL);
|
return changeGameMode(context, player, GameMode.SURVIVAL, SwitchGameModePermissions.SURVIVAL);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ public class FeatureSwitchGameMode extends CoreModule<LimitedCreative> {
|
||||||
@Alias("c")
|
@Alias("c")
|
||||||
@Description(value = "command.switch.creative", translate = true)
|
@Description(value = "command.switch.creative", translate = true)
|
||||||
@NeedsPermission(value={"creative", "backonly"}, optional = true)
|
@NeedsPermission(value={"creative", "backonly"}, optional = true)
|
||||||
@Usage("[player]")
|
@Usages("[player]")
|
||||||
public boolean creative(CommandContext context, String player) throws MissingPermissionCommandException, CommandException {
|
public boolean creative(CommandContext context, String player) throws MissingPermissionCommandException, CommandException {
|
||||||
return changeGameMode(context, player, GameMode.CREATIVE, SwitchGameModePermissions.CREATIVE);
|
return changeGameMode(context, player, GameMode.CREATIVE, SwitchGameModePermissions.CREATIVE);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ public class FeatureSwitchGameMode extends CoreModule<LimitedCreative> {
|
||||||
@Alias("a")
|
@Alias("a")
|
||||||
@Description(value = "command.switch.adventure", translate = true)
|
@Description(value = "command.switch.adventure", translate = true)
|
||||||
@NeedsPermission(value={"adventure", "backonly"}, optional = true)
|
@NeedsPermission(value={"adventure", "backonly"}, optional = true)
|
||||||
@Usage("[player]")
|
@Usages("[player]")
|
||||||
public boolean adventure(CommandContext context, String player) throws MissingPermissionCommandException, CommandException {
|
public boolean adventure(CommandContext context, String player) throws MissingPermissionCommandException, CommandException {
|
||||||
return changeGameMode(context, player, GameMode.ADVENTURE, SwitchGameModePermissions.ADVENTURE);
|
return changeGameMode(context, player, GameMode.ADVENTURE, SwitchGameModePermissions.ADVENTURE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package de.jaschastarke.minecraft.limitedcreative;
|
||||||
import de.jaschastarke.I18n;
|
import de.jaschastarke.I18n;
|
||||||
import de.jaschastarke.bukkit.lib.Core;
|
import de.jaschastarke.bukkit.lib.Core;
|
||||||
import de.jaschastarke.bukkit.lib.PluginLang;
|
import de.jaschastarke.bukkit.lib.PluginLang;
|
||||||
import de.jaschastarke.bukkit.lib.configuration.ConfigCommand;
|
import de.jaschastarke.bukkit.lib.configuration.command.ConfigCommand;
|
||||||
|
|
||||||
public class LimitedCreative extends Core {
|
public class LimitedCreative extends Core {
|
||||||
protected Config config = null;
|
protected Config config = null;
|
||||||
|
|
|
@ -40,8 +40,8 @@ public class MainCommand extends BukkitCommand implements IHelpDescribed {
|
||||||
return new IAbstractPermission[]{Permissions.COMMAND};
|
return new IAbstractPermission[]{Permissions.COMMAND};
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String getUsage() {
|
public String[] getUsages() {
|
||||||
return "<subcommand>";
|
return null;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getDescription() {
|
public CharSequence getDescription() {
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
package de.jaschastarke.minecraft.limitedcreative;
|
package de.jaschastarke.minecraft.limitedcreative;
|
||||||
|
|
||||||
import de.jaschastarke.bukkit.lib.CoreModule;
|
import de.jaschastarke.bukkit.lib.CoreModule;
|
||||||
|
import de.jaschastarke.minecraft.limitedcreative.limits.BlockListener;
|
||||||
|
import de.jaschastarke.minecraft.limitedcreative.limits.EntityListener;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.limits.LimitConfig;
|
import de.jaschastarke.minecraft.limitedcreative.limits.LimitConfig;
|
||||||
|
import de.jaschastarke.minecraft.limitedcreative.limits.PlayerListener;
|
||||||
import de.jaschastarke.modularize.IModule;
|
import de.jaschastarke.modularize.IModule;
|
||||||
import de.jaschastarke.modularize.ModuleEntry;
|
import de.jaschastarke.modularize.ModuleEntry;
|
||||||
|
import de.jaschastarke.modularize.ModuleEntry.ModuleState;
|
||||||
|
|
||||||
public class ModCreativeLimits extends CoreModule<LimitedCreative> {
|
public class ModCreativeLimits extends CoreModule<LimitedCreative> {
|
||||||
protected LimitConfig config;
|
protected LimitConfig config;
|
||||||
|
@ -12,19 +16,40 @@ public class ModCreativeLimits extends CoreModule<LimitedCreative> {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LimitConfig getConfig() {
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected FeatureBlockItemSpawn blockDrops = null;
|
protected FeatureBlockItemSpawn blockDrops = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Limits";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(ModuleEntry<IModule> entry) {
|
public void initialize(ModuleEntry<IModule> entry) {
|
||||||
super.initialize(entry);
|
super.initialize(entry);
|
||||||
blockDrops = plugin.getModule(FeatureBlockItemSpawn.class);
|
listeners.addListener(new PlayerListener(this));
|
||||||
|
listeners.addListener(new EntityListener(this));
|
||||||
|
listeners.addListener(new BlockListener(this));
|
||||||
|
config = plugin.getPluginConfig().registerSection(new LimitConfig(this, entry));
|
||||||
|
|
||||||
|
/*blockDrops = plugin.getModule(FeatureBlockItemSpawn.class);
|
||||||
if (blockDrops == null)
|
if (blockDrops == null)
|
||||||
blockDrops = plugin.addModule(new FeatureBlockItemSpawn(plugin)).getModule();
|
blockDrops = plugin.addModule(new FeatureBlockItemSpawn(plugin)).getModule();
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!config.getEnabled()) {
|
||||||
|
entry.initialState = ModuleState.DISABLED;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
super.onEnable();
|
||||||
|
getLog().info(plugin.getLocale().trans("basic.loaded.module"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public LimitConfig getConfig() {
|
||||||
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,6 @@ public class ArmoryConfig extends Configuration implements IConfigurationSubGrou
|
||||||
mod = modInventories;
|
mod = modInventories;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isReadOnly() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValues(ConfigurationSection sect) {
|
public void setValues(ConfigurationSection sect) {
|
||||||
if (sect == null || sect.getValues(false).size() == 0) {
|
if (sect == null || sect.getValues(false).size() == 0) {
|
||||||
|
|
|
@ -28,17 +28,12 @@ public class InventoryConfig extends Configuration implements IConfigurationSubG
|
||||||
entry = modEntry;
|
entry = modEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isReadOnly() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValue(IConfigurationNode node, Object pValue) throws InvalidValueException {
|
public void setValue(IConfigurationNode node, Object pValue) throws InvalidValueException {
|
||||||
super.setValue(node, pValue);
|
super.setValue(node, pValue);
|
||||||
if (node.getName().equals("enabled")) {
|
if (node.getName().equals("enabled")) {
|
||||||
if ((Boolean) pValue) {
|
if (getEnabled()) {
|
||||||
entry.activate();
|
entry.enable();
|
||||||
} else {
|
} else {
|
||||||
entry.disable();
|
entry.disable();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,13 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
import de.jaschastarke.bukkit.lib.configuration.ConfigurableList;
|
import de.jaschastarke.bukkit.lib.configuration.ConfigurableList;
|
||||||
|
import de.jaschastarke.bukkit.lib.configuration.IToGeneric;
|
||||||
import de.jaschastarke.bukkit.lib.items.ItemUtils;
|
import de.jaschastarke.bukkit.lib.items.ItemUtils;
|
||||||
import de.jaschastarke.bukkit.lib.items.MaterialDataNotRecognizedException;
|
import de.jaschastarke.bukkit.lib.items.MaterialDataNotRecognizedException;
|
||||||
import de.jaschastarke.bukkit.lib.items.MaterialNotRecognizedException;
|
import de.jaschastarke.bukkit.lib.items.MaterialNotRecognizedException;
|
||||||
|
import de.jaschastarke.configuration.InvalidValueException;
|
||||||
|
|
||||||
public class BlackList extends ArrayList<BlackList.Blacklisted> implements ConfigurableList {
|
public class BlackList extends ArrayList<BlackList.Blacklisted> implements ConfigurableList<BlackList.Blacklisted>, IToGeneric {
|
||||||
private static final long serialVersionUID = -3701659163474405152L;
|
private static final long serialVersionUID = -3701659163474405152L;
|
||||||
|
|
||||||
public static class Blacklisted {
|
public static class Blacklisted {
|
||||||
|
@ -22,15 +24,15 @@ public class BlackList extends ArrayList<BlackList.Blacklisted> implements Confi
|
||||||
private MaterialData md;
|
private MaterialData md;
|
||||||
private boolean hasData = false;
|
private boolean hasData = false;
|
||||||
|
|
||||||
public Blacklisted(String rep) {
|
public Blacklisted(String rep) throws InvalidValueException {
|
||||||
stringRep = rep;
|
stringRep = rep;
|
||||||
try {
|
try {
|
||||||
md = ItemUtils.parseMaterial(rep);
|
md = ItemUtils.parseMaterial(rep);
|
||||||
hasData = rep.contains(ItemUtils.MATERIAL_DATA_SEP);
|
hasData = rep.contains(ItemUtils.MATERIAL_DATA_SEP);
|
||||||
} catch (MaterialNotRecognizedException e) {
|
} catch (MaterialNotRecognizedException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new InvalidValueException(e);
|
||||||
} catch (MaterialDataNotRecognizedException e) {
|
} catch (MaterialDataNotRecognizedException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new InvalidValueException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Blacklisted(Material m) {
|
public Blacklisted(Material m) {
|
||||||
|
@ -51,7 +53,7 @@ public class BlackList extends ArrayList<BlackList.Blacklisted> implements Confi
|
||||||
}
|
}
|
||||||
public boolean matches(Block block) {
|
public boolean matches(Block block) {
|
||||||
if (hasData) {
|
if (hasData) {
|
||||||
return md.equals(block.getData());
|
return md.equals(new MaterialData(block.getType(), block.getData()));
|
||||||
} else {
|
} else {
|
||||||
return block.getType().equals(md.getItemType());
|
return block.getType().equals(md.getItemType());
|
||||||
}
|
}
|
||||||
|
@ -68,17 +70,22 @@ public class BlackList extends ArrayList<BlackList.Blacklisted> implements Confi
|
||||||
public BlackList(List<?> list) {
|
public BlackList(List<?> list) {
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
for (Object el : list) {
|
for (Object el : list) {
|
||||||
if (el instanceof Blacklisted)
|
if (el instanceof Blacklisted) {
|
||||||
add((Blacklisted) el);
|
add((Blacklisted) el);
|
||||||
else
|
} else {
|
||||||
|
try {
|
||||||
add(el.toString());
|
add(el.toString());
|
||||||
|
} catch (InvalidValueException e) {
|
||||||
|
System.err.println(e.getCause().getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(String e) {
|
public boolean contains(String e) {
|
||||||
for (Blacklisted bl : this) {
|
for (Blacklisted bl : this) {
|
||||||
if (bl.toString().equals(e))
|
if (bl.toString().equalsIgnoreCase(e))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -100,7 +107,7 @@ public class BlackList extends ArrayList<BlackList.Blacklisted> implements Confi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // ConfigurableList, not List<E>
|
@Override // ConfigurableList, not List<E>
|
||||||
public void add(String e) {
|
public void add(String e) throws InvalidValueException {
|
||||||
if (!contains(e)) {
|
if (!contains(e)) {
|
||||||
add(new Blacklisted(e));
|
add(new Blacklisted(e));
|
||||||
}
|
}
|
||||||
|
@ -110,11 +117,24 @@ public class BlackList extends ArrayList<BlackList.Blacklisted> implements Confi
|
||||||
public boolean remove(String e) {
|
public boolean remove(String e) {
|
||||||
Iterator<Blacklisted> it = iterator();
|
Iterator<Blacklisted> it = iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
if (it.next().toString().equals(e)) {
|
if (it.next().toString().equalsIgnoreCase(e)) {
|
||||||
it.remove();
|
it.remove();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> toStringList() {
|
||||||
|
List<String> list = new ArrayList<String>(size());
|
||||||
|
for (Blacklisted bl : this) {
|
||||||
|
list.add(bl.toString());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> toGeneric() {
|
||||||
|
return toStringList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import de.jaschastarke.bukkit.lib.configuration.Configuration;
|
import de.jaschastarke.bukkit.lib.configuration.Configuration;
|
||||||
|
import de.jaschastarke.bukkit.lib.configuration.IToGeneric;
|
||||||
import de.jaschastarke.configuration.IConfigurationNode;
|
import de.jaschastarke.configuration.IConfigurationNode;
|
||||||
import de.jaschastarke.configuration.IConfigurationSubGroup;
|
import de.jaschastarke.configuration.IConfigurationSubGroup;
|
||||||
import de.jaschastarke.configuration.InvalidValueException;
|
import de.jaschastarke.configuration.InvalidValueException;
|
||||||
|
@ -29,17 +30,13 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
|
||||||
entry = modEntry;
|
entry = modEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isReadOnly() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValue(IConfigurationNode node, Object pValue) throws InvalidValueException {
|
public void setValue(IConfigurationNode node, Object pValue) throws InvalidValueException {
|
||||||
|
if (!(pValue instanceof BlackList))
|
||||||
super.setValue(node, pValue);
|
super.setValue(node, pValue);
|
||||||
if (node.getName().equals("enabled")) {
|
if (node.getName().equals("enabled")) {
|
||||||
if ((Boolean) pValue) {
|
if (getEnabled()) {
|
||||||
entry.activate();
|
entry.enable();
|
||||||
} else {
|
} else {
|
||||||
entry.disable();
|
entry.disable();
|
||||||
}
|
}
|
||||||
|
@ -54,7 +51,7 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
|
||||||
if (!sect.contains("interact") && sect.contains("sign")) {
|
if (!sect.contains("interact") && sect.contains("sign")) {
|
||||||
interactList = new BlackList();
|
interactList = new BlackList();
|
||||||
if (config.getBoolean("sign", true)) {
|
if (config.getBoolean("sign", true)) {
|
||||||
interactList.add(new BlackList.Blacklisted(Material.SIGN));
|
interactList.add(new BlackList.Blacklisted(Material.WALL_SIGN));
|
||||||
interactList.add(new BlackList.Blacklisted(Material.SIGN_POST));
|
interactList.add(new BlackList.Blacklisted(Material.SIGN_POST));
|
||||||
}
|
}
|
||||||
if (config.getBoolean("button", false)) {
|
if (config.getBoolean("button", false)) {
|
||||||
|
@ -114,9 +111,14 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static enum BlockPickup {
|
public static enum BlockPickup implements IToGeneric {
|
||||||
PREVENT,
|
PREVENT,
|
||||||
REMOVE;
|
REMOVE;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object toGeneric() {
|
||||||
|
return name().toLowerCase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,7 +178,7 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
|
||||||
if (interactList == null) {
|
if (interactList == null) {
|
||||||
interactList = new BlackList(config.getList("interact"));
|
interactList = new BlackList(config.getList("interact"));
|
||||||
if (!config.contains("interact")) {
|
if (!config.contains("interact")) {
|
||||||
interactList.add(new BlackList.Blacklisted(Material.SIGN));
|
interactList.add(new BlackList.Blacklisted(Material.WALL_SIGN));
|
||||||
interactList.add(new BlackList.Blacklisted(Material.SIGN_POST));
|
interactList.add(new BlackList.Blacklisted(Material.SIGN_POST));
|
||||||
interactList.add(new BlackList.Blacklisted(Material.LEVER));
|
interactList.add(new BlackList.Blacklisted(Material.LEVER));
|
||||||
interactList.add(new BlackList.Blacklisted(Material.STONE_BUTTON));
|
interactList.add(new BlackList.Blacklisted(Material.STONE_BUTTON));
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class PlayerListener implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
if (!isCancelled(event) && event.getPlayer().getGameMode() == GameMode.CREATIVE) {
|
if (!isCancelled(event) && event.getPlayer().getGameMode() == GameMode.CREATIVE) {
|
||||||
if (mod.getConfig().getBlockUse().isListed(event.getItem())) {
|
if (event.getItem() != null && mod.getConfig().getBlockUse().isListed(event.getItem())) {
|
||||||
if (!checkPermission(event, NoLimitPermissions.USE(event.getItem().getData()))) {
|
if (!checkPermission(event, NoLimitPermissions.USE(event.getItem().getData()))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.setUseItemInHand(Event.Result.DENY);
|
event.setUseItemInHand(Event.Result.DENY);
|
||||||
|
@ -112,6 +112,11 @@ public class PlayerListener implements Listener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Well, the action could be ignored, if the player is sneaking, as MC now let you place block on workbench
|
||||||
|
// and other while crouching.
|
||||||
|
// But we don't trust other plugins, like chest-shops that do something while right-clicking a block even
|
||||||
|
// when crouching.
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
if (isChest(block)) {
|
if (isChest(block)) {
|
||||||
|
@ -130,6 +135,7 @@ public class PlayerListener implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||||
if (!event.isCancelled() && event.getPlayer().getGameMode() == GameMode.CREATIVE) {
|
if (!event.isCancelled() && event.getPlayer().getGameMode() == GameMode.CREATIVE) {
|
||||||
|
|
|
@ -43,16 +43,15 @@ exception.storage.load: Failed to load your Inventory. Ask your Admin to enable
|
||||||
exception.region.not_optional: You can not be {0} in that area
|
exception.region.not_optional: You can not be {0} in that area
|
||||||
|
|
||||||
blocked.chest: Access to chests is not allowed in creative mode
|
blocked.chest: Access to chests is not allowed in creative mode
|
||||||
blocked.sign: To interact with signs is not allowed in creative mode
|
|
||||||
blocked.button: To interact with buttons is not allowed in creative mode
|
|
||||||
blocked.lever: To interact with levers is not allowed in creative mode
|
|
||||||
blocked.survival_flying: You should stay on ground, when leaving a creative-area
|
blocked.survival_flying: You should stay on ground, when leaving a creative-area
|
||||||
blocked.outside_place: You can not place blocks outside of the gamemode-area
|
blocked.outside_place: You can not place blocks outside of the gamemode-area
|
||||||
blocked.outside_break: You can not destroy blocks outside of the gamemode-area
|
blocked.outside_break: You can not destroy blocks outside of the gamemode-area
|
||||||
blocked.inside_place: You can not place blocks inside of the gamemode-area
|
blocked.inside_place: You can not place blocks inside of the gamemode-area
|
||||||
blocked.inside_break: You can not destroy blocks inside of the gamemode-area
|
blocked.inside_break: You can not destroy blocks inside of the gamemode-area
|
||||||
|
blocked.interact: You are not allowed to interact with this type of blocks
|
||||||
blocked.use: You are not allowed to use this type of item
|
blocked.use: You are not allowed to use this type of item
|
||||||
blocked.place: You are not allowed to place this type of block
|
blocked.place: You are not allowed to place this type of block
|
||||||
blocked.break: You are not allowed to break this type of block
|
blocked.break: You are not allowed to break this type of block
|
||||||
blocked.piston: Moving {0} block out of creative area was blocked at {1}
|
|
||||||
blocked.piston_in: Moving {0} block into creative area was blocked at {1}
|
blocked.region.piston: Moving {0} block out of creative area was blocked at {1}
|
||||||
|
blocked.region.piston_in: Moving {0} block into creative area was blocked at {1}
|
||||||
|
|
Loading…
Reference in a new issue