mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-22 20:28:00 +00:00
create constructor with plugin parameter in RedisClass
This commit is contained in:
parent
44f9a0945d
commit
b15b9dbb96
@ -1,6 +1,7 @@
|
|||||||
package com.imaginarycode.minecraft.redisbungee.internal.util;
|
package com.imaginarycode.minecraft.redisbungee.internal.util;
|
||||||
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
|
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.internal.RedisBungeePlugin;
|
||||||
import com.imaginarycode.minecraft.redisbungee.internal.summoners.ClusterJedisSummoner;
|
import com.imaginarycode.minecraft.redisbungee.internal.summoners.ClusterJedisSummoner;
|
||||||
import com.imaginarycode.minecraft.redisbungee.internal.summoners.JedisSummoner;
|
import com.imaginarycode.minecraft.redisbungee.internal.summoners.JedisSummoner;
|
||||||
import com.imaginarycode.minecraft.redisbungee.internal.summoners.Summoner;
|
import com.imaginarycode.minecraft.redisbungee.internal.summoners.Summoner;
|
||||||
@ -14,6 +15,8 @@ public abstract class RedisTask<V> implements Runnable, Callable<V> {
|
|||||||
private final Summoner<?> summoner;
|
private final Summoner<?> summoner;
|
||||||
private final RedisBungeeAPI api;
|
private final RedisBungeeAPI api;
|
||||||
|
|
||||||
|
private RedisBungeePlugin<?> plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public V call() throws Exception {
|
public V call() throws Exception {
|
||||||
return execute();
|
return execute();
|
||||||
@ -24,6 +27,12 @@ public abstract class RedisTask<V> implements Runnable, Callable<V> {
|
|||||||
this.summoner = api.getSummoner();
|
this.summoner = api.getSummoner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RedisTask(RedisBungeePlugin<?> plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.api = plugin.getApi();
|
||||||
|
this.summoner = api.getSummoner();
|
||||||
|
}
|
||||||
|
|
||||||
public abstract V singleJedisTask(Jedis jedis);
|
public abstract V singleJedisTask(Jedis jedis);
|
||||||
|
|
||||||
public abstract V clusterJedisTask(JedisCluster jedisCluster);
|
public abstract V clusterJedisTask(JedisCluster jedisCluster);
|
||||||
@ -47,4 +56,10 @@ public abstract class RedisTask<V> implements Runnable, Callable<V> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RedisBungeePlugin<?> getPlugin() {
|
||||||
|
if (plugin == null) {
|
||||||
|
throw new NullPointerException("Plugin is null in the task");
|
||||||
|
}
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user