perf: 优化代码

This commit is contained in:
2023-01-18 16:12:22 +08:00
parent 9758be5354
commit 309d7c2f15
6 changed files with 9 additions and 75 deletions

View File

@@ -1,5 +0,0 @@
package cn.hamster3.mc.plugin.core.bukkit.page;
@SuppressWarnings("unused")
public interface PageElement {
}

View File

@@ -2,7 +2,6 @@ package cn.hamster3.mc.plugin.core.bukkit.page.handler;
import cn.hamster3.mc.plugin.core.bukkit.page.ButtonGroup;
import cn.hamster3.mc.plugin.core.bukkit.page.PageConfig;
import cn.hamster3.mc.plugin.core.bukkit.page.PageElement;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.ClickType;
@@ -24,7 +23,7 @@ import java.util.Map;
* @param <E> 页面元素
*/
@SuppressWarnings("unused")
public abstract class PageableHandler<E extends PageElement> extends FixedPageHandler {
public abstract class PageableHandler<E> extends FixedPageHandler {
private static final ItemStack EMPTY_STACK = new ItemStack(Material.AIR);
private String previewButtonName = "preview";

View File

@@ -8,8 +8,8 @@ import org.bukkit.entity.HumanEntity;
import java.util.concurrent.CompletableFuture;
@SuppressWarnings("unused")
public final class CallbackUtils {
private CallbackUtils() {
public final class BukkitCallbackUtils {
private BukkitCallbackUtils() {
}
public static CompletableFuture<String> getPlayerChat(HumanEntity player) {

View File

@@ -1,12 +0,0 @@
package cn.hamster3.mc.plugin.core.common.util;
@SuppressWarnings("unused")
public final class CaseUtils {
private CaseUtils() {
}
@SuppressWarnings("unchecked")
public static <T> T caseObject(Object o) {
return (T) o;
}
}

View File

@@ -8,7 +8,6 @@ import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -65,7 +64,8 @@ public final class CommonUtils {
*/
@NotNull
public static String replaceColorCode(@Nullable String string, @NotNull String defaultValue) {
return replaceColorCode(Objects.requireNonNullElse(string, defaultValue));
if (string == null) return defaultValue;
return string.replace("&", "§");
}
/**
@@ -171,5 +171,9 @@ public final class CommonUtils {
return list;
}
@SuppressWarnings("unchecked")
public static <T> T caseObject(Object o) {
return (T) o;
}
}

View File

@@ -1,52 +0,0 @@
package cn.hamster3.mc.plugin.core.common.util;
import org.jetbrains.annotations.NotNull;
import java.io.Serializable;
import java.util.Objects;
/**
* <p>A convenience class to represent name-value pairs.</p>
*/
@SuppressWarnings({"unused", "ClassCanBeRecord"})
public class Pair<K, V> implements Serializable {
/**
* Key of this <code>Pair</code>.
*/
@NotNull
private final K key;
/**
* Value of this <code>Pair</code>.
*/
@NotNull
private final V value;
public Pair(@NotNull K key, @NotNull V value) {
this.key = key;
this.value = value;
}
@NotNull
public K getKey() {
return key;
}
@NotNull
public V getValue() {
return value;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Pair<?, ?> pair = (Pair<?, ?>) o;
return key.equals(pair.key) && value.equals(pair.value);
}
@Override
public int hashCode() {
return Objects.hash(key, value);
}
}