This commit is contained in:
Sam 2018-07-18 12:09:31 +01:00 committed by Alexander Meech
parent f8b5a13240
commit 4fb6608c3f
21 changed files with 1101 additions and 462 deletions

View File

@ -21,6 +21,7 @@ import nautilus.game.arcade.game.games.build.Build;
import nautilus.game.arcade.game.games.buildmavericks.BuildMavericks; import nautilus.game.arcade.game.games.buildmavericks.BuildMavericks;
import nautilus.game.arcade.game.games.cakewars.CakeWars; import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.modes.CakeWarsDuos; import nautilus.game.arcade.game.games.cakewars.modes.CakeWarsDuos;
import nautilus.game.arcade.game.games.cakewars.modes.OPCakeWars;
import nautilus.game.arcade.game.games.castleassault.CastleAssault; import nautilus.game.arcade.game.games.castleassault.CastleAssault;
import nautilus.game.arcade.game.games.castleassault.CastleAssaultTDM; import nautilus.game.arcade.game.games.castleassault.CastleAssaultTDM;
import nautilus.game.arcade.game.games.castlesiegenew.CastleSiegeNew; import nautilus.game.arcade.game.games.castlesiegenew.CastleSiegeNew;
@ -203,7 +204,10 @@ public enum GameType implements Voteable
Pair.create(MinecraftVersion.Version1_9, "http://198.20.72.74/ResStrikeGames19.zip") Pair.create(MinecraftVersion.Version1_9, "http://198.20.72.74/ResStrikeGames19.zip")
}, true), }, true),
CakeWars4(CakeWars.class, GameDisplay.CakeWars4), CakeWars4(CakeWars.class, new GameMode[]
{
new GameMode(OPCakeWars.class, "Sugar Rush")
},GameDisplay.CakeWars4),
CakeWarsDuos(CakeWarsDuos.class, GameDisplay.CakeWarsDuos), CakeWarsDuos(CakeWarsDuos.class, GameDisplay.CakeWarsDuos),
SquidShooters(SquidShooters.class, GameDisplay.SquidShooter), SquidShooters(SquidShooters.class, GameDisplay.SquidShooter),

View File

@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -39,23 +40,35 @@ import mineplex.core.leaderboard.StaticLeaderboard;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.DeathMessageType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.PlayerKitGiveEvent;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.modules.AbsorptionFix;
import nautilus.game.arcade.game.games.cakewars.capturepoint.CakePointModule; import nautilus.game.arcade.game.games.cakewars.capturepoint.CakePointModule;
import nautilus.game.arcade.game.games.cakewars.general.CakeBatModule; import nautilus.game.arcade.game.games.cakewars.general.CakeBatModule;
import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule; import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule;
import nautilus.game.arcade.game.games.cakewars.general.CakeSpawnerModule; import nautilus.game.arcade.game.games.cakewars.general.CakeSpawnerModule;
import nautilus.game.arcade.game.games.cakewars.island.CakeIslandModule; import nautilus.game.arcade.game.games.cakewars.island.CakeIslandModule;
import nautilus.game.arcade.game.games.cakewars.item.CakeItemModule; import nautilus.game.arcade.game.games.cakewars.item.CakeItemModule;
import nautilus.game.arcade.game.games.cakewars.item.CakeSpecialItem;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeDeployPlatform;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeSheep;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeWall;
import nautilus.game.arcade.game.games.cakewars.kits.KitCakeArcher; import nautilus.game.arcade.game.games.cakewars.kits.KitCakeArcher;
import nautilus.game.arcade.game.games.cakewars.kits.KitCakeBuilder; import nautilus.game.arcade.game.games.cakewars.kits.KitCakeBuilder;
import nautilus.game.arcade.game.games.cakewars.kits.KitCakeFrosting; import nautilus.game.arcade.game.games.cakewars.kits.KitCakeFrosting;
import nautilus.game.arcade.game.games.cakewars.kits.KitCakeWarrior; import nautilus.game.arcade.game.games.cakewars.kits.KitCakeWarrior;
import nautilus.game.arcade.game.games.cakewars.shop.CakeItem;
import nautilus.game.arcade.game.games.cakewars.shop.CakeNetherItem;
import nautilus.game.arcade.game.games.cakewars.shop.CakeResource;
import nautilus.game.arcade.game.games.cakewars.shop.CakeShopItem;
import nautilus.game.arcade.game.games.cakewars.shop.CakeShopItemType;
import nautilus.game.arcade.game.games.cakewars.shop.CakeShopModule; import nautilus.game.arcade.game.games.cakewars.shop.CakeShopModule;
import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeBearTrap;
import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeTNTTrap;
import nautilus.game.arcade.game.games.cakewars.team.CakeTeam; import nautilus.game.arcade.game.games.cakewars.team.CakeTeam;
import nautilus.game.arcade.game.games.cakewars.team.CakeTeamModule; import nautilus.game.arcade.game.games.cakewars.team.CakeTeamModule;
import nautilus.game.arcade.game.games.cakewars.trackers.EatAllCakesTracker; import nautilus.game.arcade.game.games.cakewars.trackers.EatAllCakesTracker;
@ -68,6 +81,9 @@ import nautilus.game.arcade.game.games.cakewars.trackers.Survive10Tracker;
import nautilus.game.arcade.game.games.cakewars.trackers.WinWithOneBiteTracker; import nautilus.game.arcade.game.games.cakewars.trackers.WinWithOneBiteTracker;
import nautilus.game.arcade.game.games.cakewars.trackers.WinWithinTimeTracker; import nautilus.game.arcade.game.games.cakewars.trackers.WinWithinTimeTracker;
import nautilus.game.arcade.game.games.cakewars.trackers.WinWithoutKillingTracker; import nautilus.game.arcade.game.games.cakewars.trackers.WinWithoutKillingTracker;
import nautilus.game.arcade.game.games.cakewars.ui.CakeResourcePage;
import nautilus.game.arcade.game.games.cakewars.ui.CakeResourceStarPage;
import nautilus.game.arcade.game.modules.AbsorptionFix;
import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.CustomScoreboardModule;
import nautilus.game.arcade.game.modules.EnderPearlModule; import nautilus.game.arcade.game.modules.EnderPearlModule;
import nautilus.game.arcade.game.modules.capturepoint.CapturePointModule; import nautilus.game.arcade.game.modules.capturepoint.CapturePointModule;
@ -193,7 +209,7 @@ public class CakeWars extends TeamGame
manager.GetCreature().SetDisableCustomDrops(true); manager.GetCreature().SetDisableCustomDrops(true);
new AbsorptionFix() new AbsorptionFix()
.register(this); .register(this);
new CompassModule() new CompassModule()
.register(this); .register(this);
@ -387,48 +403,7 @@ public class CakeWars extends TeamGame
_averages.put(team, UtilAlg.getAverageLocation(team.GetSpawns())); _averages.put(team, UtilAlg.getAverageLocation(team.GetSpawns()));
} }
_chestLootModule.registerChestType(CakeIslandModule.CHEST_TYPE, new ArrayList<>(), generateChests();
new ChestLootPool()
.addItem(new ItemBuilder(Material.DIAMOND_SWORD)
.addEnchantment(Enchantment.KNOCKBACK, 1)
.setUnbreakable(true)
.build())
.addItem(new ItemBuilder(Material.BOW)
.addEnchantment(Enchantment.ARROW_KNOCKBACK, 1)
.setUnbreakable(true)
.build())
.addItem(new ItemBuilder(Material.BOW)
.addEnchantment(Enchantment.ARROW_DAMAGE, 2)
.addEnchantment(Enchantment.ARROW_INFINITE, 1)
.setDurability((short) (Material.BOW.getMaxDurability() - 9))
.build())
.addItem(new ItemBuilder(Material.BOW)
.addEnchantment(Enchantment.ARROW_DAMAGE, 4)
.setDurability((short) (Material.BOW.getMaxDurability() - 9))
.build())
.addItem(new ItemBuilder(Material.GOLD_PICKAXE)
.setTitle(C.cGoldB + "The Golden Pickaxe")
.setUnbreakable(true)
.build())
.addItem(new ItemBuilder(Material.DIAMOND_CHESTPLATE)
.setUnbreakable(true)
.build())
.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()),
new ChestLootPool()
.addItem(new ItemStack(Material.EMERALD), 4, 8),
new ChestLootPool()
.addItem(new ItemStack(Material.CLAY_BRICK), 8, 16)
).destroyAfterOpened(30);
_chestLootModule.register(this); _chestLootModule.register(this);
// Backwards compatibility with old cake wars maps // Backwards compatibility with old cake wars maps
@ -550,15 +525,32 @@ public class CakeWars extends TeamGame
} }
} }
@EventHandler @EventHandler(priority = EventPriority.MONITOR)
public void updateDamageScoreboard(UpdateEvent event) public void scoreboardDamage(CustomDamageEvent event)
{ {
if (event.getType() != UpdateType.SEC) if (event.IsCancelled() || event.GetDamageePlayer() == null || !IsLive())
{ {
return; return;
} }
_customScoreboardModule.refresh(); Manager.runSyncLater(() -> _customScoreboardModule.refreshAsSubject(event.GetDamageePlayer()), 0);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void scoreboardRegainHealth(EntityRegainHealthEvent event)
{
if (!(event.getEntity() instanceof Player) || !IsLive())
{
return;
}
Manager.runSyncLater(() -> _customScoreboardModule.refreshAsSubject((Player) event.getEntity()), 0);
}
@EventHandler
public void kitGiveItems(PlayerKitGiveEvent event)
{
_customScoreboardModule.refreshAsSubject(event.getPlayer());
} }
@EventHandler @EventHandler
@ -631,6 +623,178 @@ public class CakeWars extends TeamGame
return DeathMessageType.Detailed; return DeathMessageType.Detailed;
} }
public int getGeneratorRate(CakeResource resource, int current)
{
return current;
}
public List<CakeItem> generateItems(CakeResource resource)
{
switch (resource)
{
case BRICK:
return Arrays.asList
(
// Iron Set
new CakeShopItem(CakeShopItemType.HELMET, new ItemStack(Material.IRON_HELMET), 5),
new CakeShopItem(CakeShopItemType.CHESTPLATE, new ItemStack(Material.IRON_CHESTPLATE), 8),
new CakeShopItem(CakeShopItemType.LEGGINGS, new ItemStack(Material.IRON_LEGGINGS), 6),
new CakeShopItem(CakeShopItemType.BOOTS, new ItemStack(Material.IRON_BOOTS), 5),
// Sword
new CakeShopItem(CakeShopItemType.SWORD, new ItemStack(Material.IRON_SWORD), 5),
// Bow
new CakeShopItem(CakeShopItemType.BOW, new ItemStack(Material.BOW), 12),
// Pickaxe
new CakeShopItem(CakeShopItemType.PICKAXE, new ItemStack(Material.IRON_PICKAXE), 8),
// Axe
new CakeShopItem(CakeShopItemType.AXE, new ItemStack(Material.IRON_AXE), 3),
// Arrow
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.ARROW, 3), 12),
// Blocks
// Wool
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.WOOL, 16), 3),
// Coloured Clay
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.STAINED_CLAY, 8), 8),
// Wood
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.WOOD, 8), 8),
// End Stone
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.ENDER_STONE, 8), 12),
// Deploy Platform
new CakeShopItem(CakeShopItemType.OTHER, CakeDeployPlatform.ITEM_STACK, 5),
// Emerald
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.EMERALD), 20)
);
case EMERALD:
return Arrays.asList
(
// Diamond Set
new CakeShopItem(CakeShopItemType.HELMET, new ItemStack(Material.DIAMOND_HELMET), 10),
new CakeShopItem(CakeShopItemType.CHESTPLATE, new ItemStack(Material.DIAMOND_CHESTPLATE), 24),
new CakeShopItem(CakeShopItemType.LEGGINGS, new ItemStack(Material.DIAMOND_LEGGINGS), 16),
new CakeShopItem(CakeShopItemType.BOOTS, new ItemStack(Material.DIAMOND_BOOTS), 10),
// Sword
new CakeShopItem(CakeShopItemType.SWORD, new ItemStack(Material.DIAMOND_SWORD), 5),
// Pickaxe
new CakeShopItem(CakeShopItemType.PICKAXE, new ItemStack(Material.DIAMOND_PICKAXE), 10),
// Axe
new CakeShopItem(CakeShopItemType.AXE, new ItemStack(Material.DIAMOND_AXE), 4),
// Obsidian
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.OBSIDIAN), 8),
// Shears
new CakeShopItem(CakeShopItemType.SHEARS, new ItemStack(Material.SHEARS), 5),
// Golden Apple
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.GOLDEN_APPLE), 8),
// Ender pearl
new CakeShopItem(CakeShopItemType.OTHER, CakeShopModule.ENDER_PEARL, 7),
// Rune of Holding
new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.RUNE_OF_HOLDING, 20),
// Insta-Wall
new CakeShopItem(CakeShopItemType.OTHER, CakeWall.ITEM_STACK, 2),
new CakeShopItem(CakeShopItemType.OTHER, CakeSheep.ITEM_STACK, 8),
// Traps
new CakeTNTTrap(8),
new CakeBearTrap(8)
);
case STAR:
return Arrays.asList(CakeNetherItem.values());
default:
return Collections.emptyList();
}
}
public List<CakeSpecialItem> generateSpecialItems()
{
return Arrays.asList
(
new CakeDeployPlatform(this),
new CakeWall(this),
new CakeSheep(this)
);
}
public void generateChests()
{
_chestLootModule.registerChestType(CakeIslandModule.CHEST_TYPE, new ArrayList<>(),
new ChestLootPool()
.addItem(new ItemBuilder(Material.DIAMOND_SWORD)
.addEnchantment(Enchantment.KNOCKBACK, 1)
.setUnbreakable(true)
.build())
.addItem(new ItemBuilder(Material.BOW)
.addEnchantment(Enchantment.ARROW_KNOCKBACK, 1)
.setUnbreakable(true)
.build())
.addItem(new ItemBuilder(Material.BOW)
.addEnchantment(Enchantment.ARROW_DAMAGE, 2)
.addEnchantment(Enchantment.ARROW_INFINITE, 1)
.setDurability((short) (Material.BOW.getMaxDurability() - 9))
.build())
.addItem(new ItemBuilder(Material.BOW)
.addEnchantment(Enchantment.ARROW_DAMAGE, 4)
.setDurability((short) (Material.BOW.getMaxDurability() - 9))
.build())
.addItem(new ItemBuilder(Material.GOLD_PICKAXE)
.setTitle(C.cGoldB + "The Golden Pickaxe")
.setUnbreakable(true)
.build())
.addItem(new ItemBuilder(Material.DIAMOND_CHESTPLATE)
.setUnbreakable(true)
.build())
.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()),
new ChestLootPool()
.addItem(new ItemStack(Material.EMERALD), 4, 8),
new ChestLootPool()
.addItem(new ItemStack(Material.CLAY_BRICK), 8, 16)
).destroyAfterOpened(30);
}
public CakeResourcePage getShopPage(CakeResource resource, Player player)
{
switch (resource)
{
case BRICK:
case EMERALD:
return new CakeResourcePage(getArcadeManager(), getCakeShopModule().getShop(), player, resource, getCakeShopModule().getItems().get(resource));
case STAR:
return new CakeResourceStarPage(getArcadeManager(), getCakeShopModule().getShop(), player, Arrays.asList(CakeNetherItem.values()));
default:
return null;
}
}
public Location getAverageLocation(GameTeam team) public Location getAverageLocation(GameTeam team)
{ {
return _averages.get(team); return _averages.get(team);

View File

@ -244,7 +244,7 @@ public class CakePlayerModule extends CakeModule
} }
} }
@EventHandler @EventHandler(priority = EventPriority.HIGHEST)
public void kitGiveItems(PlayerKitGiveEvent event) public void kitGiveItems(PlayerKitGiveEvent event)
{ {
if (!_game.IsLive()) if (!_game.IsLive())
@ -257,27 +257,24 @@ public class CakePlayerModule extends CakeModule
if (storedInventory != null) if (storedInventory != null)
{ {
_game.getArcadeManager().runSyncLater(() -> PlayerInventory inventory = player.getInventory();
ItemStack[] contents = storedInventory[0];
for (int i = 0; i < contents.length; i++)
{ {
PlayerInventory inventory = player.getInventory(); ItemStack itemStack = contents[i];
ItemStack[] contents = storedInventory[0];
for (int i = 0; i < contents.length; i++) if (itemStack != null && itemStack.getAmount() < 1)
{ {
ItemStack itemStack = contents[i]; contents[i] = null;
if (itemStack != null && itemStack.getAmount() < 1)
{
contents[i] = null;
}
} }
}
inventory.setContents(storedInventory[0]); inventory.setContents(storedInventory[0]);
inventory.setArmorContents(storedInventory[1]); inventory.setArmorContents(storedInventory[1]);
player.updateInventory(); player.updateInventory();
UtilInv.remove(player, RUNE_OF_HOLDING.getType(), RUNE_OF_HOLDING.getData().getData(), 1); UtilInv.remove(player, RUNE_OF_HOLDING.getType(), RUNE_OF_HOLDING.getData().getData(), 1);
}, 20);
} }
} }

View File

@ -23,9 +23,8 @@ import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.CakeModule; import nautilus.game.arcade.game.games.cakewars.CakeModule;
import nautilus.game.arcade.game.games.cakewars.CakeWars; import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.capturepoint.CakePointModule;
import nautilus.game.arcade.game.games.cakewars.shop.CakeResource; import nautilus.game.arcade.game.games.cakewars.shop.CakeResource;
import nautilus.game.arcade.game.games.cakewars.shop.CakeTeamItem; import nautilus.game.arcade.game.games.cakewars.shop.CakeNetherItem;
import nautilus.game.arcade.game.games.cakewars.team.CakeTeam; import nautilus.game.arcade.game.games.cakewars.team.CakeTeam;
public class CakeSpawnerModule extends CakeModule public class CakeSpawnerModule extends CakeModule
@ -70,7 +69,7 @@ public class CakeSpawnerModule extends CakeModule
continue; continue;
} }
_game.getCakeTeamModule().getCakeTeams().forEach((team, cakeTeam) -> resource.handleDistribution(this, team)); _game.getCakeTeamModule().getCakeTeams().forEach((team, cakeTeam) -> distributeItem(resource, getItemsToDrop(resource, team, cakeTeam), team));
} }
} }
@ -82,58 +81,69 @@ public class CakeSpawnerModule extends CakeModule
return; return;
} }
CakePointModule pointModule = _game.getCakePointModule();
CakeResource[] resources = CakeResource.values(); CakeResource[] resources = CakeResource.values();
List<String> text = new ArrayList<>();
_game.getCakeTeamModule().getCakeTeams().forEach((team, cakeTeam) -> _game.getCakeTeamModule().getCakeTeams().forEach((team, cakeTeam) ->
{ {
String[] text = new String[resources.length]; text.clear();
int resourceGenerator = cakeTeam.getUpgrades().get(CakeTeamItem.RESOURCE);
for (int i = 0; i < resources.length; i++) for (CakeResource resource : resources)
{ {
CakeResource resource = resources[i]; int rate = getItemsToDrop(resource, team, cakeTeam);
int rate = resourceGenerator;
switch (resource) if (rate < 0)
{ {
case BRICK: continue;
rate++;
break;
case EMERALD:
int emeraldPoints = pointModule.ownedEmeraldPoints(team);
if (emeraldPoints == 0)
{
rate = 0;
}
else
{
rate += emeraldPoints;
}
break;
case STAR:
int netherStarPoints = pointModule.ownedNetherStarPoints(team);
if (netherStarPoints == 0)
{
rate = 0;
}
else
{
rate += netherStarPoints;
}
break;
} }
text[i] = resource.getChatColor() + resource.getName() + C.cWhite + " : " + resource.getChatColor() + "x" + rate; text.add(resource.getChatColor() + resource.getName() + C.cWhite + " : " + resource.getChatColor() + "x" + rate);
} }
cakeTeam.getGeneratorHologram().setText(text); cakeTeam.getGeneratorHologram().setText(text.toArray(new String[0]));
}); });
} }
public void distributeItem(CakeResource resource, int amount, GameTeam team) private int getItemsToDrop(CakeResource resource, GameTeam team, CakeTeam cakeTeam)
{
int rate = cakeTeam.getUpgrades().get(CakeNetherItem.RESOURCE);
switch (resource)
{
case BRICK:
rate++;
break;
case EMERALD:
int emeraldPoints = _game.getCakePointModule().ownedEmeraldPoints(team);
if (emeraldPoints == 0)
{
rate = 0;
}
else
{
rate += emeraldPoints;
}
break;
case STAR:
int netherStarPoints = _game.getCakePointModule().ownedNetherStarPoints(team);
if (netherStarPoints == 0)
{
rate = 0;
}
else
{
rate += netherStarPoints;
}
break;
}
rate = getGame().getGeneratorRate(resource, rate);
return rate;
}
private void distributeItem(CakeResource resource, int amount, GameTeam team)
{ {
if (amount <= 0) if (amount <= 0)
{ {
@ -142,7 +152,7 @@ public class CakeSpawnerModule extends CakeModule
CakeTeam cakeTeam = _game.getCakeTeamModule().getCakeTeam(team); CakeTeam cakeTeam = _game.getCakeTeamModule().getCakeTeam(team);
amount += cakeTeam.getUpgrades().get(CakeTeamItem.RESOURCE); amount += cakeTeam.getUpgrades().get(CakeNetherItem.RESOURCE);
ItemStack itemStack = resource.getItemStack().clone(); ItemStack itemStack = resource.getItemStack().clone();
itemStack.setAmount(amount); itemStack.setAmount(amount);

View File

@ -1,7 +1,6 @@
package nautilus.game.arcade.game.games.cakewars.item; package nautilus.game.arcade.game.games.cakewars.item;
import java.util.HashSet; import java.util.List;
import java.util.Set;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -18,36 +17,24 @@ import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.CakeModule; import nautilus.game.arcade.game.games.cakewars.CakeModule;
import nautilus.game.arcade.game.games.cakewars.CakeWars; import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeDeployPlatform;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeSheep;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeWall;
import nautilus.game.arcade.game.games.cakewars.team.CakeTeam; import nautilus.game.arcade.game.games.cakewars.team.CakeTeam;
public class CakeItemModule extends CakeModule public class CakeItemModule extends CakeModule
{ {
private final Set<CakeSpecialItem> _items; private final List<CakeSpecialItem> _items;
public CakeItemModule(CakeWars game) public CakeItemModule(CakeWars game)
{ {
super(game); super(game);
_items = new HashSet<>(); _items = game.generateSpecialItems();
}
@Override
protected void setup()
{
_items.add(new CakeDeployPlatform(_game));
_items.add(new CakeWall(_game));
_items.add(new CakeSheep(_game));
} }
@Override @Override
public void cleanup() public void cleanup()
{ {
_items.forEach(CakeSpecialItem::cleanup); _items.forEach(CakeSpecialItem::cleanup);
_items.clear();
} }
@EventHandler @EventHandler
@ -78,7 +65,7 @@ public class CakeItemModule extends CakeModule
return; return;
} }
if (itemStack == null || event.getClickedBlock() == null) if (itemStack == null)
{ {
return; return;
} }

View File

@ -28,9 +28,9 @@ public class CakeDeployPlatform extends CakeSpecialItem
.build(); .build();
private static final int PLATFORM_DELTA = 1; private static final int PLATFORM_DELTA = 1;
public CakeDeployPlatform(CakeWars cakeWars) public CakeDeployPlatform(CakeWars game)
{ {
super(cakeWars, ITEM_STACK); super(game, ITEM_STACK);
} }
@Override @Override
@ -39,6 +39,11 @@ public class CakeDeployPlatform extends CakeSpecialItem
Player player = event.getPlayer(); Player player = event.getPlayer();
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
if (block == null)
{
return false;
}
BlockFace face = UtilBlock.getFace(player.getLocation().getYaw()).getOppositeFace(); BlockFace face = UtilBlock.getFace(player.getLocation().getYaw()).getOppositeFace();
GameTeam team = cakeTeam.getGameTeam(); GameTeam team = cakeTeam.getGameTeam();
byte teamData = team.GetColorData(); byte teamData = team.GetColorData();

View File

@ -0,0 +1,110 @@
package nautilus.game.arcade.game.games.cakewars.item.items;
import java.util.concurrent.TimeUnit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.item.CakeSpecialItem;
import nautilus.game.arcade.game.games.cakewars.team.CakeTeam;
public class CakeIceBridge extends CakeSpecialItem
{
public static final ItemStack ITEM_STACK = new ItemBuilder(Material.ICE)
.setTitle(C.cYellowB + "Ice Bridge")
.addLore("", "Creates a huge bridge of ice", "Warning! Ice Bridges have a", C.cRed + "20 second" + C.cGray + " cooldown between uses ", "and only last for " + C.cRed + "7 Seconds" + C.cGray + "!", "Uses: " + C.cRed + "1")
.setUnbreakable(true)
.build();
private static final int MAX_DISTANCE = 30;
private static final long BRIDGE_TIME = TimeUnit.SECONDS.toMillis(7);
public CakeIceBridge(CakeWars game)
{
super(game, ITEM_STACK, "Ice Bridge", TimeUnit.SECONDS.toMillis(20));
}
@Override
protected boolean onClick(PlayerInteractEvent event, CakeTeam cakeTeam)
{
event.setCancelled(true);
Player player = event.getPlayer();
Block block = event.getClickedBlock();
if (block == null)
{
block = player.getLocation().getBlock();
}
else
{
block = block.getRelative(BlockFace.UP);
}
if (isInvalidBlock(block))
{
return false;
}
Location location = player.getLocation();
location.setPitch(0);
BlockFace direction = UtilBlock.getFace(player.getLocation().getYaw()).getOppositeFace();
BlockRestore restore = _game.getArcadeManager().GetBlockRestore();
Block finalBlock = block;
_game.getArcadeManager().runSyncTimer(new BukkitRunnable()
{
Block target = finalBlock;
int i = 0;
@Override
public void run()
{
if (!_game.IsLive())
{
cancel();
return;
}
target = target.getRelative(direction);
boolean blockChanged = false;
for (BlockFace face : UtilBlock.horizontals)
{
Block nearby = target.getRelative(face);
if (!isInvalidBlock(nearby))
{
restore.add(nearby, Material.ICE.getId(), (byte) 0,BRIDGE_TIME + UtilMath.rRange(0, 500));
blockChanged = true;
}
}
if (!blockChanged || i++ > MAX_DISTANCE)
{
cancel();
}
else
{
target.getWorld().playSound(target.getLocation(), Sound.DIG_SNOW, 1, 1);
}
}
}, 0, 5);
return true;
}
}

View File

@ -0,0 +1,107 @@
package nautilus.game.arcade.game.games.cakewars.item.items;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.item.CakeSpecialItem;
import nautilus.game.arcade.game.games.cakewars.team.CakeTeam;
public class CakeSafeTeleport extends CakeSpecialItem implements Listener
{
public static final ItemStack ITEM_STACK = new ItemBuilder(Material.EYE_OF_ENDER)
.setTitle(C.cYellowB + "Safe Teleport")
.addLore("", "Teleports you have to a safe location", "if you fall into the void.", "Warning! Safe Teleport has a", C.cRed + "20 second" + C.cGray + " cooldown between uses.", "Uses: " + C.cRed + "1")
.setUnbreakable(true)
.build();
private final Map<Player, Location> _safeLocations;
public CakeSafeTeleport(CakeWars game)
{
super(game, ITEM_STACK, "Safe Teleport", TimeUnit.SECONDS.toMillis(20));
_safeLocations = new HashMap<>();
}
@Override
protected void setup()
{
UtilServer.RegisterEvents(this);
}
@Override
protected void cleanup()
{
_safeLocations.clear();
UtilServer.Unregister(this);
}
@Override
protected boolean onClick(PlayerInteractEvent event, CakeTeam cakeTeam)
{
event.setCancelled(true);
Player player = event.getPlayer();
Location location = _safeLocations.get(player);
if (location == null)
{
return false;
}
player.teleport(location.add(0, 1.5, 0));
player.setFallDistance(0);
player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 0);
UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, player.getEyeLocation(), 0.5F, 0.5F, 0.5F, 0.5F, 10, ViewDist.NORMAL);
return true;
}
@EventHandler
public void updateSafeLocation(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
for (Player player : _game.GetPlayers(true))
{
if (!player.isOnline() || UtilPlayer.isSpectator(player) || !UtilEnt.isGrounded(player))
{
continue;
}
_safeLocations.put(player, player.getLocation());
}
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
_safeLocations.remove(event.getPlayer());
}
}

View File

@ -59,9 +59,9 @@ public class CakeSheep extends CakeSpecialItem implements Listener
private static final int EXPLOSION_RADIUS = 7; private static final int EXPLOSION_RADIUS = 7;
private static final int NO_PLACE_RADIUS_SQUARED = 225; private static final int NO_PLACE_RADIUS_SQUARED = 225;
public CakeSheep(CakeWars cakeWars) public CakeSheep(CakeWars game)
{ {
super(cakeWars, ITEM_STACK, "Polly The Sheep", TimeUnit.SECONDS.toMillis(20)); super(game, ITEM_STACK, "Polly The Sheep", TimeUnit.SECONDS.toMillis(20));
} }
@Override @Override

View File

@ -37,9 +37,9 @@ public class CakeWall extends CakeSpecialItem
private static final int PLATFORM_DELTA = 1; private static final int PLATFORM_DELTA = 1;
private static final int WALL_WARMUP_TICKS = 40; private static final int WALL_WARMUP_TICKS = 40;
public CakeWall(CakeWars cakeWars) public CakeWall(CakeWars game)
{ {
super(cakeWars, ITEM_STACK, "Wool Wall", 500); super(game, ITEM_STACK, "Wool Wall", 500);
} }
@Override @Override

View File

@ -65,7 +65,7 @@ public class PerkSlowSnowball extends Perk
Player damager = event.GetDamagerPlayer(true); Player damager = event.GetDamagerPlayer(true);
Projectile projectile = event.GetProjectile(); Projectile projectile = event.GetProjectile();
if (damagee == null || damager == null || !hasPerk(damager) || projectile == null || !(projectile instanceof Snowball)) if (damagee == null || damager == null || !hasPerk(damager) || !(projectile instanceof Snowball))
{ {
return; return;
} }

View File

@ -0,0 +1,294 @@
package nautilus.game.arcade.game.games.cakewars.modes;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule;
import nautilus.game.arcade.game.games.cakewars.item.CakeSpecialItem;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeDeployPlatform;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeIceBridge;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeSafeTeleport;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeSheep;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeWall;
import nautilus.game.arcade.game.games.cakewars.shop.CakeItem;
import nautilus.game.arcade.game.games.cakewars.shop.CakeResource;
import nautilus.game.arcade.game.games.cakewars.shop.CakeShopItem;
import nautilus.game.arcade.game.games.cakewars.shop.CakeShopItemType;
import nautilus.game.arcade.game.games.cakewars.shop.CakeShopModule;
import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeBearTrap;
import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeTNTTrap;
import nautilus.game.arcade.game.games.cakewars.ui.CakeResourcePage;
public class OPCakeWars extends CakeWars
{
private final PotionEffect SUGAR_BUFF = new PotionEffect(PotionEffectType.SPEED, 40, 0, false, false);
public OPCakeWars(ArcadeManager manager)
{
super(manager);
AllowParticles = false;
}
@EventHandler
public void live(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
{
return;
}
getCakeTeamModule().getCakeTeams().values().forEach(cakeTeam ->
{
for (Block block : UtilBlock.getSurrounding(cakeTeam.getCake().getBlock(), false))
{
if (block.getType() == Material.AIR)
{
getCakePlayerModule().getPlacedBlocks().add(block);
block.setType(Material.OBSIDIAN);
}
}
cakeTeam.getUpgrades().entrySet().forEach(entry -> entry.setValue(entry.getKey().getLevels().length));
});
for (GameTeam team : GetTeamList())
{
for (Player player : team.GetPlayers(false))
{
UtilTextMiddle.display(team.GetColor() + C.Bold + "Sugar Rush", team.GetColor() + "Hyper" + C.Reset + " items available!", 0, 50, 40, player);
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1);
}
}
}
@EventHandler
public void updateSugarRush(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
GetTeamList().forEach(team ->
{
if (getCakePointModule().ownedNetherStarPoints(team) > 0)
{
for (Player player : team.GetPlayers(true))
{
if (UtilPlayer.isSpectator(player))
{
continue;
}
player.addPotionEffect(SUGAR_BUFF, true);
UtilParticle.PlayParticleToAll(ParticleType.FLAME, player.getLocation().add(0, 1, 0), null, 0.1F, 3, ViewDist.LONG);
}
}
});
}
@EventHandler(priority = EventPriority.HIGH)
public void damage(CustomDamageEvent event)
{
if (event.GetCause() != DamageCause.ENTITY_ATTACK || !hasSugarBuff(event.GetDamagerPlayer(false)))
{
return;
}
event.AddMod(GetMode(), event.GetDamage() * 0.25);
event.AddKnockback(GetMode(), 1.25);
}
@Override
public int getGeneratorRate(CakeResource resource, int current)
{
if (resource == CakeResource.STAR)
{
return -1;
}
// 1.5 seems like a low number to increase by, but all upgrades, including Resource Generator are maxed out by default.
return (int) (current * 1.5);
}
@Override
public List<CakeItem> generateItems(CakeResource resource)
{
switch (resource)
{
case BRICK:
return Arrays.asList
(
// Diamond Set
new CakeShopItem(CakeShopItemType.HELMET, new ItemStack(Material.DIAMOND_HELMET), 5),
new CakeShopItem(CakeShopItemType.CHESTPLATE, new ItemStack(Material.DIAMOND_CHESTPLATE), 8),
new CakeShopItem(CakeShopItemType.LEGGINGS, new ItemStack(Material.DIAMOND_LEGGINGS), 6),
new CakeShopItem(CakeShopItemType.BOOTS, new ItemStack(Material.DIAMOND_BOOTS), 5),
// Sword
new CakeShopItem(CakeShopItemType.SWORD, new ItemStack(Material.DIAMOND_SWORD), 5),
// Bow
new CakeShopItem(CakeShopItemType.BOW, new ItemStack(Material.BOW), 12),
// Pickaxe
new CakeShopItem(CakeShopItemType.PICKAXE, new ItemStack(Material.DIAMOND_PICKAXE), 8),
// Axe
new CakeShopItem(CakeShopItemType.AXE, new ItemStack(Material.DIAMOND_AXE), 3),
// Arrow
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.ARROW, 3), 12),
// Blocks
// Wool
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.WOOL, 16), 3),
// Coloured Clay
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.STAINED_CLAY, 8), 8),
// Wood
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.WOOD, 8), 8),
// End Stone
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.ENDER_STONE, 8), 12),
// Deploy Platform
new CakeShopItem(CakeShopItemType.OTHER, CakeDeployPlatform.ITEM_STACK, 5),
// Walls
new CakeShopItem(CakeShopItemType.OTHER, CakeWall.ITEM_STACK, 5),
// Emerald
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.EMERALD), 20)
);
case EMERALD:
return Arrays.asList
(
// Obsidian
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.OBSIDIAN), 8),
// Shears
new CakeShopItem(CakeShopItemType.SHEARS, new ItemStack(Material.SHEARS), 5),
// Golden Apple
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.GOLDEN_APPLE), 8),
// Ender pearl
new CakeShopItem(CakeShopItemType.OTHER, CakeShopModule.ENDER_PEARL, 7),
// Rune of Holding
new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.RUNE_OF_HOLDING, 20),
// Special
new CakeShopItem(CakeShopItemType.OTHER, CakeSheep.ITEM_STACK, 8),
new CakeShopItem(CakeShopItemType.OTHER, CakeIceBridge.ITEM_STACK, 10),
new CakeShopItem(CakeShopItemType.OTHER, CakeSafeTeleport.ITEM_STACK, 10),
// Traps
new CakeTNTTrap(8),
new CakeBearTrap(8)
);
case STAR:
return super.generateItems(resource);
default:
return null;
}
}
@Override
public List<CakeSpecialItem> generateSpecialItems()
{
return Arrays.asList
(
new CakeDeployPlatform(this),
new CakeWall(this),
new CakeSheep(this),
new CakeIceBridge(this),
new CakeSafeTeleport(this)
);
}
@Override
public CakeResourcePage getShopPage(CakeResource resource, Player player)
{
if (resource == CakeResource.STAR)
{
return new CakeResourcePage(getArcadeManager(), getCakeShopModule().getShop(), player, 36, CakeResource.STAR, Collections.emptyList())
{
@Override
protected void buildPage()
{
super.buildPage();
addButtonNoAction(13, new ItemBuilder(Material.SUGAR)
.setTitle(C.cRedB + "Sugar Buff")
.addLore(
"",
"Capture the center beacon to earn",
"your team the following buffs:",
"",
" - " + C.cGreen + "Speed I" + C.cGray + " Potion Buff",
" - +" + C.cGreen + "25%" + C.cGray + " Damage",
" - +" + C.cGreen + "25%" + C.cGray + " Knockback"
)
.build());
}
@Override
protected void buildMulti()
{
}
};
}
return super.getShopPage(resource, player);
}
@Override
public boolean isAllowingGameStats()
{
return false;
}
@Override
public String GetMode()
{
return "Sugar Rush";
}
private boolean hasSugarBuff(Player player)
{
return player != null && player.hasPotionEffect(PotionEffectType.SPEED);
}
}

View File

@ -0,0 +1,189 @@
package nautilus.game.arcade.game.games.cakewars.shop;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.Pair;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilText;
import mineplex.core.itemstack.ItemBuilder;
public enum CakeNetherItem implements CakeTeamItem
{
PROTECTION(
"Protection",
new ItemStack(Material.DIAMOND_CHESTPLATE),
"Gives your entire team %s.",
Pair.create("Protection I", 4),
Pair.create("Protection II", 10)
)
{
@Override
public void apply(Player player, int level, Location cake)
{
for (ItemStack itemStack : player.getInventory().getArmorContents())
{
if (UtilItem.isArmor(itemStack) && itemStack.getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL) < level)
{
itemStack.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, level);
}
}
}
},
HASTE(
"Haste",
new ItemStack(Material.GOLD_PICKAXE),
"Gives your entire team %s.",
Pair.create("Haste I", 4),
Pair.create("Haste II", 10)
)
{
@Override
public void apply(Player player, int level, Location cake)
{
player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, level - 1, true, false), true);
}
},
SHARPNESS(
"Sharpness",
new ItemStack(Material.DIAMOND_SWORD),
"Gives your entire team %s.",
Pair.create("Sharpness I", 8),
Pair.create("Sharpness II", 12)
)
{
@Override
public void apply(Player player, int level, Location cake)
{
for (ItemStack itemStack : player.getInventory().getContents())
{
if (UtilItem.isSword(itemStack) && itemStack.getEnchantmentLevel(Enchantment.DAMAGE_ALL) < level)
{
itemStack.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, level);
}
}
}
},
POWER(
"Power",
new ItemStack(Material.BOW),
"Gives your entire team %s.",
Pair.create("Power I", 8),
Pair.create("Power II", 12)
)
{
@Override
public void apply(Player player, int level, Location cake)
{
for (ItemStack itemStack : player.getInventory().getContents())
{
if (itemStack != null && itemStack.getType() == Material.BOW && itemStack.getEnchantmentLevel(Enchantment.ARROW_DAMAGE) < level)
{
itemStack.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, level);
}
}
}
},
RESOURCE(
"Resource Generator",
new ItemStack(Material.NETHER_STAR),
"When an item generates in your generator it will also generate %s extra.",
Pair.create("1", 10),
Pair.create("2", 20)
),
REGENERATION(
"Healing Station",
new ItemStack(Material.GOLDEN_APPLE),
"Receive %s when within %s of your cake.",
Pair.create("Regeneration I;" + CakeShopModule.getHealingStationRadius(1) + " blocks", 8),
Pair.create("Regeneration I;" + CakeShopModule.getHealingStationRadius(2) + " blocks", 12)
)
{
@Override
public void apply(Player player, int level, Location cake)
{
int maxDist = CakeShopModule.getHealingStationRadius(level);
if (UtilMath.offset2dSquared(player.getLocation(), cake) < maxDist * maxDist)
{
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60, 0, true, false), true);
}
}
},
;
private final String _name;
private final ItemStack _itemStack;
private final String _description;
private final Pair<String, Integer>[] _levels;
@SafeVarargs
CakeNetherItem(String name, ItemStack itemStack, String description, Pair<String, Integer>... levels)
{
_name = name;
_itemStack = new ItemBuilder(itemStack)
.setTitle(name)
.setGlow(true)
.build();
_description = description;
_levels = levels;
}
@Override
public void apply(Player player, int level, Location cake)
{
}
@Override
public CakeShopItemType getItemType()
{
return CakeShopItemType.TEAM_UPGRADE;
}
@Override
public String getName()
{
return _name;
}
@Override
public ItemStack getItemStack()
{
return _itemStack;
}
@Override
public String[] getDescription(int level)
{
String description = C.mBody + _description;
String[] vars = _levels[level].getLeft().split(";");
for (String var : vars)
{
description = description.replaceFirst("%s", C.cGreen + var + C.mBody);
}
return UtilText.splitLineToArray(description, LineFormat.LORE);
}
@Override
public Pair<String, Integer>[] getLevels()
{
return _levels;
}
@Override
public int getCost()
{
return 0;
}
}

View File

@ -6,42 +6,12 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.general.CakeSpawnerModule;
public enum CakeResource public enum CakeResource
{ {
BRICK("Brick", ChatColor.RED, new ItemStack(Material.CLAY_BRICK), UpdateType.TWOSEC, 64) BRICK("Brick", ChatColor.RED, new ItemStack(Material.CLAY_BRICK), UpdateType.TWOSEC, 64),
{ EMERALD("Emerald", ChatColor.GREEN, new ItemStack(Material.EMERALD), UpdateType.SEC_05, 24),
STAR("Nether Star", ChatColor.GOLD, new ItemStack(Material.NETHER_STAR), UpdateType.SEC_08, 8);
@Override
public void handleDistribution(CakeSpawnerModule module, GameTeam team)
{
module.distributeItem(this, 1, team);
}
},
EMERALD("Emerald", ChatColor.GREEN, new ItemStack(Material.EMERALD), UpdateType.SEC_05, 24)
{
@Override
public void handleDistribution(CakeSpawnerModule module, GameTeam team)
{
module.distributeItem(this, module.getGame().getCakePointModule().ownedEmeraldPoints(team), team);
}
},
STAR("Nether Star", ChatColor.GOLD, new ItemStack(Material.NETHER_STAR), UpdateType.SEC_08, 8)
{
@Override
public void handleDistribution(CakeSpawnerModule module, GameTeam team)
{
module.distributeItem(this, module.getGame().getCakePointModule().ownedNetherStarPoints(team), team);
}
};
private final String _name; private final String _name;
private final ChatColor _chatColor; private final ChatColor _chatColor;
@ -58,8 +28,6 @@ public enum CakeResource
_maxSpawned = maxSpawned; _maxSpawned = maxSpawned;
} }
public abstract void handleDistribution(CakeSpawnerModule module, GameTeam team);
public String getName() public String getName()
{ {
return _name; return _name;

View File

@ -1,6 +1,5 @@
package nautilus.game.arcade.game.games.cakewars.shop; package nautilus.game.arcade.game.games.cakewars.shop;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -47,15 +46,8 @@ import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.CakeModule; import nautilus.game.arcade.game.games.cakewars.CakeModule;
import nautilus.game.arcade.game.games.cakewars.CakeWars; import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeDeployPlatform;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeSheep;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeWall;
import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeBearTrap;
import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeTNTTrap;
import nautilus.game.arcade.game.games.cakewars.ui.CakeResourcePage; import nautilus.game.arcade.game.games.cakewars.ui.CakeResourcePage;
import nautilus.game.arcade.game.games.cakewars.ui.CakeResourceShop; import nautilus.game.arcade.game.games.cakewars.ui.CakeResourceShop;
import nautilus.game.arcade.game.games.cakewars.ui.CakeResourceStarPage;
public class CakeShopModule extends CakeModule public class CakeShopModule extends CakeModule
{ {
@ -88,92 +80,9 @@ public class CakeShopModule extends CakeModule
_ownedItems = new HashMap<>(); _ownedItems = new HashMap<>();
_ownedTeamItems = new HashMap<>(8); _ownedTeamItems = new HashMap<>(8);
_items.put(CakeResource.BRICK, Arrays.asList( _items.put(CakeResource.BRICK, game.generateItems(CakeResource.BRICK));
_items.put(CakeResource.EMERALD, game.generateItems(CakeResource.EMERALD));
// Iron Set _items.put(CakeResource.STAR, game.generateItems(CakeResource.STAR));
new CakeShopItem(CakeShopItemType.HELMET, new ItemStack(Material.IRON_HELMET), 5),
new CakeShopItem(CakeShopItemType.CHESTPLATE, new ItemStack(Material.IRON_CHESTPLATE), 8),
new CakeShopItem(CakeShopItemType.LEGGINGS, new ItemStack(Material.IRON_LEGGINGS), 6),
new CakeShopItem(CakeShopItemType.BOOTS, new ItemStack(Material.IRON_BOOTS), 5),
// Sword
new CakeShopItem(CakeShopItemType.SWORD, new ItemStack(Material.IRON_SWORD), 5),
// Bow
new CakeShopItem(CakeShopItemType.BOW, new ItemStack(Material.BOW), 12),
// Pickaxe
new CakeShopItem(CakeShopItemType.PICKAXE, new ItemStack(Material.IRON_PICKAXE), 8),
// Axe
new CakeShopItem(CakeShopItemType.AXE, new ItemStack(Material.IRON_AXE), 3),
// Arrow
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.ARROW, 3), 12),
// Blocks
// Wool
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.WOOL, 16), 3),
// Coloured Clay
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.STAINED_CLAY, 8), 8),
// Wood
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.WOOD, 8), 8),
// End Stone
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.ENDER_STONE, 8), 12),
// Deploy Platform
new CakeShopItem(CakeShopItemType.OTHER, CakeDeployPlatform.ITEM_STACK, 5),
// Emerald
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.EMERALD), 20)
));
_items.put(CakeResource.EMERALD, Arrays.asList(
// Diamond Set
new CakeShopItem(CakeShopItemType.HELMET, new ItemStack(Material.DIAMOND_HELMET), 10),
new CakeShopItem(CakeShopItemType.CHESTPLATE, new ItemStack(Material.DIAMOND_CHESTPLATE), 24),
new CakeShopItem(CakeShopItemType.LEGGINGS, new ItemStack(Material.DIAMOND_LEGGINGS), 16),
new CakeShopItem(CakeShopItemType.BOOTS, new ItemStack(Material.DIAMOND_BOOTS), 10),
// Sword
new CakeShopItem(CakeShopItemType.SWORD, new ItemStack(Material.DIAMOND_SWORD), 5),
// Pickaxe
new CakeShopItem(CakeShopItemType.PICKAXE, new ItemStack(Material.DIAMOND_PICKAXE), 10),
// Axe
new CakeShopItem(CakeShopItemType.AXE, new ItemStack(Material.DIAMOND_AXE), 10),
// Obsidian
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.OBSIDIAN), 8),
// Shears
new CakeShopItem(CakeShopItemType.SHEARS, new ItemStack(Material.SHEARS), 5),
// Golden Apple
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.GOLDEN_APPLE), 8),
// Ender pearl
new CakeShopItem(CakeShopItemType.OTHER, ENDER_PEARL, 7),
// Rune of Holding
new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.RUNE_OF_HOLDING, 20),
// Insta-Wall
new CakeShopItem(CakeShopItemType.OTHER, CakeWall.ITEM_STACK, 2),
new CakeShopItem(CakeShopItemType.OTHER, CakeSheep.ITEM_STACK, 8),
// Traps
new CakeTNTTrap(8),
new CakeBearTrap(8)
));
} }
@Override @Override
@ -263,23 +172,12 @@ public class CakeShopModule extends CakeModule
continue; continue;
} }
CakeResource resource = entry.getValue();
if (UtilPlayer.isSpectator(player) || (action == Action.LEFT_CLICK_BLOCK && UtilItem.isSword(player.getItemInHand())) || !Recharge.Instance.use(player, "Interact Shop", 500, false, false)) if (UtilPlayer.isSpectator(player) || (action == Action.LEFT_CLICK_BLOCK && UtilItem.isSword(player.getItemInHand())) || !Recharge.Instance.use(player, "Interact Shop", 500, false, false))
{ {
return; return;
} }
CakeResourcePage page; CakeResourcePage page = _game.getShopPage(entry.getValue(), player);
if (resource == CakeResource.STAR)
{
page = new CakeResourceStarPage(_game.getArcadeManager(), _shop, player);
}
else
{
page = new CakeResourcePage(_game.getArcadeManager(), _shop, player, resource, _items.get(resource));
}
page.refresh(); page.refresh();
_shop.openPageForPlayer(player, page); _shop.openPageForPlayer(player, page);
@ -318,7 +216,7 @@ public class CakeShopModule extends CakeModule
cakeTeam.getUpgrades().forEach((item, level) -> cakeTeam.getUpgrades().forEach((item, level) ->
{ {
if (_game.getCakeTeamModule().hasCakeRot() && item == CakeTeamItem.REGENERATION) if (_game.getCakeTeamModule().hasCakeRot() && item == CakeNetherItem.REGENERATION)
{ {
return; return;
} }
@ -341,7 +239,7 @@ public class CakeShopModule extends CakeModule
_game.getCakeTeamModule().getCakeTeams().forEach((team, cakeTeam) -> _game.getCakeTeamModule().getCakeTeams().forEach((team, cakeTeam) ->
{ {
int level = cakeTeam.getUpgrades().getOrDefault(CakeTeamItem.REGENERATION, 0); int level = cakeTeam.getUpgrades().getOrDefault(CakeNetherItem.REGENERATION, 0);
if (level == 0 || !cakeTeam.canRespawn()) if (level == 0 || !cakeTeam.canRespawn())
{ {
@ -411,4 +309,14 @@ public class CakeShopModule extends CakeModule
return false; return false;
} }
public CakeResourceShop getShop()
{
return _shop;
}
public Map<CakeResource, List<CakeItem>> getItems()
{
return _items;
}
} }

View File

@ -1,185 +1,19 @@
package nautilus.game.arcade.game.games.cakewars.shop; package nautilus.game.arcade.game.games.cakewars.shop;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.Pair; import mineplex.core.common.Pair;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilText;
import mineplex.core.itemstack.ItemBuilder;
public enum CakeTeamItem implements CakeItem public interface CakeTeamItem extends CakeItem
{ {
PROTECTION( void apply(Player player, int level, Location cake);
"Protection",
new ItemStack(Material.DIAMOND_CHESTPLATE),
"Gives your entire team %s.",
Pair.create("Protection I", 4),
Pair.create("Protection II", 10)
)
{
@Override
public void apply(Player player, int level, Location cake)
{
for (ItemStack itemStack : player.getInventory().getArmorContents())
{
if (UtilItem.isArmor(itemStack) && itemStack.getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL) < level)
{
itemStack.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, level);
}
}
}
},
HASTE(
"Haste",
new ItemStack(Material.GOLD_PICKAXE),
"Gives your entire team %s.",
Pair.create("Haste I", 4),
Pair.create("Haste II", 10)
)
{
@Override
public void apply(Player player, int level, Location cake)
{
player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, level - 1, true, false), true);
}
},
SHARPNESS(
"Sharpness",
new ItemStack(Material.DIAMOND_SWORD),
"Gives your entire team %s.",
Pair.create("Sharpness I", 8),
Pair.create("Sharpness II", 12)
)
{
@Override
public void apply(Player player, int level, Location cake)
{
for (ItemStack itemStack : player.getInventory().getContents())
{
if (UtilItem.isSword(itemStack) && itemStack.getEnchantmentLevel(Enchantment.DAMAGE_ALL) < level)
{
itemStack.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, level);
}
}
}
},
POWER(
"Power",
new ItemStack(Material.BOW),
"Gives your entire team %s.",
Pair.create("Power I", 8),
Pair.create("Power II", 12)
)
{
@Override
public void apply(Player player, int level, Location cake)
{
for (ItemStack itemStack : player.getInventory().getContents())
{
if (itemStack != null && itemStack.getType() == Material.BOW && itemStack.getEnchantmentLevel(Enchantment.ARROW_DAMAGE) < level)
{
itemStack.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, level);
}
}
}
},
RESOURCE(
"Resource Generator",
new ItemStack(Material.NETHER_STAR),
"When an item generates in your generator it will also generate %s extra.",
Pair.create("1", 10),
Pair.create("2", 20)
),
REGENERATION(
"Healing Station",
new ItemStack(Material.GOLDEN_APPLE),
"Receive %s when within %s of your cake.",
Pair.create("Regeneration I;" + CakeShopModule.getHealingStationRadius(1) + " blocks", 8),
Pair.create("Regeneration I;" + CakeShopModule.getHealingStationRadius(2) + " blocks", 12)
)
{
@Override
public void apply(Player player, int level, Location cake)
{
int maxDist = CakeShopModule.getHealingStationRadius(level);
if (UtilMath.offset2dSquared(player.getLocation(), cake) < maxDist * maxDist) String getName();
{
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60, 0, true, false), true);
}
}
},
;
private final String _name; String[] getDescription(int level);
private final ItemStack _itemStack;
private final String _description;
private final Pair<String, Integer>[] _levels;
@SafeVarargs Pair<String, Integer>[] getLevels();
CakeTeamItem(String name, ItemStack itemStack, String description, Pair<String, Integer>... levels)
{
_name = name;
_itemStack = new ItemBuilder(itemStack)
.setTitle(name)
.setGlow(true)
.build();
_description = description;
_levels = levels;
}
public void apply(Player player, int level, Location cake)
{
}
@Override
public CakeShopItemType getItemType()
{
return CakeShopItemType.TEAM_UPGRADE;
}
public String getName()
{
return _name;
}
@Override
public ItemStack getItemStack()
{
return _itemStack;
}
public String[] getDescription(int level)
{
String description = C.mBody + _description;
String[] vars = _levels[level].getLeft().split(";");
for (String var : vars)
{
description = description.replaceFirst("%s", C.cGreen + var + C.mBody);
}
return UtilText.splitLineToArray(description, LineFormat.LORE);
}
public Pair<String, Integer>[] getLevels()
{
return _levels;
}
@Override
public int getCost()
{
return 0;
}
} }

View File

@ -15,6 +15,9 @@ import mineplex.core.hologram.HologramManager;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.CakeWars; import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.shop.CakeItem;
import nautilus.game.arcade.game.games.cakewars.shop.CakeNetherItem;
import nautilus.game.arcade.game.games.cakewars.shop.CakeResource;
import nautilus.game.arcade.game.games.cakewars.shop.CakeTeamItem; import nautilus.game.arcade.game.games.cakewars.shop.CakeTeamItem;
public class CakeTeam public class CakeTeam
@ -55,11 +58,11 @@ public class CakeTeam
_cake = game.WorldData.GetDataLocs(team.GetName().toUpperCase()).get(0).getBlock().getLocation().add(0.5, 0.5, 0.5); _cake = game.WorldData.GetDataLocs(team.GetName().toUpperCase()).get(0).getBlock().getLocation().add(0.5, 0.5, 0.5);
_cake.getBlock().setType(Material.CAKE_BLOCK); _cake.getBlock().setType(Material.CAKE_BLOCK);
_upgrades = new HashMap<>(CakeTeamItem.values().length); _upgrades = new HashMap<>();
for (CakeTeamItem item : CakeTeamItem.values()) for (CakeItem item : game.generateItems(CakeResource.STAR))
{ {
_upgrades.put(item, 0); _upgrades.put((CakeTeamItem) item, 0);
} }
_tipHolograms = new ArrayList<>(3); _tipHolograms = new ArrayList<>(3);

View File

@ -40,15 +40,22 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
final CakeResource _resource; final CakeResource _resource;
final List<CakeItem> _items; final List<CakeItem> _items;
final GameTeam _team; final GameTeam _team;
int _multiplier;
public CakeResourcePage(ArcadeManager plugin, CakeResourceShop shop, Player player, CakeResource resource, List<CakeItem> items) public CakeResourcePage(ArcadeManager plugin, CakeResourceShop shop, Player player, CakeResource resource, List<CakeItem> items)
{ {
super(plugin, shop, plugin.GetClients(), plugin.GetDonation(), resource.getName() + " Shop", player, items.size() > 14 ? 36 : 27); this(plugin, shop, player, 45, resource, items);
}
public CakeResourcePage(ArcadeManager plugin, CakeResourceShop shop, Player player, int slots, CakeResource resource, List<CakeItem> items)
{
super(plugin, shop, plugin.GetClients(), plugin.GetDonation(), resource.getName() + " Shop", player, slots);
_game = (CakeWars) plugin.GetGame(); _game = (CakeWars) plugin.GetGame();
_resource = resource; _resource = resource;
_items = items; _items = items;
_team = plugin.GetGame().GetTeam(player); _team = plugin.GetGame().GetTeam(player);
_multiplier = 1;
} }
@Override @Override
@ -69,6 +76,29 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
slot += 2; slot += 2;
} }
} }
buildMulti();
}
protected void buildMulti()
{
buildMultiItem(39, Material.GOLD_NUGGET, 1);
buildMultiItem(40, Material.GOLD_INGOT, 3);
buildMultiItem(41, Material.GOLD_BLOCK, 5);
}
private void buildMultiItem(int slot, Material material, int multiplier)
{
addButton(slot, new ItemBuilder(material)
.setTitle(C.cGray + "x" + C.cYellow + multiplier + C.cGray + " Multiplier")
.addLore("", "Click to set the item multiplier", ".")
.setGlow(_multiplier == multiplier)
.build(), (player, clickType) ->
{
_multiplier = multiplier;
playAcceptSound(player);
refresh();
});
} }
void addCloseButton() void addCloseButton()
@ -90,7 +120,7 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
{ {
return CakeShopResult.ONLY_ONE; return CakeShopResult.ONLY_ONE;
} }
else if (!UtilInv.contains(_player, null, itemStack.getType(), itemStack.getData().getData(), item.getCost(), false, false, false)) else if (!UtilInv.contains(_player, null, itemStack.getType(), itemStack.getData().getData(), getCost(item), false, false, false))
{ {
return CakeShopResult.NOT_ENOUGH_RESOURCES; return CakeShopResult.NOT_ENOUGH_RESOURCES;
} }
@ -123,14 +153,22 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
ItemStack prepareItem(CakeItem item, CakeShopResult result) ItemStack prepareItem(CakeItem item, CakeShopResult result)
{ {
ItemBuilder builder = new ItemBuilder(item.getItemStack()); ItemStack itemStack = item.getItemStack();
ItemBuilder builder = new ItemBuilder(itemStack);
handleTeamColours(builder); handleTeamColours(builder);
builder.setTitle(getItemName(item.getItemStack())); builder.setTitle(getItemName(itemStack));
builder.addLore("");
if (itemStack.getAmount() > 1)
{
builder.setAmount(itemStack.getAmount() * _multiplier);
builder.addLore("Amount: " + _resource.getChatColor() + itemStack.getAmount());
}
builder.addLore( builder.addLore(
"", "Cost: " + _resource.getChatColor() + (item.getCost() * _multiplier) + " " + _resource.getName() + "s",
"Cost: " + _resource.getChatColor() + item.getCost() + " " + _resource.getName() + "s",
"", "",
result.getColour() + result.getFeedback() result.getColour() + result.getFeedback()
); );
@ -166,6 +204,11 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
return ItemStackFactory.Instance.GetName(itemStack, true); return ItemStackFactory.Instance.GetName(itemStack, true);
} }
private int getCost(CakeItem item)
{
return item.getItemStack().getItemMeta().spigot().isUnbreakable() ? item.getCost() : item.getCost() * _multiplier
}
protected enum CakeShopResult protected enum CakeShopResult
{ {
@ -227,15 +270,21 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
CakeShopItemType itemType = _item.getItemType(); CakeShopItemType itemType = _item.getItemType();
ItemStack resource = _resource.getItemStack(); ItemStack resource = _resource.getItemStack();
ItemBuilder give = new ItemBuilder(_item.getItemStack()); ItemStack itemStack = _item.getItemStack();
ItemBuilder give = new ItemBuilder(itemStack);
Material material = give.getType(); Material material = give.getType();
if (itemStack.getAmount() > 1)
{
give.setAmount(_item.getItemStack().getAmount() * _multiplier);
}
if (UtilItem.isWeapon(material) || UtilItem.isTool(material) || UtilItem.isArmor(material) || material == Material.BOW || material == Material.SHEARS) if (UtilItem.isWeapon(material) || UtilItem.isTool(material) || UtilItem.isArmor(material) || material == Material.BOW || material == Material.SHEARS)
{ {
give.setUnbreakable(true); give.setUnbreakable(true);
} }
UtilInv.remove(player, resource.getType(), resource.getData().getData(), _item.getCost()); UtilInv.remove(player, resource.getType(), resource.getData().getData(), _item.getCost() * _multiplier);
handleTeamColours(give); handleTeamColours(give);
ItemStack giveItem = give.build(); ItemStack giveItem = give.build();

View File

@ -1,6 +1,6 @@
package nautilus.game.arcade.game.games.cakewars.ui; package nautilus.game.arcade.game.games.cakewars.ui;
import java.util.Arrays; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -28,9 +28,9 @@ public class CakeResourceStarPage extends CakeResourcePage
private final CakeTeam _cakeTeam; private final CakeTeam _cakeTeam;
public CakeResourceStarPage(ArcadeManager plugin, CakeResourceShop shop, Player player) public CakeResourceStarPage(ArcadeManager plugin, CakeResourceShop shop, Player player, List<CakeItem> items)
{ {
super(plugin, shop, player, CakeResource.STAR, Arrays.asList(CakeTeamItem.values())); super(plugin, shop, player, 36, CakeResource.STAR, items);
_cakeTeam = _game.getCakeTeamModule().getCakeTeam(_game.GetTeam(player)); _cakeTeam = _game.getCakeTeamModule().getCakeTeam(_game.GetTeam(player));
} }
@ -56,6 +56,12 @@ public class CakeResourceStarPage extends CakeResourcePage
} }
} }
@Override
protected void buildMulti()
{
}
@Override @Override
CakeShopResult getResultPurchase(CakeItem item) CakeShopResult getResultPurchase(CakeItem item)
{ {

View File

@ -86,6 +86,7 @@ public class CustomScoreboardModule extends Module
} }
setupScoreboard(player); setupScoreboard(player);
refreshAsPerspective(player);
refreshAsSubject(player); refreshAsSubject(player);
} }

View File

@ -75,7 +75,7 @@ public class WinStreakModule extends Module
{ {
ArcadeManager manager = getGame().getArcadeManager(); ArcadeManager manager = getGame().getArcadeManager();
if (!manager.IsRewardStats() || !manager.hasBeenPlaying(player)) if (!isEnabled(player))
{ {
return; return;
} }
@ -107,9 +107,7 @@ public class WinStreakModule extends Module
private void removeStreak(Player player) private void removeStreak(Player player)
{ {
ArcadeManager manager = getGame().getArcadeManager(); if (!isEnabled(player))
if (!manager.IsRewardStats() || !manager.hasBeenPlaying(player))
{ {
return; return;
} }
@ -117,6 +115,11 @@ public class WinStreakModule extends Module
getGame().getArcadeManager().getWinStreakManager().removeWinStreak(player, getGame().GetType().getDisplay()); getGame().getArcadeManager().getWinStreakManager().removeWinStreak(player, getGame().GetType().getDisplay());
} }
private boolean isEnabled(Player player)
{
return getGame().getArcadeManager().IsRewardStats() && getGame().isAllowingGameStats() && getGame().getArcadeManager().hasBeenPlaying(player);
}
private String getStat(String stat) private String getStat(String stat)
{ {
return getGame().GetName() + "." + stat; return getGame().GetName() + "." + stat;