Compare commits
3 Commits
5d995022e7
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 43c3edf5c6 | |||
| 6c1699b2c5 | |||
| a58191a961 |
@@ -3,8 +3,8 @@ package net.limework.gal.utils;
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @// TODO: 12/14/21 move the messages into A Config file in yaml or json
|
||||
*/
|
||||
@Deprecated
|
||||
public class Messages {
|
||||
//
|
||||
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
|
||||
2. Disconnecting when connection to a server faster!
|
||||
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("&", "§");
|
||||
|
||||
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
|
||||
&6- &a&lGovindas Limework&6 -
|
||||
|
||||
&aOffline mode has been disabled &l✔
|
||||
&cNow try reconnecting to server now!
|
||||
@@ -37,9 +33,6 @@ public class Messages {
|
||||
|
||||
&c&l============================
|
||||
&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============================
|
||||
""".replace("&", "§");
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ public interface Configuration {
|
||||
char getCrackedChar();
|
||||
String getCrackedCharString();
|
||||
|
||||
char getBedrockChar();
|
||||
|
||||
boolean doReplaceSpacesWithUnderscore();
|
||||
|
||||
boolean useTheContainMethod();
|
||||
@@ -13,6 +15,8 @@ public interface Configuration {
|
||||
|
||||
String getOnlineModeDomain();
|
||||
|
||||
String[] getDisclaimerMessage();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
{
|
||||
"default-cracked-char": "-",
|
||||
"bedrock-char": "*",
|
||||
"replace-spaces-with-underscore": true,
|
||||
"use-the-contain-method": false,
|
||||
"simple-anti-bot": {
|
||||
"max-connections": 590,
|
||||
"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======================================="
|
||||
]
|
||||
}
|
||||
@@ -44,7 +44,7 @@
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.2.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -8,24 +8,34 @@ import net.limework.gal.utils.config.Configuration;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ConfigLoader implements Configuration {
|
||||
|
||||
private final char crackedChar;
|
||||
private final char bedrockChar;
|
||||
private final boolean replaceSpacesWithUnderscore;
|
||||
private final boolean useTheContainMethod;
|
||||
private final AntiBot antiBot;
|
||||
private final String onlineModeDomain;
|
||||
|
||||
private final String[] disclaimerMessage;
|
||||
|
||||
public ConfigLoader(File file) throws FileNotFoundException {
|
||||
JsonObject jsonObject = JsonParser.parseReader(new FileReader(file)).getAsJsonObject();
|
||||
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.useTheContainMethod = jsonObject.get("use-the-contain-method").getAsBoolean();
|
||||
JsonObject antiBotJson = jsonObject.getAsJsonObject("simple-anti-bot");
|
||||
this.antiBot = new AntiBot(antiBotJson.get("max-connections").getAsInt(), antiBotJson.get("reset").getAsLong(), TimeUnit.MINUTES);
|
||||
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
|
||||
@@ -38,6 +48,11 @@ public class ConfigLoader implements Configuration {
|
||||
return String.valueOf(this.crackedChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getBedrockChar() {
|
||||
return this.bedrockChar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doReplaceSpacesWithUnderscore() {
|
||||
return this.replaceSpacesWithUnderscore;
|
||||
@@ -57,4 +72,9 @@ public class ConfigLoader implements Configuration {
|
||||
public String getOnlineModeDomain() {
|
||||
return this.onlineModeDomain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getDisclaimerMessage() {
|
||||
return this.disclaimerMessage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
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.internal.Messages;
|
||||
import com.velocitypowered.api.event.PostOrder;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
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.util.GameProfile;
|
||||
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.FileNotFoundException;
|
||||
@@ -22,11 +22,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static net.limework.gal.utils.PlayerUUIDUtils.*;
|
||||
@@ -79,8 +75,12 @@ public class VelocityGalPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@Subscribe(order = PostOrder.LAST)
|
||||
public void onGameProfileRequestEvent(GameProfileRequestEvent event) {
|
||||
if (event.getGameProfile().getName().charAt(0) == config.getBedrockChar()) {
|
||||
return;
|
||||
}
|
||||
if (!event.isOnlineMode()) {
|
||||
logger.info("handling " + event.getUsername());
|
||||
String username = getCorrectCrackedUsername(event.getUsername(), config);
|
||||
@@ -94,9 +94,20 @@ public class VelocityGalPlugin {
|
||||
@Subscribe
|
||||
public void onPostLoginEvent(PostLoginEvent event) {
|
||||
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() {
|
||||
return proxyServer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user