Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
319 commits
Select commit Hold shift + click to select a range
8898395
remove unnecessary method
xGinko Jul 30, 2024
e57f1af
dont call cleanup
xGinko Aug 1, 2024
7735b6c
fill without applying physics and schedule on folia
xGinko Aug 1, 2024
733f72e
improve bedrock modules yet again
xGinko Aug 1, 2024
7379012
improve commandwhitelist
xGinko Aug 1, 2024
d54682b
more tweaks for chat modules
xGinko Aug 1, 2024
beffa3e
optimize shared modules
xGinko Aug 1, 2024
61a5357
improve code for legacy sign command module
xGinko Aug 1, 2024
4e71c62
sync villager limit module and dont use enumsets for 1.21
xGinko Aug 1, 2024
42555c9
add ability to toggle whitelist
xGinko Aug 1, 2024
2e71f89
fix and use XentityType
xGinko Aug 1, 2024
26a526c
semantics
xGinko Aug 2, 2024
4321ae1
merge FramedMapUtil into EntityUtil
xGinko Aug 2, 2024
1dd715c
add javadoc
xGinko Aug 2, 2024
f164217
some util cleanup
xGinko Aug 2, 2024
85ff01e
check if feature is available using BlockUtil
xGinko Aug 2, 2024
f642674
replace deprecated method
xGinko Aug 2, 2024
3010206
catch possible exception
xGinko Aug 2, 2024
9818cc5
update gradle plugins
xGinko Aug 2, 2024
18b665a
update other dependencies
xGinko Aug 2, 2024
7db0ce3
fix build
xGinko Aug 2, 2024
c4a51a0
clear map on disable
xGinko Aug 2, 2024
322bb21
remove awkward spacing from getters in main
xGinko Aug 2, 2024
0aca7d0
initial inventory lag patch concept
xGinko Aug 3, 2024
4d2a290
check cooldown first
xGinko Aug 3, 2024
c05c113
improve performance and add logging
xGinko Aug 3, 2024
eb7efa9
add more configuration to inventory-lag
xGinko Aug 3, 2024
6319baa
improve logging
xGinko Aug 3, 2024
36eb5cf
remove unused annotation
xGinko Aug 3, 2024
a002900
fix config paths in module
xGinko Aug 4, 2024
9abef08
comment improvements
xGinko Aug 4, 2024
6b8f4bf
update default config and improve compatibility
xGinko Aug 4, 2024
97975e4
improve logging and fix condition
xGinko Aug 4, 2024
770ade7
adjust config defaults
xGinko Aug 4, 2024
aa0b687
reduce codesize
xGinko Aug 4, 2024
2ede4a8
add more materials to check
xGinko Aug 4, 2024
8f148d0
this is all unnecessary
xGinko Aug 4, 2024
4b9ce96
hide coords on more packets
xGinko Aug 4, 2024
301de20
check active item and no longer remove entity
xGinko Aug 5, 2024
ea94cfe
only remove if handling is set to take action
xGinko Aug 5, 2024
a3b555e
reading semantics
xGinko Aug 5, 2024
98b3d6c
rename var and add comment
xGinko Aug 5, 2024
e68f123
turn entity targetting and pathfinding into physics modules
xGinko Aug 5, 2024
8a5dd99
fix legacy and catch possible exception
xGinko Aug 5, 2024
83c2df3
rename modules and change path
xGinko Aug 5, 2024
e898ffc
bring back falling block limit
xGinko Aug 5, 2024
c95a342
rename package
xGinko Aug 5, 2024
f06c25a
improve credits in keepstashloaded
xGinko Aug 5, 2024
a71dd41
fix extend
xGinko Aug 5, 2024
c936bbd
improve map cursor lag
xGinko Aug 5, 2024
28ca2cc
fix config path
xGinko Aug 5, 2024
8a11e88
only load spigotreflection when needed
xGinko Aug 6, 2024
7bea0c5
rename method for unity
xGinko Aug 6, 2024
09c7082
increase defaults
xGinko Aug 6, 2024
2d998de
store instance and turn into getter
xGinko Aug 6, 2024
7e7d274
move to tickdata package
xGinko Aug 6, 2024
319f96d
use static import for XEnchant instead
xGinko Aug 6, 2024
9f0b517
ensure 1.12 compatibility
xGinko Aug 6, 2024
fd4c9e1
optimize check order
xGinko Aug 6, 2024
78b9149
swap order as trident is more commone
xGinko Aug 6, 2024
eb71550
update NBT API usage
xGinko Aug 6, 2024
ad56d51
fix unbreakable module
xGinko Aug 6, 2024
6f83220
check for hasItemMeta beforehand
xGinko Aug 6, 2024
7235008
set to max durability instead of deleting item
xGinko Aug 6, 2024
7002aab
simplify code
xGinko Aug 6, 2024
1b2554f
fix config default
xGinko Aug 6, 2024
2a89adb
correct negative stack size to 1
xGinko Aug 6, 2024
58e42e5
properly use XSeries in placedblocks illegals
xGinko Aug 6, 2024
f1d9d2b
rename argument variables
xGinko Aug 6, 2024
c4e2228
make arrays final
xGinko Aug 6, 2024
3a18475
improve tabcomplete suggestion
xGinko Aug 6, 2024
080599e
declare more readable
xGinko Aug 6, 2024
b16eace
dont do anything if we are unable to do so
xGinko Aug 6, 2024
569e2e2
annotate method
xGinko Aug 6, 2024
485a5e3
make elytra-speed more configurable
xGinko Aug 7, 2024
5ce3b51
fix speed average
xGinko Aug 7, 2024
3b8d3ba
get from world if respawn anchors work
xGinko Aug 7, 2024
1b9986f
improvements for packet modules
xGinko Aug 7, 2024
006252e
check for necessary methods as well to avoid errors
xGinko Aug 7, 2024
63f5b2b
correct config option
xGinko Aug 7, 2024
940ce81
correct elytra speed calculation
xGinko Aug 7, 2024
e5433fc
better patch for silent switch
xGinko Aug 8, 2024
c537c3d
simplify code
xGinko Aug 8, 2024
2cd208a
shorten code even more
xGinko Aug 8, 2024
ddefc8c
reiterate over combat modules
xGinko Aug 8, 2024
fd66319
better configuration for minimum world heights
xGinko Aug 8, 2024
4fb3a16
create defaults map when needed
xGinko Aug 8, 2024
be361f1
use Integer#parseInt instead of valueOf
xGinko Aug 8, 2024
e21a5ce
use empty map if we can use the API
xGinko Aug 8, 2024
f9dfc14
improve isPlayerHead
xGinko Aug 8, 2024
bb5fa60
check if blockstate is instanceof skull
xGinko Aug 8, 2024
225d715
just use getter
xGinko Aug 8, 2024
c17d3da
remove braces from statements
xGinko Aug 8, 2024
1068ef9
silent swap patch is not exclusive to ca
xGinko Aug 9, 2024
ab82e63
Wind charge cannot blow up blocks
xKumorio Aug 9, 2024
5922c64
i hate git
xKumorio Aug 9, 2024
621ae98
shorten packetlistener
xGinko Aug 9, 2024
ba25088
add multitask module
xGinko Aug 9, 2024
85851bf
add portalgodmode, closing #157
xGinko Aug 10, 2024
d6eec31
listen on MONITOR and add comment
xGinko Aug 10, 2024
c76b758
improve comments
xGinko Aug 10, 2024
e43a720
shorten configpath
xGinko Aug 10, 2024
5611429
remove duplicate module
xGinko Aug 10, 2024
256deb9
better accuracy for silent swap
xGinko Aug 10, 2024
69e1b06
increase accuracy for ca, aa and ba
xGinko Aug 10, 2024
930b3fb
fix config path
xGinko Aug 10, 2024
ec5398e
fix pistonaura config
xGinko Aug 10, 2024
2aee0da
remove isEmpty call due to invocationtargetexception
xGinko Aug 10, 2024
676ea48
add entity spawns to regional activity modules
xGinko Aug 10, 2024
c5badb4
fix module comments from copy paste
xGinko Aug 10, 2024
0aae0ef
implement per hand delay in folia build
xGinko Aug 11, 2024
3fd1d73
fix comment
xGinko Aug 11, 2024
3f6a37b
fix various method names
xGinko Aug 12, 2024
558b81b
shorten regional activity module
xGinko Aug 12, 2024
55f35ea
fix flipped bool
xGinko Aug 12, 2024
0904029
move javadoc to interface
xGinko Aug 12, 2024
0a90592
minor comment fixes
xGinko Aug 12, 2024
899fada
fix var name
xGinko Aug 12, 2024
c1f01b9
include plugin and server version in config for better debug
xGinko Aug 12, 2024
062cb02
improvements for burrow module
xGinko Aug 12, 2024
d05511f
update NBT-API
xGinko Aug 12, 2024
c53700f
fix new NBT-API usage
xGinko Aug 12, 2024
358c9a8
forgot to use util method
xGinko Aug 12, 2024
baf766d
use XMaterial in util
xGinko Aug 12, 2024
3f77c84
improve MaterialUtil
xGinko Aug 13, 2024
85689b3
restructure util
xGinko Aug 13, 2024
7e22478
Release 2.7.2
xGinko Aug 13, 2024
a1357a5
add allay dupe prevention
xGinko Aug 14, 2024
7d01642
kick allay from vehicle on item pickup or drop
xGinko Aug 14, 2024
ffe7c0e
oof
xGinko Aug 16, 2024
e01060d
inherit javadoc
xGinko Aug 17, 2024
9e9d659
update xseries
xGinko Aug 17, 2024
0675ec8
fix display of wrong jar version error
xGinko Aug 17, 2024
16c343a
rework withers section
xGinko Aug 17, 2024
552a7c0
fix build
xGinko Aug 17, 2024
76d58ab
shorten code
xGinko Aug 17, 2024
6a60c15
dismount a few ticks later and make it configurable
xGinko Aug 18, 2024
0e24c13
fix module loadup
xGinko Aug 19, 2024
fd20a39
add inventory interactions to silent swap
xGinko Aug 20, 2024
c4d5e3c
add option to update inv on cancel
xGinko Aug 21, 2024
d2364d1
get rid of listener and just move to module
xGinko Sep 5, 2024
9024a3e
dont forget to listen for deaths
xGinko Sep 5, 2024
cb4766e
only do operation if needed
xGinko Sep 5, 2024
edbdefb
add 1.20.6-1.21 bookdupe prevention
xGinko Sep 10, 2024
97d90f6
improve lag caused by operations happening on chunk load
xGinko Sep 12, 2024
ba0db4d
change path and rename book-ban module
xGinko Sep 12, 2024
8b1b943
remove hacky pearl phase patch until theres a better one
xGinko Sep 12, 2024
fe4b563
fix paper warning about getting faraway chunks
xGinko Nov 5, 2024
a3b10af
Merge remote-tracking branch 'origin/dev' into dev
xGinko Nov 5, 2024
fcec699
speed up reload
xGinko Nov 5, 2024
ce96c1b
remove useless method
xGinko Nov 5, 2024
15e97a5
rename getters
xGinko Nov 5, 2024
60bf157
disable logging in relevant class
xGinko Nov 5, 2024
2b23674
check for paper first
xGinko Nov 5, 2024
092b455
dont disable packetevents update check
xGinko Nov 5, 2024
2c33bda
patch new exploit and update plugin
xGinko Dec 20, 2024
d021f2c
decrease to 256 chars by default
xGinko Dec 20, 2024
e8399a9
use bytebufhelper instead
xGinko Dec 20, 2024
4306941
speed up module loading
xGinko Dec 30, 2024
281501b
ignore modules that couldnt be loaded due to missing dependencies
xGinko Dec 30, 2024
7db304c
unregister permissions on disable
xGinko Dec 31, 2024
c357828
move comment
xGinko Dec 31, 2024
9824441
shutdown executor instead of calling close
xGinko Dec 31, 2024
62c0266
use XMaterial to always set version defaults
xGinko Dec 31, 2024
fa1e831
fix NPE during config default creation
xGinko Dec 31, 2024
f81c95f
remove unnecessary override
xGinko Dec 31, 2024
897f234
fix wrong entity type
xGinko Dec 31, 2024
c971490
initialize map with smaller size
xGinko Dec 31, 2024
e803cf4
use smaller map for defaults as well
xGinko Dec 31, 2024
6e25205
be more specific in version testing
xGinko Dec 31, 2024
1e5eb10
remove another unnecessary override
xGinko Dec 31, 2024
565d23e
only load defaults if lang folder doesnt exist
xGinko Dec 31, 2024
b9aa6f9
first language cache loaded creates lang folder if doesnt exist
xGinko Dec 31, 2024
316b180
define variable for clarity
xGinko Dec 31, 2024
0100fdd
fix #243
xGinko Dec 31, 2024
eb1c45f
shorten code
xGinko Dec 31, 2024
b985498
apply misunderstood fix from #240
xGinko Dec 31, 2024
e680a47
fix #248
xGinko Dec 31, 2024
7249f48
disable plugin if we are unable to create directory
xGinko Dec 31, 2024
2175d87
fix cleanup handling in permission cache
xGinko Dec 31, 2024
8e5669e
cache blocklimiter result to prevent lag
xGinko Dec 31, 2024
d95133e
fix default cache time
xGinko Dec 31, 2024
6d60016
one second is more efficient
xGinko Dec 31, 2024
510ddd5
speed up checking if over the limit
xGinko Dec 31, 2024
519dcaa
cleanup leftover chunklimit modules
xGinko Dec 31, 2024
e201839
add a few more version related log messages and checks to legacy init
xGinko Dec 31, 2024
31ad940
fix missing config defaults
xGinko Dec 31, 2024
aed48a2
fix config path
xGinko Dec 31, 2024
8aaaabe
actually fix config path
xGinko Dec 31, 2024
c4fbc7e
set to disabled unless overriden
xGinko Jan 1, 2025
e7dc6a4
getter is fast enough
xGinko Jan 1, 2025
627ed67
simplify logging during module initialization
xGinko Jan 1, 2025
87641b1
expand module enable & disable logging
xGinko Jan 1, 2025
4cf5f0a
fix tabcomplete suggestions
xGinko Jan 1, 2025
5b8a7aa
specifically use immutable collections
xGinko Jan 1, 2025
3eb4b4a
speedup overview creation
xGinko Jan 1, 2025
cf5dfc8
fix #237
xGinko Jan 1, 2025
f1031c6
fix build
xGinko Jan 1, 2025
7c80f55
weaken visibility
xGinko Jan 1, 2025
30f3508
default to undefined
xGinko Jan 1, 2025
132d99d
handle bypass permissions more sanely on illegal item modules
xGinko Jan 1, 2025
382aa5b
ignore gui item interactions in illegal listeners
xGinko Jan 1, 2025
4b1f04a
let luckperms only handle players
xGinko Jan 1, 2025
f9c823a
simplify implementation
xGinko Jan 1, 2025
e14f271
simplify down to permissible
xGinko Jan 1, 2025
72e96bc
fix variable name
xGinko Jan 1, 2025
e52d6b9
finalize util classes
xGinko Jan 1, 2025
22ad86b
turn exp-bottle-limit into more useful projectile limit
xGinko Jan 1, 2025
f738988
improve enable/disable of swapitemdelay
xGinko Jan 1, 2025
28d25d6
fix possible concurrency issue on folia
xGinko Jan 1, 2025
cd77a58
remove unnecessary override
xGinko Jan 1, 2025
a9c2d87
move comment into constructor
xGinko Jan 1, 2025
ea328f1
fix all cross version compatible Air material handling
xGinko Jan 1, 2025
1da9a41
cleanup constructors
xGinko Jan 1, 2025
6e9aac3
set to FALSE instead of attempting removal
xGinko Jan 1, 2025
6c4a5d0
improve logging messages
xGinko Jan 1, 2025
a13b9b4
expand module features
xGinko Jan 1, 2025
b62f3f8
fix catch
xGinko Jan 1, 2025
d31a091
fix comments
xGinko Jan 1, 2025
6be25ca
fix enable without luckperms
xGinko Jan 1, 2025
1103b95
replace left over deprecated parseMaterial calls
xGinko Jan 2, 2025
e24f3f2
improve logging level for shaded libraries
xGinko Jan 2, 2025
6585a6b
improve accuracy of startup version test
xGinko Jan 2, 2025
be0d646
improve startup order and logging of modules
xGinko Jan 2, 2025
5a3b110
improve server type and version detection
xGinko Jan 2, 2025
a85c41b
improve version check accuracy
xGinko Jan 2, 2025
cfd1434
improve purpur detection on older versions
xGinko Jan 2, 2025
ba63930
go back to showing traces on error
xGinko Jan 2, 2025
11fbb14
minor change of enable logs
xGinko Jan 2, 2025
2e92748
remove double comment
xGinko Jan 2, 2025
9789625
fix default config generation
xGinko Jan 2, 2025
dcf42a4
improve illegal item handling for all modules
xGinko Jan 2, 2025
7056f8d
modules should log by default
xGinko Jan 2, 2025
35ea3d6
cleanup entries first
xGinko Jan 2, 2025
8a4793e
improve handling of inventory clicks
xGinko Jan 2, 2025
63914f6
remove unnecessary listener
xGinko Jan 2, 2025
76c2fa0
rename to long name
xGinko Jan 2, 2025
e8be936
ignore drops in inventory clicks
xGinko Jan 2, 2025
ccefca7
implement typed limits in regional activity
xGinko Jan 3, 2025
086bc19
rename to util
xGinko Jan 3, 2025
e8152dd
lazily initialize to save resources
xGinko Jan 3, 2025
2626cdc
dont double check packet
xGinko Jan 4, 2025
28cd893
add comments in regional activity modules
xGinko Jan 4, 2025
4d3ada1
update dependencies
xGinko Jan 4, 2025
2796979
ready for release
xGinko Jan 4, 2025
f2b2908
Merge remote-tracking branch 'origin/master' into dev
xGinko Jan 4, 2025
84a6f31
Add new-places.ru in README.md (#234)
Imptovskii Aug 13, 2024
f0fd1e5
add archmc to list of servers (#235)
professorparabellum Sep 10, 2024
95fa251
Update README.md
xGinko Oct 1, 2024
d390027
cherry pick
xGinko Jan 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion AnarchyExploitFixesFolia/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ tasks.shadowJar {
archiveFileName = "${rootProject.name}-${project.name}-${project.version}.${archiveExtension.get()}"
exclude(
"com/cryptomorin/xseries/XBiome*",
"com/cryptomorin/xseries/XPotion*",
"com/cryptomorin/xseries/NMSExtras*",
"com/cryptomorin/xseries/NoteBlockMusic*",
"com/cryptomorin/xseries/SkullCacheListener*"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package me.xginko.aef;

import com.github.retrooper.packetevents.PacketEvents;
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import de.tr7zw.changeme.nbtapi.NBT;
import me.xginko.aef.commands.AEFCommand;
import me.xginko.aef.config.Config;
import me.xginko.aef.config.LanguageCache;
import me.xginko.aef.enums.AEFPermission;
import me.xginko.aef.listeners.AEFListener;
import me.xginko.aef.modules.AEFModule;
import me.xginko.aef.utils.CachingPermTool;
import me.xginko.aef.utils.permissions.AEFPermission;
import me.xginko.aef.utils.permissions.PermissionHandler;
import me.xginko.aef.utils.KyoriUtil;
import me.xginko.aef.utils.PlatformUtil;
import me.xginko.aef.utils.tickdata.TickReporter;
Expand All @@ -24,8 +24,6 @@

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Collections;
Expand All @@ -34,6 +32,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.jar.JarFile;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
Expand All @@ -45,31 +44,33 @@ public final class AnarchyExploitFixes extends JavaPlugin {
private static AnarchyExploitFixes instance;
private static Map<String, LanguageCache> languageCacheMap;
private static Config config;

private static TickReporter tickReporter;
private static CachingPermTool cachingPermTool;
private static PermissionHandler permissionHandler;
private static ComponentLogger prefixedLogger, unPrefixedLogger;

private static Metrics metrics;
private static boolean isPacketEventsInstalled;

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

@Override
public void onEnable() {
if (!PlatformUtil.isPaper()) {
getLogger().severe("This plugin depends on Paper's API, which is not present on your server.");
getServer().getPluginManager().disablePlugin(this);
return;
}

prefixedLogger = ComponentLogger.logger(getLogger().getName());
unPrefixedLogger = ComponentLogger.logger("");

isPacketEventsInstalled = getServer().getPluginManager().getPlugin("packetevents") != null;
if (!isPacketEventsInstalled) {
Stream.of(" ",
" _ _ _ _ _ ",
Expand All @@ -89,10 +90,6 @@ public void onEnable() {
return;
}

instance = this;
cachingPermTool = CachingPermTool.enable(this);
metrics = new Metrics(this, 8700);

Stream.of(" ",
" ",
" █████ ███████ ███████ ",
Expand All @@ -104,32 +101,29 @@ public void onEnable() {
" "
).map(str -> Component.text(str).color(KyoriUtil.AEF_WHITE)).forEach(prefixedLogger::info);

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

prefixedLogger.info("Detected Version 1.{}.{}", PlatformUtil.getMinecraftVersion(), PlatformUtil.getMinecraftPatchVersion());

if (PlatformUtil.getMinecraftVersion() < 19) {
prefixedLogger.error("The Folia jar is intended for Paper and Folia servers running 1.19 and above.");
prefixedLogger.error("Please replace it with the Legacy jar.");
try {
Files.createDirectories(getDataFolder().toPath());
} catch (Exception e) {
prefixedLogger.error("Unable to create plugin directory.", e);
getServer().getPluginManager().disablePlugin(this);
return;
}

if (PlatformUtil.isFolia()) {
prefixedLogger.info("Detected Folia server.");
}
instance = this;

try {
createDirectory(getDataFolder());
} catch (IOException e) {
prefixedLogger.error("Unable to create plugin folder!", e);
getServer().getPluginManager().disablePlugin(this);
return;
}
prefixedLogger.info("Registering Permissions");
permissionHandler = PermissionHandler.create(this);
AEFPermission.registerAll();

prefixedLogger.info("Loading Config");
reloadConfiguration();
Expand All @@ -140,31 +134,30 @@ public void onEnable() {
prefixedLogger.info("Registering Commands");
AEFCommand.registerCommands();

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

prefixedLogger.info("Initializing PacketEvents");
PacketEvents.getAPI().init();
prefixedLogger.info("Loading Metrics");
metrics = new Metrics(this, 8700);

prefixedLogger.info("Ready.");
prefixedLogger.info("Done.");
}

@Override
public void onDisable() {
AEFPermission.unregisterAll();
if (isPacketEventsInstalled) {
AEFModule.ENABLED_MODULES.forEach(AEFModule::disable);
AEFModule.ENABLED_MODULES.clear();
AEFListener.LISTENERS.forEach(AEFListener::disable);
AEFListener.LISTENERS.clear();
PacketEvents.getAPI().terminate();
AEFModule.disableAll();
}
if (languageCacheMap != null) {
languageCacheMap.clear();
languageCacheMap = null;
}
if (cachingPermTool != null) {
cachingPermTool.disable();
cachingPermTool = null;
if (permissionHandler != null) {
permissionHandler.disable();
permissionHandler = null;
}
if (tickReporter != null) {
tickReporter.disable();
Expand All @@ -184,19 +177,23 @@ public static AnarchyExploitFixes getInstance() {
return instance;
}

public static TickReporter getTickReporter() {
public static PermissionHandler permissions() {
return permissionHandler;
}

public static TickReporter tickReporter() {
return tickReporter;
}

public static Config config() {
return config;
}

public static ComponentLogger getPrefixedLogger() {
public static ComponentLogger prefixedLogger() {
return prefixedLogger;
}

public static ComponentLogger getUnprefixedLogger() {
public static ComponentLogger unprefixedLogger() {
return unPrefixedLogger;
}

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

public void createDirectory(File dir) throws IOException {
try {
Files.createDirectories(dir.toPath());
} catch (FileAlreadyExistsException e) { // Thrown if dir exists but is not a directory
if (dir.delete()) createDirectory(dir);
}
}

public void reloadPlugin() {
reloadConfiguration();
reloadLang();
}

private void reloadConfiguration() {
try {
createDirectory(getDataFolder());
config = new Config();
if (tickReporter != null) tickReporter.disable();
tickReporter = TickReporter.create(this, config.tickData_cache_duration);
AEFListener.reloadListeners();
AEFModule.reloadModules();
config.saveConfig();
} catch (Throwable t) {
Expand Down Expand Up @@ -276,10 +263,9 @@ public void reloadLang() {

private @NotNull List<String> getAvailableTranslations() {
try (final JarFile pluginJar = new JarFile(getFile())) {
createDirectory(new File(getDataFolder(), "/lang"));
final Pattern langPattern = Pattern.compile("([a-z]{1,3}_[a-z]{1,3})(\\.yml)", Pattern.CASE_INSENSITIVE);
final File[] langDirFiles = new File(getDataFolder() + "/lang").listFiles();
return Stream.concat(pluginJar.stream().map(ZipEntry::getName), Arrays.stream(langDirFiles).map(File::getName))
final File langFolder = new File(getDataFolder(), "/lang");
return (langFolder.exists() ? Arrays.stream(langFolder.listFiles()).map(File::getName) : pluginJar.stream().map(ZipEntry::getName))
.map(langPattern::matcher)
.filter(Matcher::find)
.map(matcher -> matcher.group(1))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.xginko.aef.commands;

import me.xginko.aef.AnarchyExploitFixes;
import me.xginko.aef.enums.AEFPermission;
import me.xginko.aef.utils.permissions.AEFPermission;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -37,7 +37,7 @@ public void enable() {

@Override
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
if (!sender.hasPermission(AEFPermission.CMD_HELP.bukkit())) {
if (!AnarchyExploitFixes.permissions().permissionValue(sender, AEFPermission.CMD_HELP.node()).toBoolean()) {
sender.sendMessage(AnarchyExploitFixes.getLang(sender).no_permission);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.xginko.aef.commands;

import me.xginko.aef.AnarchyExploitFixes;
import me.xginko.aef.enums.AEFPermission;
import me.xginko.aef.utils.permissions.AEFPermission;
import me.xginko.aef.utils.CommandUtil;
import net.kyori.adventure.text.TextReplacementConfig;
import net.kyori.adventure.text.minimessage.MiniMessage;
Expand Down Expand Up @@ -40,7 +40,7 @@ public void enable() {

@Override
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
if (!sender.hasPermission(AEFPermission.CMD_SAY.bukkit())) {
if (!AnarchyExploitFixes.permissions().permissionValue(sender, AEFPermission.CMD_SAY.node()).toBoolean()) {
sender.sendMessage(AnarchyExploitFixes.getLang(sender).no_permission);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package me.xginko.aef.commands;

import me.xginko.aef.AnarchyExploitFixes;
import me.xginko.aef.enums.AEFKey;
import me.xginko.aef.enums.AEFPermission;
import me.xginko.aef.utils.enums.AEFKey;
import me.xginko.aef.utils.permissions.AEFPermission;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.command.Command;
Expand Down Expand Up @@ -44,7 +44,7 @@ public void enable() {
@Override
@SuppressWarnings("DataFlowIssue")
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
if (!sender.hasPermission(AEFPermission.CMD_TOGGLE_CONNECT_MSGS.bukkit())) {
if (!AnarchyExploitFixes.permissions().permissionValue(sender, AEFPermission.CMD_TOGGLE_CONNECT_MSGS.node()).toBoolean()) {
sender.sendMessage(AnarchyExploitFixes.getLang(sender).no_permission);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package me.xginko.aef.commands.aef;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import me.xginko.aef.AnarchyExploitFixes;
import me.xginko.aef.commands.AEFCommand;
import me.xginko.aef.commands.SubCommand;
Expand All @@ -18,11 +20,14 @@

import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class AEFCmd extends Command implements AEFCommand {

private final @NotNull List<SubCommand> subCommands;
private final @NotNull Set<SubCommand> subCommands;
private final @NotNull List<String> tabCompletes;
private final @NotNull List<Component> overview;

Expand All @@ -46,16 +51,17 @@ public AEFCmd() {
" <#00edff>/aef bytesize <mainhand/inventory> (player) (utf8/utf16)",
" <#869699>- <#e2fdff>Get the byte size of an item or inventory.",
""
).map(MiniMessage.miniMessage()::deserialize).toList();
this.subCommands = List.of(
).map(MiniMessage.miniMessage()::deserialize)
.collect(Collectors.collectingAndThen(Collectors.toList(), ImmutableList::copyOf));
this.subCommands = ImmutableSet.of(
new ReloadSubCmd(),
new VersionSubCmd(),
new DisableSubCmd(),
new LagSubCmd(),
new ElytraSubCmd(),
new GearedSubCmd()
);
this.tabCompletes = subCommands.stream().map(SubCommand::label).sorted().toList();
new GearedSubCmd());
this.tabCompletes = subCommands.stream().map(SubCommand::label).sorted()
.collect(Collectors.collectingAndThen(Collectors.toList(), ImmutableList::copyOf));
}

@Override
Expand All @@ -75,7 +81,9 @@ public void enable() {
throws CommandException, IllegalArgumentException
{
if (args.length == 1) {
return tabCompletes;
return tabCompletes.stream()
.filter(cmd -> cmd.toLowerCase(Locale.ROOT).startsWith(args[0].toLowerCase(Locale.ROOT)))
.collect(Collectors.toList());
}

if (args.length > 1) {
Expand Down
Loading
Loading