fix supply chest protection, absorbtion effect, tnt and level bugs

This commit is contained in:
xXVevzZXx 2016-06-17 20:25:57 +02:00 committed by cnr
parent a33b070ae7
commit 399ab5c363
6 changed files with 68 additions and 26 deletions

View File

@ -218,7 +218,7 @@ public enum GameType
Pair<MinecraftVersion, String>[] _resourcePacks; Pair<MinecraftVersion, String>[] _resourcePacks;
Class<? extends Game> _gameClass; Class<? extends Game> _gameClass;
GameMode[] _gameModes; private GameMode[] _gameModes;
private boolean _gameMaps; private boolean _gameMaps;
private int _gameId; // Unique identifying id for this gamemode (used for statistics) private int _gameId; // Unique identifying id for this gamemode (used for statistics)
@ -322,16 +322,15 @@ public enum GameType
return _display.getGameCategory(); return _display.getGameCategory();
} }
public String GetKitGameName() public String GetKitGameName(Game game)
{ {
if (hasGamemodes())
{
return getModeGameType(game.getClass())._display.getKitGameName();
}
return _display.getKitGameName(); return _display.getKitGameName();
} }
public boolean isUsingGameModes()
{
return _gameMaps;
}
public GameType getModeGameType(Class<? extends Game> game) public GameType getModeGameType(Class<? extends Game> game)
{ {
for (GameMode mode : getGameModes()) for (GameMode mode : getGameModes())
@ -343,4 +342,14 @@ public enum GameType
} }
return null; return null;
} }
public boolean isUsingGameModesMaps()
{
return _gameMaps;
}
public boolean hasGamemodes()
{
return _gameModes.length != 0;
}
} }

View File

@ -462,7 +462,7 @@ public abstract class Game implements Listener
} }
} }
if (GetType().isUsingGameModes()) if (GetType().isUsingGameModesMaps())
{ {
GameType mode = GetType().getModeGameType(getClass()); GameType mode = GetType().getModeGameType(getClass());

View File

@ -48,7 +48,7 @@ public class AbsorptionFix implements Listener
{ {
player.removePotionEffect(PotionEffectType.ABSORPTION); player.removePotionEffect(PotionEffectType.ABSORPTION);
player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles())); player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
player.setHealth(player.getMaxHealth()); player.setHealth(player.getHealth() + 4);
} }
} }
} }

View File

@ -13,6 +13,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -21,6 +22,7 @@ import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionType; import org.bukkit.potion.PotionType;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
@ -49,6 +51,8 @@ public class OverpoweredBridge extends Bridge
WorldBoundaryKill = true; WorldBoundaryKill = true;
Manager.GetDamage().SetEnabled(false);
new AbsorptionFix(this); new AbsorptionFix(this);
} }
@ -128,6 +132,10 @@ public class OverpoweredBridge extends Bridge
public void supplyChest(PlayerPrepareTeleportEvent event) public void supplyChest(PlayerPrepareTeleportEvent event)
{ {
Location chestLoc = event.GetPlayer().getLocation().clone().add(0, 0, 1); Location chestLoc = event.GetPlayer().getLocation().clone().add(0, 0, 1);
while (chestLoc.getBlock().getType() == Material.CHEST)
chestLoc.add(2, 0, 0);
_starterChests.put(event.GetPlayer(), chestLoc); _starterChests.put(event.GetPlayer(), chestLoc);
Block block = chestLoc.getBlock(); Block block = chestLoc.getBlock();
@ -136,8 +144,9 @@ public class OverpoweredBridge extends Bridge
Chest chest = (Chest) block.getState(); Chest chest = (Chest) block.getState();
event.GetPlayer().getLocation().getBlock().setType(Material.WALL_SIGN); Block signBlock = chestLoc.clone().add(0, 0, -1).getBlock();
Sign sign = (Sign) event.GetPlayer().getLocation().getBlock().getState(); signBlock.setType(Material.WALL_SIGN);
Sign sign = (Sign) signBlock.getState();
sign.setLine(0, "§b============="); sign.setLine(0, "§b=============");
sign.setLine(1, "§4§l" + event.GetPlayer().getName() + ChatColor.RESET + "§4's"); sign.setLine(1, "§4§l" + event.GetPlayer().getName() + ChatColor.RESET + "§4's");
sign.setLine(2, "§4Supply Chest"); sign.setLine(2, "§4Supply Chest");
@ -182,20 +191,18 @@ public class OverpoweredBridge extends Bridge
if (event.getClickedBlock().getType() != Material.CHEST) if (event.getClickedBlock().getType() != Material.CHEST)
return; return;
for (Player player : _starterChests.keySet()) event.setCancelled(disallow(event.getPlayer(), event.getClickedBlock()));
{
if (player == event.getPlayer())
continue;
if (_starterChests.get(player).getBlock().getLocation()
.equals(event.getClickedBlock().getLocation()))
{
event.setCancelled(true);
break;
}
}
} }
} }
@EventHandler
public void placeChest(BlockPlaceEvent event)
{
if (event.getBlockPlaced().getType() != Material.CHEST)
return;
event.setCancelled(disallow(event.getPlayer(), event.getBlock()));
}
@EventHandler @EventHandler
public void CheatChestBreak(BlockBreakEvent event) public void CheatChestBreak(BlockBreakEvent event)
@ -219,6 +226,32 @@ public class OverpoweredBridge extends Bridge
} }
} }
} }
private boolean disallow(Player clicker, Block block)
{
for (Player player : _starterChests.keySet())
{
System.out.println("test4");
if (player == clicker)
continue;
System.out.println("test2");
Location chest = _starterChests.get(player);
if (chest.getBlock().getLocation().equals(block.getLocation()))
{
System.out.println("test1");
return true;
}
for (Block surround : UtilBlock.getSurrounding(block, false))
{
if(chest.getBlock().getLocation().equals(surround.getLocation()))
return true;
}
}
return false;
}
@Override @Override
public void ParseOre(ArrayList<Location> teamOre) public void ParseOre(ArrayList<Location> teamOre)

View File

@ -292,7 +292,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit
if (this.GetAvailability() == KitAvailability.Free || if (this.GetAvailability() == KitAvailability.Free ||
Manager.hasKitsUnlocked(player) || Manager.hasKitsUnlocked(player) ||
(this.GetAvailability() == KitAvailability.Achievement && Manager.GetAchievement().hasCategory(player, this.getAchievementRequirement())) || (this.GetAvailability() == KitAvailability.Achievement && Manager.GetAchievement().hasCategory(player, this.getAchievementRequirement())) ||
donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName() + " " + this.GetName()) || donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName(Manager.GetGame()) + " " + this.GetName()) ||
Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) ||
donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || Manager.GetServerConfig().Tournament) donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || Manager.GetServerConfig().Tournament)
{ {
@ -306,7 +306,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit
{ {
Manager.GetGame().SetKit(player, this, true); Manager.GetGame().SetKit(player, this, true);
} }
}, null, new KitPackage(Manager.GetGame().GetType().GetKitGameName(), this), CurrencyType.GEM, player)); }, null, new KitPackage(Manager.GetGame().GetType().GetKitGameName(Manager.GetGame()), this), CurrencyType.GEM, player));
} }
else if (this.GetAvailability() == KitAvailability.Achievement) else if (this.GetAvailability() == KitAvailability.Achievement)
{ {

View File

@ -1177,7 +1177,7 @@ public class GameLobbyManager implements Listener
Manager.hasKitsUnlocked(player) || //YouTube Manager.hasKitsUnlocked(player) || //YouTube
(ent.GetKit().GetAvailability() == KitAvailability.Achievement && (ent.GetKit().GetAvailability() == KitAvailability.Achievement &&
Manager.GetAchievement().hasCategory(player, ent.GetKit().getAchievementRequirement())) || //Achievement Manager.GetAchievement().hasCategory(player, ent.GetKit().getAchievementRequirement())) || //Achievement
donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName() + " " + ent.GetKit().GetName()) || //Green donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName(game) + " " + ent.GetKit().GetName()) || //Green
Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || //STAFF Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || //STAFF
donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old) donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old)
Manager.GetServerConfig().Tournament) //Tournament Manager.GetServerConfig().Tournament) //Tournament