mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-02-18 13:31:30 +01:00
Added support for MagicSpells v1.1 (bad nisovin, BAD!)
This commit is contained in:
parent
5e55d57326
commit
f0f5967e8d
BIN
MobArena.jar
BIN
MobArena.jar
Binary file not shown.
@ -16,6 +16,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.util.config.Configuration;
|
import org.bukkit.util.config.Configuration;
|
||||||
|
|
||||||
|
import com.garbagemule.MobArena.listeners.MagicSpellsBetaListener;
|
||||||
import com.garbagemule.MobArena.listeners.MagicSpellsListener;
|
import com.garbagemule.MobArena.listeners.MagicSpellsListener;
|
||||||
import com.garbagemule.MobArena.spout.Spouty;
|
import com.garbagemule.MobArena.spout.Spouty;
|
||||||
import com.garbagemule.MobArena.util.FileUtils;
|
import com.garbagemule.MobArena.util.FileUtils;
|
||||||
@ -195,8 +196,12 @@ public class MobArena extends JavaPlugin
|
|||||||
if (spells == null) return;
|
if (spells == null) return;
|
||||||
|
|
||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
MagicSpellsListener spellsListener = new MagicSpellsListener(this);
|
|
||||||
pm.registerEvent(Event.Type.CUSTOM_EVENT, spellsListener, Priority.Normal, this);
|
// Check the version, and make the correct listener. Deprecate as soon as 1.1 is out of beta.
|
||||||
|
if (spells.getDescription().getVersion().equals("1.1"))
|
||||||
|
pm.registerEvent(Event.Type.CUSTOM_EVENT, new MagicSpellsBetaListener(this), Priority.Normal, this);
|
||||||
|
else
|
||||||
|
pm.registerEvent(Event.Type.CUSTOM_EVENT, new MagicSpellsListener(this), Priority.Normal, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Configuration getConfig() { return config; }
|
public Configuration getConfig() { return config; }
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
package com.garbagemule.MobArena.listeners;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.util.config.Configuration;
|
||||||
|
|
||||||
|
import com.garbagemule.MobArena.Arena;
|
||||||
|
import com.garbagemule.MobArena.MobArena;
|
||||||
|
import com.garbagemule.MobArena.util.FileUtils;
|
||||||
|
import com.garbagemule.MobArena.waves.Wave.WaveType;
|
||||||
|
import com.nisovin.magicspells.events.SpellCastEvent;
|
||||||
|
import com.nisovin.magicspells.events.SpellListener;
|
||||||
|
|
||||||
|
public class MagicSpellsBetaListener extends SpellListener
|
||||||
|
{
|
||||||
|
private MobArena plugin;
|
||||||
|
private List<String> disabled, disabledOnBoss, disabledOnSwarm;
|
||||||
|
|
||||||
|
public MagicSpellsBetaListener(MobArena plugin)
|
||||||
|
{
|
||||||
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
// Set up the MagicSpells config-file.
|
||||||
|
File spellFile = FileUtils.extractFile(plugin.getDataFolder(), "magicspells.yml");
|
||||||
|
Configuration spellConfig = new Configuration(spellFile);
|
||||||
|
spellConfig.load();
|
||||||
|
setupSpells(spellConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSpellCast(SpellCastEvent event)
|
||||||
|
{
|
||||||
|
Arena arena = plugin.getAM().getArenaWithPlayer(event.getCaster());
|
||||||
|
if (arena == null || !arena.isRunning()) return;
|
||||||
|
|
||||||
|
String spell = event.getSpell().getName();
|
||||||
|
WaveType type = (arena.getWave() != null) ? arena.getWave().getType() : null;
|
||||||
|
|
||||||
|
if (disabled.contains(spell) ||
|
||||||
|
(type == WaveType.BOSS && disabledOnBoss.contains(spell)) ||
|
||||||
|
(type == WaveType.SWARM && disabledOnSwarm.contains(spell)))
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupSpells(Configuration config)
|
||||||
|
{
|
||||||
|
this.disabled = config.getStringList("disabled-spells", new LinkedList<String>());
|
||||||
|
this.disabledOnBoss = config.getStringList("disabled-only-on-bosses", new LinkedList<String>());
|
||||||
|
this.disabledOnSwarm = config.getStringList("disabled-only-on-swarms", new LinkedList<String>());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableSpell(String spell)
|
||||||
|
{
|
||||||
|
disabled.add(spell);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableSpellOnBoss(String spell)
|
||||||
|
{
|
||||||
|
disabledOnBoss.add(spell);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user