Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-25 15:50:10 +01:00
Implement the UpdateListener for Bungee
Dieser Commit ist enthalten in:
Ursprung
4b3f757881
Commit
7d23b12f85
@ -12,7 +12,6 @@ import net.md_5.bungee.event.EventHandler;
|
|||||||
import us.myles.ViaVersion.api.Pair;
|
import us.myles.ViaVersion.api.Pair;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.ViaAPI;
|
import us.myles.ViaVersion.api.ViaAPI;
|
||||||
import us.myles.ViaVersion.api.ViaVersionConfig;
|
|
||||||
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
||||||
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
|
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
@ -83,7 +82,7 @@ public class BungeePlugin extends Plugin implements ViaPlatform, Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskId runSync(Runnable runnable) {
|
public TaskId runSync(Runnable runnable) {
|
||||||
return new BungeeTaskId(getProxy().getScheduler().runAsync(this, runnable).getId());
|
return runAsync(runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -112,13 +111,13 @@ public class BungeePlugin extends Plugin implements ViaPlatform, Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(UUID uuid, String message) {
|
public void sendMessage(UUID uuid, String message) {
|
||||||
getProxy().getPlayer(uuid).sendMessage(new TextComponent(message));
|
getProxy().getPlayer(uuid).sendMessage(TextComponent.fromLegacyText(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean kickPlayer(UUID uuid, String message) {
|
public boolean kickPlayer(UUID uuid, String message) {
|
||||||
if (getProxy().getPlayer(uuid) != null) {
|
if (getProxy().getPlayer(uuid) != null) {
|
||||||
getProxy().getPlayer(uuid).disconnect(new TextComponent(message));
|
getProxy().getPlayer(uuid).disconnect(TextComponent.fromLegacyText(message));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package us.myles.ViaVersion.bungee.listeners;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
import us.myles.ViaVersion.update.UpdateUtil;
|
||||||
|
|
||||||
|
public class UpdateListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onJoin(PostLoginEvent e) {
|
||||||
|
if (e.getPlayer().hasPermission("viaversion.update")
|
||||||
|
&& Via.getConfig().isCheckForUpdates()) {
|
||||||
|
UpdateUtil.sendUpdateMessage(e.getPlayer().getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ import net.md_5.bungee.api.ProxyServer;
|
|||||||
import us.myles.ViaVersion.BungeePlugin;
|
import us.myles.ViaVersion.BungeePlugin;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.platform.ViaPlatformLoader;
|
import us.myles.ViaVersion.api.platform.ViaPlatformLoader;
|
||||||
|
import us.myles.ViaVersion.bungee.listeners.UpdateListener;
|
||||||
import us.myles.ViaVersion.bungee.providers.BungeeMovementTransmitter;
|
import us.myles.ViaVersion.bungee.providers.BungeeMovementTransmitter;
|
||||||
import us.myles.ViaVersion.bungee.providers.BungeeVersionProvider;
|
import us.myles.ViaVersion.bungee.providers.BungeeVersionProvider;
|
||||||
import us.myles.ViaVersion.bungee.service.ProtocolDetectorService;
|
import us.myles.ViaVersion.bungee.service.ProtocolDetectorService;
|
||||||
@ -21,6 +22,8 @@ public class BungeeViaLoader implements ViaPlatformLoader {
|
|||||||
public void load() {
|
public void load() {
|
||||||
// Listeners
|
// Listeners
|
||||||
ProxyServer.getInstance().getPluginManager().registerListener(plugin, plugin);
|
ProxyServer.getInstance().getPluginManager().registerListener(plugin, plugin);
|
||||||
|
ProxyServer.getInstance().getPluginManager().registerListener(plugin, new UpdateListener());
|
||||||
|
|
||||||
// Providers
|
// Providers
|
||||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
|
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
|
||||||
Via.getManager().getProviders().use(VersionProvider.class, new BungeeVersionProvider());
|
Via.getManager().getProviders().use(VersionProvider.class, new BungeeVersionProvider());
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren