Added combatlogx integration
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package com.willfp.eco.spigot.integrations.antigrief;
|
||||
|
||||
import com.SirBlobman.combatlogx.expansion.newbie.helper.NewbieHelper;
|
||||
import com.SirBlobman.combatlogx.expansion.newbie.helper.listener.ListenerPVP;
|
||||
import com.github.sirblobman.combatlogx.api.ICombatLogX;
|
||||
import com.willfp.eco.spigot.EcoPlugin;
|
||||
import com.willfp.eco.util.integrations.antigrief.AntigriefWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -15,6 +18,26 @@ public class AntigriefCombatLogX implements AntigriefWrapper {
|
||||
*/
|
||||
private final ICombatLogX instance = (ICombatLogX) Bukkit.getPluginManager().getPlugin("CombatLogX");
|
||||
|
||||
/**
|
||||
* PVPManager for CombatLogX NewbieHelper.
|
||||
*/
|
||||
private ListenerPVP pvp = null;
|
||||
|
||||
/**
|
||||
* Create new CombatLogX antigrief.
|
||||
*/
|
||||
public AntigriefCombatLogX() {
|
||||
assert instance != null;
|
||||
EcoPlugin.getInstance().getScheduler().runLater(() -> {
|
||||
Object expansionUncast = instance.getExpansionManager().getAllExpansions().stream().filter(ex -> ex.getName().toLowerCase().contains("newbie")).findFirst().orElse(null);
|
||||
if (expansionUncast != null) {
|
||||
if (expansionUncast.getClass().getName().equals(NewbieHelper.class.getName())) {
|
||||
pvp = ((NewbieHelper) expansionUncast).getPVPListener();
|
||||
}
|
||||
}
|
||||
}, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreakBlock(@NotNull final Player player,
|
||||
@NotNull final Block block) {
|
||||
@@ -36,7 +59,15 @@ public class AntigriefCombatLogX implements AntigriefWrapper {
|
||||
@Override
|
||||
public boolean canInjure(@NotNull final Player player,
|
||||
@NotNull final LivingEntity victim) {
|
||||
return true;
|
||||
if (!(victim instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pvp == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (pvp.isPVPEnabled(player) && pvp.isPVPEnabled((Player) victim));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
BIN
lib/Newbie Helper.jar
Normal file
BIN
lib/Newbie Helper.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user