blob: ebf7d8b6dbfef27ef0f4a1835a97f1a859ee7a34 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/**
*
*/
package darkknight.jewelrycraft.commands;
/**
* @author Sorin
*
*/
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import darkknight.jewelrycraft.JewelrycraftMod;
import darkknight.jewelrycraft.api.Curse;
import darkknight.jewelrycraft.events.EntityEventHandler;
import darkknight.jewelrycraft.network.PacketRequestPlayerInfo;
import darkknight.jewelrycraft.util.JewelryNBT;
import darkknight.jewelrycraft.util.JewelrycraftUtil;
import darkknight.jewelrycraft.util.PlayerUtils;
public class JewelrycraftCommands extends CommandBase
{
private List aliases;
public JewelrycraftCommands()
{
this.aliases = new ArrayList();
this.aliases.add("jw");
this.aliases.add("jewelry");
}
@Override
public String getCommandName()
{
return "jewelrycraft";
}
@Override
public String getCommandUsage(ICommandSender var1)
{
return "/jewelrycraft <addCursePoints:getCursePoints:setCursePoints> <user> [points]";
}
@Override
public List getCommandAliases()
{
return aliases;
}
@Override
public void processCommand(ICommandSender commandSender, String[] astring)
{
if (astring.length == 0 || astring[0].equals("help")) throw new WrongUsageException(getCommandUsage(commandSender));
if (astring[0].equals("getCursePoints")){
EntityPlayerMP entityplayermp = getPlayer(commandSender, astring[1]);
commandSender.addChatMessage(new ChatComponentTranslation(Integer.toString(JewelrycraftUtil.getCursePoints(entityplayermp))));
}else if (astring[0].equals("addCursePoints")){
int points = CommandBase.parseIntWithMin(commandSender, astring[2], 0);
EntityPlayerMP entityplayermp = getPlayer(commandSender, astring[1]);
JewelrycraftUtil.addCursePoints(entityplayermp, points);
}else if (astring[0].equals("setCursePoints")){
int points = CommandBase.parseIntWithMin(commandSender, astring[2], 0);
EntityPlayerMP entityplayermp = getPlayer(commandSender, astring[1]);
JewelrycraftUtil.addCursePoints(entityplayermp, points - JewelrycraftUtil.getCursePoints(entityplayermp));
}
}
@Override
public List addTabCompletionOptions(ICommandSender icommandsender, String[] astring)
{
final List<String> MATCHES = new LinkedList<String>();
final String ARG_LC = astring[astring.length - 1].toLowerCase();
if (astring.length == 1){
if ("addCursePoints".toLowerCase().startsWith(ARG_LC)) MATCHES.add("addCursePoints");
if ("getCursePoints".toLowerCase().startsWith(ARG_LC)) MATCHES.add("getCursePoints");
if ("setCursePoints".toLowerCase().startsWith(ARG_LC)) MATCHES.add("setCursePoints");
}else if (astring.length == 2){
for(String un: MinecraftServer.getServer().getAllUsernames())
if (un.toLowerCase().startsWith(ARG_LC)) MATCHES.add(un);
}
return MATCHES.isEmpty() ? null : MATCHES;
}
}
|