From: rnayabed Date: Sat, 20 Mar 2021 12:09:56 +0530 Subject: Register Actions now creates separate action instances, makes the server more accessible for the action api --- Register Actions now creates separate action instances, makes the server more accessible for the action api --- --- 'a/src/main/java/com/stream_pi/server/connection/ClientConnection.java' +++ b/src/main/java/com/stream_pi/server/connection/ClientConnection.java @@ -461,25 +461,10 @@ public class ClientConnection extends Th Location location = new Location(Integer.parseInt(row), Integer.parseInt(col)); - - - Action action = new Action(ID, actionType); - - action.setBgColourHex(bgColorHex); - action.setCurrentIconState(defaultIconState); - - action.setShowDisplayText(isShowDisplayText); - action.setDisplayTextFontColourHex(displayFontColor); - action.setDisplayText(displayText); - action.setDisplayTextAlignment(displayTextAlignment); - - - action.setLocation(location); - String root = r[14]; - action.setParent(root); - action.setDelayBeforeExecuting(Integer.parseInt(r[15])); + int delayBeforeRunning = Integer.parseInt(r[15]); + //client properties @@ -498,71 +483,138 @@ public class ClientConnection extends Th clientProperties.addProperty(property); } - action.setClientProperties(clientProperties); - action.setModuleName(r[4]); - //set up action //action toBeAdded = null; - logger.info("Module nAMe : "+r[4]+" __ "+actionType); + boolean createBasicAction = false; if(actionType == ActionType.NORMAL || actionType == ActionType.TOGGLE) { - ExternalPlugin actionCopy = ExternalPlugins.getInstance().getPluginByModuleName(r[4]); + String moduleName = r[4]; + Version version = new Version(r[3]); + + ExternalPlugin originalAction = ExternalPlugins.getInstance().getPluginByModuleName(moduleName); - if(actionCopy == null) + if(originalAction == null) { - action.setInvalid(true); + createBasicAction = true; } else { - action.setVersion(new Version(r[3])); - - //action.setHelpLink(actionCopy.getHelpLink()); - - if(actionCopy.getVersion().getMajor() != action.getVersion().getMajor()) + if(originalAction.getVersion().getMajor() != version.getMajor()) { - action.setInvalid(true); + createBasicAction = true; } else { - action.setName(actionCopy.getName()); + try + { + ExternalPlugin newPlugin = originalAction.clone(); - ClientProperties finalClientProperties = new ClientProperties(); + newPlugin.setID(ID); + newPlugin.setProfileID(profileID); + newPlugin.setSocketAddressForClient(socket.getRemoteSocketAddress()); + newPlugin.setBgColourHex(bgColorHex); + newPlugin.setCurrentIconState(defaultIconState); - for(Property property : actionCopy.getClientProperties().get()) - { - for(int i = 0;i