TimeCommand for relative player time
This commit is contained in:
parent
99f3dd1805
commit
1e3648358b
@ -0,0 +1,46 @@
|
||||
package mineplex.mapparser.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.mapparser.MapParser;
|
||||
|
||||
public class TimeCommand extends BaseCommand
|
||||
{
|
||||
|
||||
public TimeCommand(MapParser plugin)
|
||||
{
|
||||
super(plugin, "time");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(Player player, String alias, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
player.resetPlayerTime();
|
||||
|
||||
message(player, "Reset your local player time.");
|
||||
return true;
|
||||
}
|
||||
|
||||
long time;
|
||||
try
|
||||
{
|
||||
time = Long.parseLong(args[0]);
|
||||
|
||||
if (time < 0)
|
||||
{
|
||||
throw new NumberFormatException("Time must be positive");
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
message(player, "Please enter a valid value for time.");
|
||||
return true;
|
||||
}
|
||||
|
||||
player.setPlayerTime(time, false);
|
||||
message(player, "Your local player time has been updated.");
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user