mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-27 03:28:30 +01:00
Implement drop-items-if-full for /give command (default false)
This commit is contained in:
parent
e33c42e123
commit
306aab0d8d
@ -225,4 +225,6 @@ public interface ISettings extends IConf {
|
||||
String getCustomQuitMessage();
|
||||
|
||||
boolean isNotifyNoNewMail();
|
||||
|
||||
boolean isDropItemsIfFull();
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user