mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-23 02:35:22 +01:00
Upgraded to EngineAbstract for LWC and made use of the LWC module system.
This commit is contained in:
parent
34b166503e
commit
cf859f2e61
@ -3,30 +3,27 @@ package com.massivecraft.factions.integration.lwc;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.griefcraft.lwc.LWC;
|
||||
import com.griefcraft.model.Protection;
|
||||
import com.griefcraft.scripting.event.LWCProtectionRegisterEvent;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.event.EventFactionsChunkChange;
|
||||
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
|
||||
import com.massivecraft.factions.listeners.FactionsListenerMain;
|
||||
import com.massivecraft.massivecore.EngineAbstract;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
|
||||
|
||||
public class EngineLwc implements Listener
|
||||
public class EngineLwc extends EngineAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
@ -37,17 +34,13 @@ public class EngineLwc implements Listener
|
||||
private EngineLwc() {}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ACTIVATE & DEACTIVATE
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void activate()
|
||||
@Override
|
||||
public Plugin getPlugin()
|
||||
{
|
||||
Bukkit.getPluginManager().registerEvents(this, Factions.get());
|
||||
}
|
||||
|
||||
public void deactivate()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
return Factions.get();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -68,13 +61,6 @@ public class EngineLwc implements Listener
|
||||
removeAlienProtections(event.getChunk(), newFaction);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onCreateProtection(LWCProtectionRegisterEvent event)
|
||||
{
|
||||
if (FactionsListenerMain.canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), false)) return;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// UTIL
|
||||
// -------------------------------------------- //
|
||||
@ -121,4 +107,5 @@ public class EngineLwc implements Listener
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
package com.massivecraft.factions.integration.lwc;
|
||||
|
||||
import com.griefcraft.lwc.LWC;
|
||||
import com.griefcraft.scripting.JavaModule;
|
||||
import com.griefcraft.scripting.event.LWCProtectionRegisterEvent;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.listeners.FactionsListenerMain;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class FactionsLwcModule extends JavaModule
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
// These plugin variables must be present.
|
||||
// They are set by LWC using reflection somehow.
|
||||
private Factions plugin;
|
||||
private LWC lwc;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public FactionsLwcModule(Factions plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void onRegisterProtection(LWCProtectionRegisterEvent event)
|
||||
{
|
||||
if (FactionsListenerMain.canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), false)) return;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.massivecraft.factions.integration.lwc;
|
||||
|
||||
import com.griefcraft.lwc.LWC;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.massivecore.integration.IntegrationAbstract;
|
||||
|
||||
public class IntegrationLwc extends IntegrationAbstract
|
||||
@ -20,12 +22,16 @@ public class IntegrationLwc extends IntegrationAbstract
|
||||
public void activate()
|
||||
{
|
||||
EngineLwc.get().activate();
|
||||
|
||||
LWC.getInstance().getModuleLoader().registerModule(Factions.get(), new FactionsLwcModule(Factions.get()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate()
|
||||
{
|
||||
EngineLwc.get().deactivate();
|
||||
|
||||
LWC.getInstance().getModuleLoader().removeModules(Factions.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user