diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/winstreaks/WinStreakManager.java b/Plugins/Mineplex.Core/src/mineplex/core/game/winstreaks/WinStreakManager.java index dba772b47..090661076 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/winstreaks/WinStreakManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/winstreaks/WinStreakManager.java @@ -64,8 +64,7 @@ public class WinStreakManager extends MiniDbClientPlugin> map.put(game.getGameId(), newValue); } - int finalValue = newValue; - runAsync(() -> _repository.setWinStreak(ClientManager.getAccountId(player), game.getGameId(), finalValue)); + runAsync(() -> _repository.incrementWinStreak(ClientManager.getAccountId(player), game.getGameId())); } public void removeWinStreak(Player player, GameDisplay game) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/winstreaks/WinStreakRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/game/winstreaks/WinStreakRepository.java index e2eb12623..386fb4835 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/winstreaks/WinStreakRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/winstreaks/WinStreakRepository.java @@ -7,7 +7,7 @@ import mineplex.serverdata.database.column.ColumnInt; class WinStreakRepository extends RepositoryBase { - private static final String UPDATE_OR_INSERT = "REPLACE INTO accountWinStreak VALUES(?,?,?)"; + private static final String UPDATE_OR_INSERT = "INSERT INTO accountWinStreak VALUES (?,?,?) ON DUPLICATE KEY value=value+1"; private static final String DELETE = "DELETE FROM accountWinStreak WHERE accountId=? AND gameId=?"; WinStreakRepository() @@ -15,12 +15,12 @@ class WinStreakRepository extends RepositoryBase super(DBPool.getAccount()); } - void setWinStreak(int accountId, int gameId, int value) + void incrementWinStreak(int accountId, int gameId) { executeUpdate(UPDATE_OR_INSERT, new ColumnInt("accountId", accountId), new ColumnInt("gameId", gameId), - new ColumnInt("value", value) + new ColumnInt("value", 1) ); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/CakeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/CakeWars.java index 57e48d5a0..b19f43475 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/CakeWars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/CakeWars.java @@ -396,15 +396,19 @@ public class CakeWars extends TeamGame .addItem(new ItemBuilder(Material.DIAMOND_CHESTPLATE) .setUnbreakable(true) .build()) - .addItem(new ItemStack(Material.EMERALD), 10, 20) - .addItem(new ItemStack(Material.CLAY_BRICK), 20, 40) .addItem(new ItemStack(Material.NETHER_STAR), 3, 4) .addItem(CakeShopModule.ENDER_PEARL, 1, 2) .addItem(new ItemStack(Material.GOLDEN_APPLE), 2, 3) .addItem(new ItemBuilder(Material.POTION) .setTitle(C.cAqua + "Speed Potion") .addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 30 * 20, 0)) - .build()) + .build()), + + new ChestLootPool() + .addItem(new ItemStack(Material.EMERALD), 4, 8), + + new ChestLootPool() + .addItem(new ItemStack(Material.CLAY_BRICK), 8, 16) ).destroyAfterOpened(30); _chestLootModule.register(this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/general/CakePlayerModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/general/CakePlayerModule.java index c7622c215..98b9764e1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/general/CakePlayerModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/general/CakePlayerModule.java @@ -5,6 +5,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -58,6 +59,11 @@ public class CakePlayerModule extends CakeModule .addLore("", "Creates a platform of wool next to", "any block you click!", "Uses: " + C.cRed + "1") .setUnbreakable(true) .build(); + public static final ItemStack INSTA_WALL = new ItemBuilder(Material.STAINED_GLASS) + .setTitle(C.cYellowB + "Insta-Wall") + .addLore("", "Creates a wall of wool above", "any block you click!", "Uses: " + C.cRed + "1") + .setUnbreakable(true) + .build(); private static final int PLATFORM_DELTA = 1; private static final PotionEffect SPAWN_PROTECTION = new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 120, 0); @@ -315,38 +321,65 @@ public class CakePlayerModule extends CakeModule return; } - if (itemStack == null || itemStack.getType() != Material.INK_SACK || block == null) + if (itemStack == null || block == null) { return; } BlockFace face = UtilBlock.getFace(player.getLocation().getYaw()).getOppositeFace(); - block = block.getRelative(face).getRelative(face); byte teamData = _game.GetTeam(player).GetColorData(); boolean blockChanged = false; - for (int x = -PLATFORM_DELTA; x <= PLATFORM_DELTA; x++) + if (itemStack.getType() == DEPLOY_PLATFORM.getType()) { - for (int z = -PLATFORM_DELTA; z <= PLATFORM_DELTA; z++) + block = block.getRelative(face).getRelative(face); + + for (int x = -PLATFORM_DELTA; x <= PLATFORM_DELTA; x++) { - Block nearby = block.getRelative(x, 0, z); - - Location nearbyLocation = nearby.getLocation(); - - if ( - !UtilBlock.airFoliage(nearby) || - _game.getCapturePointModule().isOnPoint(nearbyLocation) || - _game.getCakeShopModule().isNearShop(nearbyLocation) || - _game.getCakeSpawnerModule().isNearSpawner(nearbyLocation) || - _game.isNearSpawn(nearbyLocation) - ) + for (int z = -PLATFORM_DELTA; z <= PLATFORM_DELTA; z++) { - continue; - } + Block nearby = block.getRelative(x, 0, z); + Location nearbyLocation = nearby.getLocation(); - _placedBlocks.add(nearby); - MapUtil.QuickChangeBlockAt(nearbyLocation, Material.WOOL, teamData); - blockChanged = true; + if (isInvalidBlock(nearby)) + { + continue; + } + + _placedBlocks.add(nearby); + MapUtil.QuickChangeBlockAt(nearbyLocation, Material.WOOL, teamData); + blockChanged = true; + } + } + } + else if (itemStack.getType() == INSTA_WALL.getType()) + { + event.setCancelled(true); + + boolean xAxis = face == BlockFace.NORTH || face == BlockFace.SOUTH; + block = block.getRelative(BlockFace.UP).getRelative(BlockFace.UP); + + for (int x = -PLATFORM_DELTA; x <= PLATFORM_DELTA; x++) + { + for (int y = -PLATFORM_DELTA; y <= PLATFORM_DELTA; y++) + { + Block nearby = block.getRelative(xAxis ? x : 0, y, xAxis ? 0 : x); + Location nearbyLocation = nearby.getLocation(); + + if (isInvalidBlock(nearby)) + { + continue; + } + + _placedBlocks.add(nearby); + MapUtil.QuickChangeBlockAt(nearbyLocation, Material.WOOL, teamData); + blockChanged = true; + + if (Math.random() > 0.5) + { + nearbyLocation.getWorld().playEffect(nearbyLocation, Effect.STEP_SOUND, Material.WOOL, teamData); + } + } } } @@ -356,6 +389,12 @@ public class CakePlayerModule extends CakeModule } } + private boolean isInvalidBlock(Block block) + { + Location location = block.getLocation(); + return !UtilBlock.airFoliage(block) || _game.getCapturePointModule().isOnPoint(location) || _game.getCakeShopModule().isNearShop(location) || _game.getCakeSpawnerModule().isNearSpawner(location) || _game.isNearSpawn(location); + } + @EventHandler public void itemCraft(CraftItemEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/kits/KitCakeBuilder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/kits/KitCakeBuilder.java index 401585149..3775b752d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/kits/KitCakeBuilder.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/kits/KitCakeBuilder.java @@ -5,8 +5,6 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import mineplex.core.common.util.C; - import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.cakewars.kits.perk.PerkPassiveWoolGain; import nautilus.game.arcade.kit.KitAvailability; @@ -20,7 +18,8 @@ public class KitCakeBuilder extends ProgressingKit { "Get extra blocks to build with!", "", - receiveItem("Wool Block", 1, 4, 32), + receiveItem("Knitted Wool", 1, 5, 32), + receiveItem("Knitted Platform", 1, 10, 8) }; private static final Perk[] PERKS = diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/CakeShopModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/CakeShopModule.java index ecce33e85..41be39d7d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/CakeShopModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/CakeShopModule.java @@ -15,6 +15,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -25,6 +26,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.itemstack.ItemBuilder; @@ -149,6 +151,9 @@ public class CakeShopModule extends CakeModule // Rune of Holding new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.RUNE_OF_HOLDING, 20), + // Insta-Wall + new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.INSTA_WALL, 3), + // Traps new CakeTNTTrap(8), new CakeBearTrap(8) @@ -228,7 +233,7 @@ public class CakeShopModule extends CakeModule Player player = event.getPlayer(); CakeResource resource = entry.getValue(); - if (UtilPlayer.isSpectator(player) || !Recharge.Instance.use(player, "Interact Shop", 500, false, false)) + if (UtilPlayer.isSpectator(player) || event.getAction() == Action.LEFT_CLICK_BLOCK && UtilItem.isSword(player.getItemInHand()) || !Recharge.Instance.use(player, "Interact Shop", 500, false, false)) { return; } @@ -281,7 +286,7 @@ public class CakeShopModule extends CakeModule cakeTeam.getUpgrades().forEach((item, level) -> { - if (level > 0) + if (level > 0 && (!_game.getCakeTeamModule().hasCakeRot() && item == CakeTeamItem.REGENERATION)) { alive.forEach(player -> item.apply(player, level, cakeTeam.getCake())); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/CakeTeamItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/CakeTeamItem.java index ee8f02df3..af179482f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/CakeTeamItem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/CakeTeamItem.java @@ -83,7 +83,7 @@ public enum CakeTeamItem implements CakeItem @Override public void apply(Player player, int level, Location cake) { - if (UtilMath.offsetSquared(player.getLocation(), cake) < 400) + if (UtilMath.offset2dSquared(player.getLocation(), cake) < 25) { player.removePotionEffect(PotionEffectType.REGENERATION); player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60, level - 1, true, false)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/trap/CakeBearTrap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/trap/CakeBearTrap.java index 71d394b33..0835c7d02 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/trap/CakeBearTrap.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/trap/CakeBearTrap.java @@ -19,13 +19,15 @@ public class CakeBearTrap extends CakeTrapItem public CakeBearTrap(int cost) { super(new ItemStack(Material.TRIPWIRE_HOOK), cost, "Bear Trap", - C.cWhite + "When a player attempts to eat your Cake.", + C.cWhite + "When a player gets near your Cake.", C.cWhite + "They are blinded and slowed for " + C.cGreen + "4 Seconds" + C.cWhite + "." ); + + _trapTrigger = TrapTrigger.CAKE_NEAR; } @Override - public void onCakeInteract(Player player, Location cake) + public void onTrapTrigger(Player player, Location cake) { player.getWorld().playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 2, 1); UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, player.getLocation().add(0, 1.5, 0), 0.25F, 0.25F, 0.25F, 0.5F, 30, ViewDist.NORMAL); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/trap/CakeTNTTrap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/trap/CakeTNTTrap.java index 2bbbd87ca..2640d1441 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/trap/CakeTNTTrap.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/trap/CakeTNTTrap.java @@ -26,7 +26,7 @@ public class CakeTNTTrap extends CakeTrapItem } @Override - public void onCakeInteract(Player player, Location cake) + public void onTrapTrigger(Player player, Location cake) { player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 2, 0.6F); UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, player.getLocation().add(0, 1.5, 0), 0, 0, 0, 1, 1, ViewDist.NORMAL); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/trap/CakeTrapItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/trap/CakeTrapItem.java index 206daa890..bc7656e57 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/trap/CakeTrapItem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/trap/CakeTrapItem.java @@ -16,6 +16,7 @@ public abstract class CakeTrapItem extends CakeShopItem { private final String _name; + TrapTrigger _trapTrigger; CakeTrapItem(ItemStack itemStack, int cost, String name, String... description) { @@ -25,12 +26,24 @@ public abstract class CakeTrapItem extends CakeShopItem .build(), cost); _name = name; + _trapTrigger = TrapTrigger.CAKE_INTERACT; } - public abstract void onCakeInteract(Player player, Location cake); + public abstract void onTrapTrigger(Player player, Location cake); public String getName() { return _name; } + + public TrapTrigger getTrapTrigger() + { + return _trapTrigger; + } + + public enum TrapTrigger + { + CAKE_NEAR, + CAKE_INTERACT, + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/team/CakeTeamModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/team/CakeTeamModule.java index def0d9fe1..f48377cb0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/team/CakeTeamModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/team/CakeTeamModule.java @@ -56,6 +56,7 @@ import nautilus.game.arcade.game.games.cakewars.event.CakeWarsEatCakeEvent; import nautilus.game.arcade.game.games.cakewars.shop.CakeItem; import nautilus.game.arcade.game.games.cakewars.shop.CakeShopModule; import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeTrapItem; +import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeTrapItem.TrapTrigger; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.world.WorldData; @@ -65,6 +66,7 @@ public class CakeTeamModule extends CakeModule private static final int HOLOGRAM_VIEW_SQUARED = 16; private static final long CAKE_ROT_TIME = TimeUnit.MINUTES.toMillis(20); private static final long CAKE_WARNING_TIME = TimeUnit.MINUTES.toMillis(5); + private static final long TRAP_COOLDOWN = TimeUnit.SECONDS.toMillis(10); private static final ItemStack[] STARTING_ITEMS = { new ItemBuilder(Material.WOOD_SWORD) @@ -247,35 +249,19 @@ public class CakeTeamModule extends CakeModule module.getOwnedItems(team).removeIf(item -> { - if (!(item instanceof CakeTrapItem) || !Recharge.Instance.use(player, "Trap", 10000, false, false)) + if (!(item instanceof CakeTrapItem)) { return false; } - Player damager = null; - - for (Player teamMember : team.GetPlayers(true)) - { - Set items = module.getOwnedItems(teamMember); - Iterator iterator = items.iterator(); - - while (iterator.hasNext()) - { - if (iterator.next().equals(item)) - { - damager = teamMember; - iterator.remove(); - } - } - } - CakeTrapItem trapItem = (CakeTrapItem) item; - _game.getArcadeManager().GetDamage().NewDamageEvent(player, damager, null, DamageCause.CUSTOM, 2, false, true, false, "Trap", trapItem.getName()); - trapItem.onCakeInteract(player, cakeTeam.getCake()); - UtilTextMiddle.display(team.GetColor() + "TRAP SET OFF", "One of your traps as been set off!", 5, 20, 5, team.GetPlayers(true).toArray(new Player[0])); - UtilTextMiddle.display("", C.cRedB + "TRAPPED", 5, 20, 5, player); + if (trapItem.getTrapTrigger() != TrapTrigger.CAKE_INTERACT || !Recharge.Instance.use(player, "Trap", TRAP_COOLDOWN, false, false)) + { + return false; + } + triggerTrap(player, team, cakeTeam, trapItem); return true; }); @@ -317,6 +303,71 @@ public class CakeTeamModule extends CakeModule }); } + @EventHandler + public void updateIslandTraps(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + CakeShopModule module = _game.getCakeShopModule(); + + _teams.forEach((team, cakeTeam) -> + { + module.getOwnedItems(team).removeIf(item -> + { + if (!(item instanceof CakeTrapItem)) + { + return false; + } + + CakeTrapItem trapItem = (CakeTrapItem) item; + + if (trapItem.getTrapTrigger() != TrapTrigger.CAKE_NEAR) + { + return false; + } + + for (Player player : UtilPlayer.getNearby(cakeTeam.getCake(), 3)) + { + if (!team.HasPlayer(player) && Recharge.Instance.use(player, "Trap", TRAP_COOLDOWN, false, false)) + { + triggerTrap(player, team, cakeTeam, trapItem); + return true; + } + } + + return false; + }); + }); + } + + private void triggerTrap(Player player, GameTeam team, CakeTeam cakeTeam, CakeTrapItem trapItem) + { + Player damager = null; + + for (Player teamMember : team.GetPlayers(true)) + { + Set items = _game.getCakeShopModule().getOwnedItems(teamMember); + Iterator iterator = items.iterator(); + + while (iterator.hasNext()) + { + if (iterator.next().equals(trapItem)) + { + damager = teamMember; + iterator.remove(); + } + } + } + + _game.getArcadeManager().GetDamage().NewDamageEvent(player, damager, null, DamageCause.CUSTOM, 2, false, true, false, "Trap", trapItem.getName()); + trapItem.onTrapTrigger(player, cakeTeam.getCake()); + UtilTextMiddle.display(team.GetColor() + "TRAP SET OFF", "One of your traps as been set off!", 5, 20, 5, team.GetPlayers(true).toArray(new Player[0])); + UtilTextMiddle.display("", C.cRedB + "TRAPPED", 5, 20, 5, player); + } + @EventHandler public void playerDeathOut(PlayerDeathOutEvent event) { @@ -531,6 +582,11 @@ public class CakeTeamModule extends CakeModule return UtilTime.MakeStr(time); } + public boolean hasCakeRot() + { + return UtilTime.elapsed(_game.GetStateTime(), CAKE_ROT_TIME); + } + public CakeTeam getCakeTeam(GameTeam team) { return _teams.get(team); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/ui/CakeResourcePage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/ui/CakeResourcePage.java index b467a06c6..5ffbc6ee4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/ui/CakeResourcePage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/ui/CakeResourcePage.java @@ -4,7 +4,6 @@ import java.util.List; import java.util.Set; import org.bukkit.ChatColor; -import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -82,7 +81,7 @@ public class CakeResourcePage extends ShopPageBase