From bae2d970bbd4c1af16f3133bcf4a8bbe113c4988 Mon Sep 17 00:00:00 2001 From: mohammed jasem alaajel <34905970+ham1255@users.noreply.github.com> Date: Tue, 16 Mar 2021 18:05:20 +0400 Subject: [PATCH] added jedis stuff --- .../rediskript/skript/elements/ExprJedis.java | 46 +++++++++++++++++++ .../rediskript/skript/elements/Types.java | 33 +++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 src/main/java/net/limework/rediskript/skript/elements/ExprJedis.java create mode 100644 src/main/java/net/limework/rediskript/skript/elements/Types.java diff --git a/src/main/java/net/limework/rediskript/skript/elements/ExprJedis.java b/src/main/java/net/limework/rediskript/skript/elements/ExprJedis.java new file mode 100644 index 0000000..a7f208a --- /dev/null +++ b/src/main/java/net/limework/rediskript/skript/elements/ExprJedis.java @@ -0,0 +1,46 @@ +package net.limework.rediskript.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 org.bukkit.event.Event; +import org.eclipse.jdt.annotation.Nullable; +import redis.clients.jedis.Jedis; + +@SuppressWarnings("unchecked") +public class ExprJedis extends SimpleExpression { + + static { + + } + + private Jedis jedis; + + + @Nullable + @Override + protected Jedis[] get(Event event) { + return new Jedis[]{jedis}; + } + + @Override + public boolean isSingle() { + return true; + } + + @Override + public Class getReturnType() { + return Jedis.class; + } + + @Override + public String toString(@Nullable Event event, boolean b) { + return null; + } + + @Override + public boolean init(Expression[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) { + return false; + } +} diff --git a/src/main/java/net/limework/rediskript/skript/elements/Types.java b/src/main/java/net/limework/rediskript/skript/elements/Types.java new file mode 100644 index 0000000..9d41b07 --- /dev/null +++ b/src/main/java/net/limework/rediskript/skript/elements/Types.java @@ -0,0 +1,33 @@ +package net.limework.rediskript.skript.elements; + +import ch.njol.skript.classes.ClassInfo; +import ch.njol.skript.classes.Parser; +import ch.njol.skript.registrations.Classes; +import redis.clients.jedis.Jedis; + +public class Types { + static { + Classes.registerClass( + new ClassInfo<>(Jedis.class, "jedis") + .user("JedisInstances?") + .parser(new Parser() { + @Override + public String toString(Jedis t, int i) { + return t.toString(); + } + + @Override + public String toVariableNameString(Jedis t) { + return t.toString(); + } + + @Override + public String getVariableNamePattern() { + return "jedis:+"; + } + })); + + } + + +}