mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2026-01-04 15:41:35 +00:00
checkpoint - 23
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package net.momirealms.customfishing.common.item;
|
||||
|
||||
import net.momirealms.customfishing.common.plugin.CustomFishingPlugin;
|
||||
import net.momirealms.customfishing.common.util.Key;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class AbstractItem<R, I> implements Item<I> {
|
||||
@@ -67,6 +69,30 @@ public class AbstractItem<R, I> implements Item<I> {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item<I> enchantments(Map<Key, Short> enchantments) {
|
||||
factory.enchantments(item, enchantments);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item<I> addEnchantment(Key enchantment, int level) {
|
||||
factory.addEnchantment(item, enchantment, level);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item<I> storedEnchantments(Map<Key, Short> enchantments) {
|
||||
factory.storedEnchantments(item, enchantments);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item<I> addStoredEnchantment(Key enchantment, int level) {
|
||||
factory.addStoredEnchantment(item, enchantment, level);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Object> getTag(Object... path) {
|
||||
return factory.getTag(item, path);
|
||||
|
||||
@@ -9,6 +9,8 @@ public class ComponentKeys {
|
||||
public static final String LORE = Key.key("minecraft", "lore").asString();
|
||||
public static final String DAMAGE = Key.key("minecraft", "damage").asString();
|
||||
public static final String ENCHANTMENT_GLINT_OVERRIDE = Key.key("minecraft", "enchantment_glint_override").asString();
|
||||
public static final String ENCHANTMENTS = Key.key("minecraft", "enchantments").asString();
|
||||
public static final String STORED_ENCHANTMENTS = Key.key("minecraft", "stored_enchantments").asString();
|
||||
public static final String HIDE_TOOLTIP = Key.key("minecraft", "hide_tooltip").asString();
|
||||
public static final String MAX_STACK_SIZE = Key.key("minecraft", "max_stack_size").asString();
|
||||
public static final String PROFILE = Key.key("minecraft", "profile").asString();
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package net.momirealms.customfishing.common.item;
|
||||
|
||||
import net.momirealms.customfishing.common.util.Key;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface Item<I> {
|
||||
@@ -23,6 +26,14 @@ public interface Item<I> {
|
||||
|
||||
Item<I> skull(String data);
|
||||
|
||||
Item<I> enchantments(Map<Key, Short> enchantments);
|
||||
|
||||
Item<I> addEnchantment(Key enchantment, int level);
|
||||
|
||||
Item<I> storedEnchantments(Map<Key, Short> enchantments);
|
||||
|
||||
Item<I> addStoredEnchantment(Key enchantment, int level);
|
||||
|
||||
Optional<Object> getTag(Object... path);
|
||||
|
||||
Item<I> setTag(Object value, Object... path);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package net.momirealms.customfishing.common.item;
|
||||
|
||||
import net.momirealms.customfishing.common.plugin.CustomFishingPlugin;
|
||||
import net.momirealms.customfishing.common.util.Key;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -60,4 +62,12 @@ public abstract class ItemFactory<P extends CustomFishingPlugin, R, I> {
|
||||
protected abstract Optional<Integer> damage(R item);
|
||||
|
||||
protected abstract void damage(R item, Integer damage);
|
||||
|
||||
protected abstract void enchantments(R item, Map<Key, Short> enchantments);
|
||||
|
||||
protected abstract void storedEnchantments(R item, Map<Key, Short> enchantments);
|
||||
|
||||
protected abstract void addEnchantment(R item, Key enchantment, int level);
|
||||
|
||||
protected abstract void addStoredEnchantment(R item, Key enchantment, int level);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,11 @@ public record Key(String namespace, String value) {
|
||||
return new Key(namespace, value);
|
||||
}
|
||||
|
||||
public static Key fromString(String key) {
|
||||
String[] split = key.split(":", 2);
|
||||
return of(split[0], split[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return toString().hashCode();
|
||||
|
||||
Reference in New Issue
Block a user