mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-25 18:09:26 +00:00
try fixing some hooks
This commit is contained in:
@@ -43,6 +43,7 @@ public class HookConfigParser {
|
||||
|
||||
private final String id;
|
||||
private final String material;
|
||||
private final int maxUsages;
|
||||
private final List<PriorityFunction<BiConsumer<Item<ItemStack>, Context<Player>>>> tagConsumers = new ArrayList<>();
|
||||
private final List<Consumer<EventCarrier.Builder>> eventBuilderConsumers = new ArrayList<>();
|
||||
private final List<Consumer<HookConfig.Builder>> hookBuilderConsumers = new ArrayList<>();
|
||||
@@ -53,6 +54,7 @@ public class HookConfigParser {
|
||||
public HookConfigParser(String id, Section section, Map<String, Node<ConfigParserFunction>> functionMap) {
|
||||
this.id = id;
|
||||
this.material = section.getString("material");
|
||||
this.maxUsages = section.getInt("max-durability", -1);
|
||||
if (!section.contains("tag")) section.set("tag", true);
|
||||
analyze(section, functionMap);
|
||||
}
|
||||
@@ -135,6 +137,7 @@ public class HookConfigParser {
|
||||
|
||||
public HookConfig getHook() {
|
||||
HookConfig.Builder builder = HookConfig.builder()
|
||||
.maxUsages(maxUsages)
|
||||
.id(id);
|
||||
for (Consumer<HookConfig.Builder> consumer : hookBuilderConsumers) {
|
||||
consumer.accept(builder);
|
||||
|
||||
@@ -38,6 +38,13 @@ public interface HookConfig {
|
||||
*/
|
||||
List<String> lore();
|
||||
|
||||
/**
|
||||
* Gets the max usages of the hook
|
||||
*
|
||||
* @return the max usages
|
||||
*/
|
||||
int maxUsages();
|
||||
|
||||
/**
|
||||
* Creates a new builder for constructing {@link HookConfig} instances.
|
||||
*
|
||||
@@ -60,6 +67,11 @@ public interface HookConfig {
|
||||
*/
|
||||
Builder id(String id);
|
||||
|
||||
/**
|
||||
* Sets the max usages of the hook
|
||||
*/
|
||||
Builder maxUsages(int maxUsages);
|
||||
|
||||
/**
|
||||
* Sets the lore for the hook configuration.
|
||||
*
|
||||
|
||||
@@ -22,12 +22,12 @@ import java.util.List;
|
||||
public class HookConfigImpl implements HookConfig {
|
||||
|
||||
private final String id;
|
||||
private final int maxDurability;
|
||||
private final int maxUsages;
|
||||
private final List<String> lore;
|
||||
|
||||
public HookConfigImpl(String id, int maxDurability, List<String> lore) {
|
||||
public HookConfigImpl(String id, int maxUsages, List<String> lore) {
|
||||
this.id = id;
|
||||
this.maxDurability = maxDurability;
|
||||
this.maxUsages = maxUsages;
|
||||
this.lore = lore;
|
||||
}
|
||||
|
||||
@@ -41,9 +41,14 @@ public class HookConfigImpl implements HookConfig {
|
||||
return lore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxUsages() {
|
||||
return maxUsages;
|
||||
}
|
||||
|
||||
public static class BuilderImpl implements Builder {
|
||||
private String id;
|
||||
private int maxDurability;
|
||||
private int maxUsages;
|
||||
private List<String> lore;
|
||||
@Override
|
||||
public Builder id(String id) {
|
||||
@@ -51,13 +56,18 @@ public class HookConfigImpl implements HookConfig {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public Builder maxUsages(int maxUsages) {
|
||||
this.maxUsages = maxUsages;
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public Builder lore(List<String> lore) {
|
||||
this.lore = lore;
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public HookConfig build() {
|
||||
return new HookConfigImpl(id, maxDurability, lore);
|
||||
return new HookConfigImpl(id, maxUsages, lore);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +95,15 @@ public interface ItemManager extends Reloadable {
|
||||
@Nullable
|
||||
String getCustomFishingItemID(@NotNull ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Gets the loot by providing the context
|
||||
*
|
||||
* @param context context
|
||||
* @param rod rod
|
||||
* @param hook hook
|
||||
* @return the loot
|
||||
*/
|
||||
@NotNull
|
||||
ItemStack getItemLoot(@NotNull Context<Player> context, ItemStack rod, FishHook hook);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user