-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommandTest.java
52 lines (48 loc) · 2.3 KB
/
CommandTest.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
package dime;
import com.mojang.authlib.GameProfile;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.WorldSettings;
/**
* Created by OkuBlade.
*/
public class CommandTest implements ICommandLol{
@Override
public void onCommand(Command cmd, ICommandSender snd, String[] args) {
if(args.length == 0) {
snd.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"Usage: "+cmd.commandUsage));
return;
}
if(args[0].equalsIgnoreCase("yes")){
snd.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA+"That's Good! We Don't Want Cheaters Here!"));
if (snd instanceof EntityPlayer){
boolean isCreative = ((EntityPlayer) snd).capabilities.isCreativeMode;
// not in creative
if(isCreative){
snd.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"You're in Creative! How dare you!"));
((EntityPlayer) snd).setGameType(WorldSettings.GameType.SURVIVAL);
}else {
snd.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA+"Great! Here's something to help!"));
((EntityPlayer) snd).inventory.addItemStackToInventory(new ItemStack(Items.golden_apple, 1, 1));
}
}
}else if(args[0].equalsIgnoreCase("no")){
snd.addChatMessage(new ChatComponentText("FINE!"));
if(snd instanceof EntityPlayer){
((EntityPlayer) snd).addExperienceLevel(5);
boolean isCreative = ((EntityPlayer) snd).capabilities.isCreativeMode;
// not in creative
if(isCreative){
snd.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA+"Good. You're already there. Have Fun!"));
}else {
snd.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "How can you cheat without Creative?"));
((EntityPlayer) snd).setGameType(WorldSettings.GameType.CREATIVE);
}
}
}
}
}