Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- import net.minecraft.command.CommandBase;
- import net.minecraft.command.ICommandSender;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.util.ChatComponentText;
- public class Calculator extends CommandBase {
- @Override
- public String getCommandName(){
- return "calculator";
- }
- @Override
- public String getCommandUsage(ICommandSender sender){
- return "/calculator";
- }
- @Override
- public int getRequiredPermissionLevel(){
- return 0;
- }
- @Override
- public boolean canCommandSenderUseCommand(ICommandSender sender){
- return true;
- }
- @Override
- public List getCommandAliases(){
- ArrayList<String> aliases = new ArrayList<String>();
- aliases.add("calculator");
- aliases.add("Calculator");
- aliases.add("CALULATOR");
- aliases.add("cal");
- aliases.add("Cal");
- aliases.add("CAL");
- return aliases;
- }
- @Override
- public void processCommand(ICommandSender sender, double Math1, String operator, double Math2){
- EntityPlayer player = getCommandSenderAsPlayer(sender);
- switch ( operator ) {
- case "+":
- System.out.println("+ this is testing code");
- double Printplus = Math1 + Math2;
- player.addChatMessage(new ChatComponentText("the answer is " + Printplus));
- break;
- case "-":
- System.out.println("- this is testing code");
- double Printsub = Math1 - Math2;
- player.addChatMessage(new ChatComponentText("the answer is " + Printsub));
- break;
- case "*":
- System.out.println("* this is testing code");
- double Printtimes = Math1 - Math2;
- player.addChatMessage(new ChatComponentText("the answer is " + Printtimes));
- break;
- case "/":
- System.out.println("/ this is testing code");
- double Printdivide = Math1 - Math2;
- player.addChatMessage(new ChatComponentText("the answer is " + Printdivide));
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement