forked from Limework/RediSkript
added code
This commit is contained in:
parent
d67568599a
commit
78ca2849e4
19
.idea/$PRODUCT_WORKSPACE_FILE$
Normal file
19
.idea/$PRODUCT_WORKSPACE_FILE$
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
<state key="ProjectJDKs.UI">
|
||||
<settings>
|
||||
<last-edited>1.8</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.21079047" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
</states>
|
||||
</component>
|
||||
</project>
|
16
.idea/artifacts/SkLimework_jar.xml
Normal file
16
.idea/artifacts/SkLimework_jar.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="SkLimework:jar">
|
||||
<output-path>C:/Complie</output-path>
|
||||
<root id="archive" name="SkLimework.jar">
|
||||
<element id="module-output" name="SkLimework" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/commons/commons-pool2/2.6.2/commons-pool2-2.6.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/json/json/20190722/json-20190722.jar" path-in-jar="/" />
|
||||
<element id="directory" name="sourcecode">
|
||||
<element id="module-source" name="SkLimework" />
|
||||
</element>
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/redis/clients/jedis/3.3.0/jedis-3.3.0.jar" path-in-jar="/" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
13
.idea/compiler.xml
Normal file
13
.idea/compiler.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="SkLimework" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
14
.idea/misc.xml
Normal file
14
.idea/misc.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
92
.idea/workspace.xml
Normal file
92
.idea/workspace.xml
Normal file
@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ArtifactsWorkspaceSettings">
|
||||
<artifacts-to-build>
|
||||
<artifact name="SkLimework:jar" />
|
||||
</artifacts-to-build>
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="61139119-6327-48a6-9183-0df6346ed8d8" name="Default Changelist" comment="" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Class" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="MavenImportPreferences">
|
||||
<option name="importingSettings">
|
||||
<MavenImportingSettings>
|
||||
<option name="importAutomatically" value="true" />
|
||||
</MavenImportingSettings>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectId" id="1ZwZbhHZiGU2Gkz7zWjyRIlJngw" />
|
||||
<component name="PropertiesComponent">
|
||||
<property name="GenerateAntBuildDialog.backupFiles" value="true" />
|
||||
<property name="GenerateAntBuildDialog.enableUiFormCompile" value="true" />
|
||||
<property name="GenerateAntBuildDialog.forceTargetJdk" value="true" />
|
||||
<property name="GenerateAntBuildDialog.outputFileNameProperty" value="sklimework" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/../FallBack/plugins/Skript.jar!/" />
|
||||
<property name="project.structure.last.edited" value="Artifacts" />
|
||||
<property name="project.structure.proportion" value="0.15" />
|
||||
<property name="project.structure.side.proportion" value="0.2" />
|
||||
<property name="settings.editor.selected.configurable" value="preferences.lookFeel" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyClassDialog.RECENTS_KEY">
|
||||
<recent name="net.limework.skLimework.elements" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
<list>
|
||||
<RuleState>
|
||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
<RuleState>
|
||||
<option name="name" value="StatusDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration name="Tester" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="net.limework.skLimework.DoNotUse.Tester" />
|
||||
<module name="SkLimework" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="net.limework.skLimework.DoNotUse.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Application.Tester" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration />
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="61139119-6327-48a6-9183-0df6346ed8d8" name="Default Changelist" comment="" />
|
||||
<created>1585752189522</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1585752189522</updated>
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
</project>
|
2
SkLimework.iml
Normal file
2
SkLimework.iml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4" />
|
63
pom.xml
Normal file
63
pom.xml
Normal file
@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>net.limework.addon</groupId>
|
||||
<artifactId>SkLimework</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20190722</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
96
src/main/java/net/limework/skLimework/AddonPlugin.java
Normal file
96
src/main/java/net/limework/skLimework/AddonPlugin.java
Normal file
@ -0,0 +1,96 @@
|
||||
package net.limework.skLimework;
|
||||
|
||||
import ch.njol.skript.Skript;
|
||||
import ch.njol.skript.SkriptAddon;
|
||||
import ch.njol.skript.lang.ExpressionType;
|
||||
import ch.njol.skript.registrations.EventValues;
|
||||
import ch.njol.skript.util.Getter;
|
||||
import net.limework.skLimework.Events.RedisSub;
|
||||
import net.limework.skLimework.Events.onRedisMessage;
|
||||
import net.limework.skLimework.elements.EvtRedis;
|
||||
import net.limework.skLimework.elements.ExprChannel;
|
||||
import net.limework.skLimework.elements.ExprMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
|
||||
import java.beans.Expression;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class AddonPlugin extends JavaPlugin {
|
||||
private AddonPlugin instance;
|
||||
private SkriptAddon addon;
|
||||
private JedisPool jedisPool;
|
||||
private RedisSub redisSub;
|
||||
private ExecutorService service;
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable(){
|
||||
instance = this;
|
||||
this.saveDefaultConfig();
|
||||
addon = Skript.registerAddon(this);
|
||||
try { addon.loadClasses("net.limework.skLimework", "elements");
|
||||
Skript.registerEvent("redis message", EvtRedis.class, onRedisMessage.class, "redis message");
|
||||
Skript.registerExpression(ExprChannel.class, String.class, ExpressionType.SIMPLE, "channel");
|
||||
EventValues.registerEventValue(onRedisMessage.class, String.class, new Getter<String, onRedisMessage>() {
|
||||
@Override
|
||||
public String get(onRedisMessage e) {
|
||||
return e.getChannelName();
|
||||
}
|
||||
}, 0);
|
||||
Skript.registerExpression(ExprMessage.class, String.class, ExpressionType.SIMPLE, "redis message");
|
||||
EventValues.registerEventValue(onRedisMessage.class, String.class, new Getter<String, onRedisMessage>() {
|
||||
@Override
|
||||
public String get(onRedisMessage e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
}, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (IOException e) { e.printStackTrace(); }
|
||||
JedisPoolConfig jconfig = new JedisPoolConfig();
|
||||
jconfig.setMaxTotal(this.getConfig().getInt("Redis.MaxConnections"));
|
||||
jconfig.setMaxIdle(this.getConfig().getInt("Redis.MaxConnections"));
|
||||
jconfig.setMinIdle(1);
|
||||
jedisPool = new JedisPool(jconfig,
|
||||
this.getConfig().getString("Redis.Host"),
|
||||
this.getConfig().getInt("Redis.Port") ,
|
||||
this.getConfig().getInt("Redis.TimeOut"),
|
||||
this.getConfig().getString("Redis.Password"),
|
||||
this.getConfig().getBoolean("Redis.useSSL"));
|
||||
redisSub = new RedisSub(this, jedisPool.getResource(), this.getConfig().getStringList("Channels"));
|
||||
service = Executors.newFixedThreadPool(this.getConfig().getInt("Redis.Threads"));
|
||||
|
||||
Bukkit.getLogger().info("[Govindas limework Addon] was enabled!");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDisable(){
|
||||
redisSub.unSubAndCloseConnection();
|
||||
service.shutdown();
|
||||
try { service.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); } catch (InterruptedException e) { e.printStackTrace(); }
|
||||
jedisPool.close();
|
||||
}
|
||||
|
||||
public AddonPlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public SkriptAddon getAddonInstance() {
|
||||
return addon;
|
||||
}
|
||||
|
||||
public ExecutorService getJedisExecutionService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
public JedisPool getJedisPool() { return jedisPool; }
|
||||
}
|
29
src/main/java/net/limework/skLimework/DoNotUse/Tester.java
Normal file
29
src/main/java/net/limework/skLimework/DoNotUse/Tester.java
Normal file
@ -0,0 +1,29 @@
|
||||
package net.limework.skLimework.DoNotUse;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
import redis.clients.jedis.JedisPubSub;
|
||||
|
||||
public class Tester {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
JedisPoolConfig jconfig = new JedisPoolConfig();
|
||||
jconfig.setMaxTotal(100);
|
||||
jconfig.setMaxIdle(100);
|
||||
jconfig.setMinIdle(1);
|
||||
JedisPool d = new JedisPool(jconfig, "192.168.0.112", 6379, 400, "yHy0d2zdBlRmaSPj3CiBwEv5V3XxBTLTrCsGW7ntBnzhfxPxXJS6Q1aTtR6DSfAtCZr2VxWnsungXHTcF94a4bsWEpGAvjL6XMU");
|
||||
Jedis dd = d.getResource();
|
||||
JSONObject J = new JSONObject();
|
||||
J.put("Message", "something::something::something");
|
||||
int x = 0;
|
||||
while (true) {
|
||||
x++;
|
||||
System.out.println(x);
|
||||
dd.publish("fs", J.toString() );
|
||||
if (x == 1000) break;
|
||||
Thread.sleep(1000);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
40
src/main/java/net/limework/skLimework/Events/RedisSub.java
Normal file
40
src/main/java/net/limework/skLimework/Events/RedisSub.java
Normal file
@ -0,0 +1,40 @@
|
||||
package net.limework.skLimework.Events;
|
||||
|
||||
import net.limework.skLimework.AddonPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.json.JSONObject;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPubSub;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RedisSub extends JedisPubSub {
|
||||
private AddonPlugin plugin;
|
||||
private Jedis j;
|
||||
public RedisSub(AddonPlugin plugin, Jedis j, List<String> channels) {
|
||||
this.plugin = plugin;
|
||||
this.j = j;
|
||||
String[] ss = channels.toArray(new String[0]);
|
||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin,
|
||||
() -> this.j.subscribe(this, ss));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(String channel, String message) {
|
||||
try {
|
||||
JSONObject json = new JSONObject(message);
|
||||
//System.out.println("Message got from channel: "+channel +" and the Message: " +json.toString());
|
||||
plugin.getServer().getPluginManager().callEvent(new onRedisMessage(channel, json.getString("Message")));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Bukkit.getLogger().warning(ChatColor.translateAlternateColorCodes('&', "&2[&aGBot&a] &cI Got a Message that Was empty from channel "+ channel +" Please check your code that you used to send the message. ^ ignore the error."));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void unSubAndCloseConnection(){
|
||||
this.unsubscribe();
|
||||
j.close();
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package net.limework.skLimework.Events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
|
||||
public class onRedisMessage extends Event {
|
||||
private final static HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private String channelName;
|
||||
private String message;
|
||||
|
||||
onRedisMessage(String channelName , String message) {
|
||||
super(true);
|
||||
this.channelName = channelName;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getEventName() {
|
||||
return super.getEventName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public String getChannelName() {
|
||||
return channelName;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package net.limework.skLimework.elements;
|
||||
|
||||
import ch.njol.skript.Skript;
|
||||
import ch.njol.skript.SkriptAPIException;
|
||||
import ch.njol.skript.lang.Effect;
|
||||
import ch.njol.skript.lang.Expression;
|
||||
import ch.njol.skript.lang.SkriptParser;
|
||||
import ch.njol.util.Kleenean;
|
||||
import net.limework.skLimework.AddonPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.Event;
|
||||
import org.json.JSONObject;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
public class EffSendMessage extends Effect {
|
||||
//"hi"
|
||||
static {
|
||||
Skript.registerEffect(EffSendMessage.class, "send redis message to channel %string% with message %string%");
|
||||
}
|
||||
|
||||
|
||||
private Expression<String> channel;
|
||||
private Expression<String> message;
|
||||
|
||||
|
||||
@Override
|
||||
protected void execute(Event event) {
|
||||
AddonPlugin plugin = (AddonPlugin) Bukkit.getPluginManager().getPlugin("SKLimework");
|
||||
String message = this.message.getSingle(event);
|
||||
String channel = this.channel.getSingle(event);
|
||||
if (message == null){//checks if message equals null if true does not execute.
|
||||
Bukkit.getLogger().warning(ChatColor.translateAlternateColorCodes('&', "&2[&aGBot&a] &cMessage Was empty Please check your code."));
|
||||
return;
|
||||
}
|
||||
plugin.getJedisExecutionService().execute(() -> {
|
||||
Jedis j = plugin.getJedisPool().getResource();
|
||||
JSONObject json = new JSONObject();
|
||||
try {
|
||||
json.put("Message", message);
|
||||
json.put("Type", "Skript");
|
||||
j.publish(channel, json.toString());
|
||||
//System.out.println("SkriptSide sent MESSAGE: ["+ message + "] to channel: " + channel + " and json: \n" + json.toString());
|
||||
}catch (Exception e){e.printStackTrace();}
|
||||
j.close();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Event event, boolean b) {
|
||||
return null;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) {
|
||||
this.channel = (Expression<String>) expressions[0];
|
||||
this.message = (Expression<String>) expressions[1];
|
||||
return true;
|
||||
}
|
||||
}
|
32
src/main/java/net/limework/skLimework/elements/EvtRedis.java
Normal file
32
src/main/java/net/limework/skLimework/elements/EvtRedis.java
Normal file
@ -0,0 +1,32 @@
|
||||
package net.limework.skLimework.elements;
|
||||
|
||||
import ch.njol.skript.Skript;
|
||||
import ch.njol.skript.lang.ExpressionType;
|
||||
import ch.njol.skript.lang.Literal;
|
||||
import ch.njol.skript.lang.SkriptEvent;
|
||||
import ch.njol.skript.lang.SkriptParser;
|
||||
import ch.njol.skript.registrations.EventValues;
|
||||
import ch.njol.skript.util.Getter;
|
||||
import net.limework.skLimework.Events.onRedisMessage;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public class EvtRedis extends SkriptEvent {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean init(Literal<?>[] literals, int i, SkriptParser.ParseResult parseResult) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(Event event) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Event event, boolean b) {
|
||||
return "redis message";
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package net.limework.skLimework.elements;
|
||||
|
||||
|
||||
import ch.njol.skript.lang.Expression;
|
||||
import ch.njol.skript.lang.SkriptParser;
|
||||
import ch.njol.skript.lang.util.SimpleExpression;
|
||||
import ch.njol.util.Kleenean;
|
||||
import net.limework.skLimework.Events.onRedisMessage;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public class ExprChannel extends SimpleExpression<String> {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSingle() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends String> getReturnType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Event event, boolean b) {
|
||||
return "redis channel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String[] get(Event e) {
|
||||
if (e instanceof onRedisMessage){
|
||||
return new String[]{((onRedisMessage) e).getChannelName()};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package net.limework.skLimework.elements;
|
||||
|
||||
|
||||
import ch.njol.skript.lang.Expression;
|
||||
import ch.njol.skript.lang.SkriptParser;
|
||||
import ch.njol.skript.lang.util.SimpleExpression;
|
||||
import ch.njol.util.Kleenean;
|
||||
import net.limework.skLimework.Events.onRedisMessage;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public class ExprMessage extends SimpleExpression<String> {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSingle() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends String> getReturnType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Event event, boolean b) {
|
||||
return "redis message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String[] get(Event e) {
|
||||
if (e instanceof onRedisMessage){
|
||||
return new String[]{((onRedisMessage) e).getMessage()};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
13
src/main/resources/config.yml
Normal file
13
src/main/resources/config.yml
Normal file
@ -0,0 +1,13 @@
|
||||
Redis:
|
||||
Password: "yHy0d2zdBlRmaSPj3CiBwEv5V3XxBTLTrCsGW7ntBnzhfxPxXJS6Q1aTtR6DSfAtCZr2VxWnsungXHTcF94a4bsWEpGAvjL6XMU"
|
||||
Host: "127.0.0.1"
|
||||
MaxConnections: 20
|
||||
Threads: 10
|
||||
Port: 6379
|
||||
TimeOut: 40
|
||||
useSSL: true
|
||||
|
||||
Channels:
|
||||
- "Channel1"
|
||||
- "Channel2"
|
||||
- "Channel3"
|
6
src/main/resources/plugin.yml
Normal file
6
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,6 @@
|
||||
main: net.limework.skLimework.AddonPlugin
|
||||
name: SKLimework
|
||||
version: 1.0
|
||||
author: limework.net
|
||||
depend:
|
||||
- Skript
|
BIN
target/classes/META-INF/SkLimework.kotlin_module
Normal file
BIN
target/classes/META-INF/SkLimework.kotlin_module
Normal file
Binary file not shown.
13
target/classes/config.yml
Normal file
13
target/classes/config.yml
Normal file
@ -0,0 +1,13 @@
|
||||
Redis:
|
||||
Password: "yHy0d2zdBlRmaSPj3CiBwEv5V3XxBTLTrCsGW7ntBnzhfxPxXJS6Q1aTtR6DSfAtCZr2VxWnsungXHTcF94a4bsWEpGAvjL6XMU"
|
||||
Host: "127.0.0.1"
|
||||
MaxConnections: 20
|
||||
Threads: 10
|
||||
Port: 6379
|
||||
TimeOut: 40
|
||||
useSSL: true
|
||||
|
||||
Channels:
|
||||
- "Channel1"
|
||||
- "Channel2"
|
||||
- "Channel3"
|
BIN
target/classes/net/limework/skLimework/AddonPlugin$1.class
Normal file
BIN
target/classes/net/limework/skLimework/AddonPlugin$1.class
Normal file
Binary file not shown.
BIN
target/classes/net/limework/skLimework/AddonPlugin$2.class
Normal file
BIN
target/classes/net/limework/skLimework/AddonPlugin$2.class
Normal file
Binary file not shown.
BIN
target/classes/net/limework/skLimework/AddonPlugin.class
Normal file
BIN
target/classes/net/limework/skLimework/AddonPlugin.class
Normal file
Binary file not shown.
BIN
target/classes/net/limework/skLimework/DoNotUse/Tester.class
Normal file
BIN
target/classes/net/limework/skLimework/DoNotUse/Tester.class
Normal file
Binary file not shown.
BIN
target/classes/net/limework/skLimework/Events/RedisSub.class
Normal file
BIN
target/classes/net/limework/skLimework/Events/RedisSub.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
target/classes/net/limework/skLimework/elements/EvtRedis.class
Normal file
BIN
target/classes/net/limework/skLimework/elements/EvtRedis.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
6
target/classes/plugin.yml
Normal file
6
target/classes/plugin.yml
Normal file
@ -0,0 +1,6 @@
|
||||
main: net.limework.skLimework.AddonPlugin
|
||||
name: SKLimework
|
||||
version: 1.0
|
||||
author: limework.net
|
||||
depend:
|
||||
- Skript
|
Loading…
Reference in New Issue
Block a user