去除 lombok 化,轻量化模块

This commit is contained in:
筱锋xiao_lfeng 2023-10-19 19:29:01 +08:00
parent 2c1a5cce36
commit 069b78a225
7 changed files with 97 additions and 49 deletions

View File

@ -59,6 +59,10 @@
<id>aliyun</id> <id>aliyun</id>
<url>https://maven.aliyun.com/repository/</url> <url>https://maven.aliyun.com/repository/</url>
</repository> </repository>
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
@ -68,11 +72,6 @@
<version>1.20-R0.2-SNAPSHOT</version> <version>1.20-R0.2-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.28</version>
</dependency>
<dependency> <dependency>
<groupId>org.jetbrains</groupId> <groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId> <artifactId>annotations</artifactId>

View File

@ -8,7 +8,6 @@ import com.frontleaves.bungeecross.configuration.ServerEnable;
import com.frontleaves.bungeecross.configuration.VariableStorage; import com.frontleaves.bungeecross.configuration.VariableStorage;
import com.frontleaves.bungeecross.events.PlayerJoinProxyEvent; import com.frontleaves.bungeecross.events.PlayerJoinProxyEvent;
import com.frontleaves.bungeecross.events.PlayerLeaveProxyEvent; import com.frontleaves.bungeecross.events.PlayerLeaveProxyEvent;
import lombok.Getter;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
/** /**
@ -16,9 +15,7 @@ import net.md_5.bungee.api.plugin.Plugin;
* @version final VERSION 变量 * @version final VERSION 变量
*/ */
public final class BungeeCross extends Plugin { public final class BungeeCross extends Plugin {
@Getter
private final static String VERSION = "v1.0-SNAPSHOT"; private final static String VERSION = "v1.0-SNAPSHOT";
@Getter
private final static String AUTHOR = "筱锋xiao_lfeng"; private final static String AUTHOR = "筱锋xiao_lfeng";
@Override @Override
@ -31,7 +28,7 @@ public final class BungeeCross extends Plugin {
getProxy().getPluginManager().registerCommand(this, new ProxyServerListCommand("server-list")); getProxy().getPluginManager().registerCommand(this, new ProxyServerListCommand("server-list"));
getProxy().getPluginManager().registerCommand(this, new ReturnHubCommand("lobby", this)); getProxy().getPluginManager().registerCommand(this, new ReturnHubCommand("lobby", this));
getProxy().getPluginManager().registerCommand(this, new SendToServerCommand("serverTo", this)); getProxy().getPluginManager().registerCommand(this, new SendToServerCommand("serverTo", this));
getProxy().getPluginManager().registerCommand(this, new SendToServerCommand("sto", this)); getProxy().getPluginManager().registerCommand(this, new SendToServerCommand("bro", this));
// 注册监听器 // 注册监听器
getProxy().getPluginManager().registerListener(this, new PlayerJoinProxyEvent(this)); getProxy().getPluginManager().registerListener(this, new PlayerJoinProxyEvent(this));
getProxy().getPluginManager().registerListener(this, new PlayerLeaveProxyEvent(this)); getProxy().getPluginManager().registerListener(this, new PlayerLeaveProxyEvent(this));
@ -44,4 +41,12 @@ public final class BungeeCross extends Plugin {
VariableStorage.setPrefix(null); VariableStorage.setPrefix(null);
VariableStorage.setProxyServer(null); VariableStorage.setProxyServer(null);
} }
public static String getVersion() {
return VERSION;
}
public static String getAuthor() {
return AUTHOR;
}
} }

View File

@ -34,7 +34,7 @@ public class PluginInfoCommand extends Command {
} }
} else if ("update".equals(strings[0])) { } else if ("update".equals(strings[0])) {
if (commandSender.hasPermission("bungeecross.admin")) { if (commandSender.hasPermission("bungeecross.admin")) {
commandSender.sendMessage(VariableStorage.getPrefix() + "您的版本为最新的 " + BungeeCross.getVERSION()); commandSender.sendMessage(VariableStorage.getPrefix() + "您的版本为最新的 " + BungeeCross.getVersion());
} else { } else {
commandSender.sendMessage(VariableStorage.getPrefix() + "您不是管理员,无法进行操作"); commandSender.sendMessage(VariableStorage.getPrefix() + "您不是管理员,无法进行操作");
} }
@ -46,8 +46,8 @@ public class PluginInfoCommand extends Command {
default: { default: {
commandSender.sendMessage("§9§l§m=]=======§2 Bungee§aCross §9§l§m========[="); commandSender.sendMessage("§9§l§m=]=======§2 Bungee§aCross §9§l§m========[=");
commandSender.sendMessage(VariableStorage.getPrefix() + "跨服插件§2Bungee§aCross"); commandSender.sendMessage(VariableStorage.getPrefix() + "跨服插件§2Bungee§aCross");
commandSender.sendMessage(VariableStorage.getPrefix() + "§6作者§e" + BungeeCross.getAUTHOR()); commandSender.sendMessage(VariableStorage.getPrefix() + "§6作者§e" + BungeeCross.getAuthor());
commandSender.sendMessage(VariableStorage.getPrefix() + "§9版本§d" + BungeeCross.getVERSION()); commandSender.sendMessage(VariableStorage.getPrefix() + "§9版本§d" + BungeeCross.getVersion());
commandSender.sendMessage(VariableStorage.getPrefix() + "§b您的版本为最新的"); commandSender.sendMessage(VariableStorage.getPrefix() + "§b您的版本为最新的");
commandSender.sendMessage("§9§l§m=]=======§2 Bungee§aCross §9§l§m========[="); commandSender.sendMessage("§9§l§m=]=======§2 Bungee§aCross §9§l§m========[=");
} }

View File

@ -25,13 +25,13 @@ public class ProxyServerListCommand extends Command {
serverList = null; serverList = null;
VariableStorage.getProxyServer().forEach((key, serverInfo) -> { VariableStorage.getProxyServer().forEach((key, serverInfo) -> {
if (serverList == null) { if (serverList == null) {
serverList = new StringBuilder("\t" + serverInfo.getName()); serverList = new StringBuilder(" §6" + serverInfo.getName());
} else { } else {
serverList.append(", ").append(serverInfo.getName()); serverList.append("§r, §6").append(serverInfo.getName());
} }
}); });
// 返回列表信息 // 返回列表信息
commandSender.sendMessage(VariableStorage.getPrefix() + "当前服务器如下:"); commandSender.sendMessage(VariableStorage.getPrefix() + "§e当前服务器如下:");
commandSender.sendMessage(serverList.toString()); commandSender.sendMessage(serverList.toString());
} }
} }

View File

@ -17,8 +17,10 @@ import org.jetbrains.annotations.NotNull;
*/ */
public class SendToServerCommand extends Command { public class SendToServerCommand extends Command {
private final BungeeCross plugin; private final BungeeCross plugin;
private static String name;
public SendToServerCommand(String name, BungeeCross bungeeCross) { public SendToServerCommand(String name, BungeeCross bungeeCross) {
super(name); super(name);
SendToServerCommand.name = name;
plugin = bungeeCross; plugin = bungeeCross;
} }
@ -111,7 +113,7 @@ public class SendToServerCommand extends Command {
} }
break; break;
default: { default: {
commandSender.sendMessage(VariableStorage.getPrefix() + "使用方法 /sto <ServerName> [player]"); commandSender.sendMessage(VariableStorage.getPrefix() + "使用方法 /" + name + " <ServerName> [player]");
} }
} }
} }

View File

@ -1,7 +1,6 @@
package com.frontleaves.bungeecross.configuration; package com.frontleaves.bungeecross.configuration;
import com.frontleaves.bungeecross.BungeeCross; import com.frontleaves.bungeecross.BungeeCross;
import lombok.RequiredArgsConstructor;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.config.Configuration; import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.ConfigurationProvider;
@ -13,15 +12,19 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
/** /**
* 服务器启动执行操作 * 服务器启动操作内容
* *
* @author 筱锋xiao_lfeng * @author 筱锋xiao_lfeng
*/ */
@RequiredArgsConstructor
public class ServerEnable { public class ServerEnable {
private final BungeeCross plugin; private final BungeeCross plugin;
public ServerEnable(BungeeCross plugin) {
this.plugin = plugin;
}
/** /**
* 服务器启动内容 * 服务器启动内容
*/ */
@ -32,8 +35,8 @@ public class ServerEnable {
System.out.println(VariableStorage.getPrefix() + "§c配置文件加载完毕"); System.out.println(VariableStorage.getPrefix() + "§c配置文件加载完毕");
System.out.println("§9§l§m=]=======§2 Bungee§aCross §9§l§m========[="); System.out.println("§9§l§m=]=======§2 Bungee§aCross §9§l§m========[=");
System.out.println("§6作者§e" + BungeeCross.getAUTHOR()); System.out.println("§6作者§e" + BungeeCross.getAuthor());
System.out.println("§9版本§d" + BungeeCross.getVERSION()); System.out.println("§9版本§d" + BungeeCross.getVersion());
System.out.println("§9§l§m=]=======§2 Bungee§aCross §9§l§m========[="); System.out.println("§9§l§m=]=======§2 Bungee§aCross §9§l§m========[=");
} }
@ -43,8 +46,8 @@ public class ServerEnable {
System.out.println(VariableStorage.getPrefix() + "§c配置文件重载完毕"); System.out.println(VariableStorage.getPrefix() + "§c配置文件重载完毕");
System.out.println("§9§l§m=]=======§2 Bungee§aCross §9§l§m========[="); System.out.println("§9§l§m=]=======§2 Bungee§aCross §9§l§m========[=");
System.out.println("§6作者§e" + BungeeCross.getAUTHOR()); System.out.println("§6作者§e" + BungeeCross.getAuthor());
System.out.println("§9版本§d" + BungeeCross.getVERSION()); System.out.println("§9版本§d" + BungeeCross.getVersion());
System.out.println("§9§l§m=]=======§2 Bungee§aCross §9§l§m========[="); System.out.println("§9§l§m=]=======§2 Bungee§aCross §9§l§m========[=");
} }

View File

@ -1,7 +1,5 @@
package com.frontleaves.bungeecross.configuration; package com.frontleaves.bungeecross.configuration;
import lombok.Getter;
import lombok.Setter;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import java.util.List; import java.util.List;
@ -13,35 +11,76 @@ import java.util.Map;
* @author 筱锋xiao_lfeng * @author 筱锋xiao_lfeng
*/ */
public class VariableStorage { public class VariableStorage {
@Getter
@Setter
private static String prefix; private static String prefix;
@Getter
@Setter
private static Map<String, ServerInfo> proxyServer; private static Map<String, ServerInfo> proxyServer;
@Getter
@Setter
private static List<?> loginServer; private static List<?> loginServer;
@Getter
@Setter
private static List<?> lobbyServer; private static List<?> lobbyServer;
@Getter
@Setter
private static boolean bungeeCordReminder; private static boolean bungeeCordReminder;
@Getter
@Setter
private static String joinMessage; private static String joinMessage;
@Getter
@Setter
private static String leaveMessage; private static String leaveMessage;
@Getter
@Setter
private static boolean bungeeSilent; private static boolean bungeeSilent;
public static String getPrefix() {
return prefix;
}
public static void setPrefix(String prefix) {
VariableStorage.prefix = prefix;
}
public static Map<String, ServerInfo> getProxyServer() {
return proxyServer;
}
public static void setProxyServer(Map<String, ServerInfo> proxyServer) {
VariableStorage.proxyServer = proxyServer;
}
public static List<?> getLoginServer() {
return loginServer;
}
public static void setLoginServer(List<?> loginServer) {
VariableStorage.loginServer = loginServer;
}
public static List<?> getLobbyServer() {
return lobbyServer;
}
public static void setLobbyServer(List<?> lobbyServer) {
VariableStorage.lobbyServer = lobbyServer;
}
public static boolean isBungeeCordReminder() {
return bungeeCordReminder;
}
public static void setBungeeCordReminder(boolean bungeeCordReminder) {
VariableStorage.bungeeCordReminder = bungeeCordReminder;
}
public static String getJoinMessage() {
return joinMessage;
}
public static void setJoinMessage(String joinMessage) {
VariableStorage.joinMessage = joinMessage;
}
public static String getLeaveMessage() {
return leaveMessage;
}
public static void setLeaveMessage(String leaveMessage) {
VariableStorage.leaveMessage = leaveMessage;
}
public static boolean isBungeeSilent() {
return bungeeSilent;
}
public static void setBungeeSilent(boolean bungeeSilent) {
VariableStorage.bungeeSilent = bungeeSilent;
}
} }