diff --git a/build.gradle b/build.gradle index 5753c672..0c1d2718 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'net.momirealms' -version = '1.2.3' +version = '1.2.4' repositories { mavenCentral() diff --git a/src/main/java/net/momirealms/customfishing/commands/PluginCommand.java b/src/main/java/net/momirealms/customfishing/commands/PluginCommand.java index ecae9f5b..e4d331b1 100644 --- a/src/main/java/net/momirealms/customfishing/commands/PluginCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/PluginCommand.java @@ -18,10 +18,7 @@ package net.momirealms.customfishing.commands; -import net.momirealms.customfishing.commands.subcmd.CompetitionCommand; -import net.momirealms.customfishing.commands.subcmd.ImportCommand; -import net.momirealms.customfishing.commands.subcmd.ItemsCommand; -import net.momirealms.customfishing.commands.subcmd.ReloadCommand; +import net.momirealms.customfishing.commands.subcmd.*; import net.momirealms.customfishing.manager.MessageManager; import net.momirealms.customfishing.util.AdventureUtil; import org.bukkit.command.Command; @@ -62,6 +59,7 @@ public class PluginCommand implements TabExecutor { regSubCommand(ItemsCommand.INSTANCE); regSubCommand(CompetitionCommand.INSTANCE); regSubCommand(ImportCommand.INSTANCE); + regSubCommand(SellShopCommand.INSTANCE); } public void regSubCommand(SubCommand executor) { diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/RodCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/RodCommand.java index 37decc26..76256827 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/RodCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/RodCommand.java @@ -42,8 +42,9 @@ public class RodCommand extends AbstractSubCommand { public boolean onCommand(CommandSender sender, List args) { if (args.size() < 2) { AdventureUtil.sendMessage(sender, MessageManager.prefix + MessageManager.lackArgs); + return true; } - else if (args.get(0).equalsIgnoreCase("get")) { + if (args.get(0).equalsIgnoreCase("get")) { if (sender instanceof Player player){ if (!BonusManager.RODITEMS.containsKey(args.get(1))){ AdventureUtil.sendMessage(sender, MessageManager.prefix + MessageManager.itemNotExist); diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/SellShopCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/SellShopCommand.java new file mode 100644 index 00000000..e29a5b57 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/SellShopCommand.java @@ -0,0 +1,44 @@ +package net.momirealms.customfishing.commands.subcmd; + +import net.momirealms.customfishing.CustomFishing; +import net.momirealms.customfishing.commands.AbstractSubCommand; +import net.momirealms.customfishing.commands.SubCommand; +import net.momirealms.customfishing.manager.MessageManager; +import net.momirealms.customfishing.util.AdventureUtil; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.List; + +public class SellShopCommand extends AbstractSubCommand { + + public static final SubCommand INSTANCE = new SellShopCommand(); + + public SellShopCommand() { + super("sellshop", null); + } + + @Override + public boolean onCommand(CommandSender sender, List args) { + if (args.size() < 1) { + AdventureUtil.sendMessage(sender, MessageManager.prefix + MessageManager.lackArgs); + return true; + } + + Player player = Bukkit.getPlayer(args.get(0)); + if (player == null) { + AdventureUtil.sendMessage(sender, MessageManager.prefix + MessageManager.notOnline.replace("{Player}", args.get(0))); + return true; + } + + player.closeInventory(); + CustomFishing.plugin.getSellManager().openGuiForPlayer(player); + return true; + } + + @Override + public List onTabComplete(CommandSender sender, List args) { + return online_players(); + } +} diff --git a/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java b/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java index 732a9ffa..6fbe80ff 100644 --- a/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java @@ -70,6 +70,7 @@ public class ConfigManager { public static boolean addTagToFish; public static boolean logEarning; public static boolean vaultHook; + public static boolean disableBar; public static String fishingBagTitle; public static HashSet bagWhiteListItems; @@ -94,6 +95,7 @@ public class ConfigManager { } worlds = worldList.toArray(new World[0]); + disableBar = config.getBoolean("mechanics.disable-bar-mechanic", false); alwaysFishingBar = config.getBoolean("mechanics.other-loots.fishing-bar", true); otherLootBar = config.getBoolean("mechanics.other-loots.fishing-bar", true); enableVanillaLoot = config.getBoolean("mechanics.other-loots.vanilla.enable", true); diff --git a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java index 12b68c15..d8943dcd 100644 --- a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java @@ -337,6 +337,11 @@ public class FishingManager extends Function { final Player player = event.getPlayer(); if (!(event.getCaught() instanceof Item item)) return; + if (ConfigManager.disableBar) { + noBarWaterReelIn(event); + return; + } + FishingPlayer fishingPlayer = fishingPlayerCache.remove(player); if (fishingPlayer == null) { @@ -385,12 +390,66 @@ public class FishingManager extends Function { } } + private void noBarWaterReelIn(PlayerFishEvent event) { + Entity entity = event.getCaught(); + if (!(entity instanceof Item item)) { + return; + } + entity.remove(); + event.setExpToDrop(0); + final Player player = event.getPlayer(); + Loot loot = nextLoot.remove(player); + VanillaLoot vanilla = vanillaLoot.remove(player); + Bonus bonus = nextBonus.remove(player); + if (vanilla != null) { + dropVanillaLoot(player, vanilla, item.getLocation(), bonus.getDoubleLoot() > Math.random()); + return; + } + if (loot instanceof Mob mob) { + summonMob(player, loot, item.getLocation(), mob, bonus.getScore()); + return; + } + if (loot instanceof DroppedItem droppedItem){ + if (ConfigManager.enableMcMMOLoot && Math.random() < ConfigManager.mcMMOLootChance){ + if (dropMcMMOLoot(player, item.getLocation(), bonus.getDoubleLoot() > Math.random())){ + return; + } + } + dropCustomFishingLoot(player, item.getLocation(), droppedItem, bonus.getDoubleLoot() > Math.random(), bonus.getScore()); + } + } + + private void noBarLavaReelIn(PlayerFishEvent event) { + final Player player = event.getPlayer(); + BobberCheckTask bobberCheckTask = bobberTaskCache.remove(player); + if (bobberCheckTask != null && bobberCheckTask.isHooked()) { + Loot loot = nextLoot.remove(player); + VanillaLoot vanilla = vanillaLoot.remove(player); + Bonus bonus = nextBonus.remove(player); + if (vanilla != null) { + dropVanillaLoot(player, vanilla, event.getHook().getLocation(), bonus.getDoubleLoot() > Math.random()); + return; + } + if (loot instanceof Mob mob) { + summonMob(player, loot, event.getHook().getLocation(), mob, bonus.getScore()); + return; + } + if (loot instanceof DroppedItem droppedItem){ + if (ConfigManager.enableMcMMOLoot && Math.random() < ConfigManager.mcMMOLootChance){ + if (dropMcMMOLoot(player, event.getHook().getLocation(), bonus.getDoubleLoot() > Math.random())){ + return; + } + } + dropCustomFishingLoot(player, event.getHook().getLocation(), droppedItem, bonus.getDoubleLoot() > Math.random(), bonus.getScore()); + } + } + } + private void proceedReelIn(PlayerFishEvent event, Player player, FishingPlayer fishingPlayer) { fishingPlayer.cancel(); Loot loot = nextLoot.remove(player); VanillaLoot vanilla = vanillaLoot.remove(player); player.removePotionEffect(PotionEffectType.SLOW); - if (fishingPlayer.isSuccess()) { if (ConfigManager.rodLoseDurability) loseDurability(player); Location location = event.getHook().getLocation(); @@ -421,12 +480,19 @@ public class FishingManager extends Function { public void onReelIn(PlayerFishEvent event) { final Player player = event.getPlayer(); + + if (ConfigManager.disableBar) { + noBarLavaReelIn(event); + return; + } + //in fishing FishingPlayer fishingPlayer = fishingPlayerCache.remove(player); if (fishingPlayer != null) { proceedReelIn(event, player, fishingPlayer); bobberTaskCache.remove(player); return; } + //not in fishing BobberCheckTask bobberCheckTask = bobberTaskCache.get(player); if (bobberCheckTask != null && bobberCheckTask.isHooked()) { showPlayerBar(player, nextLoot.get(player)); @@ -500,7 +566,7 @@ public class FishingManager extends Function { if (itemStack.getType() == Material.AIR) return; Entity item = location.getWorld().dropItem(location, itemStack); Vector vector = player.getLocation().subtract(location).toVector().multiply(0.1); - vector = vector.setY((vector.getY()+0.25) * 1.2); + vector = vector.setY((vector.getY()+0.18) * 1.15); item.setVelocity(vector); if (isDouble) { Entity item2 = location.getWorld().dropItem(location, itemStack); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 35abdc3d..e13c6af9 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,5 @@ # don't change -config-version: '11' +config-version: '12' # chinese/english/spanish lang: english @@ -48,6 +48,10 @@ worlds: # Mechanic settings mechanics: + + # Disable the fishing bar totally + disable-bar-mechanic: false + other-loots: # Should other loots have the same fishing mechanic CustomFishing provides # 其他战利品是否有插件提供的钓鱼特性 diff --git a/src/main/resources/sell-fish.yml b/src/main/resources/sell-fish.yml index 01e1677a..dcafc075 100644 --- a/src/main/resources/sell-fish.yml +++ b/src/main/resources/sell-fish.yml @@ -1,3 +1,5 @@ +# Fish got from command can't be sold! Only those from fishing would have special price NBT tags + container-title: 'Sell Fish' rows: 6