mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 15:09:24 +00:00
1.1.4.3
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'net.momirealms'
|
||||
version = '1.1.3'
|
||||
version = '1.1.4.3'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -93,4 +93,5 @@ tasks.withType(JavaCompile) {
|
||||
|
||||
shadowJar {
|
||||
relocate 'de.tr7zw', 'net.momirealms.customfishing.libs'
|
||||
relocate 'net.kyori', 'net.momirealms.customfishing.libs'
|
||||
}
|
||||
@@ -36,6 +36,7 @@ import net.momirealms.customfishing.requirements.*;
|
||||
import net.momirealms.customfishing.utils.*;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
@@ -105,6 +106,7 @@ public class ConfigReader{
|
||||
public static boolean hasWhitelist;
|
||||
public static boolean needRodFishing;
|
||||
public static boolean disableJobXp;
|
||||
public static boolean isSpigot;
|
||||
public static int fishFinderCoolDown;
|
||||
public static double timeMultiply;
|
||||
public static double vanillaRatio;
|
||||
@@ -195,6 +197,8 @@ public class ConfigReader{
|
||||
}
|
||||
}
|
||||
|
||||
isSpigot = Bukkit.getVersion().contains("Spigot");
|
||||
|
||||
version = config.getString("config-version");
|
||||
|
||||
doubleRealIn = config.getBoolean("config.double-reel-in", true);
|
||||
@@ -375,7 +379,7 @@ public class ConfigReader{
|
||||
loot.setTime(time);
|
||||
loot.setWeight(weight);
|
||||
if (config.contains(key + ".nick")) loot.setNick(config.getString(key + ".nick"));
|
||||
else loot.setNick(config.getString(key + ".display.name", key));
|
||||
else loot.setNick(ChatColor.stripColor(config.getString(key + ".display.name", key)));
|
||||
loot.setScore(config.getDouble(key + ".score",0));
|
||||
loot.setShowInFinder(config.getBoolean(key + ".show-in-fishfinder", true));
|
||||
loot.setRandomDurability(config.getBoolean(key + ".random-durability", false));
|
||||
|
||||
@@ -19,6 +19,7 @@ package net.momirealms.customfishing.listener;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.momirealms.customfishing.competition.CompetitionSchedule;
|
||||
@@ -37,6 +38,7 @@ import net.momirealms.customfishing.requirements.FishingCondition;
|
||||
import net.momirealms.customfishing.requirements.Requirement;
|
||||
import net.momirealms.customfishing.titlebar.Timer;
|
||||
import net.momirealms.customfishing.utils.ItemStackUtil;
|
||||
import net.momirealms.customfishing.utils.ItemUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@@ -761,9 +763,9 @@ public class FishListener implements Listener {
|
||||
itemStack = itemStack1;
|
||||
}
|
||||
}
|
||||
|
||||
player.giveExp(vanillaLoot.getXp(), true);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1,1);
|
||||
if (ConfigReader.Config.isSpigot) player.giveExp(vanillaLoot.getXp());
|
||||
else player.giveExp(vanillaLoot.getXp(), true);
|
||||
AdventureUtil.playerSound(player, net.kyori.adventure.sound.Sound.Source.PLAYER, Key.key("minecraft:entity.experience_orb.pickup"));
|
||||
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);
|
||||
@@ -840,14 +842,14 @@ public class FishListener implements Listener {
|
||||
if (text.contains("{loot}")){
|
||||
text = text.replace("{loot}","|");
|
||||
if (text.startsWith("|")){
|
||||
subtitleComponent = itemStack.displayName().append(MiniMessage.miniMessage().deserialize(text.substring(1)));
|
||||
subtitleComponent = ItemUtil.getDisplayName(itemStack).append(MiniMessage.miniMessage().deserialize(text.substring(1)));
|
||||
}
|
||||
else if (text.endsWith("|")){
|
||||
subtitleComponent = MiniMessage.miniMessage().deserialize(text.substring(0,text.length()-1)).append(itemStack.displayName());
|
||||
subtitleComponent = MiniMessage.miniMessage().deserialize(text.substring(0,text.length()-1)).append(ItemUtil.getDisplayName(itemStack));
|
||||
}
|
||||
else {
|
||||
String[] titleSplit = StringUtils.split(text, "|");
|
||||
subtitleComponent = MiniMessage.miniMessage().deserialize(titleSplit[0]).append(itemStack.displayName()).append(MiniMessage.miniMessage().deserialize(titleSplit[1]));
|
||||
subtitleComponent = MiniMessage.miniMessage().deserialize(titleSplit[0]).append(ItemUtil.getDisplayName(itemStack)).append(MiniMessage.miniMessage().deserialize(titleSplit[1]));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package net.momirealms.customfishing.object.action;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.momirealms.customfishing.ConfigReader;
|
||||
import net.momirealms.customfishing.utils.AdventureUtil;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -7,7 +10,8 @@ public record XPA(int amount) implements ActionB {
|
||||
|
||||
@Override
|
||||
public void doOn(Player player) {
|
||||
player.giveExp(amount, true);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1,1);
|
||||
if (ConfigReader.Config.isSpigot) player.giveExp(amount);
|
||||
else player.giveExp(amount, true);
|
||||
AdventureUtil.playerSound(player, net.kyori.adventure.sound.Sound.Source.PLAYER, Key.key("minecraft:entity.experience_orb.pickup"));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package net.momirealms.customfishing.object.action;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.momirealms.customfishing.ConfigReader;
|
||||
import net.momirealms.customfishing.utils.AdventureUtil;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -7,7 +10,8 @@ public record XPB(int amount) implements ActionB {
|
||||
|
||||
@Override
|
||||
public void doOn(Player player) {
|
||||
player.giveExp(amount, false);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1,1);
|
||||
if (ConfigReader.Config.isSpigot) player.giveExp(amount);
|
||||
else player.giveExp(amount, false);
|
||||
AdventureUtil.playerSound(player, net.kyori.adventure.sound.Sound.Source.PLAYER, Key.key("minecraft:entity.experience_orb.pickup"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,19 +13,21 @@ public class CustomPapi implements Requirement {
|
||||
|
||||
public CustomPapi(Map<String, Object> expressions){
|
||||
expressions.keySet().forEach(key -> {
|
||||
if (key.equals("&&")){
|
||||
if (key.startsWith("&&")){
|
||||
List<PapiRequirement> papiRequirements = new ArrayList<>();
|
||||
if (expressions.get(key) instanceof MemorySection map2){
|
||||
addAndRequirements(papiRequirements, map2.getValues(false));
|
||||
}
|
||||
papiRequirement = new ExpressionAnd(papiRequirements);
|
||||
}else if (key.equals("||")){
|
||||
}
|
||||
else if (key.startsWith("||")){
|
||||
List<PapiRequirement> papiRequirements = new ArrayList<>();
|
||||
if (expressions.get(key) instanceof MemorySection map2){
|
||||
addOrRequirements(papiRequirements, map2.getValues(false));
|
||||
}
|
||||
papiRequirement = new ExpressionOr(papiRequirements);
|
||||
}else {
|
||||
}
|
||||
else {
|
||||
if (expressions.get(key) instanceof MemorySection map){
|
||||
String type = map.getString("type");
|
||||
String papi = map.getString("papi");
|
||||
@@ -52,11 +54,11 @@ public class CustomPapi implements Requirement {
|
||||
private void addAndRequirements(List<PapiRequirement> requirements, Map<String, Object> map){
|
||||
List<PapiRequirement> andRequirements = new ArrayList<>();
|
||||
map.keySet().forEach(key -> {
|
||||
if (key.equals("&&")){
|
||||
if (key.startsWith("&&")){
|
||||
if (map.get(key) instanceof MemorySection map2){
|
||||
addAndRequirements(andRequirements, map2.getValues(false));
|
||||
}
|
||||
}else if (key.equals("||")){
|
||||
}else if (key.startsWith("||")){
|
||||
if (map.get(key) instanceof MemorySection map2){
|
||||
addOrRequirements(andRequirements, map2.getValues(false));
|
||||
}
|
||||
@@ -83,11 +85,11 @@ public class CustomPapi implements Requirement {
|
||||
private void addOrRequirements(List<PapiRequirement> requirements, Map<String, Object> map){
|
||||
List<PapiRequirement> orRequirements = new ArrayList<>();
|
||||
map.keySet().forEach(key -> {
|
||||
if (key.equals("&&")){
|
||||
if (key.startsWith("&&")){
|
||||
if (map.get(key) instanceof MemorySection map2){
|
||||
addAndRequirements(orRequirements, map2.getValues(false));
|
||||
}
|
||||
}else if (key.equals("||")){
|
||||
}else if (key.startsWith("||")){
|
||||
if (map.get(key) instanceof MemorySection map2){
|
||||
addOrRequirements(orRequirements, map2.getValues(false));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package net.momirealms.customfishing.utils;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
@@ -116,7 +117,7 @@ public class ItemStackUtil {
|
||||
public static void addRandomDamage(ItemStack itemStack){
|
||||
if (itemStack.getItemMeta() instanceof Damageable damageable){
|
||||
damageable.setDamage((int) (itemStack.getType().getMaxDurability() * Math.random()));
|
||||
itemStack.setItemMeta((ItemMeta) damageable);
|
||||
itemStack.setItemMeta(damageable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,18 @@ package net.momirealms.customfishing.utils;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customfishing.ConfigReader;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.hook.ItemsAdderItem;
|
||||
import net.momirealms.customfishing.hook.MMOItemsHook;
|
||||
import net.momirealms.customfishing.hook.MythicItems;
|
||||
import net.momirealms.customfishing.hook.OraxenItem;
|
||||
import net.momirealms.customfishing.listener.PapiUnregister;
|
||||
import net.momirealms.customfishing.object.loot.DroppedItem;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -88,10 +93,14 @@ public class ItemUtil {
|
||||
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (itemMeta.hasDisplayName()){
|
||||
yamlConfiguration.set(fileName + ".display.name", itemMeta.getDisplayName());
|
||||
yamlConfiguration.set(fileName + ".display.name", replaceLegacy(itemMeta.getDisplayName()));
|
||||
}
|
||||
if (itemMeta.hasLore()){
|
||||
yamlConfiguration.set(fileName + ".display.lore", itemMeta.getLore());
|
||||
List<String> lore = new ArrayList<>();
|
||||
itemMeta.getLore().forEach(line -> {
|
||||
lore.add(replaceLegacy(line));
|
||||
});
|
||||
yamlConfiguration.set(fileName + ".display.lore", lore);
|
||||
}
|
||||
if (itemMeta.hasCustomModelData()) {
|
||||
yamlConfiguration.set(fileName + ".custom-model-data", itemMeta.getCustomModelData());
|
||||
@@ -180,4 +189,127 @@ public class ItemUtil {
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
public static Component getDisplayName(ItemStack itemStack){
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
NBTCompound nbtCompound = nbtItem.getCompound("display");
|
||||
if (nbtCompound != null){
|
||||
String name = nbtCompound.getString("Name");
|
||||
if (!name.equals("")){
|
||||
return GsonComponentSerializer.gson().deserialize(name);
|
||||
}
|
||||
}
|
||||
String type = itemStack.getType().toString().toLowerCase();
|
||||
if (itemStack.getType().isBlock()) return GsonComponentSerializer.gson().deserialize("{\"translate\":\"block.minecraft."+ type + "\"}");
|
||||
else return GsonComponentSerializer.gson().deserialize("{\"translate\":\"item.minecraft."+ type + "\"}");
|
||||
}
|
||||
|
||||
public static String replaceLegacy(String s) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
char[] chars = s.toCharArray();
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
if (chars[i] == '§') {
|
||||
if (i + 1 < chars.length) {
|
||||
switch (chars[i+1]){
|
||||
case '0' -> {
|
||||
i++;
|
||||
stringBuilder.append("<black>");
|
||||
}
|
||||
case '1' -> {
|
||||
i++;
|
||||
stringBuilder.append("<dark_blue>");
|
||||
}
|
||||
case '2' -> {
|
||||
i++;
|
||||
stringBuilder.append("<dark_green>");
|
||||
}
|
||||
case '3' -> {
|
||||
i++;
|
||||
stringBuilder.append("<dark_aqua>");
|
||||
}
|
||||
case '4' -> {
|
||||
i++;
|
||||
stringBuilder.append("<dark_red>");
|
||||
}
|
||||
case '5' -> {
|
||||
i++;
|
||||
stringBuilder.append("<dark_purple>");
|
||||
}
|
||||
case '6' -> {
|
||||
i++;
|
||||
stringBuilder.append("<gold>");
|
||||
}
|
||||
case '7' -> {
|
||||
i++;
|
||||
stringBuilder.append("<gray>");
|
||||
}
|
||||
case '8' -> {
|
||||
i++;
|
||||
stringBuilder.append("<dark_gray>");
|
||||
}
|
||||
case '9' -> {
|
||||
i++;
|
||||
stringBuilder.append("<blue>");
|
||||
}
|
||||
case 'a' -> {
|
||||
i++;
|
||||
stringBuilder.append("<green>");
|
||||
}
|
||||
case 'b' -> {
|
||||
i++;
|
||||
stringBuilder.append("<aqua>");
|
||||
}
|
||||
case 'c' -> {
|
||||
i++;
|
||||
stringBuilder.append("<red>");
|
||||
}
|
||||
case 'd' -> {
|
||||
i++;
|
||||
stringBuilder.append("<light_purple>");
|
||||
}
|
||||
case 'e' -> {
|
||||
i++;
|
||||
stringBuilder.append("<yellow>");
|
||||
}
|
||||
case 'f' -> {
|
||||
i++;
|
||||
stringBuilder.append("<white>");
|
||||
}
|
||||
case 'r' -> {
|
||||
i++;
|
||||
stringBuilder.append("<reset><!italic>");
|
||||
}
|
||||
case 'l' -> {
|
||||
i++;
|
||||
stringBuilder.append("<bold>");
|
||||
}
|
||||
case 'm' -> {
|
||||
i++;
|
||||
stringBuilder.append("<strikethrough>");
|
||||
}
|
||||
case 'o' -> {
|
||||
i++;
|
||||
stringBuilder.append("<italic>");
|
||||
}
|
||||
case 'n' -> {
|
||||
i++;
|
||||
stringBuilder.append("<underlined>");
|
||||
}
|
||||
case 'x' -> {
|
||||
stringBuilder.append("<#").append(chars[i+3]).append(chars[i+5]).append(chars[i+7]).append(chars[i+9]).append(chars[i+11]).append(chars[i+13]).append(">");
|
||||
i += 13;
|
||||
}
|
||||
case 'k' -> {
|
||||
i++;
|
||||
stringBuilder.append("<obfuscated>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
stringBuilder.append(chars[i]);
|
||||
}
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
name: CustomFishing
|
||||
version: '${version}'
|
||||
main: net.momirealms.customfishing.CustomFishing
|
||||
api-version: 1.17
|
||||
api-version: 1.16
|
||||
authors: [ XiaoMoMi ]
|
||||
softdepend:
|
||||
- MythicMobs
|
||||
|
||||
Reference in New Issue
Block a user