-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommandSummon.java
82 lines (67 loc) · 2.39 KB
/
CommandSummon.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
77
78
79
80
81
82
package kdx7214.necessities;
import java.util.ArrayList;
import java.util.List;
import cpw.mods.fml.common.Loader;
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 CommandSummon extends CommandBaseNecessities {
public CommandSummon() {
}
@Override
public String getCommandName() {
return "tpahere";
}
@Override
public String getCommandUsage(ICommandSender par1ICommandSender) {
return "/" + getCommandName() + " <player>";
}
@Override
public List getCommandAliases() {
ArrayList<String> temp = new ArrayList();
temp.add("summon");
return temp;
}
@Override
public void processCommand(ICommandSender sender, String[] par2ArrayOfStr) {
if (par2ArrayOfStr.length != 1) {
sender.sendChatToPlayer(getCommandUsage(sender));
return;
}
EntityPlayer player = getCommandSenderAsPlayer(sender);
EntityPlayerMP other = func_82359_c(sender, par2ArrayOfStr[0]);
NBTTagCompound playerdata = NecessitiesMain.instance.necessities_data
.getCompoundTag(other.username);
NecessitiesMain.instance.necessities_data.setCompoundTag(
other.username, playerdata);
NBTTagCompound tpa = playerdata.getCompoundTag("[Tpa]");
playerdata.setCompoundTag("[Tpa]", tpa);
if (tpa.hasKey("DenyAll")) {
sender.sendChatToPlayer("Player " + other.username + " has blocked all teleport requests.") ;
return ;
}
tpa.setString("Who", player.username);
tpa.setDouble("PosX", player.posX);
tpa.setDouble("PosY", player.posY);
tpa.setDouble("PosZ", player.posZ);
tpa.setFloat("Yaw", player.rotationYaw);
tpa.setFloat("Pitch", player.rotationPitch);
tpa.setInteger("Dim", player.dimension) ;
other.sendChatToPlayer(player.username
+ " has requested that you teleport to them. Use /tpaccept to accept or /tpreject to refuse.");
} // public void processCommand(...)
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender) {
return hasPermission(sender, "necessities.tpahere", false, false) ;
} // public boolean canCommandSenderUseCommand(...)
/**
* Return whether the specified command parameter index is a username
* parameter.
*/
public boolean isUsernameIndex(int par1) {
return par1 == 0;
}
} // public class CommandSummon