Merge remote-tracking branch 'origin/clans-beta' into clans-beta

This commit is contained in:
Shaun Bennett 2015-11-14 16:46:03 -05:00
commit f90b137ccd
11 changed files with 235 additions and 244 deletions

View File

@ -8,6 +8,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
@ -41,11 +42,17 @@ public class ClansAlphaManager extends MiniPlugin
} }
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) public void onPlayerJoin(final PlayerJoinEvent event)
{ {
if (!_taskManager.hasCompletedTask(event.getPlayer(), "ClansAlphaJoinMessage")) if (!_taskManager.hasCompletedTask(event.getPlayer(), "ClansAlphaJoinMessage"))
{ {
UtilPlayer.message(event.getPlayer(), FIRST_JOIN_MESSAGES); _taskManager.completedTask(new Callback<Boolean>()
{
public void run(Boolean data)
{
UtilPlayer.message(event.getPlayer(), FIRST_JOIN_MESSAGES);
}
}, event.getPlayer(), "ClansAlphaJoinMessage");
} }
} }

View File

@ -195,7 +195,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
_npcManager = new NpcManager(plugin, creature); _npcManager = new NpcManager(plugin, creature);
_condition = new SkillConditionManager(plugin); _condition = new SkillConditionManager(plugin);
DamageManager damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition); DamageManager damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition);
_worldEvent = new WorldEventManager(plugin, this, damageManager, _lootManager, blockRestore); _worldEvent = new WorldEventManager(plugin, this, damageManager, _lootManager, blockRestore, _clanRegions);
TaskManager taskManager = new TaskManager(plugin, _clientManager, webServerAddress); TaskManager taskManager = new TaskManager(plugin, _clientManager, webServerAddress);

View File

@ -1,179 +1,161 @@
package mineplex.game.clans.clans.worldevent; package mineplex.game.clans.clans.worldevent;
import java.util.HashMap; import java.util.ArrayList;
import java.util.HashSet; import java.util.List;
import java.util.Set; import java.util.Set;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.game.clans.clans.ClansManager;
import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.regions.ClansRegions;
public class EventTerrainFinder public class EventTerrainFinder
{ {
private WorldEventManager _eventManager; private WorldEventManager _eventManager;
private ClansManager _clansManager; private ClansManager _clansManager;
private ClansRegions _clansRegions;
public EventTerrainFinder(WorldEventManager eventManager, ClansManager clansManager)
public EventTerrainFinder(WorldEventManager eventManager, ClansManager clansManager, ClansRegions clansRegions)
{ {
_eventManager = eventManager; _eventManager = eventManager;
_clansManager = clansManager; _clansManager = clansManager;
_clansRegions = clansRegions;
} }
public double posNeg() public double posNeg()
{ {
if (Math.random() > 0.5) if (Math.random() > 0.5) return -1;
return -1;
return 1; return 1;
} }
public Location findArea(World world, int size, int vert) public Location findAreaInBorderlands(World world, int size, int vert)
{ {
for (int i=0 ; i<20 ; i++) System.out.println("Starting finding area...");
int borderlandsDist = 31;
int borderlandsWidth = 47 - borderlandsDist;
for (int i = 0; i < 20; i++)
{ {
int x = 0; int x = 0;
int z = 0; int z = 0;
//X Side x = (borderlandsDist * 16) + (UtilMath.clamp(UtilMath.random.nextInt(borderlandsWidth), 2, borderlandsWidth - 2) * 16);
if (Math.random() > 0.5) z = (borderlandsDist * 16) + (UtilMath.clamp(UtilMath.random.nextInt(borderlandsWidth), 2, borderlandsWidth - 2) * 16);
if (UtilMath.random.nextBoolean())
{ {
x = (int) (posNeg() * ((400 + size) + UtilMath.r(200 - (size*2)))); x = -x;
z = (int) (posNeg() * UtilMath.r(600 - size)); z = -z;
} }
//Z Side
else
{
z = (int) (posNeg() * ((400 + size) + UtilMath.r(200 - (size*2))));
x = (int) (posNeg() * UtilMath.r(600 - size));
}
Location loc = UtilBlock.getHighest(world, x, z).getLocation(); Location loc = UtilBlock.getHighest(world, x, z).getLocation();
int total = ((size*2)+1)*((size*2)+1); int blocks = ((size * 2) + 1) * ((size * 2) + 1);
int liquid = 0; boolean suitable = true;
HashMap<Integer, Integer> heights = new HashMap<Integer, Integer>();
int liquids = 0;
HashSet<Chunk> chunks = new HashSet<Chunk>(); for (x = -size; x < size; x++)
boolean wilderness = true;
//Gather Data
for (x=-size ; x<=size && wilderness ; x++)
for (z=-size ; z<=size && wilderness ; z++)
{
Block block = UtilBlock.getHighest(world, loc.getBlockX()+x, loc.getBlockZ()+z);
if (!chunks.contains(block.getChunk()))
if (_clansManager.getClanUtility().isClaimed(block.getLocation()))
{
chunks.add(block.getChunk());
wilderness = false;
break;
}
//Liquid
if (block.getRelative(BlockFace.DOWN).isLiquid() || block.isLiquid())
liquid++;
//Height
int heightDiff = block.getY() - loc.getBlockY();
if (!heights.containsKey(heightDiff)) heights.put(heightDiff, 1);
else heights.put(heightDiff, heights.get(heightDiff) + 1);
}
if (!wilderness)
continue;
//Too Watery
if ((double)liquid/(double)total > 0.25)
continue;
//Too Height Variable
int withinHeight = 0;
for (int h=-vert ; h<=vert ; h++)
{ {
if (!heights.containsKey(h)) for (z = -size; z < size; z++)
continue; {
Block topBlock = loc.getWorld().getBlockAt(loc.getBlockX() + x, loc.getWorld().getHighestBlockYAt(loc.getBlockX() + x, loc.getBlockZ() + z), loc.getBlockZ());
withinHeight += heights.get(h);
if (255 - topBlock.getY() < size)
{
suitable = false;
continue;
}
if (topBlock.isLiquid())
{
liquids++;
}
}
} }
if ((double)withinHeight/(double)total < 0.9) if (liquids > 1 && (((double) blocks)) / ((double) liquids) > 0.25)
{
System.out.println("water bad");
suitable = false;
}
// If this region is not suitable, try again.
if (!suitable)
{
continue; continue;
}
//Success
System.out.println("Done finding area... [success]");
// Success
return loc; return loc;
} }
System.out.println("Done finding area...");
return null; return null;
} }
public Location locateSpace(Location areaSource, int areaRadius, int xArea, int yArea, int zArea, boolean replaceBlocks, boolean aboveOther, Set<Block> otherBlock) public Location locateSpace(Location areaSource, int areaRadius, int xArea, int yArea, int zArea, boolean replaceBlocks, boolean aboveOther, Set<Block> otherBlock)
{ {
for (int i=0 ; i<20 ; i++) for (int i = 0; i < 20; i++)
{ {
int x = UtilMath.r(areaRadius*2) - areaRadius + areaSource.getBlockX(); int x = UtilMath.r(areaRadius * 2) - areaRadius + areaSource.getBlockX();
int z = UtilMath.r(areaRadius*2) - areaRadius + areaSource.getBlockZ(); int z = UtilMath.r(areaRadius * 2) - areaRadius + areaSource.getBlockZ();
Block block = UtilBlock.getHighest(areaSource.getWorld(), x, z); Block block = UtilBlock.getHighest(areaSource.getWorld(), x, z);
if (!aboveOther) if (!aboveOther) if (otherBlock.contains(block.getRelative(BlockFace.DOWN))) continue;
if (otherBlock.contains(block.getRelative(BlockFace.DOWN)))
continue;
boolean valid = true; boolean valid = true;
int overlaps = 0; int overlaps = 0;
//Previous // Previous
for (x=-xArea ; x<=xArea ; x++) for (x = -xArea; x <= xArea; x++)
{ {
for (z=-zArea ; z<=zArea ; z++) for (z = -zArea; z <= zArea; z++)
{ {
for (int y=0 ; y<=yArea ; y++) for (int y = 0; y <= yArea; y++)
{ {
//Check Blocks // Check Blocks
Block cur = areaSource.getWorld().getBlockAt(block.getX()+x, block.getY()+y, block.getZ()+z); Block cur = areaSource.getWorld().getBlockAt(block.getX() + x, block.getY() + y, block.getZ() + z);
if (cur.getRelative(BlockFace.DOWN).isLiquid()) if (cur.getRelative(BlockFace.DOWN).isLiquid())
{ {
valid = false; valid = false;
break; break;
} }
if (otherBlock.contains(cur)) if (otherBlock.contains(cur))
{ {
valid = false; valid = false;
break; break;
} }
//Check Area // Check Area
if (!UtilBlock.airFoliage(cur)) if (!UtilBlock.airFoliage(cur)) overlaps += 1;
overlaps += 1;
} }
if (!valid) if (!valid) break;
break;
} }
if (!valid) if (!valid) break;
break;
} }
if (!replaceBlocks && overlaps > 0) if (!replaceBlocks && overlaps > 0) continue;
continue;
if (!valid) continue;
if (!valid)
continue;
return block.getLocation(); return block.getLocation();
} }
return null; return null;
} }
} }

View File

@ -6,20 +6,6 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import mineplex.core.MiniPlugin;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.C;
import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.loot.LootManager;
import mineplex.game.clans.clans.worldevent.command.WorldEventCommand;
import mineplex.minecraft.game.core.boss.EventState;
import mineplex.minecraft.game.core.boss.WorldEvent;
import mineplex.minecraft.game.core.damage.DamageManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -31,53 +17,75 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.loot.LootManager;
import mineplex.game.clans.clans.regions.ClansRegions;
import mineplex.game.clans.clans.worldevent.command.WorldEventCommand;
import mineplex.minecraft.game.core.boss.EventState;
import mineplex.minecraft.game.core.boss.WorldEvent;
import mineplex.minecraft.game.core.damage.DamageManager;
public class WorldEventManager extends MiniPlugin implements ScoreboardElement public class WorldEventManager extends MiniPlugin implements ScoreboardElement
{ {
private final List<WorldEvent> _events; private final List<WorldEvent> _runningEvents;
private Random _random; private Random _random;
private ClansManager _clansManager; private ClansManager _clansManager;
private EventTerrainFinder _terrainFinder; private EventTerrainFinder _terrainFinder;
private DamageManager _damageManager; private DamageManager _damageManager;
private LootManager _lootManager; private LootManager _lootManager;
private BlockRestore _blockRestore; private BlockRestore _blockRestore;
private long _lastEventEnd;
private long _nextEventStart; private long _nextEventStart;
public WorldEventManager(JavaPlugin plugin, ClansManager clansManager, DamageManager damageManager, LootManager lootManager, BlockRestore blockRestore) public WorldEventManager(JavaPlugin plugin, ClansManager clansManager, DamageManager damageManager, LootManager lootManager, BlockRestore blockRestore, ClansRegions clansRegions)
{ {
super("World Event", plugin); super("World Event", plugin);
_random = new Random(); _random = new Random();
_terrainFinder = new EventTerrainFinder(this, clansManager); _terrainFinder = new EventTerrainFinder(this, clansManager, clansRegions);
_clansManager = clansManager; _clansManager = clansManager;
_damageManager = damageManager; _damageManager = damageManager;
_lootManager = lootManager; _lootManager = lootManager;
_blockRestore = blockRestore; _blockRestore = blockRestore;
_events = new LinkedList<WorldEvent>(); _runningEvents = new LinkedList<WorldEvent>();
_lastEventEnd = System.currentTimeMillis();
updateNextEventTime(); updateNextEventTime();
} }
public void addCommands()
{
addCommand(new WorldEventCommand(this));
}
// PS: This never gets called
@Override @Override
public void disable() public void disable()
{ {
for (WorldEvent event : _events) for (WorldEvent event : _runningEvents)
{ {
event.cancel(); event.cancel();
} }
} }
@EventHandler @EventHandler
public void removeEvent(UpdateEvent event) public void cleanupEvent(UpdateEvent event)
{ {
if (event.getType() != UpdateType.SEC) if (event.getType() != UpdateType.SEC)
{
return; return;
}
boolean removed = false; boolean removed = false;
Iterator<WorldEvent> iterator = _events.iterator(); Iterator<WorldEvent> iterator = _runningEvents.iterator();
while (iterator.hasNext()) while (iterator.hasNext())
{ {
WorldEvent worldEvent = iterator.next(); WorldEvent worldEvent = iterator.next();
@ -85,46 +93,41 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
{ {
HandlerList.unregisterAll(worldEvent); HandlerList.unregisterAll(worldEvent);
iterator.remove(); iterator.remove();
// If the event was cancelled, we don't need to run a cleanup // If the event was cancelled, cleanup was already done.
if (worldEvent.getState() == EventState.COMPLETE) worldEvent.cleanup(); if (worldEvent.getState() == EventState.COMPLETE)
{
worldEvent.cleanup();
}
removed = true; removed = true;
_lastEventEnd = System.currentTimeMillis();
} }
} }
if (removed && _events.size() == 0) if (removed && _runningEvents.size() == 0)
{ {
updateNextEventTime(); updateNextEventTime();
} }
if (_runningEvents.size() == 0 && System.currentTimeMillis() >= _nextEventStart)
{
if (UtilServer.getPlayers().length > 0)
{
tryStartEvent();
}
else
{
updateNextEventTime();
}
}
} }
// @EventHandler private void tryStartEvent()
// public void startEvent(UpdateEvent event)
// {
// if (event.getType() != UpdateType.SEC)
// return;
//
// if (_events.size() == 0 && System.currentTimeMillis() > _nextEventStart)
// {
// if (UtilServer.getPlayers().length > 0)
// {
// Bukkit.broadcastMessage("Starting new event from random...");
// startRandomEvent();
// }
// else
// {
// updateNextEventTime();
// }
// }
// }
private void startRandomEvent()
{ {
WorldEventType[] types = WorldEventType.values(); WorldEventType[] types = WorldEventType.values();
WorldEventType type = types[_random.nextInt(types.length)]; WorldEventType type = types[_random.nextInt(types.length)];
Location location = _terrainFinder.findArea(Bukkit.getWorlds().get(0), type.getAreaNeeded(), type.getAreaNeeded()); Location location = _terrainFinder.findAreaInBorderlands(Bukkit.getWorlds().get(0), type.getAreaNeeded(), type.getAreaNeeded());
if (location != null) if (location != null)
{ {
initializeEvent(type.createInstance(this, location)); initializeEvent(type.createInstance(this, location));
@ -132,20 +135,20 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
else else
{ {
// Try again in 5 minutes // Try again in 5 minutes
_nextEventStart = System.currentTimeMillis() + 300000; _nextEventStart = System.currentTimeMillis() + 25000;//300000;
} }
} }
private void initializeEvent(WorldEvent event) private void initializeEvent(WorldEvent event)
{ {
assert(event != null); assert(event != null);
event.loadMap(); event.loadMap();
event.start(); event.start();
getPlugin().getServer().getPluginManager().registerEvents(event, getPlugin()); getPlugin().getServer().getPluginManager().registerEvents(event, getPlugin());
_events.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);
@ -155,13 +158,13 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
initializeEvent(event); initializeEvent(event);
return event; return event;
} }
return null; return null;
} }
public void clearEvents() public void clearEvents()
{ {
Iterator<WorldEvent> iterator = _events.iterator(); Iterator<WorldEvent> iterator = _runningEvents.iterator();
while (iterator.hasNext()) while (iterator.hasNext())
{ {
WorldEvent event = iterator.next(); WorldEvent event = iterator.next();
@ -169,89 +172,82 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
HandlerList.unregisterAll(event); HandlerList.unregisterAll(event);
iterator.remove(); iterator.remove();
} }
updateNextEventTime(); updateNextEventTime();
} }
public ClansManager getClans() public ClansManager getClans()
{ {
return _clansManager; return _clansManager;
} }
public DamageManager getDamage() public DamageManager getDamage()
{ {
return _damageManager; return _damageManager;
} }
public LootManager getLoot() public LootManager getLoot()
{ {
return _lootManager; return _lootManager;
} }
public EventTerrainFinder getTerrainFinder() public EventTerrainFinder getTerrainFinder()
{ {
return _terrainFinder; return _terrainFinder;
} }
@Override
public void addCommands()
{
addCommand(new WorldEventCommand(this));
}
private void updateNextEventTime() private void updateNextEventTime()
{ {
// 45 Minutes + 0 - 15 Minutes // 45 Minutes + (0 - 15 Minutes)
long waitTime = 2700000L + _random.nextInt(900000); long waitTime = 25000;//2700000L + _random.nextInt(900000);
_nextEventStart = System.currentTimeMillis() + waitTime; _nextEventStart = System.currentTimeMillis() + waitTime;
} }
@Override @Override
public ArrayList<String> getLines(ScoreboardManager manager, Player player, ArrayList<String> out) public ArrayList<String> getLines(ScoreboardManager manager, Player player, ArrayList<String> out)
{ {
ArrayList<String> output = new ArrayList<String>(); ArrayList<String> output = new ArrayList<String>();
Iterator<WorldEvent> iterator = _events.iterator(); Iterator<WorldEvent> iterator = _runningEvents.iterator();
while (iterator.hasNext()) while (iterator.hasNext())
{ {
WorldEvent event = iterator.next(); WorldEvent event = iterator.next();
if (event.getState() == EventState.LIVE) if (event.getState() == EventState.LIVE)
{ {
output.add(" "); output.add(" ");
output.add(C.cAqua + C.Bold + "Event"); output.add(C.cAqua + C.Bold + "Event");
Location eventLocation = event.getCenterLocation(); Location eventLocation = event.getCenterLocation();
String locationString = eventLocation.getBlockX() + ", " + eventLocation.getBlockY() + ", " + eventLocation.getBlockZ(); String locationString = eventLocation.getBlockX() + ", " + eventLocation.getBlockY() + ", " + eventLocation.getBlockZ();
output.add(" " + C.cWhite + event.getName()); output.add(" " + C.cWhite + event.getName());
output.add(" " + C.cWhite + locationString); output.add(" " + C.cWhite + locationString);
ArrayList<String> scoreboardLines = event.getScoreboardLines(); ArrayList<String> scoreboardLines = event.getScoreboardLines();
if (scoreboardLines != null) output.addAll(event.getScoreboardLines()); if (scoreboardLines != null) output.addAll(event.getScoreboardLines());
break; break;
} }
} }
return output; return output;
} }
public BlockRestore getBlockRestore() public BlockRestore getBlockRestore()
{ {
return _blockRestore; return _blockRestore;
} }
public List<WorldEvent> getEvents() public List<WorldEvent> getEvents()
{ {
return _events; return _runningEvents;
} }
@EventHandler @EventHandler
public void gear(PlayerCommandPreprocessEvent event) public void gear(PlayerCommandPreprocessEvent event)
{ {
if (!event.getPlayer().isOp()) if (!event.getPlayer().isOp()) return;
return;
// TODO: Remove // TODO: Remove
if (event.getMessage().equalsIgnoreCase("/dgear")) if (event.getMessage().equalsIgnoreCase("/dgear"))
{ {

View File

@ -12,48 +12,48 @@ import org.bukkit.Location;
public enum WorldEventType public enum WorldEventType
{ {
SLIME_KING("Slime King", SlimeBoss.class, 30), KING_OF_THE_HILL("King of The Hill", KingHill.class, 30), UNDEAD_CAMP( SLIME_KING("Slime King", SlimeBoss.class, 30),
"Undead Camp", UndeadCamp.class, 30), Golem("Iron Wizard", GolemBoss.class, 30); KING_OF_THE_HILL("King of The Hill", KingHill.class, 30),
UNDEAD_CAMP("Undead Camp", UndeadCamp.class, 30),
Golem("Iron Wizard", GolemBoss.class, 30);
private String _name; private String _name;
private Class<? extends WorldEvent> _clazz; private Class<? extends WorldEvent> _clazz;
private int _areaNeeded; private int _areaNeeded;
WorldEventType(String name, Class<? extends WorldEvent> clazz, int areaNeeded) WorldEventType(String name, Class<? extends WorldEvent> clazz, int areaNeeded)
{ {
_name = name; _name = name;
_clazz = clazz; _clazz = clazz;
_areaNeeded = areaNeeded; _areaNeeded = areaNeeded;
} }
public int getAreaNeeded() public int getAreaNeeded()
{ {
return _areaNeeded; return _areaNeeded;
} }
public WorldEvent createInstance(WorldEventManager eventManager, Location centerLocation) public WorldEvent createInstance(WorldEventManager eventManager, Location centerLocation)
{ {
WorldEvent worldEvent = null; WorldEvent worldEvent = null;
try try
{ {
for (Constructor<?> con : _clazz.getConstructors()) for (Constructor<?> con : _clazz.getConstructors())
{ {
Class<?>[] classes = con.getParameterTypes(); Class<?>[] classes = con.getParameterTypes();
if (classes[0] == WorldEventManager.class) if (classes[0] == WorldEventManager.class)
{ {
worldEvent = (WorldEvent) con.newInstance(eventManager, centerLocation); worldEvent = (WorldEvent) con.newInstance(eventManager, centerLocation);
} }
else if (classes.length == 4) else if (classes.length == 4)
{ {
worldEvent = (WorldEvent) con.newInstance(eventManager.getDamage(), eventManager.getBlockRestore(), worldEvent = (WorldEvent) con.newInstance(eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), centerLocation);
eventManager.getClans().getCondition(), centerLocation);
} }
else else
{ {
worldEvent = (WorldEvent) con.newInstance(eventManager.getDamage(), eventManager.getBlockRestore(), worldEvent = (WorldEvent) con.newInstance(eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), eventManager.getClans().getProjectile(), centerLocation);
eventManager.getClans().getCondition(), eventManager.getClans().getProjectile(), centerLocation);
} }
} }
} }
@ -61,7 +61,7 @@ public enum WorldEventType
{ {
e.printStackTrace(); e.printStackTrace();
} }
return worldEvent; return worldEvent;
} }
} }

View File

@ -18,9 +18,9 @@ public class ClearCommand extends CommandBase<WorldEventManager>
{ {
public ClearCommand(WorldEventManager plugin) public ClearCommand(WorldEventManager plugin)
{ {
super(plugin, Rank.DEVELOPER, "clear"); super(plugin, Rank.DEVELOPER, new Rank[] { Rank.JNR_DEV }, "clear");
} }
@Override @Override
public void Execute(Player caller, String[] args) public void Execute(Player caller, String[] args)
{ {

View File

@ -13,7 +13,7 @@ public class StartCommand extends CommandBase<WorldEventManager>
{ {
public StartCommand(WorldEventManager plugin) public StartCommand(WorldEventManager plugin)
{ {
super(plugin, Rank.DEVELOPER, "start", "create"); super(plugin, Rank.DEVELOPER, new Rank[] { Rank.JNR_DEV }, "start", "create");
} }
@Override @Override

View File

@ -10,15 +10,15 @@ public class WorldEventCommand extends MultiCommandBase<WorldEventManager>
{ {
public WorldEventCommand(WorldEventManager plugin) public WorldEventCommand(WorldEventManager plugin)
{ {
super(plugin, Rank.DEVELOPER, "worldevent", "we", "event"); super(plugin, Rank.DEVELOPER, new Rank[] { Rank.JNR_DEV }, "worldevent", "we", "event");
AddCommand(new StartCommand(Plugin)); AddCommand(new StartCommand(Plugin));
AddCommand(new ClearCommand(Plugin)); AddCommand(new ClearCommand(Plugin));
} }
@Override @Override
protected void Help(Player caller, String[] args) protected void Help(Player caller, String[] args)
{ {
} }
} }

View File

@ -9,6 +9,8 @@ import org.bukkit.Material;
import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton;
import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class UndeadArcher extends EventCreature<Skeleton> public class UndeadArcher extends EventCreature<Skeleton>
{ {
@ -27,6 +29,7 @@ public class UndeadArcher extends EventCreature<Skeleton>
eq.setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); eq.setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
eq.setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); eq.setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
eq.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); eq.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 0));
} }
@Override @Override

View File

@ -15,6 +15,8 @@ import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class UndeadWarrior extends EventCreature<Zombie> public class UndeadWarrior extends EventCreature<Zombie>
{ {
@ -32,6 +34,7 @@ public class UndeadWarrior extends EventCreature<Zombie>
eq.setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); eq.setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
eq.setLeggings(new ItemStack(Material.IRON_LEGGINGS)); eq.setLeggings(new ItemStack(Material.IRON_LEGGINGS));
eq.setBoots(new ItemStack(Material.IRON_BOOTS)); eq.setBoots(new ItemStack(Material.IRON_BOOTS));
entity.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 0));
} }
@Override @Override

View File

@ -54,7 +54,7 @@ public abstract class WorldEvent implements Listener
private Schematic _schematic; private Schematic _schematic;
// Creatures // Creatures
private List<EventCreature> _creatures; private List<EventCreature<?>> _creatures;
// Block Restore // Block Restore
private BlockRestoreMap _blocks; private BlockRestoreMap _blocks;
private boolean _isArcade; private boolean _isArcade;
@ -81,7 +81,7 @@ public abstract class WorldEvent implements Listener
_random = new Random(); _random = new Random();
_ticks = 0; _ticks = 0;
_creatures = new ArrayList<EventCreature>(); _creatures = new ArrayList<>();
_blocks = blockRestore.createMap(); _blocks = blockRestore.createMap();
_lastActive = System.currentTimeMillis(); _lastActive = System.currentTimeMillis();
@ -240,18 +240,18 @@ public abstract class WorldEvent implements Listener
return _map == null ? _cornerLocation : _map.getCenterLocation(); return _map == null ? _cornerLocation : _map.getCenterLocation();
} }
public List<EventCreature> getCreatures() public List<EventCreature<?>> getCreatures()
{ {
return _creatures; return _creatures;
} }
public void registerCreature(EventCreature creature) public void registerCreature(EventCreature<?> creature)
{ {
UtilServer.getServer().getPluginManager().registerEvents(creature, _damageManager.getPlugin()); UtilServer.getServer().getPluginManager().registerEvents(creature, _damageManager.getPlugin());
_creatures.add(creature); _creatures.add(creature);
} }
public void removeCreature(EventCreature creature) public void removeCreature(EventCreature<?> creature)
{ {
HandlerList.unregisterAll(creature); HandlerList.unregisterAll(creature);
_creatures.remove(creature); _creatures.remove(creature);
@ -267,7 +267,7 @@ public abstract class WorldEvent implements Listener
public void clearCreatures() public void clearCreatures()
{ {
for (EventCreature creature : _creatures) for (EventCreature<?> creature : _creatures)
{ {
creature.remove(false); creature.remove(false);
HandlerList.unregisterAll(creature); HandlerList.unregisterAll(creature);