Fix bugs arising during clans release

This commit is contained in:
AlexTheCoder 2016-07-28 19:08:47 -04:00
parent f3944527f8
commit 47d79bbad5
6 changed files with 96 additions and 29 deletions

View File

@ -96,36 +96,39 @@ public class PlayerScoreboard
for (int i=0 ; i<lines.size() ; i++)
{
//Get New Line
String newLine = lines.get(i);
//Check if Unchanged
if (_currentLines.size() > i)
if ((15-i) >= 0)
{
String oldLine = _currentLines.get(i);
//Get New Line
String newLine = lines.get(i);
if (oldLine.equals(newLine))
//Check if Unchanged
if (_currentLines.size() > i)
{
String oldLine = _currentLines.get(i);
if (oldLine.equals(newLine))
continue;
}
// Ignore extra lines
if (i >= _teamNames.length)
continue;
//Update
Team team = _scoreboard.getTeam(_teamNames[i]);
if (team == null)
{
System.out.println("Scoreboard Error: Line Team Not Found!");
return;
}
//Set Line Prefix/Suffix
team.setPrefix(newLine.substring(0, Math.min(newLine.length(), 16)));
team.setSuffix(ChatColor.getLastColors(team.getPrefix()) + newLine.substring(team.getPrefix().length(), Math.min(newLine.length(), 32)));
//Line
_sideObjective.getScore(_teamNames[i]).setScore(15-i);
}
// Ignore extra lines
if (i >= _teamNames.length)
continue;
//Update
Team team = _scoreboard.getTeam(_teamNames[i]);
if (team == null)
{
System.out.println("Scoreboard Error: Line Team Not Found!");
return;
}
//Set Line Prefix/Suffix
team.setPrefix(newLine.substring(0, Math.min(newLine.length(), 16)));
team.setSuffix(ChatColor.getLastColors(team.getPrefix()) + newLine.substring(team.getPrefix().length(), Math.min(newLine.length(), 32)));
//Line
_sideObjective.getScore(_teamNames[i]).setScore(15-i);
}
//Hide Old Unused

View File

@ -1,9 +1,13 @@
package mineplex.game.clans.clans.nether;
import java.util.LinkedList;
import java.util.List;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanTips.TipType;
@ -40,6 +44,7 @@ public class BossNetherPortal implements Listener
private Location[] _corners;
private boolean _returnPortal;
private byte _portalFacing;
private LinkedList<Long> _closeWarnings = new LinkedList<>();
public boolean Open = false;
public long Expire = -1;
@ -97,6 +102,16 @@ public class BossNetherPortal implements Listener
{
_portalFacing = (byte)0;
}
_closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
_closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
_closeWarnings.add(30000L);
_closeWarnings.add(10000L);
_closeWarnings.add(5000L);
_closeWarnings.add(4000L);
_closeWarnings.add(3000L);
_closeWarnings.add(2000L);
_closeWarnings.add(1000L);
}
private boolean isInPortal(Block block)
@ -261,6 +276,23 @@ public class BossNetherPortal implements Listener
{
return;
}
if (Open && Expire != -1)
{
Long warning = -1L;
for (Long test : _closeWarnings)
{
if ((Expire - System.currentTimeMillis()) < warning)
{
warning = test;
break;
}
}
if (warning != -1)
{
_closeWarnings.remove(warning);
Bukkit.broadcastMessage(F.main(ClansManager.getInstance().getNetherManager().getName(), "The " + F.clansNether("Nether Portal") + " at " + F.elem(UtilWorld.locToStrClean(getLocation())) + " will close in " + F.elem(UtilTime.MakeStr(warning)) + "!"));
}
}
if (Open && Expire != -1 && System.currentTimeMillis() >= Expire)
{
close();

View File

@ -260,7 +260,7 @@ public class NetherManager extends MiniPlugin
{
return;
}
BossNetherPortal portal = new BossNetherPortal(bossSpawn.clone().add(-2, 5, 0), bossSpawn.clone().add(0, 0, 2), false);
BossNetherPortal portal = new BossNetherPortal(bossSpawn.clone().add(-2, 5, 0), bossSpawn.clone().add(2, 0, 0), false);
portal.open(PORTAL_OPEN_DURATION);
for (NetherPortal returnPortal : _returnPortals)
{

View File

@ -1,9 +1,13 @@
package mineplex.game.clans.clans.nether;
import java.util.LinkedList;
import java.util.List;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanTips.TipType;
@ -41,6 +45,7 @@ public class NetherPortal implements Listener
private Location[] _corners;
private boolean _returnPortal;
private byte _portalFacing;
private LinkedList<Long> _closeWarnings = new LinkedList<>();
public boolean Open = false;
public long Expire = -1;
@ -99,6 +104,16 @@ public class NetherPortal implements Listener
{
_portalFacing = (byte)0;
}
_closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
_closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
_closeWarnings.add(30000L);
_closeWarnings.add(10000L);
_closeWarnings.add(5000L);
_closeWarnings.add(4000L);
_closeWarnings.add(3000L);
_closeWarnings.add(2000L);
_closeWarnings.add(1000L);
}
private boolean isInPortal(Block block)
@ -272,6 +287,23 @@ public class NetherPortal implements Listener
{
return;
}
if (Open && Expire != -1)
{
Long warning = -1L;
for (Long test : _closeWarnings)
{
if ((Expire - System.currentTimeMillis()) < warning)
{
warning = test;
break;
}
}
if (warning != -1)
{
_closeWarnings.remove(warning);
Bukkit.broadcastMessage(F.main(ClansManager.getInstance().getNetherManager().getName(), "The " + F.clansNether("Nether Portal") + " at " + F.elem(UtilWorld.locToStrClean(getLocation())) + " will close in " + F.elem(UtilTime.MakeStr(warning)) + "!"));
}
}
if (Open && Expire != -1 && System.currentTimeMillis() >= Expire)
{
close();

View File

@ -282,7 +282,7 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
spawnEntity();
}
if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 34)
if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 30)
{
if (_teleportHome != -1 && System.currentTimeMillis() >= _teleportHome)
{

View File

@ -135,7 +135,7 @@ public class WraithCreature extends EventCreature<Zombie>
return;
Location teleport = zombie.getTarget().getLocation().add(Math.random() + 1, 0, Math.random() + 1);
if (UtilMath.offset(getSpawnLocation(), teleport) > 34)
if (UtilMath.offset(getSpawnLocation(), teleport) > 30)
{
return;
}