fixed an annoying IllegalArgument with the World Event start command. fixed limit bukkit runnable not limiting itself.

This commit is contained in:
NewGarbo 2015-11-15 20:04:44 +00:00
parent 10eb1bb9c9
commit 5209cf3d38
3 changed files with 36 additions and 8 deletions

View File

@ -15,11 +15,16 @@ public abstract class LimitedBukkitRunnable extends BukkitRunnable
@Override @Override
public void run() public void run()
{ {
if (_timesRun > _maxTimes){ if (_timesRun > _maxTimes)
{
UtilServer.getServer().getScheduler().cancelTask(getTaskId()); UtilServer.getServer().getScheduler().cancelTask(getTaskId());
return; return;
} }
onRun(_timesRun); onRun(_timesRun);
_timesRun++;
} }
public abstract void onRun(int timesRun); public abstract void onRun(int timesRun);

View File

@ -163,6 +163,17 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
return null; 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() public void clearEvents()
{ {

View File

@ -7,6 +7,7 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.worldevent.WorldEventManager; import mineplex.game.clans.clans.worldevent.WorldEventManager;
import mineplex.game.clans.clans.worldevent.WorldEventType;
import mineplex.minecraft.game.core.boss.WorldEvent; import mineplex.minecraft.game.core.boss.WorldEvent;
public class StartCommand extends CommandBase<WorldEventManager> public class StartCommand extends CommandBase<WorldEventManager>
@ -22,13 +23,24 @@ public class StartCommand extends CommandBase<WorldEventManager>
// start specific world event type // start specific world event type
if (args != null && args.length == 1) 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) 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 else
{ {
UtilPlayer.message(caller, F.main("worldEvent", "Started WorldEvent " + F.elem(args[0]) + " at your current location")); 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])));
}
}
} }
} }