Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class NoWeatherListener extends PluginListener {
- public boolean prevrain = true;
- int time;
- public boolean onWeatherChange(World world,boolean newValue){
- if (prevrain){
- return true;
- }else{
- return false;
- }
- }
- public boolean onCommand(Player player,String[] split){
- if ((split[0].equalsIgnoreCase("/w"))&&(player.canUseCommand("/weather"))){
- if (split.length == 2){
- if (split[1].equals("sun")){
- prevrain = false;
- World world = etc.getServer().getWorld(0);
- world.setThundering(false);
- world.setRaining(false);
- prevrain = true;
- etc.getServer().messageAll("§3"+player.getName()+"§2 Changed the weather.");
- return true;
- }else{
- player.sendMessage("§cThe correct usage is '/weather <sun|rain|thunder> <rain/thunder time in seconds>'");
- return true;
- }
- }else if (split.length == 3){
- try{Integer.parseInt(split[2]);}catch(NumberFormatException nfe){player.sendMessage("§cThe correct usage is '/weather <sun|rain|thunder> <rain/thunder time in seconds>'"); return true;}
- if (split[1].equals("rain")){
- prevrain = false;
- time = Integer.parseInt(split[2])*1000;
- World world = etc.getServer().getWorld(0);
- world.setRaining(true);
- etc.getServer().messageAll("§3"+player.getName()+"§2 Changed the weather for §4"+time/1000+"§2 seconds");
- new Thread() {
- public void run() {
- try{
- Thread.sleep(time);
- etc.getServer().getWorld(0).setRaining(false);
- etc.getServer().messageAll("§2The weather turned back!");
- prevrain = true;
- }catch(InterruptedException e) {}
- }
- }.start();
- return true;
- }
- if (split[1].equals("thunder")){
- prevrain = false;
- time = Integer.parseInt(split[2])*1000;
- etc.getServer().getWorld(0).setRaining(true);
- etc.getServer().getWorld(0).setThundering(true);
- etc.getServer().messageAll("§3"+player.getName()+"§2 Changed the weather for §4"+time/1000+"§2 seconds");
- new Thread() {
- public void run() {
- try{
- Thread.sleep(time);
- etc.getServer().getWorld(0).setThundering(false);
- etc.getServer().getWorld(0).setRaining(false);
- etc.getServer().messageAll("§2The weather turned back!");
- prevrain = true;
- }catch(InterruptedException e) {}
- }
- }.start();
- return true;
- }
- }else{player.sendMessage("§cThe correct usage is '/weather <sun|rain|thunder> <rain/thunder time in seconds>'"); return true;}
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment