-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommandSpawn.java
68 lines (50 loc) · 2.1 KB
/
CommandSpawn.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
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;
import net.minecraft.util.ChunkCoordinates;
public class CommandSpawn extends CommandBaseNecessities {
@Override
public String getCommandName()
{
return "spawn";
}
@Override
public String getCommandUsage(ICommandSender par1ICommandSender)
{
return "/" + getCommandName() ;
}
@Override
public void processCommand(ICommandSender sender, String[] par2ArrayOfStr)
{
if (!NecessitiesMain.instance.necessities_data.hasKey("[Spawn]")) {
sender.sendChatToPlayer("No Spawn point has been set.") ;
return ;
}
MinecraftServer server = ModLoader.getMinecraftServerInstance() ;
EntityPlayer player = getCommandSenderAsPlayer(sender) ;
EntityPlayerMP playerMP = (EntityPlayerMP) sender ;
sender.sendChatToPlayer("Returning to spawn point.") ;
setBackLocation(player) ;
NBTTagCompound spawn = NecessitiesMain.instance.necessities_data.getCompoundTag("[Spawn]") ;
double posX = spawn.getDouble("PosX") ;
double posY = spawn.getDouble("PosY") ;
double posZ = spawn.getDouble("PosZ") ;
float yaw = spawn.getFloat("Yaw") ;
float pitch = spawn.getFloat("Pitch") ;
int dim = spawn.getInteger("Dim") ;
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.spawn", false, false) ;
} // public boolean canCommandSenderUseCommand(...)
} // public class CommandSpawn