mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-03-02 11:11:58 +01:00
Fix attempting to spawn invalid items.
This commit is contained in:
parent
e66ad88451
commit
1bb569fff2
@ -10,6 +10,7 @@ import java.util.*;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
import java.util.logging.Level;
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
@ -26,6 +27,7 @@ public class MetaItemStack
|
|||||||
{
|
{
|
||||||
private static final Map<String, DyeColor> colorMap = new HashMap<String, DyeColor>();
|
private static final Map<String, DyeColor> colorMap = new HashMap<String, DyeColor>();
|
||||||
private static final Map<String, FireworkEffect.Type> fireworkShape = new HashMap<String, FireworkEffect.Type>();
|
private static final Map<String, FireworkEffect.Type> fireworkShape = new HashMap<String, FireworkEffect.Type>();
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
for (DyeColor color : DyeColor.values())
|
for (DyeColor color : DyeColor.values())
|
||||||
@ -95,6 +97,35 @@ public class MetaItemStack
|
|||||||
completePotion = true;
|
completePotion = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canSpawn(final IEssentials ess)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ess.getServer().getUnsafe().modifyItemStack(stack, "{}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (NullPointerException npe)
|
||||||
|
{
|
||||||
|
if (ess.getSettings().isDebug())
|
||||||
|
{
|
||||||
|
ess.getLogger().log(Level.INFO, "Itemstack is invalid", npe);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (NoSuchMethodError nsme)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Throwable throwable)
|
||||||
|
{
|
||||||
|
if (ess.getSettings().isDebug())
|
||||||
|
{
|
||||||
|
ess.getLogger().log(Level.INFO, "Itemstack is invalid", throwable);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void parseStringMeta(final CommandSource sender, final boolean allowUnsafe, String[] string, int fromArg, final IEssentials ess) throws Exception
|
public void parseStringMeta(final CommandSource sender, final boolean allowUnsafe, String[] string, int fromArg, final IEssentials ess) throws Exception
|
||||||
{
|
{
|
||||||
if (string[fromArg].startsWith("{"))
|
if (string[fromArg].startsWith("{"))
|
||||||
@ -103,6 +134,13 @@ public class MetaItemStack
|
|||||||
{
|
{
|
||||||
stack = ess.getServer().getUnsafe().modifyItemStack(stack, Joiner.on(' ').join(Arrays.asList(string).subList(fromArg, string.length)));
|
stack = ess.getServer().getUnsafe().modifyItemStack(stack, Joiner.on(' ').join(Arrays.asList(string).subList(fromArg, string.length)));
|
||||||
}
|
}
|
||||||
|
catch (NullPointerException npe)
|
||||||
|
{
|
||||||
|
if (ess.getSettings().isDebug())
|
||||||
|
{
|
||||||
|
ess.getLogger().log(Level.INFO, "Itemstack is invalid", npe);
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (NoSuchMethodError nsme)
|
catch (NoSuchMethodError nsme)
|
||||||
{
|
{
|
||||||
throw new Exception(tl("noMetaJson"), nsme);
|
throw new Exception(tl("noMetaJson"), nsme);
|
||||||
|
@ -69,9 +69,14 @@ public class Commandgive extends EssentialsCommand
|
|||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaItemStack metaStack = new MetaItemStack(stack);
|
||||||
|
if (!metaStack.canSpawn(ess))
|
||||||
|
{
|
||||||
|
throw new Exception(tl("unableToSpawnItem", itemname));
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length > 3)
|
if (args.length > 3)
|
||||||
{
|
{
|
||||||
MetaItemStack metaStack = new MetaItemStack(stack);
|
|
||||||
boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
|
boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
|
||||||
if (allowUnsafe && sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.enchantments.allowunsafe"))
|
if (allowUnsafe && sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.enchantments.allowunsafe"))
|
||||||
{
|
{
|
||||||
|
@ -6661,6 +6661,7 @@ goldencarrot,396,0
|
|||||||
goldcarrot,396,0
|
goldcarrot,396,0
|
||||||
gcarrot,396,0
|
gcarrot,396,0
|
||||||
head,397,0
|
head,397,0
|
||||||
|
skull,397,0
|
||||||
skeletonhead,397,0
|
skeletonhead,397,0
|
||||||
headskeleton,397,0
|
headskeleton,397,0
|
||||||
skeletonskull,397,0
|
skeletonskull,397,0
|
||||||
|
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000 characters.
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000 characters.
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000 characters.
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000 characters.
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
@ -546,3 +546,4 @@ gameModeInvalid=\u00a74You need to specify a valid player/mode.
|
|||||||
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
|
||||||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||||
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
|
||||||
|
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||||
|
Loading…
Reference in New Issue
Block a user