spenk

ConsoleCommandsIngame

Apr 19th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 36.89 KB | None | 0 0
  1.     import java.io.BufferedReader;
  2.     import java.io.BufferedWriter;
  3.     import java.io.File;
  4.     import java.io.FileNotFoundException;
  5.     import java.io.FileReader;
  6.     import java.io.FileWriter;
  7.     import java.io.IOException;
  8.     import java.io.Writer;
  9.     import java.text.DateFormat;
  10.     import java.text.SimpleDateFormat;
  11.     import java.util.ArrayList;
  12.     import java.util.Date;
  13. import java.util.logging.Logger;
  14.  
  15. public class ConsoleCommandsIngame extends PluginListener{
  16.         boolean noweather;
  17.         int time;
  18.         int mode;
  19.         File filename;
  20.         String directory = "plugins/CCPlayerLogs/";
  21.         File props = new File(directory+"LoggedPlayers.txt");
  22.         public boolean onCommand(final Player player,String[] split){
  23.            
  24.             PluginLoader Loader = etc.getLoader();
  25.             if(Loader.getPlugin("NoWeather") != null && Loader.getPlugin("NoWeather").isEnabled()){
  26.                 noweather = true;
  27.             }else{
  28.             noweather = false; 
  29.             }
  30.            
  31.             if (split[0].equalsIgnoreCase("/#xp")){
  32.                 if (player.isOp()){
  33.                 if (split.length >= 3)
  34.                   try {
  35.                      Player player2 = etc.getServer().matchPlayer(split[2]);
  36.                      if (player2 == null){
  37.                          player.notify("player does not exist");
  38.                      }
  39.                     if (split[1].equalsIgnoreCase("get")) {
  40.                       player.sendMessage("§a" + player2.getName() + "'s XP: " + player2.getXP() + ". Level: " + player2.getLevel());
  41.                     }
  42.                     if (split.length < 4) return true; int exp = Integer.parseInt(split[3]);
  43.                     if (split[1].equalsIgnoreCase("set")) {
  44.                       player2.setXP(exp);
  45.                       player2.sendMessage("§a" + player.getName() + " set your XP " + exp);
  46.                       player.sendMessage("§a"+player2.getName() + "'s XP was set to " + exp);
  47.                       return true;
  48.                     }
  49.                     if (split[1].equalsIgnoreCase("add")) {
  50.                       player2.addXP(exp);
  51.                      player.sendMessage("§a"+exp + " XP was added to " + player2.getName() + ".");
  52.                       player2.sendMessage("§a" + player.getName() + " added " + exp + " to your XP."); return true;
  53.                     }
  54.                     if (split[1].equalsIgnoreCase("remove")) {
  55.                       exp = player2.getXP() - exp;
  56.                       player2.setXP(exp);
  57.                      player.sendMessage("§a"+exp + " XP was removed from " + player2.getName() + ".");
  58.                       player2.sendMessage("§e" + player.getName() + " removed " + exp + " from your XP."); return true;
  59.                     }
  60.                    player.notify("§a"+"Usage - xp [get|set|add|remove] [player] [amount]");
  61.                     return true;
  62.                   }
  63.                   catch (Throwable t)
  64.                   {
  65.                       player.notify("Usage - xp [get|set|add|remove] [player] [amount]");
  66.                     return true;
  67.                   }
  68.                 else {
  69.                     player.notify("Usage - xp [get|set|add|remove] [player] [amount]");
  70.                 }
  71.                 return true;
  72.                 }
  73.               }
  74.            
  75.             if (split[0].equalsIgnoreCase("/#warp")){
  76.                 if (player.isOp()){
  77.                 if ((split.length < 3) || (split.length >3)){
  78.                     player.notify("the correct usage is 'warp <player> <warp>'");
  79.                     return true;
  80.                 }else{
  81.                 Player player2 = etc.getServer().matchPlayer(split[1]);
  82.                 Warp warp = etc.getDataSource().getWarp(split[2]);
  83.                 if (warp == null){
  84.                     player.notify("Warp Not Found.");
  85.                     return true;
  86.                 }else{
  87.                 Location location = warp.Location;
  88.                 if (player2 == null){
  89.                     player.notify("Player Not Found.");
  90.                     return true;
  91.                 }else{
  92.                     player2.teleportTo(location);
  93.                     player2.sendMessage("§2you got Warped By "+player.getName()+".");
  94.                     player.sendMessage("§a"+player2.getName() + " has been warped.");
  95.                     return true;
  96.                 }
  97.                 }
  98.              }
  99.             }
  100.             }
  101.            
  102.             if (split[0].equalsIgnoreCase("/#spawn")){
  103.                 if (player.isOp()){
  104.                 if ((split.length == 1) || (split.length > 2)){
  105.                     player.notify("the correct usage is 'spawn <player>'");
  106.                     return true;
  107.                 }else{
  108.                 Player player1 = etc.getServer().matchPlayer(split[1]);
  109.                 if (player1 == null){
  110.                     player.notify("Player Not Found.");
  111.                     return true;
  112.                 }else{
  113.                     World world = player1.getWorld();
  114.                     player1.teleportTo(world.getSpawnLocation());
  115.                     player1.sendMessage("§3You Got Respawned By "+player.getName()+".");
  116.                     player.sendMessage("§a"+player1.getName()+" has been respawned.");
  117.                     return true;
  118.                 }
  119.             }
  120.                 }
  121.             }
  122.            
  123.             if (split[0].equalsIgnoreCase("/#heal")){
  124.                 if (player.isOp()){
  125.                 if ((split.length == 1) ||(split.length > 2)){
  126.                     player.notify("the correct usage is 'heal <player>'");
  127.                     return true;
  128.                 }else{
  129.                 Player player1 = etc.getServer().matchPlayer(split[1]);
  130.                 if (player1 == null){
  131.                     player.notify("Player Not Found.");
  132.                     return true;
  133.                 }
  134.                 player1.setHealth(20);
  135.                 player1.sendMessage("§2you got Healed by "+player.getName()+".");
  136.                 player.sendMessage("§a"+player1.getName()+" has been healed.");
  137.                 return true;
  138.             }
  139.                 }
  140.             }
  141.            
  142.             if (split[0].equalsIgnoreCase("/#kill")){
  143.                 if (player.isOp()){
  144.                 if ((split.length == 1) ||(split.length > 2)){
  145.                     player.notify("the correct usage is 'kill <player>'");
  146.                     return true;
  147.                 }else{
  148.                 Player player1 = etc.getServer().matchPlayer(split[1]);
  149.                 if (player1 == null){
  150.                     player.notify("Player Not Found.");
  151.                     return true;
  152.                 }
  153.                 player1.dropLoot();
  154.                 player1.setHealth(0);
  155.                 player1.sendMessage("§cyou got killed by "+player.getName()+".");
  156.                 player.sendMessage("§a"+player1.getName()+" has been killed.");
  157.                 return true;
  158.             }
  159.                 }
  160.             }
  161.            
  162.             if (split[0].equalsIgnoreCase("/#data")){
  163.                 if (player.isOp()){
  164.                 if ((split.length == 1) ||(split.length > 2)){
  165.                     player.notify("the correct usage is 'data <player>'");
  166.                     return true;
  167.                 }else{
  168.                 Player player1 = etc.getServer().matchPlayer(split[1]);
  169.                 if (player1 == null){
  170.                     player.notify("Player Not Found.");
  171.                     return true;
  172.                 }else{
  173.                     String health = Integer.toString(player1.getHealth());
  174.                     String Foodl = Integer.toString(player1.getFoodLevel());
  175.                     String level = Integer.toString(player1.getLevel());
  176.                     String exp = Integer.toString(player1.getXP());
  177.                     String X = Double.toString(player1.getX());
  178.                     String Y = Double.toString(player1.getY());
  179.                     String Z = Double.toString(player1.getZ());
  180.                     String gm = Integer.toString(player1.getCreativeMode());
  181.                     World world = player1.getWorld();
  182.                     player.sendMessage("§aPlayer Name: " +player1.getName());
  183.                     player.sendMessage("§aPlayer Prefix: "+player1.getPrefix());
  184.                     player.sendMessage("§aPlayer Group: "+"**bugged**");
  185.                     player.sendMessage("§aPlayer Gamemode: "+gm);
  186.                     player.sendMessage("§aPlayer Ip: "+player1.getIP());
  187.                     player.sendMessage("§aPlayer Health: "+health);
  188.                     player.sendMessage("§aPlayer Foodl: "+ Foodl);
  189.                     player.sendMessage("§aPlayer XP: "+ exp);
  190.                     player.sendMessage("§aPlayer Level: "+ level);
  191.                     player.sendMessage("§aPlayer Logging:"+ isInList(player1.getName()));
  192.                     player.sendMessage("§aloaction: ");
  193.                     player.sendMessage("§aPlayer World: " + world.getName());
  194.                     player.sendMessage("§aZ: "+X);
  195.                     player.sendMessage("§aY: "+Y);
  196.                     player.sendMessage("§aX: "+Z);
  197.                     return true;
  198.                 }
  199.             }
  200.                 }
  201.             }
  202.            
  203.             if (split[0].equalsIgnoreCase("/#killall")){
  204.                 if (player.isOp()){
  205.                 if (split.length > 1){
  206.                     player.notify("the correct usage is 'killall'");
  207.                     return true;
  208.                 }else{
  209.                 for (Player p  : etc.getServer().getPlayerList()){
  210.                     if (p != player){
  211.                     if (p == null){
  212.                         player.notify("there are no players online to kill.");
  213.                         return true;
  214.                     }
  215.                     }
  216.                 p.dropLoot();
  217.                 p.setHealth(0);
  218.                 p.sendMessage("§4you were killed by "+player.getName()+".");
  219.                 player.sendMessage("§aall players have been killed.");
  220.                 return true;
  221.             }
  222.                 }
  223.             }
  224.             }
  225.            
  226.             if (split[0].equalsIgnoreCase("/#kickall")){
  227.                 if (player.isOp()){
  228.                 if (split.length > 1){
  229.                     player.notify("the correct usage is 'kickall'");
  230.                     return true;
  231.                 }else{
  232.                 for (Player p  : etc.getServer().getPlayerList()){
  233.                     if (p != player){
  234.                         if (p == null){
  235.                             player.notify("There is nobody online to kick!");
  236.                             return true;
  237.                         }
  238.                     }
  239.                         p.kick("you are kicked by "+player.getName()+".");
  240.                         player.sendMessage("§aYou just kicked everyone.");
  241.                         return true;
  242.                     }
  243.             }
  244.                 }
  245.             }
  246.            
  247.             if (split[0].equalsIgnoreCase("/#healall")){
  248.                 if (player.isOp()){
  249.                 if (split.length > 1){
  250.                     player.notify("the correct usage is 'healall'");
  251.                     return true;
  252.                 }else{
  253.                 for (Player p  : etc.getServer().getPlayerList()){
  254.                     if (p != player){
  255.                     if (p == null){
  256.                         player.notify("there are no players online to heal.");
  257.                         return true;
  258.                     }
  259.                     }
  260.                 p.setHealth(20);
  261.                 p.sendMessage("§2you were healed by "+player.getName()+".");
  262.                 player.sendMessage("§aall players have been healed.");
  263.                 return true;
  264.             }
  265.             }
  266.                 }
  267.             }
  268.            
  269.             if(split[0].equalsIgnoreCase("/#tpto")){
  270.                 if (player.isOp()){
  271.                 if (split.length == 5){
  272.                     Player player1 = etc.getServer().matchPlayer(split[1]);
  273.                     if (player1 == null){
  274.                         player.notify("Player Not Found.");
  275.                         return true;
  276.                     }else{
  277.                     double X = 0;
  278.                     double Y = 0;
  279.                     double Z = 0;
  280.                     try{
  281.                         X = Double.parseDouble(split[2]);
  282.                         Y = Double.parseDouble(split[3]);
  283.                         Z = Double.parseDouble(split[4]);
  284.                     }catch(NumberFormatException nfe){
  285.                         player.notify("an error occured the correct usage is 'tpto <player> <x> <y> <z>'");
  286.                         return true;
  287.                     }
  288.                     player1.setX(X);
  289.                     player1.setY(Y+1);
  290.                     player1.setZ(Z);
  291.                     player1.sendMessage("§2you got teleported by "+player.getName()+".");
  292.                     return true;
  293.                     }
  294.                 }else{
  295.                     player.notify("the correct usage is tpto '<player> <X> <Y> <Z>'");
  296.                     return true;
  297.                 }
  298.                 }
  299.             }
  300.             //TODO if (split[0].equalsIgnoreCase("spawnmob")){
  301.             //if (split.length )
  302.            
  303.             if (split[0].equalsIgnoreCase("/#mute")){
  304.                 if (player.isOp()){
  305.                 if ((split.length <2 )||(split.length >2)){
  306.                     player.notify("the correct usage is 'mute <player>'");
  307.                     return true;
  308.                 }else{
  309.                     Player player1 = etc.getServer().matchPlayer(split[1]);
  310.                     if (player1 == null){
  311.                         player.notify("Player Not Found.");
  312.                         return true;
  313.                     }else{
  314.                         if (player1.isMuted()){
  315.                             player.notify(player1.getName() + "is already muted.");
  316.                             return true;
  317.                         }else{
  318.                         player1.toggleMute();
  319.                         player.sendMessage("§a"+player1.getName()+ " is muted.");
  320.                         player1.sendMessage("§4you got muted by "+player.getName()+".");
  321.                         return true;
  322.                     }
  323.                 }
  324.                 }
  325.                 }
  326.             }
  327.            
  328.             if (split[0].equalsIgnoreCase("/#unmute")){
  329.                 if (player.isOp()){
  330.                 if ((split.length <2 )||(split.length >2)){
  331.                     player.notify("the correct usage is 'unmute <player>'");
  332.                     return true;
  333.                 }else{
  334.                     Player player1 = etc.getServer().matchPlayer(split[1]);
  335.                     if (player1 == null){
  336.                         player.notify("Player Not Found.");
  337.                         return true;
  338.                     }else{
  339.                         if (player1.isMuted()){
  340.                             player.sendMessage("§a"+player1.getName() + "is unmuted.");
  341.                             player1.sendMessage("§2 you got unmuted by "+player.getName()+".");
  342.                             player1.toggleMute();
  343.                             return true;
  344.                         }else{
  345.                         player.notify("players is not muted!");
  346.                         return true;
  347.                     }
  348.                 }
  349.                 }
  350.                 }
  351.             }
  352.            
  353.             if (split[0].equalsIgnoreCase("/#weather")){
  354.                 if (player.isOp()){
  355.                 if (split.length == 1){
  356.                     player.notify("the correct usage is 'weather [sun|rain|storm]'");
  357.                     return true;
  358.                 }else if (split.length == 2){
  359.                     World world = etc.getServer().getWorld(0);
  360.                     if (split[1].equalsIgnoreCase("sun")){
  361.                         if (noweather){
  362.                             etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", false});
  363.                             }
  364.                         world.setRaining(false);
  365.                         world.setThundering(false);
  366.                         player.sendMessage("§athe weather has been changed.");
  367.                         etc.getServer().messageAll("§2weather changed by "+player.getName()+".");
  368.                         if (noweather){
  369.                             etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", true});
  370.                             }
  371.                         return true;
  372.                     }
  373.                     if (split[1].equalsIgnoreCase("rain")){
  374.                         if (noweather){
  375.                             etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", false});
  376.                             }
  377.                         world.setRaining(true);
  378.                         player.sendMessage("§athe weather has been changed.");
  379.                         etc.getServer().messageAll("§2weather changed by"+player.getName()+".");
  380.                         if (noweather){
  381.                             etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", true});
  382.                             }
  383.                         return true;
  384.                     }
  385.                     if (split[1].equalsIgnoreCase("storm")){
  386.                         if (noweather){
  387.                             etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", false});
  388.                             }
  389.                         world.setThundering(true);
  390.                         player.sendMessage("the weather has been changed.");
  391.                         etc.getServer().messageAll("§2weather changed by"+player.getName()+".");
  392.                         if (noweather){
  393.                             etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", true});
  394.                             }
  395.                         return true;
  396.                     }
  397.                     }
  398.                 else if (split.length == 3){
  399.                     try { Integer.parseInt(split[2]);}catch(NumberFormatException nfe){player.notify("The correct usage is 'weather <rain|storm> <time>'");}
  400.                     time = Integer.parseInt(split[2])*1000;
  401.                     if (split[1].equalsIgnoreCase("rain")){
  402.                         new Thread() {
  403.                              public void run() {
  404.                                   try{
  405.                                       if (noweather){
  406.                                             etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", false});
  407.                                             }
  408.                                       etc.getServer().getWorld(0).setRaining(true);
  409.                                       etc.getServer().messageAll("§a"+player.getName()+" changed the weather for §4"+time/1000+"§2 seconds.");
  410.                                      player.sendMessage("§aThe weather is changed.");
  411.                                       if (noweather){
  412.                                             etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", true});
  413.                                        }
  414.                                         Thread.sleep(time);
  415.                                         if (noweather){
  416.                                             etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", false});
  417.                                        }
  418.                                        etc.getServer().getWorld(0).setRaining(false);
  419.                                        etc.getServer().messageAll("§2The weather turned back!");
  420.                                        player.sendMessage("§aThe weather is changed back.");
  421.                                        if (noweather){
  422.                                             etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", true});
  423.                                        }
  424.                                   }catch(InterruptedException e) {}
  425.                              }
  426.                         }.start();
  427.                         return true;
  428.                         }  
  429.                     if (split[1].equalsIgnoreCase("storm")){
  430.                         new Thread() {
  431.                              public void run() {
  432.                                   try{
  433.                                       if (noweather){
  434.                                             etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", false});
  435.                                             }
  436.                                       etc.getServer().getWorld(0).setRaining(true);
  437.                                       etc.getServer().getWorld(0).setThundering(true);
  438.                                       etc.getServer().messageAll("§a"+player.getName()+" changed the weather for §4"+time/1000+"§2 seconds.");
  439.                                       player.sendMessage("§aThe weather is changed.");
  440.                                       if (noweather){
  441.                                             etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", true});
  442.                                        }
  443.                                         Thread.sleep(time);
  444.                                         if (noweather){
  445.                                             etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", false});
  446.                                        }
  447.                                         etc.getServer().getWorld(0).setThundering(false);
  448.                                        etc.getServer().getWorld(0).setRaining(false);
  449.                                        etc.getServer().messageAll("§2The weather turned back!");
  450.                                        player.sendMessage("§aThe weather is changed back.");
  451.                                        if (noweather){
  452.                                             etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", true});
  453.                                        }
  454.                                   }catch(InterruptedException e) {}
  455.                              }
  456.                         }.start();
  457.                         return true;
  458.                     }
  459.                    
  460.                 }else{
  461.                     player.notify("The correct usage is 'weather <rain|storm> <time>'");
  462.                     return true;
  463.                 }
  464.                 }
  465.             }
  466.            
  467.             if (split[0].equalsIgnoreCase("/#ci")){
  468.                 if (player.isOp()){
  469.                 if ((split.length <2)||(split.length >2)){
  470.                     player.notify("the correct usage is 'ci <player>'");
  471.                     return true;
  472.                 }else{
  473.                     Player player1 = etc.getServer().matchPlayer(split[1]);
  474.                     if (player1 == null){
  475.                         player.notify("Player Not Found");
  476.                         return true;
  477.                     }else{
  478.                         player1.getInventory().clearContents();
  479.                         player.sendMessage("§aplayer inventory has been cleared.");
  480.                         player1.sendMessage("§cyour inventory got cleared by "+player.getName()+".");
  481.                         return true;
  482.                     }
  483.                 }
  484.                 }
  485.             }
  486.            
  487.             if (split[0].equalsIgnoreCase("/#home")){
  488.                 if (player.isOp()){
  489.                 if ((split.length <2)||(split.length >2)){
  490.                     player.notify("the correct usage is 'home <player>'");
  491.                     return true;
  492.                 }else{
  493.                     Player player1 = etc.getServer().matchPlayer(split[1]);
  494.                     if (player1 == null){
  495.                         player.notify("Player Not Found.");
  496.                         return true;
  497.                     }else{
  498.                         Warp home = etc.getDataSource().getHome(player1.getName());
  499.                         if (home == null){
  500.                             player.notify("this player doesnt have a home.");
  501.                             return true;
  502.                         }
  503.                         Location location = home.Location;
  504.                         player1.teleportTo(location);
  505.                         player.sendMessage("§aplayer teleported.");
  506.                         player1.sendMessage("§3you got warped by "+player.getName()+".");
  507.                         return true;
  508.                     }
  509.                 }
  510.                 }
  511.             }
  512.             if (split[0].equalsIgnoreCase("/#date")){
  513.                 if (player.isOp()){
  514.                  DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
  515.                  Date date = new Date();
  516.                 if ((split.length <2)||(split.length >2)){
  517.                     player.notify("the correct usage is 'date [show|notify]'");
  518.                     return true;
  519.                 }else{
  520.                     if ((!split[1].equalsIgnoreCase("show"))&&(!split[1].equalsIgnoreCase("notify"))){
  521.                         player.notify("the correct usage is 'date [show|notify]'");
  522.                         return true;
  523.                     }else{
  524.                         if (split[1].equalsIgnoreCase("show")){
  525.                             player.sendMessage("§athe current date is "+dateFormat.format(date)+".");
  526.                             return true;
  527.                         }else{
  528.                             if(split[1].equalsIgnoreCase("notify")){
  529.                                 etc.getServer().messageAll("§3 the current date is §4"+dateFormat.format(date)+".");
  530.                                 player.sendMessage("§adate has been shown.");
  531.                                 return true;
  532.                             }
  533.                         }
  534.                         return true;
  535.                     }
  536.                 }
  537.                 }
  538.             }
  539.             if (split[0].equalsIgnoreCase("/#rtime")){
  540.                 if (player.isOp()){
  541.                  DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
  542.                 Date date = new Date();
  543.                 if ((split.length <2)||(split.length >2)){
  544.                     player.notify("the correct usage is 'date [show|notify]'");
  545.                     return true;
  546.                 }else{
  547.                     if ((!split[1].equalsIgnoreCase("show"))&&(!split[1].equalsIgnoreCase("notify"))){
  548.                         player.notify("the correct usage is 'date [show|notify]'");
  549.                         return true;
  550.                     }else{
  551.                         if (split[1].equalsIgnoreCase("show")){
  552.                             player.sendMessage("§athe current time is "+dateFormat.format(date)+".");
  553.                             return true;
  554.                         }else{
  555.                             if(split[1].equalsIgnoreCase("notify")){
  556.                                 etc.getServer().messageAll("§3 the current time is §4"+dateFormat.format(date)+".");
  557.                                 player.sendMessage("§atime has been shown.");
  558.                                 return true;
  559.                             }
  560.                         }
  561.                         return true;
  562.                     }
  563.                 }
  564.                 }
  565.             }
  566.             if (split[0].equalsIgnoreCase("/#gm")){
  567.                 if (player.isOp()){
  568.                 if (split.length == 1){
  569.                     player.notify("The correct usage is 'gm <player> <1|0>'");
  570.                     return true;
  571.                 }else if (split.length == 2){
  572.                     Player p = etc.getServer().matchPlayer(split[1]);
  573.                     if (p == null){
  574.                         player.notify("This player is currently not logged in or does not excist.");
  575.                         return true;
  576.                     }
  577.                     int m = p.getCreativeMode();
  578.                     player.sendMessage("§athis player does currently have mode "+ m+".");
  579.                     return true;
  580.                 }else if (split.length == 3){
  581.                     try{mode = Integer.parseInt(split[2]);}catch(NumberFormatException nfe){player.notify("the correct usage is 'gm <player> <1|0>'");}
  582.                     Player p = etc.getServer().matchPlayer(split[1]);
  583.                     if (p == null){
  584.                         player.notify("This player is currently not logged in or does not excist.");
  585.                         return true;
  586.                     }else
  587.                     if (mode == p.getCreativeMode()){
  588.                         player.notify("this player is already gamemode "+mode+".");
  589.                         return true;
  590.                     }else
  591.                         if ((mode != 1)&&(mode != 0)){
  592.                             player.notify(mode +" is an unacceptable gamemode.");
  593.                             return true;
  594.                         }else{
  595.                     p.setCreativeMode(mode);
  596.                     p.sendMessage("§2"+player.getName()+" changed your gamemode to "+mode+".");
  597.                     player.sendMessage("§aplayer gamemode has been changed to "+mode+".");
  598.                     return true;
  599.                 }
  600.                 }
  601.                 }
  602.             }
  603.            
  604.             if (split[0].equalsIgnoreCase("/#time")){
  605.                 if (player.isOp()){
  606.                 int time2 = 0;
  607.                 if ((split.length >3) || (split.length <2)){
  608.                     player.notify("the correct usage is time [show|notify|add|set]");
  609.                     return true;
  610.                 }
  611.                     World world = etc.getServer().getWorld(0);
  612.                     String time = Double.toString(world.getTime());
  613.                     if (split[1].equalsIgnoreCase("show")){
  614.                     player.sendMessage("§athe current time is: "+time);
  615.                     return true;
  616.                     }else if (split[1].equalsIgnoreCase("notify")){
  617.                         etc.getServer().messageAll("§5the current time is: "+time);
  618.                         player.sendMessage("§athe time has been shown");
  619.                         player.sendMessage("§athe current time is: "+time);
  620.                         return true;
  621.                 }else if (split[1].equalsIgnoreCase("set")){
  622.                     if ((split.length >3)||(split.length <3)){
  623.                     player.notify("the correct usage is 'time [set] [time]");
  624.                         return true;
  625.                     }else{
  626.                         try{time2 = Integer.parseInt(split[2]);}
  627.                         catch(NumberFormatException nfe){
  628.                             player.notify( time2 + "is not an valid number");
  629.                             return true;
  630.                         }
  631.                         world.setTime(time2);
  632.                         etc.getServer().messageAll("§6"+player.getName()+" changed te time.");
  633.                         player.sendMessage("§athe time has been changed");
  634.                         return true;
  635.                     }
  636.                 }else if (split[1].equalsIgnoreCase("add")){
  637.                     if ((split.length >3)||(split.length <3)){
  638.                         player.notify("the correct usage is 'time [add] [time]");
  639.                         return true;
  640.                     }else{
  641.                         try{time2 = Integer.parseInt(split[2]);}
  642.                         catch(NumberFormatException nfe){
  643.                             player.notify( time2 + "is not an valid number");
  644.                             return true;
  645.                         }
  646.                         long addtime = world.getTime()+time2;
  647.                         world.setTime(addtime);
  648.                         etc.getServer().messageAll("§6"+player.getName()+" changed te time.");
  649.                         player.notify("§athe time has been changed");
  650.                         return true;
  651.                     }
  652.                
  653.                 }
  654.                 }
  655.             }
  656.             if (split[0].equalsIgnoreCase("/#pluginlist")){
  657.                 if (player.isOp()){
  658.                 if (split.length != 1){
  659.                     player.notify("the correct usage is 'pluginlist'");
  660.                     return true;
  661.                 }else{
  662.                 player.sendMessage("§athe current pluginlist is: "+etc.getLoader().getPluginList()+".");
  663.                 return true;
  664.             }
  665.                 }
  666.             }
  667.             int power = 0;
  668.             if (split[0].equalsIgnoreCase("/#bomb")){
  669.                 if (player.isOp()){
  670.                 if ((split.length <3)||(split.length >3)){
  671.                     player.notify("the correct usage is 'bomb <player> <power>'");
  672.                     return true;
  673.                 }else{
  674.                 Player p = etc.getServer().matchPlayer(split[1]);
  675.                 if (p == null){
  676.                     player.notify("player not found");
  677.                     return true;
  678.                 }else{
  679.                     try{ power = Integer.parseInt(split[2]);
  680.                     }catch (NumberFormatException nfe){player.notify(split[2]+ " is not an number!"); return true;}
  681.                 World world = p.getWorld();
  682.                 world.explode(p, p.getX(), p.getY()+1, p.getZ()+1, power);
  683.                 player.sendMessage("§aplayer bombarded");
  684.                 p.sendMessage("§4"+player.getName() +" bombed you.");
  685.                 return true;
  686.                 }
  687.             }}}
  688.             if(split[0].equalsIgnoreCase("/#strike")){
  689.                 if (player.isOp()){
  690.                 if ((split.length <2)||(split.length >2)){
  691.                     player.notify("the correct usage is 'strike <player>'");
  692.                 return true;
  693.                 }else{
  694.                     Player p = etc.getServer().matchPlayer(split[1]);
  695.                     if (p == null){
  696.                         player.notify("player not found.");
  697.                         return true;
  698.                     }else{
  699.                         OWorldServer oworld = p.getWorld().getWorld();
  700.                         oworld.a(new OEntityLightningBolt(oworld, p.getX(), p.getY(), p.getZ()));
  701.                         p.sendMessage("§4"+player.getName() +"shot an lightning bolt to your head.");
  702.                         player.sendMessage("§awe shot an lightning bolt to "+player.getName()+" master.");
  703.                         return true;
  704.                     }
  705.                 }
  706.                 }
  707.             }
  708.             if(split[0].equalsIgnoreCase("/#log")){
  709.                 if (player.isOp()){
  710.                 if ((split.length <2)||(split.length >2)){
  711.                     player.notify("usage 'log <player>'");
  712.                         return true;
  713.                 }else{
  714.                 Player p = etc.getServer().matchPlayer(split[1]);
  715.                 if (p == null){
  716.                     player.notify("Player Not Found.");
  717.                         return true;
  718.                 }else{
  719.                     if (isInList(p.getName())){
  720.                         player.notify("This player is already in the log list!");
  721.                         return true;
  722.                     }else{
  723.                 Writer writer = null;
  724.                 DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
  725.                 Date date = new Date();
  726.                 try {
  727.                         filename = new File(directory + p.getName() +".txt");
  728.                     writer = new BufferedWriter(new FileWriter(filename));
  729.                     writer.write("#date/time = "+dateFormat.format(date)+"\n");
  730.                     writer.write("player name = "+p.getName()+"\n");
  731.                     writer.write("player group = "+"**bugged**"+"\n");
  732.                     writer.write("player ip = "+p.getIP()+"\n");
  733.                     player.sendMessage("§aplayer will be logged 'till unlog'");
  734.                 } catch (FileNotFoundException e) {
  735.                     player.notify("[ERROR] File not found.");
  736.                     return true;
  737.                 } catch (IOException e) {
  738.                     player.notify("[ERROR] File IOException Found o.O");
  739.                         return true;
  740.                 } finally {
  741.                     try {
  742.                         if (writer != null) {
  743.                             writer.close();
  744.                         }
  745.                     } catch (IOException e) {
  746.                         player.notify("[ERROR] File IOException Found o.O");
  747.                         return true;
  748.                     }
  749.                 }
  750.                 try {
  751.                      if (!new File(directory+"LoggedPlayers.txt").exists()) {
  752.                          props.createNewFile();
  753.                          writer = new FileWriter(directory+"LoggedPlayers.txt", true);
  754.                          writer.write(p.getName());
  755.                      }else{
  756.                          writer = new FileWriter(directory+"LoggedPlayers.txt", true);
  757.                     writer.write(p.getName()+"\n");
  758.                     writer.close();
  759.                      }
  760.                 } catch (IOException e) {
  761.                     player.notify("an error occured O.o");
  762.                     return true;
  763.                 }
  764.                 }
  765.                 return true;
  766.         }
  767.         }
  768.                 }
  769.             }
  770.             if (split[0].equalsIgnoreCase("/#cch")||split[0].equalsIgnoreCase("/cchelp")){
  771.                 if (player.isOp()){
  772.                 player.sendMessage("§a======================ConsoleCommands======================");
  773.                 player.sendMessage("§a  warp <player> <warp>                      warps a player to location <warp>. ");
  774.                 player.sendMessage("§a  spawn <player>                            respawns a player.  ");
  775.                 player.sendMessage("§a  home <player>                             tps a player to his/her home");
  776.                 player.sendMessage("§a  heal <player>                             heals a player. ");
  777.                 player.sendMessage("§a  data <player>                             gets all player data. ");
  778.                 player.sendMessage("§a  kill <player>                             kills a player. ");
  779.                 player.sendMessage("§a  help or cch                               shows all help commands. ");
  780.                 player.sendMessage("§a  kickall -                                 kicks all players. ");
  781.                 player.sendMessage("§a  killall -                                 kills all players. ");
  782.                 player.sendMessage("§a  healall -                                 heals all players. ");
  783.                 player.sendMessage("§a  tpto <player> <X> <Y> <Z>                 tps an player to <X> <Y> <Z>. ");
  784.                 player.sendMessage("§a  mute <player>                             mutes a player.");
  785.                 player.sendMessage("§a  unmute <player>                           unmutes a player.");
  786.                 player.sendMessage("§a  ci <player>                               clears inventory of a player.");
  787.                 player.sendMessage("§a  weather <sun|rain|storm> (time in sec)    changes the weather.");
  788.                 player.sendMessage("§a  time [show|notify|set|add] <time>         showes you the time or notify's it to evryone.");
  789.                 player.sendMessage("§a  date [show|notify]                        showes you the date or notify's it to evtyone.");
  790.                 player.sendMessage("§a  rtime [show|notify]                       showes you the real time ot notify's it to evryone.");
  791.                 player.sendMessage("§a  xp [get|set|add|remove] <player> <amount> [get|set|add|remove] player xp.");
  792.                 player.sendMessage("§a  bomb <player> <power>                     creating an explosion on player coordinates");
  793.                 player.sendMessage("§a  strike <player>                           strikes a player");
  794.                 player.sendMessage("§a  log <player>                              log all player data, messages");
  795.                 player.sendMessage("§a  unlog <player>                            stops the log of a player");
  796.                 player.sendMessage("§a  gm <player> <gamemode(1|0)                changes the player gamemode");
  797.                 //log.info("  CAKE                                      The Cake is not a lie!");
  798.                 player.sendMessage("§a===========================V2.0============================");
  799.                 return true;
  800.             }
  801.                
  802.             if (split[0].equalsIgnoreCase("/#help")){
  803.                 if (player.isOp()){
  804.                 player.sendMessage("§a======================ConsoleCommands======================");
  805.                 player.sendMessage("§a  warp <player> <warp>                      warps a player to location <warp>. ");
  806.                 player.sendMessage("§a  spawn <player>                            respawns a player.  ");
  807.                 player.sendMessage("§a  home <player>                             tps a player to his/her home");
  808.                 player.sendMessage("§a  heal <player>                             heals a player. ");
  809.                 player.sendMessage("§a  data <player>                             gets all player data. ");
  810.                 player.sendMessage("§a  kill <player>                             kills a player. ");
  811.                 player.sendMessage("§a  help or cch                               shows all help commands. ");
  812.                 player.sendMessage("§a  kickall -                                 kicks all players. ");
  813.                 player.sendMessage("§a  killall -                                 kills all players. ");
  814.                 player.sendMessage("§a  healall -                                 heals all players. ");
  815.                 player.sendMessage("§a  tpto <player> <X> <Y> <Z>                 tps an player to <X> <Y> <Z>. ");
  816.                 player.sendMessage("§a  mute <player>                             mutes a player.");
  817.                 player.sendMessage("§a  unmute <player>                           unmutes a player.");
  818.                 player.sendMessage("§a  ci <player>                               clears inventory of a player.");
  819.                 player.sendMessage("§a  weather <sun|rain|storm> (time in sec)    changes the weather.");
  820.                 player.sendMessage("§a  time [show|notify|set|add] <time>         showes you the time or notify's it to evryone.");
  821.                 player.sendMessage("§a  date [show|notify]                        showes you the date or notify's it to evtyone.");
  822.                 player.sendMessage("§a  rtime [show|notify]                       showes you the real time ot notify's it to evryone.");
  823.                 player.sendMessage("§a  xp [get|set|add|remove] <player> <amount> [get|set|add|remove] player xp.");
  824.                 player.sendMessage("§a  bomb <player> <power>                     creating an explosion on player coordinates");
  825.                 player.sendMessage("§a  strike <player>                           strikes a player");
  826.                 player.sendMessage("§a  log <player>                              log all player data, messages");
  827.                 player.sendMessage("§a  unlog <player>                            stops the log of a player");
  828.                 player.sendMessage("§a  gm <player> <gamemode(1|0)                changes the player gamemode");
  829.                 //log.info("  CAKE                                      The Cake is not a lie!");
  830.                 player.sendMessage("§a===========================V2.0============================");
  831.                 return true;
  832.             }
  833.             }
  834.             }
  835.             /*if (split[0].equalsIgnoreCase("CAKE")){
  836.                 if ((split.length <1)||(split.length >1)){
  837.                     log.info("the correct usage is 'CAKE'");
  838.                     return false;
  839.             }else{
  840.                      new Thread() {
  841.                      public void run() {
  842.                           try{
  843.                                 Thread.sleep(5000);
  844.                                 log.info("THE WORLD TURNS DARK...");
  845.                                 etc.getServer().messageAll("§4THE WORLD TURNS DARK...");
  846.                                 etc.getServer().getWorld(0).setTime(18000);
  847.                                 if (noweather){
  848.                                     etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", false});
  849.                                     }
  850.                                 Thread.sleep(5000);
  851.                                 log.info("IT IS STARTING TO RAIN...");
  852.                                 etc.getServer().messageAll("§4IT IS STARTING TO RAIN...");
  853.                                 etc.getServer().getWorld(0).setRaining(true);
  854.                                 Thread.sleep(7500);
  855.                                 Location spawn = etc.getServer().getWorld(0).getSpawnLocation();
  856.                                 double x = spawn.x;
  857.                                 double y = spawn.y;
  858.                                 double z = spawn.z;
  859.  
  860.                                 etc.getServer().getWorld(0).dropItem(x+1,y-1,z,354, 1, 0);
  861.                                 etc.getServer().getWorld(0).dropItem(x+1,y-1,z+1,354, 1, 0);
  862.                                 etc.getServer().getWorld(0).dropItem(x+1,y-1,z-1,354, 1, 0);
  863.                                 etc.getServer().getWorld(0).dropItem(x-1,y-1,z+1,354, 1, 0);
  864.                                 etc.getServer().getWorld(0).dropItem(x-1,y-1,z-1,354, 1, 0);
  865.                                 etc.getServer().getWorld(0).dropItem(x-1,y-1,z,354, 1, 0);
  866.                                 etc.getServer().getWorld(0).dropItem(x,y,z+1,354, 1, 0);
  867.                                 etc.getServer().getWorld(0).dropItem(x,y,z-1,354, 1, 0);
  868.                                 log.info("SOMETHING IS HAPPENING AT THE SPAWN ...");
  869.                                 etc.getServer().messageAll("§4SOMETHING IS HAPPENING AT THE SPAWN ...");
  870.                                 Thread.sleep(2500);
  871.                                 log.info("§4GO LOOK PEOPLE FAST !!!");
  872.                                 etc.getServer().messageAll("§4GO LOOK PEOPLE FAST !!!");      
  873.                                 Thread.sleep(50000);
  874.                                 log.info("Event End.");
  875.                                 etc.getServer().messageAll("§2The Event Ended!");
  876.                                 etc.getServer().getWorld(0).setTime(0);
  877.                                 etc.getServer().getWorld(0).setRaining(false);
  878.                                 Thread.sleep(2500);
  879.                                 if (noweather){
  880.                                     etc.getLoader().callCustomHook("NoWeather", new Object[] {"SET", true});
  881.                                     }
  882.                           }catch(InterruptedException e) {}
  883.                      }
  884.                 }.start();
  885.                 }
  886.                 return true;
  887.                 }
  888.                 */
  889.  
  890.             if(split[0].equalsIgnoreCase("/#unlog")){
  891.                 if (player.isOp()){
  892.                 if ((split.length <2)||(split.length >2)){
  893.                     player.notify("usage 'unlog <player>'");
  894.                     return true;
  895.                 }else{
  896.                     if (!isInList(split[1])){
  897.                         player.notify("this player is not found in the log database!");
  898.                         player.notify("mind you have to write down full playername 'even caps'");
  899.                         return true;
  900.                     }else{
  901.                         ArrayList<String> filelines = new ArrayList<String>();
  902.                         String lineSep = System.getProperty("line.separator");
  903.                         try{
  904.                             BufferedReader in = new BufferedReader(new FileReader(props));
  905.                             String line;
  906.                             while ((line = in.readLine()) != null) {
  907.                                 if (!line.contains(split[1])) {
  908.                                     filelines.add(line);   
  909.                                 }
  910.                             }
  911.                             in.close();
  912.                             BufferedWriter out = new BufferedWriter(new FileWriter(props));
  913.                             for(String toWrite : filelines){
  914.                                 out.write(toWrite);
  915.                                 out.write(lineSep);
  916.                             }
  917.                             out.close();
  918.                             player.notify("player unlogged");
  919.                             return true;
  920.                         }catch(IOException e){
  921.                             player.notify("File IOException found!...");
  922.                             return true;
  923.                         }
  924.                     }
  925.                 }
  926.             }
  927.             }
  928.             return false;
  929.         }
  930.        
  931.         Logger log = Logger.getLogger("Minecraft");
  932.          public boolean isInList(String playername) {
  933.             try {
  934.               BufferedReader in = new BufferedReader(new FileReader(props));
  935.               String line = in.readLine();
  936.               while (line != null) {
  937.                 if (line.equalsIgnoreCase(playername)) {
  938.                   in.close();
  939.                   return true;
  940.                 }
  941.                 line = in.readLine();
  942.               }
  943.               in.close();
  944.             } catch (IOException localIOException) {
  945.             }
  946.             return false; }
  947.     }
Advertisement
Add Comment
Please, Sign In to add comment