king of the hill gold drop fix

This commit is contained in:
NewGarbo 2015-11-15 20:37:37 +00:00
parent 5209cf3d38
commit fff248ad86
2 changed files with 14 additions and 43 deletions

View File

@ -1,32 +0,0 @@
package mineplex.core.common.util;
import org.bukkit.scheduler.BukkitRunnable;
public abstract class LimitedBukkitRunnable extends BukkitRunnable
{
private int _timesRun;
private int _maxTimes;
public LimitedBukkitRunnable(int maxTimes)
{
_maxTimes = maxTimes;
}
@Override
public void run()
{
if (_timesRun > _maxTimes)
{
UtilServer.getServer().getScheduler().cancelTask(getTaskId());
return;
}
onRun(_timesRun);
_timesRun++;
}
public abstract void onRun(int timesRun);
}

View File

@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LimitedBukkitRunnable;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.scoreboard.ScoreboardManager;
@ -27,7 +26,7 @@ public class KingHill extends WorldEvent
{
private static List<HillData> LOADED_HILLS = new ArrayList<HillData>();
private static int GOLD_PER_TICK = 5;
private static int GOLD_PER_TICK = 3;
private ClanInfo _clanOnHill;
@ -54,6 +53,7 @@ public class KingHill extends WorldEvent
private long _lastGoldDrop;
private long _lastOnHillMessage;
private long _goldDrops;
public KingHill(WorldEventManager eventManager, Location centerLocation)
{
@ -133,19 +133,22 @@ public class KingHill extends WorldEvent
}
capData.TicksOnHill++;
if (System.currentTimeMillis() - _lastGoldDrop > 30000)
if (System.currentTimeMillis() - _lastGoldDrop > 20000)
{
UtilServer.getServer().getScheduler().scheduleSyncRepeatingTask(getPlugin(), new LimitedBukkitRunnable(100)
{
public void onRun(int timesRun)
{
GoldManager.getInstance().dropGold(getCenterLocation().clone().add(0, 13, 0), GOLD_PER_TICK);
}
}, 0L, 1L);
_goldDrops = 1;
_lastGoldDrop = System.currentTimeMillis();
}
if (_goldDrops > 0 && _goldDrops < 200)
{
GoldManager.getInstance().dropGold(getCenterLocation().clone().add(0, 13, 0), GOLD_PER_TICK);
_goldDrops++;
}
else
{
_goldDrops = 0;
}
if (System.currentTimeMillis() - _lastOnHillMessage > 30000)
{
Bukkit.broadcastMessage(F.desc("Hill", F.elem(lastClan.getName()) + " own the hill (" + F.time(UtilTime.MakeStr(capData.TicksOnHill * 50)) + ")"));