moved some stuff and fixed wrong usage

This commit is contained in:
ham1255 2020-06-30 11:45:14 +04:00
parent e1b051623b
commit 8f951757bc
9 changed files with 36 additions and 29 deletions

View File

@ -36,6 +36,14 @@
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<outputDirectory>${project.basedir}/compile</outputDirectory>
</configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>

View File

@ -5,9 +5,10 @@ import ch.njol.skript.SkriptAddon;
import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.registrations.EventValues; import ch.njol.skript.registrations.EventValues;
import ch.njol.skript.util.Getter; import ch.njol.skript.util.Getter;
import net.limework.core.Managers.RedisManager; import net.limework.core.managers.RedisManager;
import net.limework.core.Skript.elements.EvtRedis; import net.limework.core.skript.elements.EvtRedis;
import net.limework.core.Skript.elements.ExprChannel; import net.limework.core.skript.elements.ExprChannel;
import net.limework.core.skript.elements.ExprMessage;
import net.limework.core.events.RedisMessageEvent; import net.limework.core.events.RedisMessageEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -49,7 +50,7 @@ public class LimeworkSpigotCore extends JavaPlugin {
return e.getChannelName(); return e.getChannelName();
} }
}, 0); }, 0);
Skript.registerExpression(net.limework.skLimework.elements.ExprMessage.class, String.class, ExpressionType.SIMPLE, "redis message"); Skript.registerExpression(ExprMessage.class, String.class, ExpressionType.SIMPLE, "redis message");
EventValues.registerEventValue(RedisMessageEvent.class, String.class, new Getter<String, RedisMessageEvent>() { EventValues.registerEventValue(RedisMessageEvent.class, String.class, new Getter<String, RedisMessageEvent>() {
@Override @Override
public String get(RedisMessageEvent e) { public String get(RedisMessageEvent e) {
@ -65,6 +66,8 @@ public class LimeworkSpigotCore extends JavaPlugin {
} }
public RedisManager getRm() { public RedisManager getRm() {
return rm; return rm;
} }

View File

@ -1,18 +1,16 @@
package net.limework.skLimework.elements; package net.limework.core.skript.elements;
import ch.njol.skript.Skript; import ch.njol.skript.Skript;
import ch.njol.skript.SkriptAPIException;
import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.SkriptParser;
import ch.njol.util.Kleenean; import ch.njol.util.Kleenean;
import net.limework.skLimework.AddonPlugin; import net.limework.core.LimeworkSpigotCore;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; 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.BinaryJedis; import redis.clients.jedis.BinaryJedis;
import redis.clients.jedis.exceptions.JedisConnectionException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -29,7 +27,7 @@ public class EffSendMessage extends Effect {
@Override @Override
protected void execute(Event event) { protected void execute(Event event) {
AddonPlugin plugin = (AddonPlugin) Bukkit.getPluginManager().getPlugin("SKLimework"); LimeworkSpigotCore plugin = (LimeworkSpigotCore) Bukkit.getPluginManager().getPlugin("SKLimework");
String message = this.message.getSingle(event); String message = this.message.getSingle(event);
String channel = this.channel.getSingle(event); String channel = this.channel.getSingle(event);
if (message == null) {//checks if message equals null if true does not execute. if (message == null) {//checks if message equals null if true does not execute.
@ -37,15 +35,15 @@ public class EffSendMessage extends Effect {
return; return;
} }
assert plugin != null; assert plugin != null;
plugin.getJedisExecutionService().execute(() -> { plugin.getRm().getRedisService().execute(() -> {
BinaryJedis j = plugin.getJedisPool().getResource(); BinaryJedis j = plugin.getRm().getJedisPool().getResource();
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("Message", message); json.put("Message", message);
json.put("Type", "Skript"); json.put("Type", "Skript");
json.put("Date", System.nanoTime()); //for unique string every time & PING calculations json.put("Date", System.nanoTime()); //for unique string every time & PING calculations
byte[] msg; byte[] msg;
if (plugin.isEncryptionEnabled()) { if (plugin.getRm().getEncryption().isEncryptionEnabled()) {
msg = plugin.encrypt(json.toString()); msg = plugin.getRm().getEncryption().encrypt(json.toString());
} else { } else {
msg = message.getBytes(StandardCharsets.UTF_8); msg = message.getBytes(StandardCharsets.UTF_8);
} }
@ -60,6 +58,7 @@ public class EffSendMessage extends Effect {
public String toString(Event event, boolean b) { public String toString(Event event, boolean b) {
return null; return null;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) { public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) {

View File

@ -1,4 +1,4 @@
package net.limework.core.Skript.elements; package net.limework.core.skript.elements;
; ;
import ch.njol.skript.lang.Literal; import ch.njol.skript.lang.Literal;
import ch.njol.skript.lang.SkriptEvent; import ch.njol.skript.lang.SkriptEvent;

View File

@ -1,4 +1,4 @@
package net.limework.core.Skript.elements; package net.limework.core.skript.elements;
import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.Expression;

View File

@ -1,11 +1,11 @@
package net.limework.skLimework.elements; package net.limework.core.skript.elements;
import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean; import ch.njol.util.Kleenean;
import net.limework.skLimework.Events.onRedisMessage; import net.limework.core.events.RedisMessageEvent;
import org.bukkit.event.Event; import org.bukkit.event.Event;
public class ExprMessage extends SimpleExpression<String> { public class ExprMessage extends SimpleExpression<String> {
@ -34,8 +34,8 @@ public class ExprMessage extends SimpleExpression<String> {
@Override @Override
protected String[] get(Event e) { protected String[] get(Event e) {
if (e instanceof onRedisMessage){ if (e instanceof RedisMessageEvent){
return new String[]{((onRedisMessage) e).getMessage()}; return new String[]{((RedisMessageEvent) e).getMessage()};
} }
return null; return null;
} }

View File

@ -1,6 +1,5 @@
package net.limework.core.events; package net.limework.core.events;
import net.limework.skLimework.AddonPlugin;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -15,8 +14,6 @@ public class RedisMessageEvent extends Event {
public RedisMessageEvent(String channelName , String message) { public RedisMessageEvent(String channelName , String message) {
super(true); super(true);
this.channelName = channelName; this.channelName = channelName;
AddonPlugin instance = (AddonPlugin) Bukkit.getPluginManager().getPlugin("SKLimework");
assert instance != null;
this.message = message; this.message = message;
} }

View File

@ -1,4 +1,4 @@
package net.limework.core.Managers; package net.limework.core.managers;
import net.limework.Data.Encryption; import net.limework.Data.Encryption;
import net.limework.core.LimeworkSpigotCore; import net.limework.core.LimeworkSpigotCore;

View File

@ -1,6 +1,6 @@
main: net.limework.skLimework.AddonPlugin main: net.limework.core.LimeworkSpigotCore
name: SKLimework name: LimeworkSpigotCore
version: 1.0 version: 1.0.0
author: limework.net author: limework.net
depend: softdepend:
- Skript - Skript