diff --git a/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java b/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java index 2216cd70..ea00a4eb 100644 --- a/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java +++ b/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java @@ -14,6 +14,7 @@ import com.sekwah.advancedportals.core.util.Config; import com.sekwah.advancedportals.core.util.DataStorage; import com.sekwah.advancedportals.core.util.InfoLogger; import com.sekwah.advancedportals.core.util.Lang; +import com.sekwah.advancedportals.coreconnector.ConnectorDataCollector; import com.sekwah.advancedportals.coreconnector.command.CommandRegister; public class AdvancedPortalsCore { @@ -23,6 +24,7 @@ public class AdvancedPortalsCore { private final DataStorage dataStorage; private final InfoLogger infoLogger; private final int mcMinorVer; + private final ConnectorDataCollector dataCollector; private WarpEffectRegistry warpEffectRegistry; private TagRegistry portalTagRegistry; @@ -47,11 +49,13 @@ public class AdvancedPortalsCore { * @param commandRegister - Handles the command registry, different on each platform * @param mcVer Minecraft version e.g. 1.12.2 */ - public AdvancedPortalsCore(DataStorage dataStorage, InfoLogger infoLogger, CommandRegister commandRegister, int[] mcVer) { + public AdvancedPortalsCore(DataStorage dataStorage, InfoLogger infoLogger, CommandRegister commandRegister, + ConnectorDataCollector dataCollector, int[] mcVer) { this.dataStorage = dataStorage; this.infoLogger = infoLogger; this.instance = this; this.commandRegister = commandRegister; + this.dataCollector = dataCollector; this.mcMinorVer = this.checkMcVer(mcVer); this.onEnable(); @@ -181,6 +185,10 @@ public class AdvancedPortalsCore { return instance.infoLogger; } + public static ConnectorDataCollector getDataCollector() { + return instance.dataCollector; + } + public static CoreListeners getCoreListeners() { return instance.coreListeners; } diff --git a/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java b/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java index ad873b93..6e2c58bf 100644 --- a/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java +++ b/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java @@ -157,7 +157,15 @@ public class PortalManager { AdvancedPortal portal = new AdvancedPortal(maxLoc, minLoc); for(DataTag portalTag : tags) { if(portalTag.NAME.equalsIgnoreCase("triggerblock")) { - portal.setTriggerBlocks(portalTag.VALUE.split(",")); + ArrayList triggers = new ArrayList<>(); + for(String trigger : portalTag.VALUE.split(",")) { + if(AdvancedPortalsCore.getDataCollector().materialExists(trigger)) { + triggers.add(trigger.toLowerCase()); + } + } + if(triggers.size() != 0) { + portal.setTriggerBlocks(triggers.toArray(new String[0])); + } } else { portal.setArg(portalTag); diff --git a/src/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java b/src/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java index abb5918e..e488e09e 100644 --- a/src/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java +++ b/src/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java @@ -50,11 +50,9 @@ public class CreateDestiSubCommand extends CreateSubCommand implements SubComman } protected String getTag(String arg) { - ArrayList tags = AdvancedPortalsCore.getDestinationTagRegistry().getTags(); - for(String tag : tags) { - if(arg.startsWith(tag + ":")) { - return tag; - } + int splitLoc = arg.indexOf(":"); + if(splitLoc != -1) { + return arg.substring(0,splitLoc + 1); } return null; } diff --git a/src/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java b/src/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java index e1f9aafe..e778ee47 100644 --- a/src/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java +++ b/src/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java @@ -26,6 +26,7 @@ public class CreatePortalSubCommand extends CreateSubCommand implements SubComma } ArrayList portalTags = this.getTagsFromArgs(args); try { + System.out.println(Arrays.toString(portalTags.toArray())); AdvancedPortal portal = AdvancedPortalsCore.getPortalManager().createPortal(args[1], player, portalTags); if(portal != null) { sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translateColor("command.create.complete")); @@ -46,11 +47,9 @@ public class CreatePortalSubCommand extends CreateSubCommand implements SubComma } protected String getTag(String arg) { - ArrayList tags = AdvancedPortalsCore.getPortalTagRegistry().getTags(); - for(String tag : tags) { - if(arg.startsWith(tag + ":")) { - return tag; - } + int splitLoc = arg.indexOf(":"); + if(splitLoc != -1) { + return arg.substring(0,splitLoc + 1); } return null; } diff --git a/src/com/sekwah/advancedportals/coreconnector/ConnectorDataCollector.java b/src/com/sekwah/advancedportals/coreconnector/ConnectorDataCollector.java index 687c0eb0..68416271 100644 --- a/src/com/sekwah/advancedportals/coreconnector/ConnectorDataCollector.java +++ b/src/com/sekwah/advancedportals/coreconnector/ConnectorDataCollector.java @@ -1,7 +1,9 @@ package com.sekwah.advancedportals.coreconnector; +/** + * Gets info from the specific implementation + */ public class ConnectorDataCollector { - public boolean materialExists(String materialName) { return false; }