Implement drop-items-if-full for /give command (default false)

This commit is contained in:
vemacs 2015-06-28 10:28:55 -05:00
parent e33c42e123
commit 306aab0d8d
4 changed files with 19 additions and 1 deletions

View file

@ -225,4 +225,6 @@ public interface ISettings extends IConf {
String getCustomQuitMessage();
boolean isNotifyNoNewMail();
boolean isDropItemsIfFull();
}

View file

@ -1106,6 +1106,11 @@ public class Settings implements net.ess3.api.ISettings {
return config.getBoolean("notify-no-new-mail", true);
}
@Override
public boolean isDropItemsIfFull() {
return config.getBoolean("drop-items-if-full", false);
}
// #easteregg
@Override
public int getMaxUserCacheCount() {

View file

@ -7,6 +7,7 @@ import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import com.earth2me.essentials.utils.NumberUtil;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.inventory.ItemStack;
import java.util.Locale;
@ -85,8 +86,15 @@ public class Commandgive extends EssentialsCommand {
leftovers = InventoryWorkaround.addItems(giveTo.getBase().getInventory(), stack);
}
boolean isDropItemsIfFull = ess.getSettings().isDropItemsIfFull();
for (ItemStack item : leftovers.values()) {
sender.sendMessage(tl("giveSpawnFailure", item.getAmount(), itemName, giveTo.getDisplayName()));
if (isDropItemsIfFull) {
World w = giveTo.getWorld();
w.dropItemNaturally(giveTo.getLocation(), item);
} else {
sender.sendMessage(tl("giveSpawnFailure", item.getAmount(), itemName, giveTo.getDisplayName()));
}
}
giveTo.getBase().updateInventory();

View file

@ -95,6 +95,9 @@ spawnmob-limit: 10
# Shall we notify users when using /lightning?
warn-on-smite: true
# Shall we drop items instead of adding to inventory if the target inventory is full?
drop-items-if-full: false
# Essentials Mail Notification
# Should we notify players if they have no new mail?
notify-no-new-mail: true