9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2026-01-03 22:26:15 +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

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

View File

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

View File

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

View File

@@ -383,7 +383,7 @@ public class BukkitConfigManager extends ConfigManager {
this.registerItemParser(f1, 4700, "enchantment-pool");
Function<Object, BiConsumer<Item<ItemStack>, Context<Player>>> f2 = 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);
return (item, context) -> {
HashSet<String> ids = new HashSet<>();

View File

@@ -411,17 +411,17 @@ public class BukkitMarketManager implements MarketManager, Listener {
ItemStack itemStack = gui.inventory.getItem(slot);
if (itemStack != null && itemStack.getType() != Material.AIR) {
if (current.getType() == itemStack.getType()
&& itemStack.getAmount() != itemStack.getType().getMaxStackSize()
&& itemStack.getAmount() != itemStack.getMaxStackSize()
&& current.getItemMeta().equals(itemStack.getItemMeta())
) {
int left = itemStack.getType().getMaxStackSize() - itemStack.getAmount();
int left = itemStack.getMaxStackSize() - itemStack.getAmount();
if (current.getAmount() <= left) {
itemStack.setAmount(itemStack.getAmount() + current.getAmount());
current.setAmount(0);
break;
} else {
current.setAmount(current.getAmount() - left);
itemStack.setAmount(itemStack.getType().getMaxStackSize());
itemStack.setAmount(itemStack.getMaxStackSize());
}
}
} 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>"
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.give.success: "<white>成功给予 <arg:0> <arg:2> 个 <arg:1></white>"
command.item.get.success: "<white>成功获得 <arg:1> 个 <arg:0></white>"
command.item.give.success: "<white>成功给予 <arg:0> <arg:1> 个 <arg:2></white>"
command.item.get.success: "<white>成功获得 <arg:0> 个 <arg:1></white>"
command.item.import.failure.no_item: "<red>无法导入空气</red>"
command.item.import.success: "<white>物品 [<arg:0>] 已保存至 /plugins/CustomFishing/imported_items.yml</white>"
command.fish_finder.possible_loots: "<white>可以钓到的战利品: <arg:0></white>"