From b8143c63c20b6d578a77edc84a5049323e3bf567 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Thu, 16 Jan 2014 01:48:38 -0500 Subject: [PATCH] [Bleeding] Implement methods for /achievement command. Addresses BUKKIT-4932 --- .../craftbukkit/util/CraftMagicNumbers.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 89c599eebf..43adac1363 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -1,5 +1,7 @@ package org.bukkit.craftbukkit.util; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import net.minecraft.server.Block; @@ -7,9 +9,13 @@ import net.minecraft.server.Blocks; import net.minecraft.server.Item; import net.minecraft.server.MojangsonParser; import net.minecraft.server.NBTTagCompound; +import net.minecraft.server.StatisticList; +import org.bukkit.Achievement; import org.bukkit.Material; +import org.bukkit.Statistic; import org.bukkit.UnsafeValues; +import org.bukkit.craftbukkit.CraftStatistic; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; import org.bukkit.util.StringUtil; @@ -100,4 +106,27 @@ public final class CraftMagicNumbers implements UnsafeValues { return stack; } + + @Override + public Statistic getStatisticFromInternalName(String name) { + return CraftStatistic.getBukkitStatisticByName(name); + } + + @Override + public Achievement getAchievementFromInternalName(String name) { + return CraftStatistic.getBukkitAchievementByName(name); + } + + @Override + public List tabCompleteInternalStatisticOrAchievementName(String token, List completions) { + List matches = new ArrayList(); + Iterator iterator = StatisticList.b.iterator(); + while (iterator.hasNext()) { + String statistic = ((net.minecraft.server.Statistic) iterator.next()).e; + if (statistic.startsWith(token)) { + matches.add(statistic); + } + } + return matches; + } }