Skip to content

Commit

Permalink
v2.7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nulli0n committed Dec 6, 2024
1 parent efa794c commit 2dae3ce
Show file tree
Hide file tree
Showing 63 changed files with 3,445 additions and 376 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>su.nightexpress.nightcore</groupId>
<artifactId>nightcore</artifactId>
<version>2.7.2</version>
<version>2.7.3</version>

<properties>
<maven.compiler.source>21</maven.compiler.source>
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/su/nightexpress/nightcore/NightCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import su.nightexpress.nightcore.core.CoreManager;
import su.nightexpress.nightcore.core.CorePerms;
import su.nightexpress.nightcore.core.command.CoreCommands;
import su.nightexpress.nightcore.dialog.Dialog;
import su.nightexpress.nightcore.integration.VaultHook;
import su.nightexpress.nightcore.language.LangAssets;
import su.nightexpress.nightcore.util.Plugins;
Expand Down Expand Up @@ -55,7 +54,6 @@ public void enable() {
public void disable() {
this.coreManager.shutdown();

Dialog.shutdown();
if (Plugins.hasVault()) {
VaultHook.shutdown();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package su.nightexpress.nightcore.api.event;

import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import su.nightexpress.nightcore.ui.menu.Menu;

public class MenuOpenEvent extends Event implements Cancellable {

public static final HandlerList HANDLER_LIST = new HandlerList();

private final Player player;
private final Menu menu;

private boolean cancelled;

public MenuOpenEvent(@NotNull Player player, @NotNull Menu menu) {
this.player = player;
this.menu = menu;
}

@NotNull
@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}

public static HandlerList getHandlerList() {
return HANDLER_LIST;
}

@NotNull
public Player getPlayer() {
return this.player;
}

@NotNull
public Menu getMenu() {
return this.menu;
}

@Override
public boolean isCancelled() {
return this.cancelled;
}

@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import org.jetbrains.annotations.Nullable;
import su.nightexpress.nightcore.util.StringUtil;
import su.nightexpress.nightcore.util.TriFunction;
import su.nightexpress.nightcore.util.bukkit.NightItem;
import su.nightexpress.nightcore.util.bukkit.NightSound;
import su.nightexpress.nightcore.util.bukkit.NightItem;
import su.nightexpress.nightcore.util.wrapper.UniFormatter;
import su.nightexpress.nightcore.util.wrapper.UniParticle;
import su.nightexpress.nightcore.util.wrapper.UniSound;
Expand Down Expand Up @@ -113,6 +113,7 @@ public static ConfigValue<Set<String>> create(@NotNull String path, @NotNull Set
}

@NotNull
@Deprecated
public static ConfigValue<ItemStack> create(@NotNull String path, @NotNull ItemStack defaultValue, @Nullable String... description) {
return create(path, FileConfig::getItem, FileConfig::setItem, defaultValue, description);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import org.jetbrains.annotations.Nullable;
import su.nightexpress.nightcore.NightCorePlugin;
import su.nightexpress.nightcore.util.*;
import su.nightexpress.nightcore.util.bukkit.NightItem;
import su.nightexpress.nightcore.util.text.NightMessage;
import su.nightexpress.nightcore.util.bukkit.NightItem;

import java.io.File;
import java.io.IOException;
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/su/nightexpress/nightcore/core/CoreLang.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import su.nightexpress.nightcore.language.entry.LangItem;
import su.nightexpress.nightcore.language.entry.LangString;
import su.nightexpress.nightcore.language.entry.LangText;
import su.nightexpress.nightcore.ui.dialog.DialogManager;

import static su.nightexpress.nightcore.util.Placeholders.*;
import static su.nightexpress.nightcore.util.text.tag.Tags.*;
Expand Down Expand Up @@ -140,6 +141,7 @@ public class CoreLang {
" "
);

@Deprecated
public static final LangText EDITOR_ACTION_EXIT = LangText.of("Editor.Action.Exit",
TAG_NO_PREFIX,
"",
Expand All @@ -151,9 +153,30 @@ public class CoreLang {
+ " to leave input mode."),
"");

public static final LangString DIALOG_HEADER = LangString.of("Dialog.Header",
LIGHT_YELLOW.enclose(GENERIC_TIME));

public static final LangString DIALOG_DEFAULT_PROMPT = LangString.of("Dialog.DefaultPrompt",
LIGHT_GRAY.enclose("Enter " + LIGHT_GREEN.enclose("[Value]")));

public static final LangText DIALOG_INFO_EXIT = LangText.of("Dialog.Info.Exit",
TAG_NO_PREFIX,
"",
GRAY.enclose("Click " +
CLICK.encloseRun(
HOVER.encloseHint(GREEN.enclose("[Here]"), GRAY.enclose("Click to cancel.")),
"/" + DialogManager.EXIT
)
+ " to leave input mode."),
"");

@Deprecated
public static final LangString EDITOR_INPUT_HEADER_MAIN = LangString.of("Editor.Input.Header.Main", GREEN.enclose(BOLD.enclose("Input Mode")));
@Deprecated
public static final LangString EDITOR_INPUT_HEADER_ERROR = LangString.of("Editor.Input.Header.Error", RED.enclose(BOLD.enclose("ERROR")));
@Deprecated
public static final LangString EDITOR_INPUT_ERROR_NOT_INTEGER = LangString.of("Editor.Input.Error.NotInteger", GRAY.enclose("Expecting " + RED.enclose("whole") + " number!"));
@Deprecated
public static final LangString EDITOR_INPUT_ERROR_GENERIC = LangString.of("Editor.Input.Error.Generic", GRAY.enclose("Invalid value!"));

public static final LangItem EDITOR_ITEM_CLOSE = LangItem.of("Editor.Generic.Close", LIGHT_RED.enclose(BOLD.enclose("Exit")));
Expand Down
19 changes: 17 additions & 2 deletions src/main/java/su/nightexpress/nightcore/core/CoreManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
import su.nightexpress.nightcore.manager.AbstractManager;
import su.nightexpress.nightcore.menu.MenuListener;
import su.nightexpress.nightcore.menu.impl.AbstractMenu;
import su.nightexpress.nightcore.ui.UIListener;
import su.nightexpress.nightcore.ui.dialog.DialogManager;
import su.nightexpress.nightcore.ui.menu.MenuRegistry;
import su.nightexpress.nightcore.ui.menu.MenuViewer;
import su.nightexpress.nightcore.util.TimeUtil;

import java.util.HashSet;

Expand All @@ -22,18 +27,21 @@ protected void onLoad() {
this.addListener(new CoreListener(this.plugin));
this.addListener(new DialogListener(this.plugin));
this.addListener(new MenuListener(this.plugin));
this.addListener(new UIListener(this.plugin));

this.addAsyncTask(this::tickDialogs, 1);
this.addTask(this::tickDialogs, 1);
this.addTask(this::tickMenus, 1);
}

@Override
protected void onShutdown() {

Dialog.shutdown();
DialogManager.shutdown();
}

private void tickDialogs() {
Dialog.checkTimeOut();
DialogManager.tickDialogs();
}

private void tickMenus() {
Expand All @@ -43,5 +51,12 @@ private void tickMenus() {
menu.getOptions().setLastAutoRefresh(System.currentTimeMillis());
}
});

MenuRegistry.getViewers().stream().map(MenuViewer::getMenu).distinct().forEach(menu -> {
if (menu.isReadyToRefresh()) {
menu.flush();
menu.setAutoRefreshDate(TimeUtil.createFutureTimestamp(menu.getAutoRefreshInterval()));
}
});
}
}
1 change: 1 addition & 0 deletions src/main/java/su/nightexpress/nightcore/dialog/Dialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static su.nightexpress.nightcore.util.text.tag.Tags.*;

@Deprecated
public class Dialog {

private static final Map<UUID, Dialog> DIALOG_MAP = new ConcurrentHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.jetbrains.annotations.NotNull;

@Deprecated
public interface DialogHandler {

boolean onInput(@NotNull Dialog dialog, @NotNull WrappedInput input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.util.HashSet;

@Deprecated
public class DialogListener extends AbstractListener<NightCore> {

public DialogListener(@NotNull NightCore plugin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import su.nightexpress.nightcore.util.wrapper.UniDouble;
import su.nightexpress.nightcore.util.wrapper.UniInt;

@Deprecated
public class WrappedInput {

private final String text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import su.nightexpress.nightcore.NightCorePlugin;
import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.ItemUtil;
import su.nightexpress.nightcore.util.bukkit.NightItem;
import su.nightexpress.nightcore.util.text.NightMessage;
import su.nightexpress.nightcore.util.text.TextRoot;
import su.nightexpress.nightcore.util.bukkit.NightItem;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -61,6 +61,7 @@ public void apply(@NotNull ItemStack item) {
});
}

@Deprecated
public void apply(@NotNull NightItem item) {
item.setDisplayName(this.localizedName);
item.setLore(this.localizedLore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import su.nightexpress.nightcore.menu.click.ClickResult;
import su.nightexpress.nightcore.menu.impl.AbstractMenu;

@Deprecated
public class MenuListener extends AbstractListener<NightCore> {

public MenuListener(@NotNull NightCore core) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.util.function.UnaryOperator;

@Deprecated
public class MenuOptions {

private String title;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/su/nightexpress/nightcore/menu/MenuSize.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package su.nightexpress.nightcore.menu;

@Deprecated
public enum MenuSize {

CHEST_9(9),
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/su/nightexpress/nightcore/menu/MenuViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.jetbrains.annotations.Nullable;
import su.nightexpress.nightcore.util.Version;

@Deprecated
public class MenuViewer {

private final Player player;
Expand All @@ -16,7 +17,7 @@ public class MenuViewer {
private int page;
private int pages;
private long lastClickTime;
private boolean updateTitle;
private boolean updateTitle;

public MenuViewer(@NotNull Player player) {
this.player = player;
Expand Down Expand Up @@ -47,7 +48,7 @@ public boolean canClickAgain(long cooldown) {

@NotNull
public Player getPlayer() {
return player;
return this.player;
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.List;
import java.util.function.Function;

@Deprecated
public class AutoFill<T> {

private int[] slots;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.ArrayList;
import java.util.List;

@Deprecated
public interface AutoFilled<I> extends Menu {

default boolean open(@NotNull Player player, int page) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/su/nightexpress/nightcore/menu/api/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.util.*;

@Deprecated
public interface Menu {

void clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.jetbrains.annotations.NotNull;
import su.nightexpress.nightcore.menu.MenuViewer;

@Deprecated
public interface ClickAction {

void onClick(@NotNull MenuViewer viewer, @NotNull InventoryClickEvent event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;

@Deprecated
public class ClickResult {

private final int slot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.bukkit.event.inventory.InventoryClickEvent;
import org.jetbrains.annotations.NotNull;

@Deprecated
public enum ClickType {

LEFT, RIGHT, SHIFT_LEFT, SHIFT_RIGHT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.util.*;

@Deprecated
public abstract class AbstractMenu<P extends NightCorePlugin> implements Menu {

public static final Map<UUID, Menu> PLAYER_MENUS = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
import su.nightexpress.nightcore.menu.item.ItemHandler;
import su.nightexpress.nightcore.menu.item.MenuItem;
import su.nightexpress.nightcore.util.*;
import su.nightexpress.nightcore.util.bukkit.NightItem;
import su.nightexpress.nightcore.util.text.NightMessage;
import su.nightexpress.nightcore.util.bukkit.NightItem;

import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;

@Deprecated
public abstract class ConfigMenu<P extends NightCorePlugin> extends AbstractMenu<P> {

protected static final String DEFAULT_ITEM_SECTION = "Content";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.util.function.Consumer;

@Deprecated
public abstract class EditorMenu<P extends NightCorePlugin, T> extends AbstractMenu<P> implements Linked<T> {

protected final ViewLink<T> link;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.UUID;
import java.util.function.Predicate;

@Deprecated
public class ItemHandler {

public static final String RETURN = "return";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.function.BiConsumer;
import java.util.function.Predicate;

@Deprecated
public class ItemOptions {

private Predicate<MenuViewer> visibilityPolicy;
Expand Down
Loading

0 comments on commit 2dae3ce

Please sign in to comment.