Skip to content

Commit

Permalink
rename getters
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Nov 5, 2024
1 parent ce96c1b commit 15e97a5
Show file tree
Hide file tree
Showing 37 changed files with 64 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,19 @@ public static AnarchyExploitFixes getInstance() {
return instance;
}

public static TickReporter getTickReporter() {
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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab
} catch (InterruptedException e) {
sender.sendMessage(Component.text(" Operation was interrupted! - " + e.getLocalizedMessage()).color(NamedTextColor.RED));
player.sendMessage(Component.empty());
AnarchyExploitFixes.getPrefixedLogger().error("Lag command encountered an error!", e);
AnarchyExploitFixes.prefixedLogger().error("Lag command encountered an error!", e);
}
}, null, 1L);
} else {
Expand All @@ -72,7 +72,7 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab
sender.sendMessage(Component.empty());
} catch (InterruptedException e) {
sender.sendMessage(Component.text(" Operation was interrupted! - " + e.getLocalizedMessage()).color(NamedTextColor.RED));
AnarchyExploitFixes.getPrefixedLogger().error("Lag command encountered an error!", e);
AnarchyExploitFixes.prefixedLogger().error("Lag command encountered an error!", e);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ The time in ticks (1 sec = 20 ticks) a checked tps will be cached\s
try {
parsedSound = Sound.valueOf(configuredSound);
} catch (IllegalArgumentException e) {
AnarchyExploitFixes.getPrefixedLogger().warn("<elytra-speed> Sound '{}' does not exist. Using default.", configuredSound);
AnarchyExploitFixes.prefixedLogger().warn("<elytra-speed> Sound '{}' does not exist. Using default.", configuredSound);
parsedSound = Sound.ENTITY_EXPERIENCE_ORB_PICKUP;
}
this.elytra_too_fast_sound = parsedSound;
Expand All @@ -115,7 +115,7 @@ public void saveConfig() {
try {
config.save();
} catch (Exception e) {
AnarchyExploitFixes.getPrefixedLogger().error("Failed to save config file!", e);
AnarchyExploitFixes.prefixedLogger().error("Failed to save config file!", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public LanguageCache(String langString) throws Exception {
// Check if the lang folder has already been created
File parent = langYML.getParentFile();
if (!parent.exists() && !parent.mkdir())
AnarchyExploitFixes.getPrefixedLogger().error("Unable to create lang directory.");
AnarchyExploitFixes.prefixedLogger().error("Unable to create lang directory.");
// Check if the file already exists and save the one from the plugin's resources folder if it does not
if (!langYML.exists())
plugin.saveResource("lang/" + langString + ".yml", false);
Expand Down Expand Up @@ -171,7 +171,7 @@ public LanguageCache(String langString) throws Exception {
try {
this.lang.save();
} catch (Exception e) {
AnarchyExploitFixes.getPrefixedLogger().error("Failed to save language file: {}!", langYML.getName(), e);
AnarchyExploitFixes.prefixedLogger().error("Failed to save language file: {}!", langYML.getName(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,25 @@ public static void reloadModules() {
ENABLED_MODULES.add(module);
}
} catch (Throwable t) { // We want to catch everything here if it fails to init
AnarchyExploitFixes.getPrefixedLogger().warn("Failed initialising module class '{}'.", moduleClass.getSimpleName(), t);
AnarchyExploitFixes.prefixedLogger().warn("Failed initialising module class '{}'.", moduleClass.getSimpleName(), t);
}
}
}

protected void error(String message, Throwable throwable) {
AnarchyExploitFixes.getPrefixedLogger().error(logFormat, message, throwable);
AnarchyExploitFixes.prefixedLogger().error(logFormat, message, throwable);
}

protected void error(String message) {
AnarchyExploitFixes.getPrefixedLogger().error(logFormat, message);
AnarchyExploitFixes.prefixedLogger().error(logFormat, message);
}

protected void warn(String message) {
AnarchyExploitFixes.getPrefixedLogger().warn(logFormat, message);
AnarchyExploitFixes.prefixedLogger().warn(logFormat, message);
}

protected void info(String message) {
AnarchyExploitFixes.getPrefixedLogger().info(logFormat, message);
AnarchyExploitFixes.prefixedLogger().info(logFormat, message);
}

protected void notRecognized(Class<?> clazz, String unrecognized) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void onChunkLoad(ChunkLoadEvent event) {
if (world.getEnvironment() != World.Environment.NETHER) return;
if (exemptedWorlds.contains(world.getName())) return;

if (!checkShouldPauseOnLowTPS || AnarchyExploitFixes.getTickReporter().getTPS() >= pauseTPS) {
if (!checkShouldPauseOnLowTPS || AnarchyExploitFixes.tickReporter().getTPS() >= pauseTPS) {
ChunkUtil.createBedrockLayer(event.getChunk(), config.nether_ceiling_max_y);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void onChunkLoad(ChunkLoadEvent event) {
if (world.getEnvironment() != World.Environment.NETHER) return;
if (exemptedWorlds.contains(world.getName())) return;

if (!checkShouldPauseOnLowTPS || AnarchyExploitFixes.getTickReporter().getTPS() >= pauseTPS) {
if (!checkShouldPauseOnLowTPS || AnarchyExploitFixes.tickReporter().getTPS() >= pauseTPS) {
ChunkUtil.createBedrockLayer(event.getChunk(), world.getMinHeight());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void onChunkLoad(ChunkLoadEvent event) {
if (world.getEnvironment() != World.Environment.NETHER) return;
if (exemptedWorlds.contains(world.getName())) return;

if (!checkShouldPauseOnLowTPS || AnarchyExploitFixes.getTickReporter().getTPS() >= pauseTPS) {
if (!checkShouldPauseOnLowTPS || AnarchyExploitFixes.tickReporter().getTPS() >= pauseTPS) {
ChunkUtil.createBedrockLayer(event.getChunk(), world.getMinHeight());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void disable() {

@Override
public void accept(ScheduledTask task) {
if (pauseOnLowTPS && AnarchyExploitFixes.getTickReporter().getGlobalTPS() <= pauseTPS) return;
if (pauseOnLowTPS && AnarchyExploitFixes.tickReporter().getGlobalTPS() <= pauseTPS) return;

for (World world : plugin.getServer().getWorlds()) {
if (world.getEnvironment() != World.Environment.NETHER) continue;
Expand All @@ -61,7 +61,7 @@ public void accept(ScheduledTask task) {

plugin.getServer().getRegionScheduler().execute(plugin, world, chunk.getX(), chunk.getZ(), () -> {
if (!chunk.isEntitiesLoaded()) return;
if (pauseOnLowTPS && AnarchyExploitFixes.getTickReporter().getTPS() <= pauseTPS) return;
if (pauseOnLowTPS && AnarchyExploitFixes.tickReporter().getTPS() <= pauseTPS) return;

ChunkUtil.createBedrockLayer(chunk, config.nether_ceiling_max_y);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void disable() {

@Override
public void accept(ScheduledTask task) {
if (pauseOnLowTPS && AnarchyExploitFixes.getTickReporter().getGlobalTPS() <= pauseTPS) return;
if (pauseOnLowTPS && AnarchyExploitFixes.tickReporter().getGlobalTPS() <= pauseTPS) return;

for (World world : plugin.getServer().getWorlds()) {
if (world.getEnvironment() != World.Environment.NETHER) continue;
Expand All @@ -61,7 +61,7 @@ public void accept(ScheduledTask task) {

plugin.getServer().getRegionScheduler().execute(plugin, world, chunk.getX(), chunk.getZ(), () -> {
if (!chunk.isEntitiesLoaded()) return;
if (pauseOnLowTPS && AnarchyExploitFixes.getTickReporter().getTPS() <= pauseTPS) return;
if (pauseOnLowTPS && AnarchyExploitFixes.tickReporter().getTPS() <= pauseTPS) return;

ChunkUtil.createBedrockLayer(chunk, world.getMinHeight());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void disable() {

@Override
public void accept(ScheduledTask task) {
if (pauseOnLowTPS && AnarchyExploitFixes.getTickReporter().getGlobalTPS() <= pauseTPS) return;
if (pauseOnLowTPS && AnarchyExploitFixes.tickReporter().getGlobalTPS() <= pauseTPS) return;

for (World world : plugin.getServer().getWorlds()) {
if (world.getEnvironment() != World.Environment.NORMAL) continue;
Expand All @@ -62,7 +62,7 @@ public void accept(ScheduledTask task) {

plugin.getServer().getRegionScheduler().execute(plugin, world, chunk.getX(), chunk.getZ(), () -> {
if (!chunk.isEntitiesLoaded()) return;
if (pauseOnLowTPS && AnarchyExploitFixes.getTickReporter().getTPS() <= pauseTPS) return;
if (pauseOnLowTPS && AnarchyExploitFixes.tickReporter().getTPS() <= pauseTPS) return;

ChunkUtil.createBedrockLayer(chunk, world.getMinHeight());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
return;
}

if (spawn_DenyOnLowTPS && AnarchyExploitFixes.getTickReporter().getTPS() <= spawn_DenyElytraTPS) {
if (spawn_DenyOnLowTPS && AnarchyExploitFixes.tickReporter().getTPS() <= spawn_DenyElytraTPS) {
if (config.elytra_teleport_back) player.teleportAsync(ElytraHelper.getInstance().getSetbackLocation(event));
else event.setCancelled(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
return;
}

if (global_DenyOnLowTPS && AnarchyExploitFixes.getTickReporter().getTPS() <= global_DenyElytraTPS) {
if (global_DenyOnLowTPS && AnarchyExploitFixes.tickReporter().getTPS() <= global_DenyElytraTPS) {
if (config.elytra_teleport_back) player.teleportAsync(ElytraHelper.getInstance().getSetbackLocation(event));
else event.setCancelled(true);

Expand Down Expand Up @@ -112,7 +112,7 @@ private void onPlayerMove(PlayerMoveEvent event) {

if (ElytraHelper.getInstance().isInNewChunks(player)) {
// Speed New Chunks
if (global_EnableBursting && AnarchyExploitFixes.getTickReporter().getTPS() >= global_BurstNewChunk_TPS) {
if (global_EnableBursting && AnarchyExploitFixes.tickReporter().getTPS() >= global_BurstNewChunk_TPS) {
// Burst Speed New Chunks
if (flySpeed > global_BurstSpeedNewChunks) {
if (config.elytra_teleport_back) player.teleportAsync(ElytraHelper.getInstance().getSetbackLocation(event));
Expand Down Expand Up @@ -195,7 +195,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
}
} else {
// Speed Old Chunks
if (global_EnableBursting && AnarchyExploitFixes.getTickReporter().getTPS() >= global_BurstOldChunk_TPS) {
if (global_EnableBursting && AnarchyExploitFixes.tickReporter().getTPS() >= global_BurstOldChunk_TPS) {
// Burst Speed Old Chunks
if (flySpeed > global_BurstSpeedOldChunks) {
if (config.elytra_teleport_back) player.teleportAsync(ElytraHelper.getInstance().getSetbackLocation(event));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
return;
}

if (ceiling_DenyOnLowTPS && AnarchyExploitFixes.getTickReporter().getTPS() <= ceiling_DenyElytraTPS) {
if (ceiling_DenyOnLowTPS && AnarchyExploitFixes.tickReporter().getTPS() <= ceiling_DenyElytraTPS) {
if (config.elytra_teleport_back) player.teleportAsync(ElytraHelper.getInstance().getSetbackLocation(event));
else event.setCancelled(true);

Expand Down Expand Up @@ -110,7 +110,7 @@ private void onPlayerMove(PlayerMoveEvent event) {

if (ElytraHelper.getInstance().isInNewChunks(player)) {
// Speed New Chunks
if (ceiling_EnableBursting && AnarchyExploitFixes.getTickReporter().getTPS() >= ceiling_BurstNewChunk_TPS) {
if (ceiling_EnableBursting && AnarchyExploitFixes.tickReporter().getTPS() >= ceiling_BurstNewChunk_TPS) {
// Burst Speed New Chunks
if (flySpeed > ceiling_BurstSpeedNewChunks) {
if (config.elytra_teleport_back) player.teleportAsync(ElytraHelper.getInstance().getSetbackLocation(event));
Expand Down Expand Up @@ -193,7 +193,7 @@ private void onPlayerMove(PlayerMoveEvent event) {
}
} else {
// Speed Old Chunks
if (ceiling_EnableBursting && AnarchyExploitFixes.getTickReporter().getTPS() >= ceiling_BurstOldChunk_TPS) {
if (ceiling_EnableBursting && AnarchyExploitFixes.tickReporter().getTPS() >= ceiling_BurstOldChunk_TPS) {
// Burst Speed Old Chunks
if (flySpeed > ceiling_BurstSpeedOldChunks) {
if (config.elytra_teleport_back) player.teleportAsync(ElytraHelper.getInstance().getSetbackLocation(event));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void accept(ScheduledTask task) {
if (ChunkUtil.isRetrievalUnsafe(chunk)) continue;

plugin.getServer().getRegionScheduler().execute(plugin, world, chunk.getX(), chunk.getZ(), () -> {
if (checkShouldPauseOnLowTPS && AnarchyExploitFixes.getTickReporter().getTPS() <= pauseTPS) return;
if (checkShouldPauseOnLowTPS && AnarchyExploitFixes.tickReporter().getTPS() <= pauseTPS) return;
if (!chunk.isEntitiesLoaded()) return;

for (int x = 0; x < 16; x++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void onChunkLoad(ChunkLoadEvent event) {
if (event.isNewChunk()) return;
if (ChunkUtil.isRetrievalUnsafe(event.getChunk())) return;
if (exemptedWorlds.contains(event.getWorld().getName())) return;
if (checkShouldPauseOnLowTPS && AnarchyExploitFixes.getTickReporter().getTPS() <= pauseTPS) return;
if (checkShouldPauseOnLowTPS && AnarchyExploitFixes.tickReporter().getTPS() <= pauseTPS) return;

final int minY = event.getWorld().getMinHeight();
final int maxY = event.getWorld().getMaxHeight();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void onChunkLoad(ChunkLoadEvent event) {
if (event.isNewChunk()) return;
if (ChunkUtil.isRetrievalUnsafe(event.getChunk())) return;
if (!naturalSpawners.containsKey(event.getWorld().getName())) return;
if (checkShouldPauseOnLowTPS && AnarchyExploitFixes.getTickReporter().getTPS() <= pauseTPS) return;
if (checkShouldPauseOnLowTPS && AnarchyExploitFixes.tickReporter().getTPS() <= pauseTPS) return;

final int minY = event.getWorld().getMinHeight();
final int maxY = event.getWorld().getMaxHeight();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public void disable() {
}

public boolean shouldCancelActivity(Event event, Location location, int limit) {
double tps = AnarchyExploitFixes.getTickReporter().getTPS();
double mspt = AnarchyExploitFixes.getTickReporter().getMSPT();
double tps = AnarchyExploitFixes.tickReporter().getTPS();
double mspt = AnarchyExploitFixes.tickReporter().getMSPT();

if (tps <= pauseTPS || mspt >= pauseMSPT) {
if (logIsEnabled) info("Cancelling " + event.getClass().getSimpleName() + " because server is lagging." +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private void onPlayerJoin(PlayerJoinEvent event) {

if (logFirstJoin) {
for (Component line : AnarchyExploitFixes.getLang(joiningPlayer.locale()).misc_firstJoinMessage) {
AnarchyExploitFixes.getUnprefixedLogger().info(line
AnarchyExploitFixes.unprefixedLogger().info(line
.replaceText(TextReplacementConfig.builder()
.matchLiteral("%player%")
.replacement(joiningPlayer.name())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private void onPlayerJoinEvent(PlayerJoinEvent event) {
}

if (showInConsole) {
AnarchyExploitFixes.getUnprefixedLogger().info(AnarchyExploitFixes.getLang(joiningPlayer.locale()).misc_joinMessage
AnarchyExploitFixes.unprefixedLogger().info(AnarchyExploitFixes.getLang(joiningPlayer.locale()).misc_joinMessage
.replaceText(TextReplacementConfig.builder().matchLiteral("%player%").replacement(joiningPlayer.name()).build())
.append(Component.text(" (" + joiningPlayer.locale() + ")")));
}
Expand Down Expand Up @@ -96,7 +96,7 @@ private void onPlayerLeaveEvent(PlayerQuitEvent event) {
}

if (showInConsole) {
AnarchyExploitFixes.getUnprefixedLogger().info(AnarchyExploitFixes.getLang(leavingPlayer.locale()).misc_leaveMessage
AnarchyExploitFixes.unprefixedLogger().info(AnarchyExploitFixes.getLang(leavingPlayer.locale()).misc_leaveMessage
.replaceText(TextReplacementConfig.builder().matchLiteral("%player%").replacement(leavingPlayer.name()).build())
.append(Component.text(" (" + leavingPlayer.locale() + ")")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ public static Config config() {
return config;
}

public static Datastore getDatastore() {
public static Datastore datastore() {
return datastore;
}

public static TickReporter getTickReporter() {
public static TickReporter tickReporter() {
return tickReporter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab

final Player player = (Player) sender;

AnarchyExploitFixes.getDatastore().getJoinLeaveEnabled(player.getUniqueId()).thenAccept(enabled -> {
AnarchyExploitFixes.datastore().getJoinLeaveEnabled(player.getUniqueId()).thenAccept(enabled -> {
if (enabled) {
AnarchyExploitFixes.getDatastore().setJoinLeaveEnabled(player.getUniqueId(), false)
AnarchyExploitFixes.datastore().setJoinLeaveEnabled(player.getUniqueId(), false)
.thenRun(() -> sender.sendMessage(AnarchyExploitFixes.getLang(player.getLocale()).misc_disabledConnectionMsgs));
} else {
AnarchyExploitFixes.getDatastore().setJoinLeaveEnabled(player.getUniqueId(), true)
AnarchyExploitFixes.datastore().setJoinLeaveEnabled(player.getUniqueId(), true)
.thenRun(() -> sender.sendMessage(AnarchyExploitFixes.getLang(player.getLocale()).misc_enabledConnectionMsgs));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void onChunkLoad(ChunkLoadEvent event) {
if (world.getEnvironment() != World.Environment.NETHER) return;
if (exemptedWorlds.contains(world.getName())) return;

if (!pauseOnLowTPS || AnarchyExploitFixes.getTickReporter().getTPS() >= pauseTPS) {
if (!pauseOnLowTPS || AnarchyExploitFixes.tickReporter().getTPS() >= pauseTPS) {
ChunkUtil.createBedrockLayer(event.getChunk(), config.nether_ceiling_max_y);
}
}
Expand Down
Loading

0 comments on commit 15e97a5

Please sign in to comment.