mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 11:49:12 +00:00
[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
This commit is contained in:
parent
037473d13b
commit
7efdb11d53
4 changed files with 45 additions and 15 deletions
|
@ -478,4 +478,9 @@ public class Settings implements IConf
|
||||||
{
|
{
|
||||||
return config.getBoolean("warn-on-smite" ,true);
|
return config.getBoolean("warn-on-smite" ,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean permissionBasedItemSpawn()
|
||||||
|
{
|
||||||
|
return config.getBoolean("permission-based-item-spawn", false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,16 @@ public class Commandgive extends EssentialsCommand
|
||||||
String[] itemArgs = args[1].split("[^a-zA-Z0-9]");
|
String[] itemArgs = args[1].split("[^a-zA-Z0-9]");
|
||||||
ItemStack stack = ItemDb.get(itemArgs[0]);
|
ItemStack stack = ItemDb.get(itemArgs[0]);
|
||||||
|
|
||||||
|
String itemname = stack.getType().toString().toLowerCase().replace("_", "");
|
||||||
if (sender instanceof Player
|
if (sender instanceof Player
|
||||||
&& !ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt")
|
&& (ess.getSettings().permissionBasedItemSpawn()
|
||||||
&& !ess.getUser(sender).canSpawnItem(stack.getTypeId()))
|
? !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;
|
return;
|
||||||
}
|
}
|
||||||
if (itemArgs.length > 1)
|
if (itemArgs.length > 1)
|
||||||
|
@ -43,8 +48,9 @@ public class Commandgive extends EssentialsCommand
|
||||||
{
|
{
|
||||||
stack.setAmount(Integer.parseInt(args[2]));
|
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.");
|
sender.sendMessage(ChatColor.RED + "You can't give air.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,20 +25,29 @@ public class Commanditem extends EssentialsCommand
|
||||||
String[] itemArgs = args[0].split("[^a-zA-Z0-9]");
|
String[] itemArgs = args[0].split("[^a-zA-Z0-9]");
|
||||||
ItemStack stack = ItemDb.get(itemArgs[0]);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if (itemArgs.length > 1) {
|
if (itemArgs.length > 1)
|
||||||
|
{
|
||||||
stack.setDurability(Short.parseShort(itemArgs[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]));
|
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.");
|
user.sendMessage(ChatColor.RED + "You can't get air.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,19 @@ heal-cooldown: 60
|
||||||
# The number of items given if the quantity parameter is left out in /item or /give.
|
# The number of items given if the quantity parameter is left out in /item or /give.
|
||||||
default-stack-size: 64
|
default-stack-size: 64
|
||||||
|
|
||||||
#what to prevent from /i /give
|
# What to prevent from /i /give
|
||||||
#e.g item-spawn-blacklist: 46,11,10
|
# e.g item-spawn-blacklist: 46,11,10
|
||||||
item-spawn-blacklist:
|
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.
|
# 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.
|
# This generally increases server stability unless very specific runtime configurations are used.
|
||||||
|
|
Loading…
Reference in a new issue