Archive eaglerxpaper (plugin, 1.8.8 - 26.x, clean)
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
|
||||
plugins {
|
||||
id "java-library"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api project(":eaglermotd")
|
||||
compileOnly project(":api-velocity")
|
||||
compileOnly(libs.velocity.api)
|
||||
annotationProcessor(libs.velocity.api)
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2026 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
package net.lax1dude.eaglercraft.backend.eaglermotd.velocity;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.velocitypowered.api.command.CommandManager;
|
||||
import com.velocitypowered.api.command.CommandMeta;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.lax1dude.eaglercraft.backend.eaglermotd.adapter.IEaglerMOTDPlatform;
|
||||
|
||||
class CommandEaglerMOTD implements SimpleCommand {
|
||||
|
||||
private final PlatformPluginVelocity plugin;
|
||||
|
||||
CommandEaglerMOTD(PlatformPluginVelocity plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Invocation invocation) {
|
||||
return invocation.source().hasPermission("eaglercraft.eaglermotd.reload");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Invocation invocation) {
|
||||
String[] args = invocation.arguments();
|
||||
if (args.length == 1 && "reload".equalsIgnoreCase(args[0])) {
|
||||
IEaglerMOTDPlatform.IHandleReload handler = plugin.handleReload;
|
||||
if (handler == null) {
|
||||
invocation.source().sendMessage(Component.text("Plugin is not enabled!", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
handler.reload();
|
||||
} catch (IOException ex) {
|
||||
plugin.logger().error("Failed to reload config files!", ex);
|
||||
invocation.source()
|
||||
.sendMessage(Component.text("Failed to reload config files! (Check Proxy Log)", NamedTextColor.RED));
|
||||
invocation.source().sendMessage(Component.text(ex.toString(), NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
invocation.source().sendMessage(Component.text("Configuration reloaded.", NamedTextColor.AQUA));
|
||||
} else {
|
||||
invocation.source().sendMessage(Component.text("Usage: /eaglermotd reload", NamedTextColor.RED));
|
||||
}
|
||||
}
|
||||
|
||||
public CommandMeta register() {
|
||||
CommandManager mgr = plugin.proxy().getCommandManager();
|
||||
CommandMeta meta = mgr.metaBuilder("eaglermotd").plugin(plugin).build();
|
||||
mgr.register(meta, this);
|
||||
return meta;
|
||||
}
|
||||
|
||||
}
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2025 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
package net.lax1dude.eaglercraft.backend.eaglermotd.velocity;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.command.CommandMeta;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||
import com.velocitypowered.api.plugin.Dependency;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
|
||||
import net.lax1dude.eaglercraft.backend.eaglermotd.adapter.IEaglerMOTDImpl;
|
||||
import net.lax1dude.eaglercraft.backend.eaglermotd.adapter.IEaglerMOTDLogger;
|
||||
import net.lax1dude.eaglercraft.backend.eaglermotd.adapter.IEaglerMOTDPlatform;
|
||||
import net.lax1dude.eaglercraft.backend.eaglermotd.adapter.SLF4JLogger;
|
||||
import net.lax1dude.eaglercraft.backend.eaglermotd.base.EaglerMOTD;
|
||||
import net.lax1dude.eaglercraft.backend.eaglermotd.base.EaglerMOTDVersion;
|
||||
import net.lax1dude.eaglercraft.backend.server.api.event.IEaglercraftMOTDEvent;
|
||||
import net.lax1dude.eaglercraft.backend.server.api.velocity.EaglerXServerAPI;
|
||||
|
||||
@Plugin(
|
||||
id = PlatformPluginVelocity.PLUGIN_ID,
|
||||
name = PlatformPluginVelocity.PLUGIN_NAME,
|
||||
authors = {
|
||||
PlatformPluginVelocity.PLUGIN_AUTHOR
|
||||
},
|
||||
version = PlatformPluginVelocity.PLUGIN_VERSION,
|
||||
description = "Official EaglerMOTD plugin for EaglercraftXServer",
|
||||
dependencies = {
|
||||
@Dependency(id = EaglerXServerAPI.PLUGIN_ID, optional = false)
|
||||
}
|
||||
)
|
||||
public class PlatformPluginVelocity implements IEaglerMOTDPlatform<Player> {
|
||||
|
||||
public static final String PLUGIN_ID = "eaglermotd-reborn";
|
||||
public static final String PLUGIN_NAME = EaglerMOTDVersion.PLUGIN_BRAND;
|
||||
public static final String PLUGIN_AUTHOR = EaglerMOTDVersion.PLUGIN_AUTHOR;
|
||||
public static final String PLUGIN_VERSION = EaglerMOTDVersion.PLUGIN_VERSION;
|
||||
|
||||
private final ProxyServer proxy;
|
||||
private final Logger logger;
|
||||
private final File dataDir;
|
||||
private final SLF4JLogger rewindLogger;
|
||||
private final IEaglerMOTDImpl<Player> eaglermotd;
|
||||
private CommandMeta refreshCommandMeta;
|
||||
Consumer<IEaglercraftMOTDEvent<Player>> onMOTDHandler;
|
||||
IHandleReload handleReload;
|
||||
|
||||
@Inject
|
||||
public PlatformPluginVelocity(ProxyServer proxyIn, Logger loggerIn, @DataDirectory Path dataDirIn) {
|
||||
proxy = proxyIn;
|
||||
logger = loggerIn;
|
||||
dataDir = dataDirIn.toFile();
|
||||
rewindLogger = new SLF4JLogger(loggerIn);
|
||||
eaglermotd = new EaglerMOTD<>(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyInit(ProxyInitializeEvent e) {
|
||||
proxy.getEventManager().register(this, new VelocityListener(this));
|
||||
refreshCommandMeta = (new CommandEaglerMOTD(this)).register();
|
||||
eaglermotd.onEnable(EaglerXServerAPI.instance());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyShutdown(ProxyShutdownEvent e) {
|
||||
proxy.getEventManager().unregisterListeners(this);
|
||||
if (refreshCommandMeta != null) {
|
||||
proxy.getCommandManager().unregister(refreshCommandMeta);
|
||||
refreshCommandMeta = null;
|
||||
}
|
||||
eaglermotd.onDisable(EaglerXServerAPI.instance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEaglerMOTDLogger logger() {
|
||||
return rewindLogger;
|
||||
}
|
||||
|
||||
public ProxyServer proxy() {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnMOTD(Consumer<IEaglercraftMOTDEvent<Player>> handler) {
|
||||
this.onMOTDHandler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnReload(IHandleReload handleReload) {
|
||||
this.handleReload = handleReload;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return dataDir;
|
||||
}
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2025 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
package net.lax1dude.eaglercraft.backend.eaglermotd.velocity;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
||||
import net.lax1dude.eaglercraft.backend.server.api.event.IEaglercraftMOTDEvent;
|
||||
import net.lax1dude.eaglercraft.backend.server.api.velocity.event.EaglercraftMOTDEvent;
|
||||
|
||||
public class VelocityListener {
|
||||
|
||||
private final PlatformPluginVelocity plugin;
|
||||
|
||||
VelocityListener(PlatformPluginVelocity plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onEaglercraftMOTDEvent(EaglercraftMOTDEvent event) {
|
||||
Consumer<IEaglercraftMOTDEvent<Player>> consumer = plugin.onMOTDHandler;
|
||||
if (consumer != null) {
|
||||
consumer.accept(event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user