cleanup main class
This commit is contained in:
parent
9dd32b1207
commit
ca3c486d8b
@ -30,6 +30,7 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@ -159,30 +160,39 @@ public final class VillagerOptimizer extends JavaPlugin {
|
||||
public static @NotNull VillagerOptimizer getInstance() {
|
||||
return instance;
|
||||
}
|
||||
public static @NotNull Config config() {
|
||||
return config;
|
||||
}
|
||||
public static @NotNull Cache<Villager, WrappedVillager> getCache() {
|
||||
return wrapperCache;
|
||||
}
|
||||
public static @NotNull CommandRegistration commandRegistration() {
|
||||
return commandRegistration;
|
||||
}
|
||||
|
||||
public static @NotNull GracefulScheduling scheduling() {
|
||||
return scheduling;
|
||||
}
|
||||
|
||||
public static @NotNull CommandRegistration commandRegistration() {
|
||||
return commandRegistration;
|
||||
}
|
||||
|
||||
public static @NotNull Cache<Villager, WrappedVillager> wrappers() {
|
||||
return wrapperCache;
|
||||
}
|
||||
|
||||
public static @NotNull Config config() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public static @NotNull ComponentLogger logger() {
|
||||
return logger;
|
||||
}
|
||||
public static @NotNull BukkitAudiences getAudiences() {
|
||||
|
||||
public static @NotNull BukkitAudiences audiences() {
|
||||
return audiences;
|
||||
}
|
||||
|
||||
public static @NotNull LanguageCache getLang(Locale locale) {
|
||||
return getLang(locale.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static @NotNull LanguageCache getLang(CommandSender commandSender) {
|
||||
return commandSender instanceof Player ? getLang(((Player) commandSender).locale()) : getLang(config.default_lang);
|
||||
}
|
||||
|
||||
public static @NotNull LanguageCache getLang(String lang) {
|
||||
if (!config.auto_lang) return languageCacheMap.get(config.default_lang.toString().toLowerCase());
|
||||
return languageCacheMap.getOrDefault(lang.replace("-", "_"), languageCacheMap.get(config.default_lang.toString().toLowerCase()));
|
||||
@ -243,7 +253,7 @@ public final class VillagerOptimizer extends JavaPlugin {
|
||||
.collect(Collectors.toCollection(TreeSet::new));
|
||||
} catch (Throwable t) {
|
||||
logger.error("Failed while searching for available translations!", t);
|
||||
return new TreeSet<>();
|
||||
return Collections.emptySortedSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class OptVillagersRadius extends VillagerOptimizerCommand {
|
||||
Villager.Profession profession = villager.getProfession();
|
||||
if (profession.equals(Villager.Profession.NITWIT) || profession.equals(Villager.Profession.NONE)) continue;
|
||||
|
||||
WrappedVillager wVillager = VillagerOptimizer.getCache().get(villager, WrappedVillager::new);
|
||||
WrappedVillager wVillager = VillagerOptimizer.wrappers().get(villager, WrappedVillager::new);
|
||||
|
||||
if (player_has_cooldown_bypass || wVillager.canOptimize(cooldown)) {
|
||||
VillagerOptimizeEvent optimizeEvent = new VillagerOptimizeEvent(wVillager, OptimizationType.COMMAND, player);
|
||||
|
@ -92,7 +92,7 @@ public class UnOptVillagersRadius extends VillagerOptimizerCommand {
|
||||
Villager.Profession profession = villager.getProfession();
|
||||
if (profession.equals(Villager.Profession.NITWIT) || profession.equals(Villager.Profession.NONE)) continue;
|
||||
|
||||
WrappedVillager wVillager = VillagerOptimizer.getCache().get(villager, WrappedVillager::new);
|
||||
WrappedVillager wVillager = VillagerOptimizer.wrappers().get(villager, WrappedVillager::new);
|
||||
|
||||
if (wVillager.isOptimized()) {
|
||||
VillagerUnoptimizeEvent unOptimizeEvent = new VillagerUnoptimizeEvent(wVillager, player, OptimizationType.COMMAND);
|
||||
|
@ -33,7 +33,7 @@ public abstract class VillagerOptimizerModule implements Enableable, Disableable
|
||||
public VillagerOptimizerModule(String configPath) {
|
||||
this.plugin = VillagerOptimizer.getInstance();
|
||||
this.config = VillagerOptimizer.config();
|
||||
this.wrapperCache = VillagerOptimizer.getCache();
|
||||
this.wrapperCache = VillagerOptimizer.wrappers();
|
||||
this.scheduling = VillagerOptimizer.scheduling();
|
||||
this.configPath = configPath;
|
||||
shouldEnable(); // Ensure enable option is always first
|
||||
|
@ -11,11 +11,11 @@ import java.util.Locale;
|
||||
public class KyoriUtil {
|
||||
|
||||
public static void sendMessage(@NotNull CommandSender sender, @NotNull Component message) {
|
||||
VillagerOptimizer.getAudiences().sender(sender).sendMessage(message);
|
||||
VillagerOptimizer.audiences().sender(sender).sendMessage(message);
|
||||
}
|
||||
|
||||
public static void sendActionBar(@NotNull CommandSender sender, @NotNull Component message) {
|
||||
VillagerOptimizer.getAudiences().sender(sender).sendActionBar(message);
|
||||
VillagerOptimizer.audiences().sender(sender).sendActionBar(message);
|
||||
}
|
||||
|
||||
public static @NotNull Component toUpperCase(@NotNull Component input, @NotNull Locale locale) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user