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

Commit

Permalink
v2.2.12 + 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Sep 28, 2023
1 parent 2a67d3a commit a424516
Show file tree
Hide file tree
Showing 54 changed files with 480 additions and 3,799 deletions.
11 changes: 8 additions & 3 deletions NexEngine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<parent>
<artifactId>NexEnginePlugin</artifactId>
<groupId>su.nexmedia</groupId>
<version>2.2.11</version>
<version>2.2.12</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>NexEngine</artifactId>

<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<repositories>
Expand Down Expand Up @@ -59,6 +59,11 @@
<artifactId>sqlite-jdbc</artifactId>
<version>3.41.2.2</version>
</dependency>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>8.5.11</version>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
Expand Down
34 changes: 0 additions & 34 deletions NexEngine/src/main/java/org/jetbrains/annotations/Range.java

This file was deleted.

2 changes: 2 additions & 0 deletions NexEngine/src/main/java/su/nexmedia/engine/NexEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import su.nexmedia.engine.lang.EngineLang;
import su.nexmedia.engine.utils.EngineUtils;
import su.nexmedia.engine.utils.Placeholders;
import su.nexmedia.engine.utils.blocktracker.PlayerBlockTracker;

import java.util.HashSet;
import java.util.Set;
Expand Down Expand Up @@ -49,6 +50,7 @@ public void disable() {
if (this.menuRefreshTask != null) this.menuRefreshTask.stop();

if (EngineUtils.hasVault()) VaultHook.shutdown();
PlayerBlockTracker.shutdown();
}

@Override
Expand Down
1 change: 1 addition & 0 deletions NexEngine/src/main/java/su/nexmedia/engine/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum Version {
@Deprecated V1_19_R2("1.19.3", true),
V1_19_R3("1.19.4"),
V1_20_R1("1.20.1"),
V1_20_R2("1.20.2"),
UNKNOWN("Unknown", true),
// API-Version in plugin.yml won't allow to load this on lower version, so
// assume any other version not listed here is newer one.
Expand Down
19 changes: 12 additions & 7 deletions NexEngine/src/main/java/su/nexmedia/engine/api/config/JOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.nexmedia.engine.api.particle.SimpleParticle;
import su.nexmedia.engine.utils.TriFunction;
import su.nexmedia.engine.utils.values.UniParticle;
import su.nexmedia.engine.utils.values.UniSound;

import java.util.*;
import java.util.function.Function;
Expand Down Expand Up @@ -82,15 +83,19 @@ public static JOption<ItemStack> create(@NotNull String path, @NotNull ItemStack
}

@NotNull
public static <E extends Enum<E>> JOption<E> create(@NotNull String path, @NotNull Class<E> clazz, @NotNull E defaultValue, @Nullable String... description) {
return new JOption<>(path, ((cfg, path1, def) -> cfg.getEnum(path1, clazz, defaultValue)), defaultValue, description)
.setWriter((cfg, path1, type) -> cfg.set(path1, type.name()));
public static JOption<UniSound> create(@NotNull String path, @NotNull UniSound defaultValue, @Nullable String... description) {
return new JOption<>(path, (cfg, path1, def) -> UniSound.read(cfg, path1), defaultValue, description).setWriter((cfg, path2, us) -> us.write(cfg, path2));
}

@NotNull
public static JOption<SimpleParticle> create(@NotNull String path, @NotNull SimpleParticle defaulValue, @Nullable String... description) {
return new JOption<>(path, (cfg, path1, def) -> SimpleParticle.read(cfg, path1), defaulValue, description)
.setWriter((cfg, path1, particle) -> particle.write(cfg, path1));
public static JOption<UniParticle> create(@NotNull String path, @NotNull UniParticle defaultValue, @Nullable String... description) {
return new JOption<>(path, (cfg, path1, def) -> UniParticle.read(cfg, path1), defaultValue, description).setWriter((cfg, path2, us) -> us.write(cfg, path2));
}

@NotNull
public static <E extends Enum<E>> JOption<E> create(@NotNull String path, @NotNull Class<E> clazz, @NotNull E defaultValue, @Nullable String... description) {
return new JOption<>(path, ((cfg, path1, def) -> cfg.getEnum(path1, clazz, defaultValue)), defaultValue, description)
.setWriter((cfg, path1, type) -> cfg.set(path1, type.name()));
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ protected void onLoad() {
this.synchronizationTask.start();
this.plugin.info("Enabled data synchronization with " + config.syncInterval + " seconds interval.");
}
else {
this.plugin.warn("Data synchronization is useless for local databases (SQLite). It will be disabled.");
}
}

if (this.getConfig().purgeEnabled && this.getConfig().purgePeriod > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void onUnload() {
}

@SuppressWarnings("unchecked")
@Deprecated
public <U extends AbstractUser<P>> void saveData(@NotNull UserDataHolder<P, U> dataHolder) {
this.plugin.runTaskAsync(task -> dataHolder.getData().saveUser((U) this));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

import java.sql.ResultSet;
import java.time.LocalDateTime;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.function.Function;

public abstract class AbstractUserDataHandler<P extends NexPlugin<P>, U extends AbstractUser<P>> extends AbstractDataHandler<P> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ public final void unloadUser(@NotNull UUID uuid) {

public void unloadUser(@NotNull U user) {
user.onUnload();
user.saveData(this.dataHolder);
this.saveUser(user);
}

public void saveUser(@NotNull U user) {
this.plugin.runTaskAsync(task -> this.dataHolder.getData().saveUser(user));
}

@NotNull
Expand Down Expand Up @@ -178,13 +182,13 @@ public PlayerListener(@NotNull P plugin) {
}

@EventHandler(priority = EventPriority.MONITOR)
public void onUserLogin(AsyncPlayerPreLoginEvent e) {
if (e.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) return;
public void onUserLogin(AsyncPlayerPreLoginEvent event) {
if (event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) return;

UUID uuid = e.getUniqueId();
UUID uuid = event.getUniqueId();
U user;
if (!dataHolder.getData().isUserExists(uuid)) {
user = createData(uuid, e.getName());
user = createData(uuid, event.getName());
user.setRecentlyCreated(true);
cache(user);
dataHolder.getData().addUser(user);
Expand All @@ -196,13 +200,13 @@ public void onUserLogin(AsyncPlayerPreLoginEvent e) {
}

if (user == null) {
e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Unable to load your user data.");
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Unable to load your user data.");
}
}

@EventHandler(priority = EventPriority.MONITOR)
public void onUserQuit(PlayerQuitEvent e) {
unloadUser(e.getPlayer());
public void onUserQuit(PlayerQuitEvent event) {
unloadUser(event.getPlayer());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package su.nexmedia.engine.api.editor;

import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.lang.LangColors;

import java.util.ArrayList;
import java.util.List;

public class EditorLocales implements LangColors {
import static su.nexmedia.engine.utils.Colors.*;

public class EditorLocales {

public static final EditorLocale CLOSE = EditorLocale.of("Editor.Generic.Close", "#FF5733(✕) &lExit");
public static final EditorLocale RETURN = EditorLocale.of("Editor.Generic.Return", "#ffee9a(↓) &fReturn");
Expand Down Expand Up @@ -37,7 +38,7 @@ public EditorLocale build() {

@NotNull
public Builder name(@NotNull String name) {
this.name = YELLOW + "&l" + name;
this.name = YELLOW + BOLD + name;
return this;
}

Expand All @@ -53,7 +54,7 @@ public Builder textRaw(@NotNull String... text) {

@NotNull
public Builder currentHeader() {
return this.addLore(YELLOW + "&l", "Current:");
return this.addLore(YELLOW + BOLD, "Current:");
}

@NotNull
Expand All @@ -63,7 +64,7 @@ public Builder current(@NotNull String type, @NotNull String value) {

@NotNull
public Builder warningHeader() {
return this.addLore(RED + "&l", "Warning:");
return this.addLore(RED + BOLD, "Warning:");
}

@NotNull
Expand All @@ -73,7 +74,7 @@ public Builder warning(@NotNull String... info) {

@NotNull
public Builder noteHeader() {
return this.addLore(ORANGE + "&l", "Notes:");
return this.addLore(ORANGE + BOLD, "Notes:");
}

@NotNull
Expand All @@ -83,7 +84,7 @@ public Builder notes(@NotNull String... info) {

@NotNull
public Builder actionsHeader() {
return this.addLore(GREEN + "&l", "Actions:");
return this.addLore(GREEN + BOLD, "Actions:");
}

@NotNull
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class LangKey {

private final String path;
private final String defaultText;
// TODO int version ?

public LangKey(@NotNull String path, @NotNull String defaultText) {
this.path = path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.NexPlugin;
import su.nexmedia.engine.api.placeholder.PlaceholderMap;
import su.nexmedia.engine.utils.*;
import su.nexmedia.engine.utils.Colorizer;
import su.nexmedia.engine.utils.Placeholders;
import su.nexmedia.engine.utils.PlayerUtil;
import su.nexmedia.engine.utils.StringUtil;
import su.nexmedia.engine.utils.message.NexParser;
import su.nexmedia.engine.utils.regex.RegexUtil;
import su.nexmedia.engine.utils.values.UniSound;

import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
Expand Down Expand Up @@ -175,7 +182,7 @@ public void send(@NotNull CommandSender sender) {
if (this.isEmpty()) return;

if (this.sound != null && sender instanceof Player player) {
PlayerUtil.sound(player, this.sound);
UniSound.of(this.sound).play(player);
}

if (this.type == LangMessage.OutputType.CHAT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.NexPlugin;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.utils.StringUtil;

import java.io.File;

public abstract class AbstractConfigHolder<P extends NexPlugin<P>> implements ConfigHolder {
public abstract class AbstractConfigHolder<P extends NexPlugin<P>> {

protected final P plugin;
protected final JYML cfg;
Expand All @@ -17,7 +18,7 @@ public AbstractConfigHolder(@NotNull P plugin, @NotNull String filePath) {
}

public AbstractConfigHolder(@NotNull P plugin, @NotNull JYML cfg) {
this(plugin, cfg, cfg.getFile().getName().replace(".yml", "").toLowerCase());
this(plugin, cfg, cfg.getFile().getName().replace(".yml", ""));
}

public AbstractConfigHolder(@NotNull P plugin, @NotNull String filePath, @NotNull String id) {
Expand All @@ -27,15 +28,27 @@ public AbstractConfigHolder(@NotNull P plugin, @NotNull String filePath, @NotNul
public AbstractConfigHolder(@NotNull P plugin, @NotNull JYML cfg, @NotNull String id) {
this.plugin = plugin;
this.cfg = cfg;
this.id = id.toLowerCase().replace(" ", "_");
this.id = StringUtil.lowerCaseUnderscore(id);
}

public abstract boolean load();

protected abstract void onSave();

public boolean reload() {
return this.getConfig().reload() && this.load();
}

public void save() {
this.onSave();
this.getConfig().save();
}

@NotNull
public File getFile() {
return this.getConfig().getFile();
}

@NotNull
public P plugin() {
return this.plugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.NexPlugin;

public class AbstractListener<P extends NexPlugin<P>> implements EventListener {
public abstract class AbstractListener<P extends NexPlugin<P>> implements EventListener {

@NotNull
public final P plugin;
Expand Down
Loading

0 comments on commit a424516

Please sign in to comment.