Skip to content

Commit

Permalink
Add a few of patches
Browse files Browse the repository at this point in the history
  • Loading branch information
SoSeDiK committed Sep 13, 2024
1 parent bd2a6c8 commit bb76cf0
Show file tree
Hide file tree
Showing 31 changed files with 567 additions and 27 deletions.
172 changes: 169 additions & 3 deletions patches/api/0015-Data-driven-items.patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,25 @@ index b32ae215e976bcfcdd86b03037de61b3d896f57c..7b12d1fcf5a2f5d4a043f934611fc824
}
diff --git a/src/main/java/me/sosedik/kiterino/registry/data/ItemRegistryEntity.java b/src/main/java/me/sosedik/kiterino/registry/data/ItemRegistryEntity.java
new file mode 100644
index 0000000000000000000000000000000000000000..1f61fe3836de8d89a23e36efc4c5d65fd56ae838
index 0000000000000000000000000000000000000000..84520226226685b746acc2b2c39a02bc999652f8
--- /dev/null
+++ b/src/main/java/me/sosedik/kiterino/registry/data/ItemRegistryEntity.java
@@ -0,0 +1,142 @@
@@ -0,0 +1,308 @@
+package me.sosedik.kiterino.registry.data;
+
+import io.papermc.paper.registry.RegistryBuilder;
+import net.kyori.adventure.key.Key;
+import org.bukkit.inventory.ItemRarity;
+import org.bukkit.inventory.ItemType;
+import org.bukkit.potion.PotionEffect;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.Range;
+
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+
+/**
Expand Down Expand Up @@ -74,6 +78,20 @@ index 0000000000000000000000000000000000000000..1f61fe3836de8d89a23e36efc4c5d65f
+ @Nullable ItemRarity rarity();
+
+ /**
+ * Provides the key for the item that's left after using this item in crafts
+ *
+ * @return the key for the item that's left after using this item in crafts
+ */
+ @Nullable Key craftRemainingItem();
+
+ /**
+ * Provides the item's default food properties
+ *
+ * @return the item's default food properties
+ */
+ @Nullable FoodProperties foodProperties();
+
+ /**
+ * Provides the item's compost chance
+ *
+ * @return the item's compost chance
Expand All @@ -95,6 +113,136 @@ index 0000000000000000000000000000000000000000..1f61fe3836de8d89a23e36efc4c5d65f
+ @Nullable Function<Object, Object> nmsItemFunction();
+
+ /**
+ * Represents food properties
+ */
+ @ApiStatus.Experimental
+ interface FoodProperties {
+
+ /**
+ * Provides the item's nutrition value
+ *
+ * @return the item's nutrition value
+ */
+ int nutrition();
+
+ /**
+ * Provides the item's saturation value
+ *
+ * @return the item's saturation value
+ */
+ float saturation();
+
+ /**
+ * Whether the item is always edible
+ *
+ * @return whether the item is always edible
+ */
+ boolean canAlwaysEat();
+
+ /**
+ * Provides the time in seconds the item takes to be eaten
+ *
+ * @return the time in seconds the item takes to be eaten
+ */
+ float eatSeconds();
+
+ /**
+ * Provides the key for the item that's left after consuming this item
+ *
+ * @return the key for the item that's left after consuming this item
+ */
+ @Nullable Key usingConvertsTo();
+
+ /**
+ * Provides the list of possible effects and their chances
+ *
+ * @return the list of possible effects and their chances
+ */
+ @Nullable List<Map.Entry<PotionEffect, @Range(from = 0L, to = 1L) Float>> possibleEffects();
+
+ interface Builder extends FoodProperties {
+
+ /**
+ * Configures the item's nutrition value
+ *
+ * @param nutrition the item's nutrition value
+ * @return this builder
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder nutrition(@Range(from = 0L, to = Integer.MAX_VALUE) int nutrition);
+
+ /**
+ * Configures the item's saturation value
+ *
+ * @param saturation the item's saturation value
+ * @return this builder
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder saturation(float saturation);
+
+ /**
+ * Configures whether the item is always edible
+ *
+ * @param alwaysEdible whether the item is always edible
+ * @return this builder
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder canAlwaysEat(boolean alwaysEdible);
+
+ /**
+ * Marks the item as always edible
+ *
+ * @return this builder
+ * @see #canAlwaysEat(boolean)
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ default @NonNull Builder alwaysEdible() {
+ return canAlwaysEat(true);
+ }
+
+ /**
+ * Configures the time in seconds the item takes to be eaten
+ *
+ * @param seconds the time in seconds the item takes to be eaten
+ * @return this builder
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder eatSeconds(float seconds);
+
+ /**
+ * Marks the item as "fast food", i.e. it takes 0.865 seconds to eat
+ *
+ * @return this builder
+ * @see #eatSeconds(float)
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ default @NonNull Builder fastFood() {
+ return eatSeconds(0.8F);
+ }
+
+ /**
+ * Configures the key for the item that's left after consuming this item
+ *
+ * @param key the key for the item that's left after consuming this item
+ * @return this builder
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder usingConvertsTo(@Nullable Key key);
+
+ /**
+ * Configures the list of possible effects and their chances
+ *
+ * @param possibleEffects the list of possible effects and their chances
+ * @return this builder
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder possibleEffects(@Nullable List<Map.Entry<PotionEffect, @Range(from = 0L, to = 1L) Float>> possibleEffects);
+
+ }
+
+ }
+
+ /**
+ * A mutable builder for the {@link ItemRegistryEntity} plugins may change in applicable registry events.
+ */
+ @ApiStatus.Experimental
Expand Down Expand Up @@ -138,6 +286,24 @@ index 0000000000000000000000000000000000000000..1f61fe3836de8d89a23e36efc4c5d65f
+ @NonNull Builder rarity(@Nullable ItemRarity rarity);
+
+ /**
+ * Configures the key for the item that's left after using this item in crafts
+ *
+ * @param key the key for the item that's left after using this item in crafts
+ * @return this builder
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder craftRemainingItem(@Nullable Key key);
+
+ /**
+ * Configures the item's default food properties
+ *
+ * @param foodProperties the item's default food properties
+ * @return this builder
+ */
+ @Contract(value = "_ -> this", mutates = "this")
+ @NonNull Builder foodProperties(@Nullable Function<FoodProperties.Builder, FoodProperties.Builder> foodProperties);
+
+ /**
+ * Configures the item's compost chance
+ *
+ * @param levelIncreaseChance the item's compost chance
Expand Down
8 changes: 4 additions & 4 deletions patches/api/0017-Faking-custom-items.patch
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ index 0000000000000000000000000000000000000000..e34e247ae98bf9fe65485f9f2376a61a
+
+}
diff --git a/src/main/java/me/sosedik/kiterino/registry/data/ItemRegistryEntity.java b/src/main/java/me/sosedik/kiterino/registry/data/ItemRegistryEntity.java
index 1f61fe3836de8d89a23e36efc4c5d65fd56ae838..998405409ec613e60a13f1a235a477ababa6364e 100644
index 84520226226685b746acc2b2c39a02bc999652f8..2a270d97c37cbb4bbc3c755938a1bfaef2aad8d1 100644
--- a/src/main/java/me/sosedik/kiterino/registry/data/ItemRegistryEntity.java
+++ b/src/main/java/me/sosedik/kiterino/registry/data/ItemRegistryEntity.java
@@ -1,5 +1,6 @@
package me.sosedik.kiterino.registry.data;

+import me.sosedik.kiterino.modifier.item.KiterinoItemModifier;
import io.papermc.paper.registry.RegistryBuilder;
import net.kyori.adventure.key.Key;
import org.bukkit.inventory.ItemRarity;
import org.bukkit.inventory.ItemType;
@@ -18,6 +19,13 @@ import java.util.function.Function;
@@ -22,6 +23,13 @@ import java.util.function.Function;
@ApiStatus.NonExtendable
public interface ItemRegistryEntity {

Expand All @@ -69,7 +69,7 @@ index 1f61fe3836de8d89a23e36efc4c5d65fd56ae838..998405409ec613e60a13f1a235a477ab
/**
* Provides the item's default max stack size
*
@@ -74,6 +82,15 @@ public interface ItemRegistryEntity {
@@ -222,6 +230,15 @@ public interface ItemRegistryEntity {
@ApiStatus.NonExtendable
interface Builder extends ItemRegistryEntity, RegistryBuilder<ItemType> {

Expand Down
26 changes: 26 additions & 0 deletions patches/api/0027-Panda-force-scared-state.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: SoSeDiK <[email protected]>
Date: Thu, 12 Sep 2024 23:52:50 +0300
Subject: [PATCH] Panda force scared state


diff --git a/src/main/java/org/bukkit/entity/Panda.java b/src/main/java/org/bukkit/entity/Panda.java
index 4f06870cc8d8aab93aa83b1b8165e6714884372c..e82ce9616e9f0c4866060aa444ed2c1858a1a0a4 100644
--- a/src/main/java/org/bukkit/entity/Panda.java
+++ b/src/main/java/org/bukkit/entity/Panda.java
@@ -100,6 +100,15 @@ public interface Panda extends Animals, Sittable {
*/
boolean isScared();

+ // Kiterino start - Panda force scared state
+ /**
+ * Forces panda's scared state
+ *
+ * @param scared whether panda is scared
+ */
+ void setScared(@NotNull net.kyori.adventure.util.TriState scared);
+ // Kiterino end - Panda force scared state
+
/**
* Gets how many ticks the panda will be unhappy for
*
40 changes: 35 additions & 5 deletions patches/server/0006-Add-Kiterino-configs.patch
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ index 0000000000000000000000000000000000000000..6c77d9c7583ea95e0ad7ffba4aecccb3
+}
diff --git a/src/main/java/me/sosedik/kiterino/KiterinoWorldConfig.java b/src/main/java/me/sosedik/kiterino/KiterinoWorldConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..e3afd27ef22e689133b42c947102b54ae14f8eb4
index 0000000000000000000000000000000000000000..54b1af069c31532e1fc66a065cb83681e4aaaf4c
--- /dev/null
+++ b/src/main/java/me/sosedik/kiterino/KiterinoWorldConfig.java
@@ -0,0 +1,18 @@
Expand All @@ -145,7 +145,7 @@ index 0000000000000000000000000000000000000000..e3afd27ef22e689133b42c947102b54a
+public final class KiterinoWorldConfig extends WorldConfig {
+
+ public KiterinoWorldConfig(@NotNull String worldName, @NotNull World.Environment environment) {
+ super(worldName, environment);
+ super(KiterinoConfig.config, worldName, environment);
+ }
+
+ @Override
Expand All @@ -157,21 +157,27 @@ index 0000000000000000000000000000000000000000..e3afd27ef22e689133b42c947102b54a
+}
diff --git a/src/main/java/me/sosedik/kiterino/WorldConfig.java b/src/main/java/me/sosedik/kiterino/WorldConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..33cb6b7760b0aa77b64c693b34aef577134e66e2
index 0000000000000000000000000000000000000000..2847457b5ac30d4b4130547ea6b05763fdfc0025
--- /dev/null
+++ b/src/main/java/me/sosedik/kiterino/WorldConfig.java
@@ -0,0 +1,23 @@
@@ -0,0 +1,53 @@
+package me.sosedik.kiterino;
+
+import org.bukkit.World;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+
+public abstract class WorldConfig {
+
+ protected final YamlConfiguration config;
+ protected final String worldName;
+ protected final World.Environment environment;
+
+ protected WorldConfig(@NotNull String worldName, @NotNull World.Environment environment) {
+ protected WorldConfig(@NotNull YamlConfiguration config, @NotNull String worldName, @NotNull World.Environment environment) {
+ this.config = config;
+ this.worldName = worldName;
+ this.environment = environment;
+ init();
Expand All @@ -183,4 +189,28 @@ index 0000000000000000000000000000000000000000..33cb6b7760b0aa77b64c693b34aef577
+ KiterinoConfig.log(s);
+ }
+
+ public @Nullable String getString(@NotNull String path, @NotNull String def, @NotNull String... comments) {
+ config.addDefault("world-settings.default." + path, def);
+ if (comments.length > 0) config.setComments("world-settings.default." + path, List.of(comments));
+ return config.getString("world-settings." + worldName + "." + path, config.getString("world-settings.default." + path));
+ }
+
+ public boolean getBoolean(@NotNull String path, boolean def, @NotNull String... comments) {
+ config.addDefault("world-settings.default." + path, def);
+ if (comments.length > 0) config.setComments("world-settings.default." + path, List.of(comments));
+ return config.getBoolean("world-settings." + worldName + "." + path, config.getBoolean("world-settings.default." + path));
+ }
+
+ public double getDouble(@NotNull String path, double def, @NotNull String... comments) {
+ config.addDefault("world-settings.default." + path, def);
+ if (comments.length > 0) config.setComments("world-settings.default." + path, List.of(comments));
+ return config.getDouble("world-settings." + worldName + "." + path, config.getDouble("world-settings.default." + path));
+ }
+
+ public int getInt(@NotNull String path, int def, @NotNull String... comments) {
+ config.addDefault("world-settings.default." + path, def);
+ if (comments.length > 0) config.setComments("world-settings.default." + path, List.of(comments));
+ return config.getInt("world-settings." + worldName + "." + path, config.getInt("world-settings.default." + path));
+ }
+
+}
Loading

0 comments on commit bb76cf0

Please sign in to comment.