13
0
geforkt von Mirrors/Paper

Implement UnsafeValues for give command. Addresses BUKKIT-5286

Dieser Commit ist enthalten in:
Wesley Wolfe 2014-01-14 22:38:03 -06:00
Ursprung 81919478fc
Commit 05ed0a3139
2 geänderte Dateien mit 43 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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 org.bukkit.Material;
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;
}
}