Fixing bugs

This commit is contained in:
libraryaddict 2015-11-04 18:34:22 +13:00
parent c25b1969de
commit b3f86ba638
5 changed files with 257 additions and 406 deletions

View File

@ -8,6 +8,7 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -17,6 +18,7 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.EnchantingInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
@ -174,7 +176,14 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
return;
}
event.getInventory().setItem(1, new ItemStack(Material.INK_SACK, 30, (byte) 4));
int level = ((Player) event.getPlayer()).getLevel();
for (HumanEntity viewer : event.getViewers())
{
level = Math.max(((Player) viewer).getLevel(), level);
}
event.getInventory().setItem(1, new ItemStack(Material.INK_SACK, level, (byte) 4));
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
@ -198,6 +207,14 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
if (event.getViewers().size() > 1)
{
int level = ((Player) event.getPlayer()).getLevel();
for (HumanEntity viewer : event.getViewers())
{
level = Math.max(((Player) viewer).getLevel(), level);
}
event.getInventory().setItem(1, new ItemStack(Material.INK_SACK, level, (byte) 4));
return;
}
@ -205,21 +222,45 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
public void onInventoryClick(final InventoryClickEvent event)
{
if (event.getView().getTopInventory().getType() != InventoryType.ENCHANTING)
{
return;
}
ItemStack item = event.getCurrentItem();
if (event.getSlot() == 1)
{
event.setCancelled(true);
return;
}
if (item == null || item.getType() != Material.INK_SACK)
if (event.getSlot() != 2)
{
return;
}
event.setCancelled(true);
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
{
public void run()
{
Inventory inv = event.getInventory();
if (inv.getViewers().isEmpty())
{
return;
}
int level = 0;
for (HumanEntity viewer : inv.getViewers())
{
level = Math.max(((Player) viewer).getLevel(), level);
}
event.getInventory().setItem(1, new ItemStack(Material.INK_SACK, level, (byte) 4));
}
});
}
@EventHandler

View File

@ -100,12 +100,7 @@ public abstract class Game implements Listener
public enum GameState
{
Loading,
Recruit,
Prepare,
Live,
End,
Dead
Loading, Recruit, Prepare, Live, End, Dead
}
public ArcadeManager Manager;
@ -306,7 +301,6 @@ public abstract class Game implements Listener
public int DeadBodiesExpire = -1;
private IPacketHandler _useEntityPacketHandler;
protected Field PacketTeam;
private int _deadBodyCount;
private NautHashMap<String, Entity> _deadBodies = new NautHashMap<String, Entity>();
private NautHashMap<String, Long> _deadBodiesExpire = new NautHashMap<String, Long>();
@ -319,7 +313,8 @@ public abstract class Game implements Listener
Manager = manager;
// Player List
UtilTabTitle.broadcastHeaderAndFooter(C.cGold + C.Bold + gameType.GetName(), "Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop");
UtilTabTitle.broadcastHeaderAndFooter(C.cGold + C.Bold + gameType.GetName(), "Visit " + C.cGreen + "www.mineplex.com"
+ ChatColor.RESET + " for News, Forums and Shop");
// Game
_gameType = gameType;
@ -372,32 +367,12 @@ public abstract class Game implements Listener
WorldData = new WorldData(this);
// Stat Trackers
registerStatTrackers(
new KillsStatTracker(this),
new DeathsStatTracker(this),
new AssistsStatTracker(this),
new ExperienceStatTracker(this),
new WinStatTracker(this),
new LoseStatTracker(this),
new DamageDealtStatTracker(this),
new DamageTakenStatTracker(this),
new GamesPlayedStatTracker(this)
);
registerStatTrackers(new KillsStatTracker(this), new DeathsStatTracker(this), new AssistsStatTracker(this),
new ExperienceStatTracker(this), new WinStatTracker(this), new LoseStatTracker(this), new DamageDealtStatTracker(
this), new DamageTakenStatTracker(this), new GamesPlayedStatTracker(this));
Manager.setResourcePack(gameType.getResourcePackUrl(), gameType.isEnforceResourcePack());
try
{
PacketTeam = Class.forName(
"org.bukkit.craftbukkit.v1_8_R3.scoreboard.CraftTeam")
.getDeclaredField("team");
PacketTeam.setAccessible(true);
}
catch (Exception ex)
{
ex.printStackTrace();
}
_useEntityPacketHandler = new IPacketHandler()
{
@Override
@ -405,9 +380,8 @@ public abstract class Game implements Listener
{
if (packetInfo.getPacket() instanceof PacketPlayInUseEntity)
{
net.minecraft.server.v1_8_R3.Entity entity = ((PacketPlayInUseEntity) packetInfo
.getPacket()).a(((CraftWorld) packetInfo
.getPlayer().getWorld()).getHandle());
net.minecraft.server.v1_8_R3.Entity entity = ((PacketPlayInUseEntity) packetInfo.getPacket())
.a(((CraftWorld) packetInfo.getPlayer().getWorld()).getHandle());
if (entity instanceof EntityItem)
{
@ -437,7 +411,10 @@ public abstract class Game implements Listener
public GameType[] GetWorldHostNames()
{
GameType[] mapSource = new GameType[]{GetType()};
GameType[] mapSource = new GameType[]
{
GetType()
};
if (GetType().getMapSource() != null)
{
if (GetType().ownMaps())
@ -643,8 +620,7 @@ public abstract class Game implements Listener
for (Perk perk : kit.GetPerks())
{
UtilServer.getServer().getPluginManager()
.registerEvents(perk, Manager.getPlugin());
UtilServer.getServer().getPluginManager().registerEvents(perk, Manager.getPlugin());
perk.registeredEvents();
}
}
@ -777,8 +753,7 @@ public abstract class Game implements Listener
{
for (Kit kit : _kits)
{
if (kit.GetAvailability() == KitAvailability.Hide ||
kit.GetAvailability() == KitAvailability.Null)
if (kit.GetAvailability() == KitAvailability.Hide || kit.GetAvailability() == KitAvailability.Null)
continue;
if (team.KitAllowed(kit))
@ -798,7 +773,10 @@ public abstract class Game implements Listener
if (!team.KitAllowed(kit))
{
player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 0.5f);
UtilPlayer.message(player, F.main("Kit", F.elem(team.GetFormattedName()) + " cannot use " + F.elem(kit.GetFormattedName() + " Kit") + "."));
UtilPlayer.message(
player,
F.main("Kit", F.elem(team.GetFormattedName()) + " cannot use " + F.elem(kit.GetFormattedName() + " Kit")
+ "."));
return;
}
}
@ -981,7 +959,8 @@ public abstract class Game implements Listener
SpectatorSpawn.setZ(vec.getZ());
// Move Up - Out Of Blocks
while (!UtilBlock.airFoliage(SpectatorSpawn.getBlock()) || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP)))
while (!UtilBlock.airFoliage(SpectatorSpawn.getBlock())
|| !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP)))
{
SpectatorSpawn.add(0, 1, 0);
}
@ -1003,7 +982,8 @@ public abstract class Game implements Listener
}
// Move Down - Out Of Blocks
while (Up > 0 && !UtilBlock.airFoliage(SpectatorSpawn.getBlock()) || !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP)))
while (Up > 0 && !UtilBlock.airFoliage(SpectatorSpawn.getBlock())
|| !UtilBlock.airFoliage(SpectatorSpawn.getBlock().getRelative(BlockFace.UP)))
{
SpectatorSpawn.subtract(0, 1, 0);
Up--;
@ -1045,13 +1025,15 @@ public abstract class Game implements Listener
public boolean CanJoinTeam(GameTeam team)
{
return Manager.IsTeamBalance() ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length / GetTeamList().size()) : true;
return Manager.IsTeamBalance() ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length / GetTeamList().size())
: true;
}
@EventHandler
public final void onFoodLevelChangeEvent(FoodLevelChangeEvent event)
{
((Player) event.getEntity()).setSaturation(3.8F); // While not entirely accurate, this is a pretty good guess at original food level changes
((Player) event.getEntity()).setSaturation(3.8F); // While not entirely accurate, this is a pretty good guess at original
// food level changes
}
public GameTeam GetTeamPreference(Player player)
@ -1091,7 +1073,11 @@ public abstract class Game implements Listener
{
for (Player player : _teamPreference.get(team))
{
UtilPlayer.message(player, F.main("Team", "You are " + F.elem(GetTeamQueuePosition(player)) + " in queue for " + F.elem(team.GetFormattedName() + " Team") + "."));
UtilPlayer.message(
player,
F.main("Team",
"You are " + F.elem(GetTeamQueuePosition(player)) + " in queue for "
+ F.elem(team.GetFormattedName() + " Team") + "."));
}
}
}
@ -1123,7 +1109,8 @@ public abstract class Game implements Listener
}
UtilPlayer.message(player, "");
UtilPlayer.message(player, C.cGreen + "Map - " + C.cYellow + C.Bold + WorldData.MapName + ChatColor.RESET + C.cGray + " created by " + C.cYellow + C.Bold + WorldData.MapAuthor);
UtilPlayer.message(player, C.cGreen + "Map - " + C.cYellow + C.Bold + WorldData.MapName + ChatColor.RESET + C.cGray
+ " created by " + C.cYellow + C.Bold + WorldData.MapAuthor);
UtilPlayer.message(player, ArcadeFormat.Line);
}
@ -1162,10 +1149,10 @@ public abstract class Game implements Listener
UtilPlayer.message(player, "Nobody won the game!");
}
UtilPlayer.message(player, _customWinLine);
UtilPlayer.message(player, "");
UtilPlayer.message(player, "§aMap - §f§l" + WorldData.MapName + C.cGray + " created by " + "§f§l" + WorldData.MapAuthor);
UtilPlayer.message(player, "§aMap - §f§l" + WorldData.MapName + C.cGray + " created by " + "§f§l"
+ WorldData.MapAuthor);
UtilPlayer.message(player, ArcadeFormat.Line);
}
@ -1209,13 +1196,11 @@ public abstract class Game implements Listener
UtilPlayer.message(player, C.cRed + C.Bold + "1st Place" + C.cWhite + " - " + places.get(0).getName());
}
if (places.size() >= 2)
{
UtilPlayer.message(player, C.cGold + C.Bold + "2nd Place" + C.cWhite + " - " + places.get(1).getName());
}
if (places.size() >= 3)
{
UtilPlayer.message(player, C.cYellow + C.Bold + "3rd Place" + C.cWhite + " - " + places.get(2).getName());
@ -1223,7 +1208,8 @@ public abstract class Game implements Listener
}
UtilPlayer.message(player, "");
UtilPlayer.message(player, "§aMap - §f§l" + WorldData.MapName + C.cGray + " created by " + "§f§l" + WorldData.MapAuthor);
UtilPlayer.message(player, "§aMap - §f§l" + WorldData.MapName + C.cGray + " created by " + "§f§l"
+ WorldData.MapAuthor);
UtilPlayer.message(player, ArcadeFormat.Line);
}
@ -1234,7 +1220,6 @@ public abstract class Game implements Listener
Manager.GetChat().Silence(5000, false);
}
public void Announce(String message)
{
if (message == null)
@ -1344,17 +1329,22 @@ public abstract class Game implements Listener
return;
}
Announce(F.elem(player.getName()) + " used a " + F.elem(C.cGreen + "Gem Booster") + " for " + F.elem("+" + (100 - (GemBoosters.size() * 25)) + "% Gems") + "!");
Announce(F.elem(player.getName()) + " used a " + F.elem(C.cGreen + "Gem Booster") + " for "
+ F.elem("+" + (100 - (GemBoosters.size() * 25)) + "% Gems") + "!");
GemBoosters.add(player.getName());
}
public double GetGemBoostAmount()
{
if (GemBoosters.size() == 1) return 1;
if (GemBoosters.size() == 2) return 1.75;
if (GemBoosters.size() == 3) return 2.25;
if (GemBoosters.size() == 4) return 2.5;
if (GemBoosters.size() == 1)
return 1;
if (GemBoosters.size() == 2)
return 1.75;
if (GemBoosters.size() == 3)
return 2.25;
if (GemBoosters.size() == 4)
return 2.5;
return 0;
}
@ -1400,8 +1390,6 @@ public abstract class Game implements Listener
}
}
public Collection<StatTracker<? extends Game>> getStatTrackers()
{
return _statTrackers;
@ -1454,13 +1442,8 @@ public abstract class Game implements Listener
public boolean isInsideMap(Location loc)
{
return !(
loc.getX() >= WorldData.MaxX + 1 ||
loc.getX() <= WorldData.MinX ||
loc.getZ() >= WorldData.MaxZ + 1 ||
loc.getZ() <= WorldData.MinZ ||
loc.getY() >= WorldData.MaxY + 1 ||
loc.getY() <= WorldData.MinY);
return !(loc.getX() >= WorldData.MaxX + 1 || loc.getX() <= WorldData.MinX || loc.getZ() >= WorldData.MaxZ + 1
|| loc.getZ() <= WorldData.MinZ || loc.getY() >= WorldData.MaxY + 1 || loc.getY() <= WorldData.MinY);
}
public void setItemMerge(boolean itemMerge)
@ -1538,46 +1521,11 @@ public abstract class Game implements Listener
{
if (event.GetState() == GameState.Live)
{
getArcadeManager().getPacketHandler().addPacketHandler(
_useEntityPacketHandler, PacketPlayInUseEntity.class);
getArcadeManager().getPacketHandler().addPacketHandler(_useEntityPacketHandler, PacketPlayInUseEntity.class);
}
else if (event.GetState() == GameState.Dead)
{
getArcadeManager().getPacketHandler().removePacketHandler(
_useEntityPacketHandler);
}
}
@EventHandler
public void onDeadBodyJoin(PlayerJoinEvent event)
{
for (int i = 0; i < _deadBodyCount; i++)
{
String name = "";
for (char c : ("" + i).toCharArray())
{
name += "§" + c;
}
try
{
Team team = Scoreboard.GetScoreboard().getTeam(name);
if (team == null)
{
continue;
}
PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam(
(ScoreboardTeam) PacketTeam.get(team), 2);
UtilPlayer.sendPacket(event.getPlayer(), packet);
}
catch (Exception ex)
{
ex.printStackTrace();
}
getArcadeManager().getPacketHandler().removePacketHandler(_useEntityPacketHandler);
}
}
@ -1628,43 +1576,21 @@ public abstract class Game implements Listener
return;
}
String name = "";
String name = "Body #" + _deadBodyCount++;
for (char c : ("" + _deadBodyCount++).toCharArray())
{
name += "§" + c;
}
try
{
Team team = Scoreboard.GetScoreboard().getTeam(ChatColor.COLOR_CHAR + "DeadBody");
Team team = Scoreboard.GetScoreboard().getTeam(ChatColor.COLOR_CHAR + "DeadBodies");
if (team == null)
{
team = Scoreboard.GetScoreboard().registerNewTeam(ChatColor.COLOR_CHAR + "DeadBody");
}
team = Scoreboard.GetScoreboard().registerNewTeam(ChatColor.COLOR_CHAR + "DeadBodies");
team.setNameTagVisibility(NameTagVisibility.NEVER);
}
team.addEntry(name);
PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam(
(ScoreboardTeam) PacketTeam.get(team), 2);
for (Player alive : GetPlayers(false))
{
UtilPlayer.sendPacket(alive, packet);
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
GameProfile newProfile = new GameProfile(UUID.randomUUID(), name);
newProfile.getProperties()
.putAll(((CraftPlayer) player).getHandle().getProfile()
.getProperties());
newProfile.getProperties().putAll(((CraftPlayer) player).getHandle().getProfile().getProperties());
DisguisePlayer disguise = new DisguisePlayer(null, newProfile);
@ -1675,10 +1601,8 @@ public abstract class Game implements Listener
Location loc = player.getLocation();
WorldServer world = ((CraftWorld) loc.getWorld()).getHandle();
EntityItem nmsItem = new EntityItem(world, loc.getX(),
loc.getY() + 0.5, loc.getZ(),
CraftItemStack.asNMSCopy(new ItemBuilder(Material.STONE)
.setTitle(System.currentTimeMillis() + "").build()));
EntityItem nmsItem = new EntityItem(world, loc.getX(), loc.getY() + 0.5, loc.getZ(),
CraftItemStack.asNMSCopy(new ItemBuilder(Material.STONE).setTitle(System.currentTimeMillis() + "").build()));
nmsItem.motX = 0;
nmsItem.motY = 0;
@ -1695,8 +1619,7 @@ public abstract class Game implements Listener
if (DeadBodiesExpire > 0)
{
_deadBodiesExpire.put(player.getName(), System.currentTimeMillis()
+ (DeadBodiesExpire * 1000));
_deadBodiesExpire.put(player.getName(), System.currentTimeMillis() + (DeadBodiesExpire * 1000));
}
}
@ -1732,37 +1655,36 @@ public abstract class Game implements Listener
{
Block block = loc.getBlock();
while (block.getY() > 0
&& !UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN))
while (block.getY() > 0 && !UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN))
&& !UtilBlock.solid(block.getRelative(BlockFace.DOWN)))
{
block = block.getRelative(BlockFace.DOWN);
}
BlockFace proper = BlockFace.values()[Math.round(loc.getYaw() / 90F) & 0x3]
.getOppositeFace();
BlockFace proper = BlockFace.values()[Math.round(loc.getYaw() / 90F) & 0x3].getOppositeFace();
// A complicated way to get the face the dead body should be towards.
for (HashSet<Byte> validBlocks : new HashSet[]
{
UtilBlock.blockAirFoliageSet, UtilBlock.blockPassSet
UtilBlock.blockAirFoliageSet,
UtilBlock.blockPassSet
})
{
if (validBlocks.contains((byte) block.getRelative(proper)
.getTypeId()))
if (validBlocks.contains((byte) block.getRelative(proper).getTypeId()))
{
return proper;
}
for (BlockFace face : new BlockFace[]
{
BlockFace.EAST, BlockFace.SOUTH, BlockFace.NORTH,
BlockFace.EAST,
BlockFace.SOUTH,
BlockFace.NORTH,
BlockFace.WEST
})
{
if (validBlocks.contains((byte) block.getRelative(face)
.getTypeId()))
if (validBlocks.contains((byte) block.getRelative(face).getTypeId()))
{
return face;
}
@ -1780,8 +1702,7 @@ public abstract class Game implements Listener
return;
}
Iterator<Entry<String, Long>> itel = _deadBodiesExpire.entrySet()
.iterator();
Iterator<Entry<String, Long>> itel = _deadBodiesExpire.entrySet().iterator();
while (itel.hasNext())
{

View File

@ -97,7 +97,6 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder.EnumWorldBorderAction;
import net.minecraft.server.v1_8_R3.ScoreboardTeam;
import net.minecraft.server.v1_8_R3.WorldServer;
import net.minecraft.server.v1_8_R3.WorldBorder;
public abstract class SurvivalGames extends Game
{
@ -643,7 +642,10 @@ public abstract class SurvivalGames extends Game
border);
}
setBorder();
_borderStartedMoving = System.currentTimeMillis();
WorldBorder border = WorldData.World.getWorldBorder();
border.setSize(_currentBorder * 2, 1);
_deathMatchTime = 11;
}
@ -876,31 +878,6 @@ public abstract class SurvivalGames extends Game
}.runTaskTimer(getArcadeManager().getPlugin(), 0, 60);
}
@EventHandler
public void onGameState(GameStateChangeEvent event)
{
if (GetState() != GameState.Live)
{
return;
}
for (Player player : UtilServer.getPlayers())
{
setupBorder(player);
}
}
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
if (!IsLive())
{
return;
}
setupBorder(event.getPlayer());
}
@EventHandler
public void onSecond(UpdateEvent event)
{
@ -921,7 +898,10 @@ public abstract class SurvivalGames extends Game
{
_currentBorder = _borderPositions.get(_secondsSinceStart);
setBorder();
_borderStartedMoving = System.currentTimeMillis();
WorldBorder border = WorldData.World.getWorldBorder();
border.setSize(_currentBorder * 2, 1);
}
_secondsSinceStart++;
@ -1337,6 +1317,13 @@ public abstract class SurvivalGames extends Game
_supplyLocations = WorldData.GetDataLocs("WHITE");
for (Location loc : _supplyLocations)
loc.getBlock().setType(Material.GLASS);
WorldBorder border = WorldData.World.getWorldBorder();
border.setCenter(_spawn);
border.setSize(_currentBorder * 2);
border.setDamageBuffer(-99);
border.setWarningDistance(-99);
border.setWarningTime(-99);
}
@EventHandler
@ -1467,50 +1454,6 @@ public abstract class SurvivalGames extends Game
_hiddenNames.remove(event.getPlayer());
}
private void setBorder()
{
_borderStartedMoving = System.currentTimeMillis();
WorldBorder border = new WorldBorder();
border.setCenter(_spawn.getX(), _spawn.getZ());
border.transitionSizeBetween(_previousBorder * 2, _currentBorder * 2,
_currentBorder != _previousBorder ? 1000 : 0);
PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(border,
EnumWorldBorderAction.LERP_SIZE);
for (Player player : Bukkit.getOnlinePlayers())
{
UtilPlayer.sendPacket(player, packet);
}
}
private void setupBorder(Player player)
{
WorldBorder border = new WorldBorder();
border.transitionSizeBetween(
_previousBorder * 2,
_currentBorder * 2,
_currentBorder != _previousBorder ? 1000 - Math.min(1000,
(System.currentTimeMillis() - _borderStartedMoving))
: 0);
border.setCenter(_spawn.getX(), _spawn.getZ());
border.setWarningDistance(-10);
border.setWarningTime(-10);
PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(border,
EnumWorldBorderAction.INITIALIZE);
// We don't set warnings speed or blocks as its not particularly useful
// for this game.
// Also if we don't use it here, its more effective in other places to
// reinforce the idea what its for.
UtilPlayer.sendPacket(player, packet);
}
private void setupChestsEnchantingCrafting()
{
ArrayList<Location> chests = WorldData.GetCustomLocs("54");

View File

@ -34,9 +34,6 @@ import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.kit.Kit;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder;
import net.minecraft.server.v1_8_R3.WorldBorder;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder.EnumWorldBorderAction;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -45,6 +42,7 @@ import org.bukkit.Difficulty;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.WorldBorder;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -231,6 +229,13 @@ public class UHC extends TeamGame
{
_borderPositions.put(i++ * 4, border);
}
WorldBorder border = WorldData.World.getWorldBorder();
border.setCenter(0, 0);
border.setSize(_currentBorder * 2);
border.setDamageBuffer(-99);
border.setWarningDistance(-99);
border.setWarningTime(-99);
}
@EventHandler
@ -270,28 +275,15 @@ public class UHC extends TeamGame
{
_currentBorder = _borderPositions.get(_secondsSinceStart);
setBorder();
_borderStartedMoving = System.currentTimeMillis();
WorldBorder border = WorldData.World.getWorldBorder();
border.setSize(_currentBorder * 2, 1);
}
_secondsSinceStart++;
}
private void setBorder()
{
WorldBorder border = new WorldBorder();
border.transitionSizeBetween(_previousBorder * 2, _currentBorder * 2,
_currentBorder != _previousBorder ? 1000 : 0);
PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(border,
EnumWorldBorderAction.LERP_SIZE);
for (Player player : Bukkit.getOnlinePlayers())
{
UtilPlayer.sendPacket(player, packet);
}
}
@EventHandler
public void outsideBorder(UpdateEvent event)
{
@ -349,53 +341,6 @@ public class UHC extends TeamGame
}
}
@EventHandler
public void onGameState(GameStateChangeEvent event)
{
if (GetState() != GameState.Live)
{
return;
}
for (Player player : UtilServer.getPlayers())
{
setupBorder(player);
}
}
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
if (!IsLive())
{
return;
}
setupBorder(event.getPlayer());
}
private void setupBorder(Player player)
{
WorldBorder border = new WorldBorder();
border.transitionSizeBetween(
_previousBorder * 2,
_currentBorder * 2,
_currentBorder != _previousBorder ? 1000 - Math.min(1000,
(System.currentTimeMillis() - _borderStartedMoving))
: 0);
border.setWarningDistance(-10);
border.setWarningTime(-10);
PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(border,
EnumWorldBorderAction.INITIALIZE);
// We don't set warnings speed or blocks as its not particularly useful for this game.
// Also if we don't use it here, its more effective in other places to reinforce the idea what its for.
UtilPlayer.sendPacket(player, packet);
}
private ArrayList<Double> buildBorders(int seconds, double border, double leaveRemaining)
{
double totalNumber = Math.pow(seconds, 1.9D) + (seconds * 50);

View File

@ -115,6 +115,7 @@ public class WorldData
TimingManager.stop("WorldData loading world.");
World.setDifficulty(Difficulty.HARD);
World.setGameRuleValue("showDeathmessages", "false");
TimingManager.start("WorldData loading WorldConfig.");
//Load World Data