9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00
This commit is contained in:
XiaoMoMi
2024-07-27 17:06:42 +08:00
parent 4b8537016e
commit a36b92df6e
10 changed files with 33 additions and 13 deletions

View File

@@ -301,6 +301,23 @@ public class FishingGears {
wrapped.removeTag("CustomFishing", "hook_id"); wrapped.removeTag("CustomFishing", "hook_id");
wrapped.removeTag("CustomFishing", "hook_stack"); wrapped.removeTag("CustomFishing", "hook_stack");
wrapped.removeTag("CustomFishing", "hook_max_damage"); wrapped.removeTag("CustomFishing", "hook_max_damage");
List<String> durabilityLore = new ArrayList<>();
List<String> newLore = new ArrayList<>();
List<String> previousLore = wrapped.lore().orElse(new ArrayList<>());
for (String previous : previousLore) {
Component component = AdventureHelper.jsonToComponent(previous);
if (component instanceof ScoreComponent scoreComponent && scoreComponent.name().equals("cf")) {
if (scoreComponent.objective().equals("hook")) {
continue;
} else if (scoreComponent.objective().equals("durability")) {
durabilityLore.add(previous);
continue;
}
}
newLore.add(previous);
}
newLore.addAll(durabilityLore);
wrapped.lore(newLore);
BukkitCustomFishingPlugin.getInstance().getSenderFactory().getAudience(context.getHolder()).playSound(Sound.sound(Key.key("minecraft:entity.item.break"), Sound.Source.PLAYER, 1, 1)); BukkitCustomFishingPlugin.getInstance().getSenderFactory().getAudience(context.getHolder()).playSound(Sound.sound(Key.key("minecraft:entity.item.break"), Sound.Source.PLAYER, 1, 1));
} else { } else {
wrapped.setTag(hookDamage, "CustomFishing", "hook_damage"); wrapped.setTag(hookDamage, "CustomFishing", "hook_damage");

View File

@@ -20,6 +20,7 @@ package net.momirealms.customfishing.bukkit.integration.item;
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin; import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import net.momirealms.customfishing.api.integration.ItemProvider; import net.momirealms.customfishing.api.integration.ItemProvider;
import net.momirealms.customfishing.api.mechanic.context.Context; import net.momirealms.customfishing.api.mechanic.context.Context;
import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -45,7 +46,7 @@ public class CustomFishingItemProvider implements ItemProvider {
// CustomFishing:TYPE:ID // CustomFishing:TYPE:ID
finalID = split[1]; finalID = split[1];
} }
ItemStack itemStack = BukkitCustomFishingPlugin.getInstance().getItemManager().buildInternal(Context.player(player), finalID); ItemStack itemStack = BukkitCustomFishingPlugin.getInstance().getItemManager().buildInternal(Context.player(player).arg(ContextKeys.ID, finalID), finalID);
return requireNonNull(itemStack); return requireNonNull(itemStack);
} }

View File

@@ -55,6 +55,7 @@ import net.momirealms.customfishing.common.plugin.classpath.ClassPathAppender;
import net.momirealms.customfishing.common.plugin.classpath.ReflectionClassPathAppender; import net.momirealms.customfishing.common.plugin.classpath.ReflectionClassPathAppender;
import net.momirealms.customfishing.common.plugin.logging.JavaPluginLogger; import net.momirealms.customfishing.common.plugin.logging.JavaPluginLogger;
import net.momirealms.customfishing.common.plugin.logging.PluginLogger; import net.momirealms.customfishing.common.plugin.logging.PluginLogger;
import net.momirealms.sparrow.heart.SparrowHeart;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@@ -106,6 +107,7 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
@Override @Override
public void enable() { public void enable() {
SparrowHeart.getInstance();
this.configManager = new BukkitConfigManager(this); this.configManager = new BukkitConfigManager(this);
new Migration(this).start(); new Migration(this).start();
this.eventManager = new BukkitEventManager(this); this.eventManager = new BukkitEventManager(this);

View File

@@ -454,7 +454,7 @@ public class BukkitActionManager implements ActionManager<Player> {
Player player = context.getHolder(); Player player = context.getHolder();
ItemStack itemStack = plugin.getItemManager().buildAny(context, id); ItemStack itemStack = plugin.getItemManager().buildAny(context, id);
if (itemStack != null) { if (itemStack != null) {
int maxStack = itemStack.getType().getMaxStackSize(); int maxStack = itemStack.getMaxStackSize();
int amountToGive = amount; int amountToGive = amount;
while (amountToGive > 0) { while (amountToGive > 0) {
int perStackSize = Math.min(maxStack, amountToGive); int perStackSize = Math.min(maxStack, amountToGive);
@@ -462,9 +462,9 @@ public class BukkitActionManager implements ActionManager<Player> {
ItemStack more = itemStack.clone(); ItemStack more = itemStack.clone();
more.setAmount(perStackSize); more.setAmount(perStackSize);
if (toInventory) { if (toInventory) {
PlayerUtils.giveItem(player, itemStack, itemStack.getAmount()); PlayerUtils.giveItem(player, more, itemStack.getAmount());
} else { } else {
PlayerUtils.dropItem(player, itemStack, true, true, false); PlayerUtils.dropItem(player, more, true, true, false);
} }
} }
} }

View File

@@ -71,7 +71,7 @@ public class GetItemCommand extends BukkitCommandFeature<CommandSender> {
throw new RuntimeException("Unrecognized item id: " + id); throw new RuntimeException("Unrecognized item id: " + id);
} }
int amountToGive = amount; int amountToGive = amount;
int maxStack = itemStack.getType().getMaxStackSize(); int maxStack = itemStack.getMaxStackSize();
while (amountToGive > 0) { while (amountToGive > 0) {
int perStackSize = Math.min(maxStack, amountToGive); int perStackSize = Math.min(maxStack, amountToGive);
amountToGive -= perStackSize; amountToGive -= perStackSize;

View File

@@ -72,7 +72,7 @@ public class GiveItemCommand extends BukkitCommandFeature<CommandSender> {
throw new RuntimeException("Unrecognized item id: " + id); throw new RuntimeException("Unrecognized item id: " + id);
} }
int amountToGive = amount; int amountToGive = amount;
int maxStack = itemStack.getType().getMaxStackSize(); int maxStack = itemStack.getMaxStackSize();
while (amountToGive > 0) { while (amountToGive > 0) {
int perStackSize = Math.min(maxStack, amountToGive); int perStackSize = Math.min(maxStack, amountToGive);
amountToGive -= perStackSize; amountToGive -= perStackSize;

View File

@@ -383,7 +383,7 @@ public class BukkitConfigManager extends ConfigManager {
this.registerItemParser(f1, 4700, "enchantment-pool"); this.registerItemParser(f1, 4700, "enchantment-pool");
Function<Object, BiConsumer<Item<ItemStack>, Context<Player>>> f2 = arg -> { Function<Object, BiConsumer<Item<ItemStack>, Context<Player>>> f2 = arg -> {
Section section = (Section) arg; Section section = (Section) arg;
boolean stored = Objects.equals(section.getNameAsString(), "stored-random-enchantments"); boolean stored = Objects.equals(section.getNameAsString(), "random-stored-enchantments");
List<Tuple<Double, String, Short>> enchantments = getPossibleEnchantments(section); List<Tuple<Double, String, Short>> enchantments = getPossibleEnchantments(section);
return (item, context) -> { return (item, context) -> {
HashSet<String> ids = new HashSet<>(); HashSet<String> ids = new HashSet<>();

View File

@@ -411,17 +411,17 @@ public class BukkitMarketManager implements MarketManager, Listener {
ItemStack itemStack = gui.inventory.getItem(slot); ItemStack itemStack = gui.inventory.getItem(slot);
if (itemStack != null && itemStack.getType() != Material.AIR) { if (itemStack != null && itemStack.getType() != Material.AIR) {
if (current.getType() == itemStack.getType() if (current.getType() == itemStack.getType()
&& itemStack.getAmount() != itemStack.getType().getMaxStackSize() && itemStack.getAmount() != itemStack.getMaxStackSize()
&& current.getItemMeta().equals(itemStack.getItemMeta()) && current.getItemMeta().equals(itemStack.getItemMeta())
) { ) {
int left = itemStack.getType().getMaxStackSize() - itemStack.getAmount(); int left = itemStack.getMaxStackSize() - itemStack.getAmount();
if (current.getAmount() <= left) { if (current.getAmount() <= left) {
itemStack.setAmount(itemStack.getAmount() + current.getAmount()); itemStack.setAmount(itemStack.getAmount() + current.getAmount());
current.setAmount(0); current.setAmount(0);
break; break;
} else { } else {
current.setAmount(current.getAmount() - left); current.setAmount(current.getAmount() - left);
itemStack.setAmount(itemStack.getType().getMaxStackSize()); itemStack.setAmount(itemStack.getMaxStackSize());
} }
} }
} else { } else {

View File

@@ -40,8 +40,8 @@ argument.parse.failure.either: "<red>无法从 '<arg:0>' 解析 <arg:1> 或 <arg
argument.parse.failure.namedtextcolor: "<red>'<arg:0>' 不是颜色代码</red>" argument.parse.failure.namedtextcolor: "<red>'<arg:0>' 不是颜色代码</red>"
command.reload.success: "<white>重新加载完成.耗时 <green><arg:0></green> 毫秒</white><newline><green><click:open_url:https://github.com/jhqwqmc>译者jhqwqmc</click></green>" command.reload.success: "<white>重新加载完成.耗时 <green><arg:0></green> 毫秒</white><newline><green><click:open_url:https://github.com/jhqwqmc>译者jhqwqmc</click></green>"
command.item.failure.not_exist: "<red>物品 [<arg:0>] 不存在</red>" command.item.failure.not_exist: "<red>物品 [<arg:0>] 不存在</red>"
command.item.give.success: "<white>成功给予 <arg:0> <arg:2> 个 <arg:1></white>" command.item.give.success: "<white>成功给予 <arg:0> <arg:1> 个 <arg:2></white>"
command.item.get.success: "<white>成功获得 <arg:1> 个 <arg:0></white>" command.item.get.success: "<white>成功获得 <arg:0> 个 <arg:1></white>"
command.item.import.failure.no_item: "<red>无法导入空气</red>" command.item.import.failure.no_item: "<red>无法导入空气</red>"
command.item.import.success: "<white>物品 [<arg:0>] 已保存至 /plugins/CustomFishing/imported_items.yml</white>" command.item.import.success: "<white>物品 [<arg:0>] 已保存至 /plugins/CustomFishing/imported_items.yml</white>"
command.fish_finder.possible_loots: "<white>可以钓到的战利品: <arg:0></white>" command.fish_finder.possible_loots: "<white>可以钓到的战利品: <arg:0></white>"

View File

@@ -17,7 +17,7 @@ h2_driver_version=2.2.224
sqlite_driver_version=3.46.0.0 sqlite_driver_version=3.46.0.0
adventure_bundle_version=4.17.0 adventure_bundle_version=4.17.0
adventure_platform_version=4.3.3 adventure_platform_version=4.3.3
sparrow_heart_version=0.32 sparrow_heart_version=0.33
cloud_core_version=2.0.0-rc.2 cloud_core_version=2.0.0-rc.2
cloud_services_version=2.0.0-rc.2 cloud_services_version=2.0.0-rc.2
cloud_brigadier_version=2.0.0-beta.9 cloud_brigadier_version=2.0.0-beta.9