Quick fix in EventTerrainFinder because of incorrect block checking.

Added a constant "GOLD_PER_TICK" in the King of the Hill code, because hardcoded numbers are no fun.
Commented out some strange useless code.

Renamed getTicks() to getTicksRunning() and _ticks to _ticksRunning.
This commit is contained in:
NewGarbo 2015-11-15 12:09:31 +00:00
parent e28059848c
commit 33d358ac6a
3 changed files with 25 additions and 22 deletions

View File

@ -64,7 +64,7 @@ public class EventTerrainFinder
{
for (z = -size; z < size; z++)
{
Block topBlock = loc.getWorld().getBlockAt(loc.getBlockX() + x, loc.getWorld().getHighestBlockYAt(loc.getBlockX() + x, loc.getBlockZ() + z), loc.getBlockZ());
Block topBlock = loc.getWorld().getBlockAt(loc.getBlockX() + x, UtilBlock.getHighest(loc.getWorld(), loc.getBlockX() + x, loc.getBlockZ() + z).getY(), loc.getBlockZ());
if (255 - topBlock.getY() < size)
{

View File

@ -25,7 +25,9 @@ import org.bukkit.entity.Player;
public class KingHill extends WorldEvent
{
private static List<HillData> LOADED_HILLS = new ArrayList<HillData>();
private static int GOLD_PER_TICK = 1;
static
{
// TODO load hills from schematic folder with extra hill data from a config file?
@ -78,8 +80,8 @@ public class KingHill extends WorldEvent
@Override
protected void customTick()
{
if (getTicks() % 1 == 0)
// uh who wrote this code? below code == [divide ticksRunning by 1, if remainder is 0 do tickHill()]
// if (getTicksRunning() % 1 == 0)
tickHill();
if (System.currentTimeMillis() > _nextLootDrop)
@ -115,7 +117,7 @@ public class KingHill extends WorldEvent
if (clanCount == 1 && lastClan != null)
{
if (getTicks() % 40 == 0)
if (getTicksRunning() % 40 == 0)
Bukkit.broadcastMessage(lastClan.getName() + " owns the hill!");
CaptureData capData = _scoreMap.get(lastClan);
@ -126,7 +128,7 @@ public class KingHill extends WorldEvent
}
capData.TicksOnHill++;
GoldManager.getInstance().dropGold(_hill.getHillCenter(getCenterLocation()), 1);
GoldManager.getInstance().dropGold(_hill.getHillCenter(getCenterLocation()), GOLD_PER_TICK);
}
}

View File

@ -6,6 +6,15 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.blockrestore.BlockRestoreMap;
import mineplex.core.common.block.BlockData;
@ -15,6 +24,7 @@ import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilWorld;
@ -25,15 +35,6 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public abstract class WorldEvent implements Listener
{
// 20 Minutes
@ -49,7 +50,7 @@ public abstract class WorldEvent implements Listener
private Location _cornerLocation;
private EventMap _map;
private Random _random;
private int _ticks;
private int _ticksRunning;
private long _lastActive;
private Schematic _schematic;
@ -79,7 +80,7 @@ public abstract class WorldEvent implements Listener
_state = EventState.PREPARE;
_cornerLocation = cornerLocation;
_random = new Random();
_ticks = 0;
_ticksRunning = 0;
_creatures = new ArrayList<>();
_blocks = blockRestore.createMap();
@ -210,9 +211,9 @@ public abstract class WorldEvent implements Listener
return _state;
}
public int getTicks()
public int getTicksRunning()
{
return _ticks;
return _ticksRunning;
}
public DamageManager getDamageManager()
@ -354,7 +355,7 @@ public abstract class WorldEvent implements Listener
public int getRandomRange(int min, int max)
{
return min + _random.nextInt(max - min);
return min + _random.nextInt(UtilMath.clamp(max - min, min, max));
}
@EventHandler
@ -363,7 +364,7 @@ public abstract class WorldEvent implements Listener
if (event.getType() != UpdateType.TICK)
return;
_ticks++;
_ticksRunning++;
customTick();
}
@ -388,7 +389,7 @@ public abstract class WorldEvent implements Listener
return;
// Event was preparing for more than 5 minutes
if (getTicks() > 6000)
if (getTicksRunning() > 6000)
cancel();
}
}