47 Zeilen
1.3 KiB
Java
47 Zeilen
1.3 KiB
Java
|
package de.steamwar.bausystem.commands;
|
||
|
|
||
|
import de.steamwar.bausystem.BauSystem;
|
||
|
import de.steamwar.bausystem.Permission;
|
||
|
import org.bukkit.Bukkit;
|
||
|
import org.bukkit.command.CommandSender;
|
||
|
import org.bukkit.command.defaults.BukkitCommand;
|
||
|
import org.bukkit.entity.Player;
|
||
|
|
||
|
public class CommandTime extends BukkitCommand {
|
||
|
|
||
|
public CommandTime() {
|
||
|
super("time");
|
||
|
this.description = "Ändert die Zeit auf der Spielwelt";
|
||
|
this.usageMessage = "/time <Zeit 0=Morgen, 6000=Mittag, 18000=Mitternacht>";
|
||
|
}
|
||
|
|
||
|
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
||
|
if (!(sender instanceof Player)) {
|
||
|
return false;
|
||
|
} else if (args.length == 0) {
|
||
|
sender.sendMessage(BauSystem.PREFIX + this.usageMessage);
|
||
|
return false;
|
||
|
}
|
||
|
Player player = (Player) sender;
|
||
|
|
||
|
if (!Welt.hasPermission(player, Permission.world)){
|
||
|
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
int time;
|
||
|
try{
|
||
|
time = Integer.valueOf(args[0]);
|
||
|
}catch(NumberFormatException e){
|
||
|
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an");
|
||
|
return false;
|
||
|
}
|
||
|
if (time < 0 || time > 24000) {
|
||
|
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
Bukkit.getWorlds().get(0).setTime(time);
|
||
|
return false;
|
||
|
}
|
||
|
}
|