mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-28 19:39:06 +00:00
1.3.0.3
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'net.momirealms'
|
||||
version = '1.3.0.2'
|
||||
version = '1.3.0.3'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -81,6 +81,7 @@ public final class CustomFishing extends JavaPlugin {
|
||||
this.registerQuests();
|
||||
AdventureUtil.consoleMessage("[CustomFishing] Plugin Enabled!");
|
||||
if (ConfigManager.bStats) new Metrics(this, 16648);
|
||||
if (ConfigManager.updateChecker) this.versionHelper.checkUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,12 +193,12 @@ public final class CustomFishing extends JavaPlugin {
|
||||
MessageManager.load();
|
||||
getDataManager().unload();
|
||||
getDataManager().load();
|
||||
getEffectManager().unload();
|
||||
getEffectManager().load();
|
||||
getIntegrationManager().unload();
|
||||
getIntegrationManager().load();
|
||||
getBarMechanicManager().unload();
|
||||
getBarMechanicManager().load();
|
||||
getEffectManager().unload();
|
||||
getEffectManager().load();
|
||||
getOffsetManager().unload();
|
||||
getOffsetManager().load();
|
||||
getLootManager().unload();
|
||||
|
||||
@@ -43,7 +43,10 @@ public class ImportCommand extends AbstractSubCommand {
|
||||
return true;
|
||||
} else if (sender instanceof Player player) {
|
||||
if (ItemStackUtil.saveToFile(player.getInventory().getItemInMainHand(), args.get(0))) {
|
||||
AdventureUtil.playerMessage(player, MessageManager.prefix + "Done! File is saved to /CustomFishing/loots/" + args.get(0) + ".yml");
|
||||
AdventureUtil.playerMessage(player, MessageManager.prefix + "Done! File is saved to /CustomFishing/loots/imported.yml");
|
||||
}
|
||||
else {
|
||||
AdventureUtil.playerMessage(player, MessageManager.prefix + "<red>Error. The item can't be null or there already exists loot with that key name");
|
||||
}
|
||||
} else {
|
||||
AdventureUtil.consoleMessage(MessageManager.prefix + MessageManager.noConsole);
|
||||
@@ -54,7 +57,7 @@ public class ImportCommand extends AbstractSubCommand {
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, List<String> args) {
|
||||
if (args.size() == 1) {
|
||||
return Collections.singletonList("<file_name>");
|
||||
return Collections.singletonList("<key>");
|
||||
}
|
||||
return super.onTabComplete(sender, args);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package net.momirealms.customfishing.data.storage;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.data.PlayerSellData;
|
||||
import net.momirealms.customfishing.data.PlayerStatisticsData;
|
||||
import net.momirealms.customfishing.manager.ConfigManager;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import net.momirealms.customfishing.util.InventoryUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -31,10 +32,7 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class MySQLStorageImpl implements DataStorageInterface {
|
||||
|
||||
@@ -82,12 +80,14 @@ public class MySQLStorageImpl implements DataStorageInterface {
|
||||
int size = rs.getInt(3);
|
||||
String contents = rs.getString(4);
|
||||
ItemStack[] itemStacks = InventoryUtil.getInventoryItems(contents);
|
||||
inventory = Bukkit.createInventory(null, size, "{CustomFishing_Bag_" + offlinePlayer.getName() + "}");
|
||||
if (plugin.getVersionHelper().isSpigot()) inventory = Bukkit.createInventory(null, size, AdventureUtil.replaceMiniMessage(ConfigManager.fishingBagTitle.replace("{player}", Optional.ofNullable(offlinePlayer.getName()).orElse(""))));
|
||||
else inventory = Bukkit.createInventory(null, size, "{CustomFishing_Bag_" + offlinePlayer.getName() + "}");
|
||||
if (itemStacks != null) inventory.setContents(itemStacks);
|
||||
lockData(uuid, "fishingbag");
|
||||
}
|
||||
else {
|
||||
inventory = Bukkit.createInventory(null, 9, "{CustomFishing_Bag_" + offlinePlayer.getName() + "}");
|
||||
if (plugin.getVersionHelper().isSpigot()) inventory = Bukkit.createInventory(null, 9, AdventureUtil.replaceMiniMessage(ConfigManager.fishingBagTitle.replace("{player}", Optional.ofNullable(offlinePlayer.getName()).orElse(""))));
|
||||
else inventory = Bukkit.createInventory(null, 9, "{CustomFishing_Bag_" + offlinePlayer.getName() + "}");
|
||||
insertBagData(uuid, InventoryUtil.toBase64(inventory.getContents()));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
|
||||
@@ -19,14 +19,28 @@ package net.momirealms.customfishing.fishing.action;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public record VanillaXPImpl(int amount, boolean mending) implements Action {
|
||||
|
||||
@Override
|
||||
public void doOn(Player player, Player another) {
|
||||
player.giveExp(amount, mending);
|
||||
AdventureUtil.playerSound(player, Sound.Source.PLAYER, Key.key("minecraft:entity.experience_orb.pickup"), 1, 1);
|
||||
if (CustomFishing.getInstance().getVersionHelper().isSpigot()) {
|
||||
if (mending) {
|
||||
player.getLocation().getWorld().spawn(player.getLocation(), ExperienceOrb.class, e -> e.setExperience(amount));
|
||||
}
|
||||
else {
|
||||
player.giveExp(amount);
|
||||
AdventureUtil.playerSound(player, Sound.Source.PLAYER, Key.key("minecraft:entity.experience_orb.pickup"), 1, 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.giveExp(amount, mending);
|
||||
AdventureUtil.playerSound(player, Sound.Source.PLAYER, Key.key("minecraft:entity.experience_orb.pickup"), 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package net.momirealms.customfishing.fishing.totem;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.manager.FishingManager;
|
||||
import net.momirealms.customfishing.util.ArmorStandUtil;
|
||||
import net.momirealms.customfishing.util.LocationUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@@ -29,6 +30,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ActivatedTotem extends BukkitRunnable {
|
||||
|
||||
@@ -72,7 +74,7 @@ public class ActivatedTotem extends BukkitRunnable {
|
||||
}
|
||||
|
||||
HashSet<Player> temp = new HashSet<>(nearbyPlayerSet);
|
||||
Collection<Player> nearbyPlayers = bottomLoc.getNearbyPlayers(totem.getRadius());
|
||||
Collection<Player> nearbyPlayers = LocationUtils.getNearbyPlayers(bottomLoc, totem.getRadius());
|
||||
|
||||
for (Player player : temp) {
|
||||
if (nearbyPlayers.remove(player)) {
|
||||
|
||||
@@ -3,19 +3,29 @@ package net.momirealms.customfishing.helper;
|
||||
import de.tr7zw.changeme.nbtapi.utils.MinecraftVersion;
|
||||
import de.tr7zw.changeme.nbtapi.utils.VersionChecker;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.manager.ConfigManager;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
public class VersionHelper {
|
||||
|
||||
private boolean isNewerThan1_19_R2;
|
||||
private String version;
|
||||
private final CustomFishing plugin;
|
||||
private final boolean isSpigot;
|
||||
|
||||
public VersionHelper(CustomFishing plugin) {
|
||||
this.plugin = plugin;
|
||||
isVersionNewerThan1_19_R2();
|
||||
disableUseLessInfo();
|
||||
isSpigot = plugin.getServer().getName().equals("CraftBukkit");
|
||||
}
|
||||
|
||||
public boolean isVersionNewerThan1_19_R2() {
|
||||
@@ -62,4 +72,89 @@ public class VersionHelper {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkUpdate() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
try {
|
||||
URL url = new URL("https://api.polymart.org/v1/getResourceInfoSimple/?resource_id=2723&key=version");
|
||||
URLConnection conn = url.openConnection();
|
||||
conn.setConnectTimeout(10000);
|
||||
conn.setReadTimeout(60000);
|
||||
InputStream inputStream = conn.getInputStream();
|
||||
String newest = new BufferedReader(new InputStreamReader(inputStream)).readLine();
|
||||
String current = plugin.getDescription().getVersion();
|
||||
inputStream.close();
|
||||
|
||||
if (!compareVer(newest, current)) {
|
||||
AdventureUtil.consoleMessage(ConfigManager.lang.equalsIgnoreCase("chinese") ? "[CustomFishing] 当前已是最新版本" : "[CustomFishing] You are using the latest version.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConfigManager.lang.equalsIgnoreCase("chinese")) {
|
||||
AdventureUtil.consoleMessage("[CustomFishing] 当前版本: <red>" + current);
|
||||
AdventureUtil.consoleMessage("[CustomFishing] 最新版本: <green>" + newest);
|
||||
AdventureUtil.consoleMessage("[CustomFishing] 请到 <u>售后群<!u> 或 <u>https://polymart.org/resource/customfishing.2723<!u> 获取最新版本.");
|
||||
}
|
||||
else {
|
||||
AdventureUtil.consoleMessage("[CustomFishing] Current version: <red>" + current);
|
||||
AdventureUtil.consoleMessage("[CustomFishing] Latest version: <green>" + newest);
|
||||
AdventureUtil.consoleMessage("[CustomFishing] Update is available: <u>https://polymart.org/resource/customfishing.2723<!u>");
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
Log.warn("Error occurred when checking update");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean compareVer(String newV, String currentV) {
|
||||
if (newV == null || currentV == null || newV.isEmpty() || currentV.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
String[] newVS = newV.split("\\.");
|
||||
String[] currentVS = currentV.split("\\.");
|
||||
int maxL = Math.min(newVS.length, currentVS.length);
|
||||
for (int i = 0; i < maxL; i++) {
|
||||
try {
|
||||
String[] newPart = newVS[i].split("-");
|
||||
String[] currentPart = currentVS[i].split("-");
|
||||
int newNum = Integer.parseInt(newPart[0]);
|
||||
int currentNum = Integer.parseInt(currentPart[0]);
|
||||
if (newNum > currentNum) {
|
||||
return true;
|
||||
} else if (newNum < currentNum) {
|
||||
return false;
|
||||
} else if (newPart.length > 1 && currentPart.length > 1) {
|
||||
String[] newHotfix = newPart[1].split("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)");
|
||||
String[] currentHotfix = currentPart[1].split("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)");
|
||||
// hotfix2 & hotfix
|
||||
if (newHotfix.length == 2 && currentHotfix.length == 1) return true;
|
||||
// hotfix3 & hotfix2
|
||||
else if (newHotfix.length > 1 && currentHotfix.length > 1) {
|
||||
int newHotfixNum = Integer.parseInt(newHotfix[1]);
|
||||
int currentHotfixNum = Integer.parseInt(currentHotfix[1]);
|
||||
if (newHotfixNum > currentHotfixNum) {
|
||||
return true;
|
||||
} else if (newHotfixNum < currentHotfixNum) {
|
||||
return false;
|
||||
} else {
|
||||
return newHotfix[0].compareTo(currentHotfix[0]) > 0;
|
||||
}
|
||||
}
|
||||
} else if (newPart.length > 1) {
|
||||
return true;
|
||||
} else if (currentPart.length > 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if common parts are the same, the longer is newer
|
||||
return newVS.length > currentVS.length;
|
||||
}
|
||||
|
||||
public boolean isSpigot() {
|
||||
return isSpigot;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ public class BagDataManager extends DataFunction {
|
||||
}
|
||||
if (size * 9 != inventory.getSize()) {
|
||||
ItemStack[] itemStacks = inventory.getContents();
|
||||
Inventory newInv = Bukkit.createInventory(null, size * 9, "{CustomFishing_Bag_" + owner.getName() + "}");
|
||||
Inventory newInv = plugin.getVersionHelper().isSpigot() ? Bukkit.createInventory(null, size * 9, AdventureUtil.replaceMiniMessage(ConfigManager.fishingBagTitle.replace("{player}", owner.getName()))) : Bukkit.createInventory(null, size * 9, "{CustomFishing_Bag_" + owner.getName() + "}");
|
||||
newInv.setContents(itemStacks);
|
||||
dataMap.put(owner.getUniqueId(), newInv);
|
||||
viewer.openInventory(newInv);
|
||||
|
||||
@@ -77,12 +77,14 @@ public class ConfigManager {
|
||||
public static boolean bStats;
|
||||
public static HashSet<Material> bagWhiteListItems;
|
||||
public static boolean enableStatistics;
|
||||
public static boolean updateChecker;
|
||||
|
||||
public static void load() {
|
||||
ConfigUtil.update("config.yml");
|
||||
YamlConfiguration config = ConfigUtil.getConfig("config.yml");
|
||||
lang = config.getString("lang","english");
|
||||
bStats = config.getBoolean("metrics", true);
|
||||
updateChecker = config.getBoolean("update-checker", true);
|
||||
loadMechanics(config);
|
||||
loadTitle(config);
|
||||
loadFishingWorlds(config);
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.api.event.*;
|
||||
import net.momirealms.customfishing.fishing.*;
|
||||
import net.momirealms.customfishing.fishing.action.Action;
|
||||
import net.momirealms.customfishing.fishing.action.VanillaXPImpl;
|
||||
import net.momirealms.customfishing.fishing.bar.FishingBar;
|
||||
import net.momirealms.customfishing.fishing.bar.ModeOneBar;
|
||||
import net.momirealms.customfishing.fishing.bar.ModeThreeBar;
|
||||
@@ -617,7 +618,7 @@ public class FishingManager extends Function {
|
||||
}
|
||||
|
||||
doVanillaActions(player, location, itemStack, fishResultEvent.isDouble());
|
||||
player.giveExp(new Random().nextInt(24), true);
|
||||
new VanillaXPImpl(new Random().nextInt(24), true).doOn(player, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -637,7 +638,7 @@ public class FishingManager extends Function {
|
||||
}
|
||||
|
||||
doVanillaActions(player, location, itemStack, fishResultEvent.isDouble());
|
||||
player.giveExp(vanillaLoot.getXp(), true);
|
||||
new VanillaXPImpl(vanillaLoot.getXp(), true).doOn(player, null);
|
||||
}
|
||||
|
||||
private void doVanillaActions(Player player, Location location, ItemStack itemStack, boolean isDouble) {
|
||||
@@ -913,7 +914,7 @@ public class FishingManager extends Function {
|
||||
}
|
||||
if (totem.getNearbyActions() != null)
|
||||
for (Action action : totem.getNearbyActions()) {
|
||||
for (Player nearby : coreLoc.getNearbyPlayers(totem.getRadius())) {
|
||||
for (Player nearby : LocationUtils.getNearbyPlayers(coreLoc, totem.getRadius())) {
|
||||
action.doOn(nearby, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ public class SellManager extends DataFunction {
|
||||
AdventureUtil.consoleMessage("<red>Sell cache is not loaded for player " + player.getName());
|
||||
return;
|
||||
}
|
||||
Inventory inventory = Bukkit.createInventory(player, guiSize, "{CustomFishing_Sell}");
|
||||
Inventory inventory = plugin.getVersionHelper().isSpigot() ? Bukkit.createInventory(player, guiSize, AdventureUtil.replaceMiniMessage(SellManager.title.replace("{player}", player.getName()))) : Bukkit.createInventory(player, guiSize, "{CustomFishing_Sell}");
|
||||
for (Map.Entry<Integer, ItemStack> entry : guiItems.entrySet()) {
|
||||
inventory.setItem(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class AdventureUtil {
|
||||
|
||||
@@ -132,16 +136,16 @@ public class AdventureUtil {
|
||||
|
||||
/**
|
||||
* Replace the legacy codes with MiniMessage Format
|
||||
* @param s text
|
||||
* @param str text
|
||||
* @return MiniMessage format text
|
||||
*/
|
||||
public static String replaceLegacy(String s) {
|
||||
public static String replaceLegacy(String str) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
char[] chars = s.replace("&","§").toCharArray();
|
||||
char[] chars = str.replace("&","§").toCharArray();
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
if (chars[i] == '§') {
|
||||
if (i + 1 < chars.length) {
|
||||
switch (chars[i+1]){
|
||||
switch (chars[i+1]) {
|
||||
case '0' -> {i++;stringBuilder.append("<black>");}
|
||||
case '1' -> {i++;stringBuilder.append("<dark_blue>");}
|
||||
case '2' -> {i++;stringBuilder.append("<dark_green>");}
|
||||
@@ -174,4 +178,49 @@ public class AdventureUtil {
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
public static String replaceMiniMessage(String str) {
|
||||
String result = str.replace("&","§");
|
||||
List<String> miniFormat = new ArrayList<>();
|
||||
Pattern pattern = Pattern.compile("<.*?>");
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
while (matcher.find()) miniFormat.add(matcher.group());
|
||||
for (String mini : miniFormat) {
|
||||
StringBuilder replacer = new StringBuilder();
|
||||
switch (mini) {
|
||||
case "<black>" -> replacer = new StringBuilder("§0");
|
||||
case "<dark_blue>" -> replacer = new StringBuilder("§1");
|
||||
case "<dark_green>" -> replacer = new StringBuilder("§2");
|
||||
case "<dark_aqua>" -> replacer = new StringBuilder("§3");
|
||||
case "<dark_red>" -> replacer = new StringBuilder("§4");
|
||||
case "<dark_purple>" -> replacer = new StringBuilder("§5");
|
||||
case "<gold>" -> replacer = new StringBuilder("§6");
|
||||
case "<gray>" -> replacer = new StringBuilder("§7");
|
||||
case "<dark_gray>" -> replacer = new StringBuilder("§8");
|
||||
case "<blue>" -> replacer = new StringBuilder("§9");
|
||||
case "<green>" -> replacer = new StringBuilder("§a");
|
||||
case "<aqua>" -> replacer = new StringBuilder("§b");
|
||||
case "<red>" -> replacer = new StringBuilder("§c");
|
||||
case "<light_purple>" -> replacer = new StringBuilder("§d");
|
||||
case "<yellow>" -> replacer = new StringBuilder("§e");
|
||||
case "<white>" -> replacer = new StringBuilder("§f");
|
||||
case "<reset>" -> replacer = new StringBuilder("§r");
|
||||
case "<bold>" -> replacer = new StringBuilder("§l");
|
||||
case "<strikethrough>" -> replacer = new StringBuilder("§m");
|
||||
case "<italic>" -> replacer = new StringBuilder("§o");
|
||||
case "<underlined>" -> replacer = new StringBuilder("§n");
|
||||
case "<obfuscated>" -> replacer = new StringBuilder("§k");
|
||||
default -> {
|
||||
if (mini.length() == 9 && mini.charAt(1) == '#') {
|
||||
replacer = new StringBuilder("§x");
|
||||
for (int i = 2; i < 8; i++) {
|
||||
replacer.append("§").append(mini.charAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result = result.replace(mini, replacer.toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,18 +200,18 @@ public class ItemStackUtil {
|
||||
player.getInventory().addItem(itemStack);
|
||||
}
|
||||
|
||||
public static boolean saveToFile(ItemStack itemStack, String fileName){
|
||||
if (itemStack == null || itemStack.getType() == Material.AIR) return false;
|
||||
YamlConfiguration yamlConfiguration = new YamlConfiguration();
|
||||
yamlConfiguration.set(fileName + ".material", itemStack.getType().toString());
|
||||
public static boolean saveToFile(ItemStack itemStack, String key){
|
||||
if (itemStack == null || itemStack.getType() == Material.AIR || CustomFishing.getInstance().getLootManager().hasLoot(key)) return false;
|
||||
File file = new File(CustomFishing.getInstance().getDataFolder(), File.separator + "loots" + File.separator + "imported.yml");
|
||||
YamlConfiguration data = ConfigUtil.readData(file);
|
||||
data.set(key + ".material", itemStack.getType().toString());
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
Map<String, Object> map0 = compoundToMap(nbtItem);
|
||||
if (map0.size() != 0) {
|
||||
yamlConfiguration.createSection(fileName + ".nbt", map0);
|
||||
data.createSection(key + ".nbt", map0);
|
||||
}
|
||||
File file = new File(CustomFishing.getInstance().getDataFolder(), File.separator + "loots" + File.separator + fileName + ".yml");
|
||||
try {
|
||||
yamlConfiguration.save(file);
|
||||
data.save(file);
|
||||
CustomFishing.getInstance().getLootManager().unload();
|
||||
CustomFishing.getInstance().getLootManager().load();
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -17,13 +17,18 @@
|
||||
|
||||
package net.momirealms.customfishing.util;
|
||||
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.object.SimpleLocation;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LocationUtils {
|
||||
|
||||
public static SimpleLocation getSimpleLocation(Location location) {
|
||||
@@ -54,4 +59,19 @@ public class LocationUtils {
|
||||
public static String getStringLocation(Location location) {
|
||||
return location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ();
|
||||
}
|
||||
|
||||
public static Collection<Player> getNearbyPlayers(Location location, double radius) {
|
||||
Collection<Player> nearbyPlayers;
|
||||
if (CustomFishing.getInstance().getVersionHelper().isSpigot()) {
|
||||
nearbyPlayers = location.getWorld().getNearbyEntities(location, radius, radius, radius)
|
||||
.stream()
|
||||
.filter(entity -> entity instanceof Player)
|
||||
.map(entity -> (Player) entity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
else {
|
||||
nearbyPlayers = location.getNearbyPlayers(radius);
|
||||
}
|
||||
return nearbyPlayers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
# Don't change
|
||||
config-version: '19'
|
||||
config-version: '20'
|
||||
|
||||
# bStats
|
||||
metrics: true
|
||||
|
||||
# Check update
|
||||
update-checker: true
|
||||
|
||||
# Wiki: https://mo-mi.gitbook.io/xiaomomi-plugins/
|
||||
# chinese/english/spanish
|
||||
lang: english
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customfishing/item-library
|
||||
vanilla:
|
||||
disable-stats: false
|
||||
disable-bar-mechanic: false
|
||||
disable-bar-mechanic: true
|
||||
rubbish:
|
||||
material: cod
|
||||
show-in-fishfinder: false
|
||||
@@ -33,39 +33,6 @@ wither_skeleton_skull:
|
||||
action:
|
||||
success:
|
||||
mending: 80
|
||||
pufferfish:
|
||||
nick: '<#DAA520>Pufferfish</#DAA520>'
|
||||
material: PUFFERFISH
|
||||
weight: 50
|
||||
action:
|
||||
success:
|
||||
mending: 7
|
||||
cod:
|
||||
nick: '<#FFFACD>Cod</#FFFACD>'
|
||||
material: COD
|
||||
weight: 300
|
||||
action:
|
||||
success:
|
||||
mending: 3
|
||||
salmon:
|
||||
nick: '<#D2691E>Salmon</#D2691E>'
|
||||
material: SALMON
|
||||
weight: 250
|
||||
tropical_fish:
|
||||
nick: '&cT&fr&co&fp&ci&fc&ca&fl &cF&fi&cs&fh'
|
||||
material: TROPICAL_FISH
|
||||
weight: 50
|
||||
action:
|
||||
success:
|
||||
mending: 4
|
||||
requirements:
|
||||
biome:
|
||||
- minecraft:jungle
|
||||
- minecraft:bamboo_jungle
|
||||
- minecraft:sparse_jungle
|
||||
- minecraft:warm_ocean
|
||||
- minecraft:lukewarm_ocean
|
||||
- minecraft:deep_lukewarm_ocean
|
||||
tuna_fish:
|
||||
material: cod
|
||||
nick: <gradient:#F0FFFF:#4682B4:#F0FFFF>Tuna Fish</gradient>
|
||||
|
||||
Reference in New Issue
Block a user