-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommandDelHome.java
69 lines (50 loc) · 1.89 KB
/
CommandDelHome.java
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
package kdx7214.necessities;
import java.util.List;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.ModLoader;
public class CommandDelHome extends CommandBaseNecessities {
public CommandDelHome() {
}
public String getCommandName()
{
return "delhome";
}
public List getCommandAliases()
{
return null;
}
@Override
public String getCommandUsage(ICommandSender var1) {
return "/" + getCommandName() + " <homename>" ;
}
@Override
public void processCommand(ICommandSender sender, String[] par2ArrayOfStr) {
assert(sender instanceof EntityPlayer || sender instanceof EntityPlayerMP) ;
if (par2ArrayOfStr.length != 1) {
sender.sendChatToPlayer(getCommandUsage(sender)) ;
return ;
}
MinecraftServer server = ModLoader.getMinecraftServerInstance() ;
EntityPlayer player = getCommandSenderAsPlayer(sender) ;
NBTTagCompound playerdata = NecessitiesMain.instance.necessities_data.getCompoundTag(player.username) ;
NecessitiesMain.instance.necessities_data.setCompoundTag(player.username, playerdata) ;
NBTTagCompound homes = playerdata.getCompoundTag("Homes") ;
playerdata.setCompoundTag("Homes", homes) ;
if (!homes.hasKey(par2ArrayOfStr[0])) {
sender.sendChatToPlayer("Unknown home.") ;
return ;
}
homes.removeTag(par2ArrayOfStr[0]) ;
sender.sendChatToPlayer("Home \"" + par2ArrayOfStr[0] + "\" deleted.") ;
}
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender) {
return hasPermission(sender, "necessities.delhome", false, false) ;
}
} // public class CommandDelHome