Alert give sender that the user was unable to receive all the items.

This commit is contained in:
cexikitin 2013-06-04 17:12:15 -04:00 committed by KHobbits
parent 09f67c9723
commit f38ed576c5
18 changed files with 32 additions and 6 deletions

View File

@ -3,10 +3,10 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.MetaItemStack;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.Locale;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -73,14 +73,14 @@ public class Commandgive extends EssentialsCommand
if (args.length > 3)
{
MetaItemStack metaStack = new MetaItemStack(stack);
boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
if (allowUnsafe && sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.enchantments.allowunsafe"))
{
allowUnsafe = false;
}
metaStack.parseStringMeta(sender, allowUnsafe, args, NumberUtil.isInt(args[3]) ? 4 : 3, ess);
stack = metaStack.getItemStack();
}
@ -91,14 +91,23 @@ public class Commandgive extends EssentialsCommand
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
sender.sendMessage(_("giveSpawn", stack.getAmount(), itemName, giveTo.getDisplayName()));
Map<Integer, ItemStack> leftovers;
if (giveTo.isAuthorized("essentials.oversizedstacks"))
{
InventoryWorkaround.addOversizedItems(giveTo.getInventory(), ess.getSettings().getOversizedStackSize(), stack);
leftovers = InventoryWorkaround.addOversizedItems(giveTo.getInventory(), ess.getSettings().getOversizedStackSize(), stack);
}
else
{
InventoryWorkaround.addItems(giveTo.getInventory(), stack);
leftovers = InventoryWorkaround.addItems(giveTo.getInventory(), stack);
}
for (ItemStack item : leftovers.values())
{
sender.sendMessage(_("giveSpawnFailure", item.getAmount(), itemName, giveTo.getDisplayName()));
}
giveTo.updateInventory();
}
}

View File

@ -134,6 +134,7 @@ geoIpUrlEmpty=GeoIP download url is empty.
geoIpUrlInvalid=GeoIP download url is invalid.
geoipJoinFormat=\u00a76Player \u00a7c{0} \u00a76comes from \u00a7c{1}\u00a76.
giveSpawn=\u00a76Giving\u00a7c {0} \u00a76of\u00a7c {1} to\u00a7c {2}\u00a76.
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.
godDisabledFor=\u00a74disabled\u00a76 for\u00a7c {0}
godEnabledFor=\u00a7aenabled\u00a76 for\u00a7c {0}
godMode=\u00a76God mode\u00a7c {0}\u00a76.

View File

@ -545,3 +545,4 @@ youAreHealed=\u00a77Byl jsi uzdraven.
youHaveNewMail=\u00a7cMas {0} zprav!\u00a7f Napis \u00a77/mail read\u00a7f aby jsi si precetl sve zpravy.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -541,3 +541,4 @@ youAreHealed=\u00a77Du er blevet healed. Halleluja!
youHaveNewMail=\u00a7cDu har {0} flaskeposter!\u00a7f Type \u00a77/mail read for at se din flaskepost.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -541,3 +541,4 @@ youAreHealed=\u00a77Du wurdest geheilt.
youHaveNewMail=\u00a7cDu hast {0} Nachrichten!\u00a7f Schreibe \u00a77/mail read\u00a7f um deine Nachrichten anzuzeigen.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -541,3 +541,4 @@ youAreHealed=\u00a76You have been healed.
youHaveNewMail=\u00a76You have\u00a7c {0} \u00a76messages! Type \u00a7c/mail read\u00a76 to view your mail.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -541,3 +541,4 @@ youAreHealed=\u00a77Has sido curado.
youHaveNewMail=\u00a7cTienes {0} mensajes!\u00a7f Pon \u00a77/mail read\u00a7f para ver tus emails no leidos!.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -541,3 +541,4 @@ youAreHealed=\u00a77Sinut on parannettu.
youHaveNewMail=\u00a7cSinulla on {0} viesti(\u00e4)!\u00a7f Kirjoita \u00a77/mail read\u00a7f lukeaksesi viestit.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -541,3 +541,4 @@ youAreHealed=\u00a77Vous avez \u00e9t\u00e9 soign\u00e9.
youHaveNewMail=\u00a7cVous avez {0} message(s) ! \u00a7fEntrez \u00a77/mail read\u00a7f pour voir votre courrier.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -541,3 +541,4 @@ youAreHealed=\u00a77Sei stato curato.
youHaveNewMail=\u00a7cHai {0} messaggi!\u00a7f digita \u00a77/mail read\u00a7f per consultare la tua mail.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -541,3 +541,4 @@ youAreHealed=\u00a77Je bent genezen.
youHaveNewMail=\u00a7cJe hebt {0} berichten!\u00a7f Type \u00a77/mail read\u00a7f om je berichten te bekijken.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -541,3 +541,4 @@ youAreHealed=\u00a77Zostales uleczony.
youHaveNewMail=\u00a77Masz\u00a7c {0} \u00a77wiadomosci! Wpisz \u00a7c/mail read\u00a77 aby je przeczytac.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -541,3 +541,4 @@ youAreHealed=\u00a76Voc\u00c3\u00aa foi curado.
youHaveNewMail=\u00a76Voc\u00c3\u00aa tem\u00a7c {0} \u00a76mensagens! Digite \u00a7c/mail read\u00a76 para v\u00c3\u00aa-las.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -541,3 +541,4 @@ youAreHealed=\u00a76Ai fost vindecat.
youHaveNewMail=\u00a76Ai\u00a7c {0} \u00a76mesaje! scrie \u00a7c/mail read\u00a76 pentru a-ti vedea mesajele.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -541,3 +541,4 @@ youAreHealed=\u00a77Du har blivit l\u00e4kt.
youHaveNewMail=\u00a7cDu har {0} meddelanden!\u00a7f Skriv \u00a77/mail read\u00a7f f\u00f6r att l\u00e4sa dina meddelanden.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -542,3 +542,4 @@ youAreHealed=\u00a76\u4f60\u5df2\u88ab\u6cbb\u7597
youHaveNewMail=\u00a76\u4f60\u62e5\u6709 \u00a7c{0}\u00a76 \u6761\u6d88\u606f\uff01\u00a7r\u8f93\u5165 \u00a7c/mail read\u00a76 \u6765\u67e5\u770b
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -543,3 +543,4 @@ youAreHealed=\u00a76\u4f60\u5df2\u88ab\u6cbb\u7642
youHaveNewMail=\u00a76\u4f60\u64c1\u6709 \u00a7c{0}\u00a76 \u689d\u6d88\u606f\uff01\u00a7r\u8f38\u5165 \u00a7c/mail read\u00a76 \u4f86\u67e5\u770b
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.

View File

@ -543,3 +543,4 @@ youAreHealed=\u00a76\u4f60\u5df2\u88ab\u6cbb\u7642
youHaveNewMail=\u00a76\u4f60\u64c1\u6709 \u00a7c{0}\u00a76 \u689d\u6d88\u606f\uff01\u00a7r\u8f38\u5165 \u00a7c/mail read\u00a76 \u4f86\u67e5\u770b
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
kitDelay=\u00a7m{0}\u00a7r
giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} \u00a7c{1} \u00a74was lost.