finishing all govindas requests
This commit is contained in:
parent
562e8ff014
commit
20a47229ef
@ -33,4 +33,15 @@ public class Messages {
|
|||||||
&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 cracked_disclaimer = """
|
||||||
|
&c&oYou have been found using Offline minecraft (Cracked)
|
||||||
|
&7&o This could happen because:
|
||||||
|
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 disconnect from the server and connect to
|
||||||
|
&areset.limework.net""".replace("&", "§");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.google.common.cache.CacheBuilder;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
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.PreLoginEvent;
|
import com.velocitypowered.api.event.connection.PreLoginEvent;
|
||||||
import com.velocitypowered.api.event.player.GameProfileRequestEvent;
|
import com.velocitypowered.api.event.player.GameProfileRequestEvent;
|
||||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||||
@ -40,17 +41,12 @@ public class VelocityGalPlugin {
|
|||||||
private final ConfigLoader config;
|
private final ConfigLoader config;
|
||||||
private final Cache<String, Long> secondAttemptAsCrackedCache;
|
private final Cache<String, Long> secondAttemptAsCrackedCache;
|
||||||
private final Cache<String, Object> offlineModePlayers;
|
private final Cache<String, Object> offlineModePlayers;
|
||||||
private final Cache<String, Object> showFailedMessage;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public VelocityGalPlugin(ProxyServer proxyServer, Logger logger, @DataDirectory Path dataDirectory) {
|
public VelocityGalPlugin(ProxyServer proxyServer, Logger logger, @DataDirectory Path dataDirectory) {
|
||||||
this.proxyServer = proxyServer;
|
this.proxyServer = proxyServer;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.dataFolder = dataDirectory.toFile();
|
this.dataFolder = dataDirectory.toFile();
|
||||||
this.showFailedMessage = CacheBuilder.newBuilder()
|
|
||||||
.maximumSize(4000)
|
|
||||||
.expireAfterWrite(10, TimeUnit.MINUTES)
|
|
||||||
.build();
|
|
||||||
this.offlineModePlayers = CacheBuilder.newBuilder()
|
this.offlineModePlayers = CacheBuilder.newBuilder()
|
||||||
.maximumSize(4000)
|
.maximumSize(4000)
|
||||||
.expireAfterWrite(48, TimeUnit.HOURS)
|
.expireAfterWrite(48, TimeUnit.HOURS)
|
||||||
@ -87,26 +83,21 @@ public class VelocityGalPlugin {
|
|||||||
@Subscribe(order = PostOrder.FIRST)
|
@Subscribe(order = PostOrder.FIRST)
|
||||||
public void onPreLoginEvent(PreLoginEvent event) {
|
public void onPreLoginEvent(PreLoginEvent event) {
|
||||||
if (event.getConnection().getVirtualHost().get().getHostName().toLowerCase(Locale.ROOT).equals(config.getResetDomain())) {
|
if (event.getConnection().getVirtualHost().get().getHostName().toLowerCase(Locale.ROOT).equals(config.getResetDomain())) {
|
||||||
secondAttemptAsCrackedCache.invalidate(event.getUsername() + event.getConnection().getRemoteAddress().getHostName());
|
secondAttemptAsCrackedCache.invalidate(getCorrectCrackedUsername(event.getUsername(), config) + event.getConnection().getRemoteAddress().getHostName());
|
||||||
showFailedMessage.invalidate(event.getUsername() + event.getConnection().getRemoteAddress().getHostName());
|
offlineModePlayers.invalidate(getCorrectCrackedUsername(event.getUsername(), config) + event.getConnection().getRemoteAddress().getHostName());
|
||||||
offlineModePlayers.invalidate(event.getUsername() + event.getConnection().getRemoteAddress().getHostName());
|
|
||||||
event.setResult(PreLoginEvent.PreLoginComponentResult.denied(Component.text(Messages.RESET_MESSAGE)));
|
event.setResult(PreLoginEvent.PreLoginComponentResult.denied(Component.text(Messages.RESET_MESSAGE)));
|
||||||
} else if (isCrackedPlayer(event.getUsername(), config)) {
|
} else if (isCrackedPlayer(event.getUsername(), config)) {
|
||||||
event.setResult(PreLoginEvent.PreLoginComponentResult.forceOfflineMode());
|
event.setResult(PreLoginEvent.PreLoginComponentResult.forceOfflineMode());
|
||||||
} else if (offlineModePlayers.getIfPresent(event.getUsername() + event.getConnection().getRemoteAddress().getHostName()) != null) {
|
} else if (offlineModePlayers.getIfPresent(getCorrectCrackedUsername(event.getUsername(), config) + event.getConnection().getRemoteAddress().getHostName()) != null) {
|
||||||
event.setResult(PreLoginEvent.PreLoginComponentResult.forceOfflineMode());
|
event.setResult(PreLoginEvent.PreLoginComponentResult.forceOfflineMode());
|
||||||
} else {
|
} else {
|
||||||
if (secondAttemptAsCrackedCache.getIfPresent(event.getUsername() + event.getConnection().getRemoteAddress().getHostName()) != null) {
|
if (secondAttemptAsCrackedCache.getIfPresent(getCorrectCrackedUsername(event.getUsername(), config) + event.getConnection().getRemoteAddress().getHostName()) != null) {
|
||||||
if (showFailedMessage.getIfPresent(event.getUsername() + event.getConnection().getRemoteAddress().getHostName()) == null
|
if (offlineModePlayers.getIfPresent(getCorrectCrackedUsername(event.getUsername(), config) + event.getConnection().getRemoteAddress().getHostName()) == null) {
|
||||||
&& offlineModePlayers.getIfPresent(event.getUsername() + event.getConnection().getRemoteAddress().getHostName()) == null) {
|
offlineModePlayers.put(getCorrectCrackedUsername(event.getUsername(), config) + event.getConnection().getRemoteAddress().getHostName(), new Object());
|
||||||
showFailedMessage.put(event.getUsername() + event.getConnection().getRemoteAddress().getHostName(), new Object());
|
|
||||||
offlineModePlayers.put(event.getUsername() + event.getConnection().getRemoteAddress().getHostName(), new Object());
|
|
||||||
event.setResult(PreLoginEvent.PreLoginComponentResult.denied(Component.text(Messages.FAILED_CONNECTION)));
|
|
||||||
} else {
|
|
||||||
event.setResult(PreLoginEvent.PreLoginComponentResult.forceOfflineMode());
|
event.setResult(PreLoginEvent.PreLoginComponentResult.forceOfflineMode());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
secondAttemptAsCrackedCache.put(event.getUsername() + event.getConnection().getRemoteAddress().getHostName(), System.currentTimeMillis());
|
secondAttemptAsCrackedCache.put(getCorrectCrackedUsername(event.getUsername(), config) + event.getConnection().getRemoteAddress().getHostName(), System.currentTimeMillis());
|
||||||
event.setResult(PreLoginEvent.PreLoginComponentResult.forceOnlineMode());
|
event.setResult(PreLoginEvent.PreLoginComponentResult.forceOnlineMode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,7 +105,7 @@ public class VelocityGalPlugin {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameProfileRequestEvent(GameProfileRequestEvent event) {
|
public void onGameProfileRequestEvent(GameProfileRequestEvent event) {
|
||||||
secondAttemptAsCrackedCache.invalidate(event.getUsername() + event.getConnection().getRemoteAddress().getHostName());
|
secondAttemptAsCrackedCache.invalidate(getCorrectCrackedUsername(event.getUsername(), config) + event.getConnection().getRemoteAddress().getHostName());
|
||||||
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);
|
||||||
@ -125,7 +116,12 @@ public class VelocityGalPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onPostLoginEvent(PostLoginEvent event) {
|
||||||
|
if (offlineModePlayers.getIfPresent(getCorrectCrackedUsername(event.getPlayer().getUsername(), config) + event.getPlayer().getRemoteAddress().getHostName()) != null) {
|
||||||
|
event.getPlayer().sendMessage(Component.text(Messages.cracked_disclaimer));
|
||||||
|
}
|
||||||
|
}
|
||||||
public ProxyServer getProxyServer() {
|
public ProxyServer getProxyServer() {
|
||||||
return proxyServer;
|
return proxyServer;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user