Rewrite large portions of the Shop and general system
This commit is contained in:
parent
ef31ae126c
commit
42fc0c7829
@ -1377,97 +1377,97 @@ public enum Achievement
|
|||||||
AchievementCategory.MOBA),
|
AchievementCategory.MOBA),
|
||||||
|
|
||||||
CAKE_WARS_WIN("Cake Dinners", 15000,
|
CAKE_WARS_WIN("Cake Dinners", 15000,
|
||||||
new String[]{"Cake Wars.Wins"},
|
new String[]{"Cake Wars Rumble.Wins", "Cake Wars Duos.Wins"},
|
||||||
new String[]{"Win 100 games of Cake Wars"},
|
new String[]{"Win 100 games of Cake Wars"},
|
||||||
new int[]{100},
|
new int[]{100},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_KILLS("Cake Slayer", 15000,
|
CAKE_WARS_KILLS("Cake Slayer", 15000,
|
||||||
new String[]{"Cake Wars.Kills"},
|
new String[]{"Cake Wars Rumble.Kills", "Cake Wars Duos.Kills"},
|
||||||
new String[]{"+1 for each Kill"},
|
new String[]{"Kill 1000 players in Cake Wars"},
|
||||||
new int[]{10,50,100,250,500,750,1000},
|
new int[]{1000},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_BITES("Big Appetite", 0,
|
CAKE_WARS_BITES("Big Appetite", 15000,
|
||||||
new String[]{"Cake Wars.Bites"},
|
new String[]{"Cake Wars Rumble.Bites", "Cake Wars Duos.Bites"},
|
||||||
new String[]{"+1 for each Cake Bite"},
|
new String[]{"Take 500 bites of cake in Cake Wars"},
|
||||||
new int[]{5,25,50,125,250,375,500},
|
new int[]{500},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_EAT_WHOLE_CAKE("Greedy", 2000,
|
CAKE_WARS_EAT_WHOLE_CAKE("Greedy", 2000,
|
||||||
new String[]{"Cake Wars.EatWholeCake"},
|
new String[]{"Cake Wars Rumble.EatWholeCake", "Cake Wars Duos.EatWholeCake"},
|
||||||
new String[]{"Eat a whole cake"},
|
new String[]{"Eat a whole cake"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_SURVIVE_10("This game has cakes?", 4000,
|
CAKE_WARS_SURVIVE_10("This game has cakes?", 4000,
|
||||||
new String[]{"Cake Wars.Survive10"},
|
new String[]{"Cake Wars Rumble.Survive10", "Cake Wars Duos.Survive10"},
|
||||||
new String[]{"Survive 10 minutes without", "a cake"},
|
new String[]{"Survive 10 minutes without", "a cake"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_FIRST_BLOOD("Cold Baked Killer", 2000,
|
CAKE_WARS_FIRST_BLOOD("Cold Baked Killer", 2000,
|
||||||
new String[]{"Cake Wars.FirstBlood"},
|
new String[]{"Cake Wars Rumble.FirstBlood", "Cake Wars Duos.FirstBlood"},
|
||||||
new String[]{"Get 10 First Bloods"},
|
new String[]{"Get 10 First Bloods"},
|
||||||
new int[]{10},
|
new int[]{10},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_EAT_1("Starving", 2000,
|
CAKE_WARS_EAT_1("Starving", 2000,
|
||||||
new String[]{"Cake Wars.Eat1"},
|
new String[]{"Cake Wars Rumble.Eat1", "Cake Wars Duos.Eat1"},
|
||||||
new String[]{"Eat a cake within the first", "minute of the game"},
|
new String[]{"Eat a cake within the first", "minute of the game"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_NO_DEATHS("You call that a challenge", 4000,
|
CAKE_WARS_NO_DEATHS("You call that a challenge", 4000,
|
||||||
new String[]{"Cake Wars.NoDeaths"},
|
new String[]{"Cake Wars Rumble.NoDeaths", "Cake Wars Duos.NoDeaths"},
|
||||||
new String[]{"Win a game without dying"},
|
new String[]{"Win a game without dying"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_BUY_ALL("Team Player", 2000,
|
CAKE_WARS_BUY_ALL("Team Player", 2000,
|
||||||
new String[]{"Cake Wars.BuyAll"},
|
new String[]{"Cake Wars Rumble.BuyAll", "Cake Wars Duos.BuyAll"},
|
||||||
new String[]{"Purchase all Team Upgrades", "within one game"},
|
new String[]{"Purchase all Team Upgrades", "within one game"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_WIN_WITHOUT_KILL("Love not War", 4000,
|
CAKE_WARS_WIN_WITHOUT_KILL("Love not War", 4000,
|
||||||
new String[]{"Cake Wars.NoKills"},
|
new String[]{"Cake Wars Rumble.NoKills", "Cake Wars Duos.NoKills"},
|
||||||
new String[]{"Win a game without killing", "a player"},
|
new String[]{"Win a game without killing", "a player"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_WIN_WITH_1("Last Crumb", 2000,
|
CAKE_WARS_WIN_WITH_1("Last Crumb", 2000,
|
||||||
new String[]{"Cake Wars.WinWithOneBite"},
|
new String[]{"Cake Wars Rumble.WinWithOneBite", "Cake Wars Duos.WinWithOneBite"},
|
||||||
new String[]{"Win a game with only one", "bite of your cake left"},
|
new String[]{"Win a game with only one", "bite of your cake left"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_WIN_IN_10("Gotta go fast", 2000,
|
CAKE_WARS_WIN_IN_10("Gotta go fast", 2000,
|
||||||
new String[]{"Cake Wars.WinIn10"},
|
new String[]{"Cake Wars Rumble.WinIn10", "Cake Wars Duos.WinIn10"},
|
||||||
new String[]{"Win a game within 10", "minutes"},
|
new String[]{"Win a game within 10", "minutes"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_FINAL_BITE("Last Laugh", 2000,
|
CAKE_WARS_FINAL_BITE("Last Laugh", 2000,
|
||||||
new String[]{"Cake Wars.FinalBite"},
|
new String[]{"Cake Wars Rumble.FinalBite", "Cake Wars Duos.FinalBite"},
|
||||||
new String[]{"Get the final bite on every", "cake within a game"},
|
new String[]{"Get the final bite on every", "cake within a game"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_OWN_ALL_BEACONS("I <3 Capture Points", 4000,
|
CAKE_WARS_OWN_ALL_BEACONS("I <3 Capture Points", 4000,
|
||||||
new String[]{"Cake Wars.OwnAllBeacons"},
|
new String[]{"Cake Wars Rumble.OwnAllBeacons", "Cake Wars Duos.OwnAllBeacons"},
|
||||||
new String[]{"Own all beacons for your team", "in one game"},
|
new String[]{"Own all beacons for your team", "in one game"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_GET_GOOD("Get Good", 15000,
|
CAKE_WARS_GET_GOOD("Get Good", 15000,
|
||||||
new String[]{"Cake Wars.GetGood"},
|
new String[]{"Cake Wars Rumble.GetGood", "Cake Wars Duos.GetGood"},
|
||||||
new String[]{"Kill a player while falling", "from a great height.", "Then save yourself from dying"},
|
new String[]{"Kill a player while falling", "from a great height.", "Then save yourself from dying"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
|
||||||
CAKE_WARS_FLOOR_IS_LAVA("The Floor Is Lava", 15000,
|
CAKE_WARS_FLOOR_IS_LAVA("The Floor Is Lava", 15000,
|
||||||
new String[]{"Cake Wars.FloorIsLava"},
|
new String[]{"Cake Wars Rumble.FloorIsLava", "Cake Wars Duos.FloorIsLava"},
|
||||||
new String[]{"After the first 30 seconds of the game", "Only stand on player placed blocks", "", "Includes Deploy Platforms and", "near Shops"},
|
new String[]{"After the first 30 seconds of the game", "Only stand on player placed blocks", "", "Includes Deploy Platforms and", "near Shops"},
|
||||||
new int[]{1},
|
new int[]{1},
|
||||||
AchievementCategory.CAKE_WARS),
|
AchievementCategory.CAKE_WARS),
|
||||||
|
@ -247,18 +247,23 @@ public enum AchievementCategory
|
|||||||
CAKE_WARS("Cake Wars", null,
|
CAKE_WARS("Cake Wars", null,
|
||||||
new StatDisplay[]
|
new StatDisplay[]
|
||||||
{
|
{
|
||||||
StatDisplay.WINS,
|
new StatDisplay("Rumble", true),
|
||||||
StatDisplay.GAMES_PLAYED,
|
StatDisplay.fromGame("Wins", GameDisplay.CakeWars4, "Wins"),
|
||||||
|
StatDisplay.fromGame("Games Play", GameDisplay.CakeWars4, "Wins", "Losses"),
|
||||||
|
StatDisplay.fromGame("Kills", GameDisplay.CakeWars4, "Kills"),
|
||||||
|
StatDisplay.fromGame("Deaths", GameDisplay.CakeWars4, "Deaths"),
|
||||||
|
StatDisplay.fromGame("Cake Bites", GameDisplay.CakeWars4, "Bites"),
|
||||||
|
StatDisplay.fromGame("Whole Cakes", GameDisplay.CakeWars4, "EatWholeCake"),
|
||||||
null,
|
null,
|
||||||
StatDisplay.KILLS,
|
new StatDisplay("Duos", true),
|
||||||
StatDisplay.DEATHS,
|
StatDisplay.fromGame("Wins", GameDisplay.CakeWarsDuos, "Wins"),
|
||||||
null,
|
StatDisplay.fromGame("Games Play", GameDisplay.CakeWarsDuos, "Wins", "Losses"),
|
||||||
StatDisplay.fromGame("Cake Bites", GameDisplay.CakeWars, "Bites"),
|
StatDisplay.fromGame("Kills", GameDisplay.CakeWarsDuos, "Kills"),
|
||||||
StatDisplay.fromGame("Whole Cakes", GameDisplay.CakeWars, "EatWholeCake"),
|
StatDisplay.fromGame("Deaths", GameDisplay.CakeWarsDuos, "Deaths"),
|
||||||
null,
|
StatDisplay.fromGame("Cake Bites", GameDisplay.CakeWarsDuos, "Bites"),
|
||||||
StatDisplay.GEMS_EARNED,
|
StatDisplay.fromGame("Whole Cakes", GameDisplay.CakeWarsDuos, "EatWholeCake"),
|
||||||
},
|
},
|
||||||
Material.CAKE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CakeWars.getGameId());
|
Material.CAKE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CakeWars4.getGameId(), GameDisplay.CakeWarsDuos.getGameId());
|
||||||
|
|
||||||
private String _name;
|
private String _name;
|
||||||
private String[] _statsToPull;
|
private String[] _statsToPull;
|
||||||
|
@ -109,7 +109,8 @@ public enum GameDisplay
|
|||||||
|
|
||||||
BattleRoyale("Battle Royale", Material.DIAMOND_SWORD, (byte)0, GameCategory.EVENT, 72, false),
|
BattleRoyale("Battle Royale", Material.DIAMOND_SWORD, (byte)0, GameCategory.EVENT, 72, false),
|
||||||
|
|
||||||
CakeWars("Cake Wars", Material.CAKE, (byte)0, GameCategory.ARCADE, 73, true),
|
CakeWars4("Cake Wars Rumble", Material.CAKE, (byte)0, GameCategory.CLASSICS, 73, true),
|
||||||
|
CakeWarsDuos("Cake Wars Duos", Material.CAKE, (byte)0, GameCategory.CLASSICS, 74, false),
|
||||||
|
|
||||||
GemHunters("Gem Hunters", Material.EMERALD, (byte) 0, GameCategory.SURVIVAL, 71, false),
|
GemHunters("Gem Hunters", Material.EMERALD, (byte) 0, GameCategory.SURVIVAL, 71, false),
|
||||||
|
|
||||||
|
@ -23,7 +23,8 @@ import nautilus.game.arcade.game.games.build.Build;
|
|||||||
import nautilus.game.arcade.game.games.build.modes.DukesOfDecoration;
|
import nautilus.game.arcade.game.games.build.modes.DukesOfDecoration;
|
||||||
import nautilus.game.arcade.game.games.build.modes.TeamBuild;
|
import nautilus.game.arcade.game.games.build.modes.TeamBuild;
|
||||||
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.modes.CakeWars4;
|
||||||
|
import nautilus.game.arcade.game.games.cakewars.modes.CakeWarsDuos;
|
||||||
import nautilus.game.arcade.game.games.cards.Cards;
|
import nautilus.game.arcade.game.games.cards.Cards;
|
||||||
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;
|
||||||
@ -64,7 +65,6 @@ import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
|||||||
import nautilus.game.arcade.game.games.minestrike.Minestrike;
|
import nautilus.game.arcade.game.games.minestrike.Minestrike;
|
||||||
import nautilus.game.arcade.game.games.minestrike.modes.SuperPaintstrike;
|
import nautilus.game.arcade.game.games.minestrike.modes.SuperPaintstrike;
|
||||||
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
|
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
|
||||||
import nautilus.game.arcade.game.games.moba.Moba;
|
|
||||||
import nautilus.game.arcade.game.games.moba.MobaClassic;
|
import nautilus.game.arcade.game.games.moba.MobaClassic;
|
||||||
import nautilus.game.arcade.game.games.moba.training.MobaTraining;
|
import nautilus.game.arcade.game.games.moba.training.MobaTraining;
|
||||||
import nautilus.game.arcade.game.games.monsterleague.MonsterLeague;
|
import nautilus.game.arcade.game.games.monsterleague.MonsterLeague;
|
||||||
@ -245,7 +245,8 @@ public enum GameType
|
|||||||
Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResStrikeGames19.zip")
|
Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResStrikeGames19.zip")
|
||||||
}, true),
|
}, true),
|
||||||
|
|
||||||
CakeWars(CakeWars.class, GameDisplay.CakeWars),
|
CakeWars4(CakeWars4.class, GameDisplay.CakeWars4),
|
||||||
|
CakeWarsDuos(CakeWarsDuos.class, GameDisplay.CakeWarsDuos),
|
||||||
|
|
||||||
Event(EventGame.class, GameDisplay.Event, new GameType[]{
|
Event(EventGame.class, GameDisplay.Event, new GameType[]{
|
||||||
GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build,
|
GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.module;
|
package nautilus.game.arcade.game.games.cakewars;
|
||||||
|
|
||||||
import nautilus.game.arcade.game.games.cakewars.CakeWars;
|
|
||||||
import nautilus.game.arcade.game.modules.Module;
|
import nautilus.game.arcade.game.modules.Module;
|
||||||
|
|
||||||
public class CakeModule extends Module
|
public class CakeModule extends Module
|
||||||
@ -8,7 +7,7 @@ public class CakeModule extends Module
|
|||||||
|
|
||||||
protected final CakeWars _game;
|
protected final CakeWars _game;
|
||||||
|
|
||||||
CakeModule(CakeWars game)
|
public CakeModule(CakeWars game)
|
||||||
{
|
{
|
||||||
_game = game;
|
_game = game;
|
||||||
}
|
}
|
@ -19,23 +19,22 @@ import mineplex.core.common.util.UtilTime;
|
|||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
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 nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
import nautilus.game.arcade.GameType;
|
import nautilus.game.arcade.GameType;
|
||||||
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.games.AbsorptionFix;
|
import nautilus.game.arcade.game.games.AbsorptionFix;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeTeam;
|
|
||||||
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.KitCakeWarrior;
|
import nautilus.game.arcade.game.games.cakewars.kits.KitCakeWarrior;
|
||||||
import nautilus.game.arcade.game.games.cakewars.module.CakeIslandModule;
|
import nautilus.game.arcade.game.games.cakewars.island.CakeIslandModule;
|
||||||
import nautilus.game.arcade.game.games.cakewars.module.CakePlayerModule;
|
import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule;
|
||||||
import nautilus.game.arcade.game.games.cakewars.module.CakePointModule;
|
import nautilus.game.arcade.game.games.cakewars.capturepoint.CakePointModule;
|
||||||
import nautilus.game.arcade.game.games.cakewars.module.CakeShopModule;
|
import nautilus.game.arcade.game.games.cakewars.shop.CakeShopModule;
|
||||||
import nautilus.game.arcade.game.games.cakewars.module.CakeSpawnerModule;
|
import nautilus.game.arcade.game.games.cakewars.general.CakeSpawnerModule;
|
||||||
import nautilus.game.arcade.game.games.cakewars.module.CakeTeamModule;
|
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.trackers.EatAllCakesTracker;
|
import nautilus.game.arcade.game.games.cakewars.trackers.EatAllCakesTracker;
|
||||||
import nautilus.game.arcade.game.games.cakewars.trackers.EatFirstMinuteTracker;
|
import nautilus.game.arcade.game.games.cakewars.trackers.EatFirstMinuteTracker;
|
||||||
import nautilus.game.arcade.game.games.cakewars.trackers.FirstBloodStatTracker;
|
import nautilus.game.arcade.game.games.cakewars.trackers.FirstBloodStatTracker;
|
||||||
@ -94,9 +93,9 @@ public class CakeWars extends TeamGame
|
|||||||
private boolean _colourTick;
|
private boolean _colourTick;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public CakeWars(ArcadeManager manager)
|
public CakeWars(ArcadeManager manager, GameType gameType)
|
||||||
{
|
{
|
||||||
super(manager, GameType.CakeWars, new Kit[]
|
super(manager, gameType, new Kit[]
|
||||||
{
|
{
|
||||||
new KitCakeWarrior(manager),
|
new KitCakeWarrior(manager),
|
||||||
new KitCakeArcher(manager),
|
new KitCakeArcher(manager),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.module;
|
package nautilus.game.arcade.game.games.cakewars.capturepoint;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -9,6 +9,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
|
|
||||||
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.CakeWars;
|
import nautilus.game.arcade.game.games.cakewars.CakeWars;
|
||||||
import nautilus.game.arcade.game.modules.capturepoint.CapturePoint;
|
import nautilus.game.arcade.game.modules.capturepoint.CapturePoint;
|
||||||
import nautilus.game.arcade.game.modules.capturepoint.CapturePointCaptureEvent;
|
import nautilus.game.arcade.game.modules.capturepoint.CapturePointCaptureEvent;
|
||||||
@ -53,26 +54,23 @@ public class CakePointModule extends CakeModule
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean ownsNetherPoint(GameTeam team)
|
public int ownedNetherStarPoints(GameTeam team)
|
||||||
{
|
{
|
||||||
for (CapturePoint point : _game.getCapturePointModule().getCapturePoints())
|
return ownedPoints(team, ChatColor.GOLD);
|
||||||
{
|
|
||||||
if (point.getColour().equals(ChatColor.GOLD) && point.getOwner() != null && point.getOwner().equals(team))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ownedEmeraldPoints(GameTeam team)
|
public int ownedEmeraldPoints(GameTeam team)
|
||||||
|
{
|
||||||
|
return ownedPoints(team, ChatColor.GREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int ownedPoints(GameTeam team, ChatColor colour)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (CapturePoint point : _game.getCapturePointModule().getCapturePoints())
|
for (CapturePoint point : _game.getCapturePointModule().getCapturePoints())
|
||||||
{
|
{
|
||||||
if (point.getColour().equals(ChatColor.GREEN) && point.getOwner() != null && point.getOwner().equals(team))
|
if (point.getColour().equals(colour) && point.getOwner() != null && point.getOwner().equals(team))
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
@ -1,9 +0,0 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.data;
|
|
||||||
|
|
||||||
public enum CakeTeamItemType
|
|
||||||
{
|
|
||||||
|
|
||||||
PASSIVE_UPGRADE,
|
|
||||||
TRAP
|
|
||||||
|
|
||||||
}
|
|
@ -5,7 +5,7 @@ import org.bukkit.event.HandlerList;
|
|||||||
import org.bukkit.event.player.PlayerEvent;
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
|
||||||
import nautilus.game.arcade.game.GameTeam;
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeTeam;
|
import nautilus.game.arcade.game.games.cakewars.team.CakeTeam;
|
||||||
|
|
||||||
public class CakeWarsEatCakeEvent extends PlayerEvent
|
public class CakeWarsEatCakeEvent extends PlayerEvent
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.module;
|
package nautilus.game.arcade.game.games.cakewars.general;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -18,6 +19,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.inventory.CraftItemEvent;
|
import org.bukkit.event.inventory.CraftItemEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
@ -34,17 +36,19 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
|||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.events.PlayerKitGiveEvent;
|
import nautilus.game.arcade.events.PlayerKitGiveEvent;
|
||||||
import nautilus.game.arcade.game.Game.GameState;
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
|
import nautilus.game.arcade.game.games.cakewars.CakeModule;
|
||||||
import nautilus.game.arcade.game.games.cakewars.CakeWars;
|
import nautilus.game.arcade.game.games.cakewars.CakeWars;
|
||||||
|
|
||||||
public class CakePlayerModule extends CakeModule
|
public class CakePlayerModule extends CakeModule
|
||||||
{
|
{
|
||||||
|
|
||||||
static final ItemStack RUNE_OF_HOLDING = new ItemBuilder(Material.SKULL_ITEM, (byte) 1)
|
public static final ItemStack RUNE_OF_HOLDING = new ItemBuilder(Material.SKULL_ITEM, (byte) 1)
|
||||||
.setTitle(C.cPurpleB + "Rune of Holding")
|
.setTitle(C.cPurpleB + "Rune of Holding")
|
||||||
.addLore("", "Preserves your inventory on death", "Uses: " + C.cRed + "1")
|
.addLore("", "Preserves your inventory on death", "Uses: " + C.cRed + "1")
|
||||||
.setUnbreakable(true)
|
.setUnbreakable(true)
|
||||||
.build();
|
.build();
|
||||||
static final ItemStack DEPLOY_PLATFORM = new ItemBuilder(Material.INK_SACK)
|
public static final ItemStack DEPLOY_PLATFORM = new ItemBuilder(Material.INK_SACK)
|
||||||
.setTitle(C.cYellowB + "Deploy Platform")
|
.setTitle(C.cYellowB + "Deploy Platform")
|
||||||
.addLore("", "Creates a platform of wool next to", "any block you click!", "Uses: " + C.cRed + "1")
|
.addLore("", "Creates a platform of wool next to", "any block you click!", "Uses: " + C.cRed + "1")
|
||||||
.setUnbreakable(true)
|
.setUnbreakable(true)
|
||||||
@ -200,7 +204,7 @@ public class CakePlayerModule extends CakeModule
|
|||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void playerInteractPlatform(PlayerInteractEvent event)
|
public void playerInteractPlatform(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled())
|
if (event.isCancelled() || !_game.IsLive())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -244,6 +248,34 @@ public class CakePlayerModule extends CakeModule
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void itemPickup(PlayerPickupItemEvent event)
|
||||||
|
{
|
||||||
|
if (event.isCancelled() || _game.IsLive())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
GameTeam team = _game.GetTeam(player);
|
||||||
|
|
||||||
|
if (team == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack itemStack = event.getItem().getItemStack();
|
||||||
|
|
||||||
|
if (itemStack.getType() == Material.WOOL || itemStack.getType() == Material.STAINED_CLAY)
|
||||||
|
{
|
||||||
|
itemStack.getData().setData(team.GetColorData());
|
||||||
|
}
|
||||||
|
else if (itemStack.getType() == Material.INK_SACK)
|
||||||
|
{
|
||||||
|
itemStack.getData().setData(DyeColor.getByWoolData(team.GetColorData()).getDyeData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void itemCraft(CraftItemEvent event)
|
public void itemCraft(CraftItemEvent event)
|
||||||
{
|
{
|
||||||
@ -259,4 +291,10 @@ public class CakePlayerModule extends CakeModule
|
|||||||
{
|
{
|
||||||
return _placedBlocks;
|
return _placedBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUsingRuneOfHolding(Player player)
|
||||||
|
{
|
||||||
|
return _storedInventory.containsKey(player);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,7 +1,9 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.module;
|
package nautilus.game.arcade.game.games.cakewars.general;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -9,23 +11,72 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilAction;
|
import mineplex.core.common.util.UtilAction;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
|
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.CakeWars;
|
import nautilus.game.arcade.game.games.cakewars.CakeWars;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeResource;
|
import nautilus.game.arcade.game.games.cakewars.shop.CakeResource;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeTeamItem;
|
import nautilus.game.arcade.game.games.cakewars.shop.CakeTeamItem;
|
||||||
|
|
||||||
public class CakeSpawnerModule extends CakeModule
|
public class CakeSpawnerModule extends CakeModule
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static final int MIN_BLOCK_PLACE_DIST_SQUARED = 4;
|
||||||
|
|
||||||
|
private final Map<GameTeam, Location> _spawnerLocation;
|
||||||
|
|
||||||
public CakeSpawnerModule(CakeWars game)
|
public CakeSpawnerModule(CakeWars game)
|
||||||
{
|
{
|
||||||
super(game);
|
super(game);
|
||||||
|
|
||||||
|
_spawnerLocation = new HashMap<>(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void prepare(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() != GameState.Prepare)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_game.GetTeamList().forEach(team ->
|
||||||
|
{
|
||||||
|
Location location = _game.WorldData.GetCustomLocs("GEN " + (team.GetName().toUpperCase())).get(0);
|
||||||
|
|
||||||
|
_spawnerLocation.put(team, location);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void blockPlace(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
if (event.isCancelled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location block = event.getBlock().getLocation();
|
||||||
|
|
||||||
|
for (Location location : _spawnerLocation.values())
|
||||||
|
{
|
||||||
|
if (UtilMath.offsetSquared(block, location) < MIN_BLOCK_PLACE_DIST_SQUARED)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().sendMessage(F.main("Game", "You cannot play blocks that close to a generator."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -58,7 +109,7 @@ public class CakeSpawnerModule extends CakeModule
|
|||||||
|
|
||||||
ItemStack itemStack = resource.getItemStack().clone();
|
ItemStack itemStack = resource.getItemStack().clone();
|
||||||
itemStack.setAmount(amount);
|
itemStack.setAmount(amount);
|
||||||
Location location = _game.WorldData.GetCustomLocs("GEN " + (team.GetName().toUpperCase())).get(0);
|
Location location = _spawnerLocation.get(team);
|
||||||
boolean drop = true;
|
boolean drop = true;
|
||||||
List<Player> players = new ArrayList<>();
|
List<Player> players = new ArrayList<>();
|
||||||
Item item = null;
|
Item item = null;
|
@ -1,4 +1,4 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.data;
|
package nautilus.game.arcade.game.games.cakewars.island;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.module;
|
package nautilus.game.arcade.game.games.cakewars.island;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -33,8 +33,8 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
|
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.game.Game.GameState;
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
|
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.data.CakeIsland;
|
|
||||||
|
|
||||||
public class CakeIslandModule extends CakeModule
|
public class CakeIslandModule extends CakeModule
|
||||||
{
|
{
|
@ -0,0 +1,14 @@
|
|||||||
|
package nautilus.game.arcade.game.games.cakewars.modes;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.GameType;
|
||||||
|
import nautilus.game.arcade.game.games.cakewars.CakeWars;
|
||||||
|
|
||||||
|
public class CakeWars4 extends CakeWars
|
||||||
|
{
|
||||||
|
|
||||||
|
public CakeWars4(ArcadeManager manager)
|
||||||
|
{
|
||||||
|
super(manager, GameType.CakeWars4);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package nautilus.game.arcade.game.games.cakewars.modes;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.GameType;
|
||||||
|
import nautilus.game.arcade.game.games.cakewars.CakeWars;
|
||||||
|
|
||||||
|
public class CakeWarsDuos extends CakeWars
|
||||||
|
{
|
||||||
|
|
||||||
|
public CakeWarsDuos(ArcadeManager manager)
|
||||||
|
{
|
||||||
|
super(manager, GameType.CakeWarsDuos);
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,12 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.data;
|
package nautilus.game.arcade.game.games.cakewars.shop;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public interface CakeItem
|
public interface CakeItem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
CakeShopItemType getItemType();
|
||||||
|
|
||||||
ItemStack getItemStack();
|
ItemStack getItemStack();
|
||||||
|
|
||||||
int getCost();
|
int getCost();
|
@ -1,4 +1,4 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.data;
|
package nautilus.game.arcade.game.games.cakewars.shop;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -7,7 +7,7 @@ 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.GameTeam;
|
||||||
import nautilus.game.arcade.game.games.cakewars.module.CakeSpawnerModule;
|
import nautilus.game.arcade.game.games.cakewars.general.CakeSpawnerModule;
|
||||||
|
|
||||||
public enum CakeResource
|
public enum CakeResource
|
||||||
{
|
{
|
||||||
@ -38,7 +38,7 @@ public enum CakeResource
|
|||||||
@Override
|
@Override
|
||||||
public void handleDistribution(CakeSpawnerModule module, GameTeam team)
|
public void handleDistribution(CakeSpawnerModule module, GameTeam team)
|
||||||
{
|
{
|
||||||
module.distributeItem(this, module.getGame().getCakePointModule().ownsNetherPoint(team) ? 1 : 0, team);
|
module.distributeItem(this, module.getGame().getCakePointModule().ownedNetherStarPoints(team), team);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
@ -1,19 +1,27 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.data;
|
package nautilus.game.arcade.game.games.cakewars.shop;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class CakeShopItem implements CakeItem
|
public class CakeShopItem implements CakeItem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private final CakeShopItemType _itemType;
|
||||||
private final ItemStack _itemStack;
|
private final ItemStack _itemStack;
|
||||||
private final int _cost;
|
private final int _cost;
|
||||||
|
|
||||||
public CakeShopItem(ItemStack itemStack, int cost)
|
public CakeShopItem(CakeShopItemType itemType, ItemStack itemStack, int cost)
|
||||||
{
|
{
|
||||||
|
_itemType = itemType;
|
||||||
_itemStack = itemStack;
|
_itemStack = itemStack;
|
||||||
_cost = cost;
|
_cost = cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CakeShopItemType getItemType()
|
||||||
|
{
|
||||||
|
return _itemType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemStack()
|
public ItemStack getItemStack()
|
||||||
{
|
{
|
@ -0,0 +1,69 @@
|
|||||||
|
package nautilus.game.arcade.game.games.cakewars.shop;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilItem.ItemCategory;
|
||||||
|
|
||||||
|
public enum CakeShopItemType
|
||||||
|
{
|
||||||
|
|
||||||
|
// Weapons
|
||||||
|
SWORD(ItemCategory.SWORD, false, false, true),
|
||||||
|
|
||||||
|
// Tools
|
||||||
|
AXE(ItemCategory.AXE, false, false, true),
|
||||||
|
PICKAXE(ItemCategory.PICKAXE, false, false, true),
|
||||||
|
SHEARS(null, false, false, true),
|
||||||
|
|
||||||
|
// Armour
|
||||||
|
HELMET(false, false, true),
|
||||||
|
CHESTPLATE(false, false, true),
|
||||||
|
LEGGINGS(false, false, true),
|
||||||
|
BOOTS(false, false, true),
|
||||||
|
|
||||||
|
// Blocks
|
||||||
|
BLOCK(true, false, true),
|
||||||
|
|
||||||
|
// Special
|
||||||
|
TEAM_UPGRADE(false, false, false),
|
||||||
|
TRAP(false, true, false),
|
||||||
|
|
||||||
|
// Other
|
||||||
|
OTHER(true, false, true);
|
||||||
|
|
||||||
|
private final ItemCategory _removeOnPurchase;
|
||||||
|
private final boolean _multiBuy;
|
||||||
|
private final boolean _onePerTeam;
|
||||||
|
private final boolean _isItem;
|
||||||
|
|
||||||
|
CakeShopItemType(boolean multiBuy, boolean onePerTeam, boolean isItem)
|
||||||
|
{
|
||||||
|
this(null, multiBuy, onePerTeam, isItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
CakeShopItemType(ItemCategory removeOnPurchase, boolean multiBuy, boolean onePerTeam, boolean isItem)
|
||||||
|
{
|
||||||
|
_removeOnPurchase = removeOnPurchase;
|
||||||
|
_multiBuy = multiBuy;
|
||||||
|
_onePerTeam = onePerTeam;
|
||||||
|
_isItem = isItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemCategory getRemoveOnPurchase()
|
||||||
|
{
|
||||||
|
return _removeOnPurchase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMultiBuy()
|
||||||
|
{
|
||||||
|
return _multiBuy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOnePerTeam()
|
||||||
|
{
|
||||||
|
return _onePerTeam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isItem()
|
||||||
|
{
|
||||||
|
return _isItem;
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,11 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.module;
|
package nautilus.game.arcade.game.games.cakewars.shop;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -11,7 +13,9 @@ import org.bukkit.enchantments.Enchantment;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import mineplex.core.Managers;
|
import mineplex.core.Managers;
|
||||||
@ -30,11 +34,11 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.game.Game.GameState;
|
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.CakeWars;
|
import nautilus.game.arcade.game.games.cakewars.CakeWars;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeItem;
|
import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeResource;
|
import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeBearTrap;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeShopItem;
|
import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeTNTTrap;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeTeamItemType;
|
|
||||||
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;
|
import nautilus.game.arcade.game.games.cakewars.ui.CakeResourceStarPage;
|
||||||
@ -42,12 +46,14 @@ import nautilus.game.arcade.game.games.cakewars.ui.CakeResourceStarPage;
|
|||||||
public class CakeShopModule extends CakeModule
|
public class CakeShopModule extends CakeModule
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final int MIN_BLOCK_PLACE_DIST_SQUARED = 49;
|
private static final int MIN_BLOCK_PLACE_DIST_SQUARED = 25;
|
||||||
|
|
||||||
private final NewNPCManager _manager;
|
private final NewNPCManager _manager;
|
||||||
private final Map<NPC, CakeResource> _npcs;
|
private final Map<NPC, CakeResource> _npcs;
|
||||||
private final CakeResourceShop _shop;
|
private final CakeResourceShop _shop;
|
||||||
private final Map<CakeResource, List<CakeItem>> _items;
|
private final Map<CakeResource, List<CakeItem>> _items;
|
||||||
|
private final Map<Player, Set<CakeItem>> _ownedItems;
|
||||||
|
private final Map<GameTeam, Set<CakeItem>> _ownedTeamItems;
|
||||||
|
|
||||||
public CakeShopModule(CakeWars game)
|
public CakeShopModule(CakeWars game)
|
||||||
{
|
{
|
||||||
@ -57,97 +63,111 @@ public class CakeShopModule extends CakeModule
|
|||||||
_npcs = new HashMap<>();
|
_npcs = new HashMap<>();
|
||||||
_shop = new CakeResourceShop(game.getArcadeManager());
|
_shop = new CakeResourceShop(game.getArcadeManager());
|
||||||
_items = new HashMap<>(CakeResource.values().length);
|
_items = new HashMap<>(CakeResource.values().length);
|
||||||
|
_ownedItems = new HashMap<>();
|
||||||
|
_ownedTeamItems = new HashMap<>(8);
|
||||||
|
|
||||||
_items.put(CakeResource.BRICK, Arrays.asList(
|
_items.put(CakeResource.BRICK, Arrays.asList(
|
||||||
|
|
||||||
// Iron Set
|
// Iron Set
|
||||||
new CakeShopItem(new ItemBuilder(Material.IRON_HELMET)
|
new CakeShopItem(CakeShopItemType.HELMET,
|
||||||
|
new ItemBuilder(Material.IRON_HELMET)
|
||||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||||
.build(), 5),
|
.build(), 5),
|
||||||
new CakeShopItem(new ItemBuilder(Material.IRON_CHESTPLATE)
|
new CakeShopItem(CakeShopItemType.CHESTPLATE,
|
||||||
|
new ItemBuilder(Material.IRON_CHESTPLATE)
|
||||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||||
.build(), 7),
|
.build(), 7),
|
||||||
new CakeShopItem(new ItemBuilder(Material.IRON_LEGGINGS)
|
new CakeShopItem(CakeShopItemType.LEGGINGS,
|
||||||
|
new ItemBuilder(Material.IRON_LEGGINGS)
|
||||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||||
.build(), 7),
|
.build(), 7),
|
||||||
new CakeShopItem(new ItemBuilder(Material.IRON_BOOTS)
|
new CakeShopItem(CakeShopItemType.BOOTS,
|
||||||
|
new ItemBuilder(Material.IRON_BOOTS)
|
||||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||||
.build(), 5),
|
.build(), 5),
|
||||||
|
|
||||||
// Sword
|
// Sword
|
||||||
new CakeShopItem(new ItemStack(Material.DIAMOND_SWORD), 5),
|
new CakeShopItem(CakeShopItemType.SWORD, new ItemStack(Material.DIAMOND_SWORD), 5),
|
||||||
|
|
||||||
// Pickaxe
|
// Pickaxe
|
||||||
new CakeShopItem(new ItemStack(Material.IRON_PICKAXE), 3),
|
new CakeShopItem(CakeShopItemType.PICKAXE, new ItemStack(Material.IRON_PICKAXE), 3),
|
||||||
|
|
||||||
// Axe
|
// Axe
|
||||||
new CakeShopItem(new ItemStack(Material.IRON_AXE), 3),
|
new CakeShopItem(CakeShopItemType.AXE, new ItemStack(Material.IRON_AXE), 3),
|
||||||
|
|
||||||
// Arrow
|
// Arrow
|
||||||
new CakeShopItem(new ItemStack(Material.ARROW, 3), 6),
|
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.ARROW, 3), 6),
|
||||||
|
|
||||||
// Blocks
|
// Blocks
|
||||||
// Wool
|
// Wool
|
||||||
new CakeShopItem(new ItemStack(Material.WOOL, 16), 3),
|
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.WOOL, 16), 3),
|
||||||
|
|
||||||
// Coloured Clay
|
// Coloured Clay
|
||||||
new CakeShopItem(new ItemStack(Material.STAINED_CLAY, 8), 12),
|
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.STAINED_CLAY, 8), 12),
|
||||||
|
|
||||||
// Wood
|
// Wood
|
||||||
new CakeShopItem(new ItemStack(Material.WOOD, 8), 12),
|
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.WOOD, 8), 12),
|
||||||
|
|
||||||
// End Stone
|
// End Stone
|
||||||
new CakeShopItem(new ItemStack(Material.ENDER_STONE, 4), 16),
|
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.ENDER_STONE, 8), 16),
|
||||||
|
|
||||||
// Deploy Platform
|
// Deploy Platform
|
||||||
new CakeShopItem(CakePlayerModule.DEPLOY_PLATFORM, 5),
|
new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.DEPLOY_PLATFORM, 5),
|
||||||
|
|
||||||
// Emerald
|
// Emerald
|
||||||
new CakeShopItem(new ItemStack(Material.EMERALD), 20)
|
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.EMERALD), 20)
|
||||||
)
|
|
||||||
);
|
));
|
||||||
_items.put(CakeResource.EMERALD, Arrays.asList(
|
_items.put(CakeResource.EMERALD, Arrays.asList(
|
||||||
|
|
||||||
|
|
||||||
// Diamond Set
|
// Diamond Set
|
||||||
new CakeShopItem(new ItemBuilder(Material.DIAMOND_HELMET)
|
new CakeShopItem(CakeShopItemType.HELMET,
|
||||||
|
new ItemBuilder(Material.DIAMOND_HELMET)
|
||||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||||
.build(), 10),
|
.build(), 10),
|
||||||
new CakeShopItem(new ItemBuilder(Material.DIAMOND_CHESTPLATE)
|
new CakeShopItem(CakeShopItemType.CHESTPLATE,
|
||||||
|
new ItemBuilder(Material.DIAMOND_CHESTPLATE)
|
||||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||||
.build(), 20),
|
.build(), 20),
|
||||||
new CakeShopItem(new ItemBuilder(Material.DIAMOND_LEGGINGS)
|
new CakeShopItem(CakeShopItemType.LEGGINGS,
|
||||||
|
new ItemBuilder(Material.DIAMOND_LEGGINGS)
|
||||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||||
.build(), 20),
|
.build(), 20),
|
||||||
new CakeShopItem(new ItemBuilder(Material.DIAMOND_BOOTS)
|
new CakeShopItem(CakeShopItemType.BOOTS,
|
||||||
|
new ItemBuilder(Material.DIAMOND_BOOTS)
|
||||||
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1)
|
||||||
.build(), 10),
|
.build(), 10),
|
||||||
|
|
||||||
// Sword
|
// Sword
|
||||||
new CakeShopItem(new ItemBuilder(Material.DIAMOND_SWORD)
|
new CakeShopItem(CakeShopItemType.SWORD, new ItemBuilder(Material.DIAMOND_SWORD)
|
||||||
.addEnchantment(Enchantment.DAMAGE_ALL, 1)
|
.addEnchantment(Enchantment.DAMAGE_ALL, 1)
|
||||||
.build(), 10),
|
.build(), 10),
|
||||||
|
|
||||||
// Pickaxe
|
// Pickaxe
|
||||||
new CakeShopItem(new ItemStack(Material.DIAMOND_PICKAXE), 10),
|
new CakeShopItem(CakeShopItemType.PICKAXE, new ItemStack(Material.DIAMOND_PICKAXE), 10),
|
||||||
|
|
||||||
// Axe
|
// Axe
|
||||||
new CakeShopItem(new ItemStack(Material.DIAMOND_AXE), 10),
|
new CakeShopItem(CakeShopItemType.AXE, new ItemStack(Material.DIAMOND_AXE), 10),
|
||||||
|
|
||||||
// Obsidian
|
// Obsidian
|
||||||
new CakeShopItem(new ItemStack(Material.OBSIDIAN), 5),
|
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.OBSIDIAN), 5),
|
||||||
|
|
||||||
// Shears
|
// Shears
|
||||||
new CakeShopItem(new ItemStack(Material.SHEARS), 5),
|
new CakeShopItem(CakeShopItemType.SHEARS, new ItemStack(Material.SHEARS), 5),
|
||||||
|
|
||||||
// Golden Apple
|
// Golden Apple
|
||||||
new CakeShopItem(new ItemStack(Material.GOLDEN_APPLE), 5),
|
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.GOLDEN_APPLE), 5),
|
||||||
|
|
||||||
// Ender pearl
|
// Ender pearl
|
||||||
new CakeShopItem(new ItemStack(Material.ENDER_PEARL), 5),
|
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.ENDER_PEARL), 5),
|
||||||
|
|
||||||
// Rune of Holding
|
// Rune of Holding
|
||||||
new CakeShopItem(CakePlayerModule.RUNE_OF_HOLDING, 20)
|
new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.RUNE_OF_HOLDING, 20),
|
||||||
|
|
||||||
|
// Traps
|
||||||
|
new CakeTNTTrap(12),
|
||||||
|
new CakeBearTrap(12)
|
||||||
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -160,7 +180,7 @@ public class CakeShopModule extends CakeModule
|
|||||||
_items.clear();
|
_items.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void prepare(GameStateChangeEvent event)
|
public void prepare(GameStateChangeEvent event)
|
||||||
{
|
{
|
||||||
if (event.GetState() != GameState.Prepare)
|
if (event.GetState() != GameState.Prepare)
|
||||||
@ -170,25 +190,24 @@ public class CakeShopModule extends CakeModule
|
|||||||
|
|
||||||
_game.CreatureAllowOverride = true;
|
_game.CreatureAllowOverride = true;
|
||||||
|
|
||||||
for (GameTeam team : _game.GetTeamList())
|
_game.getCakeTeamModule().getCakeTeams().forEach((team, cakeTeam) ->
|
||||||
{
|
{
|
||||||
if (!team.IsTeamAlive())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String teamName = team.GetName().toUpperCase();
|
String teamName = team.GetName().toUpperCase();
|
||||||
|
|
||||||
for (CakeResource resource : CakeResource.values())
|
for (CakeResource resource : CakeResource.values())
|
||||||
{
|
{
|
||||||
Location location = _game.WorldData.GetCustomLocs("SHOP " + teamName + " " + resource.name()).get(0);
|
Location location = _game.WorldData.GetCustomLocs("SHOP " + teamName + " " + resource.name()).get(0);
|
||||||
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory2d(location, _game.GetSpectatorLocation())));
|
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory2d(location, cakeTeam.getCake())));
|
||||||
NPC npc = new NPC(-1, EntityType.VILLAGER, resource.getChatColor() + C.Bold + resource.getName() + " Shop", location, null, (byte) 0, null, null, null, null, "CAKE_NPC");
|
NPC npc = new NPC(-1, EntityType.VILLAGER, resource.getChatColor() + C.Bold + resource.getName() + " Shop", location, null, (byte) 0, null, null, null, null, "CAKE_NPC");
|
||||||
|
|
||||||
_manager.addNPC(npc, false);
|
_manager.addNPC(npc, false);
|
||||||
_npcs.put(npc, resource);
|
_npcs.put(npc, resource);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
team.GetPlayers(false).forEach(player -> _ownedItems.put(player, new HashSet<>()));
|
||||||
|
|
||||||
|
_ownedTeamItems.put(team, new HashSet<>());
|
||||||
|
});
|
||||||
|
|
||||||
_game.CreatureAllowOverride = false;
|
_game.CreatureAllowOverride = false;
|
||||||
}
|
}
|
||||||
@ -264,7 +283,7 @@ public class CakeShopModule extends CakeModule
|
|||||||
|
|
||||||
cakeTeam.getUpgrades().forEach((item, level) ->
|
cakeTeam.getUpgrades().forEach((item, level) ->
|
||||||
{
|
{
|
||||||
if (level > 0 && item.getType() == CakeTeamItemType.PASSIVE_UPGRADE)
|
if (level > 0)
|
||||||
{
|
{
|
||||||
alive.forEach(player -> item.apply(player, level, cakeTeam.getCake()));
|
alive.forEach(player -> item.apply(player, level, cakeTeam.getCake()));
|
||||||
}
|
}
|
||||||
@ -272,6 +291,38 @@ public class CakeShopModule extends CakeModule
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void playerDeath(PlayerDeathEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getEntity();
|
||||||
|
Set<CakeItem> items = _ownedItems.get(player);
|
||||||
|
|
||||||
|
if (items != null && !_game.getCakePlayerModule().isUsingRuneOfHolding(player))
|
||||||
|
{
|
||||||
|
items.removeIf(item -> !item.getItemType().isOnePerTeam());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean ownsItem(Player player, CakeItem item)
|
||||||
|
{
|
||||||
|
return _ownedItems.get(player).contains(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean ownsItem(GameTeam team, CakeItem item)
|
||||||
|
{
|
||||||
|
return _ownedTeamItems.get(team).contains(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<CakeItem> getOwnedItems(Player player)
|
||||||
|
{
|
||||||
|
return _ownedItems.get(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<CakeItem> getOwnedItems(GameTeam team)
|
||||||
|
{
|
||||||
|
return _ownedTeamItems.get(team);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isNearShop(Location location)
|
public boolean isNearShop(Location location)
|
||||||
{
|
{
|
||||||
for (NPC npc : _npcs.keySet())
|
for (NPC npc : _npcs.keySet())
|
@ -1,22 +1,15 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.data;
|
package nautilus.game.arcade.game.games.cakewars.shop;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilAction;
|
|
||||||
import mineplex.core.common.util.UtilAlg;
|
|
||||||
import mineplex.core.common.util.UtilItem;
|
import mineplex.core.common.util.UtilItem;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilParticle;
|
|
||||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
|
||||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
|
|
||||||
public enum CakeTeamItem implements CakeItem
|
public enum CakeTeamItem implements CakeItem
|
||||||
@ -24,7 +17,6 @@ public enum CakeTeamItem implements CakeItem
|
|||||||
|
|
||||||
PROTECTION(
|
PROTECTION(
|
||||||
"Protection",
|
"Protection",
|
||||||
CakeTeamItemType.PASSIVE_UPGRADE,
|
|
||||||
new ItemStack(Material.DIAMOND_CHESTPLATE),
|
new ItemStack(Material.DIAMOND_CHESTPLATE),
|
||||||
4,
|
4,
|
||||||
10
|
10
|
||||||
@ -44,7 +36,6 @@ public enum CakeTeamItem implements CakeItem
|
|||||||
},
|
},
|
||||||
HASTE(
|
HASTE(
|
||||||
"Haste",
|
"Haste",
|
||||||
CakeTeamItemType.PASSIVE_UPGRADE,
|
|
||||||
new ItemStack(Material.GOLD_PICKAXE),
|
new ItemStack(Material.GOLD_PICKAXE),
|
||||||
4,
|
4,
|
||||||
10
|
10
|
||||||
@ -59,7 +50,6 @@ public enum CakeTeamItem implements CakeItem
|
|||||||
},
|
},
|
||||||
SHARPNESS(
|
SHARPNESS(
|
||||||
"Sharpness",
|
"Sharpness",
|
||||||
CakeTeamItemType.PASSIVE_UPGRADE,
|
|
||||||
new ItemStack(Material.DIAMOND_SWORD),
|
new ItemStack(Material.DIAMOND_SWORD),
|
||||||
4,
|
4,
|
||||||
10
|
10
|
||||||
@ -79,14 +69,12 @@ public enum CakeTeamItem implements CakeItem
|
|||||||
},
|
},
|
||||||
RESOURCE(
|
RESOURCE(
|
||||||
"Resource Generator",
|
"Resource Generator",
|
||||||
CakeTeamItemType.PASSIVE_UPGRADE,
|
|
||||||
new ItemStack(Material.NETHER_STAR),
|
new ItemStack(Material.NETHER_STAR),
|
||||||
4,
|
4,
|
||||||
10
|
10
|
||||||
),
|
),
|
||||||
REGENERATION(
|
REGENERATION(
|
||||||
"Healing Station",
|
"Healing Station",
|
||||||
CakeTeamItemType.PASSIVE_UPGRADE,
|
|
||||||
new ItemStack(Material.GOLDEN_APPLE),
|
new ItemStack(Material.GOLDEN_APPLE),
|
||||||
4,
|
4,
|
||||||
10
|
10
|
||||||
@ -102,54 +90,15 @@ public enum CakeTeamItem implements CakeItem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TRAP_BEAR(
|
|
||||||
"Bear Trap",
|
|
||||||
CakeTeamItemType.TRAP,
|
|
||||||
new ItemStack(Material.TRIPWIRE_HOOK),
|
|
||||||
3
|
|
||||||
)
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void apply(Player player, int level, 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);
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 80, 2));
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 80, 0, false, false));
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 80, 0, false, false));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
TRAP_TNT(
|
|
||||||
"TNT Trap",
|
|
||||||
CakeTeamItemType.TRAP,
|
|
||||||
new ItemStack(Material.TNT),
|
|
||||||
3
|
|
||||||
)
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void apply(Player player, int level, 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);
|
|
||||||
|
|
||||||
Vector direction = UtilAlg.getTrajectory2d(cake, player.getLocation());
|
|
||||||
direction.multiply(1.5);
|
|
||||||
direction.setY(1.3 + (Math.random() / 2D));
|
|
||||||
|
|
||||||
UtilAction.velocity(player, direction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String _name;
|
private final String _name;
|
||||||
private final CakeTeamItemType _type;
|
|
||||||
private final ItemStack _itemStack;
|
private final ItemStack _itemStack;
|
||||||
private final int[] _costs;
|
private final int[] _costs;
|
||||||
|
|
||||||
CakeTeamItem(String name, CakeTeamItemType type, ItemStack itemStack, int... costs)
|
CakeTeamItem(String name, ItemStack itemStack, int... costs)
|
||||||
{
|
{
|
||||||
_name = name;
|
_name = name;
|
||||||
_type = type;
|
|
||||||
_itemStack = new ItemBuilder(itemStack)
|
_itemStack = new ItemBuilder(itemStack)
|
||||||
.setTitle(name)
|
.setTitle(name)
|
||||||
.setGlow(true)
|
.setGlow(true)
|
||||||
@ -161,16 +110,17 @@ public enum CakeTeamItem implements CakeItem
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CakeShopItemType getItemType()
|
||||||
|
{
|
||||||
|
return CakeShopItemType.TEAM_UPGRADE;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CakeTeamItemType getType()
|
|
||||||
{
|
|
||||||
return _type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemStack()
|
public ItemStack getItemStack()
|
||||||
{
|
{
|
||||||
@ -185,6 +135,6 @@ public enum CakeTeamItem implements CakeItem
|
|||||||
@Override
|
@Override
|
||||||
public int getCost()
|
public int getCost()
|
||||||
{
|
{
|
||||||
return _costs[0];
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package nautilus.game.arcade.game.games.cakewars.shop.trap;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilParticle;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||||
|
|
||||||
|
public class CakeBearTrap extends CakeTrapItem
|
||||||
|
{
|
||||||
|
|
||||||
|
public CakeBearTrap(int cost)
|
||||||
|
{
|
||||||
|
super(new ItemStack(Material.TRIPWIRE_HOOK), cost, "Bear Trap");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCakeInteract(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);
|
||||||
|
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 80, 2));
|
||||||
|
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 80, 0, false, false));
|
||||||
|
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 80, 0, false, false));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package nautilus.game.arcade.game.games.cakewars.shop.trap;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilAction;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilParticle;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||||
|
|
||||||
|
public class CakeTNTTrap extends CakeTrapItem
|
||||||
|
{
|
||||||
|
|
||||||
|
public CakeTNTTrap(int cost)
|
||||||
|
{
|
||||||
|
super(new ItemStack(Material.TNT), cost, "TNT Trap");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCakeInteract(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);
|
||||||
|
|
||||||
|
Vector direction = UtilAlg.getTrajectory2d(cake, player.getLocation());
|
||||||
|
direction.multiply(1.5);
|
||||||
|
direction.setY(1.3 + (Math.random() / 2D));
|
||||||
|
|
||||||
|
UtilAction.velocity(player, direction);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package nautilus.game.arcade.game.games.cakewars.shop.trap;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.games.cakewars.shop.CakeShopItem;
|
||||||
|
import nautilus.game.arcade.game.games.cakewars.shop.CakeShopItemType;
|
||||||
|
|
||||||
|
public abstract class CakeTrapItem extends CakeShopItem
|
||||||
|
{
|
||||||
|
|
||||||
|
private final String _name;
|
||||||
|
|
||||||
|
CakeTrapItem(ItemStack itemStack, int cost, String name)
|
||||||
|
{
|
||||||
|
super(CakeShopItemType.TRAP, new ItemBuilder(itemStack)
|
||||||
|
.setTitle(C.mItem + name)
|
||||||
|
.build(), cost);
|
||||||
|
|
||||||
|
_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void onCakeInteract(Player player, Location cake);
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.data;
|
package nautilus.game.arcade.game.games.cakewars.team;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -16,6 +16,7 @@ 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.CakeTeamItem;
|
||||||
|
|
||||||
public class CakeTeam
|
public class CakeTeam
|
||||||
{
|
{
|
||||||
@ -71,10 +72,10 @@ public class CakeTeam
|
|||||||
.addPlayers(teamPlayers)
|
.addPlayers(teamPlayers)
|
||||||
.start());
|
.start());
|
||||||
|
|
||||||
new Hologram(hologramManager, _shop, SHOP_HOLOGRAM_TEXT)
|
_holograms.add(new Hologram(hologramManager, _shop, SHOP_HOLOGRAM_TEXT)
|
||||||
.setHologramTarget(HologramTarget.WHITELIST)
|
.setHologramTarget(HologramTarget.WHITELIST)
|
||||||
.addPlayers(teamPlayers)
|
.addPlayers(teamPlayers)
|
||||||
.start();
|
.start());
|
||||||
|
|
||||||
_cakeHologram = new Hologram(hologramManager, _cake.clone().add(0.5, 1.3, 0.5), CAKE_HOLOGRAM_TEXT)
|
_cakeHologram = new Hologram(hologramManager, _cake.clone().add(0.5, 1.3, 0.5), CAKE_HOLOGRAM_TEXT)
|
||||||
.setHologramTarget(HologramTarget.WHITELIST)
|
.setHologramTarget(HologramTarget.WHITELIST)
|
@ -1,8 +1,10 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.module;
|
package nautilus.game.arcade.game.games.cakewars.team;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -41,11 +43,12 @@ import nautilus.game.arcade.events.PlayerDeathOutEvent;
|
|||||||
import nautilus.game.arcade.events.PlayerKitGiveEvent;
|
import nautilus.game.arcade.events.PlayerKitGiveEvent;
|
||||||
import nautilus.game.arcade.game.Game.GameState;
|
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.CakeWars;
|
import nautilus.game.arcade.game.games.cakewars.CakeWars;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeTeam;
|
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeTeamItem;
|
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeTeamItemType;
|
|
||||||
import nautilus.game.arcade.game.games.cakewars.event.CakeWarsEatCakeEvent;
|
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.world.WorldData;
|
import nautilus.game.arcade.world.WorldData;
|
||||||
|
|
||||||
public class CakeTeamModule extends CakeModule
|
public class CakeTeamModule extends CakeModule
|
||||||
@ -211,21 +214,40 @@ public class CakeTeamModule extends CakeModule
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cakeTeam.getUpgrades().entrySet().forEach(entry ->
|
CakeShopModule module = _game.getCakeShopModule();
|
||||||
{
|
|
||||||
CakeTeamItem item = entry.getKey();
|
|
||||||
|
|
||||||
if (item.getType() != CakeTeamItemType.TRAP || entry.getValue() == 0 || !Recharge.Instance.use(player, "Trap", 10000, false, false))
|
module.getOwnedItems(team).removeIf(item ->
|
||||||
{
|
{
|
||||||
return;
|
if (!(item instanceof CakeTrapItem) || !Recharge.Instance.use(player, "Trap", 10000, false, false))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_game.getArcadeManager().GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 2, false, true, false, "Trap", item.getName());
|
Player damager = null;
|
||||||
item.apply(player, entry.getValue(), cakeTeam.getCake());
|
|
||||||
|
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(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);
|
UtilTextMiddle.display("", C.cRedB + "TRAPPED", 5, 20, 5, player);
|
||||||
|
|
||||||
entry.setValue(0);
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
_game.AddGems(player, 4, "Cake Bites", true, true);
|
_game.AddGems(player, 4, "Cake Bites", true, true);
|
@ -1,7 +1,9 @@
|
|||||||
package nautilus.game.arcade.game.games.cakewars.ui;
|
package nautilus.game.arcade.game.games.cakewars.ui;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -13,7 +15,6 @@ import mineplex.core.common.util.C;
|
|||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilInv;
|
import mineplex.core.common.util.UtilInv;
|
||||||
import mineplex.core.common.util.UtilItem;
|
import mineplex.core.common.util.UtilItem;
|
||||||
import mineplex.core.common.util.UtilItem.ItemCategory;
|
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
@ -23,8 +24,10 @@ import mineplex.core.shop.page.ShopPageBase;
|
|||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
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.data.CakeItem;
|
import nautilus.game.arcade.game.games.cakewars.shop.CakeItem;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeResource;
|
import nautilus.game.arcade.game.games.cakewars.shop.CakeResource;
|
||||||
|
import nautilus.game.arcade.game.games.cakewars.shop.CakeShopItemType;
|
||||||
|
import nautilus.game.arcade.game.games.cakewars.shop.CakeShopModule;
|
||||||
|
|
||||||
public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceShop>
|
public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceShop>
|
||||||
{
|
{
|
||||||
@ -32,12 +35,6 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
|
|||||||
private static final ItemStack CLOSE_ITEM = new ItemBuilder(Material.BARRIER)
|
private static final ItemStack CLOSE_ITEM = new ItemBuilder(Material.BARRIER)
|
||||||
.setTitle(C.cRedB + "Close")
|
.setTitle(C.cRedB + "Close")
|
||||||
.build();
|
.build();
|
||||||
private static final ItemCategory[] REMOVE_ON_BUY =
|
|
||||||
{
|
|
||||||
ItemCategory.SWORD,
|
|
||||||
ItemCategory.PICKAXE,
|
|
||||||
ItemCategory.AXE
|
|
||||||
};
|
|
||||||
|
|
||||||
final CakeWars _game;
|
final CakeWars _game;
|
||||||
final CakeResource _resource;
|
final CakeResource _resource;
|
||||||
@ -63,7 +60,9 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
|
|||||||
|
|
||||||
for (CakeItem item : _items)
|
for (CakeItem item : _items)
|
||||||
{
|
{
|
||||||
addButton(slot, prepareItem(item), new CakeShopButton(item));
|
CakeShopResult result = getResultPurchase(item);
|
||||||
|
|
||||||
|
addButton(slot, prepareItem(item, result), new CakeShopButton(item, result));
|
||||||
|
|
||||||
if (++slot % 9 == 8)
|
if (++slot % 9 == 8)
|
||||||
{
|
{
|
||||||
@ -77,10 +76,31 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
|
|||||||
addButton(4, CLOSE_ITEM, (player, clickType) -> player.closeInventory());
|
addButton(4, CLOSE_ITEM, (player, clickType) -> player.closeInventory());
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack prepareItem(CakeItem item)
|
CakeShopResult getResultPurchase(CakeItem item)
|
||||||
|
{
|
||||||
|
CakeShopModule module = _game.getCakeShopModule();
|
||||||
|
CakeShopItemType itemType = item.getItemType();
|
||||||
|
ItemStack itemStack = _resource.getItemStack();
|
||||||
|
|
||||||
|
if (!itemType.isMultiBuy() && module.ownsItem(_player, item))
|
||||||
|
{
|
||||||
|
return CakeShopResult.ALREADY_OWNED;
|
||||||
|
}
|
||||||
|
else if (itemType.isOnePerTeam() && module.ownsItem(_team, item))
|
||||||
|
{
|
||||||
|
return CakeShopResult.ONLY_ONE;
|
||||||
|
}
|
||||||
|
else if (!UtilInv.contains(_player, itemStack.getType(), itemStack.getData().getData(), item.getCost()))
|
||||||
|
{
|
||||||
|
return CakeShopResult.NOT_ENOUGH_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CakeShopResult.SUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack prepareItem(CakeItem item, CakeShopResult result)
|
||||||
{
|
{
|
||||||
ItemBuilder builder = new ItemBuilder(item.getItemStack());
|
ItemBuilder builder = new ItemBuilder(item.getItemStack());
|
||||||
boolean canPurchase = canPurchase(_player, item);
|
|
||||||
|
|
||||||
handleTeamColours(builder);
|
handleTeamColours(builder);
|
||||||
|
|
||||||
@ -89,7 +109,7 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
|
|||||||
"",
|
"",
|
||||||
"Cost: " + _resource.getChatColor() + item.getCost() + " " + _resource.getName() + "s",
|
"Cost: " + _resource.getChatColor() + item.getCost() + " " + _resource.getName() + "s",
|
||||||
"",
|
"",
|
||||||
canPurchase ? C.cGreen + "Click to purchase!" : C.cRed + "You do not have enough resources!"
|
result.getColour() + result.getFeedback()
|
||||||
);
|
);
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
@ -109,13 +129,6 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canPurchase(Player player, CakeItem item)
|
|
||||||
{
|
|
||||||
ItemStack resource = _resource.getItemStack();
|
|
||||||
|
|
||||||
return UtilInv.contains(player, resource.getType(), resource.getData().getData(), item.getCost());
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getItemName(ItemStack itemStack)
|
private String getItemName(ItemStack itemStack)
|
||||||
{
|
{
|
||||||
if (itemStack.getType() == Material.STAINED_CLAY)
|
if (itemStack.getType() == Material.STAINED_CLAY)
|
||||||
@ -130,14 +143,45 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
|
|||||||
return ItemStackFactory.Instance.GetName(itemStack, true);
|
return ItemStackFactory.Instance.GetName(itemStack, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected enum CakeShopResult
|
||||||
|
{
|
||||||
|
|
||||||
|
SUCCESSFUL(ChatColor.GREEN, "Click to purchase!"),
|
||||||
|
NOT_ENOUGH_RESOURCES(ChatColor.RED, "You do not have enough resources!"),
|
||||||
|
ALREADY_OWNED(ChatColor.RED, "You already have purchased this item."),
|
||||||
|
ONLY_ONE(ChatColor.RED, "Your team already owns this upgrade."),
|
||||||
|
MAX_TIER(ChatColor.RED, "Your team has already unlocked the maximum tier.");
|
||||||
|
|
||||||
|
private final ChatColor _colour;
|
||||||
|
private final String _feedback;
|
||||||
|
|
||||||
|
CakeShopResult(ChatColor colour, String feedback)
|
||||||
|
{
|
||||||
|
_colour = colour;
|
||||||
|
_feedback = feedback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getColour()
|
||||||
|
{
|
||||||
|
return _colour;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFeedback()
|
||||||
|
{
|
||||||
|
return _feedback;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class CakeShopButton implements IButton
|
private class CakeShopButton implements IButton
|
||||||
{
|
{
|
||||||
|
|
||||||
private final CakeItem _item;
|
private final CakeItem _item;
|
||||||
|
private final CakeShopResult _result;
|
||||||
|
|
||||||
CakeShopButton(CakeItem item)
|
CakeShopButton(CakeItem item, CakeShopResult result)
|
||||||
{
|
{
|
||||||
_item = item;
|
_item = item;
|
||||||
|
_result = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -147,7 +191,14 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (_result != CakeShopResult.SUCCESSFUL)
|
||||||
|
{
|
||||||
|
player.sendMessage(F.main("Game", _result.getFeedback()));
|
||||||
|
playDenySound(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CakeShopItemType itemType = _item.getItemType();
|
||||||
ItemStack resource = _resource.getItemStack();
|
ItemStack resource = _resource.getItemStack();
|
||||||
ItemBuilder give = new ItemBuilder(_item.getItemStack());
|
ItemBuilder give = new ItemBuilder(_item.getItemStack());
|
||||||
Material material = give.getType();
|
Material material = give.getType();
|
||||||
@ -157,64 +208,62 @@ public class CakeResourcePage extends ShopPageBase<ArcadeManager, CakeResourceSh
|
|||||||
give.setUnbreakable(true);
|
give.setUnbreakable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UtilInv.remove(player, resource.getType(), resource.getData().getData(), _item.getCost()))
|
UtilInv.remove(player, resource.getType(), resource.getData().getData(), _item.getCost());
|
||||||
{
|
|
||||||
handleTeamColours(give);
|
handleTeamColours(give);
|
||||||
|
|
||||||
ItemStack giveItem = give.build();
|
ItemStack giveItem = give.build();
|
||||||
|
|
||||||
if (UtilItem.isHelmet(giveItem))
|
|
||||||
{
|
|
||||||
player.getInventory().setHelmet(giveItem);
|
|
||||||
}
|
|
||||||
else if (UtilItem.isChestplate(giveItem))
|
|
||||||
{
|
|
||||||
player.getInventory().setChestplate(giveItem);
|
|
||||||
}
|
|
||||||
else if (UtilItem.isLeggings(giveItem))
|
|
||||||
{
|
|
||||||
player.getInventory().setLeggings(giveItem);
|
|
||||||
}
|
|
||||||
else if (UtilItem.isBoots(giveItem))
|
|
||||||
{
|
|
||||||
player.getInventory().setBoots(giveItem);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (ItemCategory category : REMOVE_ON_BUY)
|
|
||||||
{
|
|
||||||
if (UtilItem.is(giveItem, category))
|
|
||||||
{
|
|
||||||
removeCategory(player, category);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UtilInv.insert(player, giveItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage(F.main("Game", "You purchased " + F.name(getItemName(giveItem))) + ".");
|
|
||||||
playAcceptSound(player);
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.sendMessage(F.main("Game", "You do not have enough " + F.name(_resource.getName() + "s") + " to purchase this item."));
|
|
||||||
playDenySound(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeCategory(Player player, ItemCategory category)
|
|
||||||
{
|
|
||||||
PlayerInventory inventory = player.getInventory();
|
PlayerInventory inventory = player.getInventory();
|
||||||
|
|
||||||
|
if (itemType.getRemoveOnPurchase() != null)
|
||||||
|
{
|
||||||
for (int i = 0; i < inventory.getSize(); i++)
|
for (int i = 0; i < inventory.getSize(); i++)
|
||||||
{
|
{
|
||||||
if (UtilItem.is(inventory.getItem(i), category))
|
if (UtilItem.is(inventory.getItem(i), itemType.getRemoveOnPurchase()))
|
||||||
{
|
{
|
||||||
inventory.setItem(i, null);
|
inventory.setItem(i, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (itemType)
|
||||||
|
{
|
||||||
|
case HELMET:
|
||||||
|
inventory.setHelmet(giveItem);
|
||||||
|
break;
|
||||||
|
case CHESTPLATE:
|
||||||
|
inventory.setChestplate(giveItem);
|
||||||
|
break;
|
||||||
|
case LEGGINGS:
|
||||||
|
inventory.setLeggings(giveItem);
|
||||||
|
break;
|
||||||
|
case BOOTS:
|
||||||
|
inventory.setBoots(giveItem);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (itemType.isItem())
|
||||||
|
{
|
||||||
|
UtilInv.insert(player, giveItem);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<CakeItem> ownedItems = _game.getCakeShopModule().getOwnedItems(player);
|
||||||
|
|
||||||
|
if (!itemType.isMultiBuy())
|
||||||
|
{
|
||||||
|
ownedItems.removeIf(item -> item.getItemType().equals(itemType));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemType.isOnePerTeam())
|
||||||
|
{
|
||||||
|
_game.getCakeShopModule().getOwnedItems(_team).add(_item);
|
||||||
|
}
|
||||||
|
|
||||||
|
ownedItems.add(_item);
|
||||||
|
|
||||||
|
player.sendMessage(F.main("Game", "You purchased " + F.name(getItemName(giveItem))) + ".");
|
||||||
|
playAcceptSound(player);
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,10 @@ import mineplex.core.recharge.Recharge;
|
|||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
|
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeItem;
|
import nautilus.game.arcade.game.games.cakewars.shop.CakeItem;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeResource;
|
import nautilus.game.arcade.game.games.cakewars.shop.CakeResource;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeTeam;
|
import nautilus.game.arcade.game.games.cakewars.shop.CakeTeamItem;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeTeamItem;
|
import nautilus.game.arcade.game.games.cakewars.team.CakeTeam;
|
||||||
import nautilus.game.arcade.game.games.cakewars.data.CakeTeamItemType;
|
|
||||||
|
|
||||||
public class CakeResourceStarPage extends CakeResourcePage
|
public class CakeResourceStarPage extends CakeResourcePage
|
||||||
{
|
{
|
||||||
@ -44,21 +43,47 @@ public class CakeResourceStarPage extends CakeResourcePage
|
|||||||
|
|
||||||
for (CakeItem item : _items)
|
for (CakeItem item : _items)
|
||||||
{
|
{
|
||||||
addButton(slot++, prepareItem(item), new CakeTeamItemButton((CakeTeamItem) item));
|
CakeTeamItem teamItem = (CakeTeamItem) item;
|
||||||
|
CakeShopResult result = getResultPurchase(teamItem);
|
||||||
|
|
||||||
|
addButton(slot, prepareItem(item, result), new CakeTeamItemButton(teamItem, result));
|
||||||
|
|
||||||
|
if (++slot % 9 == 8)
|
||||||
|
{
|
||||||
|
slot += 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
ItemStack prepareItem(CakeItem item)
|
CakeShopResult getResultPurchase(CakeItem item)
|
||||||
|
{
|
||||||
|
CakeTeamItem teamItem = (CakeTeamItem) item;
|
||||||
|
int level = _cakeTeam.getUpgrades().get(item);
|
||||||
|
ItemStack itemStack = _resource.getItemStack();
|
||||||
|
|
||||||
|
if (level == teamItem.getCosts().length)
|
||||||
|
{
|
||||||
|
return CakeShopResult.MAX_TIER;
|
||||||
|
}
|
||||||
|
else if (!UtilInv.contains(_player, itemStack.getType(), itemStack.getData().getData(), teamItem.getCosts()[level]))
|
||||||
|
{
|
||||||
|
return CakeShopResult.NOT_ENOUGH_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CakeShopResult.SUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ItemStack prepareItem(CakeItem item, CakeShopResult result)
|
||||||
{
|
{
|
||||||
CakeTeamItem teamItem = (CakeTeamItem) item;
|
CakeTeamItem teamItem = (CakeTeamItem) item;
|
||||||
ItemBuilder builder = new ItemBuilder(item.getItemStack());
|
ItemBuilder builder = new ItemBuilder(item.getItemStack());
|
||||||
int level = _cakeTeam.getUpgrades().get(item);
|
int level = _cakeTeam.getUpgrades().get(item);
|
||||||
boolean canPurchase = canPurchase(_player, teamItem, level);
|
|
||||||
boolean maxTier = teamItem.getCosts().length == level;
|
|
||||||
String name = C.mItem + teamItem.getName();
|
String name = C.mItem + teamItem.getName();
|
||||||
|
boolean maxTier = result == CakeShopResult.MAX_TIER;
|
||||||
|
|
||||||
if (teamItem.getType() == CakeTeamItemType.PASSIVE_UPGRADE && !maxTier)
|
if (!maxTier)
|
||||||
{
|
{
|
||||||
name += " " + UtilText.toRomanNumeral(level + 1);
|
name += " " + UtilText.toRomanNumeral(level + 1);
|
||||||
}
|
}
|
||||||
@ -67,16 +92,7 @@ public class CakeResourceStarPage extends CakeResourcePage
|
|||||||
|
|
||||||
if (maxTier)
|
if (maxTier)
|
||||||
{
|
{
|
||||||
builder.addLore("");
|
builder.addLore("", C.cRed + result.getColour() + result.getFeedback());
|
||||||
|
|
||||||
if (teamItem.getType() != CakeTeamItemType.PASSIVE_UPGRADE)
|
|
||||||
{
|
|
||||||
builder.addLore(C.cRed + "You have already purchased this", C.cRed + "consumable upgrade.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
builder.addLore(C.cRed + "You have already purchased the maximum", C.cRed + "tier for this upgrade.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -84,7 +100,7 @@ public class CakeResourceStarPage extends CakeResourcePage
|
|||||||
"",
|
"",
|
||||||
"Cost: " + _resource.getChatColor() + teamItem.getCosts()[level] + " " + _resource.getName() + "s",
|
"Cost: " + _resource.getChatColor() + teamItem.getCosts()[level] + " " + _resource.getName() + "s",
|
||||||
"",
|
"",
|
||||||
canPurchase ? C.cGreen + "Click to purchase!" : C.cRed + "You do not have enough resources!"
|
result.getColour() + result.getFeedback()
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -92,26 +108,18 @@ public class CakeResourceStarPage extends CakeResourcePage
|
|||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canPurchase(Player player, CakeTeamItem item, int level)
|
|
||||||
{
|
|
||||||
if (item.getCosts().length <= level)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack resource = _resource.getItemStack();
|
|
||||||
|
|
||||||
return UtilInv.contains(player, resource.getType(), resource.getData().getData(), item.getCosts()[level]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CakeTeamItemButton implements IButton
|
private class CakeTeamItemButton implements IButton
|
||||||
{
|
{
|
||||||
|
|
||||||
private final CakeTeamItem _item;
|
private final CakeTeamItem _item;
|
||||||
|
private final CakeShopResult _result;
|
||||||
|
private final int _level;
|
||||||
|
|
||||||
CakeTeamItemButton(CakeTeamItem item)
|
CakeTeamItemButton(CakeTeamItem item, CakeShopResult result)
|
||||||
{
|
{
|
||||||
_item = item;
|
_item = item;
|
||||||
|
_result = result;
|
||||||
|
_level = _cakeTeam.getUpgrades().get(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -121,37 +129,18 @@ public class CakeResourceStarPage extends CakeResourcePage
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (_result != CakeShopResult.SUCCESSFUL)
|
||||||
int level = _cakeTeam.getUpgrades().get(_item);
|
|
||||||
ItemStack resource = _resource.getItemStack();
|
|
||||||
|
|
||||||
if (_item.getCosts().length == level)
|
|
||||||
{
|
{
|
||||||
if (_item.getType() != CakeTeamItemType.PASSIVE_UPGRADE)
|
player.sendMessage(F.main("Game", _result.getFeedback()));
|
||||||
{
|
playDenySound(player);
|
||||||
player.sendMessage(F.main("Game", "You already have purchased this consumable upgrade."));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.sendMessage(F.main("Game", "You have already purchased the maximum tier for this upgrade."));
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UtilInv.remove(player, resource.getType(), resource.getData().getData(), _item.getCosts()[level]))
|
ItemStack resource = _resource.getItemStack();
|
||||||
{
|
UtilInv.remove(player, resource.getType(), resource.getData().getData(), _item.getCosts()[_level]);
|
||||||
String name;
|
|
||||||
int newLevel = level + 1;
|
|
||||||
|
|
||||||
if (_item.getType() != CakeTeamItemType.PASSIVE_UPGRADE)
|
|
||||||
{
|
|
||||||
name = F.name(_item.getName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
name = F.name(_item.getName() + " " + UtilText.toRomanNumeral(newLevel));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
int newLevel = _level + 1;
|
||||||
|
String name = F.name(_item.getName() + " " + UtilText.toRomanNumeral(newLevel));
|
||||||
String message = F.main("Game", F.color(_player.getName(), _team.GetColor().toString()) + " purchased the " + name + " team upgrade.");
|
String message = F.main("Game", F.color(_player.getName(), _team.GetColor().toString()) + " purchased the " + name + " team upgrade.");
|
||||||
|
|
||||||
for (Player other : _team.GetPlayers(false))
|
for (Player other : _team.GetPlayers(false))
|
||||||
@ -166,7 +155,7 @@ public class CakeResourceStarPage extends CakeResourcePage
|
|||||||
|
|
||||||
for (Entry<CakeTeamItem, Integer> entry : _cakeTeam.getUpgrades().entrySet())
|
for (Entry<CakeTeamItem, Integer> entry : _cakeTeam.getUpgrades().entrySet())
|
||||||
{
|
{
|
||||||
if (entry.getValue() != entry.getKey().getCosts().length && entry.getKey().getType() == CakeTeamItemType.PASSIVE_UPGRADE)
|
if (entry.getValue() != entry.getKey().getCosts().length)
|
||||||
{
|
{
|
||||||
ownsAll = false;
|
ownsAll = false;
|
||||||
break;
|
break;
|
||||||
@ -187,11 +176,5 @@ public class CakeResourceStarPage extends CakeResourcePage
|
|||||||
playAcceptSound(player);
|
playAcceptSound(player);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
player.sendMessage(F.main("Game", "You do not have enough " + F.name(_resource.getName() + "s") + " to purchase this upgrade."));
|
|
||||||
playDenySound(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user