summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-12-04 23:21:30 +0100
committersnowleo <schneeleo@gmail.com>2011-12-04 23:21:30 +0100
commitcb89fe5358255ab66955d7b8ed41b0a447bae347 (patch)
tree4259659743c871dccb50207a29571c08d7c43fc6
parentad60eb538edb10844e971ef4912778aab9aa0033 (diff)
downloadEssentials-cb89fe5358255ab66955d7b8ed41b0a447bae347.tar
Essentials-cb89fe5358255ab66955d7b8ed41b0a447bae347.tar.gz
Essentials-cb89fe5358255ab66955d7b8ed41b0a447bae347.tar.lz
Essentials-cb89fe5358255ab66955d7b8ed41b0a447bae347.tar.xz
Essentials-cb89fe5358255ab66955d7b8ed41b0a447bae347.zip
Readded because of popular demand: default-stack-size for /give and /item, values below 1 return max stack size (or oversized stack size).
-rw-r--r--Essentials/src/com/earth2me/essentials/ISettings.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandgive.java19
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commanditem.java15
-rw-r--r--Essentials/src/config.yml5
5 files changed, 42 insertions, 5 deletions
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java
index 41e99c29c..de25c5c4f 100644
--- a/Essentials/src/com/earth2me/essentials/ISettings.java
+++ b/Essentials/src/com/earth2me/essentials/ISettings.java
@@ -32,6 +32,8 @@ public interface ISettings extends IConf
String getCurrencySymbol();
int getOversizedStackSize();
+
+ int getDefaultStackSize();
double getHealCooldown();
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index 1683fd7ef..b06677b44 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -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()
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
index 52e3375cd..6b5720cce 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
@@ -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();
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
index a749bb0a8..8628c3741 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
@@ -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();
diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml
index 2bb8dbd0c..89248180a 100644
--- a/Essentials/src/config.yml
+++ b/Essentials/src/config.yml
@@ -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?