mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-01-09 09:48:13 +01:00
feat: block physics updates inside portal protection zones
This commit is contained in:
parent
901b4a9989
commit
bba14185eb
@ -194,4 +194,8 @@ public class CoreListeners {
|
|||||||
pos.addY((int) entity.getHeight()), 1);
|
pos.addY((int) entity.getHeight()), 1);
|
||||||
return !(feetInPortal || headInPortal);
|
return !(feetInPortal || headInPortal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean physicsEvent(BlockLocation blockLocation, String string) {
|
||||||
|
return !configRepository.getDisablePhysicsEvents() || !portalServices.inPortalRegionProtected(blockLocation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ public class ShowDestiSubCommand
|
|||||||
if (Objects.equals(pos.getWorldName(),
|
if (Objects.equals(pos.getWorldName(),
|
||||||
player.getWorldName())
|
player.getWorldName())
|
||||||
&& pos.distanceTo(player.getLoc())
|
&& pos.distanceTo(player.getLoc())
|
||||||
< config.getVisibleRange()) {
|
< config.getShowVisibleRange()) {
|
||||||
Debug.addMarker(player, pos.toBlockPos(),
|
Debug.addMarker(player, pos.toBlockPos(),
|
||||||
destination.getArgValues("name")[0],
|
destination.getArgValues("name")[0],
|
||||||
new Color(100, 100, 100, 100), 1300);
|
new Color(100, 100, 100, 100), 1300);
|
||||||
|
@ -138,7 +138,7 @@ public class ShowPortalSubCommand
|
|||||||
if (Objects.equals(portal.getMinLoc().getWorldName(),
|
if (Objects.equals(portal.getMinLoc().getWorldName(),
|
||||||
player.getWorldName())
|
player.getWorldName())
|
||||||
&& portal.isLocationInPortal(
|
&& portal.isLocationInPortal(
|
||||||
player.getLoc(), config.getVisibleRange())) {
|
player.getLoc(), config.getShowVisibleRange())) {
|
||||||
BlockLocation minLoc = portal.getMinLoc();
|
BlockLocation minLoc = portal.getMinLoc();
|
||||||
BlockLocation maxLoc = portal.getMaxLoc();
|
BlockLocation maxLoc = portal.getMaxLoc();
|
||||||
int midX = (minLoc.getPosX() + maxLoc.getPosX()) / 2;
|
int midX = (minLoc.getPosX() + maxLoc.getPosX()) / 2;
|
||||||
|
@ -12,7 +12,7 @@ public interface ConfigRepository {
|
|||||||
|
|
||||||
void loadConfig(DataStorage dataStorage);
|
void loadConfig(DataStorage dataStorage);
|
||||||
|
|
||||||
int getVisibleRange();
|
int getShowVisibleRange();
|
||||||
|
|
||||||
int getMaxTriggerVisualisationSize();
|
int getMaxTriggerVisualisationSize();
|
||||||
|
|
||||||
@ -34,5 +34,7 @@ public interface ConfigRepository {
|
|||||||
|
|
||||||
void storeConfig();
|
void storeConfig();
|
||||||
|
|
||||||
|
boolean getDisablePhysicsEvents();
|
||||||
|
|
||||||
CommandPortalConfig getCommandPortals();
|
CommandPortalConfig getCommandPortals();
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,8 @@ public class ConfigRepositoryImpl implements ConfigRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVisibleRange() {
|
public int getShowVisibleRange() {
|
||||||
return this.config.visibleRange;
|
return this.config.showVisibleRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -96,6 +96,11 @@ public class ConfigRepositoryImpl implements ConfigRepository {
|
|||||||
return this.config.playFailSound;
|
return this.config.playFailSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getDisablePhysicsEvents() {
|
||||||
|
return this.config.disablePhysicsEvents;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandPortalConfig getCommandPortals() {
|
public CommandPortalConfig getCommandPortals() {
|
||||||
return this.config.commandPortals;
|
return this.config.commandPortals;
|
||||||
|
@ -22,11 +22,11 @@ public class Config {
|
|||||||
|
|
||||||
public String warpSound = "ENDER";
|
public String warpSound = "ENDER";
|
||||||
|
|
||||||
public String selectionBlock = "RED_STAINED_GLASS";
|
|
||||||
|
|
||||||
public String translationFile = "en_GB";
|
public String translationFile = "en_GB";
|
||||||
|
|
||||||
public int visibleRange = 50;
|
public int showVisibleRange = 50;
|
||||||
|
|
||||||
|
public boolean disablePhysicsEvents = true;
|
||||||
|
|
||||||
public int maxTriggerVisualisationSize = 1000;
|
public int maxTriggerVisualisationSize = 1000;
|
||||||
|
|
||||||
|
@ -10,10 +10,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.*;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.entity.*;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
|
|
||||||
@ -52,6 +49,15 @@ public class Listeners implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPhysicsEvent(BlockPhysicsEvent event) {
|
||||||
|
if (!coreListeners.physicsEvent(ContainerHelpers.toBlockLocation(
|
||||||
|
event.getBlock().getLocation()),
|
||||||
|
event.getBlock().getType().toString())) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onWorldChangeEvent(PlayerChangedWorldEvent event) {
|
public void onWorldChangeEvent(PlayerChangedWorldEvent event) {
|
||||||
coreListeners.worldChange(new SpigotPlayerContainer(event.getPlayer()));
|
coreListeners.worldChange(new SpigotPlayerContainer(event.getPlayer()));
|
||||||
|
Loading…
Reference in New Issue
Block a user