Readded because of popular demand: default-stack-size for /give and /item, values below 1 return max stack size (or oversized stack size).

This commit is contained in:
snowleo 2011-12-04 23:21:30 +01:00
parent ad60eb538e
commit cb89fe5358
5 changed files with 42 additions and 5 deletions

View File

@ -32,6 +32,8 @@ public interface ISettings extends IConf
String getCurrencySymbol();
int getOversizedStackSize();
int getDefaultStackSize();
double getHealCooldown();

View File

@ -86,6 +86,12 @@ public class Settings implements ISettings
{
return config.getInt("oversized-stacksize", 64);
}
@Override
public int getDefaultStackSize()
{
return config.getInt("default-stack-size", -1);
}
@Override
public int getStartingBalance()

View File

@ -41,10 +41,21 @@ public class Commandgive extends EssentialsCommand
{
throw new Exception(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
}
final User giveTo = getPlayer(server, args, 0);
if (args.length > 2 && Integer.parseInt(args[2]) > 0)
{
stack.setAmount(Integer.parseInt(args[2]));
}
else if (ess.getSettings().getDefaultStackSize() > 0)
{
stack.setAmount(ess.getSettings().getDefaultStackSize());
}
else if (ess.getSettings().getOversizedStackSize() > 0 && giveTo.isAuthorized("essentials.oversizedstacks"))
{
stack.setAmount(ess.getSettings().getOversizedStackSize());
}
if (args.length > 3)
{
@ -74,12 +85,14 @@ public class Commandgive extends EssentialsCommand
throw new Exception(ChatColor.RED + "You can't give air.");
}
final User giveTo = getPlayer(server, args, 0);
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
if (giveTo.isAuthorized("essentials.oversizedstacks")) {
if (giveTo.isAuthorized("essentials.oversizedstacks"))
{
InventoryWorkaround.addItem(giveTo.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
} else {
}
else
{
InventoryWorkaround.addItem(giveTo.getInventory(), true, stack);
}
giveTo.updateInventory();

View File

@ -41,6 +41,14 @@ public class Commanditem extends EssentialsCommand
{
stack.setAmount(Integer.parseInt(args[1]));
}
else if (ess.getSettings().getDefaultStackSize() > 0)
{
stack.setAmount(ess.getSettings().getDefaultStackSize());
}
else if (ess.getSettings().getOversizedStackSize() > 0 && user.isAuthorized("essentials.oversizedstacks"))
{
stack.setAmount(ess.getSettings().getOversizedStackSize());
}
if (args.length > 2)
{
@ -72,9 +80,12 @@ public class Commanditem extends EssentialsCommand
final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
user.sendMessage(_("itemSpawn", stack.getAmount(), displayName));
if (user.isAuthorized("essentials.oversizedstacks")) {
if (user.isAuthorized("essentials.oversizedstacks"))
{
InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
} else {
}
else
{
InventoryWorkaround.addItem(user.getInventory(), true, stack);
}
user.updateInventory();

View File

@ -224,6 +224,11 @@ no-god-in-worlds:
# Give someone permission to teleport to a world with essentials.world.<worldname>
world-teleport-permissions: false
# The number of items given if the quantity parameter is left out in /item or /give.
# If this number is below 1, the maximum stack size size is given. If oversized stacks
# is not enabled, any number higher then the maximum stack size results in more than one stack.
default-stack-size: -1
# Oversized stacks are stacks that ignore the normal max stacksize.
# They can be obtained using /give and /item, if the player has essentials.oversizedstacks permission.
# How many items should be in a oversized stack?