mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-05 20:12:54 +00: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
5 changed files with 42 additions and 5 deletions
|
@ -33,6 +33,8 @@ public interface ISettings extends IConf
|
||||||
|
|
||||||
int getOversizedStackSize();
|
int getOversizedStackSize();
|
||||||
|
|
||||||
|
int getDefaultStackSize();
|
||||||
|
|
||||||
double getHealCooldown();
|
double getHealCooldown();
|
||||||
|
|
||||||
Object getKit(String name);
|
Object getKit(String name);
|
||||||
|
|
|
@ -87,6 +87,12 @@ public class Settings implements ISettings
|
||||||
return config.getInt("oversized-stacksize", 64);
|
return config.getInt("oversized-stacksize", 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDefaultStackSize()
|
||||||
|
{
|
||||||
|
return config.getInt("default-stack-size", -1);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStartingBalance()
|
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);
|
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)
|
if (args.length > 2 && Integer.parseInt(args[2]) > 0)
|
||||||
{
|
{
|
||||||
stack.setAmount(Integer.parseInt(args[2]));
|
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)
|
if (args.length > 3)
|
||||||
{
|
{
|
||||||
|
@ -74,12 +85,14 @@ public class Commandgive extends EssentialsCommand
|
||||||
throw new Exception(ChatColor.RED + "You can't give air.");
|
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('_', ' ');
|
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
||||||
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
|
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);
|
InventoryWorkaround.addItem(giveTo.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
InventoryWorkaround.addItem(giveTo.getInventory(), true, stack);
|
InventoryWorkaround.addItem(giveTo.getInventory(), true, stack);
|
||||||
}
|
}
|
||||||
giveTo.updateInventory();
|
giveTo.updateInventory();
|
||||||
|
|
|
@ -41,6 +41,14 @@ public class Commanditem extends EssentialsCommand
|
||||||
{
|
{
|
||||||
stack.setAmount(Integer.parseInt(args[1]));
|
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)
|
if (args.length > 2)
|
||||||
{
|
{
|
||||||
|
@ -72,9 +80,12 @@ public class Commanditem extends EssentialsCommand
|
||||||
|
|
||||||
final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
||||||
user.sendMessage(_("itemSpawn", stack.getAmount(), displayName));
|
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);
|
InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
InventoryWorkaround.addItem(user.getInventory(), true, stack);
|
InventoryWorkaround.addItem(user.getInventory(), true, stack);
|
||||||
}
|
}
|
||||||
user.updateInventory();
|
user.updateInventory();
|
||||||
|
|
|
@ -224,6 +224,11 @@ no-god-in-worlds:
|
||||||
# Give someone permission to teleport to a world with essentials.world.<worldname>
|
# Give someone permission to teleport to a world with essentials.world.<worldname>
|
||||||
world-teleport-permissions: false
|
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.
|
# 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.
|
# They can be obtained using /give and /item, if the player has essentials.oversizedstacks permission.
|
||||||
# How many items should be in a oversized stack?
|
# How many items should be in a oversized stack?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue