mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-22 20:28:00 +00:00
api changes in events, move Listener serialization into Util class
This commit is contained in:
parent
fdd537b276
commit
80a4791d12
@ -16,7 +16,7 @@ Cluster mode compatibility in version 0.8.0:
|
|||||||
|
|
||||||
If you are using static legacy method `RedisBungee#getPool()` it might fail in:
|
If you are using static legacy method `RedisBungee#getPool()` it might fail in:
|
||||||
* if Cluster mode is enabled, due fact its Uses different classes
|
* if Cluster mode is enabled, due fact its Uses different classes
|
||||||
* JedisPool compatibility mode is disabled in the config due fact project internally switched to JedisPooled than Jedis
|
* if JedisPool compatibility mode is disabled in the config due fact project internally switched to JedisPooled than Jedis
|
||||||
|
|
||||||
## notes
|
## notes
|
||||||
If you are looking to use Original RedisBungee without a change to internals,
|
If you are looking to use Original RedisBungee without a change to internals,
|
||||||
|
@ -31,13 +31,18 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
protected final List<String> reservedChannels;
|
protected final List<String> reservedChannels;
|
||||||
|
|
||||||
AbstractRedisBungeeAPI(RedisBungeePlugin<?> plugin) {
|
AbstractRedisBungeeAPI(RedisBungeePlugin<?> plugin) {
|
||||||
|
// this does make sure that no one can place first initiated API class.
|
||||||
|
if (abstractRedisBungeeAPI == null) {
|
||||||
abstractRedisBungeeAPI = this;
|
abstractRedisBungeeAPI = this;
|
||||||
this.plugin = plugin;
|
}
|
||||||
this.reservedChannels = ImmutableList.of(
|
this.reservedChannels = ImmutableList.of(
|
||||||
"redisbungee-allservers",
|
"redisbungee-allservers",
|
||||||
"redisbungee-" + plugin.getConfiguration().getProxyId(),
|
"redisbungee-" + plugin.getConfiguration().getProxyId(),
|
||||||
"redisbungee-data"
|
"redisbungee-data"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.plugin = plugin;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,6 +64,7 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
public final long getLastOnline(@NonNull UUID player) {
|
public final long getLastOnline(@NonNull UUID player) {
|
||||||
return plugin.getDataManager().getLastOnline(player);
|
return plugin.getDataManager().getLastOnline(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the server where the specified player is playing. This function also deals with the case of local players
|
* Get the server where the specified player is playing. This function also deals with the case of local players
|
||||||
* as well, and will return local information on them.
|
* as well, and will return local information on them.
|
||||||
@ -361,9 +367,9 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
* This gives you instance of Jedis
|
* This gives you instance of Jedis
|
||||||
*
|
*
|
||||||
* @return {@link Jedis}
|
* @return {@link Jedis}
|
||||||
* @since 0.7.0
|
|
||||||
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
||||||
* @see #getJedisPool()
|
* @see #getJedisPool()
|
||||||
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
public Jedis requestJedis() {
|
public Jedis requestJedis() {
|
||||||
if (getMode() == RedisBungeeMode.SINGLE) {
|
if (getMode() == RedisBungeeMode.SINGLE) {
|
||||||
@ -377,9 +383,9 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
* This gets Redis Bungee {@link JedisPool}
|
* This gets Redis Bungee {@link JedisPool}
|
||||||
*
|
*
|
||||||
* @return {@link JedisPool}
|
* @return {@link JedisPool}
|
||||||
* @since 0.6.5
|
|
||||||
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
||||||
* @throws IllegalStateException if JedisPool compatibility mode is disabled in the config
|
* @throws IllegalStateException if JedisPool compatibility mode is disabled in the config
|
||||||
|
* @since 0.6.5
|
||||||
*/
|
*/
|
||||||
public JedisPool getJedisPool() {
|
public JedisPool getJedisPool() {
|
||||||
if (getMode() == RedisBungeeMode.SINGLE) {
|
if (getMode() == RedisBungeeMode.SINGLE) {
|
||||||
@ -398,8 +404,8 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
* WARNING DO NOT USE {@link JedisCluster#close()} it will break the functionally
|
* WARNING DO NOT USE {@link JedisCluster#close()} it will break the functionally
|
||||||
*
|
*
|
||||||
* @return {@link redis.clients.jedis.JedisCluster}
|
* @return {@link redis.clients.jedis.JedisCluster}
|
||||||
* @since 0.8.0
|
|
||||||
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#CLUSTER}
|
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#CLUSTER}
|
||||||
|
* @since 0.8.0
|
||||||
*/
|
*/
|
||||||
public JedisCluster requestClusterJedis() {
|
public JedisCluster requestClusterJedis() {
|
||||||
if (getMode() == RedisBungeeMode.CLUSTER) {
|
if (getMode() == RedisBungeeMode.CLUSTER) {
|
||||||
@ -414,8 +420,8 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
* WARNING: DO NOT USE {@link redis.clients.jedis.JedisPooled#close()} it will break the functionally
|
* WARNING: DO NOT USE {@link redis.clients.jedis.JedisPooled#close()} it will break the functionally
|
||||||
*
|
*
|
||||||
* @return {@link redis.clients.jedis.JedisPooled}
|
* @return {@link redis.clients.jedis.JedisPooled}
|
||||||
* @since 0.8.0
|
|
||||||
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
||||||
|
* @since 0.8.0
|
||||||
*/
|
*/
|
||||||
public JedisCluster requestJedisPooled() {
|
public JedisCluster requestJedisPooled() {
|
||||||
if (getMode() == RedisBungeeMode.SINGLE) {
|
if (getMode() == RedisBungeeMode.SINGLE) {
|
||||||
|
@ -171,7 +171,7 @@ public abstract class AbstractDataManager<P, PL, PD, PS> {
|
|||||||
ipCache.put(message1.getTarget(), message1.getPayload().getAddress());
|
ipCache.put(message1.getTarget(), message1.getPayload().getAddress());
|
||||||
plugin.executeAsync(() -> {
|
plugin.executeAsync(() -> {
|
||||||
Object event = plugin.createPlayerJoinedNetworkEvent(message1.getTarget());
|
Object event = plugin.createPlayerJoinedNetworkEvent(message1.getTarget());
|
||||||
plugin.callEvent(event);
|
plugin.fireEvent(event);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case LEAVE:
|
case LEAVE:
|
||||||
@ -181,7 +181,7 @@ public abstract class AbstractDataManager<P, PL, PD, PS> {
|
|||||||
lastOnlineCache.put(message2.getTarget(), message2.getPayload().getTimestamp());
|
lastOnlineCache.put(message2.getTarget(), message2.getPayload().getTimestamp());
|
||||||
plugin.executeAsync(() -> {
|
plugin.executeAsync(() -> {
|
||||||
Object event = plugin.createPlayerLeftNetworkEvent(message2.getTarget());
|
Object event = plugin.createPlayerLeftNetworkEvent(message2.getTarget());
|
||||||
plugin.callEvent(event);
|
plugin.fireEvent(event);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case SERVER_CHANGE:
|
case SERVER_CHANGE:
|
||||||
@ -189,8 +189,8 @@ public abstract class AbstractDataManager<P, PL, PD, PS> {
|
|||||||
}.getType());
|
}.getType());
|
||||||
serverCache.put(message3.getTarget(), message3.getPayload().getServer());
|
serverCache.put(message3.getTarget(), message3.getPayload().getServer());
|
||||||
plugin.executeAsync(() -> {
|
plugin.executeAsync(() -> {
|
||||||
Object event = plugin.createPlayerChangedNetworkEvent(message3.getTarget(), message3.getPayload().getOldServer(), message3.getPayload().getServer());
|
Object event = plugin.createPlayerChangedServerNetworkEvent(message3.getTarget(), message3.getPayload().getOldServer(), message3.getPayload().getServer());
|
||||||
plugin.callEvent(event);
|
plugin.fireEvent(event);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case KICK:
|
case KICK:
|
||||||
|
@ -38,34 +38,6 @@ public abstract class AbstractRedisBungeeListener<LE, PLE, PD, SC, PP, PM, PS> {
|
|||||||
|
|
||||||
public abstract void onPluginMessage(PM event);
|
public abstract void onPluginMessage(PM event);
|
||||||
|
|
||||||
protected void serializeMultiset(Multiset<String> collection, ByteArrayDataOutput output) {
|
|
||||||
output.writeInt(collection.elementSet().size());
|
|
||||||
for (Multiset.Entry<String> entry : collection.entrySet()) {
|
|
||||||
output.writeUTF(entry.getElement());
|
|
||||||
output.writeInt(entry.getCount());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("SameParameterValue")
|
|
||||||
protected void serializeMultimap(Multimap<String, String> collection, boolean includeNames, ByteArrayDataOutput output) {
|
|
||||||
output.writeInt(collection.keySet().size());
|
|
||||||
for (Map.Entry<String, Collection<String>> entry : collection.asMap().entrySet()) {
|
|
||||||
output.writeUTF(entry.getKey());
|
|
||||||
if (includeNames) {
|
|
||||||
serializeCollection(entry.getValue(), output);
|
|
||||||
} else {
|
|
||||||
output.writeInt(entry.getValue().size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void serializeCollection(Collection<?> collection, ByteArrayDataOutput output) {
|
|
||||||
output.writeInt(collection.size());
|
|
||||||
for (Object o : collection) {
|
|
||||||
output.writeUTF(o.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void onPubSubMessage(PS event);
|
public abstract void onPubSubMessage(PS event);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
package com.imaginarycode.minecraft.redisbungee.api;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Since each platform have their own events' implementation for example Bungeecord events extends Event while velocity don't
|
|
||||||
*
|
|
||||||
* @author Ham1255
|
|
||||||
* @since 0.7.0
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface EventsPlatform {
|
|
||||||
|
|
||||||
Object createPlayerChangedNetworkEvent(UUID uuid, String previousServer, String server);
|
|
||||||
|
|
||||||
Object createPlayerJoinedNetworkEvent(UUID uuid);
|
|
||||||
|
|
||||||
Object createPlayerLeftNetworkEvent(UUID uuid);
|
|
||||||
|
|
||||||
Object createPubSubEvent(String channel, String message);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -3,8 +3,6 @@ package com.imaginarycode.minecraft.redisbungee.api;
|
|||||||
|
|
||||||
import redis.clients.jedis.JedisPubSub;
|
import redis.clients.jedis.JedisPubSub;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
|
|
||||||
public class JedisPubSubHandler extends JedisPubSub {
|
public class JedisPubSubHandler extends JedisPubSub {
|
||||||
|
|
||||||
@ -21,7 +19,7 @@ public class JedisPubSubHandler extends JedisPubSub {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Object event = plugin.createPubSubEvent(s, s2);
|
Object event = plugin.createPubSubEvent(s, s2);
|
||||||
plugin.callEvent(event);
|
plugin.fireEvent(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import com.google.common.collect.ImmutableMultimap;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.imaginarycode.minecraft.redisbungee.AbstractRedisBungeeAPI;
|
import com.imaginarycode.minecraft.redisbungee.AbstractRedisBungeeAPI;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.config.ConfigLoader;
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.EventsPlatform;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisTask;
|
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisTask;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.util.RedisUtil;
|
import com.imaginarycode.minecraft.redisbungee.api.util.RedisUtil;
|
||||||
@ -24,12 +24,12 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Class has all internal methods needed by every redis bungee plugin, and it can be used to implement another platforms than bungeecord
|
* This Class has all internal methods needed by every redis bungee plugin, and it can be used to implement another platforms than bungeecord or another forks of RedisBungee
|
||||||
*
|
*
|
||||||
* @author Ham1255
|
* @author Ham1255
|
||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
*/
|
*/
|
||||||
public interface RedisBungeePlugin<P> extends EventsPlatform, ConfigLoader {
|
public interface RedisBungeePlugin<P> extends EventsPlatform {
|
||||||
|
|
||||||
default void initialize() {
|
default void initialize() {
|
||||||
|
|
||||||
@ -201,8 +201,6 @@ public interface RedisBungeePlugin<P> extends EventsPlatform, ConfigLoader {
|
|||||||
|
|
||||||
void executeAsyncAfter(Runnable runnable, TimeUnit timeUnit, int time);
|
void executeAsyncAfter(Runnable runnable, TimeUnit timeUnit, int time);
|
||||||
|
|
||||||
void callEvent(Object event);
|
|
||||||
|
|
||||||
boolean isOnlineMode();
|
boolean isOnlineMode();
|
||||||
|
|
||||||
void logInfo(String msg);
|
void logInfo(String msg);
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.imaginarycode.minecraft.redisbungee.api.events;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Since each platform have their own events' implementation for example Bungeecord events extends Event while velocity don't
|
||||||
|
*
|
||||||
|
* @author Ham1255
|
||||||
|
* @since 0.7.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface EventsPlatform {
|
||||||
|
|
||||||
|
IPlayerChangedServerNetworkEvent createPlayerChangedServerNetworkEvent(UUID uuid, String previousServer, String server);
|
||||||
|
|
||||||
|
IPlayerJoinedNetworkEvent createPlayerJoinedNetworkEvent(UUID uuid);
|
||||||
|
|
||||||
|
IPlayerLeftNetworkEvent createPlayerLeftNetworkEvent(UUID uuid);
|
||||||
|
|
||||||
|
IPubSubMessageEvent createPubSubEvent(String channel, String message);
|
||||||
|
|
||||||
|
void fireEvent(Object event);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.imaginarycode.minecraft.redisbungee.api.events;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface IPlayerChangedServerNetworkEvent extends RedisBungeeEvent {
|
||||||
|
|
||||||
|
UUID getUuid();
|
||||||
|
|
||||||
|
String getServer();
|
||||||
|
|
||||||
|
String getPreviousServer();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.imaginarycode.minecraft.redisbungee.api.events;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface IPlayerJoinedNetworkEvent extends RedisBungeeEvent {
|
||||||
|
|
||||||
|
UUID getUuid();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.imaginarycode.minecraft.redisbungee.api.events;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface IPlayerLeftNetworkEvent extends RedisBungeeEvent {
|
||||||
|
|
||||||
|
UUID getUuid();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.imaginarycode.minecraft.redisbungee.api.events;
|
||||||
|
|
||||||
|
public interface IPubSubMessageEvent extends RedisBungeeEvent {
|
||||||
|
|
||||||
|
String getChannel();
|
||||||
|
|
||||||
|
String getMessage();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package com.imaginarycode.minecraft.redisbungee.api.events;
|
||||||
|
|
||||||
|
interface RedisBungeeEvent {
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.imaginarycode.minecraft.redisbungee.api.util.serialize;
|
||||||
|
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
import com.google.common.collect.Multiset;
|
||||||
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Serializations {
|
||||||
|
|
||||||
|
public static void serializeMultiset(Multiset<String> collection, ByteArrayDataOutput output) {
|
||||||
|
output.writeInt(collection.elementSet().size());
|
||||||
|
for (Multiset.Entry<String> entry : collection.entrySet()) {
|
||||||
|
output.writeUTF(entry.getElement());
|
||||||
|
output.writeInt(entry.getCount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
|
public static void serializeMultimap(Multimap<String, String> collection, boolean includeNames, ByteArrayDataOutput output) {
|
||||||
|
output.writeInt(collection.keySet().size());
|
||||||
|
for (Map.Entry<String, Collection<String>> entry : collection.asMap().entrySet()) {
|
||||||
|
output.writeUTF(entry.getKey());
|
||||||
|
if (includeNames) {
|
||||||
|
serializeCollection(entry.getValue(), output);
|
||||||
|
} else {
|
||||||
|
output.writeInt(entry.getValue().size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void serializeCollection(Collection<?> collection, ByteArrayDataOutput output) {
|
||||||
|
output.writeInt(collection.size());
|
||||||
|
for (Object o : collection) {
|
||||||
|
output.writeUTF(o.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,12 @@ import com.google.common.cache.Cache;
|
|||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.config.ConfigLoader;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerChangedServerNetworkEvent;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerJoinedNetworkEvent;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEvent;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.tasks.*;
|
import com.imaginarycode.minecraft.redisbungee.api.tasks.*;
|
||||||
import com.imaginarycode.minecraft.redisbungee.commands.RedisBungeeCommands;
|
import com.imaginarycode.minecraft.redisbungee.commands.RedisBungeeCommands;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetworkEvent;
|
||||||
@ -34,7 +39,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
|
||||||
public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlayer> {
|
public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlayer>, ConfigLoader {
|
||||||
|
|
||||||
private static RedisBungeeAPI apiStatic;
|
private static RedisBungeeAPI apiStatic;
|
||||||
|
|
||||||
@ -121,7 +126,7 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void callEvent(Object event) {
|
public void fireEvent(Object event) {
|
||||||
this.getProxy().getPluginManager().callEvent((Event) event);
|
this.getProxy().getPluginManager().callEvent((Event) event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,22 +307,22 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createPlayerChangedNetworkEvent(UUID uuid, String previousServer, String server) {
|
public IPlayerChangedServerNetworkEvent createPlayerChangedServerNetworkEvent(UUID uuid, String previousServer, String server) {
|
||||||
return new PlayerChangedServerNetworkEvent(uuid, previousServer, server);
|
return new PlayerChangedServerNetworkEvent(uuid, previousServer, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createPlayerJoinedNetworkEvent(UUID uuid) {
|
public IPlayerJoinedNetworkEvent createPlayerJoinedNetworkEvent(UUID uuid) {
|
||||||
return new PlayerJoinedNetworkEvent(uuid);
|
return new PlayerJoinedNetworkEvent(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createPlayerLeftNetworkEvent(UUID uuid) {
|
public IPlayerLeftNetworkEvent createPlayerLeftNetworkEvent(UUID uuid) {
|
||||||
return new PlayerLeftNetworkEvent(uuid);
|
return new PlayerLeftNetworkEvent(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createPubSubEvent(String channel, String message) {
|
public IPubSubMessageEvent createPubSubEvent(String channel, String message) {
|
||||||
return new PubSubMessageEvent(channel, message);
|
return new PubSubMessageEvent(channel, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,10 +18,12 @@ public class RedisBungeeAPI extends AbstractRedisBungeeAPI {
|
|||||||
|
|
||||||
private static RedisBungeeAPI redisBungeeApi;
|
private static RedisBungeeAPI redisBungeeApi;
|
||||||
|
|
||||||
RedisBungeeAPI(RedisBungeePlugin<?> plugin) {
|
public RedisBungeeAPI(RedisBungeePlugin<?> plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
|
if (redisBungeeApi == null) {
|
||||||
redisBungeeApi = this;
|
redisBungeeApi = this;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the server where the specified player is playing. This function also deals with the case of local players
|
* Get the server where the specified player is playing. This function also deals with the case of local players
|
||||||
|
@ -25,6 +25,9 @@ import redis.clients.jedis.UnifiedJedis;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static com.imaginarycode.minecraft.redisbungee.api.util.serialize.Serializations.serializeMultimap;
|
||||||
|
import static com.imaginarycode.minecraft.redisbungee.api.util.serialize.Serializations.serializeMultiset;
|
||||||
|
|
||||||
public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<LoginEvent, PostLoginEvent, PlayerDisconnectEvent, ServerConnectedEvent, ProxyPingEvent, PluginMessageEvent, PubSubMessageEvent> implements Listener {
|
public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<LoginEvent, PostLoginEvent, PlayerDisconnectEvent, ServerConnectedEvent, ProxyPingEvent, PluginMessageEvent, PubSubMessageEvent> implements Listener {
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.imaginarycode.minecraft.redisbungee.events;
|
package com.imaginarycode.minecraft.redisbungee.events;
|
||||||
|
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerChangedServerNetworkEvent;
|
||||||
import net.md_5.bungee.api.plugin.Event;
|
import net.md_5.bungee.api.plugin.Event;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -13,7 +14,7 @@ import java.util.UUID;
|
|||||||
*
|
*
|
||||||
* @since 0.3.4
|
* @since 0.3.4
|
||||||
*/
|
*/
|
||||||
public class PlayerChangedServerNetworkEvent extends Event {
|
public class PlayerChangedServerNetworkEvent extends Event implements IPlayerChangedServerNetworkEvent {
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private final String previousServer;
|
private final String previousServer;
|
||||||
private final String server;
|
private final String server;
|
||||||
@ -24,14 +25,17 @@ public class PlayerChangedServerNetworkEvent extends Event {
|
|||||||
this.server = server;
|
this.server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getServer() {
|
public String getServer() {
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getPreviousServer() {
|
public String getPreviousServer() {
|
||||||
return previousServer;
|
return previousServer;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.imaginarycode.minecraft.redisbungee.events;
|
package com.imaginarycode.minecraft.redisbungee.events;
|
||||||
|
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerJoinedNetworkEvent;
|
||||||
import net.md_5.bungee.api.plugin.Event;
|
import net.md_5.bungee.api.plugin.Event;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -13,13 +14,14 @@ import java.util.UUID;
|
|||||||
*
|
*
|
||||||
* @since 0.3.4
|
* @since 0.3.4
|
||||||
*/
|
*/
|
||||||
public class PlayerJoinedNetworkEvent extends Event {
|
public class PlayerJoinedNetworkEvent extends Event implements IPlayerJoinedNetworkEvent {
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
|
|
||||||
public PlayerJoinedNetworkEvent(UUID uuid) {
|
public PlayerJoinedNetworkEvent(UUID uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.imaginarycode.minecraft.redisbungee.events;
|
package com.imaginarycode.minecraft.redisbungee.events;
|
||||||
|
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEvent;
|
||||||
import net.md_5.bungee.api.plugin.Event;
|
import net.md_5.bungee.api.plugin.Event;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -13,13 +14,14 @@ import java.util.UUID;
|
|||||||
*
|
*
|
||||||
* @since 0.3.4
|
* @since 0.3.4
|
||||||
*/
|
*/
|
||||||
public class PlayerLeftNetworkEvent extends Event {
|
public class PlayerLeftNetworkEvent extends Event implements IPlayerLeftNetworkEvent {
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
|
|
||||||
public PlayerLeftNetworkEvent(UUID uuid) {
|
public PlayerLeftNetworkEvent(UUID uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.imaginarycode.minecraft.redisbungee.events;
|
package com.imaginarycode.minecraft.redisbungee.events;
|
||||||
|
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent;
|
||||||
import net.md_5.bungee.api.plugin.Event;
|
import net.md_5.bungee.api.plugin.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -10,7 +11,7 @@ import net.md_5.bungee.api.plugin.Event;
|
|||||||
* @since 0.2.6
|
* @since 0.2.6
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PubSubMessageEvent extends Event {
|
public class PubSubMessageEvent extends Event implements IPubSubMessageEvent {
|
||||||
private final String channel;
|
private final String channel;
|
||||||
private final String message;
|
private final String message;
|
||||||
|
|
||||||
@ -19,10 +20,12 @@ public class PubSubMessageEvent extends Event {
|
|||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getChannel() {
|
public String getChannel() {
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,14 @@ public class RedisBungeeAPI extends AbstractRedisBungeeAPI {
|
|||||||
|
|
||||||
private static RedisBungeeAPI redisBungeeApi;
|
private static RedisBungeeAPI redisBungeeApi;
|
||||||
|
|
||||||
RedisBungeeAPI(RedisBungeePlugin<?> plugin) {
|
public RedisBungeeAPI(RedisBungeePlugin<?> plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
|
if (redisBungeeApi == null) {
|
||||||
redisBungeeApi = this;
|
redisBungeeApi = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the server where the specified player is playing. This function also deals with the case of local players
|
* Get the server where the specified player is playing. This function also deals with the case of local players
|
||||||
* as well, and will return local information on them.
|
* as well, and will return local information on them.
|
||||||
|
@ -33,6 +33,9 @@ import java.net.InetAddress;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.imaginarycode.minecraft.redisbungee.api.util.serialize.Serializations.serializeMultimap;
|
||||||
|
import static com.imaginarycode.minecraft.redisbungee.api.util.serialize.Serializations.serializeMultiset;
|
||||||
|
|
||||||
public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<LoginEvent, PostLoginEvent, DisconnectEvent, ServerConnectedEvent, ProxyPingEvent, PluginMessageEvent, PubSubMessageEvent> {
|
public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<LoginEvent, PostLoginEvent, DisconnectEvent, ServerConnectedEvent, ProxyPingEvent, PluginMessageEvent, PubSubMessageEvent> {
|
||||||
// Some messages are using legacy characters
|
// Some messages are using legacy characters
|
||||||
private final LegacyComponentSerializer serializer = LegacyComponentSerializer.legacySection();
|
private final LegacyComponentSerializer serializer = LegacyComponentSerializer.legacySection();
|
||||||
|
@ -6,7 +6,12 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.*;
|
import com.imaginarycode.minecraft.redisbungee.api.*;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.config.ConfigLoader;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerChangedServerNetworkEvent;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerJoinedNetworkEvent;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEvent;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.tasks.*;
|
import com.imaginarycode.minecraft.redisbungee.api.tasks.*;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.util.uuid.NameFetcher;
|
import com.imaginarycode.minecraft.redisbungee.api.util.uuid.NameFetcher;
|
||||||
@ -43,7 +48,7 @@ import java.util.concurrent.*;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@Plugin(id = "redisbungee", name = "RedisBungee", version = PomData.VERSION, url = "https://github.com/ProxioDev/RedisBungee", authors = {"astei", "ProxioDev"})
|
@Plugin(id = "redisbungee", name = "RedisBungee", version = PomData.VERSION, url = "https://github.com/ProxioDev/RedisBungee", authors = {"astei", "ProxioDev"})
|
||||||
public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, ConfigLoader {
|
||||||
private final ProxyServer server;
|
private final ProxyServer server;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
private final Path dataFolder;
|
private final Path dataFolder;
|
||||||
@ -169,7 +174,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void callEvent(Object event) {
|
public void fireEvent(Object event) {
|
||||||
this.getProxy().getEventManager().fireAndForget(event);
|
this.getProxy().getEventManager().fireAndForget(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,22 +332,22 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createPlayerChangedNetworkEvent(UUID uuid, String previousServer, String server) {
|
public IPlayerChangedServerNetworkEvent createPlayerChangedServerNetworkEvent(UUID uuid, String previousServer, String server) {
|
||||||
return new PlayerChangedServerNetworkEvent(uuid, previousServer, server);
|
return new PlayerChangedServerNetworkEvent(uuid, previousServer, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createPlayerJoinedNetworkEvent(UUID uuid) {
|
public IPlayerJoinedNetworkEvent createPlayerJoinedNetworkEvent(UUID uuid) {
|
||||||
return new PlayerJoinedNetworkEvent(uuid);
|
return new PlayerJoinedNetworkEvent(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createPlayerLeftNetworkEvent(UUID uuid) {
|
public IPlayerLeftNetworkEvent createPlayerLeftNetworkEvent(UUID uuid) {
|
||||||
return new PlayerLeftNetworkEvent(uuid);
|
return new PlayerLeftNetworkEvent(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createPubSubEvent(String channel, String message) {
|
public IPubSubMessageEvent createPubSubEvent(String channel, String message) {
|
||||||
return new PubSubMessageEvent(channel, message);
|
return new PubSubMessageEvent(channel, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.imaginarycode.minecraft.redisbungee.events;
|
package com.imaginarycode.minecraft.redisbungee.events;
|
||||||
|
|
||||||
|
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerChangedServerNetworkEvent;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,7 +14,7 @@ import java.util.UUID;
|
|||||||
*
|
*
|
||||||
* @since 0.3.4
|
* @since 0.3.4
|
||||||
*/
|
*/
|
||||||
public class PlayerChangedServerNetworkEvent {
|
public class PlayerChangedServerNetworkEvent implements IPlayerChangedServerNetworkEvent {
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private final String previousServer;
|
private final String previousServer;
|
||||||
private final String server;
|
private final String server;
|
||||||
@ -23,14 +25,17 @@ public class PlayerChangedServerNetworkEvent {
|
|||||||
this.server = server;
|
this.server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getServer() {
|
public String getServer() {
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getPreviousServer() {
|
public String getPreviousServer() {
|
||||||
return previousServer;
|
return previousServer;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.imaginarycode.minecraft.redisbungee.events;
|
package com.imaginarycode.minecraft.redisbungee.events;
|
||||||
|
|
||||||
|
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerJoinedNetworkEvent;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,13 +14,14 @@ import java.util.UUID;
|
|||||||
*
|
*
|
||||||
* @since 0.3.4
|
* @since 0.3.4
|
||||||
*/
|
*/
|
||||||
public class PlayerJoinedNetworkEvent {
|
public class PlayerJoinedNetworkEvent implements IPlayerJoinedNetworkEvent {
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
|
|
||||||
public PlayerJoinedNetworkEvent(UUID uuid) {
|
public PlayerJoinedNetworkEvent(UUID uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.imaginarycode.minecraft.redisbungee.events;
|
package com.imaginarycode.minecraft.redisbungee.events;
|
||||||
|
|
||||||
|
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEvent;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,13 +14,14 @@ import java.util.UUID;
|
|||||||
*
|
*
|
||||||
* @since 0.3.4
|
* @since 0.3.4
|
||||||
*/
|
*/
|
||||||
public class PlayerLeftNetworkEvent {
|
public class PlayerLeftNetworkEvent implements IPlayerLeftNetworkEvent {
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
|
|
||||||
public PlayerLeftNetworkEvent(UUID uuid) {
|
public PlayerLeftNetworkEvent(UUID uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.imaginarycode.minecraft.redisbungee.events;
|
package com.imaginarycode.minecraft.redisbungee.events;
|
||||||
|
|
||||||
|
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is posted when a PubSub message is received.
|
* This event is posted when a PubSub message is received.
|
||||||
@ -10,7 +11,7 @@ package com.imaginarycode.minecraft.redisbungee.events;
|
|||||||
* @since 0.2.6
|
* @since 0.2.6
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PubSubMessageEvent {
|
public class PubSubMessageEvent implements IPubSubMessageEvent {
|
||||||
private final String channel;
|
private final String channel;
|
||||||
private final String message;
|
private final String message;
|
||||||
|
|
||||||
@ -19,10 +20,12 @@ public class PubSubMessageEvent {
|
|||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getChannel() {
|
public String getChannel() {
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
1
pom.xml
1
pom.xml
@ -37,6 +37,7 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<modules>
|
<modules>
|
||||||
|
<!-- Main modules -->
|
||||||
<module>RedisBungee-API</module>
|
<module>RedisBungee-API</module>
|
||||||
<module>RedisBungee-Bungee</module>
|
<module>RedisBungee-Bungee</module>
|
||||||
<module>RedisBungee-Velocity</module>
|
<module>RedisBungee-Velocity</module>
|
||||||
|
Loading…
Reference in New Issue
Block a user