Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Renamed some classes
Browse files Browse the repository at this point in the history
  • Loading branch information
awumii committed Sep 5, 2021
1 parent b46f436 commit 63a41a9
Show file tree
Hide file tree
Showing 18 changed files with 47 additions and 53 deletions.
8 changes: 0 additions & 8 deletions core/src/main/java/me/xneox/epicguard/core/EpicGuard.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public class EpicGuard {
private AttackManager attackManager;
private ProxyManager proxyManager;

private CommandHandler commandHandler;

private PluginConfiguration config;
private MessagesConfiguration messages;

Expand All @@ -70,8 +68,6 @@ private void startup() {
this.attackManager = new AttackManager();
this.userManager = new UserManager();

this.commandHandler = new CommandHandler(this);

logger().info("Initializing LogFilter...");
new LogFilter(this).register();

Expand Down Expand Up @@ -140,8 +136,4 @@ public AttackManager attackManager() {
public ProxyManager proxyManager() {
return this.proxyManager;
}

public CommandHandler commandHandler() {
return this.commandHandler;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Handler for the PlayerQuit/Disconnect listeners. Used for removing the {@link OnlineUser}
* instance from cache.
*/
public class DisconnectHandler {
public abstract class DisconnectHandler {
private final EpicGuard epicGuard;

public DisconnectHandler(EpicGuard epicGuard) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Handler for the ServerListPing listeners. Used for the ServerListCheck to verify if the user has
* pinged the server (added it to their list).
*/
public class PingHandler {
public abstract class PingHandler {
private final EpicGuard epicGuard;

public PingHandler(EpicGuard epicGuard) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
* Handler for the PlayerJoin or PostLogin listeners Used for the auto-whitelist feature, and for
* SettingsCheck.
*/
public class JoinHandler {
public abstract class PostLoginHandler {
private final EpicGuard epicGuard;

public JoinHandler(EpicGuard epicGuard) {
public PostLoginHandler(EpicGuard epicGuard) {
this.epicGuard = epicGuard;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
*
* <p>It performs every antibot check (except SettingsCheck).
*/
public class DetectionHandler {
public abstract class PreLoginHandler {
private final List<Check> checks = new ArrayList<>();
private final EpicGuard epicGuard;

public DetectionHandler(EpicGuard epicGuard) {
public PreLoginHandler(EpicGuard epicGuard) {
this.epicGuard = epicGuard;

checks.add(new LockdownCheck(epicGuard));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* If the user has sent the Settings packet, it will be marked on their {@link OnlineUser} object.
* This packet is sent after joining the server by the vanilla client.
*/
public class SettingsHandler {
public abstract class SettingsHandler {
private final EpicGuard epicGuard;

public SettingsHandler(EpicGuard epicGuard) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import me.xneox.epicguard.core.Platform;
import me.xneox.epicguard.core.util.logging.LogWrapper;
import me.xneox.epicguard.core.util.logging.impl.JavaLoggerWrapper;
import me.xneox.epicguard.paper.listener.PlayerJoinListener;
import me.xneox.epicguard.paper.listener.PlayerPostLoginListener;
import me.xneox.epicguard.paper.listener.PlayerPreLoginListener;
import me.xneox.epicguard.paper.listener.PlayerQuitListener;
import me.xneox.epicguard.paper.listener.PlayerSettingsListener;
Expand Down Expand Up @@ -48,13 +48,13 @@ public void onEnable() {
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new PlayerPreLoginListener(this.epicGuard), this);
pm.registerEvents(new PlayerQuitListener(this.epicGuard), this);
pm.registerEvents(new PlayerJoinListener(this.epicGuard), this);
pm.registerEvents(new PlayerPostLoginListener(this.epicGuard), this);
pm.registerEvents(new ServerPingListener(this.epicGuard), this);
pm.registerEvents(new PlayerSettingsListener(this.epicGuard), this);

PluginCommand command = this.getCommand("epicguard");
if (command != null) {
PaperCommandExecutor cmdExecutor = new PaperCommandExecutor(this.epicGuard);
PaperCommandHandler cmdExecutor = new PaperCommandHandler(this.epicGuard);
command.setExecutor(cmdExecutor);
command.setTabCompleter(cmdExecutor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,27 @@
import java.util.ArrayList;
import java.util.List;
import me.xneox.epicguard.core.EpicGuard;
import me.xneox.epicguard.core.command.CommandHandler;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class PaperCommandExecutor implements CommandExecutor, TabCompleter {
private final EpicGuard epicGuard;

public PaperCommandExecutor(EpicGuard epicGuard) {
this.epicGuard = epicGuard;
public class PaperCommandHandler extends CommandHandler implements CommandExecutor, TabCompleter {
public PaperCommandHandler(EpicGuard epicGuard) {
super(epicGuard);
}

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
this.epicGuard.commandHandler().handleCommand(args, sender);
this.handleCommand(args, sender);
return true;
}

@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
return new ArrayList<>(this.epicGuard.commandHandler().handleSuggestions(args));
return new ArrayList<>(this.handleSuggestions(args));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
package me.xneox.epicguard.paper.listener;

import me.xneox.epicguard.core.EpicGuard;
import me.xneox.epicguard.core.handler.JoinHandler;
import me.xneox.epicguard.core.handler.PostLoginHandler;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

public class PlayerJoinListener extends JoinHandler implements Listener {
public PlayerJoinListener(EpicGuard epicGuard) {
public class PlayerPostLoginListener extends PostLoginHandler implements Listener {
public PlayerPostLoginListener(EpicGuard epicGuard) {
super(epicGuard);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
package me.xneox.epicguard.paper.listener;

import me.xneox.epicguard.core.EpicGuard;
import me.xneox.epicguard.core.handler.DetectionHandler;
import me.xneox.epicguard.core.handler.PreLoginHandler;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;

public class PlayerPreLoginListener extends DetectionHandler implements Listener {
public class PlayerPreLoginListener extends PreLoginHandler implements Listener {
public PlayerPreLoginListener(EpicGuard epicGuard) {
super(epicGuard);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void onEnable(ProxyInitializeEvent e) {
CommandManager commandManager = this.server.getCommandManager();
CommandMeta meta = commandManager.metaBuilder("epicguard").aliases("guard").build();

commandManager.register(meta, new VelocityCommandExecutor(this.epicGuard));
commandManager.register(meta, new VelocityCommandHandler(this.epicGuard));

EventManager eventManager = this.server.getEventManager();
eventManager.register(this, new PostLoginListener(this.epicGuard));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,21 @@
import com.velocitypowered.api.command.SimpleCommand;
import java.util.List;
import me.xneox.epicguard.core.EpicGuard;
import me.xneox.epicguard.core.command.CommandHandler;

public class VelocityCommandExecutor implements SimpleCommand {
private final EpicGuard epicGuard;

public VelocityCommandExecutor(EpicGuard epicGuard) {
this.epicGuard = epicGuard;
public class VelocityCommandHandler extends CommandHandler implements SimpleCommand {
public VelocityCommandHandler(EpicGuard epicGuard) {
super(epicGuard);
}

@Override
public void execute(Invocation invocation) {
this.epicGuard.commandHandler().handleCommand(invocation.arguments(), invocation.source());
this.handleCommand(invocation.arguments(), invocation.source());
}

@Override
public List<String> suggest(Invocation invocation) {
return (List<String>) this.epicGuard.commandHandler().handleSuggestions(invocation.arguments());
return (List<String>) this.handleSuggestions(invocation.arguments());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import com.velocitypowered.api.event.connection.PostLoginEvent;
import com.velocitypowered.api.proxy.Player;
import me.xneox.epicguard.core.EpicGuard;
import me.xneox.epicguard.core.handler.JoinHandler;
import me.xneox.epicguard.core.handler.PostLoginHandler;

public class PostLoginListener extends JoinHandler {
public class PostLoginListener extends PostLoginHandler {
public PostLoginListener(EpicGuard epicGuard) {
super(epicGuard);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PreLoginEvent;
import me.xneox.epicguard.core.EpicGuard;
import me.xneox.epicguard.core.handler.DetectionHandler;
import me.xneox.epicguard.core.handler.PreLoginHandler;

public class PreLoginListener extends DetectionHandler {
public class PreLoginListener extends PreLoginHandler {
public PreLoginListener(EpicGuard epicGuard) {
super(epicGuard);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,29 @@

package me.xneox.epicguard.waterfall;

import me.xneox.epicguard.core.command.CommandHandler;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.TabExecutor;

// why bungee... why Command is an abstract class?
public class BungeeCommandExecutor extends Command implements TabExecutor {
private final EpicGuardWaterfall epicGuardWaterfall;
public class BungeeCommandHandler extends Command implements TabExecutor {
private final CommandHandler commandHandler;
private final EpicGuardWaterfall plugin;

public BungeeCommandExecutor(EpicGuardWaterfall epicGuardWaterfall) {
public BungeeCommandHandler(EpicGuardWaterfall plugin) {
super("epicguard", "epicguard.admin", "guard", "eg", "ab", "antibot");
this.epicGuardWaterfall = epicGuardWaterfall;
this.plugin = plugin;
this.commandHandler = new CommandHandler(plugin.epicGuard());
}

@Override
public void execute(CommandSender sender, String[] args) {
this.epicGuardWaterfall.epicGuard().commandHandler().handleCommand(args, this.epicGuardWaterfall.adventure().sender(sender));
this.commandHandler.handleCommand(args, this.plugin.adventure().sender(sender));
}

@Override
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
return this.epicGuardWaterfall.epicGuard().commandHandler().handleSuggestions(args);
return this.commandHandler.handleSuggestions(args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void onEnable() {
pm.registerListener(this, new ServerPingListener(this.epicGuard));
pm.registerListener(this, new PlayerSettingsListener(this.epicGuard));

pm.registerCommand(this, new BungeeCommandExecutor(this));
pm.registerCommand(this, new BungeeCommandHandler(this));

new Metrics(this, 5956);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
package me.xneox.epicguard.waterfall.listener;

import me.xneox.epicguard.core.EpicGuard;
import me.xneox.epicguard.core.handler.JoinHandler;
import me.xneox.epicguard.core.handler.PostLoginHandler;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;

public class PostLoginListener extends JoinHandler implements Listener {
public class PostLoginListener extends PostLoginHandler implements Listener {
public PostLoginListener(EpicGuard epicGuard) {
super(epicGuard);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

import me.xneox.epicguard.waterfall.BungeeUtils;
import me.xneox.epicguard.core.EpicGuard;
import me.xneox.epicguard.core.handler.DetectionHandler;
import me.xneox.epicguard.core.handler.PreLoginHandler;
import me.xneox.epicguard.waterfall.EpicGuardWaterfall;
import net.md_5.bungee.api.connection.PendingConnection;
import net.md_5.bungee.api.event.PreLoginEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;

public class PreLoginListener extends DetectionHandler implements Listener {
public class PreLoginListener extends PreLoginHandler implements Listener {
public PreLoginListener(EpicGuard epicGuard) {
super(epicGuard);
}
Expand Down

0 comments on commit 63a41a9

Please sign in to comment.