mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2026-01-03 22:26:15 +00:00
1.1
This commit is contained in:
@@ -97,12 +97,15 @@ public class ConfigReader{
|
||||
public static boolean doubleRealIn;
|
||||
public static boolean vanillaLoot;
|
||||
public static boolean showBar;
|
||||
public static boolean mcMMOLoot;
|
||||
public static int fishFinderCoolDown;
|
||||
public static double timeMultiply;
|
||||
public static double vanillaRatio;
|
||||
public static double mcMMOLootChance;
|
||||
public static SkillXP skillXP;
|
||||
public static String version;
|
||||
public static String lang;
|
||||
public static String priority;
|
||||
public static SeasonInterface season;
|
||||
|
||||
public static void loadConfig() {
|
||||
@@ -178,8 +181,14 @@ public class ConfigReader{
|
||||
}
|
||||
|
||||
doubleRealIn = config.getBoolean("config.double-reel-in", true);
|
||||
vanillaLoot = config.getBoolean("config.vanilla-loot.enable", true);
|
||||
showBar = config.getBoolean("config.vanilla-loot.bar", true);
|
||||
|
||||
mcMMOLoot = config.getBoolean("config.other-loot.mcMMO", false);
|
||||
mcMMOLootChance = config.getDouble("config.other-loot.mcMMO-chance", 0.5);
|
||||
|
||||
vanillaLoot = config.getBoolean("config.other-loot.vanilla", true);
|
||||
showBar = config.getBoolean("config.other-loot.bar", true);
|
||||
vanillaRatio = config.getDouble("config.other-loot.vanilla-ratio");
|
||||
|
||||
convertMMOItems = config.getBoolean("config.convert-MMOITEMS", false);
|
||||
needOpenWater = config.getBoolean("config.need-open-water", false);
|
||||
needSpecialRod = config.getBoolean("config.need-special-rod", false);
|
||||
@@ -187,9 +196,9 @@ public class ConfigReader{
|
||||
preventPick = config.getBoolean("config.prevent-other-players-pick-up-loot", false);
|
||||
|
||||
version = config.getString("config-version");
|
||||
priority = config.getString("config.event-priority");
|
||||
fishFinderCoolDown = config.getInt("config.fishfinder-cooldown");
|
||||
timeMultiply = config.getDouble("config.time-multiply");
|
||||
vanillaRatio = config.getDouble("config.vanilla-loot.ratio");
|
||||
lang = config.getString("config.lang","cn");
|
||||
competition = config.getBoolean("config.fishing-competition",true);
|
||||
}
|
||||
@@ -734,7 +743,7 @@ public class ConfigReader{
|
||||
case "weight-MQ" -> {
|
||||
HashMap<String, Double> mq = new HashMap<>();
|
||||
config.getConfigurationSection(key + ".modifier.weight-MQ").getValues(false).forEach((group, value) -> {
|
||||
mq.put(group, Double.valueOf(String.valueOf(value)));
|
||||
mq.put(group, Double.parseDouble(String.valueOf(value))-1);
|
||||
});
|
||||
bonus.setWeightMQ(mq);
|
||||
}
|
||||
@@ -820,7 +829,7 @@ public class ConfigReader{
|
||||
case "weight-MQ" -> {
|
||||
HashMap<String, Double> mq = new HashMap<>();
|
||||
config.getConfigurationSection(key + ".modifier.weight-MQ").getValues(false).forEach((group, value) -> {
|
||||
mq.put(group, Double.valueOf(String.valueOf(value)));
|
||||
mq.put(group, Double.parseDouble(String.valueOf(value))-1);
|
||||
});
|
||||
bonus.setWeightMQ(mq);
|
||||
}
|
||||
@@ -947,7 +956,7 @@ public class ConfigReader{
|
||||
case "weight-MQ" -> {
|
||||
HashMap<String, Double> mq = new HashMap<>();
|
||||
config.getConfigurationSection(key + "." + level + ".weight-MQ").getValues(false).forEach((group, value) -> {
|
||||
mq.put(group, Double.valueOf(String.valueOf(value)));
|
||||
mq.put(group, Double.parseDouble(String.valueOf(value))-1);
|
||||
});
|
||||
bonus.setWeightMQ(mq);
|
||||
}
|
||||
|
||||
@@ -24,11 +24,9 @@ import net.momirealms.customfishing.command.TabComplete;
|
||||
import net.momirealms.customfishing.competition.CompetitionSchedule;
|
||||
import net.momirealms.customfishing.competition.bossbar.BossBarManager;
|
||||
import net.momirealms.customfishing.helper.LibraryLoader;
|
||||
import net.momirealms.customfishing.hook.McMMOTreasure;
|
||||
import net.momirealms.customfishing.hook.Placeholders;
|
||||
import net.momirealms.customfishing.listener.MMOItemsConverter;
|
||||
import net.momirealms.customfishing.listener.PapiUnregister;
|
||||
import net.momirealms.customfishing.listener.PickUpListener;
|
||||
import net.momirealms.customfishing.listener.FishListener;
|
||||
import net.momirealms.customfishing.listener.*;
|
||||
import net.momirealms.customfishing.utils.AdventureUtil;
|
||||
import net.momirealms.customfishing.utils.ConfigUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -84,7 +82,7 @@ public final class CustomFishing extends JavaPlugin {
|
||||
});
|
||||
}
|
||||
ConfigReader.tryEnableJedis();
|
||||
if (!Objects.equals(ConfigReader.Config.version, "5")){
|
||||
if (!Objects.equals(ConfigReader.Config.version, "6")){
|
||||
ConfigUtil.update();
|
||||
}
|
||||
if (ConfigReader.Config.preventPick){
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
package net.momirealms.customfishing.hook;
|
||||
|
||||
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasureBook;
|
||||
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class McMMOTreasure {
|
||||
|
||||
/*
|
||||
these codes are partly from mcMMO, because of the cancelled event limitation
|
||||
Plugin has to get the loot in a raw way
|
||||
*/
|
||||
public static ItemStack getTreasure(Player player){
|
||||
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
|
||||
FishingTreasure treasure = getFishingTreasure(player, fishingManager.getLootTier());
|
||||
ItemStack treasureDrop;
|
||||
if (treasure != null) {
|
||||
if(treasure instanceof FishingTreasureBook) {
|
||||
treasureDrop = ItemUtils.createEnchantBook((FishingTreasureBook) treasure);
|
||||
} else {
|
||||
treasureDrop = treasure.getDrop().clone();
|
||||
}
|
||||
Map<Enchantment, Integer> enchants = new HashMap<>();
|
||||
if(treasure instanceof FishingTreasureBook) {
|
||||
if(treasureDrop.getItemMeta() != null) {
|
||||
enchants = new HashMap<>(treasureDrop.getItemMeta().getEnchants());
|
||||
}
|
||||
} else {
|
||||
if (isMagicHunterEnabled(player) && ItemUtils.isEnchantable(treasureDrop)) {
|
||||
enchants = processMagicHunter(treasureDrop, fishingManager.getLootTier());
|
||||
}
|
||||
}
|
||||
if (!enchants.isEmpty()) {
|
||||
treasureDrop.addUnsafeEnchantments(enchants);
|
||||
}
|
||||
return treasureDrop;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isMagicHunterEnabled(Player player) {
|
||||
return RankUtils.hasUnlockedSubskill(player, SubSkillType.FISHING_MAGIC_HUNTER)
|
||||
&& RankUtils.hasUnlockedSubskill(player, SubSkillType.FISHING_TREASURE_HUNTER)
|
||||
&& Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_TREASURE_HUNTER);
|
||||
}
|
||||
|
||||
private static Map<Enchantment, Integer> processMagicHunter(@NotNull ItemStack treasureDrop, int tier) {
|
||||
Map<Enchantment, Integer> enchants = new HashMap<>();
|
||||
List<EnchantmentTreasure> fishingEnchantments = null;
|
||||
|
||||
double diceRoll = Misc.getRandom().nextDouble() * 100;
|
||||
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
|
||||
double dropRate = FishingTreasureConfig.getInstance().getEnchantmentDropRate(tier, rarity);
|
||||
|
||||
if (diceRoll <= dropRate) {
|
||||
|
||||
if (treasureDrop.getType() == Material.ENCHANTED_BOOK) {
|
||||
diceRoll = dropRate + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
fishingEnchantments = FishingTreasureConfig.getInstance().fishingEnchantments.get(rarity);
|
||||
break;
|
||||
}
|
||||
|
||||
diceRoll -= dropRate;
|
||||
}
|
||||
|
||||
if (fishingEnchantments == null) {
|
||||
return enchants;
|
||||
}
|
||||
|
||||
Collections.shuffle(fishingEnchantments, Misc.getRandom());
|
||||
|
||||
int specificChance = 1;
|
||||
|
||||
for (EnchantmentTreasure enchantmentTreasure : fishingEnchantments) {
|
||||
Enchantment possibleEnchantment = enchantmentTreasure.getEnchantment();
|
||||
|
||||
if (treasureDrop.getItemMeta().hasConflictingEnchant(possibleEnchantment) || Misc.getRandom().nextInt(specificChance) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
enchants.put(possibleEnchantment, enchantmentTreasure.getLevel());
|
||||
|
||||
specificChance *= 2;
|
||||
}
|
||||
|
||||
return enchants;
|
||||
}
|
||||
|
||||
private static @Nullable FishingTreasure getFishingTreasure(Player player, int tier) {
|
||||
double diceRoll = Misc.getRandom().nextDouble() * 100;
|
||||
int luck;
|
||||
|
||||
if (player.getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) {
|
||||
luck = player.getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK);
|
||||
}
|
||||
else {
|
||||
luck = player.getInventory().getItemInOffHand().getEnchantmentLevel(Enchantment.LUCK);
|
||||
}
|
||||
|
||||
diceRoll *= (1.0 - luck * mcMMO.p.getGeneralConfig().getFishingLureModifier() / 100);
|
||||
|
||||
FishingTreasure treasure = null;
|
||||
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
|
||||
double dropRate = FishingTreasureConfig.getInstance().getItemDropRate(tier, rarity);
|
||||
|
||||
if (diceRoll <= dropRate) {
|
||||
|
||||
List<FishingTreasure> fishingTreasures = FishingTreasureConfig.getInstance().fishingRewards.get(rarity);
|
||||
|
||||
if (fishingTreasures.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
treasure = fishingTreasures.get(Misc.getRandom().nextInt(fishingTreasures.size()));
|
||||
break;
|
||||
}
|
||||
|
||||
diceRoll -= dropRate;
|
||||
}
|
||||
|
||||
if (treasure == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack treasureDrop = treasure.getDrop().clone();
|
||||
short maxDurability = treasureDrop.getType().getMaxDurability();
|
||||
|
||||
if (maxDurability > 0) {
|
||||
treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability)));
|
||||
}
|
||||
|
||||
treasure.setDrop(treasureDrop);
|
||||
|
||||
return treasure;
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
@@ -68,13 +69,35 @@ public class FishListener implements Listener {
|
||||
private final HashMap<Player, VanillaLoot> vanilla = new HashMap<>();
|
||||
public static ConcurrentHashMap<Player, FishingPlayer> fishingPlayers = new ConcurrentHashMap<>();
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onFishHighest(PlayerFishEvent event){
|
||||
if (ConfigReader.Config.priority.equals("HIGHEST")){
|
||||
onFish(event);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onFishNormal(PlayerFishEvent event){
|
||||
if (ConfigReader.Config.priority.equals("NORMAL")){
|
||||
onFish(event);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onFishLowest(PlayerFishEvent event){
|
||||
if (ConfigReader.Config.priority.equals("LOWEST")){
|
||||
onFish(event);
|
||||
}
|
||||
}
|
||||
|
||||
public void onFish(PlayerFishEvent event){
|
||||
|
||||
PlayerFishEvent.State state = event.getState();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (state.equals(PlayerFishEvent.State.FISHING)){
|
||||
switch (state){
|
||||
|
||||
case FISHING ->{
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
if (time - (coolDown.getOrDefault(player, time - 2000)) < 2000) {
|
||||
@@ -120,12 +143,12 @@ public class FishListener implements Listener {
|
||||
pm.put(group, Optional.ofNullable(pm.get(group)).orElse(0) + weightPM.get(group));
|
||||
}
|
||||
}
|
||||
HashMap<String, Integer> weightMQ = enchantBonus.getWeightPM();
|
||||
HashMap<String, Double> weightMQ = enchantBonus.getWeightMQ();
|
||||
if (weightMQ != null){
|
||||
Object[] bonus = weightMQ.keySet().toArray();
|
||||
for (Object value : bonus) {
|
||||
String group = (String) value;
|
||||
mq.put(group, Optional.ofNullable(mq.get(group)).orElse(0d) + weightMQ.get(group));
|
||||
mq.put(group, Optional.ofNullable(mq.get(group)).orElse(1d) + weightMQ.get(group));
|
||||
}
|
||||
}
|
||||
if (enchantBonus.getTime() != 0) timeModifier *= enchantBonus.getTime();
|
||||
@@ -151,12 +174,12 @@ public class FishListener implements Listener {
|
||||
pm.put(group, Optional.ofNullable(pm.get(group)).orElse(0) + weightPM.get(group));
|
||||
}
|
||||
}
|
||||
HashMap<String, Integer> weightMQ = rod.getWeightPM();
|
||||
HashMap<String, Double> weightMQ = rod.getWeightMQ();
|
||||
if (weightMQ != null){
|
||||
Object[] bonus = weightMQ.keySet().toArray();
|
||||
for (Object value : bonus) {
|
||||
String group = (String) value;
|
||||
mq.put(group, Optional.ofNullable(mq.get(group)).orElse(0d) + weightMQ.get(group));
|
||||
mq.put(group, Optional.ofNullable(mq.get(group)).orElse(1d) + weightMQ.get(group));
|
||||
}
|
||||
}
|
||||
if (rod.getTime() != 0) timeModifier *= rod.getTime();
|
||||
@@ -178,12 +201,12 @@ public class FishListener implements Listener {
|
||||
pm.put(group, Optional.ofNullable(pm.get(group)).orElse(0) + weightPM.get(group));
|
||||
}
|
||||
}
|
||||
HashMap<String, Integer> weightMQ = bait.getWeightPM();
|
||||
HashMap<String, Double> weightMQ = bait.getWeightMQ();
|
||||
if (weightMQ != null){
|
||||
Object[] bonus = weightMQ.keySet().toArray();
|
||||
for (Object value : bonus) {
|
||||
String group = (String) value;
|
||||
mq.put(group, Optional.ofNullable(mq.get(group)).orElse(0d) + weightMQ.get(group));
|
||||
mq.put(group, Optional.ofNullable(mq.get(group)).orElse(1d) + weightMQ.get(group));
|
||||
}
|
||||
}
|
||||
if (bait.getTime() != 0) timeModifier *= bait.getTime();
|
||||
@@ -216,12 +239,12 @@ public class FishListener implements Listener {
|
||||
pm.put(group, Optional.ofNullable(pm.get(group)).orElse(0) + weightPM.get(group));
|
||||
}
|
||||
}
|
||||
HashMap<String, Integer> weightMQ = enchantBonus.getWeightPM();
|
||||
HashMap<String, Double> weightMQ = enchantBonus.getWeightMQ();
|
||||
if (weightMQ != null){
|
||||
Object[] bonus = weightMQ.keySet().toArray();
|
||||
for (Object value : bonus) {
|
||||
String group = (String) value;
|
||||
mq.put(group, Optional.ofNullable(mq.get(group)).orElse(0d) + weightMQ.get(group));
|
||||
mq.put(group, Optional.ofNullable(mq.get(group)).orElse(1d) + weightMQ.get(group));
|
||||
}
|
||||
}
|
||||
if (enchantBonus.getTime() != 0) timeModifier *= enchantBonus.getTime();
|
||||
@@ -247,12 +270,12 @@ public class FishListener implements Listener {
|
||||
pm.put(group, Optional.ofNullable(pm.get(group)).orElse(0) + weightPM.get(group));
|
||||
}
|
||||
}
|
||||
HashMap<String, Integer> weightMQ = bait.getWeightPM();
|
||||
HashMap<String, Double> weightMQ = bait.getWeightMQ();
|
||||
if (weightMQ != null){
|
||||
Object[] bonus = weightMQ.keySet().toArray();
|
||||
for (Object value : bonus) {
|
||||
String group = (String) value;
|
||||
mq.put(group, Optional.ofNullable(mq.get(group)).orElse(0d) + weightMQ.get(group));
|
||||
mq.put(group, Optional.ofNullable(mq.get(group)).orElse(1d) + weightMQ.get(group));
|
||||
}
|
||||
}
|
||||
if (bait.getTime() != 0) timeModifier *= bait.getTime();
|
||||
@@ -274,12 +297,12 @@ public class FishListener implements Listener {
|
||||
pm.put(group, Optional.ofNullable(pm.get(group)).orElse(0) + weightPM.get(group));
|
||||
}
|
||||
}
|
||||
HashMap<String, Integer> weightMQ = rod.getWeightPM();
|
||||
HashMap<String, Double> weightMQ = rod.getWeightMQ();
|
||||
if (weightMQ != null){
|
||||
Object[] bonus = weightMQ.keySet().toArray();
|
||||
for (Object value : bonus) {
|
||||
String group = (String) value;
|
||||
mq.put(group, Optional.ofNullable(mq.get(group)).orElse(0d) + weightMQ.get(group));
|
||||
mq.put(group, Optional.ofNullable(mq.get(group)).orElse(1d) + weightMQ.get(group));
|
||||
}
|
||||
}
|
||||
if (rod.getTime() != 0) timeModifier *= rod.getTime();
|
||||
@@ -317,7 +340,6 @@ public class FishListener implements Listener {
|
||||
modifier.setWillDouble(doubleLoot > Math.random());
|
||||
modifiers.put(player, modifier);
|
||||
|
||||
|
||||
double[] weights = new double[possibleLoots.size()];
|
||||
int index = 0;
|
||||
for (Loot loot : possibleLoots){
|
||||
@@ -365,54 +387,14 @@ public class FishListener implements Listener {
|
||||
nextLoot.put(player, null);
|
||||
});
|
||||
}
|
||||
|
||||
else if (state.equals(PlayerFishEvent.State.BITE)){
|
||||
|
||||
if (ConfigReader.Config.doubleRealIn) return;
|
||||
|
||||
if (fishingPlayers.get(player) != null) return;
|
||||
|
||||
Loot loot = nextLoot.get(player);
|
||||
|
||||
if (loot == null) return;
|
||||
|
||||
String layout;
|
||||
if (loot.getLayout() != null){
|
||||
layout = loot.getLayout().get((int) (loot.getLayout().size() * Math.random()));
|
||||
}else {
|
||||
Object[] values = ConfigReader.LAYOUT.keySet().toArray();
|
||||
layout = (String) values[new Random().nextInt(values.length)];
|
||||
}
|
||||
|
||||
int difficulty = loot.getDifficulty().getSpeed();
|
||||
difficulty += Objects.requireNonNullElse(modifiers.get(player).getDifficulty(), 0);;
|
||||
if (difficulty < 1){
|
||||
difficulty = 1;
|
||||
}
|
||||
|
||||
Difficulty difficult = new Difficulty(loot.getDifficulty().getTimer(), difficulty);
|
||||
fishingPlayers.put(player,
|
||||
new FishingPlayer(System.currentTimeMillis() + loot.getTime(),
|
||||
new Timer(player, difficult, layout)
|
||||
)
|
||||
);
|
||||
|
||||
for (ActionB action : loot.getHookActions()){
|
||||
action.doOn(player);
|
||||
}
|
||||
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, loot.getTime()/50,3));
|
||||
|
||||
}
|
||||
|
||||
//收杆拉鱼
|
||||
else if (state.equals(PlayerFishEvent.State.CAUGHT_FISH)) {
|
||||
|
||||
case CAUGHT_FISH -> {
|
||||
//是否需要两次拉杆
|
||||
if (ConfigReader.Config.doubleRealIn) {
|
||||
|
||||
FishingPlayer fishingPlayer = fishingPlayers.remove(player);
|
||||
|
||||
if (fishingPlayer == null){
|
||||
|
||||
Entity entity = event.getCaught();
|
||||
if (entity instanceof Item item){
|
||||
//是否有原版战利品
|
||||
@@ -448,12 +430,14 @@ public class FishListener implements Listener {
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Entity entity = event.getCaught();
|
||||
if (entity instanceof Item item){
|
||||
item.remove();
|
||||
event.setExpToDrop(0);
|
||||
}
|
||||
Loot loot = nextLoot.remove(player);
|
||||
|
||||
VanillaLoot vanillaLoot = vanilla.remove(player);
|
||||
Timer timer = fishingPlayer.getTimer();
|
||||
Layout layout = ConfigReader.LAYOUT.get(timer.getLayout());
|
||||
@@ -470,68 +454,19 @@ public class FishListener implements Listener {
|
||||
loseDurability(player);
|
||||
Location location = event.getHook().getLocation();
|
||||
if (loot instanceof Mob mob){
|
||||
MythicMobsUtil.summonMM(player.getLocation(), location, mob);
|
||||
for (ActionB action : loot.getSuccessActions())
|
||||
action.doOn(player);
|
||||
if (CompetitionSchedule.competition != null && CompetitionSchedule.competition.isGoingOn()) {
|
||||
float score = (float) (loot.getScore() * modifiers.get(player).getScore());
|
||||
CompetitionSchedule.competition.refreshRanking(player.getName(), score);
|
||||
BossBarManager.joinCompetition(player);
|
||||
}
|
||||
summonMob(player, loot, location, mob);
|
||||
}
|
||||
else if (loot instanceof DroppedItem droppedItem){
|
||||
ItemStack itemStack;
|
||||
if (vanillaLoot != null) {
|
||||
itemStack = vanillaLoot.getItemStack();
|
||||
player.giveExp(vanillaLoot.getXp(), true);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1,1);
|
||||
Entity item = location.getWorld().dropItem(location, itemStack);
|
||||
Vector vector = player.getLocation().subtract(location).toVector().multiply(0.1);
|
||||
vector = vector.setY((vector.getY()+0.2)*1.2);
|
||||
item.setVelocity(vector);
|
||||
if (CompetitionSchedule.competition != null && CompetitionSchedule.competition.isGoingOn()) {
|
||||
CompetitionSchedule.competition.refreshRanking(player.getName(), 0);
|
||||
BossBarManager.joinCompetition(player);
|
||||
dropVanillaLoot(player, vanillaLoot, location);
|
||||
}
|
||||
if (modifiers.get(player).isWillDouble()) {
|
||||
Entity item2 = location.getWorld().dropItem(location, itemStack);
|
||||
item2.setVelocity(vector);
|
||||
else if (ConfigReader.Config.mcMMOLoot && Math.random() < ConfigReader.Config.mcMMOLootChance){
|
||||
if(dropMcMMOLoot(player, location)){
|
||||
dropMyLoot(player, loot, location, droppedItem);
|
||||
}
|
||||
String title = ConfigReader.Title.success_title.get((int) (ConfigReader.Title.success_title.size()*Math.random()));
|
||||
Component titleComponent = getTitleComponent(itemStack, title);
|
||||
String subTitle = ConfigReader.Title.success_subtitle.get((int) (ConfigReader.Title.success_subtitle.size()*Math.random()));
|
||||
Component subtitleComponent = getTitleComponent(itemStack, subTitle);
|
||||
|
||||
AdventureUtil.playerTitle(
|
||||
player,
|
||||
titleComponent,
|
||||
subtitleComponent,
|
||||
ConfigReader.Title.success_in,
|
||||
ConfigReader.Title.success_stay,
|
||||
ConfigReader.Title.success_out
|
||||
);
|
||||
}
|
||||
else {
|
||||
if (CompetitionSchedule.competition != null && CompetitionSchedule.competition.isGoingOn()) {
|
||||
float score = (float) (loot.getScore() * modifiers.get(player).getScore());
|
||||
CompetitionSchedule.competition.refreshRanking(player.getName(), score);
|
||||
BossBarManager.joinCompetition(player);
|
||||
}
|
||||
for (ActionB action : loot.getSuccessActions())
|
||||
action.doOn(player);
|
||||
dropLoot(player, location, droppedItem);
|
||||
AdventureUtil.playerTitle(
|
||||
player,
|
||||
ConfigReader.Title.success_title.get((int) (ConfigReader.Title.success_title.size()*Math.random()))
|
||||
.replace("{loot}",loot.getNick())
|
||||
.replace("{player}", player.getName()),
|
||||
ConfigReader.Title.success_subtitle.get((int) (ConfigReader.Title.success_subtitle.size()*Math.random()))
|
||||
.replace("{loot}",loot.getNick())
|
||||
.replace("{player}", player.getName()),
|
||||
ConfigReader.Title.success_in,
|
||||
ConfigReader.Title.success_stay,
|
||||
ConfigReader.Title.success_out
|
||||
);
|
||||
dropMyLoot(player, loot, location, droppedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -573,12 +508,16 @@ public class FishListener implements Listener {
|
||||
MythicMobsUtil.summonMM(player.getLocation(), location, mob);
|
||||
}
|
||||
else if (loot instanceof DroppedItem droppedItem){
|
||||
if (ConfigReader.Config.mcMMOLoot && ConfigReader.Config.mcMMOLootChance > Math.random()){
|
||||
if (dropMcMMOLoot(player, location)){
|
||||
dropLoot(player, location, droppedItem);
|
||||
}
|
||||
}else {
|
||||
dropLoot(player, location, droppedItem);
|
||||
}
|
||||
}
|
||||
for (ActionB action : loot.getSuccessActions())
|
||||
action.doOn(player);
|
||||
if (ConfigReader.Config.loseDurability)
|
||||
loseDurability(player);
|
||||
if (CompetitionSchedule.competition != null && CompetitionSchedule.competition.isGoingOn()){
|
||||
float score = (float) (loot.getScore() * modifiers.get(player).getScore());
|
||||
CompetitionSchedule.competition.refreshRanking(player.getName(), score);
|
||||
@@ -596,6 +535,8 @@ public class FishListener implements Listener {
|
||||
ConfigReader.Title.success_stay,
|
||||
ConfigReader.Title.success_out
|
||||
);
|
||||
if (ConfigReader.Config.loseDurability)
|
||||
loseDurability(player);
|
||||
}
|
||||
//捕鱼失败
|
||||
else {
|
||||
@@ -611,11 +552,15 @@ public class FishListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//普通收杆
|
||||
//对于在Vanilla HashMap中有值的,说明是有原版战利品,否则全部是插件战利品
|
||||
else if (state.equals(PlayerFishEvent.State.REEL_IN)){
|
||||
|
||||
case CAUGHT_ENTITY -> {
|
||||
//理论是不存在实体的
|
||||
//说明在钓鱼的时候可能鱼钩勾上了鱿鱼之类的生物
|
||||
//直接按照失败处理
|
||||
if (fishingPlayers.remove(player) != null && event.getCaught() != null){
|
||||
AdventureUtil.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.hookOther);
|
||||
}
|
||||
}
|
||||
case REEL_IN -> {
|
||||
FishingPlayer fishingPlayer = fishingPlayers.remove(player);
|
||||
//首先得是钓鱼中的玩家
|
||||
if (fishingPlayer != null){
|
||||
@@ -633,74 +578,24 @@ public class FishListener implements Listener {
|
||||
}
|
||||
|
||||
if (Math.random() < layout.getSuccessRate()[last]){
|
||||
//这里是普通收杆,需要减少耐久度
|
||||
if (ConfigReader.Config.loseDurability)
|
||||
loseDurability(player);
|
||||
Location location = event.getHook().getLocation();
|
||||
if (loot instanceof Mob mob){
|
||||
MythicMobsUtil.summonMM(player.getLocation(), location, mob);
|
||||
for (ActionB action : loot.getSuccessActions())
|
||||
action.doOn(player);
|
||||
if (CompetitionSchedule.competition != null && CompetitionSchedule.competition.isGoingOn()) {
|
||||
float score = (float) (loot.getScore() * modifiers.get(player).getScore());
|
||||
CompetitionSchedule.competition.refreshRanking(player.getName(), score);
|
||||
BossBarManager.joinCompetition(player);
|
||||
}
|
||||
summonMob(player, loot, location, mob);
|
||||
}
|
||||
else if (loot instanceof DroppedItem droppedItem){
|
||||
ItemStack itemStack;
|
||||
|
||||
if (vanillaLoot != null) {
|
||||
itemStack = vanillaLoot.getItemStack();
|
||||
player.giveExp(vanillaLoot.getXp(), true);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1,1);
|
||||
Entity item = location.getWorld().dropItem(location, itemStack);
|
||||
Vector vector = player.getLocation().subtract(location).toVector().multiply(0.1);
|
||||
vector = vector.setY((vector.getY()+0.2)*1.2);
|
||||
item.setVelocity(vector);
|
||||
if (CompetitionSchedule.competition != null && CompetitionSchedule.competition.isGoingOn()) {
|
||||
CompetitionSchedule.competition.refreshRanking(player.getName(), 0);
|
||||
BossBarManager.joinCompetition(player);
|
||||
dropVanillaLoot(player, vanillaLoot, location);
|
||||
}
|
||||
if (modifiers.get(player).isWillDouble()) {
|
||||
Entity item2 = location.getWorld().dropItem(location, itemStack);
|
||||
item2.setVelocity(vector);
|
||||
else if (ConfigReader.Config.mcMMOLoot && Math.random() < ConfigReader.Config.mcMMOLootChance){
|
||||
if (dropMcMMOLoot(player, location)){
|
||||
dropMyLoot(player, loot, location, droppedItem);
|
||||
}
|
||||
|
||||
String title = ConfigReader.Title.success_title.get((int) (ConfigReader.Title.success_title.size()*Math.random()));
|
||||
Component titleComponent = getTitleComponent(itemStack, title);
|
||||
String subTitle = ConfigReader.Title.success_subtitle.get((int) (ConfigReader.Title.success_subtitle.size()*Math.random()));
|
||||
Component subtitleComponent = getTitleComponent(itemStack, subTitle);
|
||||
|
||||
AdventureUtil.playerTitle(
|
||||
player,
|
||||
titleComponent,
|
||||
subtitleComponent,
|
||||
ConfigReader.Title.success_in,
|
||||
ConfigReader.Title.success_stay,
|
||||
ConfigReader.Title.success_out
|
||||
);
|
||||
}
|
||||
else {
|
||||
if (CompetitionSchedule.competition != null && CompetitionSchedule.competition.isGoingOn()) {
|
||||
float score = (float) (loot.getScore() * modifiers.get(player).getScore());
|
||||
CompetitionSchedule.competition.refreshRanking(player.getName(), score);
|
||||
BossBarManager.joinCompetition(player);
|
||||
}
|
||||
for (ActionB action : loot.getSuccessActions())
|
||||
action.doOn(player);
|
||||
dropLoot(player, location, droppedItem);
|
||||
AdventureUtil.playerTitle(
|
||||
player,
|
||||
ConfigReader.Title.success_title.get((int) (ConfigReader.Title.success_title.size()*Math.random()))
|
||||
.replace("{loot}",loot.getNick())
|
||||
.replace("{player}", player.getName()),
|
||||
ConfigReader.Title.success_subtitle.get((int) (ConfigReader.Title.success_subtitle.size()*Math.random()))
|
||||
.replace("{loot}",loot.getNick())
|
||||
.replace("{player}", player.getName()),
|
||||
ConfigReader.Title.success_in,
|
||||
ConfigReader.Title.success_stay,
|
||||
ConfigReader.Title.success_out
|
||||
);
|
||||
dropMyLoot(player, loot, location, droppedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -720,9 +615,9 @@ public class FishListener implements Listener {
|
||||
vanilla.put(player, new VanillaLoot(item.getItemStack(), event.getExpToDrop()));
|
||||
showPlayerBar(player);
|
||||
}
|
||||
else {
|
||||
//啥也不干
|
||||
}
|
||||
// else {
|
||||
// //啥也不干
|
||||
// }
|
||||
}
|
||||
//不允许原版掉落物
|
||||
else {
|
||||
@@ -733,16 +628,175 @@ public class FishListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (state.equals(PlayerFishEvent.State.CAUGHT_ENTITY)){
|
||||
//理论是不存在实体的
|
||||
//说明在钓鱼的时候可能鱼钩勾上了鱿鱼之类的生物
|
||||
//直接按照失败处理
|
||||
if (fishingPlayers.remove(player) != null && event.getCaught() != null){
|
||||
AdventureUtil.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.hookOther);
|
||||
case BITE -> {
|
||||
if (ConfigReader.Config.doubleRealIn) return;
|
||||
|
||||
if (fishingPlayers.get(player) != null) return;
|
||||
|
||||
Loot loot = nextLoot.get(player);
|
||||
|
||||
if (loot == null) return;
|
||||
|
||||
String layout;
|
||||
if (loot.getLayout() != null){
|
||||
layout = loot.getLayout().get((int) (loot.getLayout().size() * Math.random()));
|
||||
}else {
|
||||
Object[] values = ConfigReader.LAYOUT.keySet().toArray();
|
||||
layout = (String) values[new Random().nextInt(values.length)];
|
||||
}
|
||||
|
||||
int difficulty = loot.getDifficulty().getSpeed();
|
||||
difficulty += Objects.requireNonNullElse(modifiers.get(player).getDifficulty(), 0);;
|
||||
if (difficulty < 1){
|
||||
difficulty = 1;
|
||||
}
|
||||
|
||||
Difficulty difficult = new Difficulty(loot.getDifficulty().getTimer(), difficulty);
|
||||
fishingPlayers.put(player,
|
||||
new FishingPlayer(System.currentTimeMillis() + loot.getTime(),
|
||||
new Timer(player, difficult, layout)
|
||||
)
|
||||
);
|
||||
|
||||
for (ActionB action : loot.getHookActions()){
|
||||
action.doOn(player);
|
||||
}
|
||||
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, loot.getTime()/50,3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dropMyLoot(Player player, Loot loot, Location location, DroppedItem droppedItem) {
|
||||
dropLoot(player, location, droppedItem);
|
||||
if (CompetitionSchedule.competition != null && CompetitionSchedule.competition.isGoingOn()) {
|
||||
float score = (float) (loot.getScore() * modifiers.get(player).getScore());
|
||||
CompetitionSchedule.competition.refreshRanking(player.getName(), score);
|
||||
BossBarManager.joinCompetition(player);
|
||||
}
|
||||
for (ActionB action : loot.getSuccessActions())
|
||||
action.doOn(player);
|
||||
AdventureUtil.playerTitle(
|
||||
player,
|
||||
ConfigReader.Title.success_title.get((int) (ConfigReader.Title.success_title.size()*Math.random()))
|
||||
.replace("{loot}",loot.getNick())
|
||||
.replace("{player}", player.getName()),
|
||||
ConfigReader.Title.success_subtitle.get((int) (ConfigReader.Title.success_subtitle.size()*Math.random()))
|
||||
.replace("{loot}",loot.getNick())
|
||||
.replace("{player}", player.getName()),
|
||||
ConfigReader.Title.success_in,
|
||||
ConfigReader.Title.success_stay,
|
||||
ConfigReader.Title.success_out
|
||||
);
|
||||
}
|
||||
|
||||
private void summonMob(Player player, Loot loot, Location location, Mob mob) {
|
||||
MythicMobsUtil.summonMM(player.getLocation(), location, mob);
|
||||
for (ActionB action : loot.getSuccessActions())
|
||||
action.doOn(player);
|
||||
if (CompetitionSchedule.competition != null && CompetitionSchedule.competition.isGoingOn()) {
|
||||
float score = (float) (loot.getScore() * modifiers.get(player).getScore());
|
||||
CompetitionSchedule.competition.refreshRanking(player.getName(), score);
|
||||
BossBarManager.joinCompetition(player);
|
||||
}
|
||||
AdventureUtil.playerTitle(
|
||||
player,
|
||||
ConfigReader.Title.success_title.get((int) (ConfigReader.Title.success_title.size()*Math.random()))
|
||||
.replace("{loot}",loot.getNick())
|
||||
.replace("{player}", player.getName()),
|
||||
ConfigReader.Title.success_subtitle.get((int) (ConfigReader.Title.success_subtitle.size()*Math.random()))
|
||||
.replace("{loot}",loot.getNick())
|
||||
.replace("{player}", player.getName()),
|
||||
ConfigReader.Title.success_in,
|
||||
ConfigReader.Title.success_stay,
|
||||
ConfigReader.Title.success_out
|
||||
);
|
||||
}
|
||||
|
||||
private void dropVanillaLoot(Player player, VanillaLoot vanillaLoot, Location location) {
|
||||
|
||||
ItemStack itemStack;
|
||||
itemStack = vanillaLoot.getItemStack();
|
||||
|
||||
if (ConfigReader.Config.mcMMOLoot && ConfigReader.Config.mcMMOLootChance > Math.random()){
|
||||
ItemStack itemStack1 = McMMOTreasure.getTreasure(player);
|
||||
if (itemStack1 != null){
|
||||
itemStack = itemStack1;
|
||||
}
|
||||
}
|
||||
|
||||
player.giveExp(vanillaLoot.getXp(), true);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1,1);
|
||||
Entity item = location.getWorld().dropItem(location, itemStack);
|
||||
Vector vector = player.getLocation().subtract(location).toVector().multiply(0.1);
|
||||
vector = vector.setY((vector.getY()+0.2)*1.2);
|
||||
item.setVelocity(vector);
|
||||
if (CompetitionSchedule.competition != null && CompetitionSchedule.competition.isGoingOn()) {
|
||||
CompetitionSchedule.competition.refreshRanking(player.getName(), 0);
|
||||
BossBarManager.joinCompetition(player);
|
||||
}
|
||||
if (modifiers.get(player).isWillDouble()) {
|
||||
Entity item2 = location.getWorld().dropItem(location, itemStack);
|
||||
item2.setVelocity(vector);
|
||||
}
|
||||
String title = ConfigReader.Title.success_title.get((int) (ConfigReader.Title.success_title.size()*Math.random()));
|
||||
Component titleComponent = getTitleComponent(itemStack, title);
|
||||
String subTitle = ConfigReader.Title.success_subtitle.get((int) (ConfigReader.Title.success_subtitle.size()*Math.random()));
|
||||
Component subtitleComponent = getTitleComponent(itemStack, subTitle);
|
||||
|
||||
AdventureUtil.playerTitle(
|
||||
player,
|
||||
titleComponent,
|
||||
subtitleComponent,
|
||||
ConfigReader.Title.success_in,
|
||||
ConfigReader.Title.success_stay,
|
||||
ConfigReader.Title.success_out
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
返回是否为mcmmo物品为空值
|
||||
*/
|
||||
private boolean dropMcMMOLoot(Player player, Location location) {
|
||||
ItemStack itemStack = McMMOTreasure.getTreasure(player);
|
||||
|
||||
if (itemStack != null) {
|
||||
if (ConfigReader.Config.preventPick)
|
||||
ItemStackUtil.addOwner(itemStack, player.getName());
|
||||
Entity item = location.getWorld().dropItem(location, itemStack);
|
||||
Vector vector = player.getLocation().subtract(location).toVector().multiply(0.1);
|
||||
vector = vector.setY((vector.getY()+0.2)*1.2);
|
||||
item.setVelocity(vector);
|
||||
if (modifiers.get(player).isWillDouble()){
|
||||
Entity item2 = location.getWorld().dropItem(location, itemStack);
|
||||
item2.setVelocity(vector);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CompetitionSchedule.competition != null && CompetitionSchedule.competition.isGoingOn()) {
|
||||
CompetitionSchedule.competition.refreshRanking(player.getName(), 0);
|
||||
BossBarManager.joinCompetition(player);
|
||||
}
|
||||
|
||||
String title = ConfigReader.Title.success_title.get((int) (ConfigReader.Title.success_title.size()*Math.random()));
|
||||
Component titleComponent = getTitleComponent(itemStack, title);
|
||||
String subTitle = ConfigReader.Title.success_subtitle.get((int) (ConfigReader.Title.success_subtitle.size()*Math.random()));
|
||||
Component subtitleComponent = getTitleComponent(itemStack, subTitle);
|
||||
|
||||
AdventureUtil.playerTitle(
|
||||
player,
|
||||
titleComponent,
|
||||
subtitleComponent,
|
||||
ConfigReader.Title.success_in,
|
||||
ConfigReader.Title.success_stay,
|
||||
ConfigReader.Title.success_out
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Component getTitleComponent(ItemStack itemStack, String text) {
|
||||
Component subtitleComponent;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# don't change
|
||||
config-version: '5'
|
||||
config-version: '6'
|
||||
|
||||
config:
|
||||
#en/es/cn
|
||||
@@ -25,13 +25,22 @@ config:
|
||||
# Otherwise the bar would show immediately the bobber is hooked
|
||||
double-reel-in: true
|
||||
|
||||
other-loot:
|
||||
# This is useful for vanilla loots
|
||||
# This should be compatible with other fishing plugin's loot system
|
||||
vanilla-loot:
|
||||
enable: true
|
||||
# Bar and ratio only works when 'double-reel-in' is true
|
||||
# Vanilla loot is available only when 'double-reel-in' is true
|
||||
vanilla: true
|
||||
# This means 30% of the loots are from vanilla
|
||||
# and 70% are from CustomFishing Loot system
|
||||
vanilla-ratio: 0.4
|
||||
# Should vanilla loots have the same fishing mechanic CustomFishing provides
|
||||
bar: true
|
||||
ratio: 0.3
|
||||
|
||||
# mcMMO treasure system
|
||||
# chance represents the chance to try to be a mcMMO treasure
|
||||
# But it doesn't mean 50% chance of the loot would be mcMMO treasure
|
||||
# mcMMO has a complex treasure system
|
||||
mcMMO: false
|
||||
mcMMO-chance: 0.5
|
||||
|
||||
# The same to vanilla (refer to the wiki)
|
||||
# https://technical-minecraft.fandom.com/wiki/Fishing
|
||||
@@ -59,3 +68,7 @@ config:
|
||||
# Prevent other players to pick up your fishing loot (Requires a restart)
|
||||
# This is useful for players to fish in a public area
|
||||
prevent-other-players-pick-up-loot: false
|
||||
|
||||
# If there's a plugin conflict, event priority sometimes works
|
||||
# HIGHEST NORMAL LOWEST
|
||||
event-priority: NORMAL
|
||||
@@ -1,25 +0,0 @@
|
||||
# Enchantment Name
|
||||
minecraft:luck_of_the_sea:
|
||||
#levels
|
||||
1:
|
||||
weight-PM:
|
||||
silver: 2
|
||||
gold: 1
|
||||
2:
|
||||
weight-PM:
|
||||
silver: 3
|
||||
gold: 2
|
||||
3:
|
||||
weight-PM:
|
||||
silver: 4
|
||||
gold: 3
|
||||
|
||||
# Supports Enchantments from Other plugins (for example EcoEnchants)
|
||||
# lucky_catch from EcoEnchants
|
||||
minecraft:lucky_catch:
|
||||
1:
|
||||
double-loot: 0.1
|
||||
2:
|
||||
double-loot: 0.2
|
||||
3:
|
||||
double-loot: 0.3
|
||||
@@ -24,7 +24,7 @@ messages:
|
||||
force-competition-failure: '¡Este concurso no existe!'
|
||||
force-competition-end: '¡Obligado a terminar el partido en curso!'
|
||||
force-competition-cancel: '¡Cancelación forzosa del partido en curso!'
|
||||
hook-other-entity: 'The bobber is hooked on another entity!'
|
||||
no-rod: 'You have to obtain a special rod to get special loots!'
|
||||
hook-other-entity: '¡El bobber está enganchado a otra entidad!'
|
||||
no-rod: 'Hay que obtener una vara especial para conseguir botines'
|
||||
no-player: 'Ningún jugador'
|
||||
no-score: 'Sin puntuación'
|
||||
Reference in New Issue
Block a user