Skip to content

Commit ddc933a

Browse files
authored
2.7.3 Release (#251)
- Added Version support up until 1.21.4 (#247) - Added patch for the 1.20.6-1.21 book dupe - Added patch for a new exploit that allows sending huge messages, creating lag on some servers - Fix functionality for some packet modules - Fix AntiBedTrap not working properly (#244) - Added ability to hook into luckperms to fix #237 - Reworked `preventsions.prevent-opped-players` to a more configurable `preventions.illegal-permissions` - Reworked `preventions.prevent-non-survival-players` to a more configurable `reventions.illegal-gamemode` - Added more configurability to all `regional-activity` modules. You can now configure custom type limits per module - Reworked legacy module `disable-fish` into a more generic `lag-preventions.disable-entity-spawns` for both plugin types. - Reworked all modules accessing chunks to check if a chunk is out of bounds to fix the "plugin is getting faraway chunk issue" - Reworked `chunk-limits.exp-bottle-limit` into `chunk-limits.projectile-limit ` since its a projectile issue and could reappear - Improved functionality of all modules handling illegal items. (Fixes having to drop something multiple times until aef removed ALL illegal enchants. It now cleans it entirely on the first interaction if handling is set to ACTION or STRICT. Also fixes items getting stuck if players try to drop them with specific plugin settings.) - Improved plugin enable logic and added more specific logging messages so users are more pushed into using the correct plugin jar - Plugin now only saves default translations if the lang folder does not exist. This means you can now delete languages you do not want to support without turning multi-lang off. - Reworked config to always include the enable: true/false option for a module. This will cause warnings on config update but should be fine after a reload. More fixed issues in this release: #248 #243
1 parent 1f7ebc5 commit ddc933a

File tree

327 files changed

+6038
-5010
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

327 files changed

+6038
-5010
lines changed

AnarchyExploitFixesFolia/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ tasks.shadowJar {
2727
archiveFileName = "${rootProject.name}-${project.name}-${project.version}.${archiveExtension.get()}"
2828
exclude(
2929
"com/cryptomorin/xseries/XBiome*",
30-
"com/cryptomorin/xseries/XPotion*",
3130
"com/cryptomorin/xseries/NMSExtras*",
3231
"com/cryptomorin/xseries/NoteBlockMusic*",
3332
"com/cryptomorin/xseries/SkullCacheListener*"

AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/AnarchyExploitFixes.java

Lines changed: 55 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package me.xginko.aef;
22

33
import com.github.retrooper.packetevents.PacketEvents;
4-
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
4+
import com.github.retrooper.packetevents.manager.server.ServerVersion;
5+
import de.tr7zw.changeme.nbtapi.NBT;
56
import me.xginko.aef.commands.AEFCommand;
67
import me.xginko.aef.config.Config;
78
import me.xginko.aef.config.LanguageCache;
8-
import me.xginko.aef.enums.AEFPermission;
9-
import me.xginko.aef.listeners.AEFListener;
109
import me.xginko.aef.modules.AEFModule;
11-
import me.xginko.aef.utils.CachingPermTool;
10+
import me.xginko.aef.utils.permissions.AEFPermission;
11+
import me.xginko.aef.utils.permissions.PermissionHandler;
1212
import me.xginko.aef.utils.KyoriUtil;
1313
import me.xginko.aef.utils.PlatformUtil;
1414
import me.xginko.aef.utils.tickdata.TickReporter;
@@ -24,8 +24,6 @@
2424

2525
import java.io.File;
2626
import java.io.FileNotFoundException;
27-
import java.io.IOException;
28-
import java.nio.file.FileAlreadyExistsException;
2927
import java.nio.file.Files;
3028
import java.util.Arrays;
3129
import java.util.Collections;
@@ -34,6 +32,7 @@
3432
import java.util.Locale;
3533
import java.util.Map;
3634
import java.util.jar.JarFile;
35+
import java.util.logging.Logger;
3736
import java.util.regex.Matcher;
3837
import java.util.regex.Pattern;
3938
import java.util.stream.Collectors;
@@ -45,31 +44,33 @@ public final class AnarchyExploitFixes extends JavaPlugin {
4544
private static AnarchyExploitFixes instance;
4645
private static Map<String, LanguageCache> languageCacheMap;
4746
private static Config config;
47+
4848
private static TickReporter tickReporter;
49-
private static CachingPermTool cachingPermTool;
49+
private static PermissionHandler permissionHandler;
5050
private static ComponentLogger prefixedLogger, unPrefixedLogger;
51+
5152
private static Metrics metrics;
5253
private static boolean isPacketEventsInstalled;
5354

5455
@Override
5556
public void onLoad() {
5657
PlatformUtil.load();
57-
prefixedLogger = ComponentLogger.logger(getLogger().getName());
58-
unPrefixedLogger = ComponentLogger.logger("");
59-
// Disable logging for some shaded libraries as those can get very verbose
60-
String shadedLibs = getClass().getPackageName() + ".libs";
61-
Configurator.setLevel(shadedLibs + ".reflections.Reflections", Level.OFF);
62-
isPacketEventsInstalled = getServer().getPluginManager().getPlugin("packetevents") != null;
63-
if (isPacketEventsInstalled) {
64-
// Configure and load packetevents
65-
PacketEvents.setAPI(SpigotPacketEventsBuilder.build(this));
66-
PacketEvents.getAPI().getSettings().kickOnPacketException(true).reEncodeByDefault(false).checkForUpdates(false);
67-
PacketEvents.getAPI().load();
68-
}
58+
// Disable info logging for Reflections because it does not provide additional value to the user and makes startup log look ugly.
59+
Configurator.setLevel(AnarchyExploitFixes.class.getPackage().getName() + ".libs.reflections.Reflections", Level.WARN);
6960
}
7061

7162
@Override
7263
public void onEnable() {
64+
if (!PlatformUtil.isPaper()) {
65+
getLogger().severe("This plugin depends on Paper's API, which is not present on your server.");
66+
getServer().getPluginManager().disablePlugin(this);
67+
return;
68+
}
69+
70+
prefixedLogger = ComponentLogger.logger(getLogger().getName());
71+
unPrefixedLogger = ComponentLogger.logger("");
72+
73+
isPacketEventsInstalled = getServer().getPluginManager().getPlugin("packetevents") != null;
7374
if (!isPacketEventsInstalled) {
7475
Stream.of(" ",
7576
" _ _ _ _ _ ",
@@ -89,10 +90,6 @@ public void onEnable() {
8990
return;
9091
}
9192

92-
instance = this;
93-
cachingPermTool = CachingPermTool.enable(this);
94-
metrics = new Metrics(this, 8700);
95-
9693
Stream.of(" ",
9794
" ",
9895
" █████ ███████ ███████ ",
@@ -104,32 +101,29 @@ public void onEnable() {
104101
" "
105102
).map(str -> Component.text(str).color(KyoriUtil.AEF_WHITE)).forEach(prefixedLogger::info);
106103

107-
if (!PlatformUtil.isPaper()) {
108-
prefixedLogger.error("This plugin depends on Paper's API, which is not present on your server.");
104+
ServerVersion serverVersion = PacketEvents.getAPI().getServerManager().getVersion();
105+
prefixedLogger.info("Detected {} {}", PlatformUtil.getServerType().niceName(),
106+
serverVersion.name().replace("V_", "").replace('_', '.'));
107+
if (serverVersion.isOlderThanOrEquals(ServerVersion.V_1_19_3) ||
108+
serverVersion.equals(ServerVersion.V_1_19_4) && !PlatformUtil.isFolia()) {
109+
prefixedLogger.error("This plugin jar is incompatible with your Server. Please use the Legacy jar.");
109110
getServer().getPluginManager().disablePlugin(this);
110111
return;
111112
}
112113

113-
prefixedLogger.info("Detected Version 1.{}.{}", PlatformUtil.getMinecraftVersion(), PlatformUtil.getMinecraftPatchVersion());
114-
115-
if (PlatformUtil.getMinecraftVersion() < 19) {
116-
prefixedLogger.error("The Folia jar is intended for Paper and Folia servers running 1.19 and above.");
117-
prefixedLogger.error("Please replace it with the Legacy jar.");
114+
try {
115+
Files.createDirectories(getDataFolder().toPath());
116+
} catch (Exception e) {
117+
prefixedLogger.error("Unable to create plugin directory.", e);
118118
getServer().getPluginManager().disablePlugin(this);
119119
return;
120120
}
121121

122-
if (PlatformUtil.isFolia()) {
123-
prefixedLogger.info("Detected Folia server.");
124-
}
122+
instance = this;
125123

126-
try {
127-
createDirectory(getDataFolder());
128-
} catch (IOException e) {
129-
prefixedLogger.error("Unable to create plugin folder!", e);
130-
getServer().getPluginManager().disablePlugin(this);
131-
return;
132-
}
124+
prefixedLogger.info("Registering Permissions");
125+
permissionHandler = PermissionHandler.create(this);
126+
AEFPermission.registerAll();
133127

134128
prefixedLogger.info("Loading Config");
135129
reloadConfiguration();
@@ -140,31 +134,30 @@ public void onEnable() {
140134
prefixedLogger.info("Registering Commands");
141135
AEFCommand.registerCommands();
142136

143-
prefixedLogger.info("Registering Permissions");
144-
AEFPermission.registerPermissions();
137+
prefixedLogger.info("Loading NBT-API");
138+
// Hide all messages with a log level lower than WARNING because of the same reason as Reflections logging.
139+
Logger.getLogger("NBTAPI").setLevel(java.util.logging.Level.WARNING);
140+
if (!NBT.preloadApi()) prefixedLogger.error("Error initializing NBT-API! This will break some modules!");
145141

146-
prefixedLogger.info("Initializing PacketEvents");
147-
PacketEvents.getAPI().init();
142+
prefixedLogger.info("Loading Metrics");
143+
metrics = new Metrics(this, 8700);
148144

149-
prefixedLogger.info("Ready.");
145+
prefixedLogger.info("Done.");
150146
}
151147

152148
@Override
153149
public void onDisable() {
150+
AEFPermission.unregisterAll();
154151
if (isPacketEventsInstalled) {
155-
AEFModule.ENABLED_MODULES.forEach(AEFModule::disable);
156-
AEFModule.ENABLED_MODULES.clear();
157-
AEFListener.LISTENERS.forEach(AEFListener::disable);
158-
AEFListener.LISTENERS.clear();
159-
PacketEvents.getAPI().terminate();
152+
AEFModule.disableAll();
160153
}
161154
if (languageCacheMap != null) {
162155
languageCacheMap.clear();
163156
languageCacheMap = null;
164157
}
165-
if (cachingPermTool != null) {
166-
cachingPermTool.disable();
167-
cachingPermTool = null;
158+
if (permissionHandler != null) {
159+
permissionHandler.disable();
160+
permissionHandler = null;
168161
}
169162
if (tickReporter != null) {
170163
tickReporter.disable();
@@ -184,19 +177,23 @@ public static AnarchyExploitFixes getInstance() {
184177
return instance;
185178
}
186179

187-
public static TickReporter getTickReporter() {
180+
public static PermissionHandler permissions() {
181+
return permissionHandler;
182+
}
183+
184+
public static TickReporter tickReporter() {
188185
return tickReporter;
189186
}
190187

191188
public static Config config() {
192189
return config;
193190
}
194191

195-
public static ComponentLogger getPrefixedLogger() {
192+
public static ComponentLogger prefixedLogger() {
196193
return prefixedLogger;
197194
}
198195

199-
public static ComponentLogger getUnprefixedLogger() {
196+
public static ComponentLogger unprefixedLogger() {
200197
return unPrefixedLogger;
201198
}
202199

@@ -213,26 +210,16 @@ public static LanguageCache getLang(String lang) {
213210
return languageCacheMap.getOrDefault(lang.replace("-", "_"), languageCacheMap.get(config.default_lang.toString().toLowerCase()));
214211
}
215212

216-
public void createDirectory(File dir) throws IOException {
217-
try {
218-
Files.createDirectories(dir.toPath());
219-
} catch (FileAlreadyExistsException e) { // Thrown if dir exists but is not a directory
220-
if (dir.delete()) createDirectory(dir);
221-
}
222-
}
223-
224213
public void reloadPlugin() {
225214
reloadConfiguration();
226215
reloadLang();
227216
}
228217

229218
private void reloadConfiguration() {
230219
try {
231-
createDirectory(getDataFolder());
232220
config = new Config();
233221
if (tickReporter != null) tickReporter.disable();
234222
tickReporter = TickReporter.create(this, config.tickData_cache_duration);
235-
AEFListener.reloadListeners();
236223
AEFModule.reloadModules();
237224
config.saveConfig();
238225
} catch (Throwable t) {
@@ -276,10 +263,9 @@ public void reloadLang() {
276263

277264
private @NotNull List<String> getAvailableTranslations() {
278265
try (final JarFile pluginJar = new JarFile(getFile())) {
279-
createDirectory(new File(getDataFolder(), "/lang"));
280266
final Pattern langPattern = Pattern.compile("([a-z]{1,3}_[a-z]{1,3})(\\.yml)", Pattern.CASE_INSENSITIVE);
281-
final File[] langDirFiles = new File(getDataFolder() + "/lang").listFiles();
282-
return Stream.concat(pluginJar.stream().map(ZipEntry::getName), Arrays.stream(langDirFiles).map(File::getName))
267+
final File langFolder = new File(getDataFolder(), "/lang");
268+
return (langFolder.exists() ? Arrays.stream(langFolder.listFiles()).map(File::getName) : pluginJar.stream().map(ZipEntry::getName))
283269
.map(langPattern::matcher)
284270
.filter(Matcher::find)
285271
.map(matcher -> matcher.group(1))

AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/commands/HelpCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package me.xginko.aef.commands;
22

33
import me.xginko.aef.AnarchyExploitFixes;
4-
import me.xginko.aef.enums.AEFPermission;
4+
import me.xginko.aef.utils.permissions.AEFPermission;
55
import org.bukkit.command.Command;
66
import org.bukkit.command.CommandException;
77
import org.bukkit.command.CommandSender;
@@ -37,7 +37,7 @@ public void enable() {
3737

3838
@Override
3939
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
40-
if (!sender.hasPermission(AEFPermission.CMD_HELP.bukkit())) {
40+
if (!AnarchyExploitFixes.permissions().permissionValue(sender, AEFPermission.CMD_HELP.node()).toBoolean()) {
4141
sender.sendMessage(AnarchyExploitFixes.getLang(sender).no_permission);
4242
return true;
4343
}

AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/commands/SayCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package me.xginko.aef.commands;
22

33
import me.xginko.aef.AnarchyExploitFixes;
4-
import me.xginko.aef.enums.AEFPermission;
4+
import me.xginko.aef.utils.permissions.AEFPermission;
55
import me.xginko.aef.utils.CommandUtil;
66
import net.kyori.adventure.text.TextReplacementConfig;
77
import net.kyori.adventure.text.minimessage.MiniMessage;
@@ -40,7 +40,7 @@ public void enable() {
4040

4141
@Override
4242
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
43-
if (!sender.hasPermission(AEFPermission.CMD_SAY.bukkit())) {
43+
if (!AnarchyExploitFixes.permissions().permissionValue(sender, AEFPermission.CMD_SAY.node()).toBoolean()) {
4444
sender.sendMessage(AnarchyExploitFixes.getLang(sender).no_permission);
4545
return true;
4646
}

AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/commands/ToggleConnectionMsgsCmd.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package me.xginko.aef.commands;
22

33
import me.xginko.aef.AnarchyExploitFixes;
4-
import me.xginko.aef.enums.AEFKey;
5-
import me.xginko.aef.enums.AEFPermission;
4+
import me.xginko.aef.utils.enums.AEFKey;
5+
import me.xginko.aef.utils.permissions.AEFPermission;
66
import net.kyori.adventure.text.Component;
77
import net.kyori.adventure.text.format.NamedTextColor;
88
import org.bukkit.command.Command;
@@ -44,7 +44,7 @@ public void enable() {
4444
@Override
4545
@SuppressWarnings("DataFlowIssue")
4646
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
47-
if (!sender.hasPermission(AEFPermission.CMD_TOGGLE_CONNECT_MSGS.bukkit())) {
47+
if (!AnarchyExploitFixes.permissions().permissionValue(sender, AEFPermission.CMD_TOGGLE_CONNECT_MSGS.node()).toBoolean()) {
4848
sender.sendMessage(AnarchyExploitFixes.getLang(sender).no_permission);
4949
return true;
5050
}

AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/commands/aef/AEFCmd.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package me.xginko.aef.commands.aef;
22

3+
import com.google.common.collect.ImmutableList;
4+
import com.google.common.collect.ImmutableSet;
35
import me.xginko.aef.AnarchyExploitFixes;
46
import me.xginko.aef.commands.AEFCommand;
57
import me.xginko.aef.commands.SubCommand;
@@ -18,11 +20,14 @@
1820

1921
import java.util.Collections;
2022
import java.util.List;
23+
import java.util.Locale;
24+
import java.util.Set;
25+
import java.util.stream.Collectors;
2126
import java.util.stream.Stream;
2227

2328
public class AEFCmd extends Command implements AEFCommand {
2429

25-
private final @NotNull List<SubCommand> subCommands;
30+
private final @NotNull Set<SubCommand> subCommands;
2631
private final @NotNull List<String> tabCompletes;
2732
private final @NotNull List<Component> overview;
2833

@@ -46,16 +51,17 @@ public AEFCmd() {
4651
" <#00edff>/aef bytesize <mainhand/inventory> (player) (utf8/utf16)",
4752
" <#869699>- <#e2fdff>Get the byte size of an item or inventory.",
4853
""
49-
).map(MiniMessage.miniMessage()::deserialize).toList();
50-
this.subCommands = List.of(
54+
).map(MiniMessage.miniMessage()::deserialize)
55+
.collect(Collectors.collectingAndThen(Collectors.toList(), ImmutableList::copyOf));
56+
this.subCommands = ImmutableSet.of(
5157
new ReloadSubCmd(),
5258
new VersionSubCmd(),
5359
new DisableSubCmd(),
5460
new LagSubCmd(),
5561
new ElytraSubCmd(),
56-
new GearedSubCmd()
57-
);
58-
this.tabCompletes = subCommands.stream().map(SubCommand::label).sorted().toList();
62+
new GearedSubCmd());
63+
this.tabCompletes = subCommands.stream().map(SubCommand::label).sorted()
64+
.collect(Collectors.collectingAndThen(Collectors.toList(), ImmutableList::copyOf));
5965
}
6066

6167
@Override
@@ -75,7 +81,9 @@ public void enable() {
7581
throws CommandException, IllegalArgumentException
7682
{
7783
if (args.length == 1) {
78-
return tabCompletes;
84+
return tabCompletes.stream()
85+
.filter(cmd -> cmd.toLowerCase(Locale.ROOT).startsWith(args[0].toLowerCase(Locale.ROOT)))
86+
.collect(Collectors.toList());
7987
}
8088

8189
if (args.length > 1) {

0 commit comments

Comments
 (0)