Removes the temporary ignoreEntrances option and replaces it with proper snowman blocking. Fixes #3
Allows new gates to contain water as underwater gates are a thing now Adds a check to prevent snowmen from placing snow inside a portal's entrance Removes the ignoreEntrances option everywhere
This commit is contained in:
@ -68,8 +68,6 @@ public class Stargate extends JavaPlugin {
|
||||
public static boolean enableBungee = true;
|
||||
public static boolean verifyPortals = true;
|
||||
private static boolean destroyExplosion = false;
|
||||
//Temp workaround for snowmen, don't check gate entrance
|
||||
public static boolean ignoreEntrance = false;
|
||||
private String dataFolderPath;
|
||||
|
||||
public static ChatColor signColor;
|
||||
@ -453,7 +451,6 @@ public class Stargate extends JavaPlugin {
|
||||
//Integrity
|
||||
protectEntrance = newConfig.getBoolean("gates.integrity.protectEntrance");
|
||||
verifyPortals = newConfig.getBoolean("gates.integrity.verifyPortals");
|
||||
ignoreEntrance = newConfig.getBoolean("gates.integrity.ignoreEntrance");
|
||||
destroyExplosion = newConfig.getBoolean("gates.integrity.destroyedByExplosion");
|
||||
|
||||
//Cosmetic
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.type.WallSign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Snowman;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -21,6 +22,7 @@ import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPistonEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.EntityBlockFormEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
import java.util.List;
|
||||
@ -31,6 +33,26 @@ import java.util.List;
|
||||
@SuppressWarnings("unused")
|
||||
public class BlockEventListener implements Listener {
|
||||
|
||||
/**
|
||||
* Detects snowmen ruining portals
|
||||
*
|
||||
* @param event <p>The triggered event</p>
|
||||
*/
|
||||
@EventHandler
|
||||
public void onBlockFormedByEntity(EntityBlockFormEvent event) {
|
||||
if (event.isCancelled() || (!Stargate.protectEntrance && !Stargate.verifyPortals)) {
|
||||
return;
|
||||
}
|
||||
//We are only interested in snowman events
|
||||
if (!(event.getEntity() instanceof Snowman)) {
|
||||
return;
|
||||
}
|
||||
//Cancel the event if a snowman is trying to place snow in the portal's entrance
|
||||
if (PortalHandler.getByEntrance(event.getBlock()) != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects sign changes to detect if the user is creating a new gate
|
||||
*
|
||||
@ -66,7 +88,7 @@ public class BlockEventListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
if (event.isCancelled() || !Stargate.protectEntrance) {
|
||||
return;
|
||||
}
|
||||
Block block = event.getBlock();
|
||||
@ -74,7 +96,7 @@ public class BlockEventListener implements Listener {
|
||||
|
||||
//Decide if a portal is broken
|
||||
Portal portal = PortalHandler.getByBlock(block);
|
||||
if (portal == null && Stargate.protectEntrance) {
|
||||
if (portal == null) {
|
||||
portal = PortalHandler.getByEntrance(block);
|
||||
}
|
||||
if (portal == null) {
|
||||
|
@ -214,16 +214,13 @@ public class Gate {
|
||||
* @return <p>Whether this is used in the context of creating a new gate</p>
|
||||
*/
|
||||
private boolean verifyGateEntrancesMatch(BlockLocation topLeft, double yaw, boolean onCreate) {
|
||||
if (Stargate.ignoreEntrance) {
|
||||
return true;
|
||||
}
|
||||
Stargate.debug("verifyGateEntrancesMatch", String.valueOf(topLeft));
|
||||
for (RelativeBlockVector entranceVector : layout.getEntrances()) {
|
||||
Stargate.debug("verifyGateEntrancesMatch", String.valueOf(entranceVector));
|
||||
Material type = getBlockAt(topLeft, entranceVector, yaw).getType();
|
||||
|
||||
//Ignore entrance if it's air, and we're creating a new gate
|
||||
if (onCreate && type == Material.AIR) {
|
||||
//Ignore entrance if it's air or water, and we're creating a new gate
|
||||
if (onCreate && (type == Material.AIR || type == Material.WATER)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,12 @@ public class PortalHandler {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets names of all portals within a network
|
||||
*
|
||||
* @param network <p>The network to get portals from</p>
|
||||
* @return <p>A list of portal names</p>
|
||||
*/
|
||||
public static List<String> getNetwork(String network) {
|
||||
return allPortalNetworks.get(network.toLowerCase());
|
||||
}
|
||||
|
Reference in New Issue
Block a user