Check if error will occure when redis fails

This commit is contained in:
ham1255 2020-05-10 21:44:10 +04:00
parent 80f65ebb8a
commit bcf7f08d81
7 changed files with 92 additions and 17 deletions

View File

@ -1,6 +1,6 @@
<component name="ArtifactManager"> <component name="ArtifactManager">
<artifact type="jar" name="SkLimework:jar"> <artifact type="jar" name="SkLimework:jar">
<output-path>C:/Complie</output-path> <output-path>$PROJECT_DIR$/../FallBack/plugins</output-path>
<root id="archive" name="SkLimework.jar"> <root id="archive" name="SkLimework.jar">
<element id="module-output" name="SkLimework" /> <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$/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar" path-in-jar="/" />

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -6,7 +6,15 @@
</artifacts-to-build> </artifacts-to-build>
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="61139119-6327-48a6-9183-0df6346ed8d8" name="Default Changelist" comment="" /> <list default="true" id="61139119-6327-48a6-9183-0df6346ed8d8" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/artifacts/SkLimework_jar.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/artifacts/SkLimework_jar.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/limework/skLimework/Events/RedisSub.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/limework/skLimework/Events/RedisSub.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/limework/skLimework/elements/EffSendMessage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/limework/skLimework/elements/EffSendMessage.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/config.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/config.yml" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -20,6 +28,9 @@
</list> </list>
</option> </option>
</component> </component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="MavenImportPreferences"> <component name="MavenImportPreferences">
<option name="importingSettings"> <option name="importingSettings">
<MavenImportingSettings> <MavenImportingSettings>
@ -33,7 +44,8 @@
<property name="GenerateAntBuildDialog.enableUiFormCompile" value="true" /> <property name="GenerateAntBuildDialog.enableUiFormCompile" value="true" />
<property name="GenerateAntBuildDialog.forceTargetJdk" value="true" /> <property name="GenerateAntBuildDialog.forceTargetJdk" value="true" />
<property name="GenerateAntBuildDialog.outputFileNameProperty" value="sklimework" /> <property name="GenerateAntBuildDialog.outputFileNameProperty" value="sklimework" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../FallBack/plugins/Skript.jar!/" /> <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../FallBack/plugins" />
<property name="project.structure.last.edited" value="Artifacts" /> <property name="project.structure.last.edited" value="Artifacts" />
<property name="project.structure.proportion" value="0.15" /> <property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" /> <property name="project.structure.side.proportion" value="0.2" />
@ -89,4 +101,17 @@
</task> </task>
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State>
<option name="COLUMN_ORDER" />
</State>
</value>
</entry>
</map>
</option>
</component>
</project> </project>

44
pom.xml
View File

@ -6,8 +6,8 @@
<groupId>net.limework.addon</groupId> <groupId>net.limework.addon</groupId>
<artifactId>SkLimework</artifactId> <artifactId>SkLimework</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0.0</version>
<packaging>jar</packaging>> <packaging>jar</packaging>
<build> <build>
<plugins> <plugins>
@ -18,29 +18,57 @@
<configuration> <configuration>
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
<encoding>UTF-8</encoding>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
<repositories> <repositories>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository> </repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>PaperMC</id>
<url>https://repo.destroystokyo.com/repository/maven-public/</url>
</repository>
<repository>
<id>sk89q</id>
<url>http://maven.sk89q.com/repo</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>com.github.skriptlang</groupId>
<artifactId>spigot-api</artifactId> <artifactId>Skript</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version> <version>2.4.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.spigotmc</groupId>
<artifactId>bukkit</artifactId> <artifactId>spigot-api</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version> <version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -6,6 +6,7 @@ import org.bukkit.ChatColor;
import org.json.JSONObject; import org.json.JSONObject;
import redis.clients.jedis.Jedis; import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPubSub; import redis.clients.jedis.JedisPubSub;
import redis.clients.jedis.exceptions.JedisConnectionException;
import java.util.List; import java.util.List;
@ -17,7 +18,17 @@ public class RedisSub extends JedisPubSub {
this.j = j; this.j = j;
String[] ss = channels.toArray(new String[0]); String[] ss = channels.toArray(new String[0]);
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, plugin.getServer().getScheduler().runTaskAsynchronously(plugin,
() -> this.j.subscribe(this, ss)); () -> {
try{
this.j.subscribe(this, ss);
} catch (JedisConnectionException je){
this.unSubAndCloseConnection();
Bukkit.broadcastMessage("Redis Went down!");
}
});
} }
@Override @Override

View File

@ -12,6 +12,7 @@ import org.bukkit.ChatColor;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.json.JSONObject; import org.json.JSONObject;
import redis.clients.jedis.Jedis; import redis.clients.jedis.Jedis;
import redis.clients.jedis.exceptions.JedisConnectionException;
public class EffSendMessage extends Effect { public class EffSendMessage extends Effect {
//"hi" //"hi"
@ -34,7 +35,11 @@ public class EffSendMessage extends Effect {
return; return;
} }
plugin.getJedisExecutionService().execute(() -> { plugin.getJedisExecutionService().execute(() -> {
Jedis j = plugin.getJedisPool().getResource(); Jedis j;
try {j = plugin.getJedisPool().getResource();}catch (JedisConnectionException e){
Bukkit.broadcastMessage("Redis is down!!! dont send messages");
return;
}
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
try { try {
json.put("Message", message); json.put("Message", message);

View File

@ -4,7 +4,7 @@ Redis:
MaxConnections: 20 MaxConnections: 20
Threads: 10 Threads: 10
Port: 6379 Port: 6379
TimeOut: 40 TimeOut: 40000
useSSL: true useSSL: true
Channels: Channels: