mirror of
https://github.com/asofold/CompatNoCheatPlus.git
synced 2025-01-22 21:31:20 +01:00
Add skeleton for MagicSpells support (not yet operable).
This commit is contained in:
parent
a284937c47
commit
dbb70e9bcc
@ -61,3 +61,6 @@ hookiinstabreak: let hooks fail completely if listeners are failing to register
|
||||
|
||||
--------------------------
|
||||
|
||||
? register listeners with NCP directly? also use annotations ?
|
||||
|
||||
! if SpoutPlugin is present: add blocks to ignorepassable automatically / adjust flags ? [generic block setup]
|
||||
|
BIN
CompatNoCheatPlus/lib-maven/MagicSpells.jar
Normal file
BIN
CompatNoCheatPlus/lib-maven/MagicSpells.jar
Normal file
Binary file not shown.
@ -6,3 +6,4 @@ loadbefore:
|
||||
softdepend:
|
||||
- mcMMO
|
||||
- Citizens
|
||||
- MagicSpells
|
||||
|
@ -51,6 +51,13 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib-maven/citizens.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nisovin</groupId>
|
||||
<artifactId>MagicSpells</artifactId>
|
||||
<version>todo</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib-maven/MagicSpells.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Building -->
|
||||
|
@ -0,0 +1,68 @@
|
||||
package me.asofold.bpl.cncp.hooks.magicspells;
|
||||
|
||||
import me.asofold.bpl.cncp.hooks.AbstractConfigurableHook;
|
||||
import me.asofold.bpl.cncp.utils.TickTask2;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.nisovin.magicspells.Spell;
|
||||
import com.nisovin.magicspells.Spell.SpellCastState;
|
||||
import com.nisovin.magicspells.events.SpellCastEvent;
|
||||
import com.nisovin.magicspells.events.SpellCastedEvent;
|
||||
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||
|
||||
public class HookMagicSpells extends AbstractConfigurableHook implements Listener{
|
||||
|
||||
public HookMagicSpells(){
|
||||
super("MagicSpells(default)", "0.0", "magicspells.");
|
||||
assertPluginPresent("MagicSpells");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener[] getListeners() {
|
||||
return new Listener[]{
|
||||
this
|
||||
};
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onSpellCast(final SpellCastEvent event){
|
||||
if (event.getSpellCastState() != SpellCastState.NORMAL) return;
|
||||
exempt(event.getCaster(), event.getSpell());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onSpellCasted(final SpellCastedEvent event){
|
||||
unexempt(event.getCaster(), event.getSpell());
|
||||
}
|
||||
|
||||
private void exempt(final Player player, final Spell spell) {
|
||||
final CheckType[] types = getCheckTypes(spell);
|
||||
if (types == null) return;
|
||||
for (final CheckType type : types){
|
||||
NCPExemptionManager.exemptPermanently(player, type);
|
||||
// Safety fall-back:
|
||||
// TODO: Might interfere with "slow" effects of spells ? [might add config for this.]
|
||||
TickTask2.addUnexemptions(player, types);
|
||||
}
|
||||
}
|
||||
|
||||
private void unexempt(final Player player, final Spell spell) {
|
||||
final CheckType[] types = getCheckTypes(spell);
|
||||
if (types == null) return;
|
||||
for (final CheckType type : types){
|
||||
NCPExemptionManager.unexempt(player, type);
|
||||
}
|
||||
}
|
||||
|
||||
protected CheckType[] getCheckTypes(final Spell spell){
|
||||
// TODO: Find checktypes according to spell (config ?)
|
||||
// TODO: Use config !
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user