-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommandBack.java
77 lines (56 loc) · 2.21 KB
/
CommandBack.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
69
70
71
72
73
74
75
76
package kdx7214.necessities;
import java.util.Collection;
import java.util.List;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.ModLoader;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.command.* ;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.* ;
public class CommandBack extends CommandBaseNecessities {
public CommandBack() {
}
public String getCommandName()
{
return "back";
}
public String getCommandUsage(ICommandSender par1ICommandSender)
{
return "/" + getCommandName() ;
}
public List getCommandAliases()
{
return null;
}
public void processCommand(ICommandSender sender, String[] par2ArrayOfStr)
{
MinecraftServer server = ModLoader.getMinecraftServerInstance() ;
EntityPlayer player = getCommandSenderAsPlayer(sender) ;
EntityPlayerMP playerMP = (EntityPlayerMP) sender ;
// Now deal with the NBT stuff
NBTTagCompound playerdata = NecessitiesMain.instance.necessities_data.getCompoundTag(player.username) ;
NecessitiesMain.instance.necessities_data.setCompoundTag(player.username, playerdata) ;
if (!playerdata.hasKey("[Back]")) {
sender.sendChatToPlayer("No position to go back to!") ;
return ;
}
NBTTagCompound back = playerdata.getCompoundTag("[Back]") ;
playerdata.setCompoundTag("[Back]", back) ;
double posX = back.getDouble("PosX") ;
double posY = back.getDouble("PosY") ;
double posZ = back.getDouble("PosZ") ;
float pitch = back.getFloat("Pitch") ;
float yaw = back.getFloat("Yaw") ;
int dim = back.getInteger("Dim") ;
setBackLocation(player) ;
if (player.dimension != dim)
server.getConfigurationManager().transferPlayerToDimension(((EntityPlayerMP) player), dim);
playerMP.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, yaw, pitch) ;
} // public void processCommand(...)
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender)
{
return hasPermission(sender, "necessities.back", false, false) ;
}
} // public class CommandBack