fixed an annoying IllegalArgument with the World Event start command. fixed limit bukkit runnable not limiting itself.
This commit is contained in:
parent
10eb1bb9c9
commit
5209cf3d38
@ -15,11 +15,16 @@ public abstract class LimitedBukkitRunnable extends BukkitRunnable
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_timesRun > _maxTimes){
|
||||
if (_timesRun > _maxTimes)
|
||||
{
|
||||
UtilServer.getServer().getScheduler().cancelTask(getTaskId());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
onRun(_timesRun);
|
||||
|
||||
_timesRun++;
|
||||
}
|
||||
|
||||
public abstract void onRun(int timesRun);
|
||||
|
@ -163,6 +163,17 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
|
||||
|
||||
return null;
|
||||
}
|
||||
public WorldEvent startEventFromType(Location location, WorldEventType eventType)
|
||||
{
|
||||
if (eventType != null)
|
||||
{
|
||||
WorldEvent event = eventType.createInstance(this, location);
|
||||
initializeEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void clearEvents()
|
||||
{
|
||||
|
@ -7,6 +7,7 @@ import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.game.clans.clans.worldevent.WorldEventManager;
|
||||
import mineplex.game.clans.clans.worldevent.WorldEventType;
|
||||
import mineplex.minecraft.game.core.boss.WorldEvent;
|
||||
|
||||
public class StartCommand extends CommandBase<WorldEventManager>
|
||||
@ -22,13 +23,24 @@ public class StartCommand extends CommandBase<WorldEventManager>
|
||||
// start specific world event type
|
||||
if (args != null && args.length == 1)
|
||||
{
|
||||
WorldEvent event = Plugin.startEventFromName(caller.getLocation(), args[0]);
|
||||
try
|
||||
{
|
||||
WorldEventType eventType = WorldEventType.valueOf(args[0]);
|
||||
WorldEvent event = Plugin.startEventFromType(caller.getLocation(), eventType);
|
||||
|
||||
if (event == null)
|
||||
UtilPlayer.message(caller, F.main("WorldEvent", "Could not find a WorldEvent with the name " + F.elem(args[0])));
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("WorldEvent", "Error whilst starting the world event you chose."));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("worldEvent", "Started WorldEvent " + F.elem(args[0]) + " at your current location"));
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("WorldEvent", "Could not find a WorldEvent with the name " + F.elem(args[0])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user