Compare commits
53 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d676be15ce | ||
|
|
16848caec1 | ||
|
|
ef26fe4629 | ||
|
|
29fbd785d7 | ||
|
|
8c73676ee0 | ||
|
|
ebf27d28d9 | ||
|
|
317bc13f65 | ||
|
|
b8ec0ee6fc | ||
|
|
307e57c902 | ||
|
|
db0d55659f | ||
|
|
548529feb3 | ||
|
|
fb56baf452 | ||
|
|
5d18b424d7 | ||
|
|
7be9a1bd10 | ||
|
|
97c39b56dd | ||
|
|
1e5955f249 | ||
|
|
bad076bbe9 | ||
|
|
e219b2f33c | ||
|
|
2f7603409e | ||
|
|
28cdb65176 | ||
|
|
2d074bc186 | ||
|
|
7e4422f6e2 | ||
|
|
5b29c90457 | ||
|
|
4ebc1a18a1 | ||
|
|
db20bed6e0 | ||
|
|
0826da6cfc | ||
|
|
6d8fce3462 | ||
|
|
eedb1404b6 | ||
|
|
299abe4568 | ||
|
|
98e1f19145 | ||
|
|
424e2ff43d | ||
|
|
3a899226a3 | ||
|
|
8336eee892 | ||
|
|
a48f756582 | ||
|
|
2aa463d083 | ||
|
|
ea833de9f7 | ||
|
|
3c0822310d | ||
|
|
d5cbc1d497 | ||
|
|
c912ad1c9c | ||
|
|
752f38ef25 | ||
|
|
a5525ab332 | ||
|
|
1b442f400d | ||
|
|
3c9c0bcef4 | ||
|
|
3a7a938e7f | ||
|
|
32c17aa3ae | ||
|
|
e451732876 | ||
|
|
53f81c0a03 | ||
|
|
f60d91c5f3 | ||
|
|
a9bdca56a5 | ||
|
|
3516d5881e | ||
|
|
95cecc2b2a | ||
|
|
f276026972 | ||
|
|
d2c6cc0d2e |
8
.github/workflows/java-ci.yml
vendored
8
.github/workflows/java-ci.yml
vendored
@@ -14,11 +14,11 @@ jobs:
|
|||||||
id: vars
|
id: vars
|
||||||
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
|
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
|
||||||
|
|
||||||
- name: Set up JDK 16
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v2
|
uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
distribution: 'adopt'
|
distribution: 'temurin'
|
||||||
java-version: 16
|
java-version: 17
|
||||||
|
|
||||||
- name: Setup build cache
|
- name: Setup build cache
|
||||||
uses: actions/cache@v2.1.6
|
uses: actions/cache@v2.1.6
|
||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-gradle-
|
${{ runner.os }}-gradle-
|
||||||
|
|
||||||
- run: ./gradlew build
|
- run: ./gradlew build --full-stacktrace
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
|
|||||||
6
.github/workflows/publish-release.yml
vendored
6
.github/workflows/publish-release.yml
vendored
@@ -12,11 +12,11 @@ jobs:
|
|||||||
- name: Checkout latest code
|
- name: Checkout latest code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set up JDK 16
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v2
|
uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
distribution: 'adopt'
|
distribution: 'temurin'
|
||||||
java-version: 16
|
java-version: 17
|
||||||
|
|
||||||
- name: Setup build cache
|
- name: Setup build cache
|
||||||
uses: actions/cache@v2.1.6
|
uses: actions/cache@v2.1.6
|
||||||
|
|||||||
@@ -21,4 +21,4 @@
|
|||||||
|
|
||||||
## Other
|
## Other
|
||||||
- All drops **must** be sent through a DropQueue - calls to World#dropItem will get your PR rejected.
|
- All drops **must** be sent through a DropQueue - calls to World#dropItem will get your PR rejected.
|
||||||
- eco is built with java 16.
|
- eco is built with java 17.
|
||||||
@@ -12,6 +12,7 @@ dependencies {
|
|||||||
implementation(project(":eco-core:core-backend"))
|
implementation(project(":eco-core:core-backend"))
|
||||||
implementation(project(":eco-core:core-nms:v1_16_R3"))
|
implementation(project(":eco-core:core-nms:v1_16_R3"))
|
||||||
implementation(project(path = ":eco-core:core-nms:v1_17_R1", configuration = "reobf"))
|
implementation(project(path = ":eco-core:core-nms:v1_17_R1", configuration = "reobf"))
|
||||||
|
implementation(project(":eco-core:core-nms:v1_18_R1"))
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
@@ -25,6 +26,9 @@ allprojects {
|
|||||||
mavenLocal()
|
mavenLocal()
|
||||||
maven("https://jitpack.io")
|
maven("https://jitpack.io")
|
||||||
|
|
||||||
|
// CustomCrafting
|
||||||
|
maven("https://maven.wolfyscript.com/repository/public/")
|
||||||
|
|
||||||
// SuperiorSkyblock2
|
// SuperiorSkyblock2
|
||||||
maven("https://repo.bg-software.com/repository/api/")
|
maven("https://repo.bg-software.com/repository/api/")
|
||||||
|
|
||||||
@@ -65,6 +69,11 @@ allprojects {
|
|||||||
// Test
|
// Test
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
|
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
|
||||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
|
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
|
||||||
|
|
||||||
|
// Adventure
|
||||||
|
compileOnly("net.kyori:adventure-api:4.9.3")
|
||||||
|
compileOnly("net.kyori:adventure-text-serializer-gson:4.9.3")
|
||||||
|
compileOnly("net.kyori:adventure-text-serializer-legacy:4.9.3")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<JavaCompile> {
|
tasks.withType<JavaCompile> {
|
||||||
@@ -93,8 +102,8 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
sourceCompatibility = JavaVersion.VERSION_16
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
targetCompatibility = JavaVersion.VERSION_16
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ dependencies {
|
|||||||
// Adventure
|
// Adventure
|
||||||
compileOnly 'net.kyori:adventure-platform-bukkit:4.0.0'
|
compileOnly 'net.kyori:adventure-platform-bukkit:4.0.0'
|
||||||
compileOnly 'net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT'
|
compileOnly 'net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT'
|
||||||
compileOnly 'net.kyori:adventure-api:4.9.2'
|
|
||||||
compileOnly 'net.kyori:adventure-text-serializer-gson:4.9.2'
|
|
||||||
compileOnly 'net.kyori:adventure-text-serializer-legacy:4.9.2'
|
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
|
||||||
|
|||||||
@@ -41,11 +41,19 @@ public class Prerequisite {
|
|||||||
"Requires server to have vault"
|
"Requires server to have vault"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requires the server to be running 1.18.
|
||||||
|
*/
|
||||||
|
public static final Prerequisite HAS_1_18 = new Prerequisite(
|
||||||
|
() -> ProxyConstants.NMS_VERSION.contains("18"),
|
||||||
|
"Requires server to be running 1.18+"
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires the server to be running 1.17.
|
* Requires the server to be running 1.17.
|
||||||
*/
|
*/
|
||||||
public static final Prerequisite HAS_1_17 = new Prerequisite(
|
public static final Prerequisite HAS_1_17 = new Prerequisite(
|
||||||
() -> ProxyConstants.NMS_VERSION.contains("17"),
|
() -> ProxyConstants.NMS_VERSION.contains("17") || HAS_1_18.isMet(),
|
||||||
"Requires server to be running 1.17+"
|
"Requires server to be running 1.17+"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -16,4 +16,40 @@ public class ConfigYml extends YamlBaseConfig {
|
|||||||
public ConfigYml(@NotNull final EcoPlugin plugin) {
|
public ConfigYml(@NotNull final EcoPlugin plugin) {
|
||||||
super("config", true, plugin);
|
super("config", true, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Config.yml.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin.
|
||||||
|
* @param removeUnused Remove unused.
|
||||||
|
*/
|
||||||
|
public ConfigYml(@NotNull final EcoPlugin plugin,
|
||||||
|
final boolean removeUnused) {
|
||||||
|
super("config", removeUnused, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Config.yml.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin.
|
||||||
|
* @param name The config name.
|
||||||
|
*/
|
||||||
|
public ConfigYml(@NotNull final EcoPlugin plugin,
|
||||||
|
@NotNull final String name) {
|
||||||
|
super(name, true, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Config.yml.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin.
|
||||||
|
* @param name The config name.
|
||||||
|
* @param removeUnused Remove unused.
|
||||||
|
*/
|
||||||
|
public ConfigYml(@NotNull final EcoPlugin plugin,
|
||||||
|
@NotNull final String name,
|
||||||
|
final boolean removeUnused) {
|
||||||
|
super(name, removeUnused, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -524,6 +524,25 @@ public interface Config extends Cloneable {
|
|||||||
@Nullable
|
@Nullable
|
||||||
List<Double> getDoublesOrNull(@NotNull String path);
|
List<Double> getDoublesOrNull(@NotNull String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of subsections from config.
|
||||||
|
*
|
||||||
|
* @param path The key to fetch the value from.
|
||||||
|
* @return The found value, or a blank {@link java.util.ArrayList} if not found.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
List<? extends Config> getSubsections(@NotNull String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of subsections from config.
|
||||||
|
*
|
||||||
|
* @param path The key to fetch the value from.
|
||||||
|
* @return The found value, or null if not found.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
List<? extends Config> getSubsectionsOrNull(@NotNull String path);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone the config.
|
* Clone the config.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -173,6 +173,16 @@ public abstract class ConfigWrapper<T extends Config> implements Config {
|
|||||||
return handle.getDoublesOrNull(path);
|
return handle.getDoublesOrNull(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull List<? extends Config> getSubsections(@NotNull final String path) {
|
||||||
|
return handle.getSubsections(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<? extends Config> getSubsectionsOrNull(@NotNull final String path) {
|
||||||
|
return handle.getSubsectionsOrNull(path);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Config clone() {
|
public Config clone() {
|
||||||
return handle.clone();
|
return handle.clone();
|
||||||
|
|||||||
@@ -14,16 +14,23 @@ import java.io.StringReader;
|
|||||||
*/
|
*/
|
||||||
public class YamlTransientConfig extends YamlConfigWrapper {
|
public class YamlTransientConfig extends YamlConfigWrapper {
|
||||||
/**
|
/**
|
||||||
* @param config The YamlConfiguration handle.
|
* @param config The YamlConfiguration handle.
|
||||||
*/
|
*/
|
||||||
public YamlTransientConfig(@NotNull final YamlConfiguration config) {
|
public YamlTransientConfig(@NotNull final YamlConfiguration config) {
|
||||||
super(Eco.getHandler().getConfigFactory().createYamlConfig(config));
|
super(Eco.getHandler().getConfigFactory().createYamlConfig(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param contents The contents of the config.
|
* @param contents The contents of the config.
|
||||||
*/
|
*/
|
||||||
public YamlTransientConfig(@NotNull final String contents) {
|
public YamlTransientConfig(@NotNull final String contents) {
|
||||||
super(Eco.getHandler().getConfigFactory().createYamlConfig(YamlConfiguration.loadConfiguration(new StringReader(contents))));
|
super(Eco.getHandler().getConfigFactory().createYamlConfig(YamlConfiguration.loadConfiguration(new StringReader(contents))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new empty transient config.
|
||||||
|
*/
|
||||||
|
public YamlTransientConfig() {
|
||||||
|
super(Eco.getHandler().getConfigFactory().createYamlConfig(YamlConfiguration.loadConfiguration(new StringReader(""))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,14 +70,14 @@ public interface FastItemStack {
|
|||||||
*
|
*
|
||||||
* @param hideFlags The flags.
|
* @param hideFlags The flags.
|
||||||
*/
|
*/
|
||||||
void addItemFlags(ItemFlag... hideFlags);
|
void addItemFlags(@NotNull ItemFlag... hideFlags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove ItemFlags.
|
* Remove ItemFlags.
|
||||||
*
|
*
|
||||||
* @param hideFlags The flags.
|
* @param hideFlags The flags.
|
||||||
*/
|
*/
|
||||||
void removeItemFlags(ItemFlag... hideFlags);
|
void removeItemFlags(@NotNull ItemFlag... hideFlags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the ItemFlags.
|
* Get the ItemFlags.
|
||||||
@@ -92,7 +92,7 @@ public interface FastItemStack {
|
|||||||
* @param flag The flag.
|
* @param flag The flag.
|
||||||
* @return If the flag is present.
|
* @return If the flag is present.
|
||||||
*/
|
*/
|
||||||
boolean hasItemFlag(ItemFlag flag);
|
boolean hasItemFlag(@NotNull ItemFlag flag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Bukkit ItemStack again.
|
* Get the Bukkit ItemStack again.
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public final class Items {
|
|||||||
/**
|
/**
|
||||||
* This is the backbone of the entire eco item system.
|
* This is the backbone of the entire eco item system.
|
||||||
* <p>
|
* <p>
|
||||||
* You can lookup a TestableItem for any material, custom item,
|
* You can look up a TestableItem for any material, custom item,
|
||||||
* or item in general, and it will return it with any modifiers
|
* or item in general, and it will return it with any modifiers
|
||||||
* passed as parameters. This includes stack size (item amount)
|
* passed as parameters. This includes stack size (item amount)
|
||||||
* and enchantments that should be present on the item.
|
* and enchantments that should be present on the item.
|
||||||
@@ -94,8 +94,8 @@ public final class Items {
|
|||||||
* <p>
|
* <p>
|
||||||
* The advantages of the testable item system are that there is the inbuilt
|
* The advantages of the testable item system are that there is the inbuilt
|
||||||
* {@link TestableItem#matches(ItemStack)} - this allows to check if any item
|
* {@link TestableItem#matches(ItemStack)} - this allows to check if any item
|
||||||
* is that testable item; which may sound negligible but actually it allows for
|
* is that testable item; which may sound negligible, but actually it allows for
|
||||||
* much more power an flexibility. For example, you can have an item with an
|
* much more power and flexibility. For example, you can have an item with an
|
||||||
* extra metadata tag, extra lore lines, different display name - and it
|
* extra metadata tag, extra lore lines, different display name - and it
|
||||||
* will still work as long as the test passes. This is very important
|
* will still work as long as the test passes. This is very important
|
||||||
* for custom crafting recipes where other plugins may add metadata
|
* for custom crafting recipes where other plugins may add metadata
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.willfp.eco.core.items.args;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse leather armor colors.
|
||||||
|
*
|
||||||
|
* @deprecated Moved to internals.
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
|
public class ColorArgParser implements LookupArgParser {
|
||||||
|
@Override
|
||||||
|
public @Nullable Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
||||||
|
@NotNull final ItemMeta meta) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,49 +9,14 @@ import java.util.function.Predicate;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse custom model data.
|
* Parse custom model data.
|
||||||
|
*
|
||||||
|
* @deprecated Moved to internals.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public class CustomModelDataArgParser implements LookupArgParser {
|
public class CustomModelDataArgParser implements LookupArgParser {
|
||||||
@Override
|
@Override
|
||||||
public @Nullable Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
public @Nullable Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
||||||
@NotNull final ItemMeta meta) {
|
@NotNull final ItemMeta meta) {
|
||||||
Integer modelData = null;
|
return null;
|
||||||
|
|
||||||
for (String arg : args) {
|
|
||||||
String[] argSplit = arg.split(":");
|
|
||||||
if (!argSplit[0].equalsIgnoreCase("custom-model-data")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argSplit.length < 2) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String asString = argSplit[1];
|
|
||||||
|
|
||||||
try {
|
|
||||||
modelData = Integer.parseInt(asString);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
modelData = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modelData == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
meta.setCustomModelData(modelData);
|
|
||||||
|
|
||||||
int finalModelData = modelData;
|
|
||||||
return test -> {
|
|
||||||
if (!test.hasItemMeta()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemMeta testMeta = test.getItemMeta();
|
|
||||||
|
|
||||||
assert testMeta != null;
|
|
||||||
|
|
||||||
return testMeta.getCustomModelData() == finalModelData;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,83 +1,22 @@
|
|||||||
package com.willfp.eco.core.items.args;
|
package com.willfp.eco.core.items.args;
|
||||||
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses enchantment arguments.
|
* Parses enchantment arguments.
|
||||||
|
*
|
||||||
|
* @deprecated Moved to internals.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public class EnchantmentArgParser implements LookupArgParser {
|
public class EnchantmentArgParser implements LookupArgParser {
|
||||||
@Override
|
@Override
|
||||||
public @Nullable Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
public @Nullable Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
||||||
@NotNull final ItemMeta meta) {
|
@NotNull final ItemMeta meta) {
|
||||||
Map<Enchantment, Integer> requiredEnchantments = new HashMap<>();
|
return null;
|
||||||
|
|
||||||
for (String enchantArg : args) {
|
|
||||||
String[] enchantArgSplit = enchantArg.split(":");
|
|
||||||
|
|
||||||
Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(enchantArgSplit[0].toLowerCase()));
|
|
||||||
if (enchantment == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enchantArgSplit.length < 2) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int level = Integer.parseInt(enchantArgSplit[1]);
|
|
||||||
|
|
||||||
requiredEnchantments.put(enchantment, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (requiredEnchantments.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (meta instanceof EnchantmentStorageMeta storageMeta) {
|
|
||||||
requiredEnchantments.forEach((enchantment, integer) -> storageMeta.addStoredEnchant(enchantment, integer, true));
|
|
||||||
} else {
|
|
||||||
requiredEnchantments.forEach((enchantment, integer) -> meta.addEnchant(enchantment, integer, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
return test -> {
|
|
||||||
if (!test.hasItemMeta()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemMeta testMeta = test.getItemMeta();
|
|
||||||
|
|
||||||
assert testMeta != null;
|
|
||||||
|
|
||||||
if (testMeta instanceof EnchantmentStorageMeta storageMeta) {
|
|
||||||
for (Map.Entry<Enchantment, Integer> entry : requiredEnchantments.entrySet()) {
|
|
||||||
if (!storageMeta.hasStoredEnchant(entry.getKey())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (storageMeta.getStoredEnchantLevel(entry.getKey()) < entry.getValue()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (Map.Entry<Enchantment, Integer> entry : requiredEnchantments.entrySet()) {
|
|
||||||
if (!testMeta.hasEnchant(entry.getKey())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (testMeta.getEnchantLevel(entry.getKey()) < entry.getValue()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package com.willfp.eco.core.items.args;
|
package com.willfp.eco.core.items.args;
|
||||||
|
|
||||||
import com.willfp.eco.util.SkullUtils;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -11,49 +9,14 @@ import java.util.function.Predicate;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse skull textures.
|
* Parse skull textures.
|
||||||
|
*
|
||||||
|
* @deprecated Moved to internals.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public class TextureArgParser implements LookupArgParser {
|
public class TextureArgParser implements LookupArgParser {
|
||||||
@Override
|
@Override
|
||||||
public @Nullable Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
public @Nullable Predicate<ItemStack> parseArguments(@NotNull final String[] args,
|
||||||
@NotNull final ItemMeta meta) {
|
@NotNull final ItemMeta meta) {
|
||||||
String skullTexture = null;
|
return null;
|
||||||
|
|
||||||
for (String arg : args) {
|
|
||||||
String[] argSplit = arg.split(":");
|
|
||||||
if (!argSplit[0].equalsIgnoreCase("texture")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argSplit.length < 2) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
skullTexture = argSplit[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (meta instanceof SkullMeta skullMeta && skullTexture != null) {
|
|
||||||
SkullUtils.setSkullTexture(skullMeta, skullTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skullTexture == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String finalSkullTexture = skullTexture;
|
|
||||||
return test -> {
|
|
||||||
if (!test.hasItemMeta()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemMeta testMeta = test.getItemMeta();
|
|
||||||
|
|
||||||
assert testMeta != null;
|
|
||||||
|
|
||||||
if (testMeta instanceof SkullMeta skullMeta) {
|
|
||||||
return finalSkullTexture.equalsIgnoreCase(SkullUtils.getSkullTexture(skullMeta));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.willfp.eco.core.recipe.recipes;
|
|||||||
import com.willfp.eco.core.Eco;
|
import com.willfp.eco.core.Eco;
|
||||||
import com.willfp.eco.core.EcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.eco.core.PluginDependent;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
|
import com.willfp.eco.core.Prerequisite;
|
||||||
import com.willfp.eco.core.items.TestableItem;
|
import com.willfp.eco.core.items.TestableItem;
|
||||||
import com.willfp.eco.core.recipe.Recipes;
|
import com.willfp.eco.core.recipe.Recipes;
|
||||||
import com.willfp.eco.core.recipe.parts.EmptyTestableItem;
|
import com.willfp.eco.core.recipe.parts.EmptyTestableItem;
|
||||||
@@ -112,6 +113,12 @@ public final class ShapedCraftingRecipe extends PluginDependent<EcoPlugin> imple
|
|||||||
displayedRecipe.setIngredient(character, new RecipeChoice.ExactChoice(item));
|
displayedRecipe.setIngredient(character, new RecipeChoice.ExactChoice(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Prerequisite.HAS_1_18.isMet() && !Prerequisite.HAS_PAPER.isMet()) {
|
||||||
|
if (Bukkit.getServer().getRecipe(this.getKey()) != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Bukkit.getServer().addRecipe(shapedRecipe);
|
Bukkit.getServer().addRecipe(shapedRecipe);
|
||||||
Bukkit.getServer().addRecipe(displayedRecipe);
|
Bukkit.getServer().addRecipe(displayedRecipe);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.willfp.eco.util;
|
package com.willfp.eco.util;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -21,8 +20,8 @@ public final class ListUtils {
|
|||||||
* @return The list, filled will null objects.
|
* @return The list, filled will null objects.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static <@Nullable T> List<List<T>> create2DList(final int rows,
|
public static <T> List<List<T>> create2DList(final int rows,
|
||||||
final int columns) {
|
final int columns) {
|
||||||
List<List<T>> list = new ArrayList<>(rows);
|
List<List<T>> list = new ArrayList<>(rows);
|
||||||
while (list.size() < rows) {
|
while (list.size() < rows) {
|
||||||
List<T> row = new ArrayList<>(columns);
|
List<T> row = new ArrayList<>(columns);
|
||||||
|
|||||||
@@ -82,13 +82,12 @@ public final class PlayerUtils {
|
|||||||
* @return The player name.
|
* @return The player name.
|
||||||
*/
|
*/
|
||||||
public static String getSavedDisplayName(@NotNull final OfflinePlayer player) {
|
public static String getSavedDisplayName(@NotNull final OfflinePlayer player) {
|
||||||
PlayerProfile profile = PlayerProfile.load(player);
|
|
||||||
|
|
||||||
if (player instanceof Player onlinePlayer) {
|
if (player instanceof Player onlinePlayer) {
|
||||||
profile.write(PLAYER_NAME_KEY, onlinePlayer.getDisplayName());
|
updateSavedDisplayName(onlinePlayer);
|
||||||
return onlinePlayer.getDisplayName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayerProfile profile = PlayerProfile.load(player);
|
||||||
|
|
||||||
String saved = profile.read(PLAYER_NAME_KEY);
|
String saved = profile.read(PLAYER_NAME_KEY);
|
||||||
|
|
||||||
if (saved.equals(PLAYER_NAME_KEY.getDefaultValue())) {
|
if (saved.equals(PLAYER_NAME_KEY.getDefaultValue())) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,14 +16,14 @@ subprojects {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly project(":eco-api")
|
compileOnly project(":eco-api")
|
||||||
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.5.31'
|
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.6.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileKotlin {
|
compileKotlin {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "16"
|
jvmTarget = "17"
|
||||||
}
|
}
|
||||||
targetCompatibility = JavaVersion.VERSION_16
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
sourceCompatibility = JavaVersion.VERSION_16
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,12 +5,11 @@ import com.willfp.eco.util.StringUtils
|
|||||||
import org.bukkit.configuration.ConfigurationSection
|
import org.bukkit.configuration.ConfigurationSection
|
||||||
import org.bukkit.configuration.file.YamlConfiguration
|
import org.bukkit.configuration.file.YamlConfiguration
|
||||||
import java.io.StringReader
|
import java.io.StringReader
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
open class EcoYamlConfigWrapper<T : ConfigurationSection> : Config {
|
open class EcoYamlConfigWrapper<T : ConfigurationSection> : Config {
|
||||||
lateinit var handle: T
|
lateinit var handle: T
|
||||||
private val cache = ConcurrentHashMap<String, Any?>()
|
private val cache = mutableMapOf<String, Any?>()
|
||||||
|
|
||||||
protected fun init(config: T): Config {
|
protected fun init(config: T): Config {
|
||||||
handle = config
|
handle = config
|
||||||
@@ -70,9 +69,9 @@ open class EcoYamlConfigWrapper<T : ConfigurationSection> : Config {
|
|||||||
|
|
||||||
override fun getInt(path: String): Int {
|
override fun getInt(path: String): Int {
|
||||||
return if (cache.containsKey(path)) {
|
return if (cache.containsKey(path)) {
|
||||||
cache[path] as Int
|
(cache[path] as Number).toInt()
|
||||||
} else {
|
} else {
|
||||||
cache[path] = handle.getInt(path, 0)
|
cache[path] = handle.getDouble(path, 0.0).toInt()
|
||||||
getInt(path)
|
getInt(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,9 +89,9 @@ open class EcoYamlConfigWrapper<T : ConfigurationSection> : Config {
|
|||||||
def: Int
|
def: Int
|
||||||
): Int {
|
): Int {
|
||||||
return if (cache.containsKey(path)) {
|
return if (cache.containsKey(path)) {
|
||||||
cache[path] as Int
|
(cache[path] as Number).toInt()
|
||||||
} else {
|
} else {
|
||||||
cache[path] = handle.getInt(path, def)
|
cache[path] = handle.getDouble(path, def.toDouble()).toInt()
|
||||||
getInt(path)
|
getInt(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,6 +261,31 @@ open class EcoYamlConfigWrapper<T : ConfigurationSection> : Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getSubsections(path: String): MutableList<out Config> {
|
||||||
|
return if (cache.containsKey(path)) {
|
||||||
|
(cache[path] as Collection<Config>).toMutableList()
|
||||||
|
} else {
|
||||||
|
val mapList = ArrayList(handle.getMapList(path)) as List<Map<String, Any?>>
|
||||||
|
val configList = mutableListOf<Config>()
|
||||||
|
for (map in mapList) {
|
||||||
|
val temp = YamlConfiguration.loadConfiguration(StringReader(""))
|
||||||
|
temp.createSection("a", map)
|
||||||
|
configList.add(EcoYamlConfigSection(temp.getConfigurationSection("a")!!))
|
||||||
|
}
|
||||||
|
|
||||||
|
cache[path] = if (has(path)) configList else emptyList()
|
||||||
|
getSubsections(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getSubsectionsOrNull(path: String): MutableList<out Config>? {
|
||||||
|
return if (has(path)) {
|
||||||
|
getSubsections(path)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun clone(): Config {
|
override fun clone(): Config {
|
||||||
return EcoYamlConfigSection(
|
return EcoYamlConfigSection(
|
||||||
YamlConfiguration.loadConfiguration(
|
YamlConfiguration.loadConfiguration(
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.willfp.eco.internal.items
|
||||||
|
|
||||||
|
import com.willfp.eco.core.items.args.LookupArgParser
|
||||||
|
import org.bukkit.Color
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta
|
||||||
|
import org.bukkit.inventory.meta.LeatherArmorMeta
|
||||||
|
import java.util.function.Predicate
|
||||||
|
|
||||||
|
class ArgParserColor : LookupArgParser {
|
||||||
|
override fun parseArguments(args: Array<out String>, meta: ItemMeta): Predicate<ItemStack>? {
|
||||||
|
if (meta !is LeatherArmorMeta) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
var color: String? = null
|
||||||
|
|
||||||
|
for (arg in args) {
|
||||||
|
val argSplit = arg.split(":")
|
||||||
|
if (!argSplit[0].equals("color", ignoreCase = true)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (argSplit.size < 2) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
color = argSplit[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
color ?: return null
|
||||||
|
|
||||||
|
meta.setColor(Color.fromRGB(Integer.parseInt(color, 16)))
|
||||||
|
|
||||||
|
return Predicate {
|
||||||
|
val testMeta = it.itemMeta as? LeatherArmorMeta ?: return@Predicate false
|
||||||
|
|
||||||
|
color.equals(
|
||||||
|
Integer.toHexString(testMeta.color.red)
|
||||||
|
+ Integer.toHexString(testMeta.color.green)
|
||||||
|
+ Integer.toHexString(testMeta.color.blue),
|
||||||
|
ignoreCase = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.willfp.eco.internal.items
|
||||||
|
|
||||||
|
import com.willfp.eco.core.items.args.LookupArgParser
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta
|
||||||
|
import java.util.function.Predicate
|
||||||
|
|
||||||
|
class ArgParserCustomModelData : LookupArgParser {
|
||||||
|
override fun parseArguments(args: Array<out String>, meta: ItemMeta): Predicate<ItemStack>? {
|
||||||
|
var modelData: Int? = null
|
||||||
|
|
||||||
|
for (arg in args) {
|
||||||
|
val argSplit = arg.split(":")
|
||||||
|
if (!argSplit[0].equals("custom-model-data", ignoreCase = true)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (argSplit.size < 2) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
modelData = argSplit[1].toIntOrNull()
|
||||||
|
}
|
||||||
|
|
||||||
|
modelData ?: return null
|
||||||
|
|
||||||
|
meta.setCustomModelData(modelData)
|
||||||
|
|
||||||
|
return Predicate {
|
||||||
|
val testMeta = it.itemMeta ?: return@Predicate false
|
||||||
|
|
||||||
|
testMeta.customModelData == modelData
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.willfp.eco.internal.items
|
||||||
|
|
||||||
|
import com.willfp.eco.core.fast.FastItemStack
|
||||||
|
import com.willfp.eco.core.items.args.LookupArgParser
|
||||||
|
import org.bukkit.NamespacedKey
|
||||||
|
import org.bukkit.enchantments.Enchantment
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.inventory.meta.EnchantmentStorageMeta
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta
|
||||||
|
import java.util.function.Predicate
|
||||||
|
|
||||||
|
class ArgParserEnchantment : LookupArgParser {
|
||||||
|
override fun parseArguments(args: Array<out String>, meta: ItemMeta): Predicate<ItemStack>? {
|
||||||
|
val enchants = mutableMapOf<Enchantment, Int>()
|
||||||
|
|
||||||
|
for (arg in args) {
|
||||||
|
val argSplit = arg.split(":")
|
||||||
|
|
||||||
|
if (argSplit.size < 2) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
val enchant = Enchantment.getByKey(NamespacedKey.minecraft(argSplit[0].lowercase()))
|
||||||
|
val level = argSplit[1].toIntOrNull()
|
||||||
|
|
||||||
|
if (enchant != null && level != null) {
|
||||||
|
enchants[enchant] = level
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ((enchant, level) in enchants) {
|
||||||
|
if (meta is EnchantmentStorageMeta) {
|
||||||
|
meta.addStoredEnchant(enchant, level, true)
|
||||||
|
} else {
|
||||||
|
meta.addEnchant(enchant, level, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Predicate {
|
||||||
|
val onItem = FastItemStack.wrap(it).getEnchantmentsOnItem(true)
|
||||||
|
|
||||||
|
for ((enchant, level) in enchants) {
|
||||||
|
if ((onItem[enchant] ?: 0) < level) {
|
||||||
|
return@Predicate false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.willfp.eco.internal.items
|
||||||
|
|
||||||
|
import com.willfp.eco.core.items.args.LookupArgParser
|
||||||
|
import org.bukkit.inventory.ItemFlag
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta
|
||||||
|
import java.util.function.Predicate
|
||||||
|
|
||||||
|
class ArgParserFlag : LookupArgParser {
|
||||||
|
override fun parseArguments(args: Array<out String>, meta: ItemMeta): Predicate<ItemStack>? {
|
||||||
|
val flags = mutableSetOf<ItemFlag>()
|
||||||
|
|
||||||
|
for (arg in args) {
|
||||||
|
val flag = try {
|
||||||
|
ItemFlag.valueOf(arg.uppercase())
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
} ?: continue
|
||||||
|
|
||||||
|
flags.add(flag)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags.isEmpty()) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
meta.addItemFlags(*flags.toTypedArray())
|
||||||
|
|
||||||
|
return Predicate {
|
||||||
|
val testMeta = it.itemMeta ?: return@Predicate false
|
||||||
|
|
||||||
|
testMeta.itemFlags.containsAll(flags)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.willfp.eco.internal.items
|
||||||
|
|
||||||
|
import com.willfp.eco.core.items.args.LookupArgParser
|
||||||
|
import com.willfp.eco.util.StringUtils
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta
|
||||||
|
import java.util.function.Predicate
|
||||||
|
|
||||||
|
class ArgParserName : LookupArgParser {
|
||||||
|
override fun parseArguments(args: Array<out String>, meta: ItemMeta): Predicate<ItemStack>? {
|
||||||
|
var name: String? = null
|
||||||
|
|
||||||
|
for (arg in args) {
|
||||||
|
val argSplit = arg.split(":")
|
||||||
|
if (!argSplit[0].equals("name", ignoreCase = true)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (argSplit.size < 2) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
name = argSplit[1].replace("_", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
name ?: return null
|
||||||
|
|
||||||
|
val formatted = StringUtils.format(name)
|
||||||
|
|
||||||
|
meta.setDisplayName(formatted)
|
||||||
|
|
||||||
|
return Predicate {
|
||||||
|
val testMeta = it.itemMeta ?: return@Predicate false
|
||||||
|
|
||||||
|
testMeta.displayName == formatted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.willfp.eco.internal.items
|
||||||
|
|
||||||
|
import com.willfp.eco.core.items.args.LookupArgParser
|
||||||
|
import com.willfp.eco.util.SkullUtils
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta
|
||||||
|
import java.util.function.Predicate
|
||||||
|
|
||||||
|
class ArgParserTexture : LookupArgParser {
|
||||||
|
override fun parseArguments(args: Array<out String>, meta: ItemMeta): Predicate<ItemStack>? {
|
||||||
|
if (meta !is SkullMeta) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
var texture: String? = null
|
||||||
|
|
||||||
|
for (arg in args) {
|
||||||
|
val argSplit = arg.split(":")
|
||||||
|
if (!argSplit[0].equals("texture", ignoreCase = true)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (argSplit.size < 2) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
texture = argSplit[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
texture ?: return null
|
||||||
|
|
||||||
|
SkullUtils.setSkullTexture(meta, texture)
|
||||||
|
|
||||||
|
return Predicate {
|
||||||
|
val testMeta = it.itemMeta as? SkullMeta ?: return@Predicate false
|
||||||
|
|
||||||
|
texture == SkullUtils.getSkullTexture(testMeta)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.willfp.eco.internal.items
|
||||||
|
|
||||||
|
import com.willfp.eco.core.items.args.LookupArgParser
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta
|
||||||
|
import java.util.function.Predicate
|
||||||
|
|
||||||
|
class ArgParserUnbreakable : LookupArgParser {
|
||||||
|
override fun parseArguments(args: Array<out String>, meta: ItemMeta): Predicate<ItemStack>? {
|
||||||
|
var unbreakable = false
|
||||||
|
|
||||||
|
for (arg in args) {
|
||||||
|
if (arg.equals("unbreakable", true)) {
|
||||||
|
unbreakable = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!unbreakable) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
meta.isUnbreakable = true
|
||||||
|
|
||||||
|
return Predicate {
|
||||||
|
val testMeta = it.itemMeta ?: return@Predicate false
|
||||||
|
|
||||||
|
testMeta.isUnbreakable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -74,7 +74,8 @@ class EcoProxyFactory(
|
|||||||
companion object {
|
companion object {
|
||||||
val SUPPORTED_VERSIONS = listOf(
|
val SUPPORTED_VERSIONS = listOf(
|
||||||
"v1_16_R3",
|
"v1_16_R3",
|
||||||
"v1_17_R1"
|
"v1_17_R1",
|
||||||
|
"v1_18_R1"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ class RequirementPlaceholderGreaterThan : Requirement() {
|
|||||||
|
|
||||||
val placeholder = args[0]
|
val placeholder = args[0]
|
||||||
val equals = args[1].toDoubleOrNull() ?: return false
|
val equals = args[1].toDoubleOrNull() ?: return false
|
||||||
return PlaceholderManager.translatePlaceholders(placeholder, player).toDoubleOrNull() ?: 0.0 >= equals
|
return (PlaceholderManager.translatePlaceholders(placeholder, player).toDoubleOrNull() ?: 0.0) >= equals
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,6 @@ class RequirementPlaceholderLessThan : Requirement() {
|
|||||||
|
|
||||||
val placeholder = args[0]
|
val placeholder = args[0]
|
||||||
val equals = args[1].toDoubleOrNull() ?: return false
|
val equals = args[1].toDoubleOrNull() ?: return false
|
||||||
return PlaceholderManager.translatePlaceholders(placeholder, player).toDoubleOrNull() ?: 0.0 < equals
|
return (PlaceholderManager.translatePlaceholders(placeholder, player).toDoubleOrNull() ?: 0.0) < equals
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
group 'com.willfp'
|
|
||||||
version rootProject.version
|
|
||||||
|
|
||||||
subprojects {
|
|
||||||
dependencies {
|
|
||||||
compileOnly project(':eco-core:core-proxy')
|
|
||||||
compileOnly project(':eco-core:core-plugin')
|
|
||||||
compileOnly project(':eco-core:core-backend')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
12
eco-core/core-nms/build.gradle.kts
Normal file
12
eco-core/core-nms/build.gradle.kts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
group = "com.willfp"
|
||||||
|
version = rootProject.version
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
dependencies {
|
||||||
|
compileOnly(project(":eco-core:core-proxy"))
|
||||||
|
compileOnly(project(":eco-core:core-plugin"))
|
||||||
|
compileOnly(project(":eco-core:core-backend"))
|
||||||
|
// libraries.minecraft.net machine broke
|
||||||
|
compileOnly("com.github.Mojang:brigadier:1.0.18")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,4 @@ version rootProject.version
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'org.spigotmc:spigot:1.16.5-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot:1.16.5-R0.1-SNAPSHOT'
|
||||||
compileOnly 'net.kyori:adventure-api:4.9.1'
|
|
||||||
compileOnly 'net.kyori:adventure-text-serializer-gson:4.8.1'
|
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,7 @@ class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemS
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
return handle.tag?.hashCode() ?: 0b00010101 * 31 + Item.getId(handle.item)
|
return handle.tag?.hashCode() ?: (0b00010101 * 31 + Item.getId(handle.item))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun apply() {
|
private fun apply() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("io.papermc.paperweight.userdev") version "1.1.14"
|
id("io.papermc.paperweight.userdev") version "1.2.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.willfp"
|
group = "com.willfp"
|
||||||
@@ -7,8 +7,6 @@ version = rootProject.version
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
paperDevBundle("1.17.1-R0.1-SNAPSHOT")
|
paperDevBundle("1.17.1-R0.1-SNAPSHOT")
|
||||||
compileOnly("net.kyori:adventure-api:4.9.1")
|
|
||||||
compileOnly("net.kyori:adventure-text-serializer-gson:4.8.1")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemS
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
return handle.tag?.hashCode() ?: 0b00010101 * 31 + Item.getId(handle.item)
|
return handle.tag?.hashCode() ?: (0b00010101 * 31 + Item.getId(handle.item))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun apply() {
|
private fun apply() {
|
||||||
|
|||||||
6
eco-core/core-nms/v1_18_R1/build.gradle.kts
Normal file
6
eco-core/core-nms/v1_18_R1/build.gradle.kts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
group = "com.willfp"
|
||||||
|
version = rootProject.version
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(files("./impl.jar"))
|
||||||
|
}
|
||||||
BIN
eco-core/core-nms/v1_18_R1/impl.jar
Normal file
BIN
eco-core/core-nms/v1_18_R1/impl.jar
Normal file
Binary file not shown.
@@ -7,9 +7,6 @@ dependencies {
|
|||||||
exclude group: 'net.kyori', module: 'adventure-api'
|
exclude group: 'net.kyori', module: 'adventure-api'
|
||||||
}
|
}
|
||||||
compileOnly 'net.kyori:adventure-platform-bukkit:4.0.0'
|
compileOnly 'net.kyori:adventure-platform-bukkit:4.0.0'
|
||||||
compileOnly 'net.kyori:adventure-api:4.9.2'
|
|
||||||
compileOnly 'net.kyori:adventure-text-serializer-gson:4.9.2'
|
|
||||||
compileOnly 'net.kyori:adventure-text-serializer-legacy:4.9.2'
|
|
||||||
compileOnly 'org.apache.maven:maven-artifact:3.8.1'
|
compileOnly 'org.apache.maven:maven-artifact:3.8.1'
|
||||||
compileOnly 'com.google.code.gson:gson:2.8.8'
|
compileOnly 'com.google.code.gson:gson:2.8.8'
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
|
||||||
@@ -42,6 +39,7 @@ dependencies {
|
|||||||
compileOnly 'com.google.guava:guava:31.0.1-jre'
|
compileOnly 'com.google.guava:guava:31.0.1-jre'
|
||||||
compileOnly 'com.iridium:IridiumSkyblock:3.1.2'
|
compileOnly 'com.iridium:IridiumSkyblock:3.1.2'
|
||||||
compileOnly 'com.github.WillFP:CrashClaim:1.0.19'
|
compileOnly 'com.github.WillFP:CrashClaim:1.0.19'
|
||||||
|
compileOnly 'com.wolfyscript.wolfyutilities:wolfyutilities:1.7.8.1'
|
||||||
|
|
||||||
// CombatLogX V10 + NewbieHelper Expansion
|
// CombatLogX V10 + NewbieHelper Expansion
|
||||||
compileOnly 'com.SirBlobman.combatlogx:CombatLogX-API:10.0.0.0-SNAPSHOT'
|
compileOnly 'com.SirBlobman.combatlogx:CombatLogX-API:10.0.0.0-SNAPSHOT'
|
||||||
|
|||||||
@@ -15,17 +15,22 @@ import com.willfp.eco.core.integrations.hologram.HologramManager
|
|||||||
import com.willfp.eco.core.integrations.mcmmo.McmmoManager
|
import com.willfp.eco.core.integrations.mcmmo.McmmoManager
|
||||||
import com.willfp.eco.core.integrations.shop.ShopManager
|
import com.willfp.eco.core.integrations.shop.ShopManager
|
||||||
import com.willfp.eco.core.items.Items
|
import com.willfp.eco.core.items.Items
|
||||||
import com.willfp.eco.core.items.args.CustomModelDataArgParser
|
|
||||||
import com.willfp.eco.core.items.args.EnchantmentArgParser
|
|
||||||
import com.willfp.eco.core.items.args.TextureArgParser
|
|
||||||
import com.willfp.eco.internal.display.EcoDisplayHandler
|
import com.willfp.eco.internal.display.EcoDisplayHandler
|
||||||
import com.willfp.eco.internal.drops.DropManager
|
import com.willfp.eco.internal.drops.DropManager
|
||||||
|
import com.willfp.eco.internal.items.ArgParserColor
|
||||||
|
import com.willfp.eco.internal.items.ArgParserCustomModelData
|
||||||
|
import com.willfp.eco.internal.items.ArgParserEnchantment
|
||||||
|
import com.willfp.eco.internal.items.ArgParserFlag
|
||||||
|
import com.willfp.eco.internal.items.ArgParserName
|
||||||
|
import com.willfp.eco.internal.items.ArgParserTexture
|
||||||
|
import com.willfp.eco.internal.items.ArgParserUnbreakable
|
||||||
import com.willfp.eco.internal.spigot.arrows.ArrowDataListener
|
import com.willfp.eco.internal.spigot.arrows.ArrowDataListener
|
||||||
import com.willfp.eco.internal.spigot.data.DataListener
|
import com.willfp.eco.internal.spigot.data.DataListener
|
||||||
import com.willfp.eco.internal.spigot.data.PlayerBlockListener
|
import com.willfp.eco.internal.spigot.data.PlayerBlockListener
|
||||||
import com.willfp.eco.internal.spigot.data.storage.ProfileSaver
|
import com.willfp.eco.internal.spigot.data.storage.ProfileSaver
|
||||||
import com.willfp.eco.internal.spigot.display.PacketAutoRecipe
|
import com.willfp.eco.internal.spigot.display.PacketAutoRecipe
|
||||||
import com.willfp.eco.internal.spigot.display.PacketChat
|
import com.willfp.eco.internal.spigot.display.PacketChat
|
||||||
|
import com.willfp.eco.internal.spigot.display.PacketHeldWindowItems
|
||||||
import com.willfp.eco.internal.spigot.display.PacketOpenWindowMerchant
|
import com.willfp.eco.internal.spigot.display.PacketOpenWindowMerchant
|
||||||
import com.willfp.eco.internal.spigot.display.PacketSetCreativeSlot
|
import com.willfp.eco.internal.spigot.display.PacketSetCreativeSlot
|
||||||
import com.willfp.eco.internal.spigot.display.PacketSetSlot
|
import com.willfp.eco.internal.spigot.display.PacketSetSlot
|
||||||
@@ -90,9 +95,13 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
|||||||
"&a"
|
"&a"
|
||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
Items.registerArgParser(EnchantmentArgParser())
|
Items.registerArgParser(ArgParserEnchantment())
|
||||||
Items.registerArgParser(TextureArgParser())
|
Items.registerArgParser(ArgParserColor())
|
||||||
Items.registerArgParser(CustomModelDataArgParser())
|
Items.registerArgParser(ArgParserTexture())
|
||||||
|
Items.registerArgParser(ArgParserCustomModelData())
|
||||||
|
Items.registerArgParser(ArgParserFlag())
|
||||||
|
Items.registerArgParser(ArgParserUnbreakable())
|
||||||
|
Items.registerArgParser(ArgParserName())
|
||||||
|
|
||||||
val skullProxy = getProxy(SkullProxy::class.java)
|
val skullProxy = getProxy(SkullProxy::class.java)
|
||||||
SkullUtils.initialize(
|
SkullUtils.initialize(
|
||||||
@@ -240,6 +249,7 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
|||||||
PacketSetCreativeSlot(this),
|
PacketSetCreativeSlot(this),
|
||||||
PacketSetSlot(this),
|
PacketSetSlot(this),
|
||||||
PacketWindowItems(this),
|
PacketWindowItems(this),
|
||||||
|
PacketHeldWindowItems(this),
|
||||||
PacketOpenWindowMerchant(this)
|
PacketOpenWindowMerchant(this)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -254,7 +264,7 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
|||||||
GUIListener(this),
|
GUIListener(this),
|
||||||
ArrowDataListener(this),
|
ArrowDataListener(this),
|
||||||
ArmorChangeEventListeners(this),
|
ArmorChangeEventListeners(this),
|
||||||
DataListener(),
|
DataListener(this),
|
||||||
PlayerBlockListener(this)
|
PlayerBlockListener(this)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.willfp.eco.internal.spigot.data
|
package com.willfp.eco.internal.spigot.data
|
||||||
|
|
||||||
import com.willfp.eco.core.Eco
|
import com.willfp.eco.core.Eco
|
||||||
|
import com.willfp.eco.core.EcoPlugin
|
||||||
import com.willfp.eco.util.PlayerUtils
|
import com.willfp.eco.util.PlayerUtils
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
import org.bukkit.event.Listener
|
import org.bukkit.event.Listener
|
||||||
@@ -8,16 +9,19 @@ import org.bukkit.event.player.PlayerJoinEvent
|
|||||||
import org.bukkit.event.player.PlayerLoginEvent
|
import org.bukkit.event.player.PlayerLoginEvent
|
||||||
import org.bukkit.event.player.PlayerQuitEvent
|
import org.bukkit.event.player.PlayerQuitEvent
|
||||||
|
|
||||||
class DataListener : Listener {
|
class DataListener(
|
||||||
|
private val plugin: EcoPlugin
|
||||||
|
) : Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
fun onLeave(event: PlayerQuitEvent) {
|
fun onLeave(event: PlayerQuitEvent) {
|
||||||
PlayerUtils.updateSavedDisplayName(event.player)
|
|
||||||
Eco.getHandler().playerProfileHandler.unloadPlayer(event.player.uniqueId)
|
Eco.getHandler().playerProfileHandler.unloadPlayer(event.player.uniqueId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
fun onJoin(event: PlayerJoinEvent) {
|
fun onJoin(event: PlayerJoinEvent) {
|
||||||
PlayerUtils.updateSavedDisplayName(event.player)
|
plugin.scheduler.runLater({
|
||||||
|
PlayerUtils.updateSavedDisplayName(event.player)
|
||||||
|
}, 5)
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.jetbrains.exposed.sql.select
|
|||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
import org.jetbrains.exposed.sql.update
|
import org.jetbrains.exposed.sql.update
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
import java.util.concurrent.Callable
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
@@ -114,13 +115,21 @@ class MySQLDataHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun <T> read(uuid: UUID, key: NamespacedKey): T? {
|
override fun <T> read(uuid: UUID, key: NamespacedKey): T? {
|
||||||
var value: T? = null
|
val doRead = Callable<T?> {
|
||||||
transaction {
|
var value: T? = null
|
||||||
val player = getPlayer(uuid)
|
transaction {
|
||||||
value = player[getColumn(key.toString())] as T?
|
val player = getPlayer(uuid)
|
||||||
|
value = player[getColumn(key.toString())] as T?
|
||||||
|
}
|
||||||
|
|
||||||
|
return@Callable value
|
||||||
}
|
}
|
||||||
|
|
||||||
return value
|
return if (Eco.getHandler().ecoPlugin.configYml.getBool("mysql.async-reads")) {
|
||||||
|
executor.submit(doRead).get()
|
||||||
|
} else {
|
||||||
|
doRead.call()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object Players : UUIDTable("eco_players")
|
object Players : UUIDTable("eco_players")
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.willfp.eco.internal.spigot.display
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType
|
||||||
|
import com.comphenix.protocol.events.PacketContainer
|
||||||
|
import com.comphenix.protocol.events.PacketEvent
|
||||||
|
import com.willfp.eco.core.AbstractPacketAdapter
|
||||||
|
import com.willfp.eco.core.EcoPlugin
|
||||||
|
import com.willfp.eco.core.Prerequisite
|
||||||
|
import com.willfp.eco.core.display.Display
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
|
||||||
|
class PacketHeldWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, PacketType.Play.Server.WINDOW_ITEMS, false) {
|
||||||
|
override fun onSend(
|
||||||
|
packet: PacketContainer,
|
||||||
|
player: Player,
|
||||||
|
event: PacketEvent
|
||||||
|
) {
|
||||||
|
if (!Prerequisite.HAS_1_17.isMet) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
packet.itemModifier.modify(0) { item: ItemStack? ->
|
||||||
|
Display.display(
|
||||||
|
item!!, player
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,14 +2,15 @@ package com.willfp.eco.internal.spigot.integrations.antigrief
|
|||||||
|
|
||||||
import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI
|
import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI
|
||||||
import com.bgsoftware.superiorskyblock.api.enums.HitActionResult
|
import com.bgsoftware.superiorskyblock.api.enums.HitActionResult
|
||||||
|
import com.bgsoftware.superiorskyblock.api.island.Island
|
||||||
import com.bgsoftware.superiorskyblock.api.island.IslandPrivilege
|
import com.bgsoftware.superiorskyblock.api.island.IslandPrivilege
|
||||||
|
import com.bgsoftware.superiorskyblock.api.key.Key
|
||||||
|
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer
|
||||||
import com.willfp.eco.core.integrations.antigrief.AntigriefWrapper
|
import com.willfp.eco.core.integrations.antigrief.AntigriefWrapper
|
||||||
import org.bukkit.Location
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.Material
|
||||||
import org.bukkit.block.Block
|
import org.bukkit.block.Block
|
||||||
import org.bukkit.entity.Animals
|
import org.bukkit.entity.*
|
||||||
import org.bukkit.entity.LivingEntity
|
|
||||||
import org.bukkit.entity.Monster
|
|
||||||
import org.bukkit.entity.Player
|
|
||||||
|
|
||||||
class AntigriefSuperiorSkyblock2 : AntigriefWrapper {
|
class AntigriefSuperiorSkyblock2 : AntigriefWrapper {
|
||||||
override fun getPluginName(): String {
|
override fun getPluginName(): String {
|
||||||
@@ -17,11 +18,42 @@ class AntigriefSuperiorSkyblock2 : AntigriefWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun canBreakBlock(player: Player, block: Block): Boolean {
|
override fun canBreakBlock(player: Player, block: Block): Boolean {
|
||||||
if (SuperiorSkyblockAPI.getPlayer(player).hasBypassModeEnabled()) {
|
val island: Island? =
|
||||||
|
SuperiorSkyblockAPI.getIslandAt(block.location)
|
||||||
|
|
||||||
|
val superiorPlayer: SuperiorPlayer =
|
||||||
|
SuperiorSkyblockAPI.getPlayer(player)
|
||||||
|
|
||||||
|
if (island == null) {
|
||||||
|
if (!superiorPlayer.hasBypassModeEnabled() && SuperiorSkyblockAPI.getSuperiorSkyblock().grid
|
||||||
|
.isIslandsWorld(player.world)
|
||||||
|
) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("Break"))
|
|
||||||
|| SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("BREAK"))
|
val blockType = block.type
|
||||||
|
|
||||||
|
val islandPermission: IslandPrivilege =
|
||||||
|
if (blockType == Material.SPAWNER) IslandPrivilege.getByName("SPAWNER_BREAK") else IslandPrivilege.getByName("BREAK")
|
||||||
|
|
||||||
|
if (!island.hasPermission(superiorPlayer, islandPermission)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SuperiorSkyblockAPI.getSuperiorSkyblock().settings.valuableBlocks
|
||||||
|
.contains(Key.of(block)) &&
|
||||||
|
!island.hasPermission(superiorPlayer, IslandPrivilege.getByName("VALUABLE_BREAK"))
|
||||||
|
) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!island.isInsideRange(block.location)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun canCreateExplosion(player: Player, location: Location): Boolean {
|
override fun canCreateExplosion(player: Player, location: Location): Boolean {
|
||||||
@@ -32,11 +64,29 @@ class AntigriefSuperiorSkyblock2 : AntigriefWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun canPlaceBlock(player: Player, block: Block): Boolean {
|
override fun canPlaceBlock(player: Player, block: Block): Boolean {
|
||||||
if (SuperiorSkyblockAPI.getPlayer(player).hasBypassModeEnabled()) {
|
val island: Island? =
|
||||||
|
SuperiorSkyblockAPI.getIslandAt(block.location)
|
||||||
|
|
||||||
|
val superiorPlayer: SuperiorPlayer =
|
||||||
|
SuperiorSkyblockAPI.getPlayer(player)
|
||||||
|
|
||||||
|
if (island == null) {
|
||||||
|
if (!superiorPlayer.hasBypassModeEnabled() && SuperiorSkyblockAPI.getSuperiorSkyblock().grid.isIslandsWorld(superiorPlayer.world)
|
||||||
|
) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("Place"))
|
|
||||||
|| SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("PLACE"))
|
if (!island.hasPermission(superiorPlayer, IslandPrivilege.getByName("BUILD"))) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!island.isInsideRange(block.location)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun canInjure(player: Player, victim: LivingEntity): Boolean {
|
override fun canInjure(player: Player, victim: LivingEntity): Boolean {
|
||||||
@@ -45,13 +95,14 @@ class AntigriefSuperiorSkyblock2 : AntigriefWrapper {
|
|||||||
}
|
}
|
||||||
return when (victim) {
|
return when (victim) {
|
||||||
is Player -> SuperiorSkyblockAPI.getPlayer(player).canHit(SuperiorSkyblockAPI.getPlayer(victim)).equals(HitActionResult.SUCCESS)
|
is Player -> SuperiorSkyblockAPI.getPlayer(player).canHit(SuperiorSkyblockAPI.getPlayer(victim)).equals(HitActionResult.SUCCESS)
|
||||||
is Animals -> {
|
else -> {
|
||||||
return SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("ANIMAL_DAMAGE"))
|
val island: Island? = SuperiorSkyblockAPI.getSuperiorSkyblock().grid.getIslandAt(victim.location)
|
||||||
|
val islandPermission = if (victim is Monster) IslandPrivilege.getByName("MONSTER_DAMAGE") else IslandPrivilege.getByName("ANIMAL_DAMAGE")
|
||||||
|
if (island != null ) {
|
||||||
|
return island.hasPermission(player, islandPermission)
|
||||||
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
is Monster -> {
|
|
||||||
return SuperiorSkyblockAPI.getPlayer(player).hasPermission(IslandPrivilege.getByName("MONSTER_DAMAGE"))
|
|
||||||
}
|
|
||||||
else -> true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,8 @@ mysql:
|
|||||||
# very high numbers can cause issues with OS configuration. If writes are taking
|
# very high numbers can cause issues with OS configuration. If writes are taking
|
||||||
# too long, increase this value.
|
# too long, increase this value.
|
||||||
threads: 2
|
threads: 2
|
||||||
|
# If read operations should be ran in the thread pool. Runs on main thread by default.
|
||||||
|
async-reads: false
|
||||||
host: localhost
|
host: localhost
|
||||||
port: 3306
|
port: 3306
|
||||||
database: database
|
database: database
|
||||||
|
|||||||
@@ -41,12 +41,11 @@ softdepend:
|
|||||||
libraries:
|
libraries:
|
||||||
- 'org.reflections:reflections:0.9.12'
|
- 'org.reflections:reflections:0.9.12'
|
||||||
- 'org.apache.maven:maven-artifact:3.0.3'
|
- 'org.apache.maven:maven-artifact:3.0.3'
|
||||||
- 'org.jetbrains.kotlin:kotlin-stdlib:1.5.31'
|
- 'org.jetbrains.kotlin:kotlin-stdlib:1.6.0'
|
||||||
- 'net.kyori:adventure-platform-bukkit:4.0.0'
|
- 'net.kyori:adventure-platform-bukkit:4.0.0'
|
||||||
- 'net.kyori:adventure-api:4.9.2'
|
- 'net.kyori:adventure-api:4.9.3'
|
||||||
- 'net.kyori:adventure-text-serializer-gson:4.9.2'
|
- 'net.kyori:adventure-text-serializer-gson:4.9.3'
|
||||||
- 'net.kyori:adventure-text-serializer-legacy:4.9.2'
|
- 'net.kyori:adventure-text-serializer-legacy:4.9.3'
|
||||||
- 'org.jetbrains.kotlin:kotlin-stdlib:1.5.21'
|
|
||||||
- 'org.jetbrains.exposed:exposed-core:0.36.2'
|
- 'org.jetbrains.exposed:exposed-core:0.36.2'
|
||||||
- 'org.jetbrains.exposed:exposed-dao:0.36.2'
|
- 'org.jetbrains.exposed:exposed-dao:0.36.2'
|
||||||
- 'org.jetbrains.exposed:exposed-jdbc:0.36.2'
|
- 'org.jetbrains.exposed:exposed-jdbc:0.36.2'
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
version = 6.13.13
|
version = 6.15.2
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
|
kotlin.code.style = official
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
jdk: openjdk16
|
jdk: openjdk17
|
||||||
before_install:
|
before_install:
|
||||||
- source "$HOME/.sdkman/bin/sdkman-init.sh"
|
- source "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||||
- sdk update
|
- sdk update
|
||||||
- sdk install java 16.0.1-open
|
- sdk install java 17.0.1-tem
|
||||||
- sdk use java 16.0.1-open
|
- sdk use java 17.0.1-tem
|
||||||
@@ -13,6 +13,7 @@ include(":eco-core")
|
|||||||
include(":eco-core:core-nms")
|
include(":eco-core:core-nms")
|
||||||
include(":eco-core:core-nms:v1_16_R3")
|
include(":eco-core:core-nms:v1_16_R3")
|
||||||
include(":eco-core:core-nms:v1_17_R1")
|
include(":eco-core:core-nms:v1_17_R1")
|
||||||
|
include(":eco-core:core-nms:v1_18_R1")
|
||||||
include(":eco-core:core-proxy")
|
include(":eco-core:core-proxy")
|
||||||
include(":eco-core:core-plugin")
|
include(":eco-core:core-plugin")
|
||||||
include(":eco-core:core-backend")
|
include(":eco-core:core-backend")
|
||||||
Reference in New Issue
Block a user