summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-02 01:49:38 +0000
committersnowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-02 01:49:38 +0000
commit7efdb11d53ee0eee0a6a82bd83108dd4d94718f9 (patch)
treecf9750f517092f83c0d258bb7338a95a59d8c313
parent037473d13b6d4ed79119f4b257f7655c2d7bbca7 (diff)
downloadEssentials-7efdb11d53ee0eee0a6a82bd83108dd4d94718f9.tar
Essentials-7efdb11d53ee0eee0a6a82bd83108dd4d94718f9.tar.gz
Essentials-7efdb11d53ee0eee0a6a82bd83108dd4d94718f9.tar.lz
Essentials-7efdb11d53ee0eee0a6a82bd83108dd4d94718f9.tar.xz
Essentials-7efdb11d53ee0eee0a6a82bd83108dd4d94718f9.zip
[trunk] /item /give, new permissions
- essentials.itemspawn.item-all - essentials.itemspawn.item-[itemname] - essentials.itemspawn.item-[itemid] - essentials.give.item-all - essentials.give.item-[itemname] - essentials.give.item-[itemid] these have to be activated with permission-based-item-spawn: true in config.yml git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1309 e251c2fe-e539-e718-e476-b85c1f46cddb
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandgive.java16
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commanditem.java23
-rw-r--r--Essentials/src/config.yml16
4 files changed, 45 insertions, 15 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index b7a000dd6..494751c76 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -478,4 +478,9 @@ public class Settings implements IConf
{
return config.getBoolean("warn-on-smite" ,true);
}
+
+ public boolean permissionBasedItemSpawn()
+ {
+ return config.getBoolean("permission-based-item-spawn", false);
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
index e9a0f792c..717da0ca2 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
@@ -28,11 +28,16 @@ public class Commandgive extends EssentialsCommand
String[] itemArgs = args[1].split("[^a-zA-Z0-9]");
ItemStack stack = ItemDb.get(itemArgs[0]);
+ String itemname = stack.getType().toString().toLowerCase().replace("_", "");
if (sender instanceof Player
- && !ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt")
- && !ess.getUser(sender).canSpawnItem(stack.getTypeId()))
+ && (ess.getSettings().permissionBasedItemSpawn()
+ ? !ess.getUser(sender).isAuthorized("essentials.give.item-all")
+ && !ess.getUser(sender).isAuthorized("essentials.give.item-" + itemname)
+ && !ess.getUser(sender).isAuthorized("essentials.give.item-" + stack.getTypeId())
+ : !ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt")
+ && !ess.getUser(sender).canSpawnItem(stack.getTypeId())))
{
- sender.sendMessage(ChatColor.RED + "You are not allowed to spawn that item");
+ sender.sendMessage(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
return;
}
if (itemArgs.length > 1)
@@ -43,8 +48,9 @@ public class Commandgive extends EssentialsCommand
{
stack.setAmount(Integer.parseInt(args[2]));
}
-
- if (stack.getType() == Material.AIR) {
+
+ if (stack.getType() == Material.AIR)
+ {
sender.sendMessage(ChatColor.RED + "You can't give air.");
return;
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
index fa960961f..e944acbca 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
@@ -25,20 +25,29 @@ public class Commanditem extends EssentialsCommand
String[] itemArgs = args[0].split("[^a-zA-Z0-9]");
ItemStack stack = ItemDb.get(itemArgs[0]);
- if(!user.isAuthorized("essentials.itemspawn.exempt") && !user.canSpawnItem(stack.getTypeId()))
+ String itemname = stack.getType().toString().toLowerCase().replace("_", "");
+ if (ess.getSettings().permissionBasedItemSpawn()
+ ? !user.isAuthorized("essentials.itemspawn.item-all")
+ && !user.isAuthorized("essentials.itemspawn.item-" + itemname)
+ && !user.isAuthorized("essentials.itemspawn.item-" + stack.getTypeId())
+ : !user.isAuthorized("essentials.itemspawn.exempt")
+ && !user.canSpawnItem(stack.getTypeId()))
{
- user.sendMessage(ChatColor.RED + "You are not allowed to spawn that item");
+ user.sendMessage(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
return;
}
- if (itemArgs.length > 1) {
+ if (itemArgs.length > 1)
+ {
stack.setDurability(Short.parseShort(itemArgs[1]));
}
-
- if (args.length > 1 && Integer.parseInt(args[1]) > 0) {
+
+ if (args.length > 1 && Integer.parseInt(args[1]) > 0)
+ {
stack.setAmount(Integer.parseInt(args[1]));
}
-
- if (stack.getType() == Material.AIR) {
+
+ if (stack.getType() == Material.AIR)
+ {
user.sendMessage(ChatColor.RED + "You can't get air.");
return;
}
diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml
index 7d3c7a17f..8874ab78d 100644
--- a/Essentials/src/config.yml
+++ b/Essentials/src/config.yml
@@ -46,9 +46,19 @@ heal-cooldown: 60
# The number of items given if the quantity parameter is left out in /item or /give.
default-stack-size: 64
-#what to prevent from /i /give
-#e.g item-spawn-blacklist: 46,11,10
-item-spawn-blacklist:
+# What to prevent from /i /give
+# e.g item-spawn-blacklist: 46,11,10
+item-spawn-blacklist:
+
+# Set this to true if you want permission based item spawn rules
+# Permissions:
+# - essentials.itemspawn.item-all
+# - essentials.itemspawn.item-[itemname]
+# - essentials.itemspawn.item-[itemid]
+# - essentials.give.item-all
+# - essentials.give.item-[itemname]
+# - essentials.give.item-[itemid]
+permission-based-item-spawn: false
# Whether or not to reclaim memory on player logout; this is technical, and should only be changed under special circumstances.
# This generally increases server stability unless very specific runtime configurations are used.