All the new shiny items and changes

This commit is contained in:
Sam 2018-01-19 23:25:58 +00:00 committed by Alexander Meech
parent 962be63970
commit 52ffd1cbf0
13 changed files with 208 additions and 72 deletions

View File

@ -64,8 +64,7 @@ public class WinStreakManager extends MiniDbClientPlugin<Map<Integer, Integer>>
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)

View File

@ -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)
);
}

View File

@ -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);

View File

@ -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)
{

View File

@ -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 =

View File

@ -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()));
}

View File

@ -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));

View File

@ -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);

View File

@ -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);

View File

@ -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,
}
}

View File

@ -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<CakeItem> items = module.getOwnedItems(teamMember);
Iterator<CakeItem> 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<CakeItem> items = _game.getCakeShopModule().getOwnedItems(teamMember);
Iterator<CakeItem> 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);

View File

@ -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<ArcadeManager, CakeResourceSh
CakeShopItemType itemType = item.getItemType();
ItemStack itemStack = _resource.getItemStack();
if (!itemType.isMultiBuy() && module.ownsItem(_player, item))
if (!itemType.isMultiBuy() && (module.ownsItem(_player, item) || containsLowerTier(_player, item.getItemStack())))
{
return CakeShopResult.ALREADY_OWNED;
}
@ -98,6 +97,29 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
return CakeShopResult.SUCCESSFUL;
}
private boolean containsLowerTier(Player player, ItemStack itemStack)
{
PlayerInventory inventory = player.getInventory();
switch (itemStack.getType())
{
case IRON_HELMET:
return inventory.getHelmet() != null && inventory.getHelmet().getType() == Material.DIAMOND_HELMET;
case IRON_CHESTPLATE:
return inventory.getChestplate() != null && inventory.getChestplate().getType() == Material.DIAMOND_CHESTPLATE;
case IRON_LEGGINGS:
return inventory.getLeggings() != null && inventory.getLeggings().getType() == Material.DIAMOND_LEGGINGS;
case IRON_BOOTS:
return inventory.getBoots() != null && inventory.getBoots().getType() == Material.DIAMOND_BOOTS;
case IRON_SWORD:
return inventory.contains(Material.DIAMOND_SWORD);
case IRON_PICKAXE:
return inventory.contains(Material.DIAMOND_PICKAXE);
}
return false;
}
ItemStack prepareItem(CakeItem item, CakeShopResult result)
{
ItemBuilder builder = new ItemBuilder(item.getItemStack());
@ -119,7 +141,7 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
{
Material material = builder.getType();
if (material == Material.WOOL || material == Material.STAINED_CLAY)
if (material == Material.WOOL || material == Material.STAINED_CLAY || material == Material.STAINED_GLASS)
{
builder.setData(_team.GetColorData());
}

View File

@ -8,6 +8,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.game.GameDisplay;
import mineplex.core.game.winstreaks.WinStreakManager;
import mineplex.core.stats.PlayerStats;
@ -15,7 +16,6 @@ import mineplex.core.stats.StatsManager;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerDeathOutEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.modules.Module;
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryModule;
@ -50,17 +50,14 @@ public class WinStreakModule extends Module
}
winners.forEach(this::incrementStreak);
}
@EventHandler(priority = EventPriority.MONITOR)
public void playerDeathOut(PlayerDeathOutEvent event)
{
if (event.isCancelled())
for (Player player : UtilServer.getPlayersCollection())
{
return;
if (player.isOnline() && !winners.contains(player))
{
removeStreak(player);
}
}
removeStreak(event.GetPlayer());
}
@EventHandler(priority = EventPriority.LOW)