Advertisement
Guest User

Untitled

a guest
Apr 10th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1.  
  2. import java.util.ArrayList;
  3. import java.util.List;
  4.  
  5. import net.minecraft.command.CommandBase;
  6. import net.minecraft.command.ICommandSender;
  7. import net.minecraft.entity.player.EntityPlayer;
  8. import net.minecraft.util.ChatComponentText;
  9.  
  10. public class Calculator extends CommandBase {
  11. @Override
  12. public String getCommandName(){
  13. return "calculator";
  14. }
  15.  
  16. @Override
  17. public String getCommandUsage(ICommandSender sender){
  18. return "/calculator";
  19. }
  20.  
  21. @Override
  22. public int getRequiredPermissionLevel(){
  23. return 0;
  24. }
  25.  
  26. @Override
  27. public boolean canCommandSenderUseCommand(ICommandSender sender){
  28. return true;
  29. }
  30.  
  31. @Override
  32. public List getCommandAliases(){
  33. ArrayList<String> aliases = new ArrayList<String>();
  34. aliases.add("calculator");
  35. aliases.add("Calculator");
  36. aliases.add("CALULATOR");
  37. aliases.add("cal");
  38. aliases.add("Cal");
  39. aliases.add("CAL");
  40. return aliases;
  41. }
  42. @Override
  43. public void processCommand(ICommandSender sender, double Math1, String operator, double Math2){
  44. EntityPlayer player = getCommandSenderAsPlayer(sender);
  45. switch ( operator ) {
  46. case "+":
  47. System.out.println("+ this is testing code");
  48. double Printplus = Math1 + Math2;
  49. player.addChatMessage(new ChatComponentText("the answer is " + Printplus));
  50. break;
  51. case "-":
  52. System.out.println("- this is testing code");
  53. double Printsub = Math1 - Math2;
  54. player.addChatMessage(new ChatComponentText("the answer is " + Printsub));
  55. break;
  56. case "*":
  57. System.out.println("* this is testing code");
  58. double Printtimes = Math1 - Math2;
  59. player.addChatMessage(new ChatComponentText("the answer is " + Printtimes));
  60. break;
  61. case "/":
  62. System.out.println("/ this is testing code");
  63. double Printdivide = Math1 - Math2;
  64. player.addChatMessage(new ChatComponentText("the answer is " + Printdivide));
  65. break;
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement