Skip to content

Commit

Permalink
Bring develop up to date
Browse files Browse the repository at this point in the history
  • Loading branch information
0ft3n committed Jan 8, 2024
2 parents 9e583f1 + 4464d3b commit 747e702
Show file tree
Hide file tree
Showing 97 changed files with 1,726 additions and 315 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ cd eco

## License

eco is licensed under GNU GPL3. *Click here to read [the entire license](https://github.com/Auxilor/eco/blob/master/LICENSE.md).*
eco is licensed under the MIT license. *Click here to read [the entire license](https://github.com/Auxilor/eco/blob/master/LICENSE.md).*

<h1 align="center">
Check out our partners!
Expand Down
25 changes: 14 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
}

dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.21")
}
}

Expand All @@ -13,7 +13,7 @@ plugins {
id("com.github.johnrengelman.shadow") version "8.1.1"
id("maven-publish")
id("java")
kotlin("jvm") version "1.7.10"
kotlin("jvm") version "1.9.21"
}

dependencies {
Expand All @@ -29,6 +29,7 @@ dependencies {
implementation(project(path = ":eco-core:core-nms:v1_19_R3", configuration = "reobf"))
implementation(project(path = ":eco-core:core-nms:v1_20_R1", configuration = "reobf"))
implementation(project(path = ":eco-core:core-nms:v1_20_R2", configuration = "reobf"))
implementation(project(path = ":eco-core:core-nms:v1_20_R3", configuration = "reobf"))
}

allprojects {
Expand All @@ -41,11 +42,9 @@ allprojects {
repositories {
mavenCentral()
mavenLocal()
maven("https://repo.auxilor.io/repository/maven-public/")
maven("https://jitpack.io")

// CustomCrafting
maven("https://maven.wolfyscript.com/repository/public/")

// SuperiorSkyblock2
maven("https://repo.bg-software.com/repository/api/")

Expand Down Expand Up @@ -87,20 +86,23 @@ allprojects {

// Denizen
maven("https://maven.citizensnpcs.co/repo")

// IridiumSkyblock
maven("https://nexus.iridiumdevelopment.net/repository/maven-releases/")
}

dependencies {
// Kotlin
implementation(kotlin("stdlib", version = "1.7.10"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.2")
implementation(kotlin("stdlib", version = "1.9.21"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")

// Included in spigot jar, no need to move to implementation
compileOnly("org.jetbrains:annotations:23.0.0")
compileOnly("com.google.guava:guava:31.1-jre")

// Test
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")

// Adventure
implementation("net.kyori:adventure-api:4.10.1")
Expand All @@ -110,8 +112,8 @@ allprojects {
implementation("net.kyori:adventure-text-serializer-legacy:4.10.1")

// Other
implementation("com.github.ben-manes.caffeine:caffeine:3.1.0")
implementation("org.apache.maven:maven-artifact:3.8.5")
implementation("com.github.ben-manes.caffeine:caffeine:3.1.5")
implementation("org.apache.maven:maven-artifact:3.9.0")
}

tasks.withType<JavaCompile> {
Expand Down Expand Up @@ -169,6 +171,7 @@ allprojects {
relocate("org.reactivestreams", "com.willfp.eco.libs.reactivestreams")
relocate("reactor.", "com.willfp.eco.libs.reactor.") // Dot in name to be safe
relocate("com.moandjiezana.toml", "com.willfp.eco.libs.toml")
relocate("com.willfp.modelenginebridge", "com.willfp.eco.libs.modelenginebridge")

/*
Kotlin and caffeine are not shaded so that they can be accessed directly by eco plugins.
Expand Down
3 changes: 2 additions & 1 deletion eco-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ dependencies {
compileOnly("net.kyori:adventure-platform-bukkit:4.1.0")

// Other
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
compileOnly("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT")
compileOnly("commons-lang:commons-lang:2.6")
compileOnly("com.comphenix.protocol:ProtocolLib:4.6.1-SNAPSHOT")
compileOnly("com.google.code.gson:gson:2.8.8")
}
Expand Down
15 changes: 15 additions & 0 deletions eco-api/src/main/java/com/willfp/eco/core/Eco.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
import com.willfp.eco.core.proxy.ProxyFactory;
import com.willfp.eco.core.scheduling.Scheduler;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Mob;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -587,6 +589,19 @@ String getPlaceholderValue(@Nullable EcoPlugin plugin,
@NotNull String args,
@NotNull PlaceholderContext context);

/**
* Set a client-side entity display name.
*
* @param entity The entity.
* @param player The player.
* @param name The display name.
* @param visible If the display name should be forcibly visible.
*/
void setClientsideDisplayName(@NotNull LivingEntity entity,
@NotNull Player player,
@NotNull Component name,
boolean visible);

/**
* Get the instance of eco; the bridge between the api frontend and the implementation backend.
*
Expand Down
2 changes: 1 addition & 1 deletion eco-api/src/main/java/com/willfp/eco/core/PluginProps.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public final class PluginProps {
private final Map<String, String> environment = new HashMap<>();

/**
* If the plugin uses reflective reload (via {@link com.willfp.eco.core.config.updating.ConfigUpdater}).
* If the plugin uses reflective reload.
*/
private boolean usesReflectiveReload = true;

Expand Down
8 changes: 8 additions & 0 deletions eco-api/src/main/java/com/willfp/eco/core/Prerequisite.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public class Prerequisite {
"Requires server to have ProtocolLib"
);

/**
* Requires the server to be running 1.20.3.
*/
public static final Prerequisite HAS_1_20_3 = new Prerequisite(
() -> ProxyConstants.NMS_VERSION.contains("20_R3"),
"Requires server to be running 1.20.3+"
);

/**
* Requires the server to be running 1.20.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ public interface LoadableConfig extends Config {
*/
void save() throws IOException;

/**
* Save the config asynchronously.
*/
default void saveAsync() {
// This default implementation exists purely for backwards compatibility
// with legacy Config implementations that don't have saveAsync().
// Default eco implementations of Config have saveAsync() implemented.
new Thread(() -> {
try {
this.save();
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}

/**
* Get the config file.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@
* <p>
* By having a plugin as a parameter, you shouldn't really need getInstance()
* calls in your code.
*
* <p>
* While flexible, this can lead to long initialization times, so this feature
* can be disabled in eco.yml with the uses-reflective-reload option.
*
* @deprecated This has been deprecated due to the poor control flow and long startup times.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
@Deprecated(since = "6.67.0", forRemoval = true)
@SuppressWarnings("DeprecatedIsStillUsed")
public @interface ConfigUpdater {
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ public final class PersistentDataKey<T> {
/**
* If the key uses local storage.
*/
private final boolean local;
private final boolean isLocal;

/**
* Create a new Persistent Data Key.
*
* @param key The key.
* @param type The data type.
* @param defaultValue The default value.
* @param local If the key uses local storage.
* @param isLocal If the key uses local storage.
*/
public PersistentDataKey(@NotNull final NamespacedKey key,
@NotNull final PersistentDataKeyType<T> type,
@NotNull final T defaultValue,
final boolean local) {
final boolean isLocal) {
this.key = key;
this.defaultValue = defaultValue;
this.type = type;
this.local = local;
this.isLocal = isLocal;

Eco.get().registerPersistentKey(this);
}
Expand All @@ -67,7 +67,7 @@ public PersistentDataKey(@NotNull final NamespacedKey key,
this.key = key;
this.defaultValue = defaultValue;
this.type = type;
this.local = false;
this.isLocal = false;

Eco.get().registerPersistentKey(this);
}
Expand Down Expand Up @@ -108,7 +108,14 @@ public PersistentDataKeyType<T> getType() {
return this.type;
}

public boolean isLocalStorage() { return this.local; }
/**
* Get if the key uses local storage.
*
* @return If the key uses local storage.
*/
public boolean isLocal() {
return this.isLocal;
}

/**
* Get all persistent data keys.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ default SlotBuilder setCaptive() {
* @deprecated Use {@link SlotBuilder#setUpdater(SlotUpdater)} instead.
*/
@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
default SlotBuilder setModifier(@NotNull SlotModifier modifier) {
return setUpdater((player, menu, previous) -> {
modifier.modify(player, menu, previous);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public static String getResult(@Nullable final EcoPlugin plugin,
*/
@Deprecated(since = "6.56.0", forRemoval = true)
@NotNull
@SuppressWarnings("DeprecatedIsStillUsed")
public static String translatePlaceholders(@NotNull final String text,
@Nullable final Player player) {
return translatePlaceholders(text, player, EMPTY_INJECTABLE);
Expand All @@ -166,6 +167,7 @@ public static String translatePlaceholders(@NotNull final String text,
*/
@Deprecated(since = "6.56.0", forRemoval = true)
@NotNull
@SuppressWarnings("DeprecatedIsStillUsed")
public static String translatePlaceholders(@NotNull final String text,
@Nullable final Player player,
@NotNull final PlaceholderInjectable context) {
Expand All @@ -192,6 +194,7 @@ public static String translatePlaceholders(@NotNull final String text,
*/
@Deprecated(since = "6.56.0", forRemoval = true)
@NotNull
@SuppressWarnings("DeprecatedIsStillUsed")
public static String translatePlaceholders(@NotNull final String text,
@Nullable final Player player,
@NotNull final PlaceholderInjectable context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ public String getDisplay(@NotNull final Player player) {
*/
public String getDisplay(@NotNull final Player player,
final double multiplier) {
double value = this.getPrice().getValue(player, multiplier);

return StringUtils.format(
formatString.replace("%value%", NumberUtils.format(this.getPrice().getValue(player, multiplier))),
formatString
.replace("%value%", NumberUtils.format(value))
.replace("%value_commas%", NumberUtils.formatWithCommas(value)),
player,
StringUtils.FormatOption.WITH_PLACEHOLDERS
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public final class ProxyConstants {
"v1_19_R2",
"v1_19_R3",
"v1_20_R1",
"v1_20_R2"
"v1_20_R2",
"v1_20_R3"
);

private ProxyConstants() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.willfp.eco.core.web;

import com.willfp.eco.core.EcoPlugin;
import org.bukkit.util.Consumer;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Scanner;
import java.util.function.Consumer;

/**
* Class to check for updates of a plugin on spigot.
Expand Down
31 changes: 31 additions & 0 deletions eco-api/src/main/java/com/willfp/eco/util/EntityUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.willfp.eco.util;

import com.willfp.eco.core.Eco;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

/**
* Utilities / API methods for entities.
*/
public final class EntityUtils {
/**
* Set a client-side entity display name.
*
* @param entity The entity.
* @param player The player.
* @param name The display name.
* @param visible If the display name should be forcibly visible.
*/
public static void setClientsideDisplayName(@NotNull final LivingEntity entity,
@NotNull final Player player,
@NotNull final Component name,
final boolean visible) {
Eco.get().setClientsideDisplayName(entity, player, name, visible);
}

private EntityUtils() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}
14 changes: 14 additions & 0 deletions eco-api/src/main/java/com/willfp/eco/util/NumberUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,20 @@ public static String format(final double toFormat) {
return formatted.endsWith("00") ? String.valueOf((int) toFormat) : formatted;
}

/**
* Format double to string with commas.
*
* @param toFormat The number to format.
* @return Formatted.
*/
@NotNull
public static String formatWithCommas(final double toFormat) {
DecimalFormat df = new DecimalFormat("#,##0.00");
String formatted = df.format(toFormat);

return formatted.endsWith(".00") ? formatted.substring(0, formatted.length() - 3) : formatted;
}

/**
* Evaluate an expression.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public final class PatternUtils {
* Cache of compiled literal patterns.
*/
private static final Cache<String, Pattern> LITERAL_PATTERN_CACHE = Caffeine.newBuilder()
.expireAfterAccess(1, TimeUnit.MINUTES)
.expireAfterAccess(15, TimeUnit.MINUTES)
.build();

/**
Expand Down
1 change: 1 addition & 0 deletions eco-api/src/main/java/com/willfp/eco/util/PotionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public final class PotionUtils {
* @param data The data.
* @return The duration.
*/
@SuppressWarnings("deprecation")
public static int getDuration(@NotNull final PotionData data) {
if (data.isExtended()) {
return switch (data.getType()) {
Expand Down
Loading

0 comments on commit 747e702

Please sign in to comment.