From c682e457149833880f8cb11f8bd5e29909a1a6ba Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Thu, 16 Jul 2020 22:19:33 +0200 Subject: [PATCH] Remove MagicSpells integration. The integration only works reliably with the `clear-wave-` settings set to `true`, because it relies on there being only one "current" wave. This is a fundamental issue with the way sessions run right now, and is another good example of why the Sessions Rework is necessary. It is possible to achieve the exact same functionality by just making a couple of Upgrade Waves before and after the waves that need to have limited skill sets (thanks Lucy). With just a couple of quality-of-life features like wave "triggers", it's possible to make things just the way they were with the integration, but by using some more general building blocks. Closes #609 --- changelog.md | 1 + pom.xml | 10 +-- .../com/garbagemule/MobArena/MobArena.java | 12 ---- .../listeners/MagicSpellsListener.java | 63 ------------------- src/main/resources/magicspells.yml | 18 ------ 5 files changed, 2 insertions(+), 102 deletions(-) delete mode 100644 src/main/java/com/garbagemule/MobArena/listeners/MagicSpellsListener.java delete mode 100644 src/main/resources/magicspells.yml diff --git a/changelog.md b/changelog.md index 999ea81..7df1f5a 100644 --- a/changelog.md +++ b/changelog.md @@ -19,6 +19,7 @@ These changes will (most likely) be included in the next version. - Config-files with missing `pet-items` nodes no longer errors. A missing `pet-items` node in `global-settings` is treated as empty, i.e. no pet items will be registered. - The `player-time-in-arena` setting has been fixed. - Config-file errors imposed by incorrect usage of `/ma setting` no longer cause "internal errors". Instead, the errors are properly communicated in the command output similar to how the `/ma reload` command works. +- The MagicSpells integration has been removed. This means that the extra `magicspells.yml` config-file (if it exists) no longer does anything and can be removed. ## [0.104.2] - 2020-01-03 - The region overlap check now works across both arena and lobby regions, i.e. all four combinations of intersections between two regions (arena-arena, arena-lobby, lobby-arena, and lobby-lobby) are evaluated. diff --git a/pom.xml b/pom.xml index 3751971..9c4ee02 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ http://repo.codemc.org/repository/maven-public/ - + jitpack.io https://jitpack.io @@ -115,14 +115,6 @@ compile - - - com.github.TheComputerGeek2 - MagicSpells - 3.5-Release - provided - - junit diff --git a/src/main/java/com/garbagemule/MobArena/MobArena.java b/src/main/java/com/garbagemule/MobArena/MobArena.java index 4f437d9..986e8d3 100644 --- a/src/main/java/com/garbagemule/MobArena/MobArena.java +++ b/src/main/java/com/garbagemule/MobArena/MobArena.java @@ -5,7 +5,6 @@ import com.garbagemule.MobArena.config.LoadsConfigFile; import com.garbagemule.MobArena.framework.Arena; import com.garbagemule.MobArena.framework.ArenaMaster; import com.garbagemule.MobArena.listeners.MAGlobalListener; -import com.garbagemule.MobArena.listeners.MagicSpellsListener; import com.garbagemule.MobArena.metrics.ArenaCountChart; import com.garbagemule.MobArena.metrics.ClassChestsChart; import com.garbagemule.MobArena.metrics.ClassCountChart; @@ -96,7 +95,6 @@ public class MobArena extends JavaPlugin registerConfigurationSerializers(); setupVault(); - setupMagicSpells(); setupBossAbilities(); setupListeners(); setupMetrics(); @@ -147,16 +145,6 @@ public class MobArena extends JavaPlugin } } - private void setupMagicSpells() { - Plugin spells = this.getServer().getPluginManager().getPlugin("MagicSpells"); - if (spells == null) { - return; - } - - getLogger().info("MagicSpells found, loading config-file."); - this.getServer().getPluginManager().registerEvents(new MagicSpellsListener(this), this); - } - private void setupBossAbilities() { AbilityManager.loadCoreAbilities(); AbilityManager.loadCustomAbilities(getDataFolder()); diff --git a/src/main/java/com/garbagemule/MobArena/listeners/MagicSpellsListener.java b/src/main/java/com/garbagemule/MobArena/listeners/MagicSpellsListener.java deleted file mode 100644 index 347a84d..0000000 --- a/src/main/java/com/garbagemule/MobArena/listeners/MagicSpellsListener.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.garbagemule.MobArena.listeners; - -import com.garbagemule.MobArena.MobArena; -import com.garbagemule.MobArena.framework.Arena; -import com.garbagemule.MobArena.waves.enums.WaveType; -import com.nisovin.magicspells.events.SpellCastEvent; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import java.io.File; -import java.util.List; - -public class MagicSpellsListener implements Listener -{ - private MobArena plugin; - private List disabled, disabledOnBoss, disabledOnSwarm; - - public MagicSpellsListener(MobArena plugin) - { - this.plugin = plugin; - - // Set up the MagicSpells config-file. - File file = new File(plugin.getDataFolder(), "magicspells.yml"); - if (!file.exists()) { - plugin.saveResource("magicspells.yml", false); - plugin.getLogger().info("magicspells.yml created."); - } - try { - FileConfiguration config = new YamlConfiguration(); - config.load(file); - setupSpells(config); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @EventHandler(priority = EventPriority.NORMAL) - public void onSpellCast(SpellCastEvent event) - { - Arena arena = plugin.getArenaMaster().getArenaWithPlayer(event.getCaster()); - if (arena == null || !arena.isRunning()) return; - - String spell = event.getSpell().getName(); - WaveType type = (arena.getWaveManager().getCurrent() != null) ? arena.getWaveManager().getCurrent().getType() : null; - - if (disabled.contains(spell) || - (type == WaveType.BOSS && disabledOnBoss.contains(spell)) || - (type == WaveType.SWARM && disabledOnSwarm.contains(spell))) { - event.setCancelled(true); - } - } - - private void setupSpells(ConfigurationSection config) - { - this.disabled = config.getStringList("disabled-spells"); - this.disabledOnBoss = config.getStringList("disabled-on-bosses"); - this.disabledOnSwarm = config.getStringList("disabled-on-swarms"); - } -} diff --git a/src/main/resources/magicspells.yml b/src/main/resources/magicspells.yml deleted file mode 100644 index 988ff37..0000000 --- a/src/main/resources/magicspells.yml +++ /dev/null @@ -1,18 +0,0 @@ -# MobArena disabled MagicSpells spells -# -# Use this file to disable the MagicSpells spells you don't want your players -# to use during arena sessions. Make sure to put a hyphen (-) before every -# spell, and try to keep the indentation proper. -# -# Spells that will be disabled for the entire arena session. -disabled-spells: -- carpet -- blink - -# Spells that will be disabled only while a boss is present. -disabled-on-bosses: -- purge - -# Spells that will be disabled only during swarm waves. -disabled-on-swarms: -- purge \ No newline at end of file