moved some stuff and fixed wrong usage

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

View File

@ -36,6 +36,14 @@
</goals>
</execution>
</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>
</plugins>
</build>

View File

@ -5,9 +5,10 @@ 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.core.Managers.RedisManager;
import net.limework.core.Skript.elements.EvtRedis;
import net.limework.core.Skript.elements.ExprChannel;
import net.limework.core.managers.RedisManager;
import net.limework.core.skript.elements.EvtRedis;
import net.limework.core.skript.elements.ExprChannel;
import net.limework.core.skript.elements.ExprMessage;
import net.limework.core.events.RedisMessageEvent;
import org.bukkit.plugin.java.JavaPlugin;
@ -49,7 +50,7 @@ public class LimeworkSpigotCore extends JavaPlugin {
return e.getChannelName();
}
}, 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>() {
@Override
public String get(RedisMessageEvent e) {
@ -65,6 +66,8 @@ public class LimeworkSpigotCore extends JavaPlugin {
}
public RedisManager getRm() {
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.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 net.limework.core.LimeworkSpigotCore;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.Event;
import org.json.JSONObject;
import redis.clients.jedis.BinaryJedis;
import redis.clients.jedis.exceptions.JedisConnectionException;
import java.nio.charset.StandardCharsets;
@ -29,7 +27,7 @@ public class EffSendMessage extends Effect {
@Override
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 channel = this.channel.getSingle(event);
if (message == null) {//checks if message equals null if true does not execute.
@ -37,15 +35,15 @@ public class EffSendMessage extends Effect {
return;
}
assert plugin != null;
plugin.getJedisExecutionService().execute(() -> {
BinaryJedis j = plugin.getJedisPool().getResource();
plugin.getRm().getRedisService().execute(() -> {
BinaryJedis j = plugin.getRm().getJedisPool().getResource();
JSONObject json = new JSONObject();
json.put("Message", message);
json.put("Type", "Skript");
json.put("Date", System.nanoTime()); //for unique string every time & PING calculations
byte[] msg;
if (plugin.isEncryptionEnabled()) {
msg = plugin.encrypt(json.toString());
if (plugin.getRm().getEncryption().isEncryptionEnabled()) {
msg = plugin.getRm().getEncryption().encrypt(json.toString());
} else {
msg = message.getBytes(StandardCharsets.UTF_8);
}
@ -60,6 +58,7 @@ public class EffSendMessage extends Effect {
public String toString(Event event, boolean b) {
return null;
}
@SuppressWarnings("unchecked")
@Override
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.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;

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

View File

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

View File

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