mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-12-23 02:28:01 +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 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
|
||||
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;
|
||||
|
||||
AbstractRedisBungeeAPI(RedisBungeePlugin<?> plugin) {
|
||||
abstractRedisBungeeAPI = this;
|
||||
this.plugin = plugin;
|
||||
// this does make sure that no one can place first initiated API class.
|
||||
if (abstractRedisBungeeAPI == null) {
|
||||
abstractRedisBungeeAPI = this;
|
||||
}
|
||||
this.reservedChannels = ImmutableList.of(
|
||||
"redisbungee-allservers",
|
||||
"redisbungee-" + plugin.getConfiguration().getProxyId(),
|
||||
"redisbungee-data"
|
||||
);
|
||||
|
||||
this.plugin = plugin;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,6 +64,7 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
public final long getLastOnline(@NonNull UUID 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
|
||||
* as well, and will return local information on them.
|
||||
@ -338,7 +344,7 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* Kicks a player from the network
|
||||
*
|
||||
* @param playerName player name
|
||||
* @param message kick message that player will see on kick
|
||||
* @param message kick message that player will see on kick
|
||||
* @since 0.8.0
|
||||
*/
|
||||
|
||||
@ -350,7 +356,7 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* Kicks a player from the network
|
||||
*
|
||||
* @param playerUUID player name
|
||||
* @param message kick message that player will see on kick
|
||||
* @param message kick message that player will see on kick
|
||||
* @since 0.8.0
|
||||
*/
|
||||
public void kickPlayer(UUID playerUUID, String message) {
|
||||
@ -361,9 +367,9 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* This gives you instance of Jedis
|
||||
*
|
||||
* @return {@link Jedis}
|
||||
* @since 0.7.0
|
||||
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
||||
* @see #getJedisPool()
|
||||
* @since 0.7.0
|
||||
*/
|
||||
public Jedis requestJedis() {
|
||||
if (getMode() == RedisBungeeMode.SINGLE) {
|
||||
@ -377,9 +383,9 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* This gets Redis Bungee {@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 JedisPool compatibility mode is disabled in the config
|
||||
* @since 0.6.5
|
||||
*/
|
||||
public JedisPool getJedisPool() {
|
||||
if (getMode() == RedisBungeeMode.SINGLE) {
|
||||
@ -398,8 +404,8 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* WARNING DO NOT USE {@link JedisCluster#close()} it will break the functionally
|
||||
*
|
||||
* @return {@link redis.clients.jedis.JedisCluster}
|
||||
* @since 0.8.0
|
||||
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#CLUSTER}
|
||||
* @since 0.8.0
|
||||
*/
|
||||
public JedisCluster requestClusterJedis() {
|
||||
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
|
||||
*
|
||||
* @return {@link redis.clients.jedis.JedisPooled}
|
||||
* @since 0.8.0
|
||||
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
||||
* @since 0.8.0
|
||||
*/
|
||||
public JedisCluster requestJedisPooled() {
|
||||
if (getMode() == RedisBungeeMode.SINGLE) {
|
||||
|
@ -171,7 +171,7 @@ public abstract class AbstractDataManager<P, PL, PD, PS> {
|
||||
ipCache.put(message1.getTarget(), message1.getPayload().getAddress());
|
||||
plugin.executeAsync(() -> {
|
||||
Object event = plugin.createPlayerJoinedNetworkEvent(message1.getTarget());
|
||||
plugin.callEvent(event);
|
||||
plugin.fireEvent(event);
|
||||
});
|
||||
break;
|
||||
case LEAVE:
|
||||
@ -181,7 +181,7 @@ public abstract class AbstractDataManager<P, PL, PD, PS> {
|
||||
lastOnlineCache.put(message2.getTarget(), message2.getPayload().getTimestamp());
|
||||
plugin.executeAsync(() -> {
|
||||
Object event = plugin.createPlayerLeftNetworkEvent(message2.getTarget());
|
||||
plugin.callEvent(event);
|
||||
plugin.fireEvent(event);
|
||||
});
|
||||
break;
|
||||
case SERVER_CHANGE:
|
||||
@ -189,8 +189,8 @@ public abstract class AbstractDataManager<P, PL, PD, PS> {
|
||||
}.getType());
|
||||
serverCache.put(message3.getTarget(), message3.getPayload().getServer());
|
||||
plugin.executeAsync(() -> {
|
||||
Object event = plugin.createPlayerChangedNetworkEvent(message3.getTarget(), message3.getPayload().getOldServer(), message3.getPayload().getServer());
|
||||
plugin.callEvent(event);
|
||||
Object event = plugin.createPlayerChangedServerNetworkEvent(message3.getTarget(), message3.getPayload().getOldServer(), message3.getPayload().getServer());
|
||||
plugin.fireEvent(event);
|
||||
});
|
||||
break;
|
||||
case KICK:
|
||||
|
@ -38,34 +38,6 @@ public abstract class AbstractRedisBungeeListener<LE, PLE, PD, SC, PP, PM, PS> {
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
@ -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 java.lang.reflect.InvocationTargetException;
|
||||
|
||||
|
||||
public class JedisPubSubHandler extends JedisPubSub {
|
||||
|
||||
@ -21,7 +19,7 @@ public class JedisPubSubHandler extends JedisPubSub {
|
||||
@Override
|
||||
public void run() {
|
||||
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.Multimap;
|
||||
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.events.EventsPlatform;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisTask;
|
||||
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
|
||||
* @since 0.7.0
|
||||
*/
|
||||
public interface RedisBungeePlugin<P> extends EventsPlatform, ConfigLoader {
|
||||
public interface RedisBungeePlugin<P> extends EventsPlatform {
|
||||
|
||||
default void initialize() {
|
||||
|
||||
@ -201,8 +201,6 @@ public interface RedisBungeePlugin<P> extends EventsPlatform, ConfigLoader {
|
||||
|
||||
void executeAsyncAfter(Runnable runnable, TimeUnit timeUnit, int time);
|
||||
|
||||
void callEvent(Object event);
|
||||
|
||||
boolean isOnlineMode();
|
||||
|
||||
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.collect.ImmutableSet;
|
||||
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.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.commands.RedisBungeeCommands;
|
||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetworkEvent;
|
||||
@ -34,7 +39,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
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;
|
||||
|
||||
@ -121,7 +126,7 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callEvent(Object event) {
|
||||
public void fireEvent(Object event) {
|
||||
this.getProxy().getPluginManager().callEvent((Event) event);
|
||||
}
|
||||
|
||||
@ -302,22 +307,22 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createPlayerJoinedNetworkEvent(UUID uuid) {
|
||||
public IPlayerJoinedNetworkEvent createPlayerJoinedNetworkEvent(UUID uuid) {
|
||||
return new PlayerJoinedNetworkEvent(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createPlayerLeftNetworkEvent(UUID uuid) {
|
||||
public IPlayerLeftNetworkEvent createPlayerLeftNetworkEvent(UUID uuid) {
|
||||
return new PlayerLeftNetworkEvent(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createPubSubEvent(String channel, String message) {
|
||||
public IPubSubMessageEvent createPubSubEvent(String channel, String message) {
|
||||
return new PubSubMessageEvent(channel, message);
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,11 @@ public class RedisBungeeAPI extends AbstractRedisBungeeAPI {
|
||||
|
||||
private static RedisBungeeAPI redisBungeeApi;
|
||||
|
||||
RedisBungeeAPI(RedisBungeePlugin<?> plugin) {
|
||||
public RedisBungeeAPI(RedisBungeePlugin<?> plugin) {
|
||||
super(plugin);
|
||||
redisBungeeApi = this;
|
||||
if (redisBungeeApi == null) {
|
||||
redisBungeeApi = this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -29,7 +31,7 @@ public class RedisBungeeAPI extends AbstractRedisBungeeAPI {
|
||||
*
|
||||
* @param player a player uuid
|
||||
* @return {@link ServerInfo} Can be null if proxy can't find it.
|
||||
* @see #getServerNameFor(UUID)
|
||||
* @see #getServerNameFor(UUID)
|
||||
*/
|
||||
public final ServerInfo getServerFor(@NonNull UUID player) {
|
||||
return ((Plugin) this.plugin).getProxy().getServerInfo(this.getServerNameFor(player));
|
||||
|
@ -25,6 +25,9 @@ import redis.clients.jedis.UnifiedJedis;
|
||||
import java.net.InetAddress;
|
||||
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 {
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.imaginarycode.minecraft.redisbungee.events;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerChangedServerNetworkEvent;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -13,7 +14,7 @@ import java.util.UUID;
|
||||
*
|
||||
* @since 0.3.4
|
||||
*/
|
||||
public class PlayerChangedServerNetworkEvent extends Event {
|
||||
public class PlayerChangedServerNetworkEvent extends Event implements IPlayerChangedServerNetworkEvent {
|
||||
private final UUID uuid;
|
||||
private final String previousServer;
|
||||
private final String server;
|
||||
@ -24,14 +25,17 @@ public class PlayerChangedServerNetworkEvent extends Event {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreviousServer() {
|
||||
return previousServer;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.imaginarycode.minecraft.redisbungee.events;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerJoinedNetworkEvent;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -13,13 +14,14 @@ import java.util.UUID;
|
||||
*
|
||||
* @since 0.3.4
|
||||
*/
|
||||
public class PlayerJoinedNetworkEvent extends Event {
|
||||
public class PlayerJoinedNetworkEvent extends Event implements IPlayerJoinedNetworkEvent {
|
||||
private final UUID uuid;
|
||||
|
||||
public PlayerJoinedNetworkEvent(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.imaginarycode.minecraft.redisbungee.events;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEvent;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -13,13 +14,14 @@ import java.util.UUID;
|
||||
*
|
||||
* @since 0.3.4
|
||||
*/
|
||||
public class PlayerLeftNetworkEvent extends Event {
|
||||
public class PlayerLeftNetworkEvent extends Event implements IPlayerLeftNetworkEvent {
|
||||
private final UUID uuid;
|
||||
|
||||
public PlayerLeftNetworkEvent(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.imaginarycode.minecraft.redisbungee.events;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
/**
|
||||
@ -10,7 +11,7 @@ import net.md_5.bungee.api.plugin.Event;
|
||||
* @since 0.2.6
|
||||
*/
|
||||
|
||||
public class PubSubMessageEvent extends Event {
|
||||
public class PubSubMessageEvent extends Event implements IPubSubMessageEvent {
|
||||
private final String channel;
|
||||
private final String message;
|
||||
|
||||
@ -19,10 +20,12 @@ public class PubSubMessageEvent extends Event {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
@ -18,9 +18,12 @@ public class RedisBungeeAPI extends AbstractRedisBungeeAPI {
|
||||
|
||||
private static RedisBungeeAPI redisBungeeApi;
|
||||
|
||||
RedisBungeeAPI(RedisBungeePlugin<?> plugin) {
|
||||
public RedisBungeeAPI(RedisBungeePlugin<?> plugin) {
|
||||
super(plugin);
|
||||
redisBungeeApi = this;
|
||||
if (redisBungeeApi == null) {
|
||||
redisBungeeApi = this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,9 @@ import java.net.InetAddress;
|
||||
import java.util.*;
|
||||
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> {
|
||||
// Some messages are using legacy characters
|
||||
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.inject.Inject;
|
||||
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.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.tasks.*;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.util.uuid.NameFetcher;
|
||||
@ -43,7 +48,7 @@ import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@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 Logger logger;
|
||||
private final Path dataFolder;
|
||||
@ -169,7 +174,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callEvent(Object event) {
|
||||
public void fireEvent(Object event) {
|
||||
this.getProxy().getEventManager().fireAndForget(event);
|
||||
}
|
||||
|
||||
@ -327,22 +332,22 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
||||
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createPlayerJoinedNetworkEvent(UUID uuid) {
|
||||
public IPlayerJoinedNetworkEvent createPlayerJoinedNetworkEvent(UUID uuid) {
|
||||
return new PlayerJoinedNetworkEvent(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createPlayerLeftNetworkEvent(UUID uuid) {
|
||||
public IPlayerLeftNetworkEvent createPlayerLeftNetworkEvent(UUID uuid) {
|
||||
return new PlayerLeftNetworkEvent(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createPubSubEvent(String channel, String message) {
|
||||
public IPubSubMessageEvent createPubSubEvent(String channel, String message) {
|
||||
return new PubSubMessageEvent(channel, message);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.imaginarycode.minecraft.redisbungee.events;
|
||||
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerChangedServerNetworkEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -12,7 +14,7 @@ import java.util.UUID;
|
||||
*
|
||||
* @since 0.3.4
|
||||
*/
|
||||
public class PlayerChangedServerNetworkEvent {
|
||||
public class PlayerChangedServerNetworkEvent implements IPlayerChangedServerNetworkEvent {
|
||||
private final UUID uuid;
|
||||
private final String previousServer;
|
||||
private final String server;
|
||||
@ -23,14 +25,17 @@ public class PlayerChangedServerNetworkEvent {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreviousServer() {
|
||||
return previousServer;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.imaginarycode.minecraft.redisbungee.events;
|
||||
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerJoinedNetworkEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -12,13 +14,14 @@ import java.util.UUID;
|
||||
*
|
||||
* @since 0.3.4
|
||||
*/
|
||||
public class PlayerJoinedNetworkEvent {
|
||||
public class PlayerJoinedNetworkEvent implements IPlayerJoinedNetworkEvent {
|
||||
private final UUID uuid;
|
||||
|
||||
public PlayerJoinedNetworkEvent(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.imaginarycode.minecraft.redisbungee.events;
|
||||
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -12,13 +14,14 @@ import java.util.UUID;
|
||||
*
|
||||
* @since 0.3.4
|
||||
*/
|
||||
public class PlayerLeftNetworkEvent {
|
||||
public class PlayerLeftNetworkEvent implements IPlayerLeftNetworkEvent {
|
||||
private final UUID uuid;
|
||||
|
||||
public PlayerLeftNetworkEvent(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.imaginarycode.minecraft.redisbungee.events;
|
||||
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent;
|
||||
|
||||
/**
|
||||
* This event is posted when a PubSub message is received.
|
||||
@ -10,7 +11,7 @@ package com.imaginarycode.minecraft.redisbungee.events;
|
||||
* @since 0.2.6
|
||||
*/
|
||||
|
||||
public class PubSubMessageEvent {
|
||||
public class PubSubMessageEvent implements IPubSubMessageEvent {
|
||||
private final String channel;
|
||||
private final String message;
|
||||
|
||||
@ -19,10 +20,12 @@ public class PubSubMessageEvent {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user