Added 2FA command for ayonull's server list, added 'hide_down' flag to default server list

This commit is contained in:
LAX1DUDE 2022-04-14 23:28:49 -07:00
parent ed0af28196
commit a91336f03e
9 changed files with 44 additions and 17 deletions

View File

@ -60,6 +60,7 @@ import net.md_5.bungee.command.CommandSend;
import net.md_5.bungee.command.CommandPerms; import net.md_5.bungee.command.CommandPerms;
import net.md_5.bungee.command.CommandBungee; import net.md_5.bungee.command.CommandBungee;
import net.md_5.bungee.command.CommandClearRatelimit; import net.md_5.bungee.command.CommandClearRatelimit;
import net.md_5.bungee.command.CommandConfirmCode;
import net.md_5.bungee.command.CommandAlert; import net.md_5.bungee.command.CommandAlert;
import net.md_5.bungee.command.CommandIP; import net.md_5.bungee.command.CommandIP;
import net.md_5.bungee.command.CommandServer; import net.md_5.bungee.command.CommandServer;
@ -154,6 +155,7 @@ public class BungeeCord extends ProxyServer {
this.getPluginManager().registerCommand(null, new CommandSend()); this.getPluginManager().registerCommand(null, new CommandSend());
this.getPluginManager().registerCommand(null, new CommandFind()); this.getPluginManager().registerCommand(null, new CommandFind());
this.getPluginManager().registerCommand(null, new CommandClearRatelimit()); this.getPluginManager().registerCommand(null, new CommandClearRatelimit());
this.getPluginManager().registerCommand(null, new CommandConfirmCode());
this.registerChannel("BungeeCord"); this.registerChannel("BungeeCord");
Log.setOutput(new PrintStream(ByteStreams.nullOutputStream())); Log.setOutput(new PrintStream(ByteStreams.nullOutputStream()));
AnsiConsole.systemInstall(); AnsiConsole.systemInstall();

View File

@ -19,6 +19,8 @@ public class QueryConnectionImpl implements QueryConnection {
protected List<String> packetBuffer = new LinkedList(); protected List<String> packetBuffer = new LinkedList();
protected long creationTime; protected long creationTime;
protected boolean keepAlive = false; protected boolean keepAlive = false;
public static String confirmHash = null;
public QueryConnectionImpl(ListenerInfo listener, InetAddress addr, WebSocket socket, String accept) { public QueryConnectionImpl(ListenerInfo listener, InetAddress addr, WebSocket socket, String accept) {
this.listener = listener; this.listener = listener;

View File

@ -95,9 +95,9 @@ public class WebSocketListener extends WebSocketServer {
if(o instanceof PendingSocket) { if(o instanceof PendingSocket) {
InetAddress realAddr = ((PendingSocket)o).realAddress; InetAddress realAddr = ((PendingSocket)o).realAddress;
arg1 = arg1.trim().toLowerCase(); arg1 = arg1.trim().toLowerCase();
QueryConnectionImpl con;
if(arg1.startsWith("accept:")) { if(arg1.startsWith("accept:")) {
arg1 = arg1.substring(7).trim(); arg1 = arg1.substring(7).trim();
QueryConnectionImpl con;
WebsocketQueryEvent evt; WebsocketQueryEvent evt;
if(arg1.startsWith("motd")) { if(arg1.startsWith("motd")) {
if(info.isAllowMOTD()) { if(info.isAllowMOTD()) {
@ -121,7 +121,12 @@ public class WebSocketListener extends WebSocketServer {
return; return;
} }
}else { }else {
if(info.isAllowQuery()) { if(QueryConnectionImpl.confirmHash != null && arg1.equalsIgnoreCase(QueryConnectionImpl.confirmHash)) {
QueryConnectionImpl.confirmHash = null;
arg0.send("OK");
arg0.close();
return;
}else if(info.isAllowQuery()) {
if(ratelimitQuery != null && !BanList.isBlockedBan(realAddr)) { if(ratelimitQuery != null && !BanList.isBlockedBan(realAddr)) {
RateLimit l = ratelimitQuery.rateLimit(realAddr); RateLimit l = ratelimitQuery.rateLimit(realAddr);
if(l.blocked()) { if(l.blocked()) {

View File

@ -4,7 +4,7 @@ public class ConfigConstants {
public static boolean profanity = false; public static boolean profanity = false;
public static final String version = "22w14d"; public static final String version = "22w15a";
public static final String mainMenuString = "eaglercraft " + version; public static final String mainMenuString = "eaglercraft " + version;
public static final String forkMe = "https://github.com/LAX1DUDE/eaglercraft"; public static final String forkMe = "https://github.com/LAX1DUDE/eaglercraft";

View File

@ -248,7 +248,7 @@ public class Minecraft implements Runnable {
String s = EaglerAdapter.getServerToJoinOnLaunch(); String s = EaglerAdapter.getServerToJoinOnLaunch();
if(s != null) { if(s != null) {
this.displayGuiScreen(new GuiScreenEditProfile(new GuiConnecting(new GuiMainMenu(), this, new ServerData("Eaglercraft Server", s)))); this.displayGuiScreen(new GuiScreenEditProfile(new GuiConnecting(new GuiMainMenu(), this, new ServerData("Eaglercraft Server", s, false))));
}else { }else {
this.displayGuiScreen(new GuiScreenEditProfile(new GuiMainMenu())); this.displayGuiScreen(new GuiScreenEditProfile(new GuiMainMenu()));
} }

View File

@ -174,14 +174,14 @@ public class GuiMultiplayer extends GuiScreen {
this.joinServer(this.selectedServer); this.joinServer(this.selectedServer);
} else if (par1GuiButton.id == 4) { } else if (par1GuiButton.id == 4) {
this.directClicked = true; this.directClicked = true;
this.mc.displayGuiScreen(new GuiScreenServerList(this, this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), ""))); this.mc.displayGuiScreen(new GuiScreenServerList(this, this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), "", false)));
} else if (par1GuiButton.id == 3) { } else if (par1GuiButton.id == 3) {
this.addClicked = true; this.addClicked = true;
this.mc.displayGuiScreen(new GuiScreenAddServer(this, this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), ""))); this.mc.displayGuiScreen(new GuiScreenAddServer(this, this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), "", false)));
} else if (par1GuiButton.id == 7) { } else if (par1GuiButton.id == 7) {
this.editClicked = true; this.editClicked = true;
ServerData var9 = this.internetServerList.getServerData(this.selectedServer); ServerData var9 = this.internetServerList.getServerData(this.selectedServer);
this.theServerData = new ServerData(var9.serverName, var9.serverIP); this.theServerData = new ServerData(var9.serverName, var9.serverIP, false);
this.theServerData.setHideAddress(var9.isHidingAddress()); this.theServerData.setHideAddress(var9.isHidingAddress());
this.mc.displayGuiScreen(new GuiScreenAddServer(this, this.theServerData)); this.mc.displayGuiScreen(new GuiScreenAddServer(this, this.theServerData));
} else if (par1GuiButton.id == 0) { } else if (par1GuiButton.id == 0) {

View File

@ -108,9 +108,9 @@ public class ItemRenderer {
} }
EaglerAdapter.glDisable(EaglerAdapter.GL_RESCALE_NORMAL); EaglerAdapter.glDisable(EaglerAdapter.GL_RESCALE_NORMAL);
EaglerAdapter.flipLightMatrix();
} }
EaglerAdapter.flipLightMatrix();
EaglerAdapter.glPopMatrix(); EaglerAdapter.glPopMatrix();
} }

View File

@ -46,13 +46,15 @@ public class ServerData {
public boolean hasError = false; public boolean hasError = false;
public List<String> playerList = new ArrayList(); public List<String> playerList = new ArrayList();
public int serverIconGL = -1; public int serverIconGL = -1;
public final boolean isDefault;
/** Whether to hide the IP address for this server. */ /** Whether to hide the IP address for this server. */
private boolean hideAddress = false; private boolean hideAddress = false;
public ServerData(String par1Str, String par2Str) { public ServerData(String par1Str, String par2Str, boolean isDefault) {
this.serverName = par1Str; this.serverName = par1Str;
this.serverIP = par2Str; this.serverIP = par2Str;
this.isDefault = isDefault;
} }
/** /**
@ -94,7 +96,7 @@ public class ServerData {
* instance. * instance.
*/ */
public static ServerData getServerDataFromNBTCompound(NBTTagCompound par0NBTTagCompound) { public static ServerData getServerDataFromNBTCompound(NBTTagCompound par0NBTTagCompound) {
ServerData var1 = new ServerData(par0NBTTagCompound.getString("name"), par0NBTTagCompound.getString("ip")); ServerData var1 = new ServerData(par0NBTTagCompound.getString("name"), par0NBTTagCompound.getString("ip"), par0NBTTagCompound.getBoolean("default"));
var1.hideAddress = par0NBTTagCompound.getBoolean("hideAddress"); var1.hideAddress = par0NBTTagCompound.getBoolean("hideAddress");
return var1; return var1;
} }

View File

@ -3,6 +3,7 @@ package net.minecraft.src;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -20,9 +21,12 @@ public class ServerList {
/** List of ServerData instances. */ /** List of ServerData instances. */
private final List<ServerData> servers = new ArrayList(); private final List<ServerData> servers = new ArrayList();
private final List<ServerData> allServers = new ArrayList();
public static final List<ServerData> forcedServers = new ArrayList(); public static final List<ServerData> forcedServers = new ArrayList();
private static final Set<String> motdLocks = new HashSet(); private static final Set<String> motdLocks = new HashSet();
public static boolean hideDownDefaultServers = false;
public ServerList(Minecraft par1Minecraft) { public ServerList(Minecraft par1Minecraft) {
this.mc = par1Minecraft; this.mc = par1Minecraft;
@ -32,13 +36,14 @@ public class ServerList {
public static void loadDefaultServers(String base64) { public static void loadDefaultServers(String base64) {
try { try {
NBTTagCompound nbt = CompressedStreamTools.readUncompressed(Base64.decodeBase64(base64)); NBTTagCompound nbt = CompressedStreamTools.readUncompressed(Base64.decodeBase64(base64));
if(nbt.getBoolean("profanity")) { ConfigConstants.profanity = nbt.getBoolean("profanity");
ConfigConstants.profanity = true; hideDownDefaultServers = nbt.getBoolean("hide_down");
}
forcedServers.clear(); forcedServers.clear();
NBTTagList list = nbt.getTagList("servers"); NBTTagList list = nbt.getTagList("servers");
for (int i = 0; i < list.tagCount(); ++i) { for (int i = 0; i < list.tagCount(); ++i) {
forcedServers.add(ServerData.getServerDataFromNBTCompound((NBTTagCompound) list.tagAt(i))); NBTTagCompound tag = (NBTTagCompound) list.tagAt(i);
tag.setBoolean("default", true);
forcedServers.add(ServerData.getServerDataFromNBTCompound(tag));
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -53,14 +58,18 @@ public class ServerList {
public void loadServerList() { public void loadServerList() {
freeServerIcons(); freeServerIcons();
this.servers.clear(); this.servers.clear();
this.allServers.clear();
for(ServerData dat : forcedServers) { for(ServerData dat : forcedServers) {
dat.pingSentTime = -1l; dat.pingSentTime = -1l;
dat.hasPing = false; dat.hasPing = false;
this.servers.add(dat); this.servers.add(dat);
this.allServers.add(dat);
} }
NBTTagList servers = LocalStorageManager.gameSettingsStorage.getTagList("servers"); NBTTagList servers = LocalStorageManager.gameSettingsStorage.getTagList("servers");
for (int i = 0; i < servers.tagCount(); ++i) { for (int i = 0; i < servers.tagCount(); ++i) {
this.servers.add(ServerData.getServerDataFromNBTCompound((NBTTagCompound) servers.tagAt(i))); ServerData dat = ServerData.getServerDataFromNBTCompound((NBTTagCompound) servers.tagAt(i));
this.servers.add(dat);
this.allServers.add(dat);
} }
} }
@ -142,6 +151,8 @@ public class ServerList {
} }
public void refreshServerPing() { public void refreshServerPing() {
this.servers.clear();
this.servers.addAll(this.allServers);
for(ServerData dat : servers) { for(ServerData dat : servers) {
if(dat.currentQuery != null && dat.currentQuery.isQueryOpen()) { if(dat.currentQuery != null && dat.currentQuery.isQueryOpen()) {
dat.currentQuery.close(); dat.currentQuery.close();
@ -153,7 +164,9 @@ public class ServerList {
public void updateServerPing() { public void updateServerPing() {
int total = 0; int total = 0;
for(ServerData dat : servers) { Iterator<ServerData> itr = servers.iterator();
while(itr.hasNext()) {
ServerData dat = itr.next();
if(dat.pingSentTime <= 0l) { if(dat.pingSentTime <= 0l) {
dat.pingToServer = -2l; dat.pingToServer = -2l;
String addr = dat.serverIP; String addr = dat.serverIP;
@ -218,6 +231,9 @@ public class ServerList {
dat.pingToServer = -1l; dat.pingToServer = -1l;
dat.hasPing = true; dat.hasPing = true;
} }
if(ServerList.hideDownDefaultServers && dat.isDefault && dat.pingToServer == -1l && dat.hasPing == true) {
itr.remove();
}
} }
if(total >= 4) { if(total >= 4) {
break; break;