mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-18 00:25:32 +01:00
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:
parent
ad60eb538e
commit
cb89fe5358
@ -32,6 +32,8 @@ public interface ISettings extends IConf
|
||||
String getCurrencySymbol();
|
||||
|
||||
int getOversizedStackSize();
|
||||
|
||||
int getDefaultStackSize();
|
||||
|
||||
double getHealCooldown();
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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?
|
||||
|
Loading…
Reference in New Issue
Block a user