From d5f16bf833286ea53538977cca7978a6ea4e8afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Dasc=C4=83lu?= Date: Sun, 22 Jan 2023 16:07:53 +0100 Subject: [PATCH] First release of 2023 (#640) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Some PAFBungeecord Fixes (#442) fix PAFBungeecord adapter * Register Indonesia Languange on start up (#452) * fix env var passing * Enhance levelling system (#448) * Updated Levelling System * Fixed if with Java convention * Change BED_DESTROYED to BED_DESTROY * workflow update * Update readme to link to wiki for addons/setups (#462) * band-aid fix for ConcurrentModificationException on disable (#460) * [enhancement] Fix Invisibility Potions on 1.8 and some cosmetic changes (#408) * Make titles smoothly fade out * What was the point for such long cooldown? * Fix english grammar error * Fix Invisibility Potion not working on 1_8_R3 * Revert "What was the point for such long cooldown?" This reverts commit f66e035e827806dae87b2ac6f0857dffc0c46ab7. Co-authored-by: MarcelDutko <32849144+MarcelDutko@users.noreply.github.com> * Implement command for set max build Y (#428) * TeamEliminatedEvent (#465) * Update deprecated versions (#495) * fix arenaGroup list command requiring unnecisary args (#484) * register forgotten listener * allow enabling of hunger (#485) * Reload command in console (#506) * Make reload command executable by console * Inline the Player casting * update #canSee so console sees the command i find really no need to retest this but whatever * Remove unused import + fix a typo * Italian Language Update (#501) * Fix traps not activating when someone is on island (#546) * Update stuff (#545) * Update Repos/Maven Plugins and fix some build warning * Remove old Gitlab stuff * 17.0.3 Workflow * Didn't mean to remove this * Java 11 Minimum Requirement (#541) * Fix Players sometimes can't Pickup items (#530) Fixes #520 * Remove Support for: (#538) 1.9.4 (v1_9_R2) 1.10 - 1.10.2 (v1_10_R1) 1.11 (v1_11_R1) 1.13.1 - 1.13.2 (v1_13_R2) 1.14 - 1.14.2 (v1_14_R1) 1.15 - 1.15.2 (v1_15_R1) 1.16.1 - 1.16.3 (v1_16_R1/2) * Fix Red not auto-scanning (#519) * Fix Red not auto-scanning * Fix Red not auto-scanning Co-authored-by: Bart Co-authored-by: DevSolaris * Fix readme for Java 11 (#556) * Use NMS and Don't call event when player is afk to save resources (#584) * Update Spanish.java (#523) * Fix Light Gray (#518) Co-authored-by: Bart * Fixes issues with invsibility potion and armor & bug with inv. shop when click on bottom inv (#590) * Fix shop interacting through own inventory * Fix visible armor when drink invisibility potion * Fix stats placeholder throwing exceptions when a player is unloaded + a small cleanup (#567) * fixed citizens repo (#609) * Fixed the nms setSource method in versions: 1_17_R1 and 1_18_R2 (#615) * Fixed source field's name * Fixed source field's name * Remove Spigot Update Checker (no longer use spigotmc) (#616) * Remove Spigot Update Checker (no longer use spigotmc) * Updates * Add the Max in team placeholder to the signs (#594) * Add the Max in team placeholder to the signs * Bug fix on server restart Co-authored-by: Angel * Cancel Pickup if player is AFK and remove extra listener (#587) * Cancel Pickup if player is AFK and remove extra listener * Forgot * SidebarLib implementation and 1.19.3 support (#617) implement sidebar lib, add 1.19.3 support * Money bug fix (#585) sync with main thread, clean up threads * Money fix (#582) give rewards if greater than zero, do not give rewards for team assist on solo * Make Armor shop message say equipped (#565) make armor-shop say equipped and not maxed as that does not make sense for armor * implement async teleport on paper servers (#561) implement async teleport on paper servers * Built in Pop-Up tower (#496) * prevent generators from spawning on game end, clean inventories and dropped items (#487) prevent generators from spawning on game end, clean inventories and dropped items * Built-in heal pool animations (#467) * Polish translation update (#431) * fix: could not pass event PlayerJoinEvent fix NullPointerException at player join when game has no set arena yet Co-authored-by: J.T. McQuigg Co-authored-by: JektDV Co-authored-by: Xxyuri2005xX <84080587+Xxyuri2005xX@users.noreply.github.com> Co-authored-by: ajgeiss0702 Co-authored-by: Marcelektro <32849144+Marcelektro@users.noreply.github.com> Co-authored-by: MarcelDutko <32849144+MarcelDutko@users.noreply.github.com> Co-authored-by: Ricardo <63428864+reussy@users.noreply.github.com> Co-authored-by: iiAhmedYT <61851106+iiAhmedYT@users.noreply.github.com> Co-authored-by: Memexurer Co-authored-by: IIHERO4 <46909116+IIHERO4@users.noreply.github.com> Co-authored-by: DevSolaris <105156235+DevSolaris@users.noreply.github.com> Co-authored-by: Bart Co-authored-by: DevSolaris Co-authored-by: Danidev819 <38832869+Danidev819@users.noreply.github.com> Co-authored-by: Zoiter7 Co-authored-by: Doãn Hiệp <33453150+dhiepp@users.noreply.github.com> Co-authored-by: PmzHeroV69 <91284999+PmzHeroV69@users.noreply.github.com> Co-authored-by: Angelillo15 <43421778+Angelillo15@users.noreply.github.com> Co-authored-by: Angel Co-authored-by: Seriously Not Beluga <79474077+OskiBoski483@users.noreply.github.com> Co-authored-by: jonathan-up Co-authored-by: MrCeasar --- .github/workflows/compile_snapshot.yml | 4 +- .github/workflows/deploy.yml | 4 +- .github/workflows/deploy_snapshot.yml | 4 +- README.md | 2 +- bedwars-api/pom.xml | 16 +- .../bedwars/api/arena/team/TeamColor.java | 4 +- .../bedwars/api/configuration/ConfigPath.java | 7 + .../bedwars/api/language/Language.java | 13 +- .../bedwars/api/language/Messages.java | 24 + .../bedwars/api/server/VersionSupport.java | 8 + bedwars-plugin/pom.xml | 86 +- .../main/java/com/andrei1058/bedwars/API.java | 16 +- .../java/com/andrei1058/bedwars/BedWars.java | 46 +- .../com/andrei1058/bedwars/arena/Arena.java | 87 +- .../bedwars/arena/OreGenerator.java | 7 +- .../bedwars/arena/SetupSession.java | 7 +- .../bedwars/arena/tasks/GamePlayingTask.java | 1 - .../bedwars/arena/team/BedWarsTeam.java | 5 +- .../bedwars/arena/upgrades/BaseListener.java | 2 - .../arena/upgrades/HealPoolListner.java | 48 + .../bedwars/arena/upgrades/HealPoolTask.java | 124 +++ .../com/andrei1058/bedwars/commands/Misc.java | 3 +- .../bedwars/subcmds/regular/CmdTpStaff.java | 3 +- .../sensitive/setup/AutoCreateTeams.java | 2 +- .../bedwars/subcmds/sensitive/setup/Save.java | 5 +- .../subcmds/sensitive/setup/SetSpawn.java | 3 +- .../bedwars/configuration/MainConfig.java | 5 + .../bedwars/configuration/SignsConfig.java | 2 +- .../bedwars/configuration/Sounds.java | 7 + .../andrei1058/bedwars/language/Bangla.java | 21 +- .../andrei1058/bedwars/language/English.java | 23 +- .../andrei1058/bedwars/language/Hindi.java | 20 +- .../bedwars/language/Indonesia.java | 20 +- .../andrei1058/bedwars/language/Italian.java | 21 +- .../bedwars/language/LangListener.java | 4 +- .../andrei1058/bedwars/language/Persian.java | 21 +- .../andrei1058/bedwars/language/Polish.java | 79 +- .../bedwars/language/Portuguese.java | 21 +- .../andrei1058/bedwars/language/Romanian.java | 21 +- .../andrei1058/bedwars/language/Russian.java | 21 +- .../andrei1058/bedwars/language/Spanish.java | 53 +- .../andrei1058/bedwars/language/Turkish.java | 21 +- .../bedwars/listeners/BreakPlace.java | 42 +- .../bedwars/listeners/DamageDeathMove.java | 14 +- .../bedwars/listeners/GameEndListener.java | 36 + .../listeners/InvisibilityPotionListener.java | 25 +- .../listeners/QuitAndTeleportListener.java | 14 +- .../joinhandler/JoinListenerBungee.java | 3 +- .../joinhandler/JoinListenerMultiArena.java | 8 +- .../joinhandler/JoinListenerShared.java | 4 +- .../money/internal/MoneyListeners.java | 73 +- .../money/internal/MoneyPerMinuteTask.java | 12 +- .../bedwars/popuptower/NewPlaceBlock.java | 34 + .../bedwars/popuptower/TowerEast.java | 167 ++++ .../bedwars/popuptower/TowerNorth.java | 168 ++++ .../bedwars/popuptower/TowerSouth.java | 168 ++++ .../bedwars/popuptower/TowerWest.java | 168 ++++ .../andrei1058/bedwars/shop/ShopManager.java | 8 + .../shop/listeners/InventoryListener.java | 42 +- .../bedwars/shop/main/CategoryContent.java | 6 +- .../bedwars/sidebar/BedWarsScoreboard.java | 675 -------------- .../andrei1058/bedwars/sidebar/BwSidebar.java | 638 ++++++++++++++ .../bedwars/sidebar/ScoreboardListener.java | 39 +- .../bedwars/sidebar/SidebarService.java | 182 ++++ .../RefreshLifeTask.java} | 12 +- .../RefreshPlaceholdersTask.java} | 12 +- .../RefreshTabListTask.java} | 14 +- .../RefreshTitleTask.java} | 17 +- .../bedwars/stats/StatsManager.java | 7 +- .../bedwars/support/paper/PaperSupport.java | 35 + .../bedwars/support/papi/PAPISupport.java | 131 +-- bedwars_mysql_remake.drawio | 27 - pom.xml | 15 +- resetadapter_slime/pom.xml | 2 +- versionsupport_1_12_R1/pom.xml | 2 +- .../support/version/v1_12_R1/v1_12_R1.java | 20 + versionsupport_1_8_R3/pom.xml | 2 +- .../support/version/v1_8_R3/v1_8_R3.java | 21 + versionsupport_common/pom.xml | 4 +- .../listeners/ItemDropPickListener.java | 27 +- .../listeners/PlayerDropPick_1_11Minus.java | 27 +- .../support/version/common/VersionCommon.java | 2 +- versionsupport_v1_16_R3/pom.xml | 2 +- .../support/version/v1_16_R3/v1_16_R3.java | 41 +- versionsupport_v1_17_R1/pom.xml | 2 +- .../support/version/v1_17_R1/v1_17_R1.java | 46 +- .../pom.xml | 6 +- .../support/version/v1_18_R2}/IGolem.java | 26 +- .../support/version/v1_18_R2}/Silverfish.java | 24 +- .../support/version/v1_18_R2/v1_18_R2.java | 139 +-- versionsupport_v1_19_R2/pom.xml | 64 ++ .../despawnable/DespawnableAttributes.java | 5 + .../despawnable/DespawnableFactory.java | 27 + .../despawnable/DespawnableProvider.java | 71 ++ .../v1_19_R2/despawnable/DespawnableType.java | 6 + .../v1_19_R2/despawnable/TeamIronGolem.java | 58 ++ .../v1_19_R2/despawnable/TeamSilverfish.java | 56 ++ .../support/version/v1_19_R2/v1_19_R2.java | 830 ++++++++++++++++++ 98 files changed, 3933 insertions(+), 1264 deletions(-) create mode 100644 bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/HealPoolListner.java create mode 100644 bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/HealPoolTask.java create mode 100644 bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/GameEndListener.java create mode 100644 bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/NewPlaceBlock.java create mode 100644 bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerEast.java create mode 100644 bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerNorth.java create mode 100644 bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerSouth.java create mode 100644 bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerWest.java delete mode 100644 bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/BedWarsScoreboard.java create mode 100644 bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/BwSidebar.java create mode 100644 bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarService.java rename bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/{SidebarTitleRefresh.java => thread/RefreshLifeTask.java} (73%) rename bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/{SidebarListRefresh.java => thread/RefreshPlaceholdersTask.java} (72%) rename bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/{SidebarPlaceholderRefresh.java => thread/RefreshTabListTask.java} (67%) rename bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/{SidebarLifeRefresh.java => thread/RefreshTitleTask.java} (57%) create mode 100644 bedwars-plugin/src/main/java/com/andrei1058/bedwars/support/paper/PaperSupport.java delete mode 100644 bedwars_mysql_remake.drawio rename {versionsupport_v1_18_R1 => versionsupport_v1_18_R2}/pom.xml (92%) rename {versionsupport_v1_18_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R1 => versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2}/IGolem.java (86%) rename {versionsupport_v1_18_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R1 => versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2}/Silverfish.java (87%) rename versionsupport_v1_18_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R1/v1_18_R1.java => versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2/v1_18_R2.java (88%) create mode 100644 versionsupport_v1_19_R2/pom.xml create mode 100644 versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableAttributes.java create mode 100644 versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableFactory.java create mode 100644 versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableProvider.java create mode 100644 versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableType.java create mode 100644 versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/TeamIronGolem.java create mode 100644 versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/TeamSilverfish.java create mode 100644 versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/v1_19_R2.java diff --git a/.github/workflows/compile_snapshot.yml b/.github/workflows/compile_snapshot.yml index b323f4576..683cb18d1 100644 --- a/.github/workflows/compile_snapshot.yml +++ b/.github/workflows/compile_snapshot.yml @@ -15,10 +15,10 @@ jobs: url: https://repo.andrei1058.dev steps: - uses: actions/checkout@v2 - - name: Set up JDK 17.0.3 + - name: Set up JDK 17.0.5 uses: actions/setup-java@v2 with: - java-version: '17.0.3' + java-version: '17.0.5' distribution: 'adopt' - name: Deploy snapshot with Maven env: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b3270313f..74211a889 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,10 +12,10 @@ jobs: url: https://repo.andrei1058.com steps: - uses: actions/checkout@v2 - - name: Set up JDK 17.0.3 + - name: Set up JDK 17.0.5 uses: actions/setup-java@v2 with: - java-version: '17.0.3' + java-version: '17.0.5' distribution: 'adopt' - name: Deploy with Maven env: diff --git a/.github/workflows/deploy_snapshot.yml b/.github/workflows/deploy_snapshot.yml index a6cd3f8c9..0d5575620 100644 --- a/.github/workflows/deploy_snapshot.yml +++ b/.github/workflows/deploy_snapshot.yml @@ -14,10 +14,10 @@ jobs: url: https://repo.andrei1058.dev steps: - uses: actions/checkout@v2 - - name: Set up JDK 17.0.3 + - name: Set up JDK 17.0.5 uses: actions/setup-java@v2 with: - java-version: '17.0.3' + java-version: '17.0.5' distribution: 'adopt' - name: Deploy snapshot with Maven env: diff --git a/README.md b/README.md index bc33d4cc3..7d70ec8cf 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Once your bed is destroyed, you cannot respawn. This software runs on [Spigot](https://www.spigotmc.org/) and NMS. Spigot forks without compiled NMS code are not supported. Officially supported servers are [spigot](https://www.spigotmc.org/) and [paper](https://papermc.io/). -It is recommended to use Java 11. +It is required to use Java 11 or newer. The internal world restore system is based on zipping and unzipping maps which can become heavy if you are still making use of HDD in 2021, and you do not have a decent CPU, for a better diff --git a/bedwars-api/pom.xml b/bedwars-api/pom.xml index 22cb4b4ed..0c192924e 100644 --- a/bedwars-api/pom.xml +++ b/bedwars-api/pom.xml @@ -5,7 +5,7 @@ BedWars1058 com.andrei1058.bedwars - 22.3-SNAPSHOT + 22.9-SNAPSHOT 4.0.0 bedwars-api @@ -36,6 +36,12 @@ 1.8.8-R0.1-SNAPSHOT provided + + org.spigotmc + spigot + 1.16.3-R0.1-SNAPSHOT + compile + @@ -51,6 +57,14 @@ false + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + \ No newline at end of file diff --git a/bedwars-api/src/main/java/com/andrei1058/bedwars/api/arena/team/TeamColor.java b/bedwars-api/src/main/java/com/andrei1058/bedwars/api/arena/team/TeamColor.java index 9459ec653..59750c9d1 100644 --- a/bedwars-api/src/main/java/com/andrei1058/bedwars/api/arena/team/TeamColor.java +++ b/bedwars-api/src/main/java/com/andrei1058/bedwars/api/arena/team/TeamColor.java @@ -234,7 +234,7 @@ public static String enName(@NotNull String material) { name = "Red"; break; case "LIGHT_GRAY_WOOL": - name = "lGray"; + name = "Gray"; break; case "BLUE_WOOL": name = "Blue"; @@ -252,7 +252,7 @@ public static String enName(@NotNull String material) { name = "Yellow"; break; case "GRAY_WOOL": - name = "Gray"; + name = "Dark_Gray"; break; } return name; diff --git a/bedwars-api/src/main/java/com/andrei1058/bedwars/api/configuration/ConfigPath.java b/bedwars-api/src/main/java/com/andrei1058/bedwars/api/configuration/ConfigPath.java index 3ba541dbf..905804db7 100644 --- a/bedwars-api/src/main/java/com/andrei1058/bedwars/api/configuration/ConfigPath.java +++ b/bedwars-api/src/main/java/com/andrei1058/bedwars/api/configuration/ConfigPath.java @@ -228,10 +228,17 @@ public class ConfigPath { public static final String GENERAL_CONFIGURATION_PERFORMANCE_ROTATE_GEN = GENERAL_CONFIGURATION_PERFORMANCE_PATH + ".rotate-generators"; public static final String GENERAL_CONFIGURATION_PERFORMANCE_SPOIL_TNT_PLAYERS = GENERAL_CONFIGURATION_PERFORMANCE_PATH + ".spoil-tnt-players"; + public static final String GENERAL_CONFIGURATION_PERFORMANCE_PAPER_FEATURES = GENERAL_CONFIGURATION_PERFORMANCE_PATH + ".paper-features"; + + private static final String GENERAL_CONFIGURATION_HEAL_POOL = GENERAL_CONFIGURATION_PERFORMANCE_PATH+".heal-pool"; + public static final String GENERAL_CONFIGURATION_HEAL_POOL_ENABLE = GENERAL_CONFIGURATION_HEAL_POOL+".enable"; + public static final String GENERAL_CONFIGURATION_HEAL_POOL_SEEN_TEAM_ONLY = GENERAL_CONFIGURATION_HEAL_POOL_ENABLE+".seen-by-team-only"; public static final String SHOP_SETTINGS_PATH = "shop-settings"; public static final String SHOP_SPECIALS_PATH = "shop-specials"; public static final String SHOP_QUICK_DEFAULTS_PATH = "quick-buy-defaults"; + public static final String SHOP_SPECIAL_TOWER_ENABLE = SHOP_SPECIALS_PATH + ".tower.enable"; + public static final String SHOP_SPECIAL_TOWER_MATERIAL = SHOP_SPECIALS_PATH + ".tower.material"; public static final String SHOP_SPECIAL_SILVERFISH_ENABLE = SHOP_SPECIALS_PATH + ".silverfish.enable"; public static final String SHOP_SPECIAL_SILVERFISH_MATERIAL = SHOP_SPECIALS_PATH + ".silverfish.material"; public static final String SHOP_SPECIAL_SILVERFISH_DATA = SHOP_SPECIALS_PATH + ".silverfish.data"; diff --git a/bedwars-api/src/main/java/com/andrei1058/bedwars/api/language/Language.java b/bedwars-api/src/main/java/com/andrei1058/bedwars/api/language/Language.java index 02d4d87e1..1c24417e6 100644 --- a/bedwars-api/src/main/java/com/andrei1058/bedwars/api/language/Language.java +++ b/bedwars-api/src/main/java/com/andrei1058/bedwars/api/language/Language.java @@ -39,6 +39,7 @@ public class Language extends ConfigManager { private static final HashMap langByPlayer = new HashMap<>(); private static final List languages = new ArrayList<>(); private static Language defaultLanguage; + private String serverIp; public Language(Plugin plugin, String iso) { super(plugin, "messages_" + iso, plugin.getDataFolder().getPath() + "/Languages"); @@ -136,7 +137,17 @@ public String m(String path) { System.err.println("Missing message key " + path + " in language " + getIso()); message = "MISSING_LANG"; } - return ChatColor.translateAlternateColorCodes('&', message.replace("{prefix}", prefix)); + if (null == serverIp) { + BedWars api = Bukkit.getServicesManager().getRegistration(BedWars.class).getProvider(); + if (null != api.getConfigs().getMainConfig()) { + serverIp = api.getConfigs().getMainConfig(). + getString(ConfigPath.GENERAL_CONFIG_PLACEHOLDERS_REPLACEMENTS_SERVER_IP); + } + } + + return ChatColor.translateAlternateColorCodes('&', message.replace("{prefix}", (prefix == null? "":prefix)) + .replace("{serverIp}", serverIp == null ? "" : serverIp) + ); } /** diff --git a/bedwars-api/src/main/java/com/andrei1058/bedwars/api/language/Messages.java b/bedwars-api/src/main/java/com/andrei1058/bedwars/api/language/Messages.java index a9ce59d04..29c2d0706 100644 --- a/bedwars-api/src/main/java/com/andrei1058/bedwars/api/language/Messages.java +++ b/bedwars-api/src/main/java/com/andrei1058/bedwars/api/language/Messages.java @@ -23,6 +23,7 @@ import com.andrei1058.bedwars.api.configuration.ConfigPath; @SuppressWarnings("WeakerAccess") +@Deprecated public class Messages { public static String PREFIX = "prefix"; @@ -169,10 +170,32 @@ public class Messages { public static String FORMATTING_SCOREBOARD_TAB_SUFFIX_STARTING = "format-sb-tab-suffix.starting"; public static String FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING = "format-sb-tab-prefix.playing"; public static String FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING = "format-sb-tab-suffix.playing"; + + public static String FORMATTING_SIDEBAR_TAB_HEADER_LOBBY = "format-sb-tab-header.lobby"; + public static String FORMATTING_SIDEBAR_TAB_HEADER_WAITING = "format-sb-tab-header.waiting"; + public static String FORMATTING_SIDEBAR_TAB_HEADER_STARTING = "format-sb-tab-header.starting"; + public static String FORMATTING_SIDEBAR_TAB_HEADER_PLAYING = "format-sb-tab-header.playing"; + public static String FORMATTING_SIDEBAR_TAB_HEADER_RESTARTING = "format-sb-tab-header.restarting"; + public static String FORMATTING_SIDEBAR_TAB_HEADER_SPECTATOR = "format-sb-tab-header.spectator"; + + public static String FORMATTING_SIDEBAR_TAB_FOOTER_LOBBY = "format-sb-tab-footer.lobby"; + public static String FORMATTING_SIDEBAR_TAB_FOOTER_WAITING = "format-sb-tab-footer.waiting"; + public static String FORMATTING_SIDEBAR_TAB_FOOTER_STARTING = "format-sb-tab-footer.starting"; + public static String FORMATTING_SIDEBAR_TAB_FOOTER_PLAYING = "format-sb-tab-footer.playing"; + public static String FORMATTING_SIDEBAR_TAB_FOOTER_RESTARTING = "format-sb-tab-footer.restarting"; + public static String FORMATTING_SIDEBAR_TAB_FOOTER_SPECTATOR = "format-sb-tab-footer.spectator"; + @Deprecated public static String FORMATTING_SCOREBOARD_TAB_PREFIX_PRESTARTING = "format-sb-tab-prefix.restarting"; + public static String FORMATTING_SCOREBOARD_TAB_PREFIX_RESTARTING = "format-sb-tab-prefix.restarting"; + @Deprecated public static String FORMATTING_SCOREBOARD_TAB_SUFFIX_PRESTARTING = "format-sb-tab-suffix.restarting"; + public static String FORMATTING_SCOREBOARD_TAB_SUFFIX_RESTARTING = "format-sb-tab-suffix.restarting"; + public static String FORMATTING_SCOREBOARD_TAB_PREFIX_SPECTATOR = "format-sb-tab-prefix.spectator"; + public static String FORMATTING_SCOREBOARD_TAB_SUFFIX_SPECTATOR = "format-sb-tab-suffix.spectator"; public static String FORMATTING_SPECTATOR_TEAM = "format-spectator-team"; + @Deprecated public static String FORMATTING_SPECTATOR_COLOR = "format-spectator-color"; + public static String FORMATTING_SCOREBOARD_TEAM_ELIMINATED = "format-sb-team-eliminated"; public static String FORMATTING_SCOREBOARD_BED_DESTROYED = "format-sb-bed-destroyed"; public static String FORMATTING_SCOREBOARD_TEAM_ALIVE = "format-sb-team-alive"; @@ -333,6 +356,7 @@ public class Messages { public static final String SHOP_LORE_STATUS_CANT_AFFORD = "shop-lore-status-cant-afford"; public static final String SHOP_LORE_STATUS_CAN_BUY = "shop-lore-status-can-buy"; public static final String SHOP_LORE_STATUS_MAXED = "shop-lore-status-tier-maxed"; + public static final String SHOP_LORE_STATUS_ARMOR = "shop-lore-status-armor"; public static final String SHOP_LORE_QUICK_ADD = "shop-lore-quick-add"; public static final String SHOP_LORE_QUICK_REMOVE = "shop-lore-quick-remove"; public static final String SHOP_INDEX_NAME = SHOP_PATH + ".inventory-name"; diff --git a/bedwars-api/src/main/java/com/andrei1058/bedwars/api/server/VersionSupport.java b/bedwars-api/src/main/java/com/andrei1058/bedwars/api/server/VersionSupport.java index c562b5485..2cbc4c4b6 100644 --- a/bedwars-api/src/main/java/com/andrei1058/bedwars/api/server/VersionSupport.java +++ b/bedwars-api/src/main/java/com/andrei1058/bedwars/api/server/VersionSupport.java @@ -50,6 +50,8 @@ public abstract class VersionSupport { private static String name2; + public static String PLUGIN_TAG_GENERIC_KEY = "BedWars1058"; + public static String PLUGIN_TAG_TIER_KEY = "tierIdentifier"; private Effect eggBridge; @@ -435,4 +437,10 @@ public void spigotHidePlayer(Player victim, Player receiver) { public abstract void playRedStoneDot(Player player); public abstract void clearArrowsFromPlayerBody(Player player); + + public abstract void placeTowerBlocks(Block b, IArena a, TeamColor color, int x, int y,int z); + + public abstract void placeLadder(Block b, int x, int y, int z, IArena a, int ladderdata); + + public abstract void playVillagerEffect(Player player, Location location); } diff --git a/bedwars-plugin/pom.xml b/bedwars-plugin/pom.xml index 881810d1b..08b860d67 100644 --- a/bedwars-plugin/pom.xml +++ b/bedwars-plugin/pom.xml @@ -5,7 +5,7 @@ BedWars1058 com.andrei1058.bedwars - 22.3-SNAPSHOT + 22.9-SNAPSHOT 4.0.0 bedwars-plugin @@ -28,16 +28,12 @@ citizens - https://repo.citizensnpcs.co/ + https://maven.citizensnpcs.co/repo placeholderapi https://repo.extendedclip.com/content/repositories/placeholderapi/ - - spigotutils-maven - https://gitlab.com/api/v4/projects/14374071/packages/maven - codemc-public https://repo.codemc.io/repository/maven-public/ @@ -64,15 +60,29 @@ andrei1058-releases - https://repo.andrei1058.com/releases/ + https://repo.andrei1058.dev/releases/ + + + citizens-repo + https://maven.citizensnpcs.co/repo + + + papermc + https://papermc.io/repo/repository/maven-public/ + + io.papermc + paperlib + 1.0.7 + compile + de.simonsator Party-and-Friends-MySQL-Edition-Spigot-API - 1.5.3 + 1.5.4-RELEASE provided @@ -101,7 +111,7 @@ net.citizensnpcs - citizens + citizens-main 2.0.30-SNAPSHOT provided @@ -159,7 +169,12 @@ com.andrei1058.bedwars - versionsupport_v1_18_R1 + versionsupport_v1_18_R2 + ${project.version} + + + com.andrei1058.bedwars + versionsupport_v1_19_R2 ${project.version} @@ -176,7 +191,7 @@ me.clip placeholderapi - 2.11.1 + 2.11.2 provided @@ -185,11 +200,6 @@ [1.0,) true - - com.andrei1058.spigotutils - spigotutils - 1.4-SNAPSHOT - commons-io @@ -214,15 +224,51 @@ org.slf4j slf4j-simple - 1.7.36 + 2.0.5 true com.andrei1058.spigot.sidebar - sidebar-api - 0.3.2-SNAPSHOT + sidebar-base + 22.12 + compile + + + com.andrei1058.spigot.sidebar + sidebar-eight + 22.12 + compile + + + com.andrei1058.spigot.sidebar + sidebar-twelve + 22.12 + compile + + + com.andrei1058.spigot.sidebar + sidebar-sixteen + 22.12 + compile + + + com.andrei1058.spigot.sidebar + sidebar-seventeen + 22.12 + compile + + + com.andrei1058.spigot.sidebar + sidebar-eighteen + 22.12 + compile + + + com.andrei1058.spigot.sidebar + sidebar-nineteen + 22.12 compile @@ -242,7 +288,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.3.0 + 3.4.1 diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/API.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/API.java index 347cbf86c..07393c8a9 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/API.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/API.java @@ -35,13 +35,14 @@ import com.andrei1058.bedwars.arena.SetupSession; import com.andrei1058.bedwars.commands.bedwars.MainCommand; import com.andrei1058.bedwars.shop.main.CategoryContent; -import com.andrei1058.bedwars.sidebar.BedWarsScoreboard; +import com.andrei1058.bedwars.sidebar.SidebarService; import com.andrei1058.bedwars.stats.StatsAPI; import com.andrei1058.bedwars.upgrades.UpgradesManager; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.HashMap; @@ -416,19 +417,12 @@ public File getAddonsPath() { @Override public void removePlayerScoreboard(Player player) { - BedWarsScoreboard scoreboard = BedWarsScoreboard.getSBoard(player.getUniqueId()); - if (null != scoreboard){ - scoreboard.remove(); - } + SidebarService.getInstance().remove(player); } @Override - public void givePlayerScoreboard(Player player, boolean delay) { - BedWarsScoreboard scoreboard = BedWarsScoreboard.getSBoard(player.getUniqueId()); - if (null == scoreboard){ - IArena arena = Arena.getArenaByPlayer(player); - BedWarsScoreboard.giveScoreboard(player, arena, delay); - } + public void givePlayerScoreboard(@NotNull Player player, boolean delay) { + SidebarService.getInstance().giveSidebar(player, Arena.getArenaByPlayer(player), delay); } }; diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java index 49147d584..056d7497e 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java @@ -38,6 +38,7 @@ import com.andrei1058.bedwars.arena.tasks.OneTick; import com.andrei1058.bedwars.arena.tasks.Refresh; import com.andrei1058.bedwars.arena.upgrades.BaseListener; +import com.andrei1058.bedwars.arena.upgrades.HealPoolListner; import com.andrei1058.bedwars.commands.bedwars.MainCommand; import com.andrei1058.bedwars.commands.leave.LeaveCommand; import com.andrei1058.bedwars.commands.party.PartyCommand; @@ -63,6 +64,10 @@ import com.andrei1058.bedwars.money.internal.MoneyListeners; import com.andrei1058.bedwars.shop.ShopManager; import com.andrei1058.bedwars.sidebar.*; +import com.andrei1058.bedwars.sidebar.thread.RefreshTitleTask; +import com.andrei1058.bedwars.sidebar.thread.RefreshPlaceholdersTask; +import com.andrei1058.bedwars.sidebar.thread.RefreshLifeTask; +import com.andrei1058.bedwars.sidebar.thread.RefreshTabListTask; import com.andrei1058.bedwars.stats.StatsManager; import com.andrei1058.bedwars.support.citizens.CitizensListener; import com.andrei1058.bedwars.support.citizens.JoinNPC; @@ -76,7 +81,6 @@ import com.andrei1058.bedwars.support.vault.*; import com.andrei1058.bedwars.support.vipfeatures.VipFeatures; import com.andrei1058.bedwars.support.vipfeatures.VipListeners; -import com.andrei1058.spigotutils.SpigotUpdater; import com.andrei1058.vipfeatures.api.IVipFeatures; import com.andrei1058.vipfeatures.api.MiniGameAlreadyRegistered; import org.bstats.bukkit.Metrics; @@ -115,6 +119,8 @@ public class BedWars extends JavaPlugin { public static BedWars plugin; public static VersionSupport nms; + public static boolean isPaper = false; + private static Party party = new NoParty(); private static Chat chat = new NoChat(); protected static Level level; @@ -145,6 +151,14 @@ public void onLoad() { return; } + try{ + Class.forName("com.destroystokyo.paper.PaperConfig"); + isPaper = true; + } catch (ClassNotFoundException e) { + isPaper = false; + throw new RuntimeException(e); + } + plugin = this; /* Load version support */ @@ -296,7 +310,12 @@ public void onEnable() { // Register events registerEvents(new EnderPearlLanded(), new QuitAndTeleportListener(), new BreakPlace(), new DamageDeathMove(), new Inventory(), new Interact(), new RefreshGUI(), new HungerWeatherSpawn(), new CmdProcess(), - new FireballListener(), new EggBridge(), new SpectatorListeners(), new BaseListener(), new TargetListener(), new LangListener(), new Warnings(this), new ChatAFK()); + new FireballListener(), new EggBridge(), new SpectatorListeners(), new BaseListener(), new TargetListener(), new LangListener(), new Warnings(this), new ChatAFK(), new GameEndListener()); + + if (config.getBoolean(ConfigPath.GENERAL_CONFIGURATION_HEAL_POOL_ENABLE)) { + registerEvents(new HealPoolListner()); + } + if (getServerType() == ServerType.BUNGEE) { if (autoscale) { //registerEvents(new ArenaListeners()); @@ -325,6 +344,7 @@ public void onEnable() { // Register setup-holograms fix registerEvents(new ChunkLoad()); + registerEvents(new InvisibilityPotionListener()); /* Deprecated versions */ switch (version) { @@ -337,7 +357,6 @@ public void onEnable() { case "v1_15_R1": case "v1_16_R1": case "v1_16_R2": - registerEvents(new InvisibilityPotionListener()); Bukkit.getScheduler().runTaskLater(this, () -> System.out.println("\u001B[31m[WARN] BedWars1058 may drop support for this server version in the future.\nSee: https://wiki.andrei1058.dev/docs/BedWars1058/compatibility \u001B[0m"), 40L); break; @@ -534,15 +553,20 @@ public void onEnable() { } } - /* Check updates */ - new SpigotUpdater(this, 50942, true).checkUpdate(); - - Bukkit.getScheduler().runTaskLater(this, () -> getLogger().info("This server is running in " + getServerType().toString() + " with auto-scale " + autoscale), 100L); // Initialize team upgrades com.andrei1058.bedwars.upgrades.UpgradesManager.init(); + // Initialize sidebar manager + if (SidebarService.init()) { + this.getLogger().info("Initializing SidebarLib by andrei1058"); + } else { + this.getLogger().severe("SidebarLib by andrei1058 does not support your server version"); + Bukkit.getPluginManager().disablePlugin(this); + return; + } + int playerListRefreshInterval = config.getInt(ConfigPath.SB_CONFIG_SIDEBAR_LIST_REFRESH); if (playerListRefreshInterval < 1) { Bukkit.getLogger().info("Scoreboard names list refresh is disabled. (Is set to " + playerListRefreshInterval + ")."); @@ -552,7 +576,7 @@ public void onEnable() { Bukkit.getLogger().warning("It is not recommended to use a value under 20 ticks."); Bukkit.getLogger().warning("If you expect performance issues please increase its timer."); } - Bukkit.getScheduler().runTaskTimer(this, new SidebarListRefresh(), 23L, playerListRefreshInterval); + Bukkit.getScheduler().runTaskTimer(this, new RefreshTabListTask(), 23L, playerListRefreshInterval); } int placeholdersRefreshInterval = config.getInt(ConfigPath.SB_CONFIG_SIDEBAR_PLACEHOLDERS_REFRESH_INTERVAL); @@ -564,7 +588,7 @@ public void onEnable() { Bukkit.getLogger().warning("It is not recommended to use a value under 20 ticks."); Bukkit.getLogger().warning("If you expect performance issues please increase its timer."); } - Bukkit.getScheduler().runTaskTimer(this, new SidebarPlaceholderRefresh(), 28L, placeholdersRefreshInterval); + Bukkit.getScheduler().runTaskTimer(this, new RefreshPlaceholdersTask(), 28L, placeholdersRefreshInterval); } int titleRefreshInterval = config.getInt(ConfigPath.SB_CONFIG_SIDEBAR_TITLE_REFRESH_INTERVAL); @@ -575,7 +599,7 @@ public void onEnable() { Bukkit.getLogger().warning("Scoreboard title refresh interval is set to: " + titleRefreshInterval); Bukkit.getLogger().warning("If you expect performance issues please increase its timer."); } - Bukkit.getScheduler().runTaskTimerAsynchronously(this, new SidebarTitleRefresh(), 32L, titleRefreshInterval); + Bukkit.getScheduler().runTaskTimerAsynchronously(this, new RefreshTitleTask(), 32L, titleRefreshInterval); } int healthAnimationInterval = config.getInt(ConfigPath.SB_CONFIG_SIDEBAR_HEALTH_REFRESH); @@ -587,7 +611,7 @@ public void onEnable() { Bukkit.getLogger().warning("It is not recommended to use a value under 20 ticks."); Bukkit.getLogger().warning("If you expect performance issues please increase its timer."); } - Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new SidebarLifeRefresh(), 40L, healthAnimationInterval); + Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new RefreshLifeTask(), 40L, healthAnimationInterval); } registerEvents(new ScoreboardListener()); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/Arena.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/Arena.java index 3a4a17402..0eb7f85af 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/Arena.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/Arena.java @@ -63,8 +63,9 @@ import com.andrei1058.bedwars.listeners.dropshandler.PlayerDrops; import com.andrei1058.bedwars.money.internal.MoneyPerMinuteTask; import com.andrei1058.bedwars.shop.ShopCache; -import com.andrei1058.bedwars.sidebar.BedWarsScoreboard; +import com.andrei1058.bedwars.sidebar.SidebarService; import com.andrei1058.bedwars.support.citizens.JoinNPC; +import com.andrei1058.bedwars.support.paper.PaperSupport; import com.andrei1058.bedwars.support.papi.SupportPAPI; import com.andrei1058.bedwars.support.vault.WithEconomy; import net.md_5.bungee.api.chat.ClickEvent; @@ -544,9 +545,9 @@ public boolean addPlayer(Player p, boolean skipOwnerCheck) { new PlayerGoods(p, true); playerLocation.put(p, p.getLocation()); } - p.teleport(getWaitingLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(p, getWaitingLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); - BedWarsScoreboard.giveScoreboard(p, this, false); + SidebarService.getInstance().giveSidebar(p, this, false); sendPreGameCommandItems(p); for (PotionEffect pf : p.getActivePotionEffects()) { p.removePotionEffect(pf.getType()); @@ -644,14 +645,14 @@ public boolean addSpectator(@NotNull Player p, boolean playerBefore, Location st setArenaByPlayer(p, this); } - BedWarsScoreboard.giveScoreboard(p, this, false); + SidebarService.getInstance().giveSidebar(p, this, false); nms.setCollide(p, this, false); if (!playerBefore) { if (staffTeleport == null) { - p.teleport(getSpectatorLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(p, getSpectatorLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); } else { - p.teleport(staffTeleport, PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(p, staffTeleport, PlayerTeleportEvent.TeleportCause.PLUGIN); } } @@ -685,12 +686,12 @@ public boolean addSpectator(@NotNull Player p, boolean playerBefore, Location st if (!playerBefore) { if (staffTeleport == null) { - p.teleport(getSpectatorLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(p, getSpectatorLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); } else { - p.teleport(staffTeleport); + PaperSupport.teleport(p, staffTeleport); } } else { - p.teleport(getSpectatorLocation()); + PaperSupport.teleport(p, getSpectatorLocation()); } p.setAllowFlight(true); @@ -885,11 +886,9 @@ public void removePlayer(@NotNull Player p, boolean disconnect) { } if (getServerType() == ServerType.SHARED) { - BedWarsScoreboard sb = BedWarsScoreboard.getSBoard(p.getUniqueId()); - if (sb != null) { - sb.remove(); - } + SidebarService.getInstance().remove(p); this.sendToMainLobby(p); + } else if (getServerType() == ServerType.BUNGEE) { Misc.moveToLobbyOrKick(p, this, true); return; @@ -925,7 +924,7 @@ public void removePlayer(@NotNull Player p, boolean disconnect) { BedWars.nms.spigotHidePlayer(on, p); } } - if (!disconnect) BedWarsScoreboard.giveScoreboard(p, null, false); + if (!disconnect) SidebarService.getInstance().giveSidebar(p, null, false); }, 5L); } @@ -1027,10 +1026,7 @@ public void removeSpectator(@NotNull Player p, boolean disconnect) { BedWars.getAPI().getAFKUtil().setPlayerAFK(p, false); if (getServerType() == ServerType.SHARED) { - BedWarsScoreboard sb = BedWarsScoreboard.getSBoard(p.getUniqueId()); - if (sb != null) { - sb.remove(); - } + SidebarService.getInstance().remove(p); this.sendToMainLobby(p); } else if (getServerType() == ServerType.MULTIARENA) { this.sendToMainLobby(p); @@ -1069,7 +1065,7 @@ public void removeSpectator(@NotNull Player p, boolean disconnect) { BedWars.nms.spigotHidePlayer(on, p); } } - if (!disconnect) BedWarsScoreboard.giveScoreboard(p, null, true); + if (!disconnect) SidebarService.getInstance().giveSidebar(p, null, false); }); } @@ -1151,8 +1147,7 @@ public boolean reJoin(Player p) { //new PlayerGoods(p, true, true); playerLocation.put(p, p.getLocation()); } - - p.teleport(getSpectatorLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(p, getSpectatorLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); p.getInventory().clear(); //restore items before re-spawning in team @@ -1166,7 +1161,7 @@ public boolean reJoin(Player p) { reJoin.getBwt().reJoin(p, ev.getRespawnTime()); reJoin.destroy(false); - BedWarsScoreboard.giveScoreboard(p, this, true); + SidebarService.getInstance().giveSidebar(p, this, true); return true; } @@ -1200,6 +1195,12 @@ public void restart() { if (getRestartingTask() != null) getRestartingTask().cancel(); if (getStartingTask() != null) getStartingTask().cancel(); if (getPlayingTask() != null) getPlayingTask().cancel(); + if (null != moneyperMinuteTask){ + moneyperMinuteTask.cancel(); + } + if (null != perMinuteTask) { + perMinuteTask.cancel(); + } plugin.getLogger().log(Level.FINE, "Restarting arena: " + getArenaName()); Bukkit.getPluginManager().callEvent(new ArenaRestartEvent(getArenaName(), getWorldName())); for (Player inWorld : getWorld().getPlayers()) { @@ -1485,10 +1486,16 @@ public void changeStatus(GameState status) { restartingTask.cancel(); } restartingTask = null; + if (null != moneyperMinuteTask){ + moneyperMinuteTask.cancel(); + } + if (null != perMinuteTask) { + perMinuteTask.cancel(); + } - players.forEach(c -> BedWarsScoreboard.giveScoreboard(c, this, false)); + players.forEach(c -> SidebarService.getInstance().giveSidebar(c, this, false)); - spectators.forEach(c -> BedWarsScoreboard.giveScoreboard(c, this, false)); + spectators.forEach(c -> SidebarService.getInstance().giveSidebar(c, this, false)); if (status == GameState.starting) { startingTask = new GameStartingTask(this); @@ -1502,12 +1509,6 @@ public void changeStatus(GameState status) { playingTask = new GamePlayingTask(this); } else if (status == GameState.restarting) { restartingTask = new GameRestartingTask(this); - if (perMinuteTask != null) { - perMinuteTask.cancel (); - } - if (moneyperMinuteTask != null) { - moneyperMinuteTask.cancel (); - } } } @@ -1590,7 +1591,8 @@ public synchronized void refreshSigns() { if (getPlayers() == null) continue; s.setLine(line, string.replace("[on]", String.valueOf(getPlayers().size())) .replace("[max]", String.valueOf(getMaxPlayers())).replace("[arena]", getDisplayName()) - .replace("[status]", getDisplayStatus(Language.getDefaultLanguage()))); + .replace("[status]", getDisplayStatus(Language.getDefaultLanguage())) + .replace("[type]", String.valueOf(getMaxInTeam()))); line++; } try { @@ -2162,12 +2164,12 @@ public ConcurrentHashMap getRespawnSessions() { @Override public void updateSpectatorCollideRule(Player p, boolean collide) { - if (!isSpectator(p)) return; - for (BedWarsScoreboard sb : BedWarsScoreboard.getScoreboards().values()) { - if (sb.getArena() == this) { - sb.updateSpectator(p, collide); - } - } +// if (!isSpectator(p)) return; +// for (BedWarsScoreboard sb : BedWarsScoreboard.getScoreboards().values()) { +// if (sb.getArena() == this) { +// sb.updateSpectator(p, collide); +// } +// } } /** @@ -2494,7 +2496,7 @@ public boolean startReSpawnSession(Player player, int seconds) { if (playing.equals(player)) continue; BedWars.nms.spigotHidePlayer(player, playing); } - player.teleport(getReSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(player, getReSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); player.setAllowFlight(true); player.setFlying(true); @@ -2510,8 +2512,7 @@ public boolean startReSpawnSession(Player player, int seconds) { } updateSpectatorCollideRule(player, false); - player.teleport(getReSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); - // + PaperSupport.teleportC(player, getReSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); }, 10L); } else { ITeam team = getTeam(player); @@ -2638,17 +2639,17 @@ private void sendToMainLobby(Player player) { if (BedWars.getServerType() == ServerType.SHARED) { Location loc = playerLocation.get(player); if (loc == null) { - player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(player, Bukkit.getWorlds().get(0).getSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); plugin.getLogger().log(Level.SEVERE, player.getName() + " was teleported to the main world because lobby location is not set!"); } else { player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN); } } else if (BedWars.getServerType() == ServerType.MULTIARENA) { if (BedWars.getLobbyWorld().isEmpty()) { - player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(player, Bukkit.getWorlds().get(0).getSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); plugin.getLogger().log(Level.SEVERE, player.getName() + " was teleported to the main world because lobby location is not set!"); } else { - player.teleport(config.getConfigLoc("lobbyLoc"), PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(player, config.getConfigLoc("lobbyLoc"), PlayerTeleportEvent.TeleportCause.PLUGIN); } } } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/OreGenerator.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/OreGenerator.java index 334eec4c2..1bcf63020 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/OreGenerator.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/OreGenerator.java @@ -21,6 +21,7 @@ package com.andrei1058.bedwars.arena; import com.andrei1058.bedwars.BedWars; +import com.andrei1058.bedwars.api.arena.GameState; import com.andrei1058.bedwars.api.arena.IArena; import com.andrei1058.bedwars.api.arena.generator.GeneratorType; import com.andrei1058.bedwars.api.arena.generator.IGenHolo; @@ -79,7 +80,7 @@ public OreGenerator(Location location, IArena arena, GeneratorType type, ITeam b this.bwt = bwt; this.type = type; loadDefaults(); - BedWars.debug("Initializing new generator at: " + location.toString() + " - " + type + " - " + (bwt == null ? "NOTEAM" : bwt.getName())); + BedWars.debug("Initializing new generator at: " + location + " - " + type + " - " + (bwt == null ? "NOTEAM" : bwt.getName())); Cuboid c = new Cuboid(location, 1, true); c.setMaxY(c.getMaxY() + 5); @@ -142,6 +143,10 @@ public void upgrade() { @Override public void spawn() { + if (arena.getStatus() != GameState.playing){ + return; + } + if (lastSpawn == 0) { lastSpawn = delay; diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/SetupSession.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/SetupSession.java index fff702209..721380505 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/SetupSession.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/SetupSession.java @@ -30,6 +30,7 @@ import com.andrei1058.bedwars.api.server.SetupType; import com.andrei1058.bedwars.commands.bedwars.MainCommand; import com.andrei1058.bedwars.configuration.ArenaConfig; +import com.andrei1058.bedwars.support.paper.PaperSupport; import net.md_5.bungee.api.chat.ClickEvent; import org.bukkit.*; import org.bukkit.configuration.ConfigurationSection; @@ -166,9 +167,9 @@ public void done() { getSetupSessions().remove(this); if (BedWars.getServerType() != ServerType.BUNGEE) { try { - getPlayer().teleport(config.getConfigLoc("lobbyLoc"), PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(getPlayer(), config.getConfigLoc("lobbyLoc"), PlayerTeleportEvent.TeleportCause.PLUGIN); } catch (Exception ex) { - getPlayer().teleport(Bukkit.getWorlds().get(0).getSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(getPlayer(), Bukkit.getWorlds().get(0).getSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); } } getPlayer().removePotionEffect(PotionEffectType.SPEED); @@ -210,7 +211,7 @@ public ArenaConfig getConfig() { @Override public void teleportPlayer() { player.getInventory().clear(); - player.teleport(Bukkit.getWorld(getWorldName()).getSpawnLocation()); + PaperSupport.teleport(player, Bukkit.getWorld(getWorldName()).getSpawnLocation()); player.setGameMode(GameMode.CREATIVE); Bukkit.getScheduler().runTaskLater(plugin, ()->{ player.setAllowFlight(true); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/tasks/GamePlayingTask.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/tasks/GamePlayingTask.java index 317cdaaae..e21906a3e 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/tasks/GamePlayingTask.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/tasks/GamePlayingTask.java @@ -38,7 +38,6 @@ import org.bukkit.scheduler.BukkitTask; import java.util.Map; -import java.util.UUID; import static com.andrei1058.bedwars.BedWars.nms; import static com.andrei1058.bedwars.api.language.Language.getMsg; diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/team/BedWarsTeam.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/team/BedWarsTeam.java index c7692ac81..91820e1d1 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/team/BedWarsTeam.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/team/BedWarsTeam.java @@ -37,6 +37,7 @@ import com.andrei1058.bedwars.arena.OreGenerator; import com.andrei1058.bedwars.configuration.Sounds; import com.andrei1058.bedwars.shop.ShopCache; +import com.andrei1058.bedwars.support.paper.PaperSupport; import org.bukkit.*; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.ArmorStand; @@ -141,7 +142,7 @@ public void addPlayers(Player... players) { */ public void firstSpawn(Player p) { if (p == null) return; - p.teleport(spawn, PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(p, spawn, PlayerTeleportEvent.TeleportCause.PLUGIN); p.setGameMode(GameMode.SURVIVAL); p.setCanPickupItems(true); nms.setCollide(p, getArena(), true); @@ -339,7 +340,7 @@ public void respawnMember(@NotNull Player p) { } else { reSpawnInvulnerability.put(p.getUniqueId(), System.currentTimeMillis() + config.getInt(ConfigPath.GENERAL_CONFIGURATION_RE_SPAWN_INVULNERABILITY)); } - p.teleport(getSpawn(), PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(p, getSpawn(), PlayerTeleportEvent.TeleportCause.PLUGIN); p.setVelocity(new Vector(0, 0, 0)); getArena().getRespawnSessions().remove(p); p.removePotionEffect(PotionEffectType.INVISIBILITY); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/BaseListener.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/BaseListener.java index 58049f299..456ff6a81 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/BaseListener.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/BaseListener.java @@ -26,8 +26,6 @@ import com.andrei1058.bedwars.api.events.player.PlayerBaseEnterEvent; import com.andrei1058.bedwars.api.events.player.PlayerBaseLeaveEvent; import com.andrei1058.bedwars.api.events.player.PlayerLeaveArenaEvent; -import com.andrei1058.bedwars.api.events.upgrades.UpgradeBuyEvent; -import com.andrei1058.bedwars.api.upgrades.EnemyBaseEnterTrap; import com.andrei1058.bedwars.arena.Arena; import com.andrei1058.bedwars.arena.team.BedWarsTeam; import org.bukkit.Bukkit; diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/HealPoolListner.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/HealPoolListner.java new file mode 100644 index 000000000..c27da4a08 --- /dev/null +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/HealPoolListner.java @@ -0,0 +1,48 @@ +package com.andrei1058.bedwars.arena.upgrades; + +import com.andrei1058.bedwars.api.arena.IArena; +import com.andrei1058.bedwars.api.arena.team.ITeam; +import com.andrei1058.bedwars.api.events.gameplay.GameEndEvent; +import com.andrei1058.bedwars.api.events.player.PlayerLeaveArenaEvent; +import com.andrei1058.bedwars.api.events.server.ArenaDisableEvent; +import com.andrei1058.bedwars.api.events.team.TeamEliminatedEvent; +import com.andrei1058.bedwars.api.events.upgrades.UpgradeBuyEvent; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class HealPoolListner implements Listener { + @EventHandler + public void onTeamUpgrade(UpgradeBuyEvent e){ + if (e.getTeamUpgrade().getName().equalsIgnoreCase("upgrade-heal-pool")){ + IArena a = e.getArena(); + if (a == null) return; + ITeam bwt = a.getTeam(e.getPlayer()); + if (bwt == null) return; + if (!HealPoolTask.exists(a, bwt)){ + new HealPoolTask(bwt); + } + } + } + + @EventHandler + public void onDisable(ArenaDisableEvent e){ + HealPoolTask.removeForArena(e.getWorldName()); + } + + @EventHandler + public void onEnd(GameEndEvent e) { + HealPoolTask.removeForArena(e.getArena()); + } + + @EventHandler + public void teamDead(TeamEliminatedEvent e) + { + HealPoolTask.removeForTeam(e.getTeam()); + } + + @EventHandler + public void LastLeave(PlayerLeaveArenaEvent event){ + if (event.getArena().getPlayers().isEmpty()) + HealPoolTask.removeForArena(event.getArena()); + } +} diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/HealPoolTask.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/HealPoolTask.java new file mode 100644 index 000000000..1cac082cb --- /dev/null +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/arena/upgrades/HealPoolTask.java @@ -0,0 +1,124 @@ +package com.andrei1058.bedwars.arena.upgrades; + +import com.andrei1058.bedwars.BedWars; +import com.andrei1058.bedwars.api.arena.IArena; +import com.andrei1058.bedwars.api.arena.team.ITeam; +import com.andrei1058.bedwars.api.configuration.ConfigPath; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import static com.andrei1058.bedwars.BedWars.config; +import static com.andrei1058.bedwars.BedWars.plugin; + +public class HealPoolTask extends BukkitRunnable { + + private ITeam bwt; + private int maxX, minX, maxY, minY, maxZ, minZ; + private IArena arena; + private Random r = new Random(); + private Location l; + + private static List healPoolTasks = new ArrayList<>(); + + public HealPoolTask(ITeam bwt){ + this.bwt = bwt; + if (bwt == null || bwt.getSpawn() == null){ + removeForTeam(this.bwt); + cancel(); + return; + } + int radius = bwt.getArena().getConfig().getInt(ConfigPath.ARENA_ISLAND_RADIUS); + Location teamspawn = bwt.getSpawn(); + this.maxX = (teamspawn.getBlockX() + radius); + this.minX = (teamspawn.getBlockX() - radius); + this.maxY = (teamspawn.getBlockY() + radius); + this.minY = (teamspawn.getBlockY() - radius); + this.maxZ = (teamspawn.getBlockZ() + radius); + this.minZ = (teamspawn.getBlockZ() - radius); + this.arena = bwt.getArena(); + this.runTaskTimerAsynchronously(plugin, 0, 80L); + healPoolTasks.add(this); + } + + @Override + public void run(){ + //null checks + if ((bwt == null) || (bwt.getSpawn() == null) || (arena == null)){ + healPoolTasks.remove(this); + return; + } + + for (int x = minX; x <= maxX; x++) { + for (int y = minY; y <= maxY; y++) { + for (int z = minZ; z <= maxZ; z++) { + l = new Location(arena.getWorld(), x + .5, y + .5, z +.5); + if (l.getBlock().getType() != Material.AIR) continue; + int chance = r.nextInt(9); + if (chance == 0) { + if (config.getBoolean(ConfigPath.GENERAL_CONFIGURATION_HEAL_POOL_SEEN_TEAM_ONLY)) { + for (Player p : bwt.getMembers()) { + BedWars.nms.playVillagerEffect(p, l); + } + } + else + { + for (Player p : arena.getPlayers()) { + BedWars.nms.playVillagerEffect(p, l); + } + } + } + } + } + } + } + + public static boolean exists(IArena arena, ITeam bwt){ + if (healPoolTasks.isEmpty()) return false; + for (HealPoolTask hpt : healPoolTasks) { + if (hpt.getArena() == arena && hpt.getBwt() == bwt) return true; + } + return false; + } + public static void removeForArena(IArena a){ + if (healPoolTasks.isEmpty() || a == null) return; + for (HealPoolTask hpt: healPoolTasks) { + if (hpt == null) continue; + if (hpt.getArena().equals(a)){ + hpt.cancel(); + healPoolTasks.remove(hpt); + } + } + } + + public static void removeForArena(String a){ + if (healPoolTasks == null || healPoolTasks.isEmpty() || (a == null)) return; + for (HealPoolTask hpt: healPoolTasks) { + if (hpt == null) continue; + if (hpt.getArena().getWorldName().equals(a)){ + hpt.cancel(); + healPoolTasks.remove(hpt); + } + } + } + + public static void removeForTeam(ITeam team){ + if (healPoolTasks == null || healPoolTasks.isEmpty() || (team == null)) return; + for (HealPoolTask hpt:healPoolTasks) { + if (hpt == null) continue; + if (hpt.getBwt().equals(team)){ + hpt.cancel(); + healPoolTasks.remove(hpt); + } + } + } + + public ITeam getBwt() {return bwt;} + + public IArena getArena() {return arena;} +} diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/Misc.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/Misc.java index 7034ba029..5bde7db30 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/Misc.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/Misc.java @@ -22,6 +22,7 @@ import com.andrei1058.bedwars.BedWars; import com.andrei1058.bedwars.arena.SetupSession; +import com.andrei1058.bedwars.support.paper.PaperSupport; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -105,7 +106,7 @@ public static void autoSetGen(Player p, String command, SetupSession setupSessio Bukkit.getScheduler().runTaskLater(BedWars.plugin, () -> { for (Location l : setupSession.getSkipAutoCreateGen()) { Bukkit.getScheduler().runTaskLater(BedWars.plugin, () -> { - p.teleport(l); + PaperSupport.teleport(p, l); Bukkit.dispatchCommand(p, command + (l.add(0, -1, 0).getBlock().getType() == Material.EMERALD_BLOCK ? "emerald" : "diamond")); }, 20); } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/regular/CmdTpStaff.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/regular/CmdTpStaff.java index d5c4ee8ce..b20291688 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/regular/CmdTpStaff.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/regular/CmdTpStaff.java @@ -27,6 +27,7 @@ import com.andrei1058.bedwars.api.language.Language; import com.andrei1058.bedwars.api.language.Messages; import com.andrei1058.bedwars.arena.Arena; +import com.andrei1058.bedwars.support.paper.PaperSupport; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -75,7 +76,7 @@ public boolean execute(String[] args, CommandSender s) { if (a2.isPlayer(p2)) a2.removePlayer(p2, false); if (a2.isSpectator(p2)) { if (a2.getArenaName().equals(a.getArenaName())) { - p2.teleport(p); + PaperSupport.teleport(p2, p.getLocation()); return true; } else a2.removeSpectator(p2, false); } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/sensitive/setup/AutoCreateTeams.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/sensitive/setup/AutoCreateTeams.java index e77bb76b4..1ba80681e 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/sensitive/setup/AutoCreateTeams.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/sensitive/setup/AutoCreateTeams.java @@ -134,7 +134,7 @@ public boolean execute(String[] args, CommandSender s) { p.sendMessage("§6§lNEW TEAMS FOUND:"); for (String tf : found) { String name = TeamColor.enName(tf); - p.sendMessage("§f ▪ " + TeamColor.getChatColor(name) + name); + p.sendMessage("§f ▪ " + TeamColor.getChatColor(name) + name.replace("_", " ")); } p.spigot().sendMessage(Misc.msgHoverClick("§6 ▪ §7§lClick here to create found teams.", "§fClick to create found teams!", "/" + getParent().getName() + " " + getSubCommandName(), ClickEvent.Action.RUN_COMMAND)); } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/sensitive/setup/Save.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/sensitive/setup/Save.java index 9455d2fad..121955706 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/sensitive/setup/Save.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/sensitive/setup/Save.java @@ -26,6 +26,7 @@ import com.andrei1058.bedwars.arena.Misc; import com.andrei1058.bedwars.arena.SetupSession; import com.andrei1058.bedwars.configuration.Permissions; +import com.andrei1058.bedwars.support.paper.PaperSupport; import net.md_5.bungee.api.chat.ClickEvent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -63,9 +64,9 @@ public boolean execute(String[] args, CommandSender s) { } if (Bukkit.getWorld(BedWars.getLobbyWorld()) != null) { - p.teleport(Bukkit.getWorld(BedWars.getLobbyWorld()).getSpawnLocation()); + PaperSupport.teleport(p, Bukkit.getWorld(BedWars.getLobbyWorld()).getSpawnLocation()); } else { - p.teleport(Bukkit.getWorlds().get(0).getSpawnLocation()); + PaperSupport.teleport(p, Bukkit.getWorlds().get(0).getSpawnLocation()); } ss.done(); p.sendMessage(ss.getPrefix() + "Arena changes saved!"); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/sensitive/setup/SetSpawn.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/sensitive/setup/SetSpawn.java index 4519a6420..5d4c7a97d 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/sensitive/setup/SetSpawn.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/commands/bedwars/subcmds/sensitive/setup/SetSpawn.java @@ -27,6 +27,7 @@ import com.andrei1058.bedwars.arena.Misc; import com.andrei1058.bedwars.arena.SetupSession; import com.andrei1058.bedwars.configuration.Permissions; +import com.andrei1058.bedwars.support.paper.PaperSupport; import net.md_5.bungee.api.chat.ClickEvent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -93,7 +94,7 @@ public boolean execute(String[] args, CommandSender s) { for (int z = -radius; z < radius; z++) { Block b = l.clone().add(x, y, z).getBlock(); if (BedWars.nms.isBed(b.getType())) { - p.teleport(b.getLocation()); + PaperSupport.teleport(p, b.getLocation()); Bukkit.dispatchCommand(p, getParent().getName() + " setBed " + args[0]); return true; } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/configuration/MainConfig.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/configuration/MainConfig.java index 5ea3aea46..117b89bcc 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/configuration/MainConfig.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/configuration/MainConfig.java @@ -96,6 +96,10 @@ public MainConfig(Plugin plugin, String name) { yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_ALLOW_FIRE_EXTINGUISH, true); + //heal pool category + yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_HEAL_POOL_ENABLE, true); + yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_HEAL_POOL_SEEN_TEAM_ONLY, true); + // tnt jump category yml.addDefault(ConfigPath.GENERAL_TNT_JUMP_BARYCENTER_IN_Y, 0.5); yml.addDefault(ConfigPath.GENERAL_TNT_JUMP_STRENGTH_REDUCTION, 5); @@ -124,6 +128,7 @@ public MainConfig(Plugin plugin, String name) { yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_PERFORMANCE_ROTATE_GEN, true); yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_PERFORMANCE_SPOIL_TNT_PLAYERS, true); + yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_PERFORMANCE_PAPER_FEATURES, true); yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_DISABLE_CRAFTING, true); yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_DISABLE_ENCHANTING, true); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/configuration/SignsConfig.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/configuration/SignsConfig.java index 819272841..82b803dfb 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/configuration/SignsConfig.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/configuration/SignsConfig.java @@ -34,7 +34,7 @@ public class SignsConfig extends ConfigManager { public SignsConfig(Plugin plugin, String name, String dir) { super(plugin, name, dir); YamlConfiguration yml = getYml(); - yml.addDefault("format", Arrays.asList("&a[arena]", "", "&2[on]&9/&2[max]", "[status]")); + yml.addDefault("format", Arrays.asList("&a[arena]", "", "&2[on]&9/&2[max] &7([type])", "[status]")); yml.addDefault(ConfigPath.SIGNS_STATUS_BLOCK_WAITING_MATERIAL, getForCurrentVersion("STAINED_CLAY", "STAINED_CLAY", "GREEN_CONCRETE")); yml.addDefault(ConfigPath.SIGNS_STATUS_BLOCK_WAITING_DATA, 5); yml.addDefault(ConfigPath.SIGNS_STATUS_BLOCK_STARTING_MATERIAL, getForCurrentVersion("STAINED_CLAY", "STAINED_CLAY", "YELLOW_CONCRETE")); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/configuration/Sounds.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/configuration/Sounds.java index 33fab6374..bcd60a66e 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/configuration/Sounds.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/configuration/Sounds.java @@ -24,6 +24,7 @@ import com.andrei1058.bedwars.BedWars; import com.andrei1058.bedwars.api.arena.NextEvent; import com.andrei1058.bedwars.api.configuration.ConfigManager; +import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; @@ -83,6 +84,7 @@ public static void init() { addDefSound("shop-auto-equip", BedWars.getForCurrentVersion("HORSE_ARMOR", "ITEM_ARMOR_EQUIP_GENERIC", "ITEM_ARMOR_EQUIP_GENERIC")); addDefSound("egg-bridge-block", BedWars.getForCurrentVersion("CHICKEN_EGG_POP", "ENTITY_CHICKEN_EGG", "ENTITY_CHICKEN_EGG")); addDefSound("ender-pearl-landed", BedWars.getForCurrentVersion("ENDERMAN_TELEPORT", "ENTITY_ENDERMEN_TELEPORT", "ENTITY_ENDERMAN_TELEPORT")); + addDefSound("pop-up-tower-build", BedWars.getForCurrentVersion("CHICKEN_EGG_POP", "ENTITY_CHICKEN_EGG","ENTITY_CHICKEN_EGG")); yml.options().copyDefaults(true); // remove old paths @@ -142,4 +144,9 @@ private static void addDefSound(String path, String value) { getSounds().getYml().addDefault(path + ".volume", 1); getSounds().getYml().addDefault(path + ".pitch", 1); } + + public static void playsoundArea(String path, Location location, float x, float y){ + final Sound sound = getSound(path); + if (sound != null) location.getWorld().playSound(location, sound, x, y); + } } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Bangla.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Bangla.java index ce047243a..742fb3237 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Bangla.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Bangla.java @@ -53,6 +53,20 @@ public Bangla() { yml.set("player-die-knocked-final", null); } + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_WAITING,"&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_STARTING, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_SPECTATOR,"&9{serverIp}"); + + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_WAITING, "&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_STARTING,"&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_SPECTATOR,"&9{serverIp}"); + yml.addDefault(Messages.COMMAND_MAIN, Arrays.asList("", "&2▪ &7/" + mainCmd + " stats", "&2▪ &7/" + mainCmd + " join &o", "&2▪ &7/" + mainCmd + " leave", "&2▪ &7/" + mainCmd + " lang", "&2▪ &7/" + mainCmd + " gui", "&2▪ &7/" + mainCmd + " start &3(vip)")); yml.addDefault(Messages.COMMAND_LANG_LIST_HEADER, "{prefix} &2Upolopdho Bhasa:"); yml.addDefault(Messages.COMMAND_LANG_LIST_FORMAT, "&a▪ &7{iso} - &f{name}"); @@ -165,9 +179,10 @@ public Bangla() { yml.addDefault(Messages.FORMATTING_CHAT_SPECTATOR, "{level}{vPrefix}&7[SPECTATOR] {player}{vSuffix}: {message}"); yml.addDefault(Messages.FORMATTING_SCOREBOARD_HEALTH, Arrays.asList("&c❤", "&aHealth")); yml.addDefault(Messages.FORMATTING_SPECTATOR_TEAM, "SPECT"); - yml.addDefault(Messages.FORMATTING_SPECTATOR_COLOR, "&7"); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PRESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PRESTARTING, new ArrayList<>()); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_SPECTATOR, "&7"); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_SPECTATOR, ""); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_RESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_RESTARTING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}&l{teamLetter} &r{teamColor}")); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_STARTING, Arrays.asList("{vPrefix} ")); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/English.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/English.java index 252fd3d34..5b224dbf1 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/English.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/English.java @@ -164,9 +164,10 @@ public English() { yml.addDefault(Messages.FORMATTING_CHAT_SPECTATOR, "{level}{vPrefix}&7[SPECTATOR] {player}{vSuffix}: {message}"); yml.addDefault(Messages.FORMATTING_SCOREBOARD_HEALTH, Arrays.asList("&c❤", "&aHealth")); yml.addDefault(Messages.FORMATTING_SPECTATOR_TEAM, "SPECT"); - yml.addDefault(Messages.FORMATTING_SPECTATOR_COLOR, "&7"); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PRESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PRESTARTING, new ArrayList<>()); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_SPECTATOR, "&7"); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_SPECTATOR, ""); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_RESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_RESTARTING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}&l{teamLetter} &r{teamColor}")); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_STARTING, Arrays.asList("{vPrefix} ")); @@ -176,6 +177,20 @@ public English() { yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_LOBBY, Arrays.asList("{vPrefix} ")); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_LOBBY, new ArrayList<>()); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_WAITING,"&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_STARTING, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_SPECTATOR,"&9{serverIp}"); + + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_WAITING, "&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_STARTING,"&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_SPECTATOR,"&9{serverIp}"); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_DATE, "dd/MM/yy"); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TEAM_GENERIC, "{TeamColor}{TeamLetter}&f {TeamName}: {TeamStatus}"); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TEAM_ELIMINATED, "&c&l✘"); @@ -356,6 +371,7 @@ public English() { yml.addDefault(Messages.SHOP_LORE_STATUS_CAN_BUY, "&eClick to purchase!"); yml.addDefault(Messages.SHOP_LORE_STATUS_CANT_AFFORD, "&cYou don't have enough {currency}!"); yml.addDefault(Messages.SHOP_LORE_STATUS_MAXED, "&aMAXED!"); + yml.addDefault(Messages.SHOP_LORE_STATUS_ARMOR, "&aEQUIPPED!"); yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&bSneak Click to add to Quick Buy"); yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&bSneak Click to remove from Quick Buy!"); @@ -430,6 +446,7 @@ public English() { "&7seconds after consuming.", "", "{quick_buy}", "{buy_status}")); addContentMessages(yml, "sponge", ConfigPath.SHOP_PATH_CATEGORY_UTILITY, "{color}Sponge", Arrays.asList("&7Cost: {cost} {currency}", "", "&7Great for soaking up water.", "", "{quick_buy}", "{buy_status}")); + addContentMessages(yml, "Compact Pop-up Tower", ConfigPath.SHOP_PATH_CATEGORY_UTILITY, "{color}Compact Pop-up Tower", Arrays.asList("&7Cost: {cost} {currency}", "", "&7Place a compact pop-up", "&7tower defense!", "", "{quick_buy}", "{buy_status}")); // yml.addDefault(Messages.MEANING_NO_TRAP, "No trap!"); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Hindi.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Hindi.java index 1427200a6..8eb2a7bfa 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Hindi.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Hindi.java @@ -52,6 +52,19 @@ public Hindi() { yml.set(Messages.PLAYER_DIE_KNOCKED_IN_VOID_FINAL_KILL, yml.getString("player-die-knocked-final")); yml.set("player-die-knocked-final", null); } + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_WAITING,"&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_STARTING, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_SPECTATOR,"&9{serverIp}"); + + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_WAITING, "&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_STARTING,"&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_SPECTATOR,"&9{serverIp}"); yml.addDefault(Messages.COMMAND_MAIN, Arrays.asList("", "&2▪ &7/" + mainCmd + " stats", "&2▪ &7/" + mainCmd + " join &o", "&2▪ &7/" + mainCmd + " leave", "&2▪ &7/" + mainCmd + " lang", "&2▪ &7/" + mainCmd + " gui", "&2▪ &7/" + mainCmd + " start &3(vip)")); yml.addDefault(Messages.COMMAND_LANG_LIST_HEADER, "{prefix} &2Upalabdh bhaasa:"); @@ -164,9 +177,10 @@ public Hindi() { yml.addDefault(Messages.FORMATTING_CHAT_SPECTATOR, "{level}{vPrefix}&7[SPECTATOR] {player}{vSuffix}: {message}"); yml.addDefault(Messages.FORMATTING_SCOREBOARD_HEALTH, Arrays.asList("&c❤", "&aHealth")); yml.addDefault(Messages.FORMATTING_SPECTATOR_TEAM, "SPECT"); - yml.addDefault(Messages.FORMATTING_SPECTATOR_COLOR, "&7"); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PRESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PRESTARTING, new ArrayList<>()); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_SPECTATOR, "&7"); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_SPECTATOR, ""); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_RESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_RESTARTING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}&l{teamLetter} &r{teamColor}")); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_STARTING, Arrays.asList("{vPrefix} ")); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Indonesia.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Indonesia.java index ae508bdb5..f6d2c1460 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Indonesia.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Indonesia.java @@ -52,6 +52,19 @@ public Indonesia() { yml.set(Messages.PLAYER_DIE_KNOCKED_IN_VOID_FINAL_KILL, yml.getString("player-die-knocked-final")); yml.set("player-die-knocked-final", null); } + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_WAITING,"&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_STARTING, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_SPECTATOR,"&9{serverIp}"); + + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_WAITING, "&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_STARTING,"&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_SPECTATOR,"&9{serverIp}"); yml.addDefault(Messages.COMMAND_MAIN, Arrays.asList("", "&2▪ &7/" + mainCmd + " stats", "&2▪ &7/" + mainCmd + " join &o", "&2▪ &7/" + mainCmd + " leave", "&2▪ &7/" + mainCmd + " lang", "&2▪ &7/" + mainCmd + " gui", "&2▪ &7/" + mainCmd + " start &3(vip)")); yml.addDefault(Messages.COMMAND_LANG_LIST_HEADER, "{prefix} &2Bahasa Tersedia:"); @@ -164,9 +177,10 @@ public Indonesia() { yml.addDefault(Messages.FORMATTING_CHAT_SPECTATOR, "&7[PENONTON] {level}{vPrefix}{player}{vSuffix}: {message}"); yml.addDefault(Messages.FORMATTING_SCOREBOARD_HEALTH, Arrays.asList("&c❤")); yml.addDefault(Messages.FORMATTING_SPECTATOR_TEAM, "PENONTON"); - yml.addDefault(Messages.FORMATTING_SPECTATOR_COLOR, "&7"); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PRESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PRESTARTING, new ArrayList<>()); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_SPECTATOR, "&7"); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_SPECTATOR, ""); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_RESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_RESTARTING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}&l{teamLetter} &r{teamColor}")); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_STARTING, Arrays.asList("{vPrefix} ")); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Italian.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Italian.java index f0c85b3d5..7217b429e 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Italian.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Italian.java @@ -53,6 +53,19 @@ public Italian() { yml.set(Messages.PLAYER_DIE_KNOCKED_IN_VOID_FINAL_KILL, yml.getString("player-die-knocked-final")); yml.set("player-die-knocked-final", null); } + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_WAITING,"&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_STARTING, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_SPECTATOR,"&9{serverIp}"); + + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_WAITING, "&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_STARTING,"&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_SPECTATOR,"&9{serverIp}"); yml.addDefault(Messages.COMMAND_MAIN, Arrays.asList("", "&2▪ &7/" + mainCmd + " stats", "&2▪ &7/" + mainCmd + " join &o", "&2▪ &7/" + mainCmd + " leave", "&2▪ &7/" + mainCmd + " lang", "&2▪ &7/" + mainCmd + " gui", "&2▪ &7/" + mainCmd + " start &3(vip)")); yml.addDefault(Messages.COMMAND_JOIN_USAGE, "§a▪ §7Utilizzo: /" + mainCmd + " join §o"); @@ -166,9 +179,10 @@ public Italian() { yml.addDefault(Messages.FORMATTING_CHAT_SPECTATOR, "{level}{vPrefix}&7[SPECTATOR] {player}{vSuffix}: {message}"); yml.addDefault(Messages.FORMATTING_SCOREBOARD_HEALTH, Arrays.asList("&c❤", "&aVita")); yml.addDefault(Messages.FORMATTING_SPECTATOR_TEAM, "SPECT"); - yml.addDefault(Messages.FORMATTING_SPECTATOR_COLOR, "&7"); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PRESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PRESTARTING, new ArrayList<>()); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_SPECTATOR, "&7"); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_SPECTATOR, ""); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_RESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_RESTARTING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}&l{teamLetter} &r{teamColor}")); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_STARTING, Arrays.asList("{vPrefix} ")); @@ -415,6 +429,7 @@ public Italian() { addContentMessages(yml, "bridge-egg", ConfigPath.SHOP_PATH_CATEGORY_UTILITY, "{color}Bridge Egg", Arrays.asList("&7Costo: {cost} {currency}", "", "&7Questo uovo crea un ponte in sua", "&7direzione dopo averlo lanciato.", "", "{quick_buy}", "{buy_status}")); addContentMessages(yml, "magic-milk", ConfigPath.SHOP_PATH_CATEGORY_UTILITY, "{color}Latte Magico", Arrays.asList("&7Costo: {cost} {currency}", "", "&7Evita le trappole per 60 secondi", "&7dopo averlo consumato.", "", "{quick_buy}", "{buy_status}")); addContentMessages(yml, "sponge", ConfigPath.SHOP_PATH_CATEGORY_UTILITY, "{color}Spugna", Arrays.asList("&7Costo: {cost} {currency}", "", "&7Utile per succhiare l'acqua :)).", "", "{quick_buy}", "{buy_status}")); + addContentMessages(yml, "Compact Pop-up Tower", ConfigPath.SHOP_PATH_CATEGORY_UTILITY, "{color}Torre Pop-up Compatta", Arrays.asList("&7Costo: {cost} {currency}", "", "&7Piazza una Torre Pop-up", "&7compatta per difenderti!", "", "{quick_buy}", "{buy_status}")); yml.addDefault(Messages.UPGRADES_LORE_REPLACEMENT_CLICK_TO_BUY, "&aClicca per acquistare!"); yml.addDefault(Messages.UPGRADES_LORE_REPLACEMENT_INSUFFICIENT_MONEY, "&cNon hai abbastanza {currency}"); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/LangListener.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/LangListener.java index c7e97beec..6548b07ba 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/LangListener.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/LangListener.java @@ -23,7 +23,7 @@ import com.andrei1058.bedwars.BedWars; import com.andrei1058.bedwars.api.events.player.PlayerLangChangeEvent; import com.andrei1058.bedwars.arena.Arena; -import com.andrei1058.bedwars.sidebar.BedWarsScoreboard; +import com.andrei1058.bedwars.sidebar.SidebarService; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -38,7 +38,7 @@ public void onLanguageChangeEvent(PlayerLangChangeEvent e) { if (BedWars.config.getLobbyWorldName().equalsIgnoreCase(e.getPlayer().getWorld().getName())) { Bukkit.getScheduler().runTaskLater(BedWars.plugin, () -> { Arena.sendLobbyCommandItems(e.getPlayer()); - BedWarsScoreboard.giveScoreboard(e.getPlayer(), Arena.getArenaByPlayer(e.getPlayer()), false); + SidebarService.getInstance().giveSidebar(e.getPlayer(), Arena.getArenaByPlayer(e.getPlayer()), false); // save to db Bukkit.getScheduler().runTaskAsynchronously(BedWars.plugin, ()-> BedWars.getRemoteDatabase().setLanguage(e.getPlayer().getUniqueId(), e.getNewLang())); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Persian.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Persian.java index f0c4e83d4..5e5e2205b 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Persian.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Persian.java @@ -54,6 +54,20 @@ public Persian() { yml.set("player-die-knocked-final", null); } + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_WAITING,"&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_STARTING, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_SPECTATOR,"&9{serverIp}"); + + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_WAITING, "&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_STARTING,"&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_SPECTATOR,"&9{serverIp}"); + yml.addDefault(Messages.COMMAND_MAIN, Arrays.asList("", "&2▪ &7/" + mainCmd + " stats", "&2▪ &7/" + mainCmd + " join &o", "&2▪ &7/" + mainCmd + " leave", "&2▪ &7/" + mainCmd + " lang", "&2▪ &7/" + mainCmd + " gui", "&2▪ &7/" + mainCmd + " start &3(vip)")); yml.addDefault(Messages.COMMAND_LANG_LIST_HEADER, "{prefix} &2Zaban haye mojood:"); yml.addDefault(Messages.COMMAND_LANG_LIST_FORMAT, "&a▪ &7{iso} - &f{name}"); @@ -165,9 +179,10 @@ public Persian() { yml.addDefault(Messages.FORMATTING_CHAT_SPECTATOR, "{level}{vPrefix}&7[SPECTATOR] {player}{vSuffix}: {message}"); yml.addDefault(Messages.FORMATTING_SCOREBOARD_HEALTH, Arrays.asList("&c❤", "&aHealth")); yml.addDefault(Messages.FORMATTING_SPECTATOR_TEAM, "SPECT"); - yml.addDefault(Messages.FORMATTING_SPECTATOR_COLOR, "&7"); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PRESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PRESTARTING, new ArrayList<>()); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_SPECTATOR, "&7"); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_SPECTATOR, ""); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_RESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_RESTARTING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}&l{teamLetter} &r{teamColor}")); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_STARTING, Arrays.asList("{vPrefix} ")); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Polish.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Polish.java index 59aa2edcd..be565088f 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Polish.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Polish.java @@ -37,7 +37,7 @@ public class Polish extends Language{ public Polish() { super(BedWars.plugin, "pl"); YamlConfiguration yml = getYml(); - yml.options().header("Polish translation by RarstManPL#0616 and Creper132#7570"); + yml.options().header("Polish translation by RarstManPL#0616 and Creper132#7570 Updated by Seriously Not Beluga#0082"); yml.addDefault(Messages.PREFIX, ""); yml.options().copyDefaults(true); yml.addDefault("name", "Polski"); @@ -53,6 +53,20 @@ public Polish() { yml.set("player-die-knocked-final", null); } + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_WAITING,"&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_STARTING, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_SPECTATOR,"&9{serverIp}"); + + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_WAITING, "&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_STARTING,"&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_SPECTATOR,"&9{serverIp}"); + yml.addDefault(Messages.COMMAND_JOIN_USAGE, "§a▪ §7Uzyj: /" + mainCmd + " join §o"); yml.addDefault(Messages.COMMAND_NOT_ALLOWED_IN_GAME, "{prefix}&cNie mozesz tego zrobic."); yml.addDefault(Messages.COMMAND_MAIN, Arrays.asList("", "&2▪ &7/" + mainCmd + " stats", "&2▪ &7/" + mainCmd + " join &o", "&2▪ &7/" + mainCmd + " leave", "&2▪ &7/" + mainCmd + " lang", "&2▪ &7/" + mainCmd + " gui", "&2▪ &7/" + mainCmd + " start &3(vip)")); @@ -109,7 +123,7 @@ public Polish() { yml.addDefault(Messages.COMMAND_COOLDOWN, "&cNie możesz tego zrobić! Poczekaj {seconds}!"); yml.addDefault(Messages.ARENA_SPECTATOR_TELEPORTER_GUI_NAME, "&8Teleporter"); yml.addDefault(Messages.ARENA_SPECTATOR_TELEPORTER_GUI_HEAD_NAME, "{vPrefix}{player}"); - yml.addDefault(Messages.ARENA_SPECTATOR_TELEPORTER_GUI_HEAD_LORE, Arrays.asList("&7Zycie: &f{health}%", "&7Jedzenie: &f{food}", "", "&7Left-click to spectate")); + yml.addDefault(Messages.ARENA_SPECTATOR_TELEPORTER_GUI_HEAD_LORE, Arrays.asList("&7Zycie: &f{health}%", "&7Jedzenie: &f{food}", "", "&7Kliknij lewym by oglądać")); yml.addDefault(Messages.ARENA_SPECTATOR_LEAVE_ITEM_NAME, "&c&lPowroc do lobby"); yml.addDefault(Messages.ARENA_SPECTATOR_LEAVE_ITEM_LORE, Collections.singletonList("&7Kliknij PPM aby wyjsc do lobby!")); yml.addDefault(Messages.ARENA_SPECTATOR_FIRST_PERSON_ENTER_TITLE, "&aObserwujesz &7{player}"); @@ -149,7 +163,7 @@ public Polish() { yml.addDefault(Messages.ARENA_STATUS_START_PLAYER_TITLE, "&aSTART"); yml.addDefault(Messages.ARENA_JOIN_DENIED_SELECTOR, "{prefix}&cAktualnie nie możesz dołączyć do tej areny, kliknij PPM aby oglądać arene"); yml.addDefault(Messages.ARENA_SPECTATE_DENIED_SELECTOR, "{prefix}&cAktualnie nie możesz obserwować tej areny, kliknij LMP aby dołączyć"); - yml.addDefault(Messages.ARENA_JOIN_DENIED_NO_PROXY, "&cSorry but you must join an arena using BedWarsProxy. \n&eIf you want to setup an arena make sure to give yourself the bw.setup permission so you can join the server directly!"); + yml.addDefault(Messages.ARENA_JOIN_DENIED_NO_PROXY, "&cPrzykro nam, ale musisz dołączyć do areny używając BedWarsProxy. \n&eJeśli chcesz utworzyć arenę, upewnij się, że nadałeś sobie uprawnienia bw.setup, aby móc bezpośrednio dołączyć do serwera!"); yml.addDefault(Messages.GENERATOR_HOLOGRAM_TIER, "&eTier &c{tier}"); yml.addDefault(Messages.GENERATOR_HOLOGRAM_TYPE_DIAMOND, "&b&lDiamentow"); yml.addDefault(Messages.GENERATOR_HOLOGRAM_TYPE_EMERALD, "&a&lSzmaragdow"); @@ -164,9 +178,10 @@ public Polish() { yml.addDefault(Messages.FORMATTING_CHAT_SPECTATOR, "{level}{vPrefix}&7[SPECTATOR] {player}{vSuffix}: {message}"); yml.addDefault(Messages.FORMATTING_SCOREBOARD_HEALTH, Arrays.asList("&c❤", "&aZYCIA")); yml.addDefault(Messages.FORMATTING_SPECTATOR_TEAM, "SPECT"); - yml.addDefault(Messages.FORMATTING_SPECTATOR_COLOR, "&7"); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PRESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PRESTARTING, new ArrayList<>()); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_SPECTATOR, "&7"); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_SPECTATOR, ""); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_RESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_RESTARTING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}&l{teamLetter} &r{teamColor}")); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_STARTING, Arrays.asList("{vPrefix} ")); @@ -189,8 +204,8 @@ public Polish() { yml.addDefault(Messages.FORMATTING_GENERATOR_TIER2, "II"); yml.addDefault(Messages.FORMATTING_GENERATOR_TIER3, "III"); yml.addDefault(Messages.FORMAT_PAPI_PLAYER_TEAM_TEAM, "{TeamColor}[{TeamName}]"); - yml.addDefault(Messages.FORMAT_PAPI_PLAYER_TEAM_SHOUT, "&6[SHOUT]"); - yml.addDefault(Messages.FORMAT_PAPI_PLAYER_TEAM_SPECTATOR, "&7[SPECTATOR]"); + yml.addDefault(Messages.FORMAT_PAPI_PLAYER_TEAM_SHOUT, "&6[GLOBALNY]"); + yml.addDefault(Messages.FORMAT_PAPI_PLAYER_TEAM_SPECTATOR, "&7[DUCH]"); yml.addDefault(Messages.MEANING_SHOUT, "okrzyk"); yml.addDefault(Messages.MEANING_NOBODY, "Nikt"); yml.addDefault(Messages.MEANING_FULL, "Full"); @@ -217,14 +232,14 @@ public Polish() { yml.addDefault(Messages.PLAYER_DIE_VOID_FALL_FINAL_KILL, "{PlayerColor}{PlayerName} &7spadl do pustki. &b&lOSTATECZNE ZABOJSTWO!"); yml.addDefault(Messages.PLAYER_DIE_KNOCKED_IN_VOID_REGULAR_KILL, "{PlayerColor}{PlayerName} &7zostal zepchniety do pustki przez {KillerColor}{KillerName}&7."); yml.addDefault(Messages.PLAYER_DIE_KNOCKED_IN_VOID_FINAL_KILL, "{PlayerColor}{PlayerName} &7zostal zepchniety do pustki przez {KillerColor}{KillerName}&7. &b&lOSTATECZNE ZABOJSTWO!"); - yml.addDefault(Messages.PLAYER_DIE_KNOCKED_BY_REGULAR_KILL, "{PlayerColor}{PlayerName} &7was pushed by {KillerColor}{KillerName}&7."); - yml.addDefault(Messages.PLAYER_DIE_KNOCKED_BY_FINAL_KILL, "{PlayerColor}{PlayerName} &7was pushed by {KillerColor}{KillerName}&7. &b&lFINAL KILL!"); + yml.addDefault(Messages.PLAYER_DIE_KNOCKED_BY_REGULAR_KILL, "{PlayerColor}{PlayerName} &7został popchnięty do pustki {KillerColor}{KillerName}&7."); + yml.addDefault(Messages.PLAYER_DIE_KNOCKED_BY_FINAL_KILL, "{PlayerColor}{PlayerName} &7został popchnięty do pustki {KillerColor}{KillerName}&7. &b&lOSTATECZNE ZABÓJSTWO!"); yml.addDefault(Messages.PLAYER_DIE_EXPLOSION_WITH_SOURCE_REGULAR_KILL, "{PlayerColor}{PlayerName} &7zostal zabity przez bombe gracza {KillerColor}{KillerName}&7."); yml.addDefault(Messages.PLAYER_DIE_EXPLOSION_WITH_SOURCE_FINAL_KILL, "{PlayerColor}{PlayerName} &7zostal zabity przez bombe gracza {KillerColor}{KillerName}&7. &b&lOSTATECZNE ZABOJSTWO!"); yml.addDefault(Messages.PLAYER_DIE_PVP_REGULAR_KILL, "{PlayerColor}{PlayerName} &7zostal zabity przez {KillerColor}{KillerName}&7."); yml.addDefault(Messages.PLAYER_DIE_PVP_FINAL_KILL, "{PlayerColor}{PlayerName} &7zostal zabity przez {KillerColor}{KillerName}&7. &b&lOSTATECZNE ZABOJSTWO!"); - yml.addDefault(Messages.PLAYER_DIE_PVP_LOG_OUT_REGULAR, "{PlayerColor}{PlayerName} &7disconnected while fighting with {KillerColor}{KillerName}&7."); - yml.addDefault(Messages.PLAYER_DIE_PVP_LOG_OUT_FINAL, "{PlayerColor}{PlayerName} &7disconnected while fighting with {KillerColor}{KillerName}&7. &b&lFINAL KILL!"); + yml.addDefault(Messages.PLAYER_DIE_PVP_LOG_OUT_REGULAR, "{PlayerColor}{PlayerName} &7wyszedł podczas walki z {KillerColor}{KillerName}&7."); + yml.addDefault(Messages.PLAYER_DIE_PVP_LOG_OUT_FINAL, "{PlayerColor}{PlayerName} &7wyszedł podczas walki z {KillerColor}{KillerName}&7. &b&lOSTATECZNE ZABÓJSTWO!"); yml.addDefault(Messages.PLAYER_DIE_RESPAWN_TITLE, "&cUMARLES"); yml.addDefault(Messages.PLAYER_DIE_RESPAWN_SUBTITLE, "&eOdrodzisz sie za &c{time} &esekund/y!"); yml.addDefault(Messages.PLAYER_DIE_RESPAWN_CHAT, "{prefix}&eOdrodzisz sie za &c{time} &esekund/y!"); @@ -233,12 +248,12 @@ public Polish() { yml.addDefault(Messages.PLAYER_HIT_BOW, "{prefix}{TeamColor}{PlayerName} &7posiada &c{amount} &7HP!"); yml.addDefault(Messages.PLAYER_DIE_UNKNOWN_REASON_REGULAR, "{PlayerColor}{PlayerName} &7umarl."); yml.addDefault(Messages.PLAYER_DIE_UNKNOWN_REASON_FINAL_KILL, "{PlayerColor}{PlayerName} &7umarl. &b&lOSTATECZNE ZABOJSTWO!"); - yml.addDefault(Messages.PLAYER_DIE_SHOOT_REGULAR, "{PlayerColor}{PlayerName} &7was shoot by {KillerColor}{KillerName}&7!"); - yml.addDefault(Messages.PLAYER_DIE_SHOOT_FINAL_KILL, "{PlayerColor}{PlayerName} &7was shoot by {KillerColor}{KillerName}&7! &b&lOSTATECZNE ZABOJSTWO!"); - yml.addDefault(Messages.PLAYER_DIE_DEBUG_REGULAR, "{PlayerColor}{PlayerName} &7was killed by {KillerColor}{KillerTeamName} &7Pluskwa!"); - yml.addDefault(Messages.PLAYER_DIE_DEBUG_FINAL_KILL, "{PlayerColor}{PlayerName} &7was killed by {KillerColor}{KillerTeamName} &7Pluskwa! &b&lOSTATECZNE ZABOJSTWO!"); - yml.addDefault(Messages.PLAYER_DIE_IRON_GOLEM_REGULAR, "{PlayerColor}{PlayerName} &7was killed by {KillerColor}{KillerTeamName}'s &7Iron Golem!"); - yml.addDefault(Messages.PLAYER_DIE_IRON_GOLEM_FINAL_KILL, "{PlayerColor}{PlayerName} &7was killed by {KillerColor}{KillerTeamName}'s &7Iron Golem! &b&lOSTATECZNE ZABOJSTWO!"); + yml.addDefault(Messages.PLAYER_DIE_SHOOT_REGULAR, "{PlayerColor}{PlayerName} &7został zastrzelony {KillerColor}{KillerName}&7!"); + yml.addDefault(Messages.PLAYER_DIE_SHOOT_FINAL_KILL, "{PlayerColor}{PlayerName} &7został zastrzelony {KillerColor}{KillerName}&7! &b&lOSTATECZNE ZABOJSTWO!"); + yml.addDefault(Messages.PLAYER_DIE_DEBUG_REGULAR, "{PlayerColor}{PlayerName} &7został zabity przez pluskwe {KillerColor}{KillerTeamName}"); + yml.addDefault(Messages.PLAYER_DIE_DEBUG_FINAL_KILL, "{PlayerColor}{PlayerName} &7został zabity przez pluskwe {KillerColor}{KillerTeamName} &b&lOSTATECZNE ZABOJSTWO!"); + yml.addDefault(Messages.PLAYER_DIE_IRON_GOLEM_REGULAR, "{PlayerColor}{PlayerName} &7został zabity przez golema {KillerColor}{KillerTeamName}"); + yml.addDefault(Messages.PLAYER_DIE_IRON_GOLEM_FINAL_KILL, "{PlayerColor}{PlayerName} &7został zabity przez golema {KillerColor}{KillerTeamName} &b&lOSTATECZNE ZABOJSTWO!"); yml.addDefault(Messages.PLAYER_DIE_REWARD_DIAMOND, "{prefix}&b+{amount} {meaning}"); yml.addDefault(Messages.PLAYER_DIE_REWARD_EMERALD, "{prefix}&a+{amount} {meaning}"); yml.addDefault(Messages.PLAYER_DIE_REWARD_IRON, "{prefix}&f+{amount} {meaning}"); @@ -327,26 +342,26 @@ public Polish() { yml.addDefault(Messages.NPC_NAME_SOLO_SHOP, "&bSKLEP Z PRZEDMIOTAMI,&e&lRIGHT CLICK"); //SHOP - yml.addDefault(Messages.SHOP_INDEX_NAME, "&8Quick Buy"); - yml.addDefault(Messages.SHOP_QUICK_ADD_NAME, "&8Adding to Quick Buy..."); + yml.addDefault(Messages.SHOP_INDEX_NAME, "&8Szybkie kupowanie"); + yml.addDefault(Messages.SHOP_QUICK_ADD_NAME, "&8Dodawanie do szybkiego kupowania"); yml.addDefault(Messages.SHOP_INSUFFICIENT_MONEY, "{prefix}&cNie masz wymaganej ilosci {currency}! Potrzebujesz {amount} wiecej!"); yml.addDefault(Messages.SHOP_NEW_PURCHASE, "{prefix}&aKupiles &6{item}"); yml.addDefault(Messages.SHOP_ALREADY_BOUGHT, "{prefix}&cJuz to kupiles!"); yml.addDefault(Messages.SHOP_UTILITY_NPC_SILVERFISH_NAME, "{TeamColor}&l{TeamName} &r{TeamColor}Pluskwa"); yml.addDefault(Messages.SHOP_UTILITY_NPC_IRON_GOLEM_NAME, "{TeamColor}{despawn}s &8[ {TeamColor}{health}&8]"); - yml.addDefault(Messages.SHOP_SEPARATOR_NAME, "&8⇧ Categories"); - yml.addDefault(Messages.SHOP_SEPARATOR_LORE, Collections.singletonList("&8⇩ Items")); - yml.addDefault(Messages.SHOP_QUICK_BUY_NAME, "&bQuick Buy"); + yml.addDefault(Messages.SHOP_SEPARATOR_NAME, "&8⇧ Kategorie"); + yml.addDefault(Messages.SHOP_SEPARATOR_LORE, Collections.singletonList("&8⇩ Przedmioty")); + yml.addDefault(Messages.SHOP_QUICK_BUY_NAME, "&bSzybkie kupowanie"); yml.addDefault(Messages.SHOP_QUICK_BUY_LORE, new ArrayList<>()); yml.addDefault(Messages.SHOP_QUICK_EMPTY_NAME, "&cEmpty slot!"); - yml.addDefault(Messages.SHOP_QUICK_EMPTY_LORE, Arrays.asList("&7This is a Quick Buy Slot!", "&bSneak Click &7any item in", "&7the shop to add it here.")); + yml.addDefault(Messages.SHOP_QUICK_EMPTY_LORE, Arrays.asList("&7To jest szybkie kupowanie!", "&bKucjnij &7aby dodać")); yml.addDefault(Messages.SHOP_CAN_BUY_COLOR, "&a"); yml.addDefault(Messages.SHOP_CANT_BUY_COLOR, "&c"); - yml.addDefault(Messages.SHOP_LORE_STATUS_CAN_BUY, "&eClick to purchase!"); - yml.addDefault(Messages.SHOP_LORE_STATUS_CANT_AFFORD, "&cYou don't have enough {currency}!"); - yml.addDefault(Messages.SHOP_LORE_STATUS_MAXED, "&aMAXED!"); - yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&bSneak Click to add to Quick Buy"); - yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&bSneak Click to remove from Quick Buy!"); + yml.addDefault(Messages.SHOP_LORE_STATUS_CAN_BUY, "&eKliknij aby kupić!"); + yml.addDefault(Messages.SHOP_LORE_STATUS_CANT_AFFORD, "&cNie masz wystarczająco {currency}!"); + yml.addDefault(Messages.SHOP_LORE_STATUS_MAXED, "&aMAX!"); + yml.addDefault(Messages.SHOP_LORE_QUICK_ADD, "&bKucnij &7by dodać do szybkiego kupowania"); + yml.addDefault(Messages.SHOP_LORE_QUICK_REMOVE, "&bKucnij &7by usunąć z szybkiego kupowania"); addCategoryMessages(yml, ConfigPath.SHOP_PATH_CATEGORY_BLOCKS, "&8Bloki", "&aBloki", Collections.singletonList("&eKliknij aby przegladac!")); @@ -450,9 +465,9 @@ public Polish() { addDefaultStatsMsg(yml, "last-play", "&6Ostatnia gra", "&f{lastPlay}"); addDefaultStatsMsg(yml, "games-played", "&6Rozegrane gry", "&f{gamesPlayed}"); - yml.addDefault(Messages.REJOIN_NO_ARENA, "{prefix}&cThere is no arena to rejoin!"); - yml.addDefault(Messages.REJOIN_DENIED, "{prefix}&cYou can't rejoin the arena anymore. Game ended or bed destroyed."); - yml.addDefault(Messages.REJOIN_ALLOWED, "{prefix}&eJoining arena &a{arena}&e!"); + yml.addDefault(Messages.REJOIN_NO_ARENA, "{prefix}&cBrak areny do rejoinu"); + yml.addDefault(Messages.REJOIN_DENIED, "{prefix}&cNie możesz rejoinować!"); + yml.addDefault(Messages.REJOIN_ALLOWED, "{prefix}&eDołączasz do &a{arena}&e!"); yml.addDefault(Messages.MEANING_NO_TRAP, "No trap!"); yml.addDefault(Messages.FORMAT_UPGRADE_TRAP_COST, "&7Cost: {currencyColor}{cost} {currency}"); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Portuguese.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Portuguese.java index 8e3f74a8e..a19ff9cd1 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Portuguese.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Portuguese.java @@ -52,6 +52,20 @@ public Portuguese() { yml.set("player-die-knocked-final", null); } + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_WAITING,"&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_STARTING, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_SPECTATOR,"&9{serverIp}"); + + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_WAITING, "&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_STARTING,"&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_SPECTATOR,"&9{serverIp}"); + yml.addDefault(Messages.COMMAND_MAIN, Arrays.asList("", "&2▪ &7/" + mainCmd + " stats", "&2▪ &7/" + mainCmd + " join &o", "&2▪ &7/" + mainCmd + " leave", "&2▪ &7/" + mainCmd + " lang", "&2▪ &7/" + mainCmd + " gui", "&2▪ &7/" + mainCmd + " start &3(vip)")); yml.addDefault(Messages.COMMAND_LANG_LIST_HEADER, "{prefix} &2Idiomas disponíveis:"); yml.addDefault(Messages.COMMAND_LANG_LIST_FORMAT, "&a▪ &7{iso} - &f{name}"); @@ -163,9 +177,10 @@ public Portuguese() { yml.addDefault(Messages.FORMATTING_CHAT_SPECTATOR, "{level}{vPrefix}&7[SPECTATOR] {player}{vSuffix}: {message}"); yml.addDefault(Messages.FORMATTING_SCOREBOARD_HEALTH, Arrays.asList("&c❤", "&aVida")); yml.addDefault(Messages.FORMATTING_SPECTATOR_TEAM, "ESPEC"); - yml.addDefault(Messages.FORMATTING_SPECTATOR_COLOR, "&7"); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PRESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PRESTARTING, new ArrayList<>()); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_SPECTATOR, "&7"); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_SPECTATOR, ""); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_RESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_RESTARTING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}&l{teamLetter} &r{teamColor}")); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_STARTING, Arrays.asList("{vPrefix} ")); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Romanian.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Romanian.java index 96d3536aa..500c6c01f 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Romanian.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Romanian.java @@ -51,6 +51,20 @@ public Romanian() { yml.set("player-die-knocked-final", null); } + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_WAITING,"&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_STARTING, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_SPECTATOR,"&9{serverIp}"); + + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_WAITING, "&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_STARTING,"&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_SPECTATOR,"&9{serverIp}"); + yml.options().copyDefaults(true); yml.addDefault(Messages.COMMAND_MAIN, Arrays.asList("", "&2▪ &7/" + mainCmd + " stats", "&2▪ &7/" + mainCmd + " join &o", "&2▪ &7/" + mainCmd + " leave", "&2▪ &7/" + mainCmd + " lang", "&2▪ &7/" + mainCmd + " gui", "&2▪ &7/" + mainCmd + " start &3(vip)")); yml.addDefault(Messages.COMMAND_JOIN_DENIED_IS_FULL, "{prefix}&cArena este plina!\n&aAi putea lua in considerare donarea pentru mai multe facilitati. &7&o(click)"); @@ -165,9 +179,10 @@ public Romanian() { yml.addDefault(Messages.FORMATTING_CHAT_SPECTATOR, "{level}{vPrefix}&7[SPECTATOR] {player}{vSuffix}: {message}"); yml.addDefault(Messages.FORMATTING_SCOREBOARD_HEALTH, Arrays.asList("&c❤", "&aViață")); yml.addDefault(Messages.FORMATTING_SPECTATOR_TEAM, "SPECT"); - yml.addDefault(Messages.FORMATTING_SPECTATOR_COLOR, "&7"); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PRESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PRESTARTING, new ArrayList<>()); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_SPECTATOR, "&7"); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_SPECTATOR, ""); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_RESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_RESTARTING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}&l{teamLetter} &r{teamColor}")); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_STARTING, Arrays.asList("{vPrefix} ")); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Russian.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Russian.java index 2e3938997..e9d18c07b 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Russian.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Russian.java @@ -51,6 +51,20 @@ public Russian() { yml.set("player-die-knocked-final", null); } + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_WAITING,"&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_STARTING, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_SPECTATOR,"&9{serverIp}"); + + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_WAITING, "&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_STARTING,"&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_SPECTATOR,"&9{serverIp}"); + yml.options().copyDefaults(true); yml.addDefault(Messages.COMMAND_MAIN, Arrays.asList("", "&2▪ &7/" + mainCmd + " stats", "&2▪ &7/" + mainCmd + " join &o", "&2▪ &7/" + mainCmd + " leave", "&2▪ &7/" + mainCmd + " lang", "&2▪ &7/" + mainCmd + " gui", "&2▪ &7/" + mainCmd + " start &3(vip)")); yml.addDefault(Messages.ARENA_JOIN_VIP_KICK, "{prefix}&cИзвините, но вас выгнали, потому что к арене присоединился донатер.\n&aЧтобы иметь больше возможностей - купите донат. &7&o(жми)"); @@ -131,9 +145,10 @@ public Russian() { yml.addDefault(Messages.FORMATTING_SCOREBOARD_HEALTH, Arrays.asList("&c❤", "&aЗдоровье")); yml.addDefault(Messages.FORMATTING_SPECTATOR_TEAM, "SPECT"); - yml.addDefault(Messages.FORMATTING_SPECTATOR_COLOR, "&7"); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PRESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PRESTARTING, new ArrayList<>()); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_SPECTATOR, "&7"); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_SPECTATOR, ""); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_RESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_RESTARTING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}&l{teamLetter} &r{teamColor}")); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_STARTING, Arrays.asList("{vPrefix} ")); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Spanish.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Spanish.java index 32076fe82..0948f08f6 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Spanish.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Spanish.java @@ -52,6 +52,20 @@ public Spanish() { yml.set("player-die-knocked-final", null); } + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_WAITING,"&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_STARTING, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_SPECTATOR,"&9{serverIp}"); + + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_WAITING, "&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_STARTING,"&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_SPECTATOR,"&9{serverIp}"); + yml.options().copyDefaults(true); yml.addDefault(Messages.COMMAND_MAIN, Arrays.asList("", "&2▪ &7/" + mainCmd + " stats", "&2▪ &7/" + mainCmd + " join &o", "&2▪ &7/" + mainCmd + " leave", "&2▪ &7/" + mainCmd + " lang", "&2▪ &7/" + mainCmd + " gui", "&2▪ &7/" + mainCmd + " start &3(vip)")); yml.addDefault(Messages.ARENA_JOIN_VIP_KICK, "{prefix}&cHas sido expulsado ya que un VIP se ha unido a la partida.\n&aConsidere hacer una donación para obtener más funciones. &7&o(click)"); @@ -134,9 +148,10 @@ public Spanish() { yml.addDefault(Messages.FORMATTING_SCOREBOARD_HEALTH, Arrays.asList("&c❤", "&aSalud")); yml.addDefault(Messages.FORMATTING_SPECTATOR_TEAM, "SPECT"); - yml.addDefault(Messages.FORMATTING_SPECTATOR_COLOR, "&7"); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PRESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PRESTARTING, new ArrayList<>()); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_SPECTATOR, "&7"); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_SPECTATOR, ""); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_RESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_RESTARTING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}&l{teamLetter} &r{teamColor}")); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_STARTING, Arrays.asList("{vPrefix} ")); @@ -332,7 +347,7 @@ public Spanish() { yml.addDefault(Messages.ARENA_LEAVE_PARTY_DISBANDED, "{prefix}§cEl dueño de la party se fue y la party se disolvió!"); yml.addDefault(Messages.XP_REWARD_PER_MINUTE, "{prefix}&6+{xp} Experiencia de BedWars recibida (Tiempo de juego)."); - yml.addDefault(Messages.XP_REWARD_WIN, "{prefix}&6+{xp} Experiencia de BedWars recibida (Ganar partida)."); + yml.addDefault(Messages.XP_REWARD_WIN, "{prefix}&6+{xp} Experiencia de BedWars recibida (Victoria)."); yml.addDefault(Messages.XP_REWARD_PER_TEAMMATE, "{prefix}&6+{xp} Experiencia de BedWars recibida (Apoyo de equipo)."); yml.addDefault(Messages.XP_REWARD_BED_DESTROY, "{prefix}&6+{xp} Experiencia de BedWars recibida (Cama Destruida)."); yml.addDefault(Messages.XP_REWARD_REGULAR_KILL, "{prefix}&6+{xp} Experiencia de BedWars recibida (Asesinato)."); @@ -347,28 +362,28 @@ public Spanish() { //tienda yml.addDefault(Messages.SHOP_INDEX_NAME, "&8Compra rapida"); - yml.addDefault(Messages.SHOP_QUICK_ADD_NAME, "&8Adding to Quick Buy..."); + yml.addDefault(Messages.SHOP_QUICK_ADD_NAME, "&8Agregando a la Compra Rápida..."); yml.addDefault(Messages.SHOP_INSUFFICIENT_MONEY, "{prefix}&cNo tienes suficiente {currency}! Necesitas {amount} mas!"); yml.addDefault(Messages.SHOP_NEW_PURCHASE, "{prefix}&aCompraste &6{item}"); yml.addDefault(Messages.SHOP_ALREADY_BOUGHT, "{prefix}&cYa lo has comprado!"); - yml.addDefault(Messages.ARENA_LEAVE_PARTY_DISBANDED, "{prefix}§cThe party owner has left and the party was disbanded!"); - yml.addDefault(Messages.XP_REWARD_PER_MINUTE, "{prefix}&6+{xp} BedWars Experience Received (Play Time)."); - yml.addDefault(Messages.XP_REWARD_WIN, "{prefix}&6+{xp} BedWars Experience Received (Game Win)."); - yml.addDefault(Messages.XP_REWARD_PER_TEAMMATE, "{prefix}&6+{xp} BedWars Experience Received (Team Support)."); + yml.addDefault(Messages.ARENA_LEAVE_PARTY_DISBANDED, "{prefix}§cEl dueño de la party se fue y la party se disolvió!"); + yml.addDefault(Messages.XP_REWARD_PER_MINUTE, "{prefix}&6+{xp} Experiencia de BedWars recibida (Tiempo de juego)."); + yml.addDefault(Messages.XP_REWARD_WIN, "{prefix}&6+{xp} Experiencia de BedWars recibida (Victoria)."); + yml.addDefault(Messages.XP_REWARD_PER_TEAMMATE, "{prefix}&6+{xp} Experiencia de BedWars recibida (Ayuda al equipo)."); - yml.addDefault(Messages.MONEY_REWARD_PER_MINUTE, "{prefix}&6+{money} Coins (Play Time)."); - yml.addDefault(Messages.MONEY_REWARD_WIN, "{prefix}&6+{money} Coins (Game Win)."); - yml.addDefault(Messages.MONEY_REWARD_PER_TEAMMATE, "{prefix}&6+{money} Coins (Team Support)."); - yml.addDefault(Messages.MONEY_REWARD_BED_DESTROYED, "{prefix}&6+{money} Coins (Bed Destroyed)."); - yml.addDefault(Messages.MONEY_REWARD_FINAL_KILL, "{prefix}&6+{money} Coins (Final Kill)."); - yml.addDefault(Messages.MONEY_REWARD_REGULAR_KILL, "{prefix}&6+{money} Coins (Regular Kill)."); + yml.addDefault(Messages.MONEY_REWARD_PER_MINUTE, "{prefix}&6+{money} Monedas (Tiempo de juego)."); + yml.addDefault(Messages.MONEY_REWARD_WIN, "{prefix}&6+{money} Monedas (Victoria)."); + yml.addDefault(Messages.MONEY_REWARD_PER_TEAMMATE, "{prefix}&6+{money} Monedas (Ayuda al equipo)."); + yml.addDefault(Messages.MONEY_REWARD_BED_DESTROYED, "{prefix}&6+{money} Monedas (Cama Destruida)."); + yml.addDefault(Messages.MONEY_REWARD_FINAL_KILL, "{prefix}&6+{money} Monedas (Asesinato Final)."); + yml.addDefault(Messages.MONEY_REWARD_REGULAR_KILL, "{prefix}&6+{money} Monedas (Asesinato)."); //shop - yml.addDefault(Messages.SHOP_INDEX_NAME, "&8Quick Buy"); - yml.addDefault(Messages.SHOP_INSUFFICIENT_MONEY, "{prefix}&cYou don't have enough {currency}! Need {amount} more!"); - yml.addDefault(Messages.SHOP_NEW_PURCHASE, "{prefix}&aYou purchased &6{item}"); - yml.addDefault(Messages.SHOP_ALREADY_BOUGHT, "{prefix}&cYou've already bought that!"); + yml.addDefault(Messages.SHOP_INDEX_NAME, "&8Compra rapida"); + yml.addDefault(Messages.SHOP_INSUFFICIENT_MONEY, "{prefix}&cNo tienes suficiente {currency}! Necesitas {amount} más!"); + yml.addDefault(Messages.SHOP_NEW_PURCHASE, "{prefix}&aHas comprado &6{item}"); + yml.addDefault(Messages.SHOP_ALREADY_BOUGHT, "{prefix}&cYa has comprado esto!"); yml.addDefault(Messages.SHOP_UTILITY_NPC_SILVERFISH_NAME, "{TeamColor}&l{TeamName} &r{TeamColor}Silverfish"); yml.addDefault(Messages.SHOP_UTILITY_NPC_IRON_GOLEM_NAME, "{TeamColor}{despawn}s &8[ {TeamColor}{health}&8]"); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Turkish.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Turkish.java index b21cc1bea..2f7af599e 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Turkish.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/language/Turkish.java @@ -54,6 +54,20 @@ public Turkish() { yml.set("player-die-knocked-final", null); } + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_WAITING,"&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_STARTING, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_HEADER_SPECTATOR,"&9{serverIp}"); + + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_LOBBY, "&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_WAITING, "&a{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_STARTING,"&6{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_PLAYING, "&d{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_RESTARTING, "&c{serverIp}"); + yml.addDefault(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_SPECTATOR,"&9{serverIp}"); + yml.addDefault(Messages.COMMAND_MAIN, Arrays.asList("", "&2▪ &7/" + mainCmd + " stats", "&2▪ &7/" + mainCmd + " join &o", "&2▪ &7/" + mainCmd + " leave", "&2▪ &7/" + mainCmd + " lang", "&2▪ &7/" + mainCmd + " gui", "&2▪ &7/" + mainCmd + " start &3(vip)")); yml.addDefault(Messages.COMMAND_LANG_LIST_HEADER, "{prefix} &2Mevcut diller:"); yml.addDefault(Messages.COMMAND_LANG_LIST_FORMAT, "&a▪ &7{iso} - &f{name}"); @@ -165,9 +179,10 @@ public Turkish() { yml.addDefault(Messages.FORMATTING_CHAT_SPECTATOR, "{level}{vPrefix}&7[SPECTATOR] {player}{vSuffix}: {message}"); yml.addDefault(Messages.FORMATTING_SCOREBOARD_HEALTH, Arrays.asList("&c❤", "&aCan")); yml.addDefault(Messages.FORMATTING_SPECTATOR_TEAM, "SEYIRCI"); - yml.addDefault(Messages.FORMATTING_SPECTATOR_COLOR, "&7"); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PRESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); - yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PRESTARTING, new ArrayList<>()); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_SPECTATOR, "&7"); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_SPECTATOR, ""); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_RESTARTING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}")); + yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_RESTARTING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING, Arrays.asList("{teamColor}&l{teamLetter} &r{teamColor}", "{team} ", "{vPrefix} {teamColor}&l{teamLetter} &r{teamColor}")); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING, new ArrayList<>()); yml.addDefault(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_STARTING, Arrays.asList("{vPrefix} ")); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/BreakPlace.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/BreakPlace.java index c0dfe5597..f284a3484 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/BreakPlace.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/BreakPlace.java @@ -26,6 +26,7 @@ import com.andrei1058.bedwars.api.arena.NextEvent; import com.andrei1058.bedwars.api.arena.generator.IGenerator; import com.andrei1058.bedwars.api.arena.team.ITeam; +import com.andrei1058.bedwars.api.arena.team.TeamColor; import com.andrei1058.bedwars.api.configuration.ConfigPath; import com.andrei1058.bedwars.api.events.player.PlayerBedBreakEvent; import com.andrei1058.bedwars.api.language.Language; @@ -35,7 +36,13 @@ import com.andrei1058.bedwars.arena.Arena; import com.andrei1058.bedwars.commands.bedwars.subcmds.sensitive.setup.AutoCreateTeams; import com.andrei1058.bedwars.configuration.Sounds; +import com.andrei1058.bedwars.support.paper.PaperSupport; +import com.andrei1058.bedwars.popuptower.TowerEast; +import com.andrei1058.bedwars.popuptower.TowerNorth; +import com.andrei1058.bedwars.popuptower.TowerSouth; +import com.andrei1058.bedwars.popuptower.TowerWest; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -131,7 +138,7 @@ public void onBlockPlace(BlockPlaceEvent e) { e.setCancelled(true); return; } - if(e.getItemInHand().getType().equals(nms.materialFireball()) && e.getBlockPlaced().getType().equals(Material.FIRE)) { + if (e.getItemInHand().getType().equals(nms.materialFireball()) && e.getBlockPlaced().getType().equals(Material.FIRE)) { e.setCancelled(true); } } @@ -179,6 +186,29 @@ public void onBlockPlace(BlockPlaceEvent e) { tnt.setFuseTicks(45); nms.setSource(tnt, p); return; + } else if (BedWars.shop.getBoolean(ConfigPath.SHOP_SPECIAL_TOWER_ENABLE)) { + if (e.getBlock().getType() == Material.valueOf(shop.getString(ConfigPath.SHOP_SPECIAL_TOWER_MATERIAL))) { + + e.setCancelled(true); + Location loc = e.getBlock().getLocation(); + IArena a1 = Arena.getArenaByPlayer(p); + TeamColor col = a1.getTeam(p).getColor(); + double rotation = (p.getLocation().getYaw() - 90.0F) % 360.0F; + if (rotation < 0.0D) { + rotation += 360.0D; + } + if (45.0D <= rotation && rotation < 135.0D) { + new TowerSouth(loc, e.getBlockPlaced(), col, p); + } else if (225.0D <= rotation && rotation < 315.0D) { + new TowerNorth(loc, e.getBlockPlaced(), col, p); + } else if (135.0D <= rotation && rotation < 225.0D) { + new TowerWest(loc, e.getBlockPlaced(), col, p); + } else if (0.0D <= rotation && rotation < 45.0D) { + new TowerEast(loc, e.getBlockPlaced(), col, p); + } else if (315.0D <= rotation && rotation < 360.0D) { + new TowerEast(loc, e.getBlockPlaced(), col, p); + } + } } return; } @@ -267,7 +297,7 @@ public void onBlockBreak(BlockBreakEvent e) { } return; case "FIRE": - if(allowFireBreak) { + if (allowFireBreak) { e.setCancelled(false); return; } @@ -285,7 +315,7 @@ public void onBlockBreak(BlockBreakEvent e) { p.sendMessage(getMsg(p, Messages.INTERACT_CANNOT_BREAK_OWN_BED)); e.setCancelled(true); if (e.getPlayer().getLocation().getBlock().getType().toString().contains("BED")) { - e.getPlayer().teleport(e.getPlayer().getLocation().add(0, 0.5, 0)); + PaperSupport.teleport(e.getPlayer(), e.getPlayer().getLocation().add(0, 0.5, 0)); } } else { e.setCancelled(false); @@ -323,7 +353,8 @@ public void onBlockBreak(BlockBreakEvent e) { if (breakEvent.getTitle() != null && breakEvent.getSubTitle() != null) { nms.sendTitle(on, breakEvent.getTitle().apply(on), breakEvent.getSubTitle().apply(on), 0, 40, 10); } - if (t.isMember(on)) Sounds.playSound(ConfigPath.SOUNDS_BED_DESTROY_OWN, on); + if (t.isMember(on)) + Sounds.playSound(ConfigPath.SOUNDS_BED_DESTROY_OWN, on); else Sounds.playSound(ConfigPath.SOUNDS_BED_DESTROY, on); } } @@ -391,7 +422,8 @@ public void onSignChange(SignChangeEvent e) { int line = 0; for (String string : BedWars.signs.getList("format")) { e.setLine(line, string.replace("[on]", String.valueOf(a.getPlayers().size())).replace("[max]", - String.valueOf(a.getMaxPlayers())).replace("[arena]", a.getDisplayName()).replace("[status]", a.getDisplayStatus(Language.getDefaultLanguage()))); + String.valueOf(a.getMaxPlayers())).replace("[arena]", a.getDisplayName()).replace("[status]", a.getDisplayStatus(Language.getDefaultLanguage())) + .replace("[type]", String.valueOf(a.getMaxInTeam()))); line++; } b.update(true); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/DamageDeathMove.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/DamageDeathMove.java index 1c1955f7b..76ef97f3c 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/DamageDeathMove.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/DamageDeathMove.java @@ -40,6 +40,7 @@ import com.andrei1058.bedwars.arena.team.BedWarsTeam; import com.andrei1058.bedwars.configuration.Sounds; import com.andrei1058.bedwars.listeners.dropshandler.PlayerDrops; +import com.andrei1058.bedwars.support.paper.PaperSupport; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -57,7 +58,7 @@ import org.bukkit.util.Vector; import java.text.DecimalFormat; -import java.util.*; +import java.util.Map; import static com.andrei1058.bedwars.BedWars.*; import static com.andrei1058.bedwars.api.language.Language.getMsg; @@ -601,7 +602,7 @@ public void onMove(PlayerMoveEvent e) { if (a.isSpectator(e.getPlayer()) || a.isReSpawning(e.getPlayer())) { if (e.getTo().getY() < 0) { - e.getPlayer().teleport(a.isSpectator(e.getPlayer()) ? a.getSpectatorLocation() : a.getReSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(e.getPlayer(), a.isSpectator(e.getPlayer()) ? a.getSpectatorLocation() : a.getReSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); e.getPlayer().setAllowFlight(true); e.getPlayer().setFlying(true); // how to remove fall velocity? @@ -636,9 +637,9 @@ public void onMove(PlayerMoveEvent e) { if (e.getPlayer().getLocation().getBlockY() <= 0) { ITeam bwt = a.getTeam(e.getPlayer()); if (bwt != null) { - e.getPlayer().teleport(bwt.getSpawn()); + PaperSupport.teleport(e.getPlayer(), bwt.getSpawn()); } else { - e.getPlayer().teleport(a.getSpectatorLocation()); + PaperSupport.teleport(e.getPlayer(), a.getSpectatorLocation()); } } } @@ -646,7 +647,7 @@ public void onMove(PlayerMoveEvent e) { } else { if (e.getPlayer().getWorld().getName().equalsIgnoreCase(config.getLobbyWorldName()) && BedWars.getServerType() == ServerType.MULTIARENA) { if (e.getTo().getY() < 0) { - e.getPlayer().teleport(config.getConfigLoc("lobbyLoc")); + PaperSupport.teleport(e.getPlayer(), config.getConfigLoc("lobbyLoc")); } } } @@ -694,6 +695,9 @@ public void onEntityDeath(EntityDeathEvent e) { e.setDroppedExp(0); } } + + // clean if necessary + nms.getDespawnablesList().remove(e.getEntity().getUniqueId()); } @EventHandler diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/GameEndListener.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/GameEndListener.java new file mode 100644 index 000000000..49c09faa2 --- /dev/null +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/GameEndListener.java @@ -0,0 +1,36 @@ +package com.andrei1058.bedwars.listeners; + +import com.andrei1058.bedwars.api.events.gameplay.GameEndEvent; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.UUID; + +public class GameEndListener implements Listener { + + @EventHandler + public void cleanInventoriesAndDroppedItems(@NotNull GameEndEvent event) { + if (event.getArena().getPlayers().isEmpty()) { + return; + } + + // clear inventories + for (UUID p : event.getAliveWinners()) { + Bukkit.getPlayer(p).getInventory().clear(); + } + + // clear dropped items + World game = event.getArena().getWorld(); + for (Entity item : game.getEntities()) { + if (item instanceof Item || item instanceof ItemStack){ + item.remove(); + } + } + } +} diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/InvisibilityPotionListener.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/InvisibilityPotionListener.java index bac1eb531..f974bceb9 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/InvisibilityPotionListener.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/InvisibilityPotionListener.java @@ -24,7 +24,7 @@ import com.andrei1058.bedwars.api.arena.team.ITeam; import com.andrei1058.bedwars.api.events.player.PlayerInvisibilityPotionEvent; import com.andrei1058.bedwars.arena.Arena; -import com.andrei1058.bedwars.sidebar.BedWarsScoreboard; +import com.andrei1058.bedwars.sidebar.SidebarService; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -32,9 +32,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; import static com.andrei1058.bedwars.BedWars.nms; import static com.andrei1058.bedwars.BedWars.plugin; @@ -46,23 +45,11 @@ public class InvisibilityPotionListener implements Listener { @EventHandler - public void onPotion(PlayerInvisibilityPotionEvent e) { + public void onPotion(@NotNull PlayerInvisibilityPotionEvent e) { if (e.getTeam() == null) return; - if (e.getType() == PlayerInvisibilityPotionEvent.Type.ADDED) { - for (BedWarsScoreboard sb : BedWarsScoreboard.getScoreboards().values()) { - if (sb.getArena() == null) continue; - if (sb.getArena().equals(e.getArena())) { - sb.invisibilityPotion(e.getTeam(), e.getPlayer(), true); - } - } - } else { - for (BedWarsScoreboard sb : BedWarsScoreboard.getScoreboards().values()) { - if (sb.getArena() == null) continue; - if (sb.getArena().equals(e.getArena())) { - sb.invisibilityPotion(e.getTeam(), e.getPlayer(), false); - } - } - } + SidebarService.getInstance().handleInvisibility( + e.getTeam(), e.getPlayer(), e.getType() == PlayerInvisibilityPotionEvent.Type.ADDED + ); } @EventHandler diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/QuitAndTeleportListener.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/QuitAndTeleportListener.java index ec1d8cdde..08750554b 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/QuitAndTeleportListener.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/QuitAndTeleportListener.java @@ -31,7 +31,7 @@ import com.andrei1058.bedwars.arena.SetupSession; import com.andrei1058.bedwars.arena.team.BedWarsTeam; import com.andrei1058.bedwars.commands.bedwars.subcmds.regular.CmdStats; -import com.andrei1058.bedwars.sidebar.BedWarsScoreboard; +import com.andrei1058.bedwars.sidebar.SidebarService; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -88,10 +88,7 @@ public void onLeave(PlayerQuitEvent e) { ss.cancel(); } - BedWarsScoreboard sb = BedWarsScoreboard.getSBoard(e.getPlayer().getUniqueId()); - if (sb != null) { - sb.remove(); - } + SidebarService.getInstance().remove(e.getPlayer()); BedWarsTeam.reSpawnInvulnerability.remove(e.getPlayer().getUniqueId()); @@ -129,12 +126,9 @@ public void onWorldChange(PlayerChangedWorldEvent e) { if (BedWars.config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_USE_LOBBY_SIDEBAR)) { //Bukkit.getScheduler().runTaskLater(plugin, ()-> { if (e.getPlayer().getWorld().getName().equalsIgnoreCase(BedWars.getLobbyWorld())) { - BedWarsScoreboard.giveScoreboard(e.getPlayer(), null, true); + SidebarService.getInstance().giveSidebar(e.getPlayer(), null, true); } else { - BedWarsScoreboard sb = BedWarsScoreboard.getSBoard(e.getPlayer().getUniqueId()); - if (sb != null) { - sb.remove(); - } + SidebarService.getInstance().remove(e.getPlayer()); } //}, 2L); } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/joinhandler/JoinListenerBungee.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/joinhandler/JoinListenerBungee.java index 3d35f6660..a25fb8d45 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/joinhandler/JoinListenerBungee.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/joinhandler/JoinListenerBungee.java @@ -30,6 +30,7 @@ import com.andrei1058.bedwars.configuration.Permissions; import com.andrei1058.bedwars.configuration.Sounds; import com.andrei1058.bedwars.lobbysocket.LoadedUser; +import com.andrei1058.bedwars.support.paper.PaperSupport; import com.andrei1058.bedwars.support.preloadedparty.PreLoadedParty; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -122,7 +123,7 @@ public void onPlayerJoin(PlayerJoinEvent e) { Bukkit.dispatchCommand(p, "bw"); World mainWorld = Bukkit.getWorlds().get(0); if (mainWorld != null) { - p.teleport(mainWorld.getSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + PaperSupport.teleportC(p, mainWorld.getSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); } // hide admin to in game users for (Player inGame : Bukkit.getOnlinePlayers()){ diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/joinhandler/JoinListenerMultiArena.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/joinhandler/JoinListenerMultiArena.java index 40eb02137..0d2b5832e 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/joinhandler/JoinListenerMultiArena.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/joinhandler/JoinListenerMultiArena.java @@ -23,7 +23,8 @@ import com.andrei1058.bedwars.BedWars; import com.andrei1058.bedwars.arena.Arena; import com.andrei1058.bedwars.arena.ReJoin; -import com.andrei1058.bedwars.sidebar.BedWarsScoreboard; +import com.andrei1058.bedwars.sidebar.SidebarService; +import com.andrei1058.bedwars.support.paper.PaperSupport; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -31,7 +32,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerTeleportEvent; import static com.andrei1058.bedwars.BedWars.*; @@ -82,13 +82,13 @@ public void onJoin(PlayerJoinEvent e) { // Teleport to lobby location Location lobbyLocation = config.getConfigLoc("lobbyLoc"); if (lobbyLocation != null && lobbyLocation.getWorld() != null) { - Bukkit.getScheduler().runTaskLater(plugin, () -> p.teleport(lobbyLocation, PlayerTeleportEvent.TeleportCause.PLUGIN), 2L); + PaperSupport.teleport(p, lobbyLocation); } // Send items Arena.sendLobbyCommandItems(p); - BedWarsScoreboard.giveScoreboard(p, null, true); + SidebarService.getInstance().giveSidebar(p, null, true); p.setHealthScale(p.getMaxHealth()); p.setExp(0); diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/joinhandler/JoinListenerShared.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/joinhandler/JoinListenerShared.java index 00807d0ab..133cedadd 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/joinhandler/JoinListenerShared.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/listeners/joinhandler/JoinListenerShared.java @@ -22,7 +22,7 @@ import com.andrei1058.bedwars.BedWars; import com.andrei1058.bedwars.arena.Arena; -import com.andrei1058.bedwars.sidebar.BedWarsScoreboard; +import com.andrei1058.bedwars.sidebar.SidebarService; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -58,7 +58,7 @@ public void onJoin(PlayerJoinEvent e){ // Give scoreboard if (e.getPlayer().getWorld().getName().equalsIgnoreCase(BedWars.getLobbyWorld())) { - BedWarsScoreboard.giveScoreboard(e.getPlayer(), null, true); + SidebarService.getInstance().giveSidebar(e.getPlayer(), null, true); } } } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/money/internal/MoneyListeners.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/money/internal/MoneyListeners.java index a7f0045c8..2d6f7bb1b 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/money/internal/MoneyListeners.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/money/internal/MoneyListeners.java @@ -1,6 +1,8 @@ package com.andrei1058.bedwars.money.internal; import com.andrei1058.bedwars.BedWars; +import com.andrei1058.bedwars.api.arena.IArena; +import com.andrei1058.bedwars.api.arena.team.ITeam; import com.andrei1058.bedwars.api.events.gameplay.GameEndEvent; import com.andrei1058.bedwars.api.events.player.PlayerBedBreakEvent; import com.andrei1058.bedwars.api.events.player.PlayerKillEvent; @@ -21,22 +23,39 @@ public class MoneyListeners implements Listener { */ @EventHandler public void onGameEnd(GameEndEvent e) { - for (UUID p : e.getWinners ()) { - Player player = Bukkit.getPlayer ( p ); + for (UUID p : e.getWinners()) { + Player player = Bukkit.getPlayer(p); if (player == null) continue; - int gamewin = MoneyConfig.money.getInt ( "money-rewards.game-win" ); - if (gamewin > 0) { - BedWars.getEconomy ().giveMoney ( player, gamewin ); - player.sendMessage ( Language.getMsg ( player, Messages.MONEY_REWARD_WIN ).replace ( "{money}", String.valueOf ( gamewin ) ) ); + int gameWin = MoneyConfig.money.getInt("money-rewards.game-win"); + if (gameWin > 0) { + BedWars.getEconomy().giveMoney(player, gameWin); + player.sendMessage(Language.getMsg(player, Messages.MONEY_REWARD_WIN).replace("{money}", String.valueOf(gameWin))); + } + ITeam bwt = e.getArena().getExTeam(player.getUniqueId()); + IArena arena = e.getArena(); + if (bwt != null) { + if (arena.getMaxInTeam() > 1) { + int teamMate = MoneyConfig.money.getInt("money-rewards.per-teammate"); + if (teamMate > 0) { + BedWars.getEconomy().giveMoney(player, teamMate); + player.sendMessage(Language.getMsg(player, Messages.MONEY_REWARD_PER_TEAMMATE).replace("{money}", String.valueOf(teamMate))); + } + } } } - for (UUID p : e.getLosers ()) { - Player player = Bukkit.getPlayer ( p ); + for (UUID p : e.getLosers()) { + Player player = Bukkit.getPlayer(p); if (player == null) continue; - int teammate = MoneyConfig.money.getInt ( "money-rewards.per-teammate" ); - if (teammate > 0) { - BedWars.getEconomy ().giveMoney ( player, teammate ); - player.sendMessage ( Language.getMsg ( player, Messages.MONEY_REWARD_PER_TEAMMATE ).replace ( "{money}", String.valueOf ( teammate ) ) ); + ITeam bwt = e.getArena().getExTeam(player.getUniqueId()); + IArena arena = e.getArena(); + if (bwt != null) { + if (arena.getMaxInTeam() > 1) { + int teamMate = MoneyConfig.money.getInt("money-rewards.per-teammate"); + if (teamMate > 0) { + BedWars.getEconomy().giveMoney(player, teamMate); + player.sendMessage(Language.getMsg(player, Messages.MONEY_REWARD_PER_TEAMMATE).replace("{money}", String.valueOf(teamMate))); + } + } } } } @@ -48,10 +67,10 @@ public void onGameEnd(GameEndEvent e) { public void onBreakBed(PlayerBedBreakEvent e) { Player player = e.getPlayer (); if (player == null) return; - int beddestroy = MoneyConfig.money.getInt ( "money-rewards.bed-destroyed" ); - if (beddestroy > 0) { - BedWars.getEconomy ().giveMoney ( player, beddestroy ); - player.sendMessage ( Language.getMsg ( player, Messages.MONEY_REWARD_BED_DESTROYED ).replace ( "{money}", String.valueOf ( beddestroy ) ) ); + int bedDestroy = MoneyConfig.money.getInt("money-rewards.bed-destroyed"); + if (bedDestroy > 0) { + BedWars.getEconomy().giveMoney(player, bedDestroy); + player.sendMessage(Language.getMsg(player, Messages.MONEY_REWARD_BED_DESTROYED).replace("{money}", String.valueOf(bedDestroy))); } } @@ -60,20 +79,20 @@ public void onBreakBed(PlayerBedBreakEvent e) { */ @EventHandler public void onKill(PlayerKillEvent e) { - Player player = e.getKiller (); - Player victim = e.getVictim (); + Player player = e.getKiller(); + Player victim = e.getVictim(); if (player == null || victim.equals(player)) return; - int finalkill = MoneyConfig.money.getInt ( "money-rewards.final-kill" ); - int regularkill = MoneyConfig.money.getInt ( "money-rewards.regular-kill" ); - if (e.getCause ().isFinalKill ()) { - if (finalkill > 0) { - BedWars.getEconomy ().giveMoney ( player, finalkill ); - player.sendMessage ( Language.getMsg ( player, Messages.MONEY_REWARD_FINAL_KILL ).replace ( "{money}", String.valueOf ( finalkill ) ) ); + int finalKill = MoneyConfig.money.getInt("money-rewards.final-kill"); + int regularKill = MoneyConfig.money.getInt("money-rewards.regular-kill"); + if (e.getCause().isFinalKill()) { + if (finalKill > 0) { + BedWars.getEconomy().giveMoney(player, finalKill); + player.sendMessage(Language.getMsg(player, Messages.MONEY_REWARD_FINAL_KILL).replace("{money}", String.valueOf(finalKill))); } } else { - if (regularkill > 0) { - BedWars.getEconomy ().giveMoney ( player, regularkill ); - player.sendMessage ( Language.getMsg ( player, Messages.MONEY_REWARD_REGULAR_KILL ).replace ( "{money}", String.valueOf ( regularkill ) ) ); + if (regularKill > 0) { + BedWars.getEconomy().giveMoney(player, regularKill); + player.sendMessage(Language.getMsg(player, Messages.MONEY_REWARD_REGULAR_KILL).replace("{money}", String.valueOf(regularKill))); } } } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/money/internal/MoneyPerMinuteTask.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/money/internal/MoneyPerMinuteTask.java index e5f454a78..d21c9f8ea 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/money/internal/MoneyPerMinuteTask.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/money/internal/MoneyPerMinuteTask.java @@ -19,13 +19,17 @@ public class MoneyPerMinuteTask { * Create a new per minute money reward. */ public MoneyPerMinuteTask(Arena arena) { - if (money < 1){ + if (money < 1) { return; } - task = Bukkit.getScheduler().runTaskTimer( BedWars.plugin, () -> { + task = Bukkit.getScheduler().runTaskTimer(BedWars.plugin, () -> { + if (null == arena){ + this.cancel(); + return; + } for (Player p : arena.getPlayers()) { - BedWars.getEconomy ().giveMoney ( p, money ); - p.sendMessage ( Language.getMsg ( p, Messages.MONEY_REWARD_PER_MINUTE ).replace ( "{money}", String.valueOf ( money ) ) ); + BedWars.getEconomy().giveMoney(p, money); + p.sendMessage(Language.getMsg(p, Messages.MONEY_REWARD_PER_MINUTE).replace("{money}", String.valueOf(money))); } }, 60 * 20, 60 * 20); } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/NewPlaceBlock.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/NewPlaceBlock.java new file mode 100644 index 000000000..da656fb6b --- /dev/null +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/NewPlaceBlock.java @@ -0,0 +1,34 @@ +package com.andrei1058.bedwars.popuptower; + +import com.andrei1058.bedwars.BedWars; +import com.andrei1058.bedwars.api.arena.team.TeamColor; +import com.andrei1058.bedwars.api.region.Region; +import com.andrei1058.bedwars.arena.Arena; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +import java.util.Iterator; + +public class NewPlaceBlock { + public NewPlaceBlock(Block b, String xyz, TeamColor color, Player p, boolean ladder, int ladderdata) { + int x = Integer.parseInt(xyz.split(", ")[0]); + int y = Integer.parseInt(xyz.split(", ")[1]); + int z = Integer.parseInt(xyz.split(", ")[2]); + if (b.getRelative(x, y, z).getType().equals(Material.AIR)) { + Iterator var10 = Arena.getArenaByPlayer(p).getRegionsList().iterator(); + while(var10.hasNext()) { + Region r = (Region)var10.next(); + if (r.isInRegion(b.getRelative(x, y, z).getLocation())) { + return; + } + } + if (!ladder) { + BedWars.nms.placeTowerBlocks(b, Arena.getArenaByPlayer(p), color, x, y, z); + } else { + BedWars.nms.placeLadder(b, x, y, z, Arena.getArenaByPlayer(p), ladderdata); + } + } + + } +} diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerEast.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerEast.java new file mode 100644 index 000000000..761613606 --- /dev/null +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerEast.java @@ -0,0 +1,167 @@ +package com.andrei1058.bedwars.popuptower; + +import com.andrei1058.bedwars.BedWars; +import com.andrei1058.bedwars.api.arena.team.TeamColor; +import com.andrei1058.bedwars.configuration.Sounds; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitTask; + +import java.util.ArrayList; +import java.util.List; + +public class TowerEast { + private BukkitTask task; + public TowerEast(Location loc, Block chest, TeamColor color, Player p) { + ItemStack itemInHand = p.getInventory().getItemInHand(); + if (itemInHand.getAmount() > 1) { + itemInHand.setAmount(itemInHand.getAmount() - 1); + } else { + p.getInventory().setItemInHand(null); + } + + List relloc = new ArrayList(); + relloc.add("2, 0, -1"); + relloc.add("1, 0, -2"); + relloc.add("0, 0, -2"); + relloc.add("-1, 0, -1"); + relloc.add("-1, 0, 0"); + relloc.add("-1, 0, 1"); + relloc.add("0, 0, 2"); + relloc.add("1, 0, 2"); + relloc.add("2, 0, 1"); + relloc.add("0, 0, 0, ladder5"); + relloc.add("2, 1, -1"); + relloc.add("1, 1, -2"); + relloc.add("0, 1, -2"); + relloc.add("-1, 1, -1"); + relloc.add("-1, 1, 0"); + relloc.add("-1, 1, 1"); + relloc.add("0, 1, 2"); + relloc.add("1, 1, 2"); + relloc.add("2, 1, 1"); + relloc.add("0, 1, 0, ladder5"); + relloc.add("2, 2, -1"); + relloc.add("1, 2, -2"); + relloc.add("0, 2, -2"); + relloc.add("-1, 2, -1"); + relloc.add("-1, 2, 0"); + relloc.add("-1, 2, 1"); + relloc.add("0, 2, 2"); + relloc.add("1, 2, 2"); + relloc.add("2, 2, 1"); + relloc.add("0, 2, 0, ladder5"); + relloc.add("2, 3, 0"); + relloc.add("2, 3, -1"); + relloc.add("1, 3, -2"); + relloc.add("0, 3, -2"); + relloc.add("-1, 3, -1"); + relloc.add("-1, 3, 0"); + relloc.add("-1, 3, 1"); + relloc.add("0, 3, 2"); + relloc.add("1, 3, 2"); + relloc.add("2, 3, 1"); + relloc.add("0, 3, 0, ladder5"); + relloc.add("2, 4, 0"); + relloc.add("2, 4, -1"); + relloc.add("1, 4, -2"); + relloc.add("0, 4, -2"); + relloc.add("-1, 4, -1"); + relloc.add("-1, 4, 0"); + relloc.add("-1, 4, 1"); + relloc.add("0, 4, 2"); + relloc.add("1, 4, 2"); + relloc.add("2, 4, 1"); + relloc.add("0, 4, 0, ladder5"); + relloc.add("-1, 5, -2"); + relloc.add("0, 5, -2"); + relloc.add("1, 5, -2"); + relloc.add("2, 5, -2"); + relloc.add("-1, 5, -1"); + relloc.add("0, 5, -1"); + relloc.add("1, 5, -1"); + relloc.add("2, 5, -1"); + relloc.add("-1, 5, 0"); + relloc.add("1, 5, 0"); + relloc.add("2, 5, 0"); + relloc.add("-1, 5, 1"); + relloc.add("0, 5, 0, ladder5"); + relloc.add("0, 5, 1"); + relloc.add("1, 5, 1"); + relloc.add("2, 5, 1"); + relloc.add("-1, 5, 2"); + relloc.add("0, 5, 2"); + relloc.add("1, 5, 2"); + relloc.add("2, 5, 2"); + relloc.add("2, 5, -3"); + relloc.add("2, 6, -3"); + relloc.add("2, 7, -3"); + relloc.add("1, 6, -3"); + relloc.add("0, 6, -3"); + relloc.add("-1, 5, -3"); + relloc.add("-1, 6, -3"); + relloc.add("-1, 7, -3"); + relloc.add("-2, 5, -2"); + relloc.add("-2, 6, -2"); + relloc.add("-2, 7, -2"); + relloc.add("-2, 6, -1"); + relloc.add("-2, 5, 0"); + relloc.add("-2, 6, 0"); + relloc.add("-2, 7, 0"); + relloc.add("-2, 6, 1"); + relloc.add("-2, 5, 2"); + relloc.add("-2, 6, 2"); + relloc.add("-2, 7, 2"); + relloc.add("2, 5, 3"); + relloc.add("2, 6, 3"); + relloc.add("2, 7, 3"); + relloc.add("1, 6, 3"); + relloc.add("0, 6, 3"); + relloc.add("-1, 5, 3"); + relloc.add("-1, 6, 3"); + relloc.add("-1, 7, 3"); + relloc.add("3, 5, -2"); + relloc.add("3, 6, -2"); + relloc.add("3, 7, -2"); + relloc.add("3, 6, -1"); + relloc.add("3, 5, 0"); + relloc.add("3, 6, 0"); + relloc.add("3, 7, 0"); + relloc.add("3, 6, 1"); + relloc.add("3, 5, 2"); + relloc.add("3, 6, 2"); + relloc.add("3, 7, 2"); + int[] i = new int[]{0}; + this.task = Bukkit.getScheduler().runTaskTimer(BedWars.plugin, () -> { + Sounds.playsoundArea("pop-up-tower-build", loc, 1.0F, 0.5F); + if (relloc.size() + 1 == i[0] + 1) { + this.task.cancel(); + } else { + String c1 = relloc.get(i[0]); + if (c1.contains("ladder")) { + int ldata = Integer.parseInt(c1.split("ladder")[1]); + new NewPlaceBlock(chest, c1, color, p, true, ldata); + } else { + new NewPlaceBlock(chest, c1, color, p, false, 0); + } + + if (relloc.size() + 1 == i[0] + 2) { + this.task.cancel(); + } else { + String c2 = relloc.get(i[0] + 1); + if (c2.contains("ladder")) { + int ldatax = Integer.parseInt(c2.split("ladder")[1]); + new NewPlaceBlock(chest, c2, color, p, true, ldatax); + } else { + new NewPlaceBlock(chest, c2, color, p, false, 0); + } + + i[0] += 2; + } + } + }, 0L, 1L); + } +} diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerNorth.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerNorth.java new file mode 100644 index 000000000..67699ddc5 --- /dev/null +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerNorth.java @@ -0,0 +1,168 @@ +package com.andrei1058.bedwars.popuptower; + +import com.andrei1058.bedwars.BedWars; +import com.andrei1058.bedwars.api.arena.team.TeamColor; +import com.andrei1058.bedwars.configuration.Sounds; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitTask; + +import java.util.ArrayList; +import java.util.List; + +public class TowerNorth { + private BukkitTask task; + + public TowerNorth(Location loc, Block chest, TeamColor color, Player p) { + ItemStack itemInHand = p.getInventory().getItemInHand(); + if (itemInHand.getAmount() > 1) { + itemInHand.setAmount(itemInHand.getAmount() - 1); + } else { + p.getInventory().setItemInHand(null); + } + + List relloc = new ArrayList(); + relloc.add("-1, 0, -2"); + relloc.add("-2, 0, -1"); + relloc.add("-2, 0, 0"); + relloc.add("-1, 0, 1"); + relloc.add("0, 0, 1"); + relloc.add("1, 0, 1"); + relloc.add("2, 0, 0"); + relloc.add("2, 0, -1"); + relloc.add("1, 0, -2"); + relloc.add("0, 0, 0, ladder2"); + relloc.add("-1, 1, -2"); + relloc.add("-2, 1, -1"); + relloc.add("-2, 1, 0"); + relloc.add("-1, 1, 1"); + relloc.add("0, 1, 1"); + relloc.add("1, 1, 1"); + relloc.add("2, 1, 0"); + relloc.add("2, 1, -1"); + relloc.add("1, 1, -2"); + relloc.add("0, 1, 0, ladder2"); + relloc.add("-1, 2, -2"); + relloc.add("-2, 2, -1"); + relloc.add("-2, 2, 0"); + relloc.add("-1, 2, 1"); + relloc.add("0, 2, 1"); + relloc.add("1, 2, 1"); + relloc.add("2, 2, 0"); + relloc.add("2, 2, -1"); + relloc.add("1, 2, -2"); + relloc.add("0, 2, 0, ladder2"); + relloc.add("0, 3, -2"); + relloc.add("-1, 3, -2"); + relloc.add("-2, 3, -1"); + relloc.add("-2, 3, 0"); + relloc.add("-1, 3, 1"); + relloc.add("0, 3, 1"); + relloc.add("1, 3, 1"); + relloc.add("2, 3, 0"); + relloc.add("2, 3, -1"); + relloc.add("1, 3, -2"); + relloc.add("0, 3, 0, ladder2"); + relloc.add("0, 4, -2"); + relloc.add("-1, 4, -2"); + relloc.add("-2, 4, -1"); + relloc.add("-2, 4, 0"); + relloc.add("-1, 4, 1"); + relloc.add("0, 4, 1"); + relloc.add("1, 4, 1"); + relloc.add("2, 4, 0"); + relloc.add("2, 4, -1"); + relloc.add("1, 4, -2"); + relloc.add("0, 4, 0, ladder2"); + relloc.add("-2, 5, 1"); + relloc.add("-2, 5, 0"); + relloc.add("-2, 5, -1"); + relloc.add("-2, 5, -2"); + relloc.add("-1, 5, 1"); + relloc.add("-1, 5, 0"); + relloc.add("-1, 5, -1"); + relloc.add("-1, 5, -2"); + relloc.add("0, 5, 1"); + relloc.add("0, 5, -1"); + relloc.add("0, 5, -2"); + relloc.add("1, 5, 1"); + relloc.add("0, 5, 0, ladder2"); + relloc.add("1, 5, 0"); + relloc.add("1, 5, -1"); + relloc.add("1, 5, -2"); + relloc.add("2, 5, 1"); + relloc.add("2, 5, 0"); + relloc.add("2, 5, -1"); + relloc.add("2, 5, -2"); + relloc.add("-3, 5, -2"); + relloc.add("-3, 6, -2"); + relloc.add("-3, 7, -2"); + relloc.add("-3, 6, -1"); + relloc.add("-3, 6, 0"); + relloc.add("-3, 5, 1"); + relloc.add("-3, 6, 1"); + relloc.add("-3, 7, 1"); + relloc.add("-2, 5, 2"); + relloc.add("-2, 6, 2"); + relloc.add("-2, 7, 2"); + relloc.add("-1, 6, 2"); + relloc.add("0, 5, 2"); + relloc.add("0, 6, 2"); + relloc.add("0, 7, 2"); + relloc.add("1, 6, 2"); + relloc.add("2, 5, 2"); + relloc.add("2, 6, 2"); + relloc.add("2, 7, 2"); + relloc.add("3, 5, -2"); + relloc.add("3, 6, -2"); + relloc.add("3, 7, -2"); + relloc.add("3, 6, -1"); + relloc.add("3, 6, 0"); + relloc.add("3, 5, 1"); + relloc.add("3, 6, 1"); + relloc.add("3, 7, 1"); + relloc.add("-2, 5, -3"); + relloc.add("-2, 6, -3"); + relloc.add("-2, 7, -3"); + relloc.add("-1, 6, -3"); + relloc.add("0, 5, -3"); + relloc.add("0, 6, -3"); + relloc.add("0, 7, -3"); + relloc.add("1, 6, -3"); + relloc.add("2, 5, -3"); + relloc.add("2, 6, -3"); + relloc.add("2, 7, -3"); + int[] i = new int[]{0}; + this.task = Bukkit.getScheduler().runTaskTimer(BedWars.plugin, () -> { + Sounds.playsoundArea("pop-up-tower-build", loc, 1.0F, 0.5F); + if (relloc.size() + 1 == i[0] + 1) { + this.task.cancel(); + } else { + String c1 = relloc.get(i[0]); + if (c1.contains("ladder")) { + int ldata = Integer.parseInt(c1.split("ladder")[1]); + new NewPlaceBlock(chest, c1, color, p, true, ldata); + } else { + new NewPlaceBlock(chest, c1, color, p, false, 0); + } + + if (relloc.size() + 1 == i[0] + 2) { + this.task.cancel(); + } else { + String c2 = relloc.get(i[0] + 1); + if (c2.contains("ladder")) { + int ldatax = Integer.parseInt(c2.split("ladder")[1]); + new NewPlaceBlock(chest, c2, color, p, true, ldatax); + } else { + new NewPlaceBlock(chest, c2, color, p, false, 0); + } + + i[0] += 2; + } + } + }, 0L, 1L); + } +} \ No newline at end of file diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerSouth.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerSouth.java new file mode 100644 index 000000000..31651dcc3 --- /dev/null +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerSouth.java @@ -0,0 +1,168 @@ +package com.andrei1058.bedwars.popuptower; + +import com.andrei1058.bedwars.BedWars; +import com.andrei1058.bedwars.api.arena.team.TeamColor; +import com.andrei1058.bedwars.configuration.Sounds; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitTask; + +import java.util.ArrayList; +import java.util.List; + +public class TowerSouth { + private BukkitTask task; + + public TowerSouth(Location loc, Block chest, TeamColor color, Player p) { + ItemStack itemInHand = p.getInventory().getItemInHand(); + if (itemInHand.getAmount() > 1) { + itemInHand.setAmount(itemInHand.getAmount() - 1); + } else { + p.getInventory().setItemInHand(null); + } + + List relloc = new ArrayList(); + relloc.add("1, 0, 2"); + relloc.add("2, 0, 1"); + relloc.add("2, 0, 0"); + relloc.add("1, 0, -1"); + relloc.add("0, 0, -1"); + relloc.add("-1, 0, -1"); + relloc.add("-2, 0, 0"); + relloc.add("-2, 0, 1"); + relloc.add("-1, 0, 2"); + relloc.add("0, 0, 0, ladder3"); + relloc.add("1, 1, 2"); + relloc.add("2, 1, 1"); + relloc.add("2, 1, 0"); + relloc.add("1, 1, -1"); + relloc.add("0, 1, -1"); + relloc.add("-1, 1, -1"); + relloc.add("-2, 1, 0"); + relloc.add("-2, 1, 1"); + relloc.add("-1, 1, 2"); + relloc.add("0, 1, 0, ladder3"); + relloc.add("1, 2, 2"); + relloc.add("2, 2, 1"); + relloc.add("2, 2, 0"); + relloc.add("1, 2, -1"); + relloc.add("0, 2, -1"); + relloc.add("-1, 2, -1"); + relloc.add("-2, 2, 0"); + relloc.add("-2, 2, 1"); + relloc.add("-1, 2, 2"); + relloc.add("0, 2, 0, ladder3"); + relloc.add("0, 3, 2"); + relloc.add("1, 3, 2"); + relloc.add("2, 3, 1"); + relloc.add("2, 3, 0"); + relloc.add("1, 3, -1"); + relloc.add("0, 3, -1"); + relloc.add("-1, 3, -1"); + relloc.add("-2, 3, 0"); + relloc.add("-2, 3, 1"); + relloc.add("-1, 3, 2"); + relloc.add("0, 3, 0, ladder3"); + relloc.add("0, 4, 2"); + relloc.add("1, 4, 2"); + relloc.add("2, 4, 1"); + relloc.add("2, 4, 0"); + relloc.add("1, 4, -1"); + relloc.add("0, 4, -1"); + relloc.add("-1, 4, -1"); + relloc.add("-2, 4, 0"); + relloc.add("-2, 4, 1"); + relloc.add("-1, 4, 2"); + relloc.add("0, 4, 0, ladder3"); + relloc.add("2, 5, -1"); + relloc.add("2, 5, 0"); + relloc.add("2, 5, 1"); + relloc.add("2, 5, 2"); + relloc.add("1, 5, -1"); + relloc.add("1, 5, 0"); + relloc.add("1, 5, 1"); + relloc.add("1, 5, 2"); + relloc.add("0, 5, -1"); + relloc.add("0, 5, 1"); + relloc.add("0, 5, 2"); + relloc.add("-1, 5, -1"); + relloc.add("0, 5, 0, ladder3"); + relloc.add("-1, 5, 0"); + relloc.add("-1, 5, 1"); + relloc.add("-1, 5, 2"); + relloc.add("-2, 5, -1"); + relloc.add("-2, 5, 0"); + relloc.add("-2, 5, 1"); + relloc.add("-2, 5, 2"); + relloc.add("3, 5, 2"); + relloc.add("3, 6, 2"); + relloc.add("3, 7, 2"); + relloc.add("3, 6, 1"); + relloc.add("3, 6, 0"); + relloc.add("3, 5, -1"); + relloc.add("3, 6, -1"); + relloc.add("3, 7, -1"); + relloc.add("2, 5, -2"); + relloc.add("2, 6, -2"); + relloc.add("2, 7, -2"); + relloc.add("1, 6, -2"); + relloc.add("0, 5, -2"); + relloc.add("0, 6, -2"); + relloc.add("0, 7, -2"); + relloc.add("-1, 6, -2"); + relloc.add("-2, 5, -2"); + relloc.add("-2, 6, -2"); + relloc.add("-2, 7, -2"); + relloc.add("-3, 5, 2"); + relloc.add("-3, 6, 2"); + relloc.add("-3, 7, 2"); + relloc.add("-3, 6, 1"); + relloc.add("-3, 6, 0"); + relloc.add("-3, 5, -1"); + relloc.add("-3, 6, -1"); + relloc.add("-3, 7, -1"); + relloc.add("2, 5, 3"); + relloc.add("2, 6, 3"); + relloc.add("2, 7, 3"); + relloc.add("1, 6, 3"); + relloc.add("0, 5, 3"); + relloc.add("0, 6, 3"); + relloc.add("0, 7, 3"); + relloc.add("-1, 6, 3"); + relloc.add("-2, 5, 3"); + relloc.add("-2, 6, 3"); + relloc.add("-2, 7, 3"); + int[] i = new int[]{0}; + this.task = Bukkit.getScheduler().runTaskTimer(BedWars.plugin, () -> { + Sounds.playsoundArea("pop-up-tower-build", loc, 1.0F, 0.5F); + if (relloc.size() + 1 == i[0] + 1) { + this.task.cancel(); + } else { + String c1 = relloc.get(i[0]); + if (c1.contains("ladder")) { + int ldata = Integer.parseInt(c1.split("ladder")[1]); + new NewPlaceBlock(chest, c1, color, p, true, ldata); + } else { + new NewPlaceBlock(chest, c1, color, p, false, 0); + } + + if (relloc.size() + 1 == i[0] + 2) { + this.task.cancel(); + } else { + String c2 = relloc.get(i[0] + 1); + if (c2.contains("ladder")) { + int ldatax = Integer.parseInt(c2.split("ladder")[1]); + new NewPlaceBlock(chest, c2, color, p, true, ldatax); + } else { + new NewPlaceBlock(chest, c2, color, p, false, 0); + } + + i[0] += 2; + } + } + }, 0L, 1L); + } +} diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerWest.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerWest.java new file mode 100644 index 000000000..8fb712ec6 --- /dev/null +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/popuptower/TowerWest.java @@ -0,0 +1,168 @@ +package com.andrei1058.bedwars.popuptower; + +import com.andrei1058.bedwars.BedWars; +import com.andrei1058.bedwars.api.arena.team.TeamColor; +import com.andrei1058.bedwars.configuration.Sounds; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitTask; + +import java.util.ArrayList; +import java.util.List; + +public class TowerWest { + private BukkitTask task; + + public TowerWest(Location loc, Block chest, TeamColor color, Player p) { + ItemStack itemInHand = p.getInventory().getItemInHand(); + if (itemInHand.getAmount() > 1) { + itemInHand.setAmount(itemInHand.getAmount() - 1); + } else { + p.getInventory().setItemInHand(null); + } + + List relloc = new ArrayList(); + relloc.add("-2, 0, 1"); + relloc.add("-1, 0, 2"); + relloc.add("0, 0, 2"); + relloc.add("1, 0, 1"); + relloc.add("1, 0, 0"); + relloc.add("1, 0, -1"); + relloc.add("0, 0, -2"); + relloc.add("-1, 0, -2"); + relloc.add("-2, 0, -1"); + relloc.add("0, 0, 0, ladder4"); + relloc.add("-2, 1, 1"); + relloc.add("-1, 1, 2"); + relloc.add("0, 1, 2"); + relloc.add("1, 1, 1"); + relloc.add("1, 1, 0"); + relloc.add("1, 1, -1"); + relloc.add("0, 1, -2"); + relloc.add("-1, 1, -2"); + relloc.add("-2, 1, -1"); + relloc.add("0, 1, 0, ladder4"); + relloc.add("-2, 2, 1"); + relloc.add("-1, 2, 2"); + relloc.add("0, 2, 2"); + relloc.add("1, 2, 1"); + relloc.add("1, 2, 0"); + relloc.add("1, 2, -1"); + relloc.add("0, 2, -2"); + relloc.add("-1, 2, -2"); + relloc.add("-2, 2, -1"); + relloc.add("0, 2, 0, ladder4"); + relloc.add("-2, 3, 0"); + relloc.add("-2, 3, 1"); + relloc.add("-1, 3, 2"); + relloc.add("0, 3, 2"); + relloc.add("1, 3, 1"); + relloc.add("1, 3, 0"); + relloc.add("1, 3, -1"); + relloc.add("0, 3, -2"); + relloc.add("-1, 3, -2"); + relloc.add("-2, 3, -1"); + relloc.add("0, 3, 0, ladder4"); + relloc.add("-2, 4, 0"); + relloc.add("-2, 4, 1"); + relloc.add("-1, 4, 2"); + relloc.add("0, 4, 2"); + relloc.add("1, 4, 1"); + relloc.add("1, 4, 0"); + relloc.add("1, 4, -1"); + relloc.add("0, 4, -2"); + relloc.add("-1, 4, -2"); + relloc.add("-2, 4, -1"); + relloc.add("0, 4, 0, ladder4"); + relloc.add("1, 5, 2"); + relloc.add("0, 5, 2"); + relloc.add("-1, 5, 2"); + relloc.add("-2, 5, 2"); + relloc.add("1, 5, 1"); + relloc.add("0, 5, 1"); + relloc.add("-1, 5, 1"); + relloc.add("-2, 5, 1"); + relloc.add("1, 5, 0"); + relloc.add("-1, 5, 0"); + relloc.add("-2, 5, 0"); + relloc.add("1, 5, -1"); + relloc.add("0, 5, -1"); + relloc.add("-1, 5, -1"); + relloc.add("-2, 5, -1"); + relloc.add("0, 5, 0, ladder4"); + relloc.add("1, 5, -2"); + relloc.add("0, 5, -2"); + relloc.add("-1, 5, -2"); + relloc.add("-2, 5, -2"); + relloc.add("-2, 5, 3"); + relloc.add("-2, 6, 3"); + relloc.add("-2, 7, 3"); + relloc.add("-1, 6, 3"); + relloc.add("0, 6, 3"); + relloc.add("1, 5, 3"); + relloc.add("1, 6, 3"); + relloc.add("1, 7, 3"); + relloc.add("2, 5, 2"); + relloc.add("2, 6, 2"); + relloc.add("2, 7, 2"); + relloc.add("2, 6, 1"); + relloc.add("2, 5, 0"); + relloc.add("2, 6, 0"); + relloc.add("2, 7, 0"); + relloc.add("2, 6, -1"); + relloc.add("2, 5, -2"); + relloc.add("2, 6, -2"); + relloc.add("2, 7, -2"); + relloc.add("-2, 5, -3"); + relloc.add("-2, 6, -3"); + relloc.add("-2, 7, -3"); + relloc.add("-1, 6, -3"); + relloc.add("0, 6, -3"); + relloc.add("1, 5, -3"); + relloc.add("1, 6, -3"); + relloc.add("1, 7, -3"); + relloc.add("-3, 5, 2"); + relloc.add("-3, 6, 2"); + relloc.add("-3, 7, 2"); + relloc.add("-3, 6, 1"); + relloc.add("-3, 5, 0"); + relloc.add("-3, 6, 0"); + relloc.add("-3, 7, 0"); + relloc.add("-3, 6, -1"); + relloc.add("-3, 5, -2"); + relloc.add("-3, 6, -2"); + relloc.add("-3, 7, -2"); + int[] i = new int[]{0}; + this.task = Bukkit.getScheduler().runTaskTimer(BedWars.plugin, () -> { + Sounds.playsoundArea("pop-up-tower-build", loc, 1.0F, 0.5F); + if (relloc.size() + 1 == i[0] + 1) { + this.task.cancel(); + } else { + String c1 = relloc.get(i[0]); + if (c1.contains("ladder")) { + int ldata = Integer.parseInt(c1.split("ladder")[1]); + new NewPlaceBlock(chest, c1, color, p, true, ldata); + } else { + new NewPlaceBlock(chest, c1, color, p, false, 0); + } + + if (relloc.size() + 1 == i[0] + 2) { + this.task.cancel(); + } else { + String c2 = relloc.get(i[0] + 1); + if (c2.contains("ladder")) { + int ldatax = Integer.parseInt(c2.split("ladder")[1]); + new NewPlaceBlock(chest, c2, color, p, true, ldatax); + } else { + new NewPlaceBlock(chest, c2, color, p, false, 0); + } + + i[0] += 2; + } + } + }, 0L, 1L); + } +} diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/ShopManager.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/ShopManager.java index fca33f450..8c45dd5c5 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/ShopManager.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/ShopManager.java @@ -89,6 +89,9 @@ private void saveDefaults() { getYml().addDefault(ConfigPath.SHOP_SPECIAL_IRON_GOLEM_DESPAWN, 240); getYml().addDefault(ConfigPath.SHOP_SPECIAL_IRON_GOLEM_SPEED, 0.25); + getYml().addDefault(ConfigPath.SHOP_SPECIAL_TOWER_ENABLE, true); + getYml().addDefault(ConfigPath.SHOP_SPECIAL_TOWER_MATERIAL, BedWars.getForCurrentVersion("CHEST", "CHEST", "CHEST")); + if (isFirstTime()) { //quick buy defaults getYml().addDefault(ConfigPath.SHOP_QUICK_DEFAULTS_PATH + ".element1.path", "blocks-category.category-content.wool"); @@ -347,6 +350,11 @@ private void saveDefaults() { addBuyItem(ConfigPath.SHOP_PATH_CATEGORY_UTILITY, "sponge", "tier1", "sponge", BedWars.getForCurrentVersion("SPONGE", "SPONGE", "SPONGE"), 0, 1, "", "", "", false); + adCategoryContentTier(ConfigPath.SHOP_PATH_CATEGORY_UTILITY, "tower", 31, "tier1", + BedWars.getForCurrentVersion("CHEST", "CHEST", "CHEST"), 0, 1, false, 24, "iron", false, false); + addBuyItem(ConfigPath.SHOP_PATH_CATEGORY_UTILITY, "tower", "tier1", "tower", BedWars.getForCurrentVersion("TOWER", "TOWER", "TOWER"), + 0, 1, "", "", "", false); + } if (getYml().get(ConfigPath.SHOP_PATH_CATEGORY_ARMOR + ConfigPath.SHOP_CATEGORY_CONTENT_PATH + ".diamond-armor") != null) { diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/listeners/InventoryListener.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/listeners/InventoryListener.java index d393714f5..5104e571d 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/listeners/InventoryListener.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/listeners/InventoryListener.java @@ -34,10 +34,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.event.inventory.InventoryAction; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.*; import org.bukkit.inventory.ItemStack; import static com.andrei1058.bedwars.BedWars.nms; @@ -50,21 +47,32 @@ public class InventoryListener implements Listener { public void onInventoryClick(InventoryClickEvent e) { if (e.isCancelled()) return; if (!(e.getWhoClicked() instanceof Player)) return; - IArena a = Arena.getArenaByPlayer((Player) e.getWhoClicked()); + + Player p = (Player) e.getWhoClicked(); + + IArena a = Arena.getArenaByPlayer(p); if (a == null) return; - if (a.isSpectator((Player) e.getWhoClicked())) return; + if (a.isSpectator(p)) return; - ShopCache shopCache = ShopCache.getShopCache(e.getWhoClicked().getUniqueId()); - PlayerQuickBuyCache cache = PlayerQuickBuyCache.getQuickBuyCache(e.getWhoClicked().getUniqueId()); + ShopCache shopCache = ShopCache.getShopCache(p.getUniqueId()); + PlayerQuickBuyCache cache = PlayerQuickBuyCache.getQuickBuyCache(p.getUniqueId()); if (cache == null) return; if (shopCache == null) return; - if (ShopIndex.getIndexViewers().contains(e.getWhoClicked().getUniqueId())) { + if(ShopIndex.getIndexViewers().contains(p.getUniqueId()) || ShopCategory.getCategoryViewers().contains(p.getUniqueId())) { + if(e.getClickedInventory().getType().equals(InventoryType.PLAYER)) { + e.setCancelled(true); + return; + } + } + + if (ShopIndex.getIndexViewers().contains(p.getUniqueId())) { e.setCancelled(true); + for (ShopCategory sc : ShopManager.getShop().getCategoryList()) { if (e.getSlot() == sc.getSlot()) { - sc.open((Player) e.getWhoClicked(), ShopManager.getShop(), shopCache); + sc.open(p, ShopManager.getShop(), shopCache); return; } } @@ -72,22 +80,22 @@ public void onInventoryClick(InventoryClickEvent e) { if (element.getSlot() == e.getSlot()) { if (e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) { cache.setElement(element.getSlot(), null); - e.getWhoClicked().closeInventory(); + p.closeInventory(); return; } - element.getCategoryContent().execute((Player) e.getWhoClicked(), shopCache, element.getSlot()); + element.getCategoryContent().execute(p, shopCache, element.getSlot()); return; } } - } else if (ShopCategory.getCategoryViewers().contains(e.getWhoClicked().getUniqueId())) { + } else if (ShopCategory.getCategoryViewers().contains(p.getUniqueId())) { e.setCancelled(true); for (ShopCategory sc : ShopManager.getShop().getCategoryList()) { if (ShopManager.getShop().getQuickBuyButton().getSlot() == e.getSlot()) { - ShopManager.getShop().open((Player) e.getWhoClicked(), cache, false); + ShopManager.getShop().open(p, cache, false); return; } if (e.getSlot() == sc.getSlot()) { - sc.open((Player) e.getWhoClicked(), ShopManager.getShop(), shopCache); + sc.open(p, ShopManager.getShop(), shopCache); return; } if (sc.getSlot() != shopCache.getSelectedCategory()) continue; @@ -95,10 +103,10 @@ public void onInventoryClick(InventoryClickEvent e) { if (cc.getSlot() == e.getSlot()) { if (e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) { if (cache.hasCategoryContent(cc)) return; - new QuickBuyAdd((Player) e.getWhoClicked(), cc); + new QuickBuyAdd(p, cc); return; } - cc.execute((Player) e.getWhoClicked(), shopCache, cc.getSlot()); + cc.execute(p, shopCache, cc.getSlot()); return; } } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/main/CategoryContent.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/main/CategoryContent.java index 2bcf91537..b148a3e43 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/main/CategoryContent.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/shop/main/CategoryContent.java @@ -260,7 +260,11 @@ public ItemStack getItemStack(Player player, ShopCache shopCache) { String buyStatus; if (isPermanent() && shopCache.hasCachedItem(this) && shopCache.getCachedItem(this).getTier() == getContentTiers().size()) { - buyStatus = getMsg(player, Messages.SHOP_LORE_STATUS_MAXED); + if (!(nms.isArmor(i))){ + buyStatus = getMsg(player, Messages.SHOP_LORE_STATUS_MAXED); //ARMOR + }else { + buyStatus = getMsg(player, Messages.SHOP_LORE_STATUS_ARMOR); + } } else if (!canAfford) { buyStatus = getMsg(player, Messages.SHOP_LORE_STATUS_CANT_AFFORD).replace("{currency}", translatedCurrency); } else { diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/BedWarsScoreboard.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/BedWarsScoreboard.java deleted file mode 100644 index 98dc8acd5..000000000 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/BedWarsScoreboard.java +++ /dev/null @@ -1,675 +0,0 @@ -/* - * BedWars1058 - A bed wars mini-game. - * Copyright (C) 2021 Andrei Dascălu - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Contact e-mail: andrew.dascalu@gmail.com - */ - -package com.andrei1058.bedwars.sidebar; - -import com.andrei1058.bedwars.BedWars; -import com.andrei1058.bedwars.api.arena.GameState; -import com.andrei1058.bedwars.api.arena.IArena; -import com.andrei1058.bedwars.api.arena.team.ITeam; -import com.andrei1058.bedwars.api.configuration.ConfigPath; -import com.andrei1058.bedwars.api.language.Language; -import com.andrei1058.bedwars.api.language.Messages; -import com.andrei1058.bedwars.api.server.ServerType; -import com.andrei1058.bedwars.arena.Arena; -import com.andrei1058.spigot.sidebar.*; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.text.SimpleDateFormat; -import java.util.*; - -import static com.andrei1058.bedwars.BedWars.*; -import static com.andrei1058.bedwars.api.language.Language.getMsg; -import static com.andrei1058.bedwars.api.language.Language.getScoreboard; -import static com.andrei1058.bedwars.arena.Misc.replaceStatsPlaceholders; - -public class BedWarsScoreboard { - - private static SidebarManager sidebarManager = null; - private static final HashMap scoreboards = new HashMap<>(); - - private final Player player; - private IArena arena; - - private Sidebar handle; - private SimpleDateFormat dateFormat; - private SimpleDateFormat nextEventDateFormat; - - private BedWarsScoreboard(@NotNull Player player, @NotNull List content, @Nullable IArena arena) { - this.arena = arena; - this.player = player; - - // Ignore if content is empty - if (content.isEmpty()) return; - - // Remove previous player scoreboard - BedWarsScoreboard previousScoreboard = scoreboards.get(player.getUniqueId()); - if (previousScoreboard != null) { - previousScoreboard.remove(); - } - - if (!player.isOnline()) { - return; - } - - // Cache the next event date format - nextEventDateFormat = new SimpleDateFormat(getMsg(player, Messages.FORMATTING_SCOREBOARD_NEXEVENT_TIMER)); - nextEventDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - dateFormat = new SimpleDateFormat(getMsg(player, Messages.FORMATTING_SCOREBOARD_DATE)); - - // Define common placeholders - List placeholders = Arrays.asList( - new PlaceholderProvider("{on}", () -> String.valueOf(getArena() == null ? Bukkit.getOnlinePlayers().size() : getArena().getPlayers().size())), - new PlaceholderProvider("{max}", () -> String.valueOf(getArena() == null ? Bukkit.getMaxPlayers() : getArena().getMaxPlayers())), - new PlaceholderProvider("{time}", () -> { - if (this.arena == null) { - return dateFormat.format(new Date(System.currentTimeMillis())); - } else if (this.arena.getStatus() == GameState.playing || this.arena.getStatus() == GameState.restarting) { - return getNextEventTime(); - } else { - if (this.arena.getStatus() == GameState.starting) { - if (getArena().getStartingTask() != null) { - return String.valueOf(getArena().getStartingTask().getCountdown() + 1); - } - } - return dateFormat.format(new Date(System.currentTimeMillis())); - } - }), - new PlaceholderProvider("{nextEvent}", this::getNextEventName), - new PlaceholderProvider("{date}", () -> dateFormat.format(new Date(System.currentTimeMillis()))), - new PlaceholderProvider("{kills}", () -> String.valueOf(getArena() == null ? BedWars.getStatsManager().get(getPlayer().getUniqueId()).getKills() : getArena().getPlayerKills(getPlayer(), false))), - new PlaceholderProvider("{finalKills}", () -> String.valueOf(getArena() == null ? BedWars.getStatsManager().get(getPlayer().getUniqueId()).getFinalKills() : getArena().getPlayerKills(getPlayer(), true))), - new PlaceholderProvider("{beds}", () -> String.valueOf(getArena() == null ? BedWars.getStatsManager().get(getPlayer().getUniqueId()).getBedsDestroyed() : getArena().getPlayerBedsDestroyed(getPlayer()))), - new PlaceholderProvider("{deaths}", () -> String.valueOf(getArena() == null ? BedWars.getStatsManager().get(getPlayer().getUniqueId()).getDeaths() : getArena().getPlayerDeaths(getPlayer(), false))), - new PlaceholderProvider("{progress}", () -> BedWars.getLevelSupport().getProgressBar(getPlayer())), - new PlaceholderProvider("{level}", () -> BedWars.getLevelSupport().getLevel(getPlayer())), - new PlaceholderProvider("{currentXp}", () -> BedWars.getLevelSupport().getCurrentXpFormatted(getPlayer())), - new PlaceholderProvider("{requiredXp}", () -> BedWars.getLevelSupport().getRequiredXpFormatted(getPlayer())) - ); - - // Initialize sidebar manager if not initialized - if (sidebarManager == null) { - try { - sidebarManager = new SidebarManager(); - } catch (InstantiationException e) { - throw new IllegalStateException(e); - } - } - - // Create the sidebar, with a title but empty content - // Note: we can set the title to null as we set it in setStrings and the first update is sent on handle.apply(player) - handle = sidebarManager.createSidebar(null, Collections.emptyList(), placeholders); - - // this needs to be before setStrings - scoreboards.put(player.getUniqueId(), this); - // Set lines - setStrings(content); - - // Apply the sidebar to the player - handle.apply(player); - - handlePlayerList(); - } - - public void handlePlayerList() { - //remove previous list formatting - handle.playerListClear(); - - // Handle health in tab and bellow name - handleHealthIcon(); - - // Update player list and health bars - if (arena != null) { - - // Dynamic team placeholders - for (ITeam currentTeam : arena.getTeams()) { - handle.addPlaceholder(new PlaceholderProvider("{Team" + currentTeam.getName() + "Status}", () -> { - String result; - if (currentTeam.isBedDestroyed()) { - if (currentTeam.getSize() > 0) { - result = getMsg(getPlayer(), Messages.FORMATTING_SCOREBOARD_BED_DESTROYED) - .replace("{remainingPlayers}", String.valueOf(currentTeam.getSize())); - } else { - result = getMsg(getPlayer(), Messages.FORMATTING_SCOREBOARD_TEAM_ELIMINATED); - } - } else { - result = getMsg(getPlayer(), Messages.FORMATTING_SCOREBOARD_TEAM_ALIVE); - } - if (currentTeam.isMember(getPlayer())) { - result += getMsg(getPlayer(), Messages.FORMATTING_SCOREBOARD_YOUR_TEAM); - } - return result; - })); - } - - if ((arena.getStatus() == GameState.playing && config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_LIST_FORMAT_PLAYING)) - || (arena.getStatus() == GameState.restarting && config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_LIST_FORMAT_RESTARTING))) { - String prefixListPath = arena.getStatus() == GameState.playing ? Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING : Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PRESTARTING; - String suffixListPath = arena.getStatus() == GameState.playing ? Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING : Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PRESTARTING; - - // format current teams in tab - for (ITeam currentTeam : arena.getTeams()) { - currentTeam.getMembers().forEach(currentMember -> { - addToTabList(currentMember, prefixListPath, suffixListPath); - BedWarsScoreboard currentSpectatorScoreboard = getSBoard(currentMember.getUniqueId()); - if (currentSpectatorScoreboard != null) { - // add current player to current member tab list - currentSpectatorScoreboard.addToTabList(getPlayer(), prefixListPath, suffixListPath); - } - }); - handle.playerListRefreshAnimation(); - } - // format spectators in tab for current spectator - if (arena.isSpectator(getPlayer())) { - arena.getSpectators().forEach(spectator -> { - addToTabList(spectator, prefixListPath, suffixListPath); - BedWarsScoreboard currentSpectatorScoreboard = getSBoard(spectator.getUniqueId()); - if (currentSpectatorScoreboard != null) { - // add current player to current spectator tab list - currentSpectatorScoreboard.addToTabList(getPlayer(), prefixListPath, suffixListPath); - } - handle.playerListRefreshAnimation(); - }); - } - } else { - // waiting/ starting tab formatting - if (arena.getStatus() == GameState.waiting && config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_LIST_FORMAT_WAITING) || - arena.getStatus() == GameState.starting && config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_LIST_FORMAT_STARTING)) { - String prefixListPath = arena.getStatus() == GameState.waiting ? Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_WAITING : Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_STARTING; - String suffixListPath = arena.getStatus() == GameState.waiting ? Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_WAITING : Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_STARTING; - arena.getPlayers().forEach(inGame -> { - addToTabList(inGame, prefixListPath, suffixListPath); - BedWarsScoreboard currentSpectatorScoreboard = getSBoard(inGame.getUniqueId()); - if (currentSpectatorScoreboard != null) { - // add current player to current inGame tab list - currentSpectatorScoreboard.addToTabList(getPlayer(), prefixListPath, suffixListPath); - } - }); - handle.playerListRefreshAnimation(); - } - } - } else { - // multi-arena lobby tab formatting - if (config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_LIST_FORMAT_LOBBY)) { - World lobbyWorld = Bukkit.getWorld(config.getLobbyWorldName()); - if (lobbyWorld != null) { - lobbyWorld.getPlayers().forEach(inGame -> { - addToTabList(inGame, Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_LOBBY, Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_LOBBY); - BedWarsScoreboard currentPlayerScoreboard = getSBoard(inGame.getUniqueId()); - if (currentPlayerScoreboard != null) { - currentPlayerScoreboard.addToTabList(getPlayer(), Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_LOBBY, Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_LOBBY); - } - handle.playerListRefreshAnimation(); - }); - } - } - } - } - - public void setArena(IArena arena) { - this.arena = arena; - } - - private void setStrings(@NotNull List strings) { - // Remove existing lines - while (handle.linesAmount() > 0) { - handle.removeLine(0); - } - - // Remove team/game related placeholders - List placeholdersToRemove = new LinkedList<>(); - handle.getPlaceholders().forEach(placeholder -> { - if (placeholder.getPlaceholder().startsWith("{Team")) { - placeholdersToRemove.add(placeholder.getPlaceholder()); - } - }); - placeholdersToRemove.forEach(placeholder -> handle.removePlaceholder(placeholder)); - - // Set the title - String[] title = strings.remove(0).split("[\\n,]"); - if (title.length == 1) { - handle.setTitle(new SidebarLine() { - @NotNull - @Override - public String getLine() { - return title[0]; - } - }); - } else { - handle.setTitle(new SidebarLineAnimated(title)); - } - - handlePlayerList(); - - int teamCount = 0; - Language language = Language.getPlayerLanguage(player); - String genericTeamFormat = language.m(Messages.FORMATTING_SCOREBOARD_TEAM_GENERIC); - for (String current : strings) { - // generic team placeholder {team} - if (arena != null && current.trim().equals("{team}")) { - if (arena.getTeams().size() > teamCount) { - ITeam team = arena.getTeams().get(teamCount++); - String teamName = team.getDisplayName(language); - current = genericTeamFormat.replace("{TeamLetter}", String.valueOf(teamName.length() != 0 ? teamName.charAt(0) : "")) - .replace("{TeamColor}", team.getColor().chat().toString()) - .replace("{TeamName}", teamName).replace("{TeamStatus}", "{Team" + team.getName() + "Status}"); - } else { - // skip line - continue; - } - } - - // General static placeholders - current = current - .replace("{server_ip}", BedWars.config.getString(ConfigPath.GENERAL_CONFIG_PLACEHOLDERS_REPLACEMENTS_SERVER_IP)) - .replace("{version}", plugin.getDescription().getVersion()) - .replace("{server}", config.getString(ConfigPath.GENERAL_CONFIGURATION_BUNGEE_OPTION_SERVER_ID)) - .replace("{playername}", player.getName()) - .replace("{player}", player.getDisplayName()) - .replace("{money}", String.valueOf(getEconomy().getMoney(player))); - - if (arena == null) { - // Lobby scoreboard - current = replaceStatsPlaceholders(getPlayer(), current, true); - } else { - // Game scoreboard - current = current - .replace("{map}", arena.getDisplayName()) - .replace("{map_name}", arena.getArenaName()) - .replace("{group}", arena.getDisplayGroup(player)); - - for (ITeam currentTeam : arena.getTeams()) { - final ChatColor color = currentTeam.getColor().chat(); - // Static team placeholders - current = current - .replace("{Team" + currentTeam.getName() + "Color}", color.toString()) - .replace("{Team" + currentTeam.getName() + "Name}", currentTeam.getDisplayName(Language.getPlayerLanguage(getPlayer()))); - - } - } - - // Add the line to the sidebar - String finalTemp = current; - SidebarLine sidebarLine = new SidebarLine() { - @NotNull - @Override - public String getLine() { - return finalTemp; - } - }; - handle.addLine(sidebarLine); - } - } - - // alter scoreboard list - // must be used when a player joins/ re-joins/ invisibility potion has expired - public void addToTabList(Player player, @NotNull String prefixListPath, @NotNull String suffixListPath) { - handle.playerListCreate(player, getTeamListText(prefixListPath, player), getTeamListText(suffixListPath, player)); - if (arena != null) { - handle.playerListAddPlaceholders(player, - new PlaceholderProvider("{team}", () -> { - if (arena.isSpectator(player)) { - return Language.getMsg(getPlayer(), Messages.FORMATTING_SPECTATOR_COLOR) + Language.getMsg(getPlayer(), Messages.FORMATTING_SPECTATOR_TEAM); - } - ITeam team = arena.getTeam(player); - if (team == null) { - team = arena.getExTeam(player.getUniqueId()); - } - if (team == null) { - //waiting/ starting phase - return ""; - } - return team.getColor().chat() + team.getDisplayName(Language.getPlayerLanguage(getPlayer())); - }), - new PlaceholderProvider("{teamLetter}", () -> { - if (arena.isSpectator(player)) { - return Language.getMsg(getPlayer(), Messages.FORMATTING_SPECTATOR_TEAM).substring(0, 1); - } - ITeam team = arena.getTeam(player); - if (team == null) { - team = arena.getExTeam(player.getUniqueId()); - } - if (team == null) { - //waiting/ starting phase - return ""; - } - return team.getDisplayName(Language.getPlayerLanguage(getPlayer())).substring(0, 1); - }), - new PlaceholderProvider("{teamName}", () -> { - if (arena.isSpectator(player)) { - return Language.getMsg(getPlayer(), Messages.FORMATTING_SPECTATOR_TEAM); - } - ITeam team = arena.getTeam(player); - if (team == null) { - team = arena.getExTeam(player.getUniqueId()); - } - if (team == null) { - //waiting/ starting phase - return ""; - } - return team.getDisplayName(Language.getPlayerLanguage(getPlayer())); - }), - new PlaceholderProvider("{teamColor}", () -> { - if (arena.isSpectator(player)) { - return Language.getMsg(getPlayer(), Messages.FORMATTING_SPECTATOR_COLOR); - } - ITeam team = arena.getTeam(player); - if (team == null) { - team = arena.getExTeam(player.getUniqueId()); - } - if (team == null) { - //waiting/ starting phase - return ""; - } - return team.getColor().chat().toString(); - })); - } - } - - public void handleHealthIcon() { - if (arena == null) { - handle.hidePlayersHealth(); - return; - } - if (arena.getStatus() != GameState.playing) { - handle.hidePlayersHealth(); - return; - } - if (handle != null) { - List animation = Language.getList(player, Messages.FORMATTING_SCOREBOARD_HEALTH); - if (animation.isEmpty()) return; - SidebarLine line; - if (animation.size() > 1) { - String[] lines = new String[animation.size()]; - for (int i = 0; i < animation.size(); i++) { - lines[i] = animation.get(i); - } - line = new SidebarLineAnimated(lines); - } else { - final String text = animation.get(0); - line = new SidebarLine() { - @NotNull - @Override - public String getLine() { - return text; - } - }; - } - handle.showPlayersHealth(line, config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_HEALTH_IN_TAB)); - Bukkit.getScheduler().runTaskLater(plugin, () -> { - if (arena != null && handle != null) { - arena.getPlayers().forEach(player -> handle.refreshHealth(player, (int) Math.ceil(player.getHealth()))); - if (arena.isSpectator(getPlayer())) { - arena.getSpectators().forEach(player -> handle.refreshHealth(player, (int) Math.ceil(player.getHealth()))); - } - } - }, 20L); - } - } - - /* I think this is no longer required - public void giveTeamColorTag() { - if (scoreboard == null){ - scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); - } - if (scoreboard.getObjective("list") == null) { - Objective objective = scoreboard.registerNewObjective("list", "health"); - objective.setDisplaySlot(DisplaySlot.PLAYER_LIST); - } - for (ITeam t : arena.getTeams()) { - Team team; - if (scoreboard.getTeam(t.getName()) == null) { - team = sb.registerNewTeam(t.getName()); - } else { - team = sb.getTeam(t.getName()); - } - team.setPrefix(t.getColor().chat() + "" + ChatColor.BOLD + t.getName().substring(0, 1).toUpperCase() + ChatColor.RESET + " " + t.getColor().chat()); - for (Player p : t.getMembers()) { - team.addEntry(p.getName()); - } - / - } - */ - - public Player getPlayer() { - return player; - } - - public void remove() { - scoreboards.remove(getPlayer().getUniqueId()); - if (handle != null) { - handle.remove(player.getUniqueId()); - handle = null; - - // remove player list formatting from other scoreboards - getScoreboards().values().forEach(scoreboard -> scoreboard.handle.playerListRemove(getPlayer().getName())); - } - } - - public IArena getArena() { - return arena; - } - - public static Map getScoreboards() { - return scoreboards; - } - - public static BedWarsScoreboard getSBoard(UUID player) { - return scoreboards.get(player); - } - - @NotNull - private String getNextEventName() { - if (!(arena instanceof Arena)) return "-"; - Arena arena = (Arena) this.arena; - String st = "-"; - switch (arena.getNextEvent()) { - case EMERALD_GENERATOR_TIER_II: - st = getMsg(getPlayer(), Messages.NEXT_EVENT_EMERALD_UPGRADE_II); - break; - case EMERALD_GENERATOR_TIER_III: - st = getMsg(getPlayer(), Messages.NEXT_EVENT_EMERALD_UPGRADE_III); - break; - case DIAMOND_GENERATOR_TIER_II: - st = getMsg(getPlayer(), Messages.NEXT_EVENT_DIAMOND_UPGRADE_II); - break; - case DIAMOND_GENERATOR_TIER_III: - st = getMsg(getPlayer(), Messages.NEXT_EVENT_DIAMOND_UPGRADE_III); - break; - case GAME_END: - st = getMsg(getPlayer(), Messages.NEXT_EVENT_GAME_END); - break; - case BEDS_DESTROY: - st = getMsg(getPlayer(), Messages.NEXT_EVENT_BEDS_DESTROY); - break; - case ENDER_DRAGON: - st = getMsg(getPlayer(), Messages.NEXT_EVENT_DRAGON_SPAWN); - break; - } - - return st; - } - - @NotNull - private String getNextEventTime() { - if (!(arena instanceof Arena)) return nextEventDateFormat.format((0L)); - Arena arena = (Arena) this.arena; - long time = 0L; - switch (arena.getNextEvent()) { - case EMERALD_GENERATOR_TIER_II: - case EMERALD_GENERATOR_TIER_III: - time = (arena.upgradeEmeraldsCount) * 1000L; - break; - case DIAMOND_GENERATOR_TIER_II: - case DIAMOND_GENERATOR_TIER_III: - time = (arena.upgradeDiamondsCount) * 1000L; - break; - case GAME_END: - time = (arena.getPlayingTask().getGameEndCountdown()) * 1000L; - break; - case BEDS_DESTROY: - time = (arena.getPlayingTask().getBedsDestroyCountdown()) * 1000L; - break; - case ENDER_DRAGON: - time = (arena.getPlayingTask().getDragonSpawnCountdown()) * 1000L; - break; - } - return time == 0 ? "0" : nextEventDateFormat.format(new Date(time)); - } - - /** - * Update spectators for player. - */ - public void updateSpectator(@SuppressWarnings("unused") Player player, @SuppressWarnings("unused") boolean value) { - /* TODO: not ready - if (getArena() == null) return; - if (getArena().getTeam(p) != null) return; - Team collide; - if (sb.getTeam("spectators") == null) { - collide = sb.registerNewTeam("spectators"); - nms.teamCollideRule(collide); - collide.setPrefix("§7[SPECT] §r"); - } else { - collide = sb.getTeam("spectators"); - } - if (!value) { - if (!collide.hasEntry(p.getName())) collide.addEntry(p.getName()); - } else { - if (collide.hasEntry(p.getName())) collide.removeEntry(p.getName()); - } - */ - } - - /** - * This will remove the player name tag when he drinks a potion. - * - * @param toggle true when applied, false when expired. - */ - public void invisibilityPotion(@SuppressWarnings("unused") @NotNull ITeam team, Player player, boolean toggle) { - if (toggle) { - handle.playerListHideNameTag(player); - } else { - handle.playerListRestoreNameTag(player); - } - } - - /** - * Give game scoreboard. - * - * @param player target player. - * @param arena target arena. - */ - public static void giveScoreboard(@NotNull Player player, IArena arena, boolean delay) { - - if (!player.isOnline()) return; - BedWarsScoreboard scoreboard = BedWarsScoreboard.getSBoard(player.getUniqueId()); - List lines = null; - - if (arena == null) { - // Lobby scoreboard - if (getServerType() == ServerType.SHARED || !config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_USE_LOBBY_SIDEBAR)) { - if (scoreboard != null) { - scoreboard.remove(); - } - return; - } - lines = Language.getList(player, Messages.SCOREBOARD_LOBBY); - } else { - // Game scoreboard - if (!config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_USE_GAME_SIDEBAR)) { - if (scoreboard != null) { - scoreboard.remove(); - } - return; - } - if (arena.getStatus() == GameState.waiting) { - lines = getScoreboard(player, "scoreboard." + arena.getGroup() + ".waiting", Messages.SCOREBOARD_DEFAULT_WAITING); - } else if (arena.getStatus() == GameState.starting) { - lines = getScoreboard(player, "scoreboard." + arena.getGroup() + ".starting", Messages.SCOREBOARD_DEFAULT_STARTING); - } else if (arena.getStatus() == GameState.playing || arena.getStatus() == GameState.restarting) { - lines = getScoreboard(player, "scoreboard." + arena.getGroup() + ".playing", Messages.SCOREBOARD_DEFAULT_PLAYING); - } - } - - if (lines == null || lines.isEmpty()) { - if (scoreboard != null) { - scoreboard.remove(); - } - return; - } - - if (scoreboard == null) { - if (delay) { - List finalLines = lines; - Bukkit.getScheduler().runTaskLater(plugin, () -> new BedWarsScoreboard(player, finalLines, arena), 5L); - } else { - new BedWarsScoreboard(player, lines, arena); - } - } else { - scoreboard.setArena(arena); - scoreboard.setStrings(lines); - } - } - - public Sidebar getHandle() { - return handle; - } - - @NotNull - private SidebarLine getTeamListText(String path, Player targetPlayer) { - List strings = Language.getList(getPlayer(), path); - if (strings.isEmpty()) { - return new SidebarLine() { - @NotNull - @Override - public String getLine() { - return ""; - } - }; - } - - strings = new ArrayList<>(); - for (String string : Language.getList(getPlayer(), path)) { - strings.add(string.replace("{vPrefix}", BedWars.getChatSupport().getPrefix(targetPlayer)).replace("{vSuffix}", BedWars.getChatSupport().getSuffix(targetPlayer))); - } - - if (strings.size() == 1) { - final String line = strings.get(0); - return new SidebarLine() { - @NotNull - @Override - public String getLine() { - return line; - } - }; - } - - final String[] lines = new String[strings.size()]; - for (int i = 0; i < lines.length; i++) { - lines[i] = strings.get(i); - } - return new SidebarLineAnimated(lines); - } -} diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/BwSidebar.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/BwSidebar.java new file mode 100644 index 000000000..27480a2f4 --- /dev/null +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/BwSidebar.java @@ -0,0 +1,638 @@ +package com.andrei1058.bedwars.sidebar; + +import com.andrei1058.bedwars.BedWars; +import com.andrei1058.bedwars.api.arena.GameState; +import com.andrei1058.bedwars.api.arena.IArena; +import com.andrei1058.bedwars.api.arena.team.ITeam; +import com.andrei1058.bedwars.api.configuration.ConfigPath; +import com.andrei1058.bedwars.api.language.Language; +import com.andrei1058.bedwars.api.language.Messages; +import com.andrei1058.bedwars.api.server.ServerType; +import com.andrei1058.bedwars.arena.Arena; +import com.andrei1058.bedwars.levels.internal.PlayerLevel; +import com.andrei1058.bedwars.stats.PlayerStats; +import com.andrei1058.spigot.sidebar.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.util.*; + +import static com.andrei1058.bedwars.BedWars.*; +import static com.andrei1058.bedwars.api.language.Language.getMsg; + +public class BwSidebar { + + private static final SidebarLine EMPTY_TITLE = new SidebarLine() { + @Override + public @NotNull String getLine() { + return ""; + } + }; + + private static final String SPECTATOR_TAB = Base64.getEncoder().encodeToString("spectators".getBytes(StandardCharsets.UTF_8)); + private static final String TEAM_PREFIX = "bw"; + + private final Player player; + private IArena arena; + private Sidebar handle; + private final SimpleDateFormat dateFormat; + private final SimpleDateFormat nextEventDateFormat; + private final HashMap tabList = new HashMap<>(); + + + protected BwSidebar(Player player) { + this.player = player; + nextEventDateFormat = new SimpleDateFormat(getMsg(player, Messages.FORMATTING_SCOREBOARD_NEXEVENT_TIMER)); + nextEventDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + dateFormat = new SimpleDateFormat(getMsg(player, Messages.FORMATTING_SCOREBOARD_DATE)); + } + + public void remove() { + if (handle == null) { + return; + } + tabList.forEach((k, v) -> handle.removeTab(k)); + handle.remove(player); + } + + public void setContent(List titleArray, List lineArray, @Nullable IArena arena) { + this.arena = arena; + SidebarLine title = this.normalizeTitle(titleArray); + List lines = this.normalizeLines(lineArray); + + List placeholders = this.getPlaceholders(); + + // if it is the first time setting content we create the handle + if (null == handle) { + handle = SidebarService.getInstance().getSidebarHandler().createSidebar(title, lines, placeholders); + handle.add(player); + } else { + while (handle.lineCount() > 0) { + handle.removeLine(0); + } + Bukkit.getScheduler().runTaskLater(plugin, () -> { + new ArrayList<>(handle.getPlaceholders()).forEach(p -> handle.removePlaceholder(p.getPlaceholder())); + placeholders.forEach(p -> handle.addPlaceholder(p)); + handle.setTitle(title); + lines.forEach(l -> handle.addLine(l)); + }, 2L); + } + handlePlayerList(); + } + + public Player getPlayer() { + return player; + } + + @SuppressWarnings("ConstantConditions") + private SidebarLine normalizeTitle(@Nullable List titleArray) { + String[] aolo = new String[titleArray.size()]; + for (int x = 0; x < titleArray.size(); x++) { + aolo[x] = titleArray.get(x); + } + return null == titleArray || titleArray.isEmpty() ? + EMPTY_TITLE : + new SidebarLineAnimated(aolo); + } + + @Contract(pure = true) + private @NotNull List normalizeLines(@NotNull List lineArray) { + List lines = new ArrayList<>(); + + int teamCount = 0; + Language language = Language.getPlayerLanguage(player); + String genericTeamFormat = language.m(Messages.FORMATTING_SCOREBOARD_TEAM_GENERIC); + + for (String line : lineArray) { + + // generic team placeholder {team} + if (arena != null) { + if (line.trim().equals("{team}")) { + if (arena.getTeams().size() > teamCount) { + ITeam team = arena.getTeams().get(teamCount++); + String teamName = team.getDisplayName(language); + line = genericTeamFormat + .replace("{TeamLetter}", String.valueOf(teamName.length() != 0 ? teamName.charAt(0) : "")) + .replace("{TeamColor}", team.getColor().chat().toString()) + .replace("{TeamName}", teamName) + .replace("{TeamStatus}", "{Team" + team.getName() + "Status}"); + } else { + // skip line + continue; + } + } + + line = line + .replace("{map}", arena.getDisplayName()) + .replace("{map_name}", arena.getArenaName()) + .replace("{group}", arena.getDisplayGroup(player)); + + for (ITeam currentTeam : arena.getTeams()) { + final ChatColor color = currentTeam.getColor().chat(); + // Static team placeholders + line = line + .replace("{Team" + currentTeam.getName() + "Color}", color.toString()) + .replace("{Team" + currentTeam.getName() + "Name}", currentTeam.getDisplayName(language)); + + } + } + + // General static placeholders + line = line + .replace("{server_ip}", BedWars.config.getString(ConfigPath.GENERAL_CONFIG_PLACEHOLDERS_REPLACEMENTS_SERVER_IP)) + .replace("{version}", plugin.getDescription().getVersion()) + .replace("{server}", config.getString(ConfigPath.GENERAL_CONFIGURATION_BUNGEE_OPTION_SERVER_ID)) + .replace("{playername}", player.getName()) + .replace("{player}", player.getDisplayName()) + .replace("{money}", String.valueOf(getEconomy().getMoney(player))); + + // Add the line to the sidebar + String finalTemp = line; + + lines.add(new SidebarLine() { + @Override + public @NotNull String getLine() { + return finalTemp; + } + }); + } + return lines; + } + + @Contract(pure = true) + private @NotNull List getPlaceholders() { + List providers = new ArrayList<>(); + + providers.add(new PlaceholderProvider("{player}", player::getDisplayName)); + providers.add(new PlaceholderProvider("{playerName}", player::getCustomName)); + providers.add(new PlaceholderProvider("{date}", () -> dateFormat.format(new Date(System.currentTimeMillis())))); + + PlayerLevel level = PlayerLevel.getLevelByPlayer(getPlayer().getUniqueId()); + if (null != level) { + providers.add(new PlaceholderProvider("{progress}", level::getProgress)); + providers.add(new PlaceholderProvider("{level}", () -> String.valueOf(level.getLevel()))); + providers.add(new PlaceholderProvider("{currentXp}", level::getFormattedCurrentXp)); + providers.add(new PlaceholderProvider("{requiredXp}", level::getFormattedRequiredXp)); + } + + if (null == arena) { + providers.add(new PlaceholderProvider("{on}", () -> + String.valueOf(Bukkit.getOnlinePlayers().size())) + ); + PlayerStats stats = BedWars.getStatsManager().get(getPlayer().getUniqueId()); + //noinspection ConstantConditions + if (null != stats) { + providers.add(new PlaceholderProvider("{kills}", () -> + String.valueOf(stats.getKills())) + ); + providers.add(new PlaceholderProvider("{finalKills}", () -> + String.valueOf(stats.getFinalKills())) + ); + providers.add(new PlaceholderProvider("{beds}", () -> + String.valueOf(stats.getBedsDestroyed())) + ); + providers.add(new PlaceholderProvider("{deaths}", () -> + String.valueOf(stats.getDeaths())) + ); + providers.add(new PlaceholderProvider("{finalDeaths}", () -> + String.valueOf(stats.getFinalDeaths())) + ); + } + } else { + providers.add(new PlaceholderProvider("{on}", () -> String.valueOf(arena.getPlayers().size()))); + providers.add(new PlaceholderProvider("{max}", () -> String.valueOf(arena.getMaxPlayers()))); + providers.add(new PlaceholderProvider("{nextEvent}", this::getNextEventName)); + providers.add(new PlaceholderProvider("{time}", () -> { + if (this.arena.getStatus() == GameState.playing || this.arena.getStatus() == GameState.restarting) { + return getNextEventTime(); + } else { + if (this.arena.getStatus() == GameState.starting) { + if (arena.getStartingTask() != null) { + return String.valueOf(arena.getStartingTask().getCountdown() + 1); + } + } + return dateFormat.format(new Date(System.currentTimeMillis())); + } + })); + providers.add(new PlaceholderProvider("{kills}", () -> + String.valueOf(arena.getPlayerKills(player, false)) + )); + providers.add(new PlaceholderProvider("{finalKills}", () -> + String.valueOf(arena.getPlayerKills(player, true)) + )); + providers.add(new PlaceholderProvider("{beds}", () -> + String.valueOf(arena.getPlayerBedsDestroyed(player)) + )); + providers.add(new PlaceholderProvider("{deaths}", () -> + String.valueOf(arena.getPlayerDeaths(player, false)) + )); + + // Dynamic team placeholders + for (ITeam currentTeam : arena.getTeams()) { + providers.add(new PlaceholderProvider("{Team" + currentTeam.getName() + "Status}", () -> { + String result; + if (currentTeam.isBedDestroyed()) { + if (currentTeam.getSize() > 0) { + result = getMsg(getPlayer(), Messages.FORMATTING_SCOREBOARD_BED_DESTROYED) + .replace("{remainingPlayers}", String.valueOf(currentTeam.getSize())); + } else { + result = getMsg(getPlayer(), Messages.FORMATTING_SCOREBOARD_TEAM_ELIMINATED); + } + } else { + result = getMsg(getPlayer(), Messages.FORMATTING_SCOREBOARD_TEAM_ALIVE); + } + if (currentTeam.isMember(getPlayer())) { + result += getMsg(getPlayer(), Messages.FORMATTING_SCOREBOARD_YOUR_TEAM); + } + return result; + })); + } + } + + return providers; + } + + @NotNull + private String getNextEventName() { + if (!(arena instanceof Arena)) return "-"; + Arena arena = (Arena) this.arena; + String st = "-"; + switch (arena.getNextEvent()) { + case EMERALD_GENERATOR_TIER_II: + st = getMsg(getPlayer(), Messages.NEXT_EVENT_EMERALD_UPGRADE_II); + break; + case EMERALD_GENERATOR_TIER_III: + st = getMsg(getPlayer(), Messages.NEXT_EVENT_EMERALD_UPGRADE_III); + break; + case DIAMOND_GENERATOR_TIER_II: + st = getMsg(getPlayer(), Messages.NEXT_EVENT_DIAMOND_UPGRADE_II); + break; + case DIAMOND_GENERATOR_TIER_III: + st = getMsg(getPlayer(), Messages.NEXT_EVENT_DIAMOND_UPGRADE_III); + break; + case GAME_END: + st = getMsg(getPlayer(), Messages.NEXT_EVENT_GAME_END); + break; + case BEDS_DESTROY: + st = getMsg(getPlayer(), Messages.NEXT_EVENT_BEDS_DESTROY); + break; + case ENDER_DRAGON: + st = getMsg(getPlayer(), Messages.NEXT_EVENT_DRAGON_SPAWN); + break; + } + + return st; + } + + @NotNull + private String getNextEventTime() { + if (!(arena instanceof Arena)) return nextEventDateFormat.format((0L)); + Arena arena = (Arena) this.arena; + long time = 0L; + switch (arena.getNextEvent()) { + case EMERALD_GENERATOR_TIER_II: + case EMERALD_GENERATOR_TIER_III: + time = (arena.upgradeEmeraldsCount) * 1000L; + break; + case DIAMOND_GENERATOR_TIER_II: + case DIAMOND_GENERATOR_TIER_III: + time = (arena.upgradeDiamondsCount) * 1000L; + break; + case GAME_END: + time = (arena.getPlayingTask().getGameEndCountdown()) * 1000L; + break; + case BEDS_DESTROY: + time = (arena.getPlayingTask().getBedsDestroyCountdown()) * 1000L; + break; + case ENDER_DRAGON: + time = (arena.getPlayingTask().getDragonSpawnCountdown()) * 1000L; + break; + } + return time == 0 ? "0" : nextEventDateFormat.format(new Date(time)); + } + + private boolean noArena() { + return null == arena; + } + + private void handlePlayerList() { + if (null != handle) { + tabList.forEach((k, v) -> { + String encodedName = Base64.getEncoder().encodeToString(k.getBytes(StandardCharsets.UTF_8)); + handle.removeTab(encodedName); + }); + } + + if (this.isTabFormattingDisabled()) { + return; + } + + handleHealthIcon(); + + if (arena == null) { + // if tab formatting is enabled in lobby world + if (config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_LIST_FORMAT_LOBBY) && + !config.getLobbyWorldName().trim().isEmpty()) { + + World lobby = Bukkit.getWorld(config.getLobbyWorldName()); + if (null == lobby) { + return; + } + lobby.getPlayers().forEach(inLobby -> giveUpdateTabFormat(inLobby, true)); + } + return; + } + + arena.getPlayers().forEach(playing -> giveUpdateTabFormat(playing, true)); + arena.getSpectators().forEach(spectating -> giveUpdateTabFormat(spectating, true)); + } + + /** + * Handle given player in sidebar owner tab list. + * Will remove existing tab and give a new one based on game conditions list like spectator, team red, etc. + */ + public void giveUpdateTabFormat(@NotNull Player player, boolean skipStateCheck) { + // if sidebar was not created + if (handle == null) { + return; + } + + // unique tab list name + String tabListName = Base64.getEncoder().encodeToString( + player.getUniqueId().toString().getBytes(StandardCharsets.UTF_8) + ); + Language lang = Language.getPlayerLanguage(player); + + if (tabList.containsKey(tabListName)) { + handle.removeTab(tabListName); + tabList.remove(tabListName); + SidebarManager.getInstance().sendHeaderFooter(player, "", ""); + } + + if (!skipStateCheck) { + if (this.isTabFormattingDisabled()) { + return; + } + } + + SidebarLine prefix; + SidebarLine suffix; + + if (noArena()) { + prefix = getTabText(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_LOBBY, player, null); + suffix = getTabText(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_LOBBY, player, null); + + PlayerTab tab = handle.playerTabCreate( + tabListName, player, prefix, suffix, PlayerTab.PushingRule.NEVER + ); + tab.add(player); + tabList.put(tabListName, tab); + + SidebarManager.getInstance().sendHeaderFooter( + player, lang.m(Messages.FORMATTING_SIDEBAR_TAB_HEADER_LOBBY), + lang.m(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_LOBBY) + ); + return; + } + + // in-game tab has a special treatment + if (arena.isSpectator(player)) { + PlayerTab tab = tabList.get(SPECTATOR_TAB); + if (null == tab) { + prefix = getTabText(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_SPECTATOR, player, null); + suffix = getTabText(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_SPECTATOR, player, null); + tab = handle.playerTabCreate(SPECTATOR_TAB, null, prefix, suffix, PlayerTab.PushingRule.NEVER); + tabList.put(SPECTATOR_TAB, tab); + } + tab.add(player); + + SidebarManager.getInstance().sendHeaderFooter( + player, lang.m(Messages.FORMATTING_SIDEBAR_TAB_HEADER_SPECTATOR), + lang.m(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_SPECTATOR) + ); + return; + } + + if (arena.getStatus() != GameState.playing) { + if (arena.getStatus() == GameState.waiting) { + prefix = getTabText(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_WAITING, player, null); + suffix = getTabText(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_WAITING, player, null); + SidebarManager.getInstance().sendHeaderFooter( + player, lang.m(Messages.FORMATTING_SIDEBAR_TAB_HEADER_WAITING), + lang.m(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_WAITING) + ); + } else if (arena.getStatus() == GameState.starting) { + prefix = getTabText(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_STARTING, player, null); + suffix = getTabText(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_STARTING, player, null); + SidebarManager.getInstance().sendHeaderFooter( + player, lang.m(Messages.FORMATTING_SIDEBAR_TAB_HEADER_STARTING), + lang.m(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_STARTING) + ); + } else if (arena.getStatus() == GameState.restarting) { + prefix = getTabText(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_RESTARTING, player, null); + suffix = getTabText(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_RESTARTING, player, null); + SidebarManager.getInstance().sendHeaderFooter( + player, lang.m(Messages.FORMATTING_SIDEBAR_TAB_HEADER_RESTARTING), + lang.m(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_RESTARTING) + ); + } else { + throw new RuntimeException("Unhandled game status!"); + } + PlayerTab t = handle.playerTabCreate(tabListName, player, prefix, suffix, PlayerTab.PushingRule.NEVER); + t.add(player); + tabList.put(tabListName, t); + return; + } + + ITeam team = arena.getTeam(player); + if (null == team) { + team = arena.getExTeam(player.getUniqueId()); + } + if (null == team) { + throw new RuntimeException("Wtf dude"); + } + + String tabName = Base64.getEncoder().encodeToString((TEAM_PREFIX + team.getName()).getBytes(StandardCharsets.UTF_8)); + + PlayerTab teamTab = tabList.get(tabName); + if (null == teamTab) { + String displayName = team.getDisplayName(Language.getPlayerLanguage(this.player)); + + HashMap replacements = new HashMap<>(); + replacements.put("{team}", team.getColor().chat() + displayName); + replacements.put("{teamLetter}", team.getColor().chat() + (displayName.substring(0, 1))); + replacements.put("{teamColor}", team.getColor().chat().toString()); + + prefix = getTabText(Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING, player, replacements); + suffix = getTabText(Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING, player, replacements); + + teamTab = handle.playerTabCreate(tabName, null, prefix, suffix, PlayerTab.PushingRule.PUSH_OTHER_TEAMS); + tabList.put(tabName, teamTab); + } + + teamTab.add(player); + + SidebarManager.getInstance().sendHeaderFooter( + player, lang.m(Messages.FORMATTING_SIDEBAR_TAB_HEADER_PLAYING), + lang.m(Messages.FORMATTING_SIDEBAR_TAB_FOOTER_PLAYING) + ); + } + + @NotNull + private SidebarLine getTabText(String path, Player targetPlayer, @Nullable HashMap replacements) { + List strings = Language.getList(getPlayer(), path); + if (strings.isEmpty()) { + return new SidebarLine() { + @NotNull + @Override + public String getLine() { + return ""; + } + }; + } + + strings = new ArrayList<>(); + for (String string : Language.getList(getPlayer(), path)) { + String parsed = string.replace("{vPrefix}", BedWars.getChatSupport().getPrefix(targetPlayer)) + .replace("{vSuffix}", BedWars.getChatSupport().getSuffix(targetPlayer)); + + if (null != replacements) { + for (Map.Entry entry : replacements.entrySet()) { + parsed = parsed.replace(entry.getKey(), entry.getValue()); + } + } + + strings.add(parsed); + } + + if (strings.size() == 1) { + final String line = strings.get(0); + return new SidebarLine() { + @NotNull + @Override + public String getLine() { + return line; + } + }; + } + + final String[] lines = new String[strings.size()]; + for (int i = 0; i < lines.length; i++) { + lines[i] = strings.get(i); + } + return new SidebarLineAnimated(lines); + } + + /** + * @return true if tab formatting is disabled for current sidebar/ arena stage + */ + private boolean isTabFormattingDisabled() { + if (null == arena) { + + if (getServerType() == ServerType.SHARED) { + if (config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_LIST_FORMAT_LOBBY) && + !config.getLobbyWorldName().trim().isEmpty()) { + + World lobby = Bukkit.getWorld(config.getLobbyWorldName()); + return null != lobby; + } + } + + return config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_LIST_FORMAT_LOBBY); + } + // if tab formatting is disabled in game + if (arena.getStatus() == GameState.playing && config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_LIST_FORMAT_PLAYING)) { + return false; + } + + // if tab formatting is disabled in starting + if (arena.getStatus() == GameState.starting && config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_LIST_FORMAT_STARTING)) { + return false; + } + + // if tab formatting is disabled in waiting + if (arena.getStatus() == GameState.waiting && config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_LIST_FORMAT_WAITING)) { + return false; + } + + // if tab formatting is disabled in restarting + if (arena.getStatus() == GameState.restarting && config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_LIST_FORMAT_RESTARTING)) { + return false; + } + + return true; + } + + public void handleHealthIcon() { + if (null == handle) { + return; + } + + if (null == arena) { + handle.hidePlayersHealth(); + } else if (arena.getStatus() != GameState.playing) { + handle.hidePlayersHealth(); + } + + List animation = Language.getList(player, Messages.FORMATTING_SCOREBOARD_HEALTH); + if (animation.isEmpty()) return; + SidebarLine line; + if (animation.size() > 1) { + String[] lines = new String[animation.size()]; + for (int i = 0; i < animation.size(); i++) { + lines[i] = animation.get(i); + } + line = new SidebarLineAnimated(lines); + } else { + final String text = animation.get(0); + line = new SidebarLine() { + @NotNull + @Override + public String getLine() { + return text; + } + }; + } + + handle.showPlayersHealth(line, config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_HEALTH_IN_TAB)); + Bukkit.getScheduler().runTaskLater(plugin, () -> { + if (arena != null && handle != null) { + arena.getPlayers().forEach(player -> handle.setPlayerHealth(player, (int) Math.ceil(player.getHealth()))); + if (arena.isSpectator(getPlayer())) { + arena.getSpectators().forEach(player -> handle.setPlayerHealth(player, (int) Math.ceil(player.getHealth()))); + } + } + }, 20L); + } + + /** + * Hide player name tag on head when he drinks an invisibility potion. + * This is required because not all clients hide it automatically. + * @param toggle true when applied, false when expired. + */ + public void handleInvisibilityPotion(@NotNull Player player, boolean toggle) { + if (toggle) { +// handle.remove(player); +// handle.playerListHideNameTag(player); + //todo the new sidebar does not provide a solution for invisibility potion?!! + } else { +// this.giveUpdateTabFormat(player, false); +// handle.playerListRestoreNameTag(player); + } + } + + public Sidebar getHandle() { + return handle; + } + + public IArena getArena() { + return arena; + } +} diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/ScoreboardListener.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/ScoreboardListener.java index 04f0646ed..b50b9aa63 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/ScoreboardListener.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/ScoreboardListener.java @@ -27,7 +27,6 @@ import com.andrei1058.bedwars.api.events.player.PlayerKillEvent; import com.andrei1058.bedwars.api.events.player.PlayerReJoinEvent; import com.andrei1058.bedwars.api.events.player.PlayerReSpawnEvent; -import com.andrei1058.bedwars.api.language.Messages; import com.andrei1058.bedwars.arena.Arena; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -47,14 +46,9 @@ public void onPlayerDamage(EntityDamageEvent e) { final IArena arena = Arena.getArenaByPlayer(player); int health = (int) Math.ceil((player.getHealth() - e.getFinalDamage())); - if (arena == null) return; - for (BedWarsScoreboard scoreboard : BedWarsScoreboard.getScoreboards().values()) { - if (arena.equals(scoreboard.getArena())) { - scoreboard.getHandle().refreshHealth(player, health); - } - } + SidebarService.getInstance().refreshHealth(arena, player, health); } @EventHandler(priority = EventPriority.MONITOR) @@ -68,22 +62,15 @@ public void onRegain(EntityRegainHealthEvent e) { int health = (int) Math.ceil(player.getHealth() + e.getAmount()); - for (BedWarsScoreboard scoreboard : BedWarsScoreboard.getScoreboards().values()) { - if (arena.equals(scoreboard.getArena())) { - scoreboard.getHandle().refreshHealth(player, health); - } - } + SidebarService.getInstance().refreshHealth(arena, player, health); } @EventHandler(priority = EventPriority.MONITOR) public void onReSpawn(PlayerReSpawnEvent e) { if (e == null) return; final IArena arena = e.getArena(); - for (BedWarsScoreboard scoreboard : BedWarsScoreboard.getScoreboards().values()) { - if (arena.equals(scoreboard.getArena())) { - scoreboard.getHandle().refreshHealth(e.getPlayer(), (int) Math.ceil(e.getPlayer().getHealth())); - } - } + + SidebarService.getInstance().refreshHealth(arena, e.getPlayer(), (int) Math.ceil(e.getPlayer().getHealth())); } @EventHandler(priority = EventPriority.LOWEST) @@ -95,11 +82,7 @@ public void reJoin(PlayerReJoinEvent e) { final Player player = e.getPlayer(); // re-add player to scoreboard tab list - for (BedWarsScoreboard scoreboard : BedWarsScoreboard.getScoreboards().values()) { - if (arena.equals(scoreboard.getArena())) { - scoreboard.addToTabList(player, Messages.FORMATTING_SCOREBOARD_TAB_PREFIX_PLAYING, Messages.FORMATTING_SCOREBOARD_TAB_SUFFIX_PLAYING); - } - } + SidebarService.getInstance().handleReJoin(arena, player); } @EventHandler @@ -108,11 +91,7 @@ public void onBedDestroy(PlayerBedBreakEvent e) { final IArena arena = e.getArena(); // refresh placeholders in case placeholders refresh is disabled - BedWarsScoreboard.getScoreboards().values().forEach(bedWarsScoreboard -> { - if (arena.equals(bedWarsScoreboard.getArena())) { - bedWarsScoreboard.getHandle().refreshPlaceholders(); - } - }); + SidebarService.getInstance().refreshPlaceholders(arena); } @EventHandler @@ -122,10 +101,6 @@ public void onFinalKill(PlayerKillEvent e) { final IArena arena = e.getArena(); // refresh placeholders in case placeholders refresh is disabled - BedWarsScoreboard.getScoreboards().values().forEach(bedWarsScoreboard -> { - if (arena.equals(bedWarsScoreboard.getArena())) { - bedWarsScoreboard.getHandle().refreshPlaceholders(); - } - }); + SidebarService.getInstance().refreshPlaceholders(arena); } } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarService.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarService.java new file mode 100644 index 000000000..cbf5a86bf --- /dev/null +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarService.java @@ -0,0 +1,182 @@ +package com.andrei1058.bedwars.sidebar; + +import com.andrei1058.bedwars.BedWars; +import com.andrei1058.bedwars.api.arena.GameState; +import com.andrei1058.bedwars.api.arena.IArena; +import com.andrei1058.bedwars.api.arena.team.ITeam; +import com.andrei1058.bedwars.api.configuration.ConfigPath; +import com.andrei1058.bedwars.api.language.Language; +import com.andrei1058.bedwars.api.language.Messages; +import com.andrei1058.bedwars.api.server.ServerType; +import com.andrei1058.spigot.sidebar.SidebarManager; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.*; + +import static com.andrei1058.bedwars.BedWars.config; +import static com.andrei1058.bedwars.api.language.Language.getScoreboard; + +public class SidebarService { + + private static SidebarService instance; + + private final SidebarManager sidebarHandler; + private final HashMap sidebars = new HashMap<>(); + + + public static boolean init() { + if (null == instance) { + instance = new SidebarService(); + } + return instance.sidebarHandler != null; + } + + private SidebarService() { + sidebarHandler = SidebarManager.init(); + } + + public void giveSidebar(@NotNull Player player, @Nullable IArena arena, boolean delay) { + BwSidebar sidebar = sidebars.getOrDefault(player.getUniqueId(), null); + + // check if we might need to remove the existing sidebar + if (null != sidebar) { + if (null == arena) { + // if sidebar is disabled in lobby on shared mode + if (!config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_USE_LOBBY_SIDEBAR)) { + this.remove(sidebar); + return; + } + } else { + // if sidebar is disabled in game + if (!config.getBoolean(ConfigPath.SB_CONFIG_SIDEBAR_USE_GAME_SIDEBAR)) { + this.remove(sidebar); + return; + } + } + } + + // set sidebar lines based on game state or lobby + List lines = null; + List title; + if (null == arena) { + if (BedWars.getServerType() != ServerType.SHARED) { + lines = Language.getList(player, Messages.SCOREBOARD_LOBBY); + } + } else { + if (arena.getStatus() == GameState.waiting) { + lines = getScoreboard(player, "scoreboard." + arena.getGroup() + ".waiting", Messages.SCOREBOARD_DEFAULT_WAITING); + } else if (arena.getStatus() == GameState.starting) { + lines = getScoreboard(player, "scoreboard." + arena.getGroup() + ".starting", Messages.SCOREBOARD_DEFAULT_STARTING); + } else if (arena.getStatus() == GameState.playing || arena.getStatus() == GameState.restarting) { + lines = getScoreboard(player, "scoreboard." + arena.getGroup() + ".playing", Messages.SCOREBOARD_DEFAULT_PLAYING); + } + } + + // if we do not have lines we eventually remove the sidebar + if (null == lines || lines.isEmpty()) { + if (null != sidebar) { + this.remove(sidebar); + } + return; + } + + // title is the first line from array + title = new ArrayList<>(Collections.singleton(lines.get(0))); + if (lines.size() == 1) { + lines = new ArrayList<>(); + } + lines = lines.subList(1, lines.size()); + + // at this point we are sure we need a sidebar instance + boolean newlyAdded = false; + if (null == sidebar) { + sidebar = new BwSidebar(player); + newlyAdded = true; + } + sidebar.setContent(title, lines, arena); + + if (newlyAdded) { + sidebars.put(player.getUniqueId(), sidebar); + } + } + + /** + * Kill a sidebar lifecycle. + */ + public void remove(@NotNull BwSidebar sidebar) { + this.sidebars.remove(sidebar.getPlayer().getUniqueId()); + sidebar.remove(); + } + + public void remove(@NotNull Player player) { + BwSidebar sidebar = this.sidebars.remove(player.getUniqueId()); + if (null != sidebar) { + sidebar.remove(); + } + } + + public static SidebarService getInstance() { + return instance; + } + + protected SidebarManager getSidebarHandler() { + return sidebarHandler; + } + + public void refreshTitles() { + this.sidebars.forEach((k, v) -> v.getHandle().refreshTitle()); + } + + public void refreshPlaceholders() { + this.sidebars.forEach((k, v) -> v.getHandle().refreshPlaceholders()); + } + + public void refreshPlaceholders(IArena arena) { + this.sidebars.forEach((k, v) -> { + if (v.getArena().equals(arena)) { + v.getHandle().refreshPlaceholders(); + } + }); + } + + public void refreshTabList() { + this.sidebars.forEach((k, v) -> v.getHandle().playerTabRefreshAnimation()); + } + + public void refreshHealth() { + this.sidebars.forEach((k, v) -> { + if (null != v.getArena()) { + v.getHandle().playerHealthRefreshAnimation(); + for (Player player : v.getArena().getPlayers()){ + v.getHandle().setPlayerHealth(player, (int) Math.ceil(player.getHealth())); + } + } + }); + } + + public void refreshHealth(IArena arena, Player player, int health) { + this.sidebars.forEach((k,v) -> { + if (null != v.getArena() && v.getArena().equals(arena)) { + v.getHandle().setPlayerHealth(player, health); + } + }); + } + + public void handleReJoin(IArena arena, Player player) { + this.sidebars.forEach((k,v) -> { + if (null != v.getArena() && v.getArena().equals(arena)) { + v.giveUpdateTabFormat(player, false); + } + }); + } + + public void handleInvisibility(ITeam team, Player player, boolean toggle) { + this.sidebars.forEach((k,v) -> { + if (null != v.getArena() && v.getArena().equals(team.getArena())) { + v.handleInvisibilityPotion(player, toggle); + } + }); + } +} diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarTitleRefresh.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/thread/RefreshLifeTask.java similarity index 73% rename from bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarTitleRefresh.java rename to bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/thread/RefreshLifeTask.java index 0a5b7ff8c..22dbfafae 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarTitleRefresh.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/thread/RefreshLifeTask.java @@ -1,6 +1,6 @@ /* * BedWars1058 - A bed wars mini-game. - * Copyright (C) 2021 Andrei Dascălu + * Copyright (C) 2022 Andrei Dascălu * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,13 +18,13 @@ * Contact e-mail: andrew.dascalu@gmail.com */ -package com.andrei1058.bedwars.sidebar; +package com.andrei1058.bedwars.sidebar.thread; -public class SidebarTitleRefresh implements Runnable { +import com.andrei1058.bedwars.sidebar.SidebarService; + +public class RefreshLifeTask implements Runnable { @Override public void run() { - for (BedWarsScoreboard scoreboard : BedWarsScoreboard.getScoreboards().values()){ - scoreboard.getHandle().refreshTitle(); - } + SidebarService.getInstance().refreshHealth(); } } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarListRefresh.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/thread/RefreshPlaceholdersTask.java similarity index 72% rename from bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarListRefresh.java rename to bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/thread/RefreshPlaceholdersTask.java index 0689909b6..9af1ba616 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarListRefresh.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/thread/RefreshPlaceholdersTask.java @@ -1,6 +1,6 @@ /* * BedWars1058 - A bed wars mini-game. - * Copyright (C) 2021 Andrei Dascălu + * Copyright (C) 2022 Andrei Dascălu * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,13 +18,13 @@ * Contact e-mail: andrew.dascalu@gmail.com */ -package com.andrei1058.bedwars.sidebar; +package com.andrei1058.bedwars.sidebar.thread; -public class SidebarListRefresh implements Runnable { +import com.andrei1058.bedwars.sidebar.SidebarService; + +public class RefreshPlaceholdersTask implements Runnable { @Override public void run() { - for (BedWarsScoreboard scoreboard : BedWarsScoreboard.getScoreboards().values()){ - scoreboard.getHandle().playerListRefreshAnimation(); - } + SidebarService.getInstance().refreshPlaceholders(); } } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarPlaceholderRefresh.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/thread/RefreshTabListTask.java similarity index 67% rename from bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarPlaceholderRefresh.java rename to bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/thread/RefreshTabListTask.java index 1b67a11aa..cbd61ac76 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarPlaceholderRefresh.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/thread/RefreshTabListTask.java @@ -1,6 +1,6 @@ /* * BedWars1058 - A bed wars mini-game. - * Copyright (C) 2021 Andrei Dascălu + * Copyright (C) 2022 Andrei Dascălu * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,15 +18,13 @@ * Contact e-mail: andrew.dascalu@gmail.com */ -package com.andrei1058.bedwars.sidebar; +package com.andrei1058.bedwars.sidebar.thread; -public class SidebarPlaceholderRefresh implements Runnable { +import com.andrei1058.bedwars.sidebar.SidebarService; + +public class RefreshTabListTask implements Runnable { @Override public void run() { - for (BedWarsScoreboard sb : BedWarsScoreboard.getScoreboards().values()){ - sb.getHandle().refreshPlaceholders(); - //TODO: move to their own task - //sb.getHandle().refreshHealthAnimation(); - } + SidebarService.getInstance().refreshTabList(); } } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarLifeRefresh.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/thread/RefreshTitleTask.java similarity index 57% rename from bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarLifeRefresh.java rename to bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/thread/RefreshTitleTask.java index 90a424d18..3bb1e13ce 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/SidebarLifeRefresh.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/sidebar/thread/RefreshTitleTask.java @@ -1,6 +1,6 @@ /* * BedWars1058 - A bed wars mini-game. - * Copyright (C) 2021 Andrei Dascălu + * Copyright (C) 2022 Andrei Dascălu * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,20 +18,13 @@ * Contact e-mail: andrew.dascalu@gmail.com */ -package com.andrei1058.bedwars.sidebar; +package com.andrei1058.bedwars.sidebar.thread; -import org.bukkit.entity.Player; +import com.andrei1058.bedwars.sidebar.SidebarService; -public class SidebarLifeRefresh implements Runnable { +public class RefreshTitleTask implements Runnable { @Override public void run() { - for (BedWarsScoreboard scoreboard : BedWarsScoreboard.getScoreboards().values()){ - if (scoreboard.getArena() != null){ - scoreboard.getHandle().refreshHealthAnimation(); - for (Player player : scoreboard.getArena().getPlayers()){ - scoreboard.getHandle().refreshHealth(player, (int) Math.ceil(player.getHealth())); - } - } - } + SidebarService.getInstance().refreshTitles(); } } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/stats/StatsManager.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/stats/StatsManager.java index c67135a9d..606e2fa69 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/stats/StatsManager.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/stats/StatsManager.java @@ -22,6 +22,8 @@ import com.andrei1058.bedwars.BedWars; import org.bukkit.Bukkit; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Map; import java.util.UUID; @@ -29,10 +31,9 @@ public class StatsManager { - private Map stats; + private final Map stats = new ConcurrentHashMap<>(); public StatsManager() { - stats = new ConcurrentHashMap<>(); registerListeners(); } @@ -44,6 +45,7 @@ public void put(UUID uuid, PlayerStats playerStats) { stats.put(uuid, playerStats); } + @NotNull public PlayerStats get(UUID uuid) { PlayerStats playerStats = stats.get(uuid); if (playerStats == null) { @@ -52,6 +54,7 @@ public PlayerStats get(UUID uuid) { return playerStats; } + @Nullable public PlayerStats getUnsafe(UUID uuid) { return stats.get(uuid); } diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/support/paper/PaperSupport.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/support/paper/PaperSupport.java new file mode 100644 index 000000000..d93e18185 --- /dev/null +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/support/paper/PaperSupport.java @@ -0,0 +1,35 @@ +package com.andrei1058.bedwars.support.paper; + +import com.andrei1058.bedwars.api.configuration.ConfigPath; +import com.andrei1058.bedwars.configuration.MainConfig; +import io.papermc.lib.PaperLib; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.event.player.PlayerTeleportEvent; + +import static com.andrei1058.bedwars.BedWars.config; +import static com.andrei1058.bedwars.BedWars.isPaper; + +public final class PaperSupport { + + public static void teleport(Entity entity, Location location){ + if (isPaper && config.getBoolean(ConfigPath.GENERAL_CONFIGURATION_PERFORMANCE_PAPER_FEATURES)){ + PaperLib.teleportAsync(entity, location); + } + else + { + entity.teleport(location); + } + } + + public static void teleportC(Entity entity, Location location, PlayerTeleportEvent.TeleportCause cause){ + if (isPaper){ + PaperLib.teleportAsync(entity, location, cause); + } + else + { + entity.teleport(location, cause); + } + } + +} diff --git a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/support/papi/PAPISupport.java b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/support/papi/PAPISupport.java index 13fe54ddc..1f2363f93 100644 --- a/bedwars-plugin/src/main/java/com/andrei1058/bedwars/support/papi/PAPISupport.java +++ b/bedwars-plugin/src/main/java/com/andrei1058/bedwars/support/papi/PAPISupport.java @@ -28,6 +28,7 @@ import com.andrei1058.bedwars.api.language.Messages; import com.andrei1058.bedwars.arena.Arena; import com.andrei1058.bedwars.commands.shout.ShoutCommand; +import com.andrei1058.bedwars.stats.PlayerStats; import me.clip.placeholderapi.expansion.PlaceholderExpansion; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; @@ -66,8 +67,9 @@ public boolean persist() { } @Override - public String onPlaceholderRequest(Player player, String s) { - if (s == null) return null; + public String onPlaceholderRequest(Player player, @NotNull String s) { + + /* Non-Player required placeholders */ if (s.startsWith("arena_status_")) { IArena a = Arena.getArenaByName(s.replace("arena_status_", "")); @@ -106,139 +108,144 @@ public String onPlaceholderRequest(Player player, String s) { return "-"; } + /* Player required placeholders */ if (player == null) return null; - String replay = ""; + + // stats placeholders + if(s.startsWith("stats_")) { + String targetedStat = s.replaceFirst("stats_", ""); + if(targetedStat.isEmpty() || targetedStat.isBlank()) { + return null; + } + PlayerStats stats = BedWars.getStatsManager().getUnsafe(player.getUniqueId()); + if(stats == null) { + return null; + } + switch (targetedStat) { + case "firstplay": + Instant firstPlay = stats.getFirstPlay(); + return new SimpleDateFormat(getMsg(player, Messages.FORMATTING_STATS_DATE_FORMAT)).format(firstPlay != null ? Timestamp.from(firstPlay) : null); + case "lastplay": + Instant lastPlay = stats.getLastPlay(); + return new SimpleDateFormat(getMsg(player, Messages.FORMATTING_STATS_DATE_FORMAT)).format(lastPlay != null ? Timestamp.from(lastPlay) : null); + case "total_kills": + return String.valueOf(stats.getTotalKills()); + case "kills": + return String.valueOf(stats.getKills()); + case "wins": + return String.valueOf(stats.getWins()); + case "finalkills": + return String.valueOf(stats.getFinalKills()); + case "deaths": + return String.valueOf(stats.getDeaths()); + case "losses": + return String.valueOf(stats.getLosses()); + case "finaldeaths": + return String.valueOf(stats.getFinalDeaths()); + case "bedsdestroyed": + return String.valueOf(stats.getBedsDestroyed()); + case "gamesplayed": + return String.valueOf(stats.getGamesPlayed()); + } + } + + // other placeholders + String response = ""; IArena a = Arena.getArenaByPlayer(player); switch (s) { - case "stats_firstplay": - Instant firstPlay = BedWars.getStatsManager().get(player.getUniqueId()).getFirstPlay(); - replay = new SimpleDateFormat(getMsg(player, Messages.FORMATTING_STATS_DATE_FORMAT)).format(firstPlay != null ? Timestamp.from(firstPlay) : null); - break; - case "stats_lastplay": - Instant lastPlay = BedWars.getStatsManager().get(player.getUniqueId()).getLastPlay(); - replay = new SimpleDateFormat(getMsg(player, Messages.FORMATTING_STATS_DATE_FORMAT)).format(lastPlay != null ? Timestamp.from(lastPlay) : null); - break; - case "stats_total_kills": - replay = String.valueOf(BedWars.getStatsManager().get(player.getUniqueId()).getTotalKills()); - break; - case "stats_kills": - replay = String.valueOf(BedWars.getStatsManager().get(player.getUniqueId()).getKills()); - break; - case "stats_wins": - replay = String.valueOf(BedWars.getStatsManager().get(player.getUniqueId()).getWins()); - break; - case "stats_finalkills": - replay = String.valueOf(BedWars.getStatsManager().get(player.getUniqueId()).getFinalKills()); - break; - case "stats_deaths": - replay = String.valueOf(BedWars.getStatsManager().get(player.getUniqueId()).getDeaths()); - break; - case "stats_losses": - replay = String.valueOf(BedWars.getStatsManager().get(player.getUniqueId()).getLosses()); - break; - case "stats_finaldeaths": - replay = String.valueOf(BedWars.getStatsManager().get(player.getUniqueId()).getFinalDeaths()); - break; - case "stats_bedsdestroyed": - replay = String.valueOf(BedWars.getStatsManager().get(player.getUniqueId()).getBedsDestroyed()); - break; - case "stats_gamesplayed": - replay = String.valueOf(BedWars.getStatsManager().get(player.getUniqueId()).getGamesPlayed()); - break; case "current_online": - replay = String.valueOf(Arena.getArenaByPlayer().size()); + response = String.valueOf(Arena.getArenaByPlayer().size()); break; case "current_arenas": - replay = String.valueOf(Arena.getArenas().size()); + response = String.valueOf(Arena.getArenas().size()); break; case "current_playing": if (a != null) { - replay = String.valueOf(a.getPlayers().size()); + response = String.valueOf(a.getPlayers().size()); } break; case "player_team_color": if (a != null && a.isPlayer(player) && a.getStatus() == GameState.playing) { ITeam team = a.getTeam(player); if (team != null) { - replay += String.valueOf(team.getColor().chat()); + response += String.valueOf(team.getColor().chat()); } } break; case "player_team": if (a != null) { if (ShoutCommand.isShout(player)) { - replay += Language.getMsg(player, Messages.FORMAT_PAPI_PLAYER_TEAM_SHOUT); + response += Language.getMsg(player, Messages.FORMAT_PAPI_PLAYER_TEAM_SHOUT); } if (a.isPlayer(player)) { if (a.getStatus() == GameState.playing) { ITeam bwt = a.getTeam(player); if (bwt != null) { - replay += Language.getMsg(player, Messages.FORMAT_PAPI_PLAYER_TEAM_TEAM).replace("{TeamName}", + response += Language.getMsg(player, Messages.FORMAT_PAPI_PLAYER_TEAM_TEAM).replace("{TeamName}", bwt.getDisplayName(Language.getPlayerLanguage(player))).replace("{TeamColor}", String.valueOf(bwt.getColor().chat())); } } } else { - replay += Language.getMsg(player, Messages.FORMAT_PAPI_PLAYER_TEAM_SPECTATOR); + response += Language.getMsg(player, Messages.FORMAT_PAPI_PLAYER_TEAM_SPECTATOR); } } break; case "player_level": - replay = BedWars.getLevelSupport().getLevel(player); + response = BedWars.getLevelSupport().getLevel(player); break; case "player_level_raw": - replay = String.valueOf(BedWars.getLevelSupport().getPlayerLevel(player)); + response = String.valueOf(BedWars.getLevelSupport().getPlayerLevel(player)); break; case "player_progress": - replay = BedWars.getLevelSupport().getProgressBar(player); + response = BedWars.getLevelSupport().getProgressBar(player); break; case "player_xp_formatted": - replay = BedWars.getLevelSupport().getCurrentXpFormatted(player); + response = BedWars.getLevelSupport().getCurrentXpFormatted(player); break; case "player_xp": - replay = String.valueOf(BedWars.getLevelSupport().getCurrentXp(player)); + response = String.valueOf(BedWars.getLevelSupport().getCurrentXp(player)); break; case "player_rerq_xp_formatted": - replay = BedWars.getLevelSupport().getRequiredXpFormatted(player); + response = BedWars.getLevelSupport().getRequiredXpFormatted(player); break; case "player_rerq_xp": - replay = String.valueOf(BedWars.getLevelSupport().getRequiredXp(player)); + response = String.valueOf(BedWars.getLevelSupport().getRequiredXp(player)); break; case "player_status": if(a != null) { switch (a.getStatus()) { case waiting: case starting: - replay = "WAITING"; + response = "WAITING"; break; case playing: if(a.isPlayer(player)) { - replay = "PLAYING"; + response = "PLAYING"; } else if(a.isSpectator(player)) { - replay = "SPECTATING"; + response = "SPECTATING"; } else { - replay = "IN_GAME_BUT_NOT"; // this shouldnt happen + response = "IN_GAME_BUT_NOT"; // this shouldnt happen } break; case restarting: - replay = "RESTARTING"; + response = "RESTARTING"; break; } } else { - replay = "NONE"; + response = "NONE"; } break; case "current_arena_group": if (a != null) { - replay = a.getGroup(); + response = a.getGroup(); } break; case "elapsed_time": if (a != null) { - replay = elapsedFormat.format(Instant.now().minusMillis(a.getStartTime().toEpochMilli())); + response = elapsedFormat.format(Instant.now().minusMillis(a.getStartTime().toEpochMilli())); } break; - } - return replay; + return response; } } diff --git a/bedwars_mysql_remake.drawio b/bedwars_mysql_remake.drawio deleted file mode 100644 index 00210864a..000000000 --- a/bedwars_mysql_remake.drawio +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pom.xml b/pom.xml index 447964f5a..5e38b55dd 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.andrei1058.bedwars BedWars1058 pom - 22.3-SNAPSHOT + 22.9-SNAPSHOT UTF-8 @@ -52,7 +52,7 @@ org.jetbrains annotations - 23.0.0 + 23.1.0 provided @@ -62,7 +62,7 @@ org.apache.maven.wagon wagon-ftp - 3.5.1 + 3.5.2 @@ -71,14 +71,14 @@ maven-compiler-plugin 3.10.1 - 11 - 11 + 8 + 8 org.apache.maven.plugins maven-javadoc-plugin - 3.4.0 + 3.4.1 true @@ -106,7 +106,8 @@ versionsupport_common versionsupport_v1_16_R3 versionsupport_v1_17_R1 - versionsupport_v1_18_R1 + versionsupport_v1_18_R2 + versionsupport_v1_19_R2 diff --git a/resetadapter_slime/pom.xml b/resetadapter_slime/pom.xml index 688c68fce..5f318fa21 100644 --- a/resetadapter_slime/pom.xml +++ b/resetadapter_slime/pom.xml @@ -7,7 +7,7 @@ BedWars1058 com.andrei1058.bedwars - 22.3-SNAPSHOT + 22.9-SNAPSHOT resetadapter-slime diff --git a/versionsupport_1_12_R1/pom.xml b/versionsupport_1_12_R1/pom.xml index 7a36bbe1f..a6174c3ec 100644 --- a/versionsupport_1_12_R1/pom.xml +++ b/versionsupport_1_12_R1/pom.xml @@ -10,7 +10,7 @@ BedWars1058 com.andrei1058.bedwars - 22.3-SNAPSHOT + 22.9-SNAPSHOT diff --git a/versionsupport_1_12_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_12_R1/v1_12_R1.java b/versionsupport_1_12_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_12_R1/v1_12_R1.java index 7b7462636..4762ceb9d 100644 --- a/versionsupport_1_12_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_12_R1/v1_12_R1.java +++ b/versionsupport_1_12_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_12_R1/v1_12_R1.java @@ -35,6 +35,7 @@ import net.minecraft.server.v1_12_R1.*; import org.bukkit.Color; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.block.Bed; import org.bukkit.block.BlockState; @@ -706,4 +707,23 @@ public void playRedStoneDot(Player player) { public void clearArrowsFromPlayerBody(Player player) { ((CraftLivingEntity)player).getHandle().getDataWatcher().set(new DataWatcherObject<>(10, DataWatcherRegistry.b),-1); } + + @Override + public void placeTowerBlocks(org.bukkit.block.Block b, IArena a, TeamColor color, int x, int y, int z){ + b.getRelative(x, y, z).setType(Material.WOOL); + setBlockTeamColor(b.getRelative(x, y, z), color); + a.addPlacedBlock(b.getRelative(x, y, z)); + } + + @Override + public void placeLadder(org.bukkit.block.Block b, int x, int y, int z, IArena a, int ladderdata){ + b.getRelative(x, y, z).setType(Material.LADDER); + b.getRelative(x, y, z).setData((byte)ladderdata); + a.addPlacedBlock(b.getRelative(x, y, z)); + } + + @Override + public void playVillagerEffect(Player player, Location location){ + player.spawnParticle(Particle.VILLAGER_HAPPY, location, 1); + } } diff --git a/versionsupport_1_8_R3/pom.xml b/versionsupport_1_8_R3/pom.xml index 4e9bfcc88..e1d9d05d4 100644 --- a/versionsupport_1_8_R3/pom.xml +++ b/versionsupport_1_8_R3/pom.xml @@ -7,7 +7,7 @@ BedWars1058 com.andrei1058.bedwars - 22.3-SNAPSHOT + 22.9-SNAPSHOT versionsupport_1_8_R3 diff --git a/versionsupport_1_8_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_8_R3/v1_8_R3.java b/versionsupport_1_8_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_8_R3/v1_8_R3.java index f2c8cf4dc..86023028f 100644 --- a/versionsupport_1_8_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_8_R3/v1_8_R3.java +++ b/versionsupport_1_8_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_8_R3/v1_8_R3.java @@ -34,6 +34,7 @@ import net.minecraft.server.v1_8_R3.*; import org.bukkit.Color; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.craftbukkit.v1_8_R3.CraftServer; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; @@ -735,4 +736,24 @@ public void playRedStoneDot(Player player) { public void clearArrowsFromPlayerBody(Player player) { ((CraftLivingEntity)player).getHandle().getDataWatcher().watch(9, (byte)-1); } + + @Override + public void placeTowerBlocks(org.bukkit.block.Block b, IArena a, TeamColor color, int x, int y, int z){ + b.getRelative(x, y, z).setType(Material.WOOL); + setBlockTeamColor(b.getRelative(x, y, z), color); + a.addPlacedBlock(b.getRelative(x, y, z)); + } + + @Override + public void placeLadder(org.bukkit.block.Block b, int x, int y, int z, IArena a, int ladderdata){ + b.getRelative(x, y, z).setType(Material.LADDER); + b.getRelative(x, y, z).setData((byte)ladderdata); + a.addPlacedBlock(b.getRelative(x, y, z)); + } + + @Override + public void playVillagerEffect(Player player, Location location){ + PacketPlayOutWorldParticles pwp = new PacketPlayOutWorldParticles(EnumParticle.VILLAGER_HAPPY, true, (float) location.getX(), (float) location.getY(), (float) location.getZ(), (float) 0, (float) 0, (float) 0, (float) 0, 1); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(pwp); + } } diff --git a/versionsupport_common/pom.xml b/versionsupport_common/pom.xml index c165e1e1e..185f49df8 100644 --- a/versionsupport_common/pom.xml +++ b/versionsupport_common/pom.xml @@ -5,7 +5,7 @@ BedWars1058 com.andrei1058.bedwars - 22.3-SNAPSHOT + 22.9-SNAPSHOT 4.0.0 @@ -23,7 +23,7 @@ com.andrei1058.bedwars bedwars-api - ${parent.version} + ${project.parent.version} provided diff --git a/versionsupport_common/src/main/java/com/andrei1058/bedwars/listeners/ItemDropPickListener.java b/versionsupport_common/src/main/java/com/andrei1058/bedwars/listeners/ItemDropPickListener.java index ca9f5ffa4..441c7a001 100644 --- a/versionsupport_common/src/main/java/com/andrei1058/bedwars/listeners/ItemDropPickListener.java +++ b/versionsupport_common/src/main/java/com/andrei1058/bedwars/listeners/ItemDropPickListener.java @@ -87,17 +87,6 @@ public void onArrowPick(PlayerPickupArrowEvent e){ } } - // common - public static class GeneratorCollect implements Listener { - @EventHandler - //Prevent AFK players from picking items - public void onCollect(PlayerGeneratorCollectEvent e){ - if (api.getAFKUtil().isPlayerAFK(e.getPlayer())){ - e.setCancelled(true); - } - } - } - /** * @return true if event should be cancelled */ @@ -136,13 +125,15 @@ private static boolean managePickup(Item item, LivingEntity player) { ItemMeta itemMeta = new ItemStack(material).getItemMeta(); //Call ore pick up event - PlayerGeneratorCollectEvent event = new PlayerGeneratorCollectEvent((Player) player, item, a); - Bukkit.getPluginManager().callEvent(event); - if (event.isCancelled()) { - return true; - } else { - item.getItemStack().setItemMeta(itemMeta); - } + if (!api.getAFKUtil().isPlayerAFK(((Player) player).getPlayer())){ + PlayerGeneratorCollectEvent event = new PlayerGeneratorCollectEvent((Player) player, item, a); + Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) { + return true; + } else { + item.getItemStack().setItemMeta(itemMeta); + } + }else return true; //Cancel event if player is afk } } } diff --git a/versionsupport_common/src/main/java/com/andrei1058/bedwars/listeners/PlayerDropPick_1_11Minus.java b/versionsupport_common/src/main/java/com/andrei1058/bedwars/listeners/PlayerDropPick_1_11Minus.java index 555304b33..eb32d70a3 100644 --- a/versionsupport_common/src/main/java/com/andrei1058/bedwars/listeners/PlayerDropPick_1_11Minus.java +++ b/versionsupport_common/src/main/java/com/andrei1058/bedwars/listeners/PlayerDropPick_1_11Minus.java @@ -25,6 +25,7 @@ import com.andrei1058.bedwars.api.arena.IArena; import com.andrei1058.bedwars.api.events.player.PlayerGeneratorCollectEvent; import com.andrei1058.bedwars.api.server.ServerType; +import com.andrei1058.bedwars.support.version.common.VersionCommon; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.event.EventHandler; @@ -79,7 +80,7 @@ public void onPickup(PlayerPickupItemEvent e) { return; } - if (e.getItem().getItemStack().getType().toString().equals("BED")) { + if (VersionCommon.api.getVersionSupport().isBed(e.getItem().getItemStack().getType())) { e.setCancelled(true); e.getItem().remove(); } else if (e.getItem().getItemStack().hasItemMeta()) { @@ -90,12 +91,18 @@ public void onPickup(PlayerPickupItemEvent e) { ItemMeta itemMeta = new ItemStack(material).getItemMeta(); //Call ore pick up event - PlayerGeneratorCollectEvent event = new PlayerGeneratorCollectEvent(e.getPlayer(), e.getItem(), a); - Bukkit.getPluginManager().callEvent(event); - if (event.isCancelled()){ + + if (!api.getAFKUtil().isPlayerAFK(e.getPlayer())){ + PlayerGeneratorCollectEvent event = new PlayerGeneratorCollectEvent(e.getPlayer(), e.getItem(), a); + Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()){ + e.setCancelled(true); + } else { + e.getItem().getItemStack().setItemMeta(itemMeta); + } + } + else { //Cancel Event if play is afk e.setCancelled(true); - } else { - e.getItem().getItemStack().setItemMeta(itemMeta); } } } @@ -133,12 +140,4 @@ public void onDrop(PlayerDropItemEvent e) { e.setCancelled(true); } } - - @EventHandler - //Prevent AFK players from picking items - public void onCollect(PlayerGeneratorCollectEvent e){ - if (api.getAFKUtil().isPlayerAFK(e.getPlayer())){ - e.setCancelled(true); - } - } } diff --git a/versionsupport_common/src/main/java/com/andrei1058/bedwars/support/version/common/VersionCommon.java b/versionsupport_common/src/main/java/com/andrei1058/bedwars/support/version/common/VersionCommon.java index 54adbad7e..09a6d6f95 100644 --- a/versionsupport_common/src/main/java/com/andrei1058/bedwars/support/version/common/VersionCommon.java +++ b/versionsupport_common/src/main/java/com/andrei1058/bedwars/support/version/common/VersionCommon.java @@ -65,7 +65,7 @@ public VersionCommon(VersionSupport versionSupport) { //} // common - registerListeners(versionSupport.getPlugin(), new ItemDropPickListener.GeneratorCollect(), new ShopItemRestoreListener.DefaultRestoreInvClose()); + registerListeners(versionSupport.getPlugin(), new ShopItemRestoreListener.DefaultRestoreInvClose()); } private void registerListeners(Plugin plugin, Listener... listener) { diff --git a/versionsupport_v1_16_R3/pom.xml b/versionsupport_v1_16_R3/pom.xml index 47d02eab5..26c2b0971 100644 --- a/versionsupport_v1_16_R3/pom.xml +++ b/versionsupport_v1_16_R3/pom.xml @@ -5,7 +5,7 @@ BedWars1058 com.andrei1058.bedwars - 22.3-SNAPSHOT + 22.9-SNAPSHOT 4.0.0 diff --git a/versionsupport_v1_16_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_16_R3/v1_16_R3.java b/versionsupport_v1_16_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_16_R3/v1_16_R3.java index fa7435618..4efbd94a0 100644 --- a/versionsupport_v1_16_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_16_R3/v1_16_R3.java +++ b/versionsupport_v1_16_R3/src/main/java/com/andrei1058/bedwars/support/version/v1_16_R3/v1_16_R3.java @@ -36,10 +36,12 @@ import net.minecraft.server.v1_16_R3.*; import org.bukkit.Color; import org.bukkit.Location; -import org.bukkit.Particle; +import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.block.data.type.Bed; +import org.bukkit.block.data.type.Ladder; import org.bukkit.block.data.type.WallSign; import org.bukkit.command.Command; import org.bukkit.craftbukkit.v1_16_R3.CraftServer; @@ -57,6 +59,7 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; import java.util.ArrayList; @@ -678,4 +681,40 @@ public void playRedStoneDot(Player player) { public void clearArrowsFromPlayerBody(Player player) { ((CraftLivingEntity)player).getHandle().getDataWatcher().set(new DataWatcherObject<>(11, DataWatcherRegistry.b),-1); } + + @Override + public void placeTowerBlocks(Block b, IArena a, TeamColor color, int x, int y,int z){ + b.getRelative(x, y, z).setType(color.woolMaterial()); + a.addPlacedBlock(b.getRelative(x, y, z)); + } + + @Override + public void placeLadder(Block b, int x, int y,int z, IArena a, int ladderdata){ + Block block = b.getRelative(x,y,z); //ladder block + block.setType(Material.LADDER); + Ladder ladder = (Ladder) block.getBlockData(); + a.addPlacedBlock(block); + switch (ladderdata){ + case 2: + ladder.setFacing(BlockFace.NORTH); + block.setBlockData(ladder); + return; + case 3: + ladder.setFacing(BlockFace.SOUTH); + block.setBlockData(ladder); + return; + case 4: + ladder.setFacing(BlockFace.WEST); + block.setBlockData(ladder); + return; + case 5: + ladder.setFacing(BlockFace.EAST); + block.setBlockData(ladder); + } + } + + @Override + public void playVillagerEffect(@NotNull Player player, Location location){ + player.spawnParticle(org.bukkit.Particle.VILLAGER_HAPPY, location, 1); + } } diff --git a/versionsupport_v1_17_R1/pom.xml b/versionsupport_v1_17_R1/pom.xml index bc1184a27..9d758b14b 100644 --- a/versionsupport_v1_17_R1/pom.xml +++ b/versionsupport_v1_17_R1/pom.xml @@ -5,7 +5,7 @@ BedWars1058 com.andrei1058.bedwars - 22.3-SNAPSHOT + 22.9-SNAPSHOT 4.0.0 diff --git a/versionsupport_v1_17_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_17_R1/v1_17_R1.java b/versionsupport_v1_17_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_17_R1/v1_17_R1.java index fa81ca9c9..93140d247 100644 --- a/versionsupport_v1_17_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_17_R1/v1_17_R1.java +++ b/versionsupport_v1_17_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_17_R1/v1_17_R1.java @@ -55,15 +55,19 @@ import net.minecraft.world.entity.item.EntityTNTPrimed; import net.minecraft.world.entity.projectile.EntityFireball; import net.minecraft.world.entity.projectile.IProjectile; -import net.minecraft.world.item.*; import net.minecraft.world.item.Item; +import net.minecraft.world.item.*; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockBase; import org.bukkit.Color; import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Particle; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.block.data.type.Bed; +import org.bukkit.block.data.type.Ladder; import org.bukkit.block.data.type.WallSign; import org.bukkit.command.Command; import org.bukkit.craftbukkit.v1_17_R1.CraftServer; @@ -72,7 +76,6 @@ import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftTNTPrimed; import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; -import org.bukkit.entity.Entity; import org.bukkit.entity.*; import org.bukkit.event.inventory.InventoryEvent; import org.bukkit.inventory.meta.ItemMeta; @@ -177,7 +180,7 @@ public void setSource(TNTPrimed tnt, Player owner) { EntityTNTPrimed nmsTNT = (((CraftTNTPrimed) tnt).getHandle()); try { //noinspection JavaReflectionMemberAccess - Field sourceField = EntityTNTPrimed.class.getDeclaredField("source"); + Field sourceField = EntityTNTPrimed.class.getDeclaredField("d"); sourceField.setAccessible(true); sourceField.set(nmsTNT, nmsEntityLiving); } catch (Exception ex) { @@ -709,4 +712,41 @@ public void playRedStoneDot(Player player) { public void clearArrowsFromPlayerBody(Player player) { ((CraftLivingEntity)player).getHandle().getDataWatcher().set(new DataWatcherObject<>(12, DataWatcherRegistry.b),-1); } + + @Override + public void placeTowerBlocks(Block b, IArena a, TeamColor color, int x, int y,int z){ + b.getRelative(x, y, z).setType(color.woolMaterial()); + a.addPlacedBlock(b.getRelative(x, y, z)); + } + + @Override + public void placeLadder(Block b, int x, int y,int z, IArena a, int ladderdata){ + Block block = b.getRelative(x,y,z); //ladder block + block.setType(Material.LADDER); + Ladder ladder = (Ladder) block.getBlockData(); + a.addPlacedBlock(block); + switch (ladderdata) { + case 2 -> { + ladder.setFacing(BlockFace.NORTH); + block.setBlockData(ladder); + } + case 3 -> { + ladder.setFacing(BlockFace.SOUTH); + block.setBlockData(ladder); + } + case 4 -> { + ladder.setFacing(BlockFace.WEST); + block.setBlockData(ladder); + } + case 5 -> { + ladder.setFacing(BlockFace.EAST); + block.setBlockData(ladder); + } + } + } + + @Override + public void playVillagerEffect(Player player, Location location){ + player.spawnParticle(Particle.VILLAGER_HAPPY, location, 1); + } } diff --git a/versionsupport_v1_18_R1/pom.xml b/versionsupport_v1_18_R2/pom.xml similarity index 92% rename from versionsupport_v1_18_R1/pom.xml rename to versionsupport_v1_18_R2/pom.xml index ed3124215..df95ac88e 100644 --- a/versionsupport_v1_18_R1/pom.xml +++ b/versionsupport_v1_18_R2/pom.xml @@ -5,11 +5,11 @@ BedWars1058 com.andrei1058.bedwars - 22.3-SNAPSHOT + 22.9-SNAPSHOT 4.0.0 - versionsupport_v1_18_R1 + versionsupport_v1_18_R2 @@ -29,7 +29,7 @@ org.spigotmc spigot - 1.18.1-R0.1-SNAPSHOT + 1.18.2-R0.1-SNAPSHOT jar provided diff --git a/versionsupport_v1_18_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R1/IGolem.java b/versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2/IGolem.java similarity index 86% rename from versionsupport_v1_18_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R1/IGolem.java rename to versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2/IGolem.java index aabf4f22a..3257e444a 100644 --- a/versionsupport_v1_18_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R1/IGolem.java +++ b/versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2/IGolem.java @@ -18,7 +18,7 @@ * Contact e-mail: andrew.dascalu@gmail.com */ -package com.andrei1058.bedwars.support.version.v1_18_R1; +package com.andrei1058.bedwars.support.version.v1_18_R2; import com.andrei1058.bedwars.api.arena.team.ITeam; import com.andrei1058.bedwars.api.language.Language; @@ -39,9 +39,9 @@ import net.minecraft.world.level.World; import org.apache.commons.lang.StringUtils; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_18_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_18_R1.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.CreatureSpawnEvent; @@ -63,23 +63,23 @@ public IGolem(EntityTypes entityTypes, World world) { @SuppressWarnings("rawtypes") @Override protected void u() { - this.bR.a(1, new PathfinderGoalFloat(this)); - this.bR.a(2, new PathfinderGoalMeleeAttack(this, 1.5D, false)); - this.bS.a(3, new PathfinderGoalHurtByTarget(this)); - this.bR.a(4, new PathfinderGoalRandomStroll(this, 1D)); - this.bR.a(5, new PathfinderGoalRandomLookaround(this)); - this.bS.a(6, new PathfinderGoalNearestAttackableTarget( + this.bQ.a(1, new PathfinderGoalFloat(this)); + this.bQ.a(2, new PathfinderGoalMeleeAttack(this, 1.5D, false)); + this.bR.a(3, new PathfinderGoalHurtByTarget(this)); + this.bQ.a(4, new PathfinderGoalRandomStroll(this, 1D)); + this.bQ.a(5, new PathfinderGoalRandomLookaround(this)); + this.bR.a(6, new PathfinderGoalNearestAttackableTarget( this, EntityHuman.class, 20, true, false, player -> !((EntityHuman)player).getBukkitEntity().isDead() && !team.wasMember(((EntityHuman)player).getBukkitEntity().getUniqueId()) && !team.getArena().isReSpawning(((EntityHuman)player).getBukkitEntity().getUniqueId()) && !team.getArena().isSpectator(((EntityHuman)player).getBukkitEntity().getUniqueId())) ); - this.bS.a(7, new PathfinderGoalNearestAttackableTarget( + this.bR.a(7, new PathfinderGoalNearestAttackableTarget( this, IGolem.class, 20, true, false, golem -> ((IGolem)golem).getTeam() != team) ); - this.bS.a(8, new PathfinderGoalNearestAttackableTarget( + this.bR.a(8, new PathfinderGoalNearestAttackableTarget( this, Silverfish.class, 20, true, false, sf -> ((Silverfish)sf).getTeam() != team) ); @@ -98,7 +98,7 @@ public static LivingEntity spawn(Location loc, ITeam bedWarsTeam, double speed, Objects.requireNonNull(customEnt.a(GenericAttributes.d)).a(speed); if (!CraftEventFactory.doEntityAddEventCalling(mcWorld, customEnt, CreatureSpawnEvent.SpawnReason.CUSTOM)){ - mcWorld.P.a(customEnt); + mcWorld.O.a(customEnt); } mcWorld.a(customEnt); diff --git a/versionsupport_v1_18_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R1/Silverfish.java b/versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2/Silverfish.java similarity index 87% rename from versionsupport_v1_18_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R1/Silverfish.java rename to versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2/Silverfish.java index 0b3d56d6b..4a28f6aae 100644 --- a/versionsupport_v1_18_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R1/Silverfish.java +++ b/versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2/Silverfish.java @@ -18,7 +18,7 @@ * Contact e-mail: andrew.dascalu@gmail.com */ -package com.andrei1058.bedwars.support.version.v1_18_R1; +package com.andrei1058.bedwars.support.version.v1_18_R2; import com.andrei1058.bedwars.api.arena.team.ITeam; import com.andrei1058.bedwars.api.language.Language; @@ -38,9 +38,9 @@ import net.minecraft.world.level.World; import org.apache.commons.lang.StringUtils; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_18_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_18_R1.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.CreatureSpawnEvent; @@ -61,20 +61,20 @@ public Silverfish(EntityTypes entityTypes, World world) { @Override protected void u() { - this.bR.a(1, new PathfinderGoalFloat(this)); - this.bR.a(2, new PathfinderGoalMeleeAttack(this, 1.9D, false)); - this.bS.a(1, new PathfinderGoalHurtByTarget(this)); - this.bR.a(3, new PathfinderGoalRandomStroll(this, 2D)); - this.bS.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 20, true, false, player -> { + this.bQ.a(1, new PathfinderGoalFloat(this)); + this.bQ.a(2, new PathfinderGoalMeleeAttack(this, 1.9D, false)); + this.bR.a(1, new PathfinderGoalHurtByTarget(this)); + this.bQ.a(3, new PathfinderGoalRandomStroll(this, 2D)); + this.bR.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 20, true, false, player -> { return (!((EntityHuman) player).getBukkitEntity().isDead()) && (!team.wasMember(((EntityHuman) player).getBukkitEntity().getUniqueId())) && (!team.getArena().isReSpawning(((EntityHuman) player).getBukkitEntity().getUniqueId())) && (!team.getArena().isSpectator(((EntityHuman) player).getBukkitEntity().getUniqueId())); })); - this.bS.a(3, new PathfinderGoalNearestAttackableTarget(this, IGolem.class, 20, true, false, golem -> { + this.bR.a(3, new PathfinderGoalNearestAttackableTarget(this, IGolem.class, 20, true, false, golem -> { return ((IGolem) golem).getTeam() != team; })); - this.bS.a(4, new PathfinderGoalNearestAttackableTarget(this, Silverfish.class, 20, true, false, sf -> { + this.bR.a(4, new PathfinderGoalNearestAttackableTarget(this, Silverfish.class, 20, true, false, sf -> { return ((Silverfish) sf).getTeam() != team; })); } @@ -92,7 +92,7 @@ public static LivingEntity spawn(Location loc, ITeam team, double speed, double customEnt.a(GenericAttributes.f).a(damage); if (!CraftEventFactory.doEntityAddEventCalling(mcWorld, customEnt, CreatureSpawnEvent.SpawnReason.CUSTOM)) { - mcWorld.P.a(customEnt); + mcWorld.O.a(customEnt); } ((CraftLivingEntity) customEnt.getBukkitEntity()).setRemoveWhenFarAway(false); ((CraftLivingEntity) customEnt.getBukkitEntity()).setRemoveWhenFarAway(true); diff --git a/versionsupport_v1_18_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R1/v1_18_R1.java b/versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2/v1_18_R2.java similarity index 88% rename from versionsupport_v1_18_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R1/v1_18_R1.java rename to versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2/v1_18_R2.java index 67d3bffd1..8416f3916 100644 --- a/versionsupport_v1_18_R1/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R1/v1_18_R1.java +++ b/versionsupport_v1_18_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_18_R2/v1_18_R2.java @@ -18,7 +18,7 @@ * Contact e-mail: andrew.dascalu@gmail.com */ -package com.andrei1058.bedwars.support.version.v1_18_R1; +package com.andrei1058.bedwars.support.version.v1_18_R2; import com.andrei1058.bedwars.api.arena.IArena; import com.andrei1058.bedwars.api.arena.shop.ShopHolo; @@ -30,70 +30,66 @@ import com.andrei1058.bedwars.api.language.Messages; import com.andrei1058.bedwars.api.server.VersionSupport; import com.andrei1058.bedwars.support.version.common.VersionCommon; -import com.mojang.datafixers.DataFixUtils; -import com.mojang.datafixers.types.Type; import com.mojang.datafixers.util.Pair; import com.mojang.math.Vector3fa; -import net.minecraft.SharedConstants; import net.minecraft.core.particles.ParticleParamRedstone; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.chat.ChatMessageType; import net.minecraft.network.chat.IChatBaseComponent; import net.minecraft.network.protocol.game.*; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; import net.minecraft.server.MinecraftServer; import net.minecraft.server.dedicated.DedicatedServer; import net.minecraft.server.level.EntityPlayer; -import net.minecraft.util.datafix.DataConverterRegistry; -import net.minecraft.util.datafix.fixes.DataConverterTypes; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.EntityTypes; -import net.minecraft.world.entity.EnumCreatureType; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityTNTPrimed; import net.minecraft.world.entity.projectile.EntityFireball; import net.minecraft.world.entity.projectile.IProjectile; -import net.minecraft.world.item.*; import net.minecraft.world.item.Item; +import net.minecraft.world.item.*; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockBase; import org.bukkit.Color; import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Particle; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.block.data.type.Bed; +import org.bukkit.block.data.type.Ladder; import org.bukkit.block.data.type.WallSign; import org.bukkit.command.Command; -import org.bukkit.craftbukkit.v1_18_R1.CraftServer; -import org.bukkit.craftbukkit.v1_18_R1.entity.CraftFireball; -import org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_18_R1.entity.CraftTNTPrimed; -import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_18_R2.CraftServer; +import org.bukkit.craftbukkit.v1_18_R2.entity.CraftFireball; +import org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_18_R2.entity.CraftTNTPrimed; +import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack; import org.bukkit.entity.Entity; import org.bukkit.entity.*; import org.bukkit.event.inventory.InventoryEvent; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.plugin.Plugin; import org.bukkit.potion.PotionEffectType; import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.UUID; import java.util.logging.Level; @SuppressWarnings("unused") -public class v1_18_R1 extends VersionSupport { +public class v1_18_R2 extends VersionSupport { private static final UUID chatUUID = new UUID(0L, 0L); - public v1_18_R1(Plugin plugin, String name) { + public v1_18_R2(Plugin plugin, String name) { super(plugin, name); loadDefaultEffects(); } @@ -111,7 +107,7 @@ public void registerCommand(String name, Command clasa) { @Override public String getTag(org.bukkit.inventory.ItemStack itemStack, String key) { ItemStack i = CraftItemStack.asNMSCopy(itemStack); - NBTTagCompound tag = i.s(); + NBTTagCompound tag = i.t(); return tag == null ? null : tag.e(key) ? tag.l(key) : null; } @@ -175,8 +171,7 @@ public void setSource(TNTPrimed tnt, Player owner) { EntityLiving nmsEntityLiving = (((CraftLivingEntity) owner).getHandle()); EntityTNTPrimed nmsTNT = (((CraftTNTPrimed) tnt).getHandle()); try { - //noinspection JavaReflectionMemberAccess - Field sourceField = EntityTNTPrimed.class.getDeclaredField("source"); + Field sourceField = EntityTNTPrimed.class.getDeclaredField("d"); sourceField.setAccessible(true); sourceField.set(nmsTNT, nmsEntityLiving); } catch (Exception ex) { @@ -221,8 +216,8 @@ public boolean isBow(org.bukkit.inventory.ItemStack itemStack) { @Override public boolean isProjectile(org.bukkit.inventory.ItemStack itemStack) { if (CraftItemStack.asNMSCopy(itemStack) == null) return false; - if (CraftItemStack.asNMSCopy(itemStack).E() == null) return false; - return CraftItemStack.asNMSCopy(itemStack).E() instanceof IProjectile; + if (CraftItemStack.asNMSCopy(itemStack).F() == null) return false; + return CraftItemStack.asNMSCopy(itemStack).F() instanceof IProjectile; } @Override @@ -234,23 +229,12 @@ public boolean isInvisibilityPotion(org.bukkit.inventory.ItemStack itemStack) { return pm != null && pm.hasCustomEffects() && pm.hasCustomEffect(org.bukkit.potion.PotionEffectType.INVISIBILITY); } - @SuppressWarnings({"unchecked"}) @Override public void registerEntities() { - //noinspection deprecation - Map> types = (Map>) DataConverterRegistry.a().getSchema( - DataFixUtils.makeKey(SharedConstants.b().getWorldVersion()) - ).findChoiceType(DataConverterTypes.q).types(); - - types.put("minecraft:bwsilverfish", types.get("minecraft:silverfish")); - EntityTypes.Builder.a(Silverfish::new, EnumCreatureType.a).a("bwsilverfish"); - - types.put("minecraft:bwgolem", types.get("minecraft:iron_golem")); - EntityTypes.Builder.a(IGolem::new, EnumCreatureType.a).a("bwgolem"); } @Override - public void spawnShop(Location loc, String name1, List players, IArena arena) { + public void spawnShop(@NotNull Location loc, String name1, List players, IArena arena) { Location l = loc.clone(); if (l.getWorld() == null) return; @@ -282,7 +266,7 @@ public void spawnShop(Location loc, String name1, List players, IArena a @Override public double getDamage(org.bukkit.inventory.ItemStack i) { ItemStack nmsStack = CraftItemStack.asNMSCopy(i); - NBTTagCompound compound = (nmsStack.s() != null) ? nmsStack.s() : new NBTTagCompound(); + NBTTagCompound compound = (nmsStack.t() != null) ? nmsStack.t() : new NBTTagCompound(); return compound.k("generic.attackDamage"); } @@ -369,10 +353,10 @@ public void colorBed(ITeam bwt) { @Override public void registerTntWhitelist() { try { - Field field = BlockBase.class.getDeclaredField("aI"); + Field field = BlockBase.class.getDeclaredField("aH"); field.setAccessible(true); - field.set(Blocks.eq, 12f); - field.set(Blocks.au, 300f); + field.set(Blocks.eq, 300f); + field.set(Blocks.bQ, 300f); } catch (NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); } @@ -399,7 +383,7 @@ public void setCollide(Player p, IArena a, boolean value) { @Override public org.bukkit.inventory.ItemStack addCustomData(org.bukkit.inventory.ItemStack i, String data) { ItemStack itemStack = CraftItemStack.asNMSCopy(i); - NBTTagCompound tag = itemStack.s(); + NBTTagCompound tag = itemStack.t(); if (tag == null) { tag = new NBTTagCompound(); itemStack.c(tag); @@ -412,7 +396,7 @@ public org.bukkit.inventory.ItemStack addCustomData(org.bukkit.inventory.ItemSta @Override public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, String value) { ItemStack is = CraftItemStack.asNMSCopy(itemStack); - NBTTagCompound tag = is.s(); + NBTTagCompound tag = is.t(); if (tag == null) { tag = new NBTTagCompound(); is.c(tag); @@ -425,7 +409,7 @@ public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack item @Override public boolean isCustomBedWarsItem(org.bukkit.inventory.ItemStack i) { ItemStack itemStack = CraftItemStack.asNMSCopy(i); - NBTTagCompound tag = itemStack.s(); + NBTTagCompound tag = itemStack.t(); if (tag == null) return false; return tag.e("BedWars1058"); } @@ -433,7 +417,7 @@ public boolean isCustomBedWarsItem(org.bukkit.inventory.ItemStack i) { @Override public String getCustomData(org.bukkit.inventory.ItemStack i) { ItemStack itemStack = CraftItemStack.asNMSCopy(i); - NBTTagCompound tag = itemStack.s(); + NBTTagCompound tag = itemStack.t(); if (tag == null) return ""; return tag.l("BedWars1058"); } @@ -527,14 +511,14 @@ public org.bukkit.Material woolMaterial() { @Override public String getShopUpgradeIdentifier(org.bukkit.inventory.ItemStack itemStack) { ItemStack i = CraftItemStack.asNMSCopy(itemStack); - NBTTagCompound tag = i.s(); + NBTTagCompound tag = i.t(); return tag == null ? "null" : tag.e("tierIdentifier") ? tag.l("tierIdentifier") : "null"; } @Override public org.bukkit.inventory.ItemStack setShopUpgradeIdentifier(org.bukkit.inventory.ItemStack itemStack, String identifier) { ItemStack i = CraftItemStack.asNMSCopy(itemStack); - NBTTagCompound tag = i.s(); + NBTTagCompound tag = i.t(); if (tag == null) { tag = new NBTTagCompound(); i.c(tag); @@ -549,25 +533,14 @@ public org.bukkit.inventory.ItemStack getPlayerHead(Player player, org.bukkit.in if (copyTagFrom != null) { ItemStack i = CraftItemStack.asNMSCopy(head); - i.c(CraftItemStack.asNMSCopy(copyTagFrom).s()); + i.c(CraftItemStack.asNMSCopy(copyTagFrom).t()); head = CraftItemStack.asBukkitCopy(i); } -// SkullMeta headMeta = (SkullMeta) head.getItemMeta(); -// FIXME: current hotfix will get rate limited! how the hell do we set head texture now? -// wtf is this: SkullOwner:{Id:[I;-1344581477,-1919271229,-1306015584,-647763423],Name:"andrei1058"} -// Field profileField; -// try { -// //noinspection ConstantConditions -// profileField = headMeta.getClass().getDeclaredField("profile"); -// profileField.setAccessible(true); -// profileField.set(headMeta, ((CraftPlayer) player).getProfile()); -// } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) { -// e1.printStackTrace(); -// } -// assert headMeta != null; -// headMeta.setOwningPlayer(player); -// head.setItemMeta(headMeta); + ItemMeta meta = head.getItemMeta(); + if (meta instanceof SkullMeta) { + ((SkullMeta) meta).setOwnerProfile(player.getPlayerProfile()); + } return head; } @@ -659,7 +632,7 @@ public void setUnbreakable(ItemMeta itemMeta) { @Override public String getMainLevel() { //noinspection deprecation - return ((DedicatedServer) MinecraftServer.getServer()).z.a().p; + return ((DedicatedServer) MinecraftServer.getServer()).y.a().p; } @Override @@ -706,6 +679,42 @@ public void playRedStoneDot(Player player) { @Override public void clearArrowsFromPlayerBody(Player player) { - ((CraftLivingEntity)player).getHandle().ai().b(new DataWatcherObject<>(12, DataWatcherRegistry.b),-1); + } + + @Override + public void placeTowerBlocks(@NotNull Block b, @NotNull IArena a, @NotNull TeamColor color, int x, int y, int z){ + b.getRelative(x, y, z).setType(color.woolMaterial()); + a.addPlacedBlock(b.getRelative(x, y, z)); + } + + @Override + public void placeLadder(@NotNull Block b, int x, int y, int z, @NotNull IArena a, int ladderData){ + Block block = b.getRelative(x,y,z); //ladder block + block.setType(Material.LADDER); + Ladder ladder = (Ladder) block.getBlockData(); + a.addPlacedBlock(block); + switch (ladderData) { + case 2 -> { + ladder.setFacing(BlockFace.NORTH); + block.setBlockData(ladder); + } + case 3 -> { + ladder.setFacing(BlockFace.SOUTH); + block.setBlockData(ladder); + } + case 4 -> { + ladder.setFacing(BlockFace.WEST); + block.setBlockData(ladder); + } + case 5 -> { + ladder.setFacing(BlockFace.EAST); + block.setBlockData(ladder); + } + } + } + + @Override + public void playVillagerEffect(@NotNull Player player, Location location){ + player.spawnParticle(Particle.VILLAGER_HAPPY, location, 1); } } diff --git a/versionsupport_v1_19_R2/pom.xml b/versionsupport_v1_19_R2/pom.xml new file mode 100644 index 000000000..36d4bf5e1 --- /dev/null +++ b/versionsupport_v1_19_R2/pom.xml @@ -0,0 +1,64 @@ + + + 4.0.0 + + com.andrei1058.bedwars + BedWars1058 + 22.9-SNAPSHOT + + + versionsupport_v1_19_R2 + + + 1.19 + 1.19 + UTF-8 + + + + + com.andrei1058.bedwars + bedwars-api + ${project.version} + jar + provided + + + com.andrei1058.bedwars + versionsupport-common + ${project.version} + jar + provided + + + org.spigotmc + spigot + 1.19.3-R0.1-SNAPSHOT + jar + provided + + + + + + + maven-deploy-plugin + + true + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.10.1 + + 17 + 17 + + + + + + \ No newline at end of file diff --git a/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableAttributes.java b/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableAttributes.java new file mode 100644 index 000000000..f31b7932f --- /dev/null +++ b/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableAttributes.java @@ -0,0 +1,5 @@ +package com.andrei1058.bedwars.support.version.v1_19_R2.despawnable; + +public record DespawnableAttributes(DespawnableType type, double speed, double health, double damage, int despawnSeconds) { + +} diff --git a/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableFactory.java b/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableFactory.java new file mode 100644 index 000000000..2b1e9495c --- /dev/null +++ b/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableFactory.java @@ -0,0 +1,27 @@ +package com.andrei1058.bedwars.support.version.v1_19_R2.despawnable; + +import com.andrei1058.bedwars.api.arena.team.ITeam; +import com.andrei1058.bedwars.api.server.VersionSupport; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +public class DespawnableFactory { + + private final VersionSupport versionSupport; + private final List> providers = new ArrayList<>(); + + public DespawnableFactory(VersionSupport versionSupport) { + this.versionSupport = versionSupport; + providers.add(new TeamIronGolem()); + providers.add(new TeamSilverfish()); + } + + public LivingEntity spawn(@NotNull DespawnableAttributes attr, @NotNull Location location, @NotNull ITeam team){ + return providers.stream().filter(provider -> provider.getType() == attr.type()) + .findFirst().orElseThrow().spawn(attr, location,team, versionSupport); + } +} diff --git a/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableProvider.java b/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableProvider.java new file mode 100644 index 000000000..831d5cca3 --- /dev/null +++ b/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableProvider.java @@ -0,0 +1,71 @@ +package com.andrei1058.bedwars.support.version.v1_19_R2.despawnable; + +import com.andrei1058.bedwars.api.arena.team.ITeam; +import com.andrei1058.bedwars.api.server.VersionSupport; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityCreature; +import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.entity.EntityLiving; +import net.minecraft.world.entity.ai.attributes.GenericAttributes; +import net.minecraft.world.entity.ai.goal.PathfinderGoal; +import net.minecraft.world.entity.ai.goal.PathfinderGoalSelector; +import net.minecraft.world.entity.ai.goal.target.PathfinderGoalNearestAttackableTarget; +import net.minecraft.world.entity.player.EntityHuman; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftEntity; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; + +public abstract class DespawnableProvider { + + abstract DespawnableType getType(); + + abstract String getDisplayName(DespawnableAttributes attr, ITeam team); + + abstract T spawn(@NotNull DespawnableAttributes attr, @NotNull Location location, @NotNull ITeam team, VersionSupport api); + + protected boolean notSameTeam(@NotNull Entity entity, ITeam team, @NotNull VersionSupport api) { + var despawnable = api.getDespawnablesList().getOrDefault(entity.getBukkitEntity().getUniqueId(), null); + return null == despawnable || despawnable.getTeam() != team; + } + + protected PathfinderGoalSelector getTargetSelector(@NotNull EntityCreature entityLiving) { + return entityLiving.bT; + } + + protected PathfinderGoalSelector getGoalSelector(@NotNull EntityCreature entityLiving) { + return entityLiving.bS; + } + + protected void clearSelectors(@NotNull EntityCreature entityLiving) { + entityLiving.bS.b().clear(); + entityLiving.bT.b().clear(); + } + + protected PathfinderGoal getTargetGoal(EntityInsentient entity, ITeam team, VersionSupport api) { + return new PathfinderGoalNearestAttackableTarget<>(entity, EntityLiving.class, 20, true, false, + entityLiving -> { + if (entityLiving instanceof EntityHuman) { + return !((EntityHuman) entityLiving).getBukkitEntity().isDead() && + !team.wasMember(((EntityHuman) entityLiving).getBukkitEntity().getUniqueId()) && + !team.getArena().isReSpawning(((EntityHuman) entityLiving).getBukkitEntity().getUniqueId()) + && !team.getArena().isSpectator(((EntityHuman) entityLiving).getBukkitEntity().getUniqueId()); + } + return notSameTeam(entityLiving, team, api); + }); + } + + protected void applyDefaultSettings(org.bukkit.entity.@NotNull LivingEntity bukkitEntity, DespawnableAttributes attr, + ITeam team) { + bukkitEntity.setRemoveWhenFarAway(false); + bukkitEntity.setPersistent(true); + bukkitEntity.setCustomNameVisible(true); + bukkitEntity.setCustomName(getDisplayName(attr, team)); + + var entity = ((EntityInsentient)((CraftEntity)bukkitEntity).getHandle()); + Objects.requireNonNull(entity.a(GenericAttributes.a)).a(attr.health()); + Objects.requireNonNull(entity.a(GenericAttributes.d)).a(attr.speed()); + Objects.requireNonNull(entity.a(GenericAttributes.f)).a(attr.damage()); + } +} diff --git a/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableType.java b/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableType.java new file mode 100644 index 000000000..d571b6eb6 --- /dev/null +++ b/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/DespawnableType.java @@ -0,0 +1,6 @@ +package com.andrei1058.bedwars.support.version.v1_19_R2.despawnable; + +public enum DespawnableType { + IRON_GOLEM, + SILVERFISH +} diff --git a/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/TeamIronGolem.java b/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/TeamIronGolem.java new file mode 100644 index 000000000..6c04805b0 --- /dev/null +++ b/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/TeamIronGolem.java @@ -0,0 +1,58 @@ +package com.andrei1058.bedwars.support.version.v1_19_R2.despawnable; + +import com.andrei1058.bedwars.api.arena.team.ITeam; +import com.andrei1058.bedwars.api.language.Language; +import com.andrei1058.bedwars.api.language.Messages; +import com.andrei1058.bedwars.api.server.VersionSupport; +import net.minecraft.world.entity.ai.goal.PathfinderGoalFloat; +import net.minecraft.world.entity.ai.goal.PathfinderGoalMeleeAttack; +import net.minecraft.world.entity.ai.goal.PathfinderGoalRandomLookaround; +import net.minecraft.world.entity.ai.goal.PathfinderGoalRandomStroll; +import net.minecraft.world.entity.ai.goal.target.PathfinderGoalHurtByTarget; +import net.minecraft.world.entity.animal.EntityIronGolem; +import org.apache.commons.lang.StringUtils; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftEntity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.IronGolem; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; + +public class TeamIronGolem extends DespawnableProvider { + + @Override + public DespawnableType getType() { + return DespawnableType.IRON_GOLEM; + } + + @Override + String getDisplayName(@NotNull DespawnableAttributes attr, @NotNull ITeam team) { + Language lang = Language.getDefaultLanguage(); + return lang.m(Messages.SHOP_UTILITY_NPC_IRON_GOLEM_NAME).replace("{despawn}", String.valueOf(attr.despawnSeconds()) + .replace("{health}", StringUtils.repeat(lang.m(Messages.FORMATTING_DESPAWNABLE_UTILITY_NPC_HEALTH) + " ", 10)) + .replace("{TeamColor}", team.getColor().chat().toString()) + ); + } + + public @NotNull IronGolem spawn(@NotNull DespawnableAttributes attr, @NotNull Location location, @NotNull ITeam team, VersionSupport api) { + + var bukkitEntity = (IronGolem) Objects.requireNonNull(location.getWorld()).spawnEntity(location, EntityType.IRON_GOLEM); + applyDefaultSettings(bukkitEntity, attr, team); + + var entity = (EntityIronGolem) ((CraftEntity) bukkitEntity).getHandle(); + + clearSelectors(entity); + var goalSelector = getGoalSelector(entity); + var targetSelector = getTargetSelector(entity); + + goalSelector.a(1, new PathfinderGoalFloat(entity)); + goalSelector.a(2, new PathfinderGoalMeleeAttack(entity, 1.5D, false)); + goalSelector.a(3, new PathfinderGoalRandomStroll(entity, 1D)); + goalSelector.a(4, new PathfinderGoalRandomLookaround(entity)); + targetSelector.a(1, new PathfinderGoalHurtByTarget(entity)); + targetSelector.a(2, getTargetGoal(entity, team, api)); + + return bukkitEntity; + } +} diff --git a/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/TeamSilverfish.java b/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/TeamSilverfish.java new file mode 100644 index 000000000..f0b017097 --- /dev/null +++ b/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/despawnable/TeamSilverfish.java @@ -0,0 +1,56 @@ +package com.andrei1058.bedwars.support.version.v1_19_R2.despawnable; + +import com.andrei1058.bedwars.api.arena.team.ITeam; +import com.andrei1058.bedwars.api.language.Language; +import com.andrei1058.bedwars.api.language.Messages; +import com.andrei1058.bedwars.api.server.VersionSupport; +import net.minecraft.world.entity.ai.goal.PathfinderGoalFloat; +import net.minecraft.world.entity.ai.goal.PathfinderGoalMeleeAttack; +import net.minecraft.world.entity.ai.goal.PathfinderGoalRandomLookaround; +import net.minecraft.world.entity.ai.goal.PathfinderGoalRandomStroll; +import net.minecraft.world.entity.ai.goal.target.PathfinderGoalHurtByTarget; +import net.minecraft.world.entity.monster.EntitySilverfish; +import org.apache.commons.lang.StringUtils; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftEntity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Silverfish; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; + +public class TeamSilverfish extends DespawnableProvider { + @Override + public DespawnableType getType() { + return DespawnableType.SILVERFISH; + } + + @Override + String getDisplayName(@NotNull DespawnableAttributes attr, @NotNull ITeam team) { + Language lang = Language.getDefaultLanguage(); + return lang.m(Messages.SHOP_UTILITY_NPC_SILVERFISH_NAME).replace("{despawn}", String.valueOf(attr.despawnSeconds()) + .replace("{health}", StringUtils.repeat(lang.m(Messages.FORMATTING_DESPAWNABLE_UTILITY_NPC_HEALTH) + " ", 10)) + .replace("{TeamColor}", team.getColor().chat().toString()) + ); + } + + @Override + public Silverfish spawn(@NotNull DespawnableAttributes attr, @NotNull Location location, @NotNull ITeam team, VersionSupport api) { + var bukkitEntity = (Silverfish) Objects.requireNonNull(location.getWorld()).spawnEntity(location, EntityType.SILVERFISH); + applyDefaultSettings(bukkitEntity, attr, team); + + var entity = (EntitySilverfish) ((CraftEntity) bukkitEntity).getHandle(); + clearSelectors(entity); + + var goalSelector = getGoalSelector(entity); + var targetSelector = getTargetSelector(entity); + goalSelector.a(1, new PathfinderGoalFloat(entity)); + goalSelector.a(2, new PathfinderGoalMeleeAttack(entity, 1.9D, false)); + goalSelector.a(3, new PathfinderGoalRandomStroll(entity, 2D)); + goalSelector.a(4, new PathfinderGoalRandomLookaround(entity)); + targetSelector.a(1, new PathfinderGoalHurtByTarget(entity)); + targetSelector.a(2, getTargetGoal(entity, team, api)); + + return bukkitEntity; + } +} diff --git a/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/v1_19_R2.java b/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/v1_19_R2.java new file mode 100644 index 000000000..3fe3d48e3 --- /dev/null +++ b/versionsupport_v1_19_R2/src/main/java/com/andrei1058/bedwars/support/version/v1_19_R2/v1_19_R2.java @@ -0,0 +1,830 @@ +package com.andrei1058.bedwars.support.version.v1_19_R2; + +import com.andrei1058.bedwars.api.arena.IArena; +import com.andrei1058.bedwars.api.arena.shop.ShopHolo; +import com.andrei1058.bedwars.api.arena.team.ITeam; +import com.andrei1058.bedwars.api.arena.team.TeamColor; +import com.andrei1058.bedwars.api.entity.Despawnable; +import com.andrei1058.bedwars.api.events.player.PlayerKillEvent; +import com.andrei1058.bedwars.api.language.Language; +import com.andrei1058.bedwars.api.language.Messages; +import com.andrei1058.bedwars.api.server.VersionSupport; +import com.andrei1058.bedwars.support.version.common.VersionCommon; +import com.andrei1058.bedwars.support.version.v1_19_R2.despawnable.DespawnableAttributes; +import com.andrei1058.bedwars.support.version.v1_19_R2.despawnable.DespawnableFactory; +import com.andrei1058.bedwars.support.version.v1_19_R2.despawnable.DespawnableType; +import com.mojang.datafixers.util.Pair; +import net.md_5.bungee.api.ChatMessageType; +import net.md_5.bungee.api.chat.TextComponent; +import net.minecraft.core.particles.ParticleParamRedstone; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.protocol.game.*; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.server.level.EntityPlayer; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.EntityLiving; +import net.minecraft.world.entity.EnumItemSlot; +import net.minecraft.world.entity.item.EntityTNTPrimed; +import net.minecraft.world.entity.projectile.EntityFireball; +import net.minecraft.world.entity.projectile.IProjectile; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.*; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockBase; +import org.bukkit.*; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; +import org.bukkit.block.data.type.Bed; +import org.bukkit.block.data.type.Ladder; +import org.bukkit.block.data.type.WallSign; +import org.bukkit.command.Command; +import org.bukkit.craftbukkit.v1_19_R2.CraftServer; +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftFireball; +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftTNTPrimed; +import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack; +import org.bukkit.entity.*; +import org.bukkit.event.inventory.InventoryEvent; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.plugin.Plugin; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scoreboard.Team; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.joml.Vector3f; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.logging.Level; + +@SuppressWarnings("unused") +public class v1_19_R2 extends VersionSupport { + + private final DespawnableFactory despawnableFactory; + + public v1_19_R2(Plugin plugin, String name) { + super(plugin, name); + loadDefaultEffects(); + this.despawnableFactory = new DespawnableFactory(this); + } + + @Override + public void registerVersionListeners() { + new VersionCommon(this); + } + + @Override + public void registerCommand(String name, Command cmd) { + ((CraftServer) getPlugin().getServer()).getCommandMap().register(name, cmd); + } + + @Override + public String getTag(org.bukkit.inventory.ItemStack itemStack, String key) { + var tag = getTag(itemStack); + return tag == null ? null : tag.e(key) ? tag.l(key) : null; + } + + @Override + public void sendTitle(@NotNull Player p, String title, String subtitle, int fadeIn, int stay, int fadeOut) { + p.sendTitle(title == null ? " " : title, subtitle == null ? " " : subtitle, fadeIn, stay, fadeOut); + } + + public void spawnSilverfish(Location loc, ITeam bedWarsTeam, double speed, double health, int despawn, double damage) { + var attr = new DespawnableAttributes(DespawnableType.SILVERFISH, speed, health, damage, despawn); + var entity = despawnableFactory.spawn(attr, loc, bedWarsTeam); + + new Despawnable( + entity, + bedWarsTeam, despawn, + Messages.SHOP_UTILITY_NPC_SILVERFISH_NAME, + PlayerKillEvent.PlayerKillCause.SILVERFISH_FINAL_KILL, + PlayerKillEvent.PlayerKillCause.SILVERFISH + ); + } + + @Override + public void spawnIronGolem(Location loc, ITeam bedWarsTeam, double speed, double health, int despawn) { + var attr = new DespawnableAttributes(DespawnableType.IRON_GOLEM, speed, health,4, despawn); + var entity = despawnableFactory.spawn(attr, loc, bedWarsTeam); + new Despawnable( + entity, + bedWarsTeam, despawn, + Messages.SHOP_UTILITY_NPC_IRON_GOLEM_NAME, + PlayerKillEvent.PlayerKillCause.IRON_GOLEM_FINAL_KILL, + PlayerKillEvent.PlayerKillCause.IRON_GOLEM + ); + } + + @Override + public void playAction(@NotNull Player p, String text) { + p.spigot().sendMessage( + ChatMessageType.ACTION_BAR, + new TextComponent(ChatColor.translateAlternateColorCodes('&', text) + ) + ); + } + + @Override + public boolean isBukkitCommandRegistered(String name) { + return ((CraftServer) getPlugin().getServer()).getCommandMap().getCommand(name) != null; + } + + @Override + public org.bukkit.inventory.ItemStack getItemInHand(@NotNull Player p) { + return p.getInventory().getItemInMainHand(); + } + + @Override + public void hideEntity(@NotNull Entity e, Player p) { + PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(e.getEntityId()); + ((CraftPlayer) p).getHandle().b.a(packet); + + } + + @Override + public void minusAmount(Player p, org.bukkit.inventory.@NotNull ItemStack i, int amount) { + if (i.getAmount() - amount <= 0) { + if (p.getInventory().getItemInOffHand().equals(i)) { + p.getInventory().setItemInOffHand(null); + } else { + p.getInventory().removeItem(i); + } + return; + } + i.setAmount(i.getAmount() - amount); + p.updateInventory(); + } + + @Override + public void setSource(TNTPrimed tnt, Player owner) { + EntityLiving nmsEntityLiving = (((CraftLivingEntity) owner).getHandle()); + EntityTNTPrimed nmsTNT = (((CraftTNTPrimed) tnt).getHandle()); + try { + Field sourceField = EntityTNTPrimed.class.getDeclaredField("d"); + sourceField.setAccessible(true); + sourceField.set(nmsTNT, nmsEntityLiving); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @Override + public boolean isArmor(org.bukkit.inventory.ItemStack itemStack) { + var i = getItem(itemStack); + if (null == i) return false; + return i instanceof ItemArmor; + } + + @Override + public boolean isTool(org.bukkit.inventory.ItemStack itemStack) { + var i = getItem(itemStack); + if (null == i) return false; + return i instanceof ItemTool; + } + + @Override + public boolean isSword(org.bukkit.inventory.ItemStack itemStack) { + var i = getItem(itemStack); + if (null == i) return false; + return i instanceof ItemSword; + } + + @Override + public boolean isAxe(org.bukkit.inventory.ItemStack itemStack) { + var i = getItem(itemStack); + if (null == i) return false; + return i instanceof ItemAxe; + } + + @Override + public boolean isBow(org.bukkit.inventory.ItemStack itemStack) { + var i = getItem(itemStack); + if (null == i) return false; + return i instanceof ItemBow; + } + + @Override + public boolean isProjectile(org.bukkit.inventory.ItemStack itemStack) { + var entity = getEntity(itemStack); + if (null == entity) return false; + return entity instanceof IProjectile; + } + + @Override + public boolean isInvisibilityPotion(org.bukkit.inventory.@NotNull ItemStack itemStack) { + if (!itemStack.getType().equals(org.bukkit.Material.POTION)) return false; + + org.bukkit.inventory.meta.PotionMeta pm = (org.bukkit.inventory.meta.PotionMeta) itemStack.getItemMeta(); + + return pm != null && pm.hasCustomEffects() && pm.hasCustomEffect(org.bukkit.potion.PotionEffectType.INVISIBILITY); + } + + @Override + public void registerEntities() { + } + + @Override + public void spawnShop(@NotNull Location loc, String name1, List players, IArena arena) { + Location l = loc.clone(); + + if (l.getWorld() == null) return; + Villager vlg = (Villager) l.getWorld().spawnEntity(loc, EntityType.VILLAGER); + vlg.setAI(false); + vlg.setRemoveWhenFarAway(false); + vlg.setCollidable(false); + vlg.setInvulnerable(true); + vlg.setSilent(true); + + for (Player p : players) { + String[] name = Language.getMsg(p, name1).split(","); + if (name.length == 1) { + ArmorStand a = createArmorStand(name[0], l.clone().add(0, 1.85, 0)); + new ShopHolo(Language.getPlayerLanguage(p).getIso(), a, null, l, arena); + } else { + ArmorStand a = createArmorStand(name[0], l.clone().add(0, 2.1, 0)); + ArmorStand b = createArmorStand(name[1], l.clone().add(0, 1.85, 0)); + new ShopHolo(Language.getPlayerLanguage(p).getIso(), a, b, l, arena); + } + } + for (ShopHolo sh : ShopHolo.getShopHolo()) { + if (sh.getA() == arena) { + sh.update(); + } + } + } + + @Override + public double getDamage(org.bukkit.inventory.ItemStack i) { + var tag = getTag(i); + if (null == tag) { + throw new RuntimeException("Provided item has no Tag"); + } + return tag.k("generic.attackDamage"); + } + + private static ArmorStand createArmorStand(String name, Location loc) { + if (loc == null) return null; + if (loc.getWorld() == null) return null; + ArmorStand a = loc.getWorld().spawn(loc, ArmorStand.class); + a.setGravity(false); + a.setVisible(false); + a.setCustomNameVisible(true); + a.setCustomName(name); + return a; + } + + @Override + public void voidKill(Player p) { + getPlayer(p).a(DamageSource.m, 1000); + } + + @Override + public void hideArmor(@NotNull Player victim, Player receiver) { + List> items = new ArrayList<>(); + List> hands = new ArrayList<>(); + hands.add(new Pair<>(EnumItemSlot.a, new ItemStack(Item.b(0)))); + hands.add(new Pair<>(EnumItemSlot.b, new ItemStack(Item.b(0)))); + + items.add(new Pair<>(EnumItemSlot.f, new ItemStack(Item.b(0)))); + items.add(new Pair<>(EnumItemSlot.e, new ItemStack(Item.b(0)))); + items.add(new Pair<>(EnumItemSlot.d, new ItemStack(Item.b(0)))); + items.add(new Pair<>(EnumItemSlot.c, new ItemStack(Item.b(0)))); + PacketPlayOutEntityEquipment packet1 = new PacketPlayOutEntityEquipment(victim.getEntityId(), items); + PacketPlayOutEntityEquipment packet2 = new PacketPlayOutEntityEquipment(victim.getEntityId(), hands); + EntityPlayer pc = getPlayer(receiver); + if (victim != receiver) { + pc.b.a(packet2); + } + pc.b.a(packet1); + } + + @Override + public void showArmor(@NotNull Player victim, Player receiver) { + List> items = new ArrayList<>(); + List> hands = new ArrayList<>(); + + hands.add(new Pair<>(EnumItemSlot.a, CraftItemStack.asNMSCopy(victim.getInventory().getItemInMainHand()))); + hands.add(new Pair<>(EnumItemSlot.b, CraftItemStack.asNMSCopy(victim.getInventory().getItemInOffHand()))); + + items.add(new Pair<>(EnumItemSlot.f, CraftItemStack.asNMSCopy(victim.getInventory().getHelmet()))); + items.add(new Pair<>(EnumItemSlot.e, CraftItemStack.asNMSCopy(victim.getInventory().getChestplate()))); + items.add(new Pair<>(EnumItemSlot.d, CraftItemStack.asNMSCopy(victim.getInventory().getLeggings()))); + items.add(new Pair<>(EnumItemSlot.c, CraftItemStack.asNMSCopy(victim.getInventory().getBoots()))); + PacketPlayOutEntityEquipment packet1 = new PacketPlayOutEntityEquipment(victim.getEntityId(), items); + PacketPlayOutEntityEquipment packet2 = new PacketPlayOutEntityEquipment(victim.getEntityId(), hands); + EntityPlayer pc = getPlayer(receiver); + if (victim != receiver) { + pc.b.a(packet2); + } + pc.b.a(packet1); + } + + @Override + public void spawnDragon(Location l, ITeam bwt) { + if (l == null || l.getWorld() == null) { + getPlugin().getLogger().log(Level.WARNING, "Could not spawn Dragon. Location is null"); + return; + } + EnderDragon ed = (EnderDragon) l.getWorld().spawnEntity(l, EntityType.ENDER_DRAGON); + ed.setPhase(EnderDragon.Phase.CIRCLING); + } + + @Override + public void colorBed(ITeam bwt) { + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + BlockState bed = bwt.getBed().clone().add(x, 0, z).getBlock().getState(); + if (bed instanceof Bed) { + bed.setType(bwt.getColor().bedMaterial()); + bed.update(); + } + } + } + } + + @Override + public void registerTntWhitelist() { + try { + var protection = 300f; + // blast resistance + Field field = BlockBase.class.getDeclaredField("aH"); + field.setAccessible(true); + // end stone + field.set(Blocks.fj, protection); + // obsidian + field.set(Blocks.ce, protection); + // standard glass + field.set(Blocks.aH, protection); + + var coloredGlass = new net.minecraft.world.level.block.Block[]{ + Blocks.dU, Blocks.dV, Blocks.dW, Blocks.dX, + Blocks.dY, Blocks.dZ, Blocks.dZ, Blocks.ea, + Blocks.eb, Blocks.ec, Blocks.ed, Blocks.ee, + Blocks.ef, Blocks.eg, Blocks.eh, Blocks.ei, + Blocks.ej, + }; + + Arrays.stream(coloredGlass).forEach( + glass -> { + try { + field.set(glass, protection); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + ); + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + } + + @Override + public void setBlockTeamColor(@NotNull Block block, TeamColor teamColor) { + if (block.getType().toString().contains("STAINED_GLASS") || block.getType().toString().equals("GLASS")) { + block.setType(teamColor.glassMaterial()); + } else if (block.getType().toString().contains("_TERRACOTTA")) { + block.setType(teamColor.glazedTerracottaMaterial()); + } else if (block.getType().toString().contains("_WOOL")) { + block.setType(teamColor.woolMaterial()); + } + } + + @Override + public void setCollide(@NotNull Player p, IArena a, boolean value) { + p.setCollidable(value); + if (a == null) return; + a.updateSpectatorCollideRule(p, value); + } + + @Override + public org.bukkit.inventory.ItemStack addCustomData(org.bukkit.inventory.ItemStack i, String data) { + var tag = getCreateTag(i); + tag.a(VersionSupport.PLUGIN_TAG_GENERIC_KEY, data); + return applyTag(i, tag); + } + + @Override + public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, String value) { + var tag = getCreateTag(itemStack); + tag.a(key, value); + return applyTag(itemStack, tag); + } + + @Override + public boolean isCustomBedWarsItem(org.bukkit.inventory.ItemStack i) { + return getCreateTag(i).e(VersionSupport.PLUGIN_TAG_GENERIC_KEY); + } + + @Override + public String getCustomData(org.bukkit.inventory.ItemStack i) { + return getCreateTag(i).l(VersionSupport.PLUGIN_TAG_GENERIC_KEY); + } + + @Override + public org.bukkit.inventory.ItemStack colourItem(org.bukkit.inventory.ItemStack itemStack, ITeam bedWarsTeam) { + if (itemStack == null) return null; + String type = itemStack.getType().toString(); + if (isBed(itemStack.getType())) { + return new org.bukkit.inventory.ItemStack(bedWarsTeam.getColor().bedMaterial(), itemStack.getAmount()); + } else if (type.contains("_STAINED_GLASS_PANE")) { + return new org.bukkit.inventory.ItemStack(bedWarsTeam.getColor().glassPaneMaterial(), itemStack.getAmount()); + } else if (type.contains("STAINED_GLASS") || type.equals("GLASS")) { + return new org.bukkit.inventory.ItemStack(bedWarsTeam.getColor().glassMaterial(), itemStack.getAmount()); + } else if (type.contains("_TERRACOTTA")) { + return new org.bukkit.inventory.ItemStack(bedWarsTeam.getColor().glazedTerracottaMaterial(), itemStack.getAmount()); + } else if (type.contains("_WOOL")) { + return new org.bukkit.inventory.ItemStack(bedWarsTeam.getColor().woolMaterial(), itemStack.getAmount()); + } + return itemStack; + } + + @Override + public org.bukkit.inventory.ItemStack createItemStack(String material, int amount, short data) { + org.bukkit.inventory.ItemStack i; + try { + i = new org.bukkit.inventory.ItemStack(org.bukkit.Material.valueOf(material), amount); + } catch (Exception ex) { + getPlugin().getLogger().log(Level.WARNING, material + " is not a valid " + getName() + " material!"); + i = new org.bukkit.inventory.ItemStack(org.bukkit.Material.BEDROCK); + } + return i; + } + + @Override + public void teamCollideRule(@NotNull Team team) { + team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER); + team.setCanSeeFriendlyInvisibles(true); + } + + @Override + public org.bukkit.Material materialFireball() { + return org.bukkit.Material.FIRE_CHARGE; + } + + @Override + public org.bukkit.Material materialPlayerHead() { + return org.bukkit.Material.PLAYER_HEAD; + } + + @Override + public org.bukkit.Material materialSnowball() { + return org.bukkit.Material.SNOWBALL; + } + + @Override + public org.bukkit.Material materialGoldenHelmet() { + return org.bukkit.Material.GOLDEN_HELMET; + } + + @Override + public org.bukkit.Material materialGoldenChestPlate() { + return org.bukkit.Material.GOLDEN_CHESTPLATE; + } + + @Override + public org.bukkit.Material materialGoldenLeggings() { + return org.bukkit.Material.GOLDEN_LEGGINGS; + } + + @Override + public org.bukkit.Material materialCake() { + return org.bukkit.Material.CAKE; + } + + @Override + public org.bukkit.Material materialCraftingTable() { + return org.bukkit.Material.CRAFTING_TABLE; + } + + @Override + public org.bukkit.Material materialEnchantingTable() { + return org.bukkit.Material.ENCHANTING_TABLE; + } + + @Override + public org.bukkit.Material woolMaterial() { + return org.bukkit.Material.WHITE_WOOL; + } + + @Override + public String getShopUpgradeIdentifier(org.bukkit.inventory.ItemStack itemStack) { + var tag = getCreateTag(itemStack); + return tag.e(VersionSupport.PLUGIN_TAG_TIER_KEY) ? tag.l(VersionSupport.PLUGIN_TAG_TIER_KEY) : "null"; + } + + @Override + public org.bukkit.inventory.ItemStack setShopUpgradeIdentifier(org.bukkit.inventory.ItemStack itemStack, String identifier) { + var tag = getCreateTag(itemStack); + tag.a(VersionSupport.PLUGIN_TAG_TIER_KEY, identifier); + return applyTag(itemStack, tag); + } + + @Override + public org.bukkit.inventory.ItemStack getPlayerHead(Player player, org.bukkit.inventory.ItemStack copyTagFrom) { + org.bukkit.inventory.ItemStack head = new org.bukkit.inventory.ItemStack(materialPlayerHead()); + + if (copyTagFrom != null) { + var tag = getTag(copyTagFrom); + return applyTag(head, tag); + } + + var meta = head.getItemMeta(); + if (meta instanceof SkullMeta) { + ((SkullMeta) meta).setOwnerProfile(player.getPlayerProfile()); + } + + return head; + } + + @Override + public void sendPlayerSpawnPackets(Player respawned, IArena arena) { + if (respawned == null) return; + if (arena == null) return; + if (!arena.isPlayer(respawned)) return; + + // if method was used when the player was still in re-spawning screen + if (arena.getRespawnSessions().containsKey(respawned)) return; + + EntityPlayer entityPlayer = getPlayer(respawned); + PacketPlayOutNamedEntitySpawn show = new PacketPlayOutNamedEntitySpawn(entityPlayer); + PacketPlayOutEntityVelocity playerVelocity = new PacketPlayOutEntityVelocity(entityPlayer); + // we send head rotation packet because sometimes on respawn others see him with bad rotation + PacketPlayOutEntityHeadRotation head = new PacketPlayOutEntityHeadRotation(entityPlayer, getCompressedAngle(entityPlayer.getBukkitYaw())); + + // retrieve current armor and in-hand items + // we send a packet later for timing issues where other players do not see them + List> list = getPlayerEquipment(entityPlayer); + + + for (Player p : arena.getPlayers()) { + if (p == null) continue; + if (p.equals(respawned)) continue; + // if p is in re-spawning screen continue + if (arena.getRespawnSessions().containsKey(p)) continue; + + EntityPlayer boundTo = getPlayer(p); + if (p.getWorld().equals(respawned.getWorld())) { + if (respawned.getLocation().distance(p.getLocation()) <= arena.getRenderDistance()) { + + // send respawned player to regular players + boundTo.b.a(show); + boundTo.b.a(head); + boundTo.b.a(playerVelocity); + boundTo.b.a(new PacketPlayOutEntityEquipment(respawned.getEntityId(), list)); + + // send nearby players to respawned player + // if the player has invisibility hide armor + if (p.hasPotionEffect(PotionEffectType.INVISIBILITY)) { + hideArmor(p, respawned); + } else { + PacketPlayOutNamedEntitySpawn show2 = new PacketPlayOutNamedEntitySpawn(boundTo); + PacketPlayOutEntityVelocity playerVelocity2 = new PacketPlayOutEntityVelocity(boundTo); + PacketPlayOutEntityHeadRotation head2 = new PacketPlayOutEntityHeadRotation(boundTo, getCompressedAngle(boundTo.getBukkitYaw())); + entityPlayer.b.a(show2); + entityPlayer.b.a(playerVelocity2); + entityPlayer.b.a(head2); + showArmor(p, respawned); + } + } + } + } + + for (Player spectator : arena.getSpectators()) { + if (spectator == null) continue; + if (spectator.equals(respawned)) continue; + EntityPlayer boundTo = ((CraftPlayer) spectator).getHandle(); + respawned.hidePlayer(getPlugin(), spectator); + if (spectator.getWorld().equals(respawned.getWorld())) { + if (respawned.getLocation().distance(spectator.getLocation()) <= arena.getRenderDistance()) { + + // send respawned player to spectator + boundTo.b.a(show); + boundTo.b.a(playerVelocity); + boundTo.b.a(new PacketPlayOutEntityEquipment(respawned.getEntityId(), list)); + boundTo.b.a(new PacketPlayOutEntityHeadRotation(entityPlayer, getCompressedAngle(entityPlayer.getBukkitYaw()))); + } + } + } + } + + @Override + public String getInventoryName(@NotNull InventoryEvent e) { + return e.getView().getTitle(); + } + + @Override + public void setUnbreakable(@NotNull ItemMeta itemMeta) { + itemMeta.setUnbreakable(true); + } + + @Override + public String getMainLevel() { + //noinspection deprecation + return ((DedicatedServer) MinecraftServer.getServer()).a().m; + } + + @Override + public int getVersion() { + return 9; + } + + @Override + public void setJoinSignBackground(@NotNull BlockState b, org.bukkit.Material material) { + if (b.getBlockData() instanceof WallSign) { + b.getBlock().getRelative(((WallSign) b.getBlockData()).getFacing().getOppositeFace()).setType(material); + } + } + + @Override + public void spigotShowPlayer(Player victim, @NotNull Player receiver) { + receiver.showPlayer(getPlugin(), victim); + } + + @Override + public void spigotHidePlayer(Player victim, @NotNull Player receiver) { + receiver.hidePlayer(getPlugin(), victim); + } + + @Override + public Fireball setFireballDirection(Fireball fireball, @NotNull Vector vector) { + EntityFireball fb = ((CraftFireball) fireball).getHandle(); + fb.b = vector.getX() * 0.1D; + fb.c = vector.getY() * 0.1D; + fb.d = vector.getZ() * 0.1D; + return (Fireball) fb.getBukkitEntity(); + } + + @Override + public void playRedStoneDot(@NotNull Player player) { + Color color = Color.RED; + PacketPlayOutWorldParticles particlePacket = new PacketPlayOutWorldParticles( + new ParticleParamRedstone( + new Vector3f((float) color.getRed(), + (float) color.getGreen(), + (float) color.getBlue()), (float) 1 + ), + true, + player.getLocation().getX(), + player.getLocation().getY() + 2.6, + player.getLocation().getZ(), + 0, 0, 0, 0, 0 + ); + for (Player inWorld : player.getWorld().getPlayers()) { + if (inWorld.equals(player)) continue; + getPlayer(inWorld).b.a(particlePacket); + } + } + + @Override + public void clearArrowsFromPlayerBody(Player player) { + // minecraft clears them on death on newer version + } + + /** + * Gets the NMS Item from ItemStack + */ + private @Nullable Item getItem(org.bukkit.inventory.ItemStack itemStack) { + var i = CraftItemStack.asNMSCopy(itemStack); + if (null == i) { + return null; + } + return i.c(); + } + + /** + * Gets the NMS Entity from ItemStack + */ + private @Nullable net.minecraft.world.entity.Entity getEntity(org.bukkit.inventory.ItemStack itemStack) { + var i = CraftItemStack.asNMSCopy(itemStack); + if (null == i) { + return null; + } + return i.G(); + } + + private @Nullable NBTTagCompound getTag(@NotNull org.bukkit.inventory.ItemStack itemStack) { + var i = CraftItemStack.asNMSCopy(itemStack); + if (null == i) { + return null; + } + return i.u(); + } + + private @Nullable NBTTagCompound getTag(@NotNull ItemStack itemStack) { + return itemStack.u(); + } + + private @NotNull NBTTagCompound initializeTag(org.bukkit.inventory.ItemStack itemStack) { + var i = CraftItemStack.asNMSCopy(itemStack); + if (null == i) { + throw new RuntimeException("Cannot convert given item to a NMS item"); + } + return initializeTag(i); + } + + private @NotNull NBTTagCompound initializeTag(ItemStack itemStack) { + + var tag = getTag(itemStack); + if (null != tag) { + throw new RuntimeException("Provided item already has a Tag"); + } + tag = new NBTTagCompound(); + itemStack.c(tag); + + return tag; + } + + public NBTTagCompound getCreateTag(ItemStack itemStack) { + var tag = getTag(itemStack); + return null == tag ? initializeTag(itemStack) : tag; + } + + public NBTTagCompound getCreateTag(org.bukkit.inventory.ItemStack itemStack) { + var i = CraftItemStack.asNMSCopy(itemStack); + if (null == i) { + throw new RuntimeException("Cannot convert given item to a NMS item"); + } + return getCreateTag(i); + } + + public org.bukkit.inventory.ItemStack applyTag(org.bukkit.inventory.ItemStack itemStack, NBTTagCompound tag) { + return CraftItemStack.asBukkitCopy(applyTag(getNmsItemCopy(itemStack), tag)); + } + + public ItemStack applyTag(@NotNull ItemStack itemStack, NBTTagCompound tag) { + itemStack.c(tag); + return itemStack; + } + + public ItemStack getNmsItemCopy(org.bukkit.inventory.ItemStack itemStack) { + var i = CraftItemStack.asNMSCopy(itemStack); + if (null == i) { + throw new RuntimeException("Cannot convert given item to a NMS item"); + } + return i; + } + + public EntityPlayer getPlayer(Player player) { + return ((CraftPlayer) player).getHandle(); + } + + public List> getPlayerEquipment(@NotNull Player player) { + return getPlayerEquipment(getPlayer(player)); + } + + public List> getPlayerEquipment(@NotNull EntityPlayer entityPlayer) { + List> list = new ArrayList<>(); + list.add(new Pair<>(EnumItemSlot.a, entityPlayer.c(EnumItemSlot.a))); + list.add(new Pair<>(EnumItemSlot.b, entityPlayer.c(EnumItemSlot.b))); + list.add(new Pair<>(EnumItemSlot.f, entityPlayer.c(EnumItemSlot.f))); + list.add(new Pair<>(EnumItemSlot.e, entityPlayer.c(EnumItemSlot.e))); + list.add(new Pair<>(EnumItemSlot.d, entityPlayer.c(EnumItemSlot.d))); + list.add(new Pair<>(EnumItemSlot.c, entityPlayer.c(EnumItemSlot.c))); + + return list; + } + + @Override + public void placeTowerBlocks(@NotNull Block b, @NotNull IArena a, @NotNull TeamColor color, int x, int y, int z){ + b.getRelative(x, y, z).setType(color.woolMaterial()); + a.addPlacedBlock(b.getRelative(x, y, z)); + } + + @Override + public void placeLadder(@NotNull Block b, int x, int y, int z, @NotNull IArena a, int ladderData){ + Block block = b.getRelative(x,y,z); //ladder block + block.setType(Material.LADDER); + Ladder ladder = (Ladder) block.getBlockData(); + a.addPlacedBlock(block); + switch (ladderData) { + case 2 -> { + ladder.setFacing(BlockFace.NORTH); + block.setBlockData(ladder); + } + case 3 -> { + ladder.setFacing(BlockFace.SOUTH); + block.setBlockData(ladder); + } + case 4 -> { + ladder.setFacing(BlockFace.WEST); + block.setBlockData(ladder); + } + case 5 -> { + ladder.setFacing(BlockFace.EAST); + block.setBlockData(ladder); + } + } + } + + @Override + public void playVillagerEffect(@NotNull Player player, Location location){ + player.spawnParticle(Particle.VILLAGER_HAPPY, location, 1); + } +} \ No newline at end of file