Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Project: fix idea warns
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Nov 11, 2023
1 parent 2d5e777 commit 4b072b7
Show file tree
Hide file tree
Showing 20 changed files with 124 additions and 246 deletions.
6 changes: 0 additions & 6 deletions src/main/java/net/flectone/chat/builder/MessageBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
public class MessageBuilder {

private final List<WordParams> messages = new ArrayList<>();
private final ComponentBuilder componentBuilder = new ComponentBuilder();
private final ItemStack itemStack;
private final Player sender;

Expand Down Expand Up @@ -212,9 +211,4 @@ private BaseComponent[] createItemComponent(@NotNull ItemStack itemStack, @NotNu
.append(color)
.create();
}

@NotNull
public BaseComponent[] create() {
return componentBuilder.create();
}
}
4 changes: 0 additions & 4 deletions src/main/java/net/flectone/chat/component/FComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ public FComponent() {
this(new TextComponent());
}

public FComponent(@NotNull FComponent fComponent) {
this(fComponent.get());
}

@NotNull
public BaseComponent get() {
return component;
Expand Down
33 changes: 0 additions & 33 deletions src/main/java/net/flectone/chat/database/sqlite/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,39 +185,6 @@ public void fromDatabase(FPlayer fPlayer) {
});
}

@Nullable
public FPlayer getPlayer(@Nullable String name) throws SQLException {
if (name == null) return null;

PreparedStatement playerStatement = connection.prepareStatement("SELECT `uuid`, `ip` FROM `players` WHERE `name` = ?");
playerStatement.setString(1, name);
ResultSet playerResult = playerStatement.executeQuery();

if (!playerResult.next()) return null;

String uuid = playerResult.getString("uuid");
String ip = playerResult.getString("ip");

return new FPlayer(name, uuid, ip);
}

@Nullable
public FPlayer getPlayer(@Nullable UUID uuid) throws SQLException {
if (uuid == null) return null;
String uuidString = uuid.toString();

PreparedStatement playerStatement = connection.prepareStatement("SELECT `name`, `ip` FROM `players` WHERE `uuid` = ?");
playerStatement.setString(1, uuidString);
ResultSet playerResult = playerStatement.executeQuery();

if (!playerResult.next()) return null;

String name = playerResult.getString("name");
String ip = playerResult.getString("ip");

return new FPlayer(name, uuidString, ip);
}

public void getMute(FPlayer fPlayer) {
try {
String uuid = fPlayer.getUuid().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,4 @@ public void disconnect() {
public void onDisconnect() {

}

public boolean isConnected() {
return connection != null;
}

}
12 changes: 1 addition & 11 deletions src/main/java/net/flectone/chat/manager/FActionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.flectone.chat.FlectoneChat;
import net.flectone.chat.module.FCommand;
import net.flectone.chat.module.FInfo;
import net.flectone.chat.module.FListener;
import net.flectone.chat.module.FTicker;
import net.flectone.chat.util.CommandsUtil;
Expand All @@ -16,7 +15,6 @@ public class FActionManager {

private final List<FListener> F_LISTENER_LIST = new ArrayList<>();
private final List<FTicker> F_TICKER_LIST = new ArrayList<>();
private final List<FInfo> F_INFO_LIST = new ArrayList<>();
private final List<FCommand> F_COMMAND_LIST = new ArrayList<>();

public FActionManager() {}
Expand All @@ -33,13 +31,9 @@ public void add(FTicker fTicker) {
F_TICKER_LIST.add(fTicker);
}

public void add(FInfo fInfo) {
F_INFO_LIST.add(fInfo);
}

public void clearAll() {
clearCommands();
clearInfos();
clearListeners();
clearTickers();
}
Expand All @@ -48,11 +42,7 @@ public void clearCommands() {
F_COMMAND_LIST.forEach(fCommand ->
CommandsUtil.unregisterCommand(fCommand.getCommand()));
}

public void clearInfos() {
F_INFO_LIST.clear();
}


public void clearListeners() {
HandlerList.unregisterAll(FlectoneChat.getPlugin());
F_LISTENER_LIST.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,25 @@

import net.flectone.chat.util.NMSUtil;
import org.bukkit.advancement.Advancement;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.util.Arrays;

// Thanks, @CroaBeast, for these methods
// Source https://github.com/CroaBeast/AdvancementInfo

public class FAdvancement {
private static final String COMP_CLASS = "IChatBaseComponent";
private final Advancement adv;
private String toChat = null;
private String hidden = null;
private Type type = Type.UNKNOWN;
private ItemStack item = null;
private String translateKey;
private String translateDesc;

private String title;

public FAdvancement(@NotNull Advancement adv) {
this.adv = adv;

Class<?> craftClass = NMSUtil.getBukkitClass("advancement.CraftAdvancement");
if (craftClass == null) return;
Expand All @@ -40,32 +35,12 @@ public FAdvancement(@NotNull Advancement adv) {
translateKey = String.valueOf(NMSUtil.getObject(NMSUtil.getObject(rawTitle, "b"), "a"));
translateDesc = String.valueOf(NMSUtil.getObject(NMSUtil.getObject(rawDesc, "b"), "a"));

Field itemField = null;
try {
itemField = display.getClass().getDeclaredField("c");
} catch (Exception e) {
e.printStackTrace();
}

Object nmsItemStack = null;
if (itemField != null) {
try {
itemField.setAccessible(true);
nmsItemStack = itemField.get(display);
itemField.setAccessible(false);
} catch (Exception e) {
e.printStackTrace();
}
}

String typeName = NMSUtil.checkValue(NMSUtil.getObject(display, "e"), "PROGRESS");
this.type = Type.getType(typeName);

toChat = NMSUtil.checkValue(NMSUtil.getObject(display, "i"));
hidden = NMSUtil.checkValue(NMSUtil.getObject(display, "j"));

item = NMSUtil.getBukkitItem(nmsItemStack);

Class<?> chatClass = NMSUtil.getVersion() >= 17 ?
NMSUtil.getNMSClass("net.minecraft.network.chat", COMP_CLASS, false) :
NMSUtil.getNMSClass(null, COMP_CLASS, true);
Expand Down Expand Up @@ -99,11 +74,6 @@ public String getTranslateDesc() {
return translateDesc;
}

@NotNull
public Advancement getBukkit() {
return adv;
}

@NotNull
public Type getType() {
return type;
Expand All @@ -117,11 +87,6 @@ public boolean isHidden() {
return getBool(hidden);
}

@Nullable
public ItemStack getItem() {
return item;
}

public enum Type {
UNKNOWN,
TASK,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class PlayerDamager {
@Getter
private Entity killer;
private String killerItemName;
private String killerItemAsJson;
private Entity finalEntityDamager;
private Material finalBlockDamager;
private String damagerTranslateName;
Expand All @@ -41,7 +40,6 @@ public ItemStack getKillerItem() {
public void setKillerItem(@NotNull ItemStack itemStack) {
this.killerItem = itemStack;
this.killerItemName = NMSUtil.getMinecraftName(itemStack);
this.killerItemAsJson = NMSUtil.getItemAsJson(itemStack);
}

@Nullable
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/net/flectone/chat/model/player/FPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,6 @@ public FPlayer(@NotNull OfflinePlayer offlinePlayer) {
this.minecraftName = offlinePlayer.getName() != null ? offlinePlayer.getName() : "Unknown";
}

public FPlayer(@NotNull String uuid, @NotNull String name, @NotNull String ip) {
this();
this.uuid = UUID.fromString(uuid);
this.minecraftName = name;
this.ip = ip;
}

public void init() {
playerManager.add(this);

Expand Down
6 changes: 0 additions & 6 deletions src/main/java/net/flectone/chat/model/player/Moderation.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.Getter;
import net.flectone.chat.util.TimeUtil;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;

import java.util.UUID;
Expand Down Expand Up @@ -52,11 +51,6 @@ private String getName(@NotNull String uuid) {
return name != null ? name : "Unknown";
}

@NotNull
public OfflinePlayer getPlayer() {
return Bukkit.getOfflinePlayer(UUID.fromString(playerUUID));
}

public int getRemainingTime() {
return this.time - TimeUtil.getCurrentTime();
}
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/net/flectone/chat/module/FCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,6 @@ public void sendMessage(@NotNull CommandSender commandSender, @NotNull String st
commandSender.sendMessage(message);
}

public void sendMessage(@NotNull Player player, @NotNull String string) {
String message = locale.getVaultString(player, string);
message = MessageUtil.formatAll(null, message);

player.sendMessage(message);
}

public void sendGlobalMessage(@Nullable Player player, @Nullable ItemStack itemStack, @NotNull String format,
@NotNull String message, boolean isClickable) {

Expand Down
13 changes: 0 additions & 13 deletions src/main/java/net/flectone/chat/module/FInfo.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ public void asyncOnCommand(@NotNull CommandSender commandSender, @NotNull Comman

pageLine = MessageUtil.formatAll(cmdSettings.getSender(), pageLine);

FComponentBuilder fComponentBuilder = getfComponentBuilder(pageLine, page, cmdSettings);

componentBuilder.append(fComponentBuilder.build(cmdSettings.getSender(), cmdSettings.getSender()));
commandSender.spigot().sendMessage(componentBuilder.create());

if (!cmdSettings.isConsole()) {
cmdSettings.getFPlayer().playSound(cmdSettings.getSender(), cmdSettings.getSender(), this.toString());
}
}

@NotNull
private FComponentBuilder getfComponentBuilder(String pageLine, int page, CmdSettings cmdSettings) {
FComponentBuilder fComponentBuilder = new FComponentBuilder(pageLine);

AtomicInteger prevNumber = new AtomicInteger(page);
Expand All @@ -144,13 +156,7 @@ public void asyncOnCommand(@NotNull CommandSender commandSender, @NotNull Comman

nextBuilder.append(fComponent.get(), ComponentBuilder.FormatRetention.NONE);
});

componentBuilder.append(fComponentBuilder.build(cmdSettings.getSender(), cmdSettings.getSender()));
commandSender.spigot().sendMessage(componentBuilder.create());

if (!cmdSettings.isConsole()) {
cmdSettings.getFPlayer().playSound(cmdSettings.getSender(), cmdSettings.getSender(), this.toString());
}
return fComponentBuilder;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command

pageLine = MessageUtil.formatAll(cmdSettings.getSender(), pageLine);

FComponentBuilder fComponentBuilder = getfComponentBuilder(pageLine, page, cmdSettings);

componentBuilder.append(fComponentBuilder.build(cmdSettings.getSender(), cmdSettings.getSender()));

commandSender.spigot().sendMessage(componentBuilder.create());

cmdSettings.getFPlayer().playSound(cmdSettings.getSender(), cmdSettings.getSender(), this.toString());

return true;
}

@NotNull
private FComponentBuilder getfComponentBuilder(String pageLine, int page, CmdSettings cmdSettings) {
FComponentBuilder fComponentBuilder = new FComponentBuilder(pageLine);

AtomicInteger prevNumber = new AtomicInteger(page);
Expand All @@ -141,14 +154,7 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command

nextBuilder.append(fComponent.get(), ComponentBuilder.FormatRetention.NONE);
});

componentBuilder.append(fComponentBuilder.build(cmdSettings.getSender(), cmdSettings.getSender()));

commandSender.spigot().sendMessage(componentBuilder.create());

cmdSettings.getFPlayer().playSound(cmdSettings.getSender(), cmdSettings.getSender(), this.toString());

return true;
return fComponentBuilder;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ public void asyncOnCommand(@NotNull CommandSender commandSender, @NotNull Comman

pageLine = MessageUtil.formatAll(cmdSettings.getSender(), pageLine);

FComponentBuilder fComponentBuilder = getfComponentBuilder(pageLine, page, cmdSettings);

componentBuilder.append(fComponentBuilder.build(cmdSettings.getSender(), cmdSettings.getSender()));

commandSender.spigot().sendMessage(componentBuilder.create());

if (!cmdSettings.isConsole()) {
cmdSettings.getFPlayer().playSound(cmdSettings.getSender(), cmdSettings.getSender(), this.toString());
}
}

@NotNull
private FComponentBuilder getfComponentBuilder(String pageLine, int page, CmdSettings cmdSettings) {
FComponentBuilder fComponentBuilder = new FComponentBuilder(pageLine);

AtomicInteger prevNumber = new AtomicInteger(page);
Expand All @@ -140,14 +153,7 @@ public void asyncOnCommand(@NotNull CommandSender commandSender, @NotNull Comman

nextBuilder.append(fComponent.get(), ComponentBuilder.FormatRetention.NONE);
});

componentBuilder.append(fComponentBuilder.build(cmdSettings.getSender(), cmdSettings.getSender()));

commandSender.spigot().sendMessage(componentBuilder.create());

if (!cmdSettings.isConsole()) {
cmdSettings.getFPlayer().playSound(cmdSettings.getSender(), cmdSettings.getSender(), this.toString());
}
return fComponentBuilder;
}

@Override
Expand Down
Loading

0 comments on commit 4b072b7

Please sign in to comment.