Compare commits

..

3 Commits

Author SHA1 Message Date
ham1255 43c3edf5c6 new diclaimer message 2023-03-25 14:22:01 +04:00
ham1255 6c1699b2c5 fix broken history / geyser support 2023-03-18 20:10:43 +04:00
ham1255 a58191a961 glomc fork 2023-01-14 12:42:08 +04:00
6 changed files with 57 additions and 20 deletions
@@ -3,8 +3,8 @@ package net.limework.gal.utils;
/** /**
* @since 1.0.0 * @since 1.0.0
* *
* @// TODO: 12/14/21 move the messages into A Config file in yaml or json
*/ */
@Deprecated
public class Messages { public class Messages {
// //
public final static String FAILED_CONNECTION = """ public final static String FAILED_CONNECTION = """
@@ -18,14 +18,10 @@ public class Messages {
1. Mojang / Microsoft api is down\040\040\040\040\040\040\040\040\040 1. Mojang / Microsoft api is down\040\040\040\040\040\040\040\040\040
2. Disconnecting when connection to a server faster! 2. Disconnecting when connection to a server faster!
3. Using cracked minecraft (if you are using cracked Minecraft please reconnect! 3. Using cracked minecraft (if you are using cracked Minecraft please reconnect!
&6If this a mistake and you own a Minecraft account\040
&cPlease connect to &a&lreset.limework.net\040\040
&2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m""".replace("&", "§"); &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m""".replace("&", "§");
public final static String RESET_MESSAGE = """ public final static String RESET_MESSAGE = """
&2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m &2&m
&6- &a&lGovindas Limework&6 -
&aOffline mode has been disabled &l✔ &aOffline mode has been disabled &l✔
&cNow try reconnecting to server now! &cNow try reconnecting to server now!
@@ -37,9 +33,6 @@ public class Messages {
&c&l============================ &c&l============================
&c&oYou have been found using Offline Minecraft (Cracked) &c&oYou have been found using Offline Minecraft (Cracked)
&cIf this a mistake and you own a Minecraft account\s
&ePlease disconnect from the server and connect to
&eIP: p.limework.net
&c&l============================ &c&l============================
""".replace("&", "§"); """.replace("&", "§");
@@ -5,6 +5,8 @@ public interface Configuration {
char getCrackedChar(); char getCrackedChar();
String getCrackedCharString(); String getCrackedCharString();
char getBedrockChar();
boolean doReplaceSpacesWithUnderscore(); boolean doReplaceSpacesWithUnderscore();
boolean useTheContainMethod(); boolean useTheContainMethod();
@@ -13,6 +15,8 @@ public interface Configuration {
String getOnlineModeDomain(); String getOnlineModeDomain();
String[] getDisclaimerMessage();
+10 -1
View File
@@ -1,10 +1,19 @@
{ {
"default-cracked-char": "-", "default-cracked-char": "-",
"bedrock-char": "*",
"replace-spaces-with-underscore": true, "replace-spaces-with-underscore": true,
"use-the-contain-method": false, "use-the-contain-method": false,
"simple-anti-bot": { "simple-anti-bot": {
"max-connections": 590, "max-connections": 590,
"reset": 10 "reset": 10
}, },
"online-mode-domain": "p.limework.net" "online-mode-domain": "p.limework.net",
"disclaimer-message": [
"§e=======================================",
"§eHi there, welcome to §a§LGovindas Limework",
"§eYou are logged in As Offline player and identified as %player-name%",
"§eif this a mistake please disconnect and connect to",
"§ep.limework.net",
"§e======================================="
]
} }
+1 -1
View File
@@ -44,7 +44,7 @@
<dependency> <dependency>
<groupId>com.velocitypowered</groupId> <groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId> <artifactId>velocity-api</artifactId>
<version>3.1.0</version> <version>3.2.0-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@@ -8,24 +8,34 @@ import net.limework.gal.utils.config.Configuration;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class ConfigLoader implements Configuration { public class ConfigLoader implements Configuration {
private final char crackedChar; private final char crackedChar;
private final char bedrockChar;
private final boolean replaceSpacesWithUnderscore; private final boolean replaceSpacesWithUnderscore;
private final boolean useTheContainMethod; private final boolean useTheContainMethod;
private final AntiBot antiBot; private final AntiBot antiBot;
private final String onlineModeDomain; private final String onlineModeDomain;
private final String[] disclaimerMessage;
public ConfigLoader(File file) throws FileNotFoundException { public ConfigLoader(File file) throws FileNotFoundException {
JsonObject jsonObject = JsonParser.parseReader(new FileReader(file)).getAsJsonObject(); JsonObject jsonObject = JsonParser.parseReader(new FileReader(file)).getAsJsonObject();
this.crackedChar = (jsonObject.get("default-cracked-char").getAsString().charAt(0)); this.crackedChar = (jsonObject.get("default-cracked-char").getAsString().charAt(0));
this.bedrockChar = (jsonObject.get("bedrock-char").getAsString().charAt(0));
this.replaceSpacesWithUnderscore = jsonObject.get("replace-spaces-with-underscore").getAsBoolean(); this.replaceSpacesWithUnderscore = jsonObject.get("replace-spaces-with-underscore").getAsBoolean();
this.useTheContainMethod = jsonObject.get("use-the-contain-method").getAsBoolean(); this.useTheContainMethod = jsonObject.get("use-the-contain-method").getAsBoolean();
JsonObject antiBotJson = jsonObject.getAsJsonObject("simple-anti-bot"); JsonObject antiBotJson = jsonObject.getAsJsonObject("simple-anti-bot");
this.antiBot = new AntiBot(antiBotJson.get("max-connections").getAsInt(), antiBotJson.get("reset").getAsLong(), TimeUnit.MINUTES); this.antiBot = new AntiBot(antiBotJson.get("max-connections").getAsInt(), antiBotJson.get("reset").getAsLong(), TimeUnit.MINUTES);
this.onlineModeDomain = jsonObject.get("online-mode-domain").getAsString(); this.onlineModeDomain = jsonObject.get("online-mode-domain").getAsString();
ArrayList<String> message = new ArrayList<>();
jsonObject.getAsJsonArray("disclaimer-message").forEach((element) -> {
message.add(element.getAsString());
});
disclaimerMessage = message.toArray(new String[0]);
} }
@Override @Override
@@ -38,6 +48,11 @@ public class ConfigLoader implements Configuration {
return String.valueOf(this.crackedChar); return String.valueOf(this.crackedChar);
} }
@Override
public char getBedrockChar() {
return this.bedrockChar;
}
@Override @Override
public boolean doReplaceSpacesWithUnderscore() { public boolean doReplaceSpacesWithUnderscore() {
return this.replaceSpacesWithUnderscore; return this.replaceSpacesWithUnderscore;
@@ -57,4 +72,9 @@ public class ConfigLoader implements Configuration {
public String getOnlineModeDomain() { public String getOnlineModeDomain() {
return this.onlineModeDomain; return this.onlineModeDomain;
} }
@Override
public String[] getDisclaimerMessage() {
return this.disclaimerMessage;
}
} }
@@ -1,8 +1,7 @@
package net.limework.gal; package net.limework.gal;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.internal.Messages;
import com.velocitypowered.api.event.PostOrder; import com.velocitypowered.api.event.PostOrder;
import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PostLoginEvent; import com.velocitypowered.api.event.connection.PostLoginEvent;
@@ -14,7 +13,8 @@ import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.api.util.GameProfile;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.limework.gal.utils.Messages; import net.kyori.adventure.text.ComponentBuilder;
import net.kyori.adventure.text.TextComponent;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@@ -22,11 +22,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.*;
import java.util.Locale;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger; import java.util.logging.Logger;
import static net.limework.gal.utils.PlayerUUIDUtils.*; import static net.limework.gal.utils.PlayerUUIDUtils.*;
@@ -79,8 +75,12 @@ public class VelocityGalPlugin {
} }
} }
@Subscribe
@Subscribe(order = PostOrder.LAST)
public void onGameProfileRequestEvent(GameProfileRequestEvent event) { public void onGameProfileRequestEvent(GameProfileRequestEvent event) {
if (event.getGameProfile().getName().charAt(0) == config.getBedrockChar()) {
return;
}
if (!event.isOnlineMode()) { if (!event.isOnlineMode()) {
logger.info("handling " + event.getUsername()); logger.info("handling " + event.getUsername());
String username = getCorrectCrackedUsername(event.getUsername(), config); String username = getCorrectCrackedUsername(event.getUsername(), config);
@@ -94,9 +94,20 @@ public class VelocityGalPlugin {
@Subscribe @Subscribe
public void onPostLoginEvent(PostLoginEvent event) { public void onPostLoginEvent(PostLoginEvent event) {
if (isCrackedPlayer(event.getPlayer().getUsername(), this.config)) { if (isCrackedPlayer(event.getPlayer().getUsername(), this.config)) {
event.getPlayer().sendMessage(Component.text(Messages.cracked_disclaimer)); event.getPlayer().sendMessage(getDisclaimerMessage(event.getPlayer().getUsername()));
} }
} }
private Component getDisclaimerMessage(String playerName) {
List<String> messages = Arrays.stream(config.getDisclaimerMessage()).toList();
Component component = Component.text("");
for (String message : messages) {
message = message.replace("%player-name%", playerName);
System.out.println(message);
component = component.append(Component.text(message)).append(Component.newline());
}
return component;
}
public ProxyServer getProxyServer() { public ProxyServer getProxyServer() {
return proxyServer; return proxyServer;
} }