mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-28 12:07:38 +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();
|
String getCustomQuitMessage();
|
||||||
|
|
||||||
boolean isNotifyNoNewMail();
|
boolean isNotifyNoNewMail();
|
||||||
|
|
||||||
|
boolean isDropItemsIfFull();
|
||||||
}
|
}
|
||||||
|
@ -1106,6 +1106,11 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
return config.getBoolean("notify-no-new-mail", true);
|
return config.getBoolean("notify-no-new-mail", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDropItemsIfFull() {
|
||||||
|
return config.getBoolean("drop-items-if-full", false);
|
||||||
|
}
|
||||||
|
|
||||||
// #easteregg
|
// #easteregg
|
||||||
@Override
|
@Override
|
||||||
public int getMaxUserCacheCount() {
|
public int getMaxUserCacheCount() {
|
||||||
|
@ -7,6 +7,7 @@ import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
|||||||
import com.earth2me.essentials.utils.NumberUtil;
|
import com.earth2me.essentials.utils.NumberUtil;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -85,9 +86,16 @@ public class Commandgive extends EssentialsCommand {
|
|||||||
leftovers = InventoryWorkaround.addItems(giveTo.getBase().getInventory(), stack);
|
leftovers = InventoryWorkaround.addItems(giveTo.getBase().getInventory(), stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isDropItemsIfFull = ess.getSettings().isDropItemsIfFull();
|
||||||
|
|
||||||
for (ItemStack item : leftovers.values()) {
|
for (ItemStack item : leftovers.values()) {
|
||||||
|
if (isDropItemsIfFull) {
|
||||||
|
World w = giveTo.getWorld();
|
||||||
|
w.dropItemNaturally(giveTo.getLocation(), item);
|
||||||
|
} else {
|
||||||
sender.sendMessage(tl("giveSpawnFailure", item.getAmount(), itemName, giveTo.getDisplayName()));
|
sender.sendMessage(tl("giveSpawnFailure", item.getAmount(), itemName, giveTo.getDisplayName()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
giveTo.getBase().updateInventory();
|
giveTo.getBase().updateInventory();
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,9 @@ spawnmob-limit: 10
|
|||||||
# Shall we notify users when using /lightning?
|
# Shall we notify users when using /lightning?
|
||||||
warn-on-smite: true
|
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
|
# Essentials Mail Notification
|
||||||
# Should we notify players if they have no new mail?
|
# Should we notify players if they have no new mail?
|
||||||
notify-no-new-mail: true
|
notify-no-new-mail: true
|
||||||
|
Loading…
Reference in New Issue
Block a user