Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SageSphinx63920 committed Mar 19, 2024
1 parent 70248f1 commit 0c5824b
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 20 deletions.
12 changes: 3 additions & 9 deletions src/main/java/de/hdg/keklist/KeklistMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,11 @@ public void shutdown() {
}

private void initChars() {
metrics.addCustomChart(new SimplePie("keklist_language", () -> {
return Keklist.getTranslations().getLanguageCode();
}));
metrics.addCustomChart(new SimplePie("keklist_language", () -> Keklist.getTranslations().getLanguageCode()));

metrics.addCustomChart(new SimplePie("keklist_whitelist", () -> {
return plugin.getConfig().getBoolean("whitelist.enabled") ? "enabled" : "disabled";
}));
metrics.addCustomChart(new SimplePie("keklist_whitelist", () -> plugin.getConfig().getBoolean("whitelist.enabled") ? "enabled" : "disabled"));

metrics.addCustomChart(new SimplePie("keklist_blacklist", () -> {
return plugin.getConfig().getBoolean("blacklist.enabled") ? "enabled" : "disabled";
}));
metrics.addCustomChart(new SimplePie("keklist_blacklist", () -> plugin.getConfig().getBoolean("blacklist.enabled") ? "enabled" : "disabled"));

metrics.addCustomChart(new SingleLineChart("keklist_whitelisted", () -> {
ResultSet rsPlayers = Keklist.getDatabase().onQuery("SELECT COUNT(*) FROM whitelist");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.hdg.keklist.api.events.whitelist;

import de.hdg.keklist.api.KeklistAPI;
import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.hdg.keklist.api.events.whitelist;

import de.hdg.keklist.Keklist;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab

if (type.equals(BlacklistType.JAVA)) {
Request request = new Request.Builder().url("https://api.mojang.com/users/profiles/minecraft/" + args[1]).build();
client.newCall(request).enqueue(new UserBlacklistAddCallback((sender instanceof Player) ? (Player) sender : null, reason));
client.newCall(request).enqueue(new UserBlacklistAddCallback((sender instanceof Player) ? sender : null, reason));
} else if (type.equals(BlacklistType.IPv4) || type.equals(BlacklistType.IPv6)) {
ResultSet rs = Keklist.getDatabase().onQuery("SELECT * FROM blacklistIp WHERE ip = ?", args[1]);

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/de/hdg/keklist/extentions/PlanHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

import java.util.Optional;

@Getter
public class PlanHook {

private @Getter Optional<Caller> caller;
private Optional<Caller> caller;

public PlanHook() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void onEntryClick(InventoryClickEvent event) {
meta.lore(List.of(
Keklist.getInstance().getMiniMessage().deserialize(translations.get("gui.blacklist.entry.player.name", username)),
Keklist.getInstance().getMiniMessage().deserialize(translations.get("gui.blacklist.entry.player.uuid")),
Keklist.getInstance().getMiniMessage().deserialize("<white>" + uuid.toString()),
Keklist.getInstance().getMiniMessage().deserialize("<white>" + uuid),
Keklist.getInstance().getMiniMessage().deserialize(translations.get("gui.blacklist.entry.player.by", byPlayer)),
Keklist.getInstance().getMiniMessage().deserialize(translations.get("gui.blacklist.entry.player.date", sdf.format(new Date(unix)))),
Keklist.getInstance().getMiniMessage().deserialize(translations.get("gui.blacklist.entry.reason", reason))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void onEntryClick(InventoryClickEvent event) {
meta.lore(List.of(
Keklist.getInstance().getMiniMessage().deserialize(translations.get("gui.whitelist.entry.player.name", username)),
Keklist.getInstance().getMiniMessage().deserialize(translations.get("gui.whitelist.entry.player.uuid")),
Keklist.getInstance().getMiniMessage().deserialize("<white>" + uuid.toString()),
Keklist.getInstance().getMiniMessage().deserialize("<white>" + uuid),
Keklist.getInstance().getMiniMessage().deserialize(translations.get("gui.whitelist.entry.player.by", byPlayer)),
Keklist.getInstance().getMiniMessage().deserialize(translations.get("gui.whitelist.entry.player.date", sdf.format(new Date(unix))))
));
Expand All @@ -87,7 +87,7 @@ public void onEntryClick(InventoryClickEvent event) {
});

overview.setItem(15, removeItem);
overview.setItem(18, getBackArrow(event.getClickedInventory()));
overview.setItem(18, getBackArrow());

player.openInventory(overview);
} else {
Expand Down Expand Up @@ -141,7 +141,7 @@ public void onEntryClick(InventoryClickEvent event) {
});

overview.setItem(15, removeItem);
overview.setItem(18, getBackArrow(event.getClickedInventory()));
overview.setItem(18, getBackArrow());

player.openInventory(overview);
} else {
Expand Down Expand Up @@ -210,7 +210,7 @@ public void onRemoveClick(InventoryClickEvent event) throws SQLException {

if (event.getCurrentItem().getType() == Material.BARRIER) {
ItemStack item = event.getClickedInventory().getItem(4);
String username = PlainTextComponentSerializer.plainText().serialize(item.getItemMeta().displayName());;
String username = PlainTextComponentSerializer.plainText().serialize(item.getItemMeta().displayName());

Keklist.getDatabase().onUpdate("DELETE FROM whitelist WHERE name = ?", username);
player.sendMessage(
Expand Down Expand Up @@ -239,7 +239,7 @@ public void onRemoveClick(InventoryClickEvent event) throws SQLException {
}
}

private ItemStack getBackArrow(Inventory inventory) {
private ItemStack getBackArrow() {
int pageIndex = 0;
int skipIndex = 0;
boolean onlyPlayer = false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/hdg/keklist/util/KeklistConfigUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class KeklistConfigUtil {
private static Keklist plugin;

public KeklistConfigUtil(Keklist plugin) {
this.plugin = plugin;
KeklistConfigUtil.plugin = plugin;
}

public void updateConfig() {
Expand Down

0 comments on commit 0c5824b

Please sign in to comment.