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
|
@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);
|
||||||
|
@ -150,7 +150,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
|
|||||||
getPlugin().getServer().getPluginManager().registerEvents(event, getPlugin());
|
getPlugin().getServer().getPluginManager().registerEvents(event, getPlugin());
|
||||||
_runningEvents.add(event);
|
_runningEvents.add(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldEvent startEventFromName(Location location, String name)
|
public WorldEvent startEventFromName(Location location, String name)
|
||||||
{
|
{
|
||||||
WorldEventType eventType = WorldEventType.valueOf(name);
|
WorldEventType eventType = WorldEventType.valueOf(name);
|
||||||
@ -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()
|
||||||
{
|
{
|
||||||
|
@ -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>
|
||||||
@ -15,19 +16,30 @@ public class StartCommand extends CommandBase<WorldEventManager>
|
|||||||
{
|
{
|
||||||
super(plugin, Rank.DEVELOPER, new Rank[] { Rank.JNR_DEV }, "start", "create");
|
super(plugin, Rank.DEVELOPER, new Rank[] { Rank.JNR_DEV }, "start", "create");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Execute(Player caller, String[] args)
|
public void Execute(Player caller, String[] args)
|
||||||
{
|
{
|
||||||
// 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
|
||||||
if (event == null)
|
|
||||||
UtilPlayer.message(caller, F.main("WorldEvent", "Could not find a WorldEvent with the name " + F.elem(args[0])));
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("worldEvent", "Started WorldEvent " + F.elem(args[0]) + " at your current location"));
|
WorldEventType eventType = WorldEventType.valueOf(args[0]);
|
||||||
|
WorldEvent event = Plugin.startEventFromType(caller.getLocation(), eventType);
|
||||||
|
|
||||||
|
if (event == null)
|
||||||
|
{
|
||||||
|
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