summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorWesley Wolfe <weswolf@aol.com>2014-01-14 22:38:03 -0600
committerWesley Wolfe <weswolf@aol.com>2014-01-14 22:38:03 -0600
commit05ed0a3139e623501c3fad5d38edece4ff472f24 (patch)
treecc5faacdf8085a83cc361e1b136505b833808119 /src/main
parent81919478fc2a4bdc9df7bcd65336a19bec33026d (diff)
downloadcraftbukkit-05ed0a3139e623501c3fad5d38edece4ff472f24.tar
craftbukkit-05ed0a3139e623501c3fad5d38edece4ff472f24.tar.gz
craftbukkit-05ed0a3139e623501c3fad5d38edece4ff472f24.tar.lz
craftbukkit-05ed0a3139e623501c3fad5d38edece4ff472f24.tar.xz
craftbukkit-05ed0a3139e623501c3fad5d38edece4ff472f24.zip
Implement UnsafeValues for give command. Addresses BUKKIT-5286
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java8
-rw-r--r--src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java35
2 files changed, 42 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index f33681c5..f3e52007 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -61,6 +61,7 @@ import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
+import org.bukkit.UnsafeValues;
import org.bukkit.Warning.WarningState;
import org.bukkit.World;
import org.bukkit.World.Environment;
@@ -93,6 +94,7 @@ import org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager;
import org.bukkit.craftbukkit.updater.AutoUpdater;
import org.bukkit.craftbukkit.updater.BukkitDLUpdaterService;
import org.bukkit.craftbukkit.util.CraftIconCache;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.craftbukkit.util.DatFileFilter;
import org.bukkit.craftbukkit.util.Versioning;
import org.bukkit.entity.Player;
@@ -1460,4 +1462,10 @@ public final class CraftServer implements Server {
public int getIdleTimeout() {
return console.aq(); // Should be getIdleTimeout
}
+
+ @Deprecated
+ @Override
+ public UnsafeValues getUnsafe() {
+ return CraftMagicNumbers.INSTANCE;
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index aea20a65..89c599ee 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -1,11 +1,23 @@
package org.bukkit.craftbukkit.util;
+import java.util.List;
+
import net.minecraft.server.Block;
import net.minecraft.server.Blocks;
import net.minecraft.server.Item;
+import net.minecraft.server.MojangsonParser;
+import net.minecraft.server.NBTTagCompound;
+
import org.bukkit.Material;
+import org.bukkit.UnsafeValues;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.util.StringUtil;
+
+@SuppressWarnings("deprecation")
+public final class CraftMagicNumbers implements UnsafeValues {
+ public static final UnsafeValues INSTANCE = new CraftMagicNumbers();
-public final class CraftMagicNumbers {
private CraftMagicNumbers() {}
public static Block getBlock(org.bukkit.block.Block block) {
@@ -67,4 +79,25 @@ public final class CraftMagicNumbers {
return block;
}
+
+ @Override
+ public Material getMaterialFromInternalName(String name) {
+ return getMaterial((Item) Item.REGISTRY.a(name));
+ }
+
+ @Override
+ public List<String> tabCompleteInternalMaterialName(String token, List<String> completions) {
+ return StringUtil.copyPartialMatches(token, Item.REGISTRY.b(), completions);
+ }
+
+ @Override
+ public ItemStack modifyItemStack(ItemStack stack, String arguments) {
+ net.minecraft.server.ItemStack nmsStack = CraftItemStack.asNMSCopy(stack);
+
+ nmsStack.setTag((NBTTagCompound) MojangsonParser.a(arguments));
+
+ stack.setItemMeta(CraftItemStack.getItemMeta(nmsStack));
+
+ return stack;
+ }
}