diff --git a/core/src/main/java/com/sekwah/advancedportals/core/CoreListeners.java b/core/src/main/java/com/sekwah/advancedportals/core/CoreListeners.java index c42616a2..4d8af696 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/CoreListeners.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/CoreListeners.java @@ -66,6 +66,9 @@ public class CoreListeners { public boolean blockBreak(PlayerContainer player, BlockLocation blockPos, String blockMaterial, String itemInHandMaterial, String itemInHandName) { + if (!configRepository.getPortalProtection()) + return true; + if (player == null) { return !portalServices.inPortalRegionProtected(blockPos); } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/repository/ConfigRepository.java b/core/src/main/java/com/sekwah/advancedportals/core/repository/ConfigRepository.java index dfec9dcd..6899c169 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/repository/ConfigRepository.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/repository/ConfigRepository.java @@ -37,4 +37,8 @@ public interface ConfigRepository { boolean getDisablePhysicsEvents(); CommandPortalConfig getCommandPortals(); + + String getWarpSound(); + + String getWarpParticles(); } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java index b79dc54e..fd39e35d 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java @@ -85,6 +85,16 @@ public class ConfigRepositoryImpl implements ConfigRepository { return this.config.throwbackStrength; } + @Override + public String getWarpSound() { + return this.config.warpSound; + } + + @Override + public String getWarpParticles() { + return this.config.warpParticles; + } + @Override public void loadConfig(DataStorage dataStorage) { this.dataStorage = dataStorage; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java index faba0051..61e51c0e 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java @@ -193,6 +193,7 @@ public class ReflectiveConstructor extends Constructor { */ private void setField(Object instance, Field field, Object value) throws IllegalAccessException { + // Check for numeric type compatibility and cast if necessary if (field.getType() == float.class &&value instanceof Double) { value = ((Double) value).floatValue(); diff --git a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/CommandPortalConfig.java b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/CommandPortalConfig.java index 67efae08..ac6ee47e 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/CommandPortalConfig.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/config/CommandPortalConfig.java @@ -1,8 +1,8 @@ package com.sekwah.advancedportals.core.serializeddata.config; public class CommandPortalConfig { - public final boolean op = true; - public final boolean console = true; - - public final boolean permsWildcard = true; + public boolean op = true; + public boolean console = true; + public boolean permsWildcard = true; + public boolean enabled = true; } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/CommandTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/CommandTag.java index 58e3732e..cff58fa4 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/CommandTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/CommandTag.java @@ -49,12 +49,7 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation { ActivationData activeData, String[] argData) { return true; } - // TODO: Check if its worth autocompleting an existing command in the - // command tag by - // grabbing all commands in the server - // TODO: Add a warning in console if op/* command is used and tell them to - // use console instead @Override public void postActivated(TagTarget target, PlayerContainer player, ActivationData activationData, String[] argData) { @@ -101,10 +96,19 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation { public boolean created(TagTarget target, PlayerContainer player, String[] argData) { if (argData != null) { + var commandPortals = configRepository.getCommandPortals(); + if(!commandPortals.enabled) { + player.sendMessage(Lang.translate("tag.command.disabled")); + return false; + } for (String command : argData) { char executionCommand = command.charAt(0); return switch (executionCommand) { case '!' -> { + if (!commandPortals.op) { + player.sendMessage(Lang.translate("tag.command.op.disabled")); + yield false; + } if (!player.hasPermission("advancedportals.createportal.commandlevel.op")) { player.sendMessage(Lang.translateInsertVariables("tag.command.nopermission", "OP")); yield false; @@ -112,6 +116,10 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation { yield true; } case '#' -> { + if (!commandPortals.console) { + player.sendMessage(Lang.translate("tag.command.console.disabled")); + yield false; + } if (!player.hasPermission("advancedportals.createportal.commandlevel.console")) { player.sendMessage(Lang.translateInsertVariables("tag.command.nopermission","Console")); yield false; @@ -119,6 +127,10 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation { yield true; } case '^' -> { + if (!commandPortals.permsWildcard) { + player.sendMessage(Lang.translate("tag.command.permswildcard.disabled")); + yield false; + } if (!player.hasPermission("advancedportals.createportal.commandlevel.permswild")) { player.sendMessage(Lang.translateInsertVariables("tag.command.nopermission", "*")); yield false;