This repository has been archived by the owner on Feb 1, 2022. It is now read-only.
/
CommandRec.java
80 lines (66 loc) · 2.43 KB
/
CommandRec.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
package fuj1n.recmod.command;
import fuj1n.recmod.RecMod;
import fuj1n.recmod.network.packet.PacketClientCommand;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentTranslation;
public class CommandRec extends CommandBase {
@Override
public int getRequiredPermissionLevel() {
return 0;
}
@Override
public String getCommandName() {
return "rec";
}
@Override
public String getCommandUsage(ICommandSender icommandsender) {
icommandsender.addChatMessage(new TextComponentTranslation("\u00A7cRec Usage: "));
icommandsender.addChatMessage(new TextComponentTranslation("\u00A7c{no oprands} (displays an easy to use GUI)"));
icommandsender.addChatMessage(new TextComponentTranslation("\u00A7c<r/s> (toggle recording or streaming)"));
return "End Rec Usage";
}
public void onWrongUsage(ICommandSender icommandsender) {
getCommandUsage(icommandsender);
}
@Override
public void execute(MinecraftServer server, ICommandSender icommandsender, String[] astring) throws CommandException {
if (!(icommandsender instanceof EntityPlayer)) {
throw new CommandException("Only players are allowed to perform this command.", new Object[0]);
}
EntityPlayer player = (EntityPlayer) icommandsender;
if (astring.length != 0) {
if (astring.length != 1 || (!astring[0].equals("r") && !astring[0].equals("s"))) {
onWrongUsage(icommandsender);
return;
}
}
sendClientProcess(player, astring);
}
public void sendClientProcess(EntityPlayer p, String[] params) {
if (p instanceof EntityPlayerMP) {
PacketClientCommand pckt = new PacketClientCommand(params);
RecMod.packetPipeline.sendTo(pckt, (EntityPlayerMP) p);
}
}
@Override
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos position) {
List<String> l = new ArrayList<String>();
if (args.length == 1) {
l.add("r");
l.add("s");
}
return l;
}
@Override
public boolean checkPermission(MinecraftServer server, ICommandSender sender) {
return true;
}
}