From 7b70695e12298e729c4c8dfd34c074cb28c16732 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 4 May 2017 18:40:57 -0400 Subject: [PATCH] Update arcade games with new crown/gem toggle and flint and steel permission flag --- .../nautilus/game/arcade/ArcadeManager.java | 16 +++++-- .../src/nautilus/game/arcade/game/Game.java | 5 ++ .../game/arcade/managers/GameFlagManager.java | 6 +++ .../arcade/managers/GameRewardManager.java | 48 +++++++++++++------ 4 files changed, 55 insertions(+), 20 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 20c226a03..d1aeddf52 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -4,8 +4,6 @@ import java.io.File; import java.util.ArrayList; import java.util.HashSet; -import net.minecraft.server.v1_8_R3.EntityLiving; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -123,7 +121,6 @@ import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; import mineplex.serverdata.Region; - import nautilus.game.arcade.addons.SoupAddon; import nautilus.game.arcade.booster.GameBoosterManager; import nautilus.game.arcade.command.CancelNextGameCommand; @@ -168,6 +165,7 @@ import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; import nautilus.game.arcade.managers.lobby.legacy.LegacyGameLobbyManager; import nautilus.game.arcade.player.ArcadePlayer; import nautilus.game.arcade.shop.ArcadeShop; +import net.minecraft.server.v1_8_R3.EntityLiving; public class ArcadeManager extends MiniPlugin implements IRelation { @@ -495,7 +493,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation scoreboard.get(ArcadeScoreboardLine.PLAYERS_NAME).write(C.cYellow + C.Bold + "Players"); scoreboard.get(ArcadeScoreboardLine.KIT_NAME).write(C.cGray + C.Bold + "Kit"); - scoreboard.get(ArcadeScoreboardLine.GEM_NAME).write(C.cGreen + C.Bold + "Gems"); scoreboard.get(ArcadeScoreboardLine.SERVER_NAME).write(C.cAqua + C.Bold + "Server"); scoreboard.get(ArcadeScoreboardLine.SERVER_VALUE).write(_plugin.getConfig().getString("serverstatus.name")); } @@ -520,7 +517,16 @@ public class ArcadeManager extends MiniPlugin implements IRelation } scoreboard.get(ArcadeScoreboardLine.PLAYERS_VALUE).write(_gameManager.getValidPlayersForGameStart().size() + "/" + GetPlayerFull()); - scoreboard.get(ArcadeScoreboardLine.GEM_VALUE).write(donationManager.Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM)); + if (GetGame() != null && GetGame().CrownsEnabled) + { + scoreboard.get(ArcadeScoreboardLine.GEM_NAME).write(C.cGold + C.Bold + "Crowns"); + scoreboard.get(ArcadeScoreboardLine.GEM_VALUE).write(donationManager.getCrowns(scoreboard.getOwner())); + } + else + { + scoreboard.get(ArcadeScoreboardLine.GEM_NAME).write(C.cGreen + C.Bold + "Gems"); + scoreboard.get(ArcadeScoreboardLine.GEM_VALUE).write(donationManager.Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM)); + } if (GetGame() != null) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 89fe831d5..90d008a25 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -252,6 +252,8 @@ public abstract class Game extends ListenerComponent implements Lifetimed public boolean WorldSoilTrample = false; public boolean WorldBoneMeal = false; public boolean WorldChunkUnload = false; + + public boolean AllowFlintAndSteel = false; public int HungerSet = -1; public int HealthSet = -1; @@ -316,6 +318,8 @@ public abstract class Game extends ListenerComponent implements Lifetimed public final ChatStatData BlankLine = new ChatStatData().blankLine(); // Gems + public boolean CrownsEnabled = false; + public double GemMultiplier = 1; public boolean GemHunterEnabled = true; public boolean GemBoosterEnabled = true; @@ -334,6 +338,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public Location SpectatorSpawn = null; public boolean FirstKill = true; + public int FirstKillReward = 10; public String Winner = "Nobody"; public GameTeam WinnerTeam = null; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index b7a2119d0..68791ddff 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -54,6 +54,7 @@ import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockGrowEvent; import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.entity.CreatureSpawnEvent; @@ -1172,6 +1173,11 @@ public class GameFlagManager implements Listener if (game.WorldFireSpread) return; + if (event.getCause() == IgniteCause.FLINT_AND_STEEL && game.AllowFlintAndSteel) + { + return; + } + event.setCancelled(true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java index f1834bdaf..2e5e4fbdf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java @@ -80,7 +80,7 @@ public class GameRewardManager implements Listener //First Kill if (game.FirstKill) { - game.AddGems(killer, 10, "First Blood", false, false); + game.AddGems(killer, game.FirstKillReward, "First Blood", false, false); Manager.getPluginManager().callEvent(new FirstBloodEvent(killer)); @@ -191,7 +191,7 @@ public class GameRewardManager implements Listener } // Gem Finder - if (game.GemHunterEnabled) + if (game.GemHunterEnabled && !game.CrownsEnabled) { int gemFinder = Manager.GetAchievement().get(player, Achievement.GLOBAL_GEM_HUNTER).getLevel(); if (gemFinder > 0) @@ -216,7 +216,7 @@ public class GameRewardManager implements Listener } } - if (DoubleGem && game.GemDoubleEnabled) + if (DoubleGem && game.GemDoubleEnabled && !game.CrownsEnabled) gemsToReward += baseGemsEarned; Rank rank = Manager.GetClients().Get(player).GetRank(); @@ -232,17 +232,35 @@ public class GameRewardManager implements Listener shardsToReward += baseShardsEarned * 2; else if (rank.has(Rank.ETERNAL)) shardsToReward += baseShardsEarned * 2.5; - - Manager.GetDonation().rewardCurrency(GlobalCurrency.GEM, player, "Earned " + game.GetName(), gemsToReward); + + if (!game.CrownsEnabled) + { + Manager.GetDonation().rewardCurrency(GlobalCurrency.GEM, player, "Earned " + game.GetName(), gemsToReward); + } + else + { + Manager.GetDonation().rewardCrowns(gemsToReward, player); + } if (accountId != -1) { Manager.GetDonation().rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, player, "Earned", shardsToReward); } - Manager.getTrackManager().getTrack(GemCollectorTrack.class).earnedGems(player, gemsToReward); + if (!game.CrownsEnabled) + { + Manager.getTrackManager().getTrack(GemCollectorTrack.class).earnedGems(player, gemsToReward); + } //Stats - Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", gemsToReward); - Manager.GetStatsManager().incrementStat(player, game.GetName() + ".GemsEarned", gemsToReward); + if (!game.CrownsEnabled) + { + Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", gemsToReward); + Manager.GetStatsManager().incrementStat(player, game.GetName() + ".GemsEarned", gemsToReward); + } + else + { + Manager.GetStatsManager().incrementStat(player, "Global.CrownsEarned", gemsToReward); + Manager.GetStatsManager().incrementStat(player, game.GetName() + ".CrownsEarned", gemsToReward); + } } private void changeName(Player player, String newName) @@ -274,7 +292,7 @@ public class GameRewardManager implements Listener UtilPlayer.message(player, ""); UtilPlayer.message(player, ArcadeFormat.Line); - UtilPlayer.message(player, Manager.IsRewardGems() ? "§f§lGems Earned" : "§f§lGame Stats"); + UtilPlayer.message(player, Manager.IsRewardGems() ? (game.CrownsEnabled ? "§f§lCrowns Earned" : "§f§lGems Earned") : "§f§lGame Stats"); UtilPlayer.message(player, ""); int earnedGems = 0; @@ -294,7 +312,7 @@ public class GameRewardManager implements Listener String out = ""; if (Manager.IsRewardGems()) - out += F.elem(C.cGreen + "+" + (int) (gemCount * game.GemMultiplier) + " Gems") + " for "; + out += F.elem((game.CrownsEnabled ? C.cGold : C.cGreen) + "+" + (int) (gemCount * game.GemMultiplier) + (game.CrownsEnabled ? " Crowns" : " Gems")) + " for "; out += F.elem(amountStr + type); UtilPlayer.message(player, out); @@ -313,7 +331,7 @@ public class GameRewardManager implements Listener int totalGems = earnedGems; //Gem Finder - if (game.GemHunterEnabled) + if (game.GemHunterEnabled && !game.CrownsEnabled) { int gemFinder = Manager.GetAchievement().get(player, Achievement.GLOBAL_GEM_HUNTER).getLevel(); if (gemFinder > 0) @@ -341,7 +359,7 @@ public class GameRewardManager implements Listener if (extraGems > 0) { - UtilPlayer.message(player, F.elem(C.cGreen + "+" + extraGems + " Gems") + " for " + + UtilPlayer.message(player, F.elem((game.CrownsEnabled ? C.cGold : C.cGreen) + "+" + extraGems + (game.CrownsEnabled ? " Crowns" : " Gems")) + " for " + F.elem("Online for " + UtilTime.MakeStr(timeOnline) + C.cGreen + " +" + (int) (hoursOnline * 20) + "%")); totalGems += extraGems; @@ -350,7 +368,7 @@ public class GameRewardManager implements Listener } //Double Gem - if (DoubleGem && game.GemDoubleEnabled) + if (DoubleGem && game.GemDoubleEnabled && !game.CrownsEnabled) { UtilPlayer.message(player, F.elem(C.cGreen + "+" + (earnedGems) + " Gems") + " for " + F.elem(C.cDGreen + "Double Gem Weekend")); @@ -393,13 +411,13 @@ public class GameRewardManager implements Listener if (give) { UtilPlayer.message(player, F.elem(C.cWhite + "§lYou now have " + - C.cGreen + C.Bold + (Manager.GetDonation().Get(player.getUniqueId()).getBalance(GlobalCurrency.GEM) + totalGems) + " Gems") + C.cWhite + C.Bold + " and " + + (game.CrownsEnabled ? (C.cGoldB + (Manager.GetDonation().getCrowns(player) + totalGems) + " Crowns") : (C.cGreenB + (Manager.GetDonation().Get(player.getUniqueId()).getBalance(GlobalCurrency.GEM) + totalGems) + " Gems"))) + C.cWhite + C.Bold + " and " + F.elem(C.cAqua + C.Bold + (Manager.GetDonation().Get(player.getUniqueId()).getBalance(GlobalCurrency.TREASURE_SHARD) + shards) + " Treasure Shards")); } else { UtilPlayer.message(player, F.elem(C.cWhite + "§lGame is still in progress...")); - UtilPlayer.message(player, F.elem(C.cWhite + "§lYou may earn more " + C.cGreen + C.Bold + "Gems" + C.cWhite + C.Bold + " when its completed.")); + UtilPlayer.message(player, F.elem(C.cWhite + "§lYou may earn more " + (game.CrownsEnabled ? (C.cGoldB + "Crowns") : (C.cGreenB + "Gems")) + C.cWhite + C.Bold + " when it's completed.")); } UtilPlayer.message(player, ArcadeFormat.Line);