MassiveCore - MassivePlugin and Active
This commit is contained in:
@@ -1,19 +1,14 @@
|
||||
package com.massivecraft.factions.integration.herochat;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.dthielke.herochat.ChannelChatEvent;
|
||||
import com.dthielke.herochat.Herochat;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.chat.ChatFormatter;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.massivecore.Engine;
|
||||
|
||||
|
||||
public class EngineHerochat implements Listener
|
||||
public class EngineHerochat extends Engine
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
@@ -21,23 +16,18 @@ public class EngineHerochat implements Listener
|
||||
|
||||
private static EngineHerochat i = new EngineHerochat();
|
||||
public static EngineHerochat get() { return i; }
|
||||
private EngineHerochat() {}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ACTIVATE & DEACTIVATE
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void activate()
|
||||
@Override
|
||||
public void setActiveInner(boolean active)
|
||||
{
|
||||
if ( ! active) return;
|
||||
|
||||
Herochat.getChannelManager().addChannel(new ChannelFactionsFaction());
|
||||
Herochat.getChannelManager().addChannel(new ChannelFactionsAllies());
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, Factions.get());
|
||||
}
|
||||
|
||||
public void deactivate()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package com.massivecraft.factions.integration.herochat;
|
||||
|
||||
import com.massivecraft.massivecore.integration.IntegrationAbstract;
|
||||
import com.massivecraft.massivecore.Engine;
|
||||
import com.massivecraft.massivecore.Integration;
|
||||
|
||||
public class IntegrationHerochat extends IntegrationAbstract
|
||||
public class IntegrationHerochat extends Integration
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
@@ -10,22 +11,19 @@ public class IntegrationHerochat extends IntegrationAbstract
|
||||
|
||||
private static IntegrationHerochat i = new IntegrationHerochat();
|
||||
public static IntegrationHerochat get() { return i; }
|
||||
private IntegrationHerochat() { super("Herochat"); }
|
||||
private IntegrationHerochat()
|
||||
{
|
||||
this.setPluginName("HeroChat");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void activate()
|
||||
public Engine getEngine()
|
||||
{
|
||||
EngineHerochat.get().activate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate()
|
||||
{
|
||||
EngineHerochat.get().deactivate();
|
||||
return EngineHerochat.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -8,7 +8,6 @@ import java.util.Set;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.griefcraft.lwc.LWC;
|
||||
import com.griefcraft.model.Protection;
|
||||
@@ -19,12 +18,12 @@ import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.event.EventFactionsChunksChange;
|
||||
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
|
||||
import com.massivecraft.massivecore.EngineAbstract;
|
||||
import com.massivecraft.massivecore.Engine;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
|
||||
|
||||
public class EngineLwc extends EngineAbstract
|
||||
public class EngineLwc extends Engine
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
@@ -32,30 +31,22 @@ public class EngineLwc extends EngineAbstract
|
||||
|
||||
private static EngineLwc i = new EngineLwc();
|
||||
public static EngineLwc get() { return i; }
|
||||
private EngineLwc() {}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public Plugin getPlugin()
|
||||
public void setActiveInner(boolean active)
|
||||
{
|
||||
return Factions.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate()
|
||||
{
|
||||
super.activate();
|
||||
LWC.getInstance().getModuleLoader().registerModule(Factions.get(), new FactionsLwcModule(Factions.get()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate()
|
||||
{
|
||||
super.deactivate();
|
||||
LWC.getInstance().getModuleLoader().removeModules(Factions.get());
|
||||
if (active)
|
||||
{
|
||||
LWC.getInstance().getModuleLoader().registerModule(Factions.get(), new FactionsLwcModule(Factions.get()));
|
||||
}
|
||||
else
|
||||
{
|
||||
LWC.getInstance().getModuleLoader().removeModules(Factions.get());
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package com.massivecraft.factions.integration.lwc;
|
||||
|
||||
import com.massivecraft.massivecore.integration.IntegrationAbstract;
|
||||
import com.massivecraft.massivecore.Engine;
|
||||
import com.massivecraft.massivecore.Integration;
|
||||
|
||||
public class IntegrationLwc extends IntegrationAbstract
|
||||
public class IntegrationLwc extends Integration
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
@@ -10,22 +11,19 @@ public class IntegrationLwc extends IntegrationAbstract
|
||||
|
||||
private static IntegrationLwc i = new IntegrationLwc();
|
||||
public static IntegrationLwc get() { return i; }
|
||||
private IntegrationLwc() { super("LWC"); }
|
||||
private IntegrationLwc()
|
||||
{
|
||||
this.setPluginName("LWC");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void activate()
|
||||
public Engine getEngine()
|
||||
{
|
||||
EngineLwc.get().activate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate()
|
||||
{
|
||||
EngineLwc.get().deactivate();
|
||||
return EngineLwc.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,123 @@
|
||||
package com.massivecraft.factions.integration.spigot;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import com.massivecraft.factions.engine.EngineMain;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.massivecore.Engine;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
|
||||
|
||||
public class EngineSpigot extends Engine
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static EngineSpigot i = new EngineSpigot();
|
||||
public static EngineSpigot get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// LISTENER
|
||||
// -------------------------------------------- //
|
||||
|
||||
// This is a special Spigot event that fires for Minecraft 1.8 armor stands.
|
||||
// It also fires for other entity types but for those the event is buggy.
|
||||
// It seems we can only cancel interaction with armor stands from here.
|
||||
// Thus we only handle armor stands from here and handle everything else in EngineMain.
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event)
|
||||
{
|
||||
// Gather Info
|
||||
final Player player = event.getPlayer();
|
||||
if (MUtil.isntPlayer(player)) return;
|
||||
final Entity entity = event.getRightClicked();
|
||||
final boolean verboose = true;
|
||||
|
||||
// Only care for armor stands.
|
||||
if (entity.getType() != EntityType.ARMOR_STAND) return;
|
||||
|
||||
// If we can't use ...
|
||||
if (EngineMain.canPlayerUseEntity(player, entity, verboose)) return;
|
||||
|
||||
// ... block use.
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Note: With 1.8 and the slime blocks, retracting and extending pistons
|
||||
* became more of a problem. Blocks located on the border of a chunk
|
||||
* could have easily been stolen. That is the reason why every block
|
||||
* needs to be checked now, whether he moved into a territory which
|
||||
* he actually may not move into.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void blockBuild(BlockPistonExtendEvent event)
|
||||
{
|
||||
// Is checking deactivated by MConf?
|
||||
if ( ! MConf.get().handlePistonProtectionThroughDenyBuild) return;
|
||||
|
||||
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
|
||||
|
||||
List<Block> blocks = event.getBlocks();
|
||||
|
||||
// Check for all extended blocks
|
||||
for (Block block : blocks)
|
||||
{
|
||||
// Block which is being pushed into
|
||||
Block targetBlock = block.getRelative(event.getDirection());
|
||||
|
||||
// Members of a faction might not have build rights in their own territory, but pistons should still work regardless
|
||||
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetBlock));
|
||||
if (targetFaction == pistonFaction) continue;
|
||||
|
||||
// Perm check
|
||||
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) continue;
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void blockBuild(BlockPistonRetractEvent event)
|
||||
{
|
||||
// Is checking deactivated by MConf?
|
||||
if ( ! MConf.get().handlePistonProtectionThroughDenyBuild) return;
|
||||
|
||||
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
|
||||
|
||||
List<Block> blocks = event.getBlocks();
|
||||
|
||||
// Check for all retracted blocks
|
||||
for (Block block : blocks)
|
||||
{
|
||||
// Is the retracted block air/water/lava? Don't worry about it
|
||||
if (block.isEmpty() || block.isLiquid()) return;
|
||||
|
||||
// Members of a faction might not have build rights in their own territory, but pistons should still work regardless
|
||||
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(block));
|
||||
if (targetFaction == pistonFaction) continue;
|
||||
|
||||
// Perm check
|
||||
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) continue;
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package com.massivecraft.factions.integration.spigot;
|
||||
|
||||
import com.massivecraft.massivecore.Engine;
|
||||
import com.massivecraft.massivecore.Integration;
|
||||
|
||||
public class IntegrationSpigot extends Integration
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static IntegrationSpigot i = new IntegrationSpigot();
|
||||
public static IntegrationSpigot get() { return i; }
|
||||
private IntegrationSpigot()
|
||||
{
|
||||
this.setPredicate(PredicateSpigot.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public Engine getEngine()
|
||||
{
|
||||
return EngineSpigot.get();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
package com.massivecraft.factions.integration.spigot;
|
||||
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
|
||||
import com.massivecraft.massivecore.Integration;
|
||||
import com.massivecraft.massivecore.predicate.Predicate;
|
||||
|
||||
public class PredicateSpigot implements Predicate<Integration>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static PredicateSpigot i = new PredicateSpigot();
|
||||
public static PredicateSpigot get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean apply(Integration integration)
|
||||
{
|
||||
try
|
||||
{
|
||||
// This line will throw if the class does not exist.
|
||||
PlayerInteractAtEntityEvent.class.getName();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -7,14 +7,11 @@ import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.MFlag;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.event.EventFactionsChunksChange;
|
||||
import com.massivecraft.massivecore.EngineAbstract;
|
||||
import com.massivecraft.massivecore.Engine;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
@@ -22,7 +19,7 @@ import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
public class EngineWorldGuard extends EngineAbstract
|
||||
public class EngineWorldGuard extends Engine
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
@@ -30,7 +27,6 @@ public class EngineWorldGuard extends EngineAbstract
|
||||
|
||||
private static EngineWorldGuard i = new EngineWorldGuard();
|
||||
public static EngineWorldGuard get() { return i; }
|
||||
private EngineWorldGuard() {}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
@@ -43,25 +39,16 @@ public class EngineWorldGuard extends EngineAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public Plugin getPlugin()
|
||||
public void setActiveInner(boolean active)
|
||||
{
|
||||
return Factions.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate()
|
||||
{
|
||||
this.worldGuard = (WorldGuardPlugin) Bukkit.getPluginManager().getPlugin("WorldGuard");
|
||||
|
||||
super.activate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate()
|
||||
{
|
||||
this.worldGuard = null;
|
||||
|
||||
super.deactivate();
|
||||
if (active)
|
||||
{
|
||||
this.worldGuard = (WorldGuardPlugin) Bukkit.getPluginManager().getPlugin("WorldGuard");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.worldGuard = null;
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package com.massivecraft.factions.integration.worldguard;
|
||||
|
||||
import com.massivecraft.massivecore.integration.IntegrationAbstract;
|
||||
import com.massivecraft.massivecore.Engine;
|
||||
import com.massivecraft.massivecore.Integration;
|
||||
|
||||
public class IntegrationWorldGuard extends IntegrationAbstract
|
||||
public class IntegrationWorldGuard extends Integration
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
@@ -10,22 +11,19 @@ public class IntegrationWorldGuard extends IntegrationAbstract
|
||||
|
||||
private static IntegrationWorldGuard i = new IntegrationWorldGuard();
|
||||
public static IntegrationWorldGuard get() { return i; }
|
||||
private IntegrationWorldGuard() { super("WorldGuard"); }
|
||||
private IntegrationWorldGuard()
|
||||
{
|
||||
this.setPluginName("WorldGuard");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void activate()
|
||||
public Engine getEngine()
|
||||
{
|
||||
EngineWorldGuard.get().activate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate()
|
||||
{
|
||||
EngineWorldGuard.get().deactivate();
|
||||
return EngineWorldGuard.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user