From 6f06ac2018f5bd4aece375fd9acfc014ef13e780 Mon Sep 17 00:00:00 2001 From: Chiss Date: Tue, 26 Nov 2013 23:54:02 +1100 Subject: [PATCH] HG lag fixes item frames cannot be broken creep damage messages --- .../game/core/combat/CombatComponent.java | 8 ++ .../game/core/combat/CombatManager.java | 43 ++++++--- .../game/core/damage/DamageManager.java | 3 - .../game/games/hungergames/HungerGames.java | 90 ++++++++++++++++--- 4 files changed, 119 insertions(+), 25 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java index 46af36a0a..e4bab96c4 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java @@ -56,6 +56,14 @@ public class CombatComponent return _damage; } + + public String GetReason() + { + if (_damage.isEmpty()) + return null; + + return _damage.get(0).GetName(); + } public long GetLastDamage() { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java index e9d48ebdc..40ab1efc3 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java @@ -240,7 +240,7 @@ public class CombatManager extends MiniPlugin String source = "?"; String reason = "-"; - + if (cause == DamageCause.BLOCK_EXPLOSION) { source = "Explosion"; @@ -326,7 +326,10 @@ public class CombatManager extends MiniPlugin source = "Wither"; reason = "-"; } - + + if (event.GetReason() != null) + reason = event.GetReason(); + Get(event.GetDamageePlayer()).Attacked(source, (int) event.GetDamage(), null, reason); } @@ -420,15 +423,33 @@ public class CombatManager extends MiniPlugin UtilPlayer.message(cur, F.main("Death", deadPlayer + C.cGray + " has died.")); else - UtilPlayer.message( - cur, - F.main("Death", - deadPlayer - + C.cGray - + " killed by " - + F.name(log.GetAttackers() - .getFirst().GetName())) - + C.cGray + "."); + { + if (log.GetLastDamager() != null && log.GetLastDamager().GetReason() != null && log.GetLastDamager().GetReason().length() > 1) + { + UtilPlayer.message( + cur, + F.main("Death", + deadPlayer + + C.cGray + + " killed by " + + F.name(log.GetLastDamager() + .GetReason())) + + C.cGray + "."); + } + else + { + UtilPlayer.message( + cur, + F.main("Death", + deadPlayer + + C.cGray + + " killed by " + + F.name(log.GetAttackers() + .getFirst().GetName())) + + C.cGray + "."); + } + } + } } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java index 82e5eb646..3a4bb6c0e 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java @@ -311,9 +311,6 @@ public class DamageManager extends MiniPlugin for (String cur : event.GetCancellers()) UtilPlayer.message(player, F.elem("Cancel ") + cur); - - - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hungergames/HungerGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hungergames/HungerGames.java index 58d1770a9..b485b47b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hungergames/HungerGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hungergames/HungerGames.java @@ -20,6 +20,7 @@ import org.bukkit.block.BlockFace; import org.bukkit.block.Chest; import org.bukkit.entity.Entity; import org.bukkit.entity.Firework; +import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; import org.bukkit.entity.Snowball; import org.bukkit.entity.TNTPrimed; @@ -32,10 +33,13 @@ import org.bukkit.event.block.BlockFadeEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockSpreadEvent; import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.hanging.HangingBreakByEntityEvent; +import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; @@ -264,8 +268,8 @@ public class HungerGames extends SoloGame int spawn = 0; //Chests - System.out.println("Chests: " + Math.min(220, chests.size())); - for (int i=0 ; i<220 && !chests.isEmpty() ; i++) + System.out.println("Chests: " + Math.min(250, chests.size())); + for (int i=0 ; i<250 && !chests.isEmpty() ; i++) { Location loc = chests.remove(UtilMath.r(chests.size())); @@ -300,7 +304,7 @@ public class HungerGames extends SoloGame int done = 0; - while (done < 30) + while (done < 40) { Block block = UtilBlock.getHighest(WorldData.World, WorldData.MinX + UtilMath.r(xDiff), WorldData.MinZ + UtilMath.r(zDiff), ignore); @@ -684,6 +688,20 @@ public class HungerGames extends SoloGame } if (surroundedByWater) return false; + + //Dont Spread to Moving + if (block.getTypeId() == 9) + if (block.getData() != 0) + return false; + + //Dont spread near moving + for (Block other : UtilBlock.getSurrounding(block, false)) + { + if (other.getTypeId() == 9 && other.getData() != 0) + { + return false; + } + } } //Ignore Signs @@ -733,7 +751,7 @@ public class HungerGames extends SoloGame return; MapUtil.ChunkBlockChange(loc, id, data); - + //Save Red if (!_redMap.containsKey(loc.getBlockX())) _redMap.put(loc.getBlockX(), new HashMap>()); @@ -742,7 +760,26 @@ public class HungerGames extends SoloGame _redMap.get(loc.getBlockX()).put(loc.getBlockY(), new HashSet()); _redMap.get(loc.getBlockX()).get(loc.getBlockY()).add(loc.getBlockZ()); + + //Old Style + /* + if (true) + { + for (Player player : UtilServer.getPlayers()) + { + if (Math.abs(player.getLocation().getChunk().getX() - loc.getChunk().getX()) > UtilServer.getServer().getViewDistance()) + continue; + + if (Math.abs(player.getLocation().getChunk().getZ() - loc.getChunk().getZ()) > UtilServer.getServer().getViewDistance()) + continue; + + player.sendBlockChange(loc, id, data); + } + return; + } + */ + //Non-Queue for (Player player : UtilServer.getPlayers()) { @@ -758,7 +795,7 @@ public class HungerGames extends SoloGame boolean added = false; for (ChunkChange change : _redChunks.get(player)) { - if (change.Chunk.equals(loc.getChunk()) && change.DirtyCount < 63) + if (change.Chunk.equals(loc.getChunk()))// && change.DirtyCount < 63) { change.AddChange(loc, id, data); added = true; @@ -773,7 +810,7 @@ public class HungerGames extends SoloGame @EventHandler public void RedChunkUpdate(UpdateEvent event) { - if (event.getType() != UpdateType.TICK) + if (event.getType() != UpdateType.FASTER) return; if (!IsLive()) @@ -830,7 +867,7 @@ public class HungerGames extends SoloGame //Send MultiBlock or Chunk Update for Fittest Chunk ChunkChange change = _redChunks.get(player).remove(bestId); - if (change.DirtyCount >= 63) + if (change.DirtyCount > 63) MapUtil.SendChunkForPlayer(change.Chunk.getX(), change.Chunk.getZ(), player); else MapUtil.SendMultiBlockForPlayer(change.Chunk.getX(), change.Chunk.getZ(), change.DirtyBlocks, change.DirtyCount, change.Chunk.getWorld(), player); @@ -914,7 +951,7 @@ public class HungerGames extends SoloGame Snowball ball = player.getWorld().spawn(block.getLocation().add(0.5, 1.5, 0.5).subtract(traj.clone().multiply(8 + UtilMath.r(8))), Snowball.class); ball.setVelocity(UtilAlg.getTrajectory(ball.getLocation(), player.getEyeLocation().add(0, 3, 0)).add(new Vector(Math.random()-0.5, Math.random()-0.5, Math.random()-0.5).multiply(0.1))); - } + } } //Nether @@ -950,14 +987,16 @@ public class HungerGames extends SoloGame if (near) { + player.getWorld().playSound(player.getLocation(), Sound.AMBIENCE_RAIN, 0.2f, 0f); + if (!_redOutTime.containsKey(player)) { _redOutTime.put(player, System.currentTimeMillis()); - } + } else { if (UtilTime.elapsed(_redOutTime.get(player), 5000)) - { + { Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, 1, false, true, false, "Hunger Games", _spreadName); @@ -1117,7 +1156,14 @@ public class HungerGames extends SoloGame if (_deathmatchTime <= 0) return; - + + for (Player player : GetPlayers(true)) + for (Player other : GetPlayers(true)) + { + player.hidePlayer(other); + player.showPlayer(other); + } + Announce(C.cRed + C.Bold + "Deathmatch in " + _deathmatchTime + "..."); _deathmatchTime--; } @@ -1331,6 +1377,26 @@ public class HungerGames extends SoloGame } } } + + @EventHandler + public void DisallowBrewFurnace(PlayerInteractEvent event) + { + if (event.getClickedBlock() == null) + return; + + if (event.getClickedBlock().getType() == Material.BREWING_STAND || + event.getClickedBlock().getType() == Material.FURNACE) + event.setCancelled(true); + } + + @EventHandler + public void CancelItemFrameBreak(HangingBreakEvent event) + { + if (event.getEntity() instanceof ItemFrame) + { + event.setCancelled(true); + } + } @EventHandler public void TNTDelay(GameStateChangeEvent event) @@ -1531,4 +1597,6 @@ public class HungerGames extends SoloGame _helpIndex = (_helpIndex + 1)%_help.length; } + + }