Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
  • Loading branch information
BlueTree242 committed Jul 26, 2022
2 parents c82afb9 + 6659976 commit f2ed19a
Show file tree
Hide file tree
Showing 64 changed files with 511 additions and 609 deletions.
1 change: 0 additions & 1 deletion Bungee/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ repositories {

dependencies {
implementation project(":core")
implementation 'space.arim.dazzleconf:dazzleconf-ext-snakeyaml:1.2.0-M2'
compileOnly 'dev.simplix:protocolize-api:2.1.0'
compileOnly 'net.md-5:bungeecord-api:1.15-SNAPSHOT'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* LICENSE
* AdvancedPlHide
* -------------
* Copyright (C) 2021 - 2021 BlueTree242
* Copyright (C) 2021 - 2022 BlueTree242
* -------------
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -30,47 +30,42 @@
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import tk.bluetree242.advancedplhide.Group;
import tk.bluetree242.advancedplhide.Platform;
import tk.bluetree242.advancedplhide.bungee.listener.event.EventListener;
import tk.bluetree242.advancedplhide.bungee.listener.packet.PacketListener;
import tk.bluetree242.advancedplhide.config.ConfManager;
import tk.bluetree242.advancedplhide.config.Config;
import tk.bluetree242.advancedplhide.exceptions.ConfigurationLoadException;
import tk.bluetree242.advancedplhide.PlatformPlugin;
import tk.bluetree242.advancedplhide.bungee.listener.event.BungeeEventListener;
import tk.bluetree242.advancedplhide.bungee.listener.packet.BungeePacketListener;
import tk.bluetree242.advancedplhide.impl.version.UpdateCheckResult;
import tk.bluetree242.advancedplhide.utils.Constants;

import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AdvancedPlHideBungee extends Plugin implements Listener {
public Config config;
protected ConfManager<Config> confManager = ConfManager.create(getDataFolder().toPath(), "config.yml", Config.class);
private PacketListener listener;
private Map<String, String> map = new HashMap<>();
private BungeePacketListener listener;
private List<Group> groups = new ArrayList<>();

public static Group getGroupForPlayer(ProxiedPlayer player) {
Platform core = Platform.get();
private final AdvancedPlHideBungee.Impl platformPlugin = new Impl();
public Group getGroupForPlayer(ProxiedPlayer player) {
if (player.hasPermission("plhide.no-group")) return null;
List<Group> groups = new ArrayList<>();
for (Group group : core.getGroups()) {
for (Group group : platformPlugin.getGroups()) {
if (player.hasPermission("plhide.group." + group.getName())) {
groups.add(group);
}
}
Group group = groups.isEmpty() ? core.getGroup("default") : core.mergeGroups(groups);
return group;
return groups.isEmpty() ? platformPlugin.getGroup("default") : platformPlugin.mergeGroups(groups);
}

public void onLoad() {
PlatformPlugin.setPlatform(new Impl());
platformPlugin.initConfigManager();
}

public void onEnable() {
reloadConfig();
Protocolize.listenerProvider().registerListener(listener = new PacketListener(this));
Platform.setPlatform(new Impl());
getProxy().getPluginManager().registerListener(this, new EventListener(this));
platformPlugin.reloadConfig();
Protocolize.listenerProvider().registerListener(listener = new BungeePacketListener(this));
getProxy().getPluginManager().registerListener(this, new BungeeEventListener(this));
ProxyServer.getInstance().getPluginManager().registerCommand(this, new AdvancedPlHideCommand(this));
new Metrics(this, 13709);
ProxyServer.getInstance().getConsole().sendMessage(ChatColor.translateAlternateColorCodes('&', Constants.startupMessage()));
Expand All @@ -83,7 +78,7 @@ public void onDisable() {

public void loadGroups() {
groups = new ArrayList<>();
config.groups().forEach((name, val) -> {
platformPlugin.getConfig().groups().forEach((name, val) -> {
if (getGroup(name) == null)
groups.add(new Group(name, val.tabcomplete()));
else {
Expand All @@ -102,7 +97,8 @@ public void performStartUpdateCheck() {
if (result == null) {
getLogger().severe("Could not check for updates");
return;
} String msg = result.getVersionsBehind() == 0 ?
}
String msg = result.getVersionsBehind() == 0 ?
ChatColor.translateAlternateColorCodes('&', Constants.DEFAULT_UP_TO_DATE) :
ChatColor.translateAlternateColorCodes('&', Constants.DEFAULT_BEHIND.replace("{versions}", result.getVersionsBehind() + "")
.replace("{download}", result.getUpdateUrl()));
Expand Down Expand Up @@ -134,24 +130,16 @@ public List<Group> getGroups() {
return groups;
}

public void reloadConfig() {
confManager.reloadConfig();
config = confManager.getConfigData();
loadGroups();

}


public class Impl extends Platform {

public class Impl extends PlatformPlugin {
@Override
public Config getConfig() {
return config;
public void loadGroups() {
AdvancedPlHideBungee.this.loadGroups();
}

@Override
public void reloadConfig() throws ConfigurationLoadException {
AdvancedPlHideBungee.this.reloadConfig();
public File getDataFolder() {
return AdvancedPlHideBungee.this.getDataFolder();
}

@Override
Expand All @@ -166,7 +154,6 @@ public Group getGroup(String name) {

@Override
public String getPluginForCommand(String s) {

return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* LICENSE
* AdvancedPlHide
* -------------
* Copyright (C) 2021 - 2021 BlueTree242
* Copyright (C) 2021 - 2022 BlueTree242
* -------------
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
Expand All @@ -26,7 +26,7 @@
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Command;
import tk.bluetree242.advancedplhide.Platform;
import tk.bluetree242.advancedplhide.PlatformPlugin;
import tk.bluetree242.advancedplhide.exceptions.ConfigurationLoadException;

import java.util.concurrent.TimeUnit;
Expand All @@ -45,26 +45,22 @@ public void execute(CommandSender sender, String[] args) {
sender.sendMessage(ChatColor.GREEN + "Running AdvancedPlHide v." + ChatColor.YELLOW + core.getDescription().getVersion());
return;
} else {
if (args.length >= 1) {
if (args[0].equalsIgnoreCase("reload")) {
if (!sender.hasPermission("plhide.reload")) {
sender.sendMessage(ChatColor.RED + "You don't have permission to run this command");
return;
} else {
ProxyServer.getInstance().getScheduler().schedule(core, () -> {
try {
Platform.get().reloadConfig();
sender.sendMessage(ChatColor.GREEN + "Configuration Reloaded");
} catch (ConfigurationLoadException e) {
sender.sendMessage(ChatColor.RED + "Could not reload " + e.getConfigName());
}
}, 0, TimeUnit.SECONDS);
return;
}
if (args[0].equalsIgnoreCase("reload")) {
if (!sender.hasPermission("plhide.reload")) {
sender.sendMessage(ChatColor.RED + "You don't have permission to run this command");
} else {
ProxyServer.getInstance().getScheduler().schedule(core, () -> {
try {
PlatformPlugin.get().reloadConfig();
sender.sendMessage(ChatColor.GREEN + "Configuration Reloaded");
} catch (ConfigurationLoadException e) {
sender.sendMessage(ChatColor.RED + "Could not reload " + e.getConfigName());
}
}, 0, TimeUnit.SECONDS);
}
return;
}
}
sender.sendMessage(ChatColor.RED + "SubCommand not found");
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* LICENSE
* AdvancedPlHide
* -------------
* Copyright (C) 2021 - 2021 BlueTree242
* Copyright (C) 2021 - 2022 BlueTree242
* -------------
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* LICENSE
* AdvancedPlHide
* -------------
* Copyright (C) 2021 - 2021 BlueTree242
* Copyright (C) 2021 - 2022 BlueTree242
* -------------
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* LICENSE
* AdvancedPlHide
* -------------
* Copyright (C) 2021 - 2021 BlueTree242
* Copyright (C) 2021 - 2022 BlueTree242
* -------------
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* LICENSE
* AdvancedPlHide
* -------------
* Copyright (C) 2021 - 2021 BlueTree242
* Copyright (C) 2021 - 2022 BlueTree242
* -------------
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* LICENSE
* AdvancedPlHide
* -------------
* Copyright (C) 2021 - 2021 BlueTree242
* Copyright (C) 2021 - 2022 BlueTree242
* -------------
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -32,6 +32,7 @@ public class StringSubCommandCompleterList extends SubCommandCompleterList {
private final String command;
private final String[] args;
private final List<String> suggestions;

public StringSubCommandCompleterList(List<String> suggestions, String notCompleted) {
this.suggestions = suggestions;
for (String suggestion : suggestions) {
Expand All @@ -43,9 +44,9 @@ public StringSubCommandCompleterList(List<String> suggestions, String notComplet
for (String s : split) {
if (!s.equalsIgnoreCase("/" + command)) {
if (notCompleted.endsWith(" "))
list.add(s);
list.add(s);
else {
if (!s.equals(split[split.length -1])) {
if (!s.equals(split[split.length - 1])) {
list.add(s);
}
}
Expand All @@ -70,7 +71,8 @@ public String getName() {
}

public boolean remove(Object e) {
if (!(e instanceof SubCommandCompleter)) throw new IllegalArgumentException("May only remove a SubCommandCompleter");
if (!(e instanceof SubCommandCompleter))
throw new IllegalArgumentException("May only remove a SubCommandCompleter");
SubCommandCompleter completer = (SubCommandCompleter) e;
for (String suggestion : new ArrayList<>(suggestions)) {
if (suggestion.equalsIgnoreCase(completer.getText())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* LICENSE
* AdvancedPlHide
* -------------
* Copyright (C) 2021 - 2021 BlueTree242
* Copyright (C) 2021 - 2022 BlueTree242
* -------------
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
Expand All @@ -29,16 +29,16 @@
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import tk.bluetree242.advancedplhide.Platform;
import tk.bluetree242.advancedplhide.PlatformPlugin;
import tk.bluetree242.advancedplhide.bungee.AdvancedPlHideBungee;
import tk.bluetree242.advancedplhide.impl.version.UpdateCheckResult;
import tk.bluetree242.advancedplhide.utils.Constants;

public class EventListener implements Listener {
public class BungeeEventListener implements Listener {
private final AdvancedPlHideBungee core;


public EventListener(AdvancedPlHideBungee core) {
public BungeeEventListener(AdvancedPlHideBungee core) {
this.core = core;
}

Expand All @@ -51,7 +51,7 @@ public void onChat(ChatEvent e) {
String cmd = e.getMessage().toLowerCase().split(" ")[0];
if (cmd.equalsIgnoreCase("/plugins") || cmd.equalsIgnoreCase("/pl") || cmd.equalsIgnoreCase("/bukkit:pl") || cmd.equalsIgnoreCase("/bukkit:plugins")) {
e.setCancelled(true);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Platform.get().getConfig().pl_message()));
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', PlatformPlugin.get().getConfig().pl_message()));
}
}
}
Expand All @@ -61,11 +61,11 @@ public void onChat(ChatEvent e) {
public void onPlayerJoin(PostLoginEvent e) {
if (e.getPlayer().hasPermission("plhide.updatechecker")) {
ProxyServer.getInstance().getScheduler().runAsync(core, () -> {
UpdateCheckResult result = Platform.get().updateCheck();
UpdateCheckResult result = PlatformPlugin.get().updateCheck();
if (result == null) return;
String msg = result.getVersionsBehind() == 0 ? null : ChatColor.translateAlternateColorCodes('&', "&e[APH-&2Bungee&e] " + Constants.DEFAULT_BEHIND.replace("{versions}", result.getVersionsBehind() + "").replace("{download}", result.getUpdateUrl()));
if (result.getMessage() != null) {
msg = ChatColor.translateAlternateColorCodes('&', "&e[APH-&2Bungee&e] &c" + result.getMessage());
msg = ChatColor.translateAlternateColorCodes('&', "&e[APH&2Bungee&e] &c" + result.getMessage());
}
if (msg != null) {
e.getPlayer().sendMessage(msg);
Expand Down
Loading

0 comments on commit f2ed19a

Please sign in to comment.