weather command
This commit is contained in:
parent
b3955729b8
commit
0af8ca57d1
3 changed files with 36 additions and 0 deletions
|
@ -251,6 +251,7 @@ public class CommandEnvironment {
|
||||||
this.registerExecutable(new CommandWarp());
|
this.registerExecutable(new CommandWarp());
|
||||||
this.registerExecutable(new CommandTime());
|
this.registerExecutable(new CommandTime());
|
||||||
this.registerExecutable(new CommandRemove());
|
this.registerExecutable(new CommandRemove());
|
||||||
|
this.registerExecutable(new CommandWeather());
|
||||||
|
|
||||||
this.registerExecutable(new CommandHelp(this));
|
this.registerExecutable(new CommandHelp(this));
|
||||||
}
|
}
|
||||||
|
|
31
java/src/game/command/commands/CommandWeather.java
Normal file
31
java/src/game/command/commands/CommandWeather.java
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
package game.command.commands;
|
||||||
|
|
||||||
|
import game.command.CommandEnvironment;
|
||||||
|
import game.command.RunException;
|
||||||
|
import game.command.Command;
|
||||||
|
import game.command.Executor;
|
||||||
|
import game.world.Weather;
|
||||||
|
import game.world.WorldServer;
|
||||||
|
|
||||||
|
public class CommandWeather extends Command {
|
||||||
|
public CommandWeather() {
|
||||||
|
super("weather");
|
||||||
|
|
||||||
|
this.addEnum("weather", Weather.class, Weather.values());
|
||||||
|
this.setParamsOptional();
|
||||||
|
this.addWorld("dim", true);
|
||||||
|
|
||||||
|
this.addFlag("transition", 't');
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exec(CommandEnvironment env, Executor exec, Weather weather, WorldServer world, boolean transition) {
|
||||||
|
if(!world.dimension.getType().weather)
|
||||||
|
throw new RunException("Welt %s hat kein Wetter", world.dimension.getFormattedName(false));
|
||||||
|
else if(world.isExterminated())
|
||||||
|
throw new RunException("Welt %s ist zerstört", world.dimension.getFormattedName(false));
|
||||||
|
world.setWeather(weather);
|
||||||
|
if(!transition)
|
||||||
|
world.resetWeather();
|
||||||
|
exec.logConsole("Wetter in %s zu %s geändert", world.dimension.getFormattedName(false), weather.getDisplay());
|
||||||
|
}
|
||||||
|
}
|
|
@ -83,6 +83,10 @@ public enum Weather {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDisplay() {
|
public String getDisplay() {
|
||||||
return this.display;
|
return this.display;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue