mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-21 16:09:34 +00:00
1.3.1.5
This commit is contained in:
13
build.gradle
13
build.gradle
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'net.momirealms'
|
group = 'net.momirealms'
|
||||||
version = '1.3.1.3'
|
version = '1.3.1.5'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {name = "aliyun-repo"; url = "https://maven.aliyun.com/repository/public/"}
|
maven {name = "aliyun-repo"; url = "https://maven.aliyun.com/repository/public/"}
|
||||||
@@ -17,6 +17,7 @@ repositories {
|
|||||||
maven {name = "jitpack-repo"; url = "https://jitpack.io"}
|
maven {name = "jitpack-repo"; url = "https://jitpack.io"}
|
||||||
maven {name = "Lumine-repo"; url = "https://mvn.lumine.io/repository/maven-public"}
|
maven {name = "Lumine-repo"; url = "https://mvn.lumine.io/repository/maven-public"}
|
||||||
maven {name = 'glaremasters-repo'; url = 'https://repo.glaremasters.me/repository/towny/'}
|
maven {name = 'glaremasters-repo'; url = 'https://repo.glaremasters.me/repository/towny/'}
|
||||||
|
maven {name = 'mmo-repo'; url = 'https://nexus.phoenixdevt.fr/repository/maven-public/'}
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,14 +37,16 @@ dependencies {
|
|||||||
compileOnly('org.mariadb.jdbc:mariadb-java-client:3.1.4')
|
compileOnly('org.mariadb.jdbc:mariadb-java-client:3.1.4')
|
||||||
compileOnly('com.google.code.gson:gson:2.10.1')
|
compileOnly('com.google.code.gson:gson:2.10.1')
|
||||||
compileOnly('com.willfp:EcoEnchants:10.13.0')
|
compileOnly('com.willfp:EcoEnchants:10.13.0')
|
||||||
|
compileOnly('net.Indyuce:MMOItems-API:6.9.2-SNAPSHOT')
|
||||||
|
//repo is private access
|
||||||
//compileOnly('com.willfp:EcoSkills:3.0.0-b2')
|
//compileOnly('com.willfp:EcoSkills:3.0.0-b2')
|
||||||
compileOnly('com.willfp:eco:6.60.0')
|
compileOnly('com.willfp:eco:6.60.0')
|
||||||
compileOnly('com.willfp:EcoJobs:3.13.0')
|
compileOnly('com.willfp:EcoJobs:3.13.0')
|
||||||
implementation('net.kyori:adventure-api:4.13.1')
|
implementation('net.kyori:adventure-api:4.14.0')
|
||||||
implementation('net.kyori:adventure-platform-bukkit:4.3.0')
|
implementation('net.kyori:adventure-platform-bukkit:4.3.0')
|
||||||
implementation('net.kyori:adventure-text-minimessage:4.13.1')
|
implementation('net.kyori:adventure-text-minimessage:4.14.0')
|
||||||
implementation('net.kyori:adventure-text-serializer-legacy:4.13.1')
|
implementation('net.kyori:adventure-text-serializer-legacy:4.14.0')
|
||||||
implementation('de.tr7zw:item-nbt-api:2.11.2')
|
implementation('de.tr7zw:item-nbt-api:2.11.3')
|
||||||
implementation('org.bstats:bstats-bukkit:3.0.1')
|
implementation('org.bstats:bstats-bukkit:3.0.1')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -2,11 +2,18 @@ package net.momirealms.customfishing.commands.subcmd;
|
|||||||
|
|
||||||
import net.momirealms.biomeapi.BiomeAPI;
|
import net.momirealms.biomeapi.BiomeAPI;
|
||||||
import net.momirealms.customfishing.CustomFishing;
|
import net.momirealms.customfishing.CustomFishing;
|
||||||
|
import net.momirealms.customfishing.api.CustomFishingAPI;
|
||||||
import net.momirealms.customfishing.commands.AbstractSubCommand;
|
import net.momirealms.customfishing.commands.AbstractSubCommand;
|
||||||
|
import net.momirealms.customfishing.fishing.Effect;
|
||||||
|
import net.momirealms.customfishing.fishing.loot.Loot;
|
||||||
import net.momirealms.customfishing.integration.SeasonInterface;
|
import net.momirealms.customfishing.integration.SeasonInterface;
|
||||||
|
import net.momirealms.customfishing.util.AdventureUtils;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DebugCommand extends AbstractSubCommand {
|
public class DebugCommand extends AbstractSubCommand {
|
||||||
@@ -36,6 +43,13 @@ public class DebugCommand extends AbstractSubCommand {
|
|||||||
if (seasonInterface == null) return true;
|
if (seasonInterface == null) return true;
|
||||||
sender.sendMessage(seasonInterface.getSeason(player.getLocation().getWorld()));
|
sender.sendMessage(seasonInterface.getSeason(player.getLocation().getWorld()));
|
||||||
}
|
}
|
||||||
|
case "loot-chance" -> {
|
||||||
|
Effect initial = CustomFishing.getInstance().getFishingManager().getInitialEffect(player);
|
||||||
|
List<String> lootProbability = getLootProbability(initial, CustomFishingAPI.getLootsAt(player.getLocation(), player));
|
||||||
|
for (String msg : lootProbability) {
|
||||||
|
AdventureUtils.playerMessage(player, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -44,8 +58,37 @@ public class DebugCommand extends AbstractSubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, List<String> args) {
|
public List<String> onTabComplete(CommandSender sender, List<String> args) {
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
return filterStartingWith(List.of("biome", "time", "world", "season"), args.get(0));
|
return filterStartingWith(List.of("biome", "time", "world", "season", "loot-chance"), args.get(0));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getLootProbability(Effect initialEffect, List<Loot> possibleLoots) {
|
||||||
|
List<Loot> availableLoots = new ArrayList<>();
|
||||||
|
HashMap<String, Integer> as = initialEffect.getWeightAS();
|
||||||
|
HashMap<String, Double> md = initialEffect.getWeightMD();
|
||||||
|
double[] weights = new double[possibleLoots.size()];
|
||||||
|
int index = 0;
|
||||||
|
for (Loot loot : possibleLoots){
|
||||||
|
double weight = loot.getWeight();
|
||||||
|
String group = loot.getGroup();
|
||||||
|
if (group != null){
|
||||||
|
if (as.get(group) != null){
|
||||||
|
weight += as.get(group);
|
||||||
|
}
|
||||||
|
if (md.get(group) != null){
|
||||||
|
weight *= md.get(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (weight <= 0) continue;
|
||||||
|
availableLoots.add(loot);
|
||||||
|
weights[index++] = weight;
|
||||||
|
}
|
||||||
|
ArrayList<String> lootWithChance = new ArrayList<>(availableLoots.size());
|
||||||
|
double total = Arrays.stream(weights).sum();
|
||||||
|
for (int i = 0; i < index; i++){
|
||||||
|
lootWithChance.add(availableLoots.get(i).getKey() + ": <gold>" + String.format("%.2f", weights[i]*100/total) + "%");
|
||||||
|
}
|
||||||
|
return lootWithChance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,12 +112,10 @@ public class BarMechanicManager extends Function {
|
|||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
ModeOneBar modeOneBar = new ModeOneBar(section);
|
ModeOneBar modeOneBar = new ModeOneBar(section);
|
||||||
bars.put(key, modeOneBar);
|
bars.put(key, modeOneBar);
|
||||||
}
|
} else if (type == 2) {
|
||||||
else if (type == 2) {
|
|
||||||
ModeTwoBar modeTwoBar = new ModeTwoBar(section);
|
ModeTwoBar modeTwoBar = new ModeTwoBar(section);
|
||||||
bars.put(key, modeTwoBar);
|
bars.put(key, modeTwoBar);
|
||||||
}
|
} else if (type == 3) {
|
||||||
else if (type == 3) {
|
|
||||||
ModeThreeBar modeThreeBar = new ModeThreeBar(section);
|
ModeThreeBar modeThreeBar = new ModeThreeBar(section);
|
||||||
bars.put(key, modeThreeBar);
|
bars.put(key, modeThreeBar);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public class EffectManager extends Function {
|
|||||||
baitItems.put(key, item);
|
baitItems.put(key, item);
|
||||||
Effect effect = ConfigUtils.getEffect(baitSection.getConfigurationSection("effect"));
|
Effect effect = ConfigUtils.getEffect(baitSection.getConfigurationSection("effect"));
|
||||||
if (baitSection.contains("requirements")) {
|
if (baitSection.contains("requirements")) {
|
||||||
effect.setRequirements(ConfigUtils.getRequirements(baitSection.getConfigurationSection("requirements")));
|
effect.setRequirements(ConfigUtils.getRequirementsWithMsg(baitSection.getConfigurationSection("requirements")));
|
||||||
}
|
}
|
||||||
baitEffects.put(key, effect);
|
baitEffects.put(key, effect);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1041,4 +1041,77 @@ public class FishingManager extends Function {
|
|||||||
for (Action action : droppedItem.getConsumeActions())
|
for (Action action : droppedItem.getConsumeActions())
|
||||||
action.doOn(player, null);
|
action.doOn(player, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Effect getInitialEffect(Player player) {
|
||||||
|
boolean noBait = true;
|
||||||
|
boolean rodOnMainHand = false;
|
||||||
|
|
||||||
|
Effect initialEffect = new Effect();
|
||||||
|
initialEffect.setWeightMD(new HashMap<>(8));
|
||||||
|
initialEffect.setWeightAS(new HashMap<>(8));
|
||||||
|
|
||||||
|
final PlayerInventory inventory = player.getInventory();
|
||||||
|
final ItemStack mainHandItem = inventory.getItemInMainHand();
|
||||||
|
final ItemStack offHandItem = inventory.getItemInOffHand();
|
||||||
|
|
||||||
|
if (mainHandItem.getType() == Material.FISHING_ROD) {
|
||||||
|
rodOnMainHand = true;
|
||||||
|
}
|
||||||
|
String rod_id = Optional.ofNullable(rodOnMainHand ? CustomFishingAPI.getRodID(mainHandItem) : CustomFishingAPI.getRodID(offHandItem)).orElse("vanilla");
|
||||||
|
final FishingCondition fishingCondition = new FishingCondition(player.getLocation(), player, rod_id, null);
|
||||||
|
|
||||||
|
String bait_id = Optional.ofNullable(rodOnMainHand ? CustomFishingAPI.getBaitID(offHandItem) : CustomFishingAPI.getBaitID(mainHandItem)).orElse("");
|
||||||
|
Effect baitEffect = plugin.getEffectManager().getBaitEffect(bait_id);
|
||||||
|
if (baitEffect != null && initialEffect.canAddEffect(baitEffect, fishingCondition)) {
|
||||||
|
initialEffect.addEffect(baitEffect);
|
||||||
|
noBait = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ActivatedTotem activatedTotem : activeTotemMap.values()) {
|
||||||
|
if (activatedTotem.getNearbyPlayerSet().contains(player)) {
|
||||||
|
initialEffect.addEffect(activatedTotem.getTotem().getEffect());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ConfigManager.enableFishingBag) {
|
||||||
|
Inventory fishingBag = plugin.getBagDataManager().getPlayerBagData(player.getUniqueId());
|
||||||
|
HashSet<String> uniqueUtils = new HashSet<>(4);
|
||||||
|
if (fishingBag != null) {
|
||||||
|
for (int i = 0; i < fishingBag.getSize(); i++) {
|
||||||
|
ItemStack itemStack = fishingBag.getItem(i);
|
||||||
|
if (itemStack == null || itemStack.getType() == Material.AIR) continue;
|
||||||
|
NBTCompound cfCompound = new NBTItem(itemStack).getCompound("CustomFishing");
|
||||||
|
if (cfCompound == null) continue;
|
||||||
|
String type = cfCompound.getString("type"); String id = cfCompound.getString("id");
|
||||||
|
if (noBait && type.equals("bait")) {
|
||||||
|
Effect effect = plugin.getEffectManager().getBaitEffect(id);
|
||||||
|
if (effect != null && itemStack.getAmount() > 0 && initialEffect.canAddEffect(effect, fishingCondition)) {
|
||||||
|
initialEffect.addEffect(effect);
|
||||||
|
noBait = false;
|
||||||
|
bait_id = id;
|
||||||
|
}
|
||||||
|
} else if (type.equals("util")) {
|
||||||
|
Effect utilEffect = plugin.getEffectManager().getUtilEffect(id);
|
||||||
|
if (utilEffect != null && !uniqueUtils.contains(id)) {
|
||||||
|
initialEffect.addEffect(utilEffect);
|
||||||
|
uniqueUtils.add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect rod_effect = plugin.getEffectManager().getRodEffect(rod_id);
|
||||||
|
if (rod_effect != null) {
|
||||||
|
if (initialEffect.canAddEffect(rod_effect, new FishingCondition(player.getLocation(), player, rod_id, bait_id))) {
|
||||||
|
initialEffect.addEffect(rod_effect);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
initialEffect.setSpecialRodID(rod_id);
|
||||||
|
}
|
||||||
|
this.addEnchantEffect(initialEffect, rodOnMainHand ? mainHandItem : offHandItem, fishingCondition);
|
||||||
|
return initialEffect;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -118,17 +118,15 @@ public class LootManager extends Function {
|
|||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (!file.getName().endsWith(".yml")) continue;
|
if (!file.getName().endsWith(".yml")) continue;
|
||||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
|
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||||
outer:
|
for (String key : config.getKeys(false)) {
|
||||||
for (String key : config.getKeys(false)) {
|
List<String> fishIDs = config.getStringList(key);
|
||||||
List<String> fishIDs = config.getStringList(key);
|
for (String id : fishIDs) {
|
||||||
for (String id : fishIDs) {
|
if (!waterLoots.containsKey(id) && !lavaLoots.containsKey(id)) {
|
||||||
if (!waterLoots.containsKey(id) && !lavaLoots.containsKey(id)) {
|
AdventureUtils.consoleMessage("<red>[CustomFishing] Loot ID " + id + " doesn't exist in category " + key);
|
||||||
AdventureUtils.consoleMessage("<red>[CustomFishing] Fish ID " + id + " doesn't exist in category " + key);
|
|
||||||
continue outer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
category.put(key, fishIDs);
|
|
||||||
}
|
}
|
||||||
|
category.put(key, fishIDs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,9 +33,13 @@ magnet_bait:
|
|||||||
gold: 1.15
|
gold: 1.15
|
||||||
# https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customfishing/requirements
|
# https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customfishing/requirements
|
||||||
requirements:
|
requirements:
|
||||||
permission: magnet_bait.use
|
requirement_1:
|
||||||
rod:
|
type: permission
|
||||||
- nature_fishing_cane
|
value: magnet_bait.use
|
||||||
- silver_fishing_rod
|
requirement_2:
|
||||||
- golden_fishing_rod
|
type: rod
|
||||||
- star_fishing_rod
|
value:
|
||||||
|
- nature_fishing_cane
|
||||||
|
- silver_fishing_rod
|
||||||
|
- golden_fishing_rod
|
||||||
|
- star_fishing_rod
|
||||||
Reference in New Issue
Block a user