[Bleeding] Implement methods for /achievement command. Addresses BUKKIT-4932

This commit is contained in:
t00thpick1 2014-01-16 01:48:38 -05:00 committed by Wesley Wolfe
parent 622a2976d9
commit b8143c63c2

View File

@ -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<String> tabCompleteInternalStatisticOrAchievementName(String token, List<String> completions) {
List<String> matches = new ArrayList<String>();
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;
}
}