Skip to content

Commit

Permalink
General code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Despical committed Jan 14, 2024
1 parent 47ec80a commit 48a1c90
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private void init() {
if (Collections.contains(plugin.getChatManager().message("language"), pluginLocale.aliases)) return;

try {
FileUtils.copyURLToFile(new URL("https://raw.githubusercontent.com/Despical/LocaleStorage/main/Minecraft/KOTL/" + pluginLocale.prefix + ".yml"), new File(plugin.getDataFolder(), "messages.yml"));
FileUtils.copyURLToFile(new URL("https://raw.githubusercontent.com/Despical/LocaleStorage/main/Minecraft/KOTL/%s.yml".formatted(pluginLocale.prefix)), new File(plugin.getDataFolder(), "messages.yml"));
} catch (IOException e) {
plugin.getLogger().warning("Error while connecting to internet!");
}
Expand Down Expand Up @@ -86,7 +86,7 @@ private void setupLocale() {
return;
}

plugin.getLogger().info("Loaded locale " + pluginLocale.name + " (ID: " + pluginLocale.prefix + ")");
plugin.getLogger().info("Loaded locale %s (ID: %s)".formatted(pluginLocale.name, pluginLocale.prefix));
}

public Locale getPluginLocale() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ public class LocaleRegistry {

public static void registerLocale(Locale locale) {
registeredLocales.removeIf(l -> l.prefix().equals(locale.prefix()));

registeredLocales.add(locale);
}

public static Set<Locale> getRegisteredLocales() {
return new HashSet<>(registeredLocales);
return Set.copyOf(registeredLocales);
}

public static Locale getByName(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public RewardType getType() {
return type;
}

final static class SubReward {
public static final class SubReward {

private String executableCode;
private final int chance, executor;
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/me/despical/kotl/kits/KitManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ public void loadKits() {

this.isEnabled = config.getBoolean("kits-enabled");

for (final var path : config.getConfigurationSection("kits").getKeys(false)) {
final var section = config.getConfigurationSection("kits");

if (section == null) {
plugin.getLogger().warning("Section ''kits'' not found in kits.yml!");
return;
}

for (final var path : section.getKeys(false)) {
this.kits.add(new Kit(plugin, "kits." + path + "."));
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/me/despical/kotl/user/data/MysqlManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public MysqlDatabase getDatabase() {
return database;
}

@NotNull
public String getTable() {
return table;
}
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/me/despical/kotl/util/CuboidSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,9 @@ public void onWandUse(PlayerInteractEvent event) {

case LEFT_CLICK_AIR, RIGHT_CLICK_AIR ->
player.sendMessage(chatManager.coloredRawMessage("&c&l✖ &cWarning | Please select solid block, not air!"));

default -> {
}
}
}

public record Selection(Location firstPos, Location secondPos) {

}
}

0 comments on commit 48a1c90

Please sign in to comment.