perf: 优化代码
This commit is contained in:
@@ -1,5 +0,0 @@
|
|||||||
package cn.hamster3.mc.plugin.core.bukkit.page;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public interface PageElement {
|
|
||||||
}
|
|
@@ -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.ButtonGroup;
|
||||||
import cn.hamster3.mc.plugin.core.bukkit.page.PageConfig;
|
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.Material;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
@@ -24,7 +23,7 @@ import java.util.Map;
|
|||||||
* @param <E> 页面元素
|
* @param <E> 页面元素
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@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 static final ItemStack EMPTY_STACK = new ItemStack(Material.AIR);
|
||||||
|
|
||||||
private String previewButtonName = "preview";
|
private String previewButtonName = "preview";
|
||||||
|
@@ -8,8 +8,8 @@ import org.bukkit.entity.HumanEntity;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class CallbackUtils {
|
public final class BukkitCallbackUtils {
|
||||||
private CallbackUtils() {
|
private BukkitCallbackUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompletableFuture<String> getPlayerChat(HumanEntity player) {
|
public static CompletableFuture<String> getPlayerChat(HumanEntity player) {
|
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -8,7 +8,6 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
@@ -65,7 +64,8 @@ public final class CommonUtils {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String replaceColorCode(@Nullable String string, @NotNull String defaultValue) {
|
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;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <T> T caseObject(Object o) {
|
||||||
|
return (T) o;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user