Add ASkyBlock support
This commit is contained in:
parent
0a127dfb40
commit
0a246fc90f
@ -1,5 +1,6 @@
|
||||
repositories {
|
||||
flatDir {dirs 'lib'}
|
||||
maven {url "http://dl.bintray.com/tastybento/maven-repo"}
|
||||
}
|
||||
dependencies {
|
||||
compile project(':core')
|
||||
@ -29,6 +30,7 @@ dependencies {
|
||||
compile 'org.bukkit.craftbukkit:Craftbukkit:1.7.10'
|
||||
compile 'org.bukkit.craftbukkit:CraftBukkit:1.8.8'
|
||||
compile 'com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT'
|
||||
compile 'com.wasteofplastic:askyblock:3.0.8.2'
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
@ -7,6 +7,7 @@ import com.boydti.fawe.bukkit.listener.BrushListener;
|
||||
import com.boydti.fawe.bukkit.listener.BukkitImageListener;
|
||||
import com.boydti.fawe.bukkit.listener.CFIPacketListener;
|
||||
import com.boydti.fawe.bukkit.listener.RenderListener;
|
||||
import com.boydti.fawe.bukkit.regions.ASkyBlockHook;
|
||||
import com.boydti.fawe.bukkit.regions.FactionsFeature;
|
||||
import com.boydti.fawe.bukkit.regions.FactionsOneFeature;
|
||||
import com.boydti.fawe.bukkit.regions.FactionsUUIDFeature;
|
||||
@ -559,6 +560,18 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final Plugin aSkyBlock = Bukkit.getServer().getPluginManager().getPlugin("ASkyBlock");
|
||||
if ((aSkyBlock != null) && aSkyBlock.isEnabled()) {
|
||||
try {
|
||||
managers.add(new ASkyBlockHook(aSkyBlock, this));
|
||||
Fawe.debug("Plugin 'ASkyBlock' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
return managers;
|
||||
}
|
||||
//
|
||||
|
@ -0,0 +1,55 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
||||
import com.wasteofplastic.askyblock.Island;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class ASkyBlockHook extends BukkitMaskManager implements Listener {
|
||||
FaweBukkit plugin;
|
||||
Plugin aSkyBlock;
|
||||
|
||||
public ASkyBlockHook(final Plugin aSkyBlock, final FaweBukkit p3) {
|
||||
super(aSkyBlock.getName());
|
||||
this.aSkyBlock = aSkyBlock;
|
||||
this.plugin = p3;
|
||||
|
||||
}
|
||||
|
||||
public boolean isAllowed(Player player, Island island, MaskType type) {
|
||||
return island != null && (player.getUniqueId().equals(island.getOwner()) || (type == MaskType.MEMBER && island.getMembers().contains(player.getUniqueId()) && hasMemberPermission(player)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
|
||||
Island island = ASkyBlockAPI.getInstance().getIslandAt(location);
|
||||
if (island != null && isAllowed(player, island, type)) {
|
||||
int minX = island.getMinProtectedX();
|
||||
int minZ = island.getMinProtectedZ();
|
||||
|
||||
World world = location.getWorld();
|
||||
Location center = island.getCenter();
|
||||
Location pos1 = new Location(world, island.getMinProtectedX(), 0, island.getMinProtectedZ());
|
||||
Location pos2 = center.add(center.subtract(pos1));
|
||||
pos2.setY(255);
|
||||
|
||||
return new BukkitMask(pos1, pos2, "ISLAND: " + minX + "," + minZ) {
|
||||
@Override
|
||||
public boolean isValid(FawePlayer player, MaskType type) {
|
||||
return isAllowed((Player) player.parent, island, type);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -7,6 +7,10 @@ import org.bukkit.Location;
|
||||
public class BukkitMask extends FaweMask {
|
||||
|
||||
public BukkitMask(Location pos1, Location pos2) {
|
||||
super(new BlockVector(pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()), new BlockVector(pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()));
|
||||
this(pos1, pos2, null);
|
||||
}
|
||||
|
||||
public BukkitMask(Location pos1, Location pos2, String name) {
|
||||
super(new BlockVector(pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()), new BlockVector(pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()), name);
|
||||
}
|
||||
}
|
@ -8,4 +8,8 @@ public abstract class BukkitMaskManager extends FaweMaskManager<Player> {
|
||||
public BukkitMaskManager(final String plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
public boolean hasMemberPermission(Player player) {
|
||||
return player.hasPermission("fawe." + getKey() + ".member");
|
||||
}
|
||||
}
|
||||
|
@ -7,27 +7,7 @@ import com.boydti.fawe.util.MathMan;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockCanBuildEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.event.block.BlockExpEvent;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockGrowEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
import org.bukkit.event.block.CauldronLevelChangeEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.block.NotePlayEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.inventory.BrewEvent;
|
||||
import org.bukkit.event.inventory.BrewingStandFuelEvent;
|
||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
|
||||
public class ChunkListener_9 extends ChunkListener {
|
||||
|
||||
@ -38,73 +18,8 @@ public class ChunkListener_9 extends ChunkListener {
|
||||
super();
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
physSkip = 0;
|
||||
physStart = System.currentTimeMillis();
|
||||
physCancel = false;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BlockBurnEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BlockCanBuildEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BlockDamageEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BlockDispenseEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BlockExpEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BlockExplodeEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BlockFadeEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BlockFromToEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BlockGrowEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BlockIgniteEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BlockPlaceEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BrewEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BrewingStandFuelEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(CauldronLevelChangeEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(FurnaceBurnEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(FurnaceSmeltEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(LeavesDecayEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(NotePlayEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(SignChangeEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void event(BlockRedstoneEvent event) { reset(); }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@Override
|
||||
public void onPhysics(BlockPhysicsEvent event) {
|
||||
if (physicsFreeze) {
|
||||
event.setCancelled(true);
|
||||
|
@ -40,4 +40,8 @@ public abstract class FaweMaskManager<T> {
|
||||
public RegionFilter getFilter(String world) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean hasMemberPermission(FawePlayer fp) {
|
||||
return fp.hasPermission("fawe." + getKey() + ".member");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user