9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-28 19:39:06 +00:00

1.3.0-beta-3

This commit is contained in:
Xiao-MoMi
2023-03-08 23:48:09 +08:00
parent a4037f96eb
commit 6d9a89e50f
33 changed files with 417 additions and 443 deletions

View File

@@ -4,46 +4,19 @@ plugins {
}
group = 'net.momirealms'
version = '1.3.0-beta-1'
version = '1.3.0-beta-3'
repositories {
mavenCentral()
maven {
name = 'papermc-repo'
url = 'https://papermc.io/repo/repository/maven-public/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
maven {
name = "dmulloy2-repo"
url = "https://repo.dmulloy2.net/repository/public/"
}
maven {
name = "clip-repo"
url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'
}
maven {
name = "NBT-API"
url = "https://repo.codemc.org/repository/maven-public/"
}
maven {
name = "sk89q-repo"
url = "https://maven.enginehub.org/repo/"
}
maven {
name = "jitpack-repo"
url = "https://jitpack.io"
}
maven {
name = "Lumine Releases"
url = "https://mvn.lumine.io/repository/maven-public"
}
maven {
name = 'glaremasters repo'
url = 'https://repo.glaremasters.me/repository/towny/'
}
maven {name = 'papermc-repo'; url = 'https://papermc.io/repo/repository/maven-public/'}
maven {name = 'sonatype'; url = 'https://oss.sonatype.org/content/groups/public/'}
maven {name = "dmulloy2-repo"; url = "https://repo.dmulloy2.net/repository/public/"}
maven {name = "clip-repo"; url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'}
maven {name = "NBT-API"; url = "https://repo.codemc.org/repository/maven-public/"}
maven {name = "sk89q-repo"; url = "https://maven.enginehub.org/repo/"}
maven {name = "jitpack-repo"; url = "https://jitpack.io"}
maven {name = "Lumine Releases"; url = "https://mvn.lumine.io/repository/maven-public"}
maven {name = 'glaremasters repo'; url = 'https://repo.glaremasters.me/repository/towny/'}
}
dependencies {
@@ -66,6 +39,7 @@ dependencies {
compileOnly('com.github.LoneDev6:api-itemsadder:3.2.3c')
compileOnly('net.objecthunter:exp4j:0.4.8')
compileOnly('org.mariadb.jdbc:mariadb-java-client:3.0.6')
compileOnly('com.google.code.gson:gson:2.10.1')
implementation('net.kyori:adventure-api:4.12.0')
implementation('net.kyori:adventure-platform-bukkit:4.2.0')
implementation('net.kyori:adventure-text-minimessage:4.12.0')

View File

@@ -76,7 +76,7 @@ public final class CustomFishing extends JavaPlugin {
this.registerCommands();
this.registerQuests();
AdventureUtil.consoleMessage("[CustomFishing] Plugin Enabled!");
new Metrics(this, 16648);
if (ConfigManager.bStats) new Metrics(this, 16648);
}
@Override
@@ -181,6 +181,8 @@ public final class CustomFishing extends JavaPlugin {
public void reload() {
ConfigManager.load();
MessageManager.load();
getDataManager().unload();
getDataManager().load();
getIntegrationManager().unload();
getIntegrationManager().load();
getBarMechanicManager().unload();

View File

@@ -1,44 +0,0 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.data;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.Inventory;
public class PlayerBagData {
private final OfflinePlayer player;
private Inventory inventory;
public PlayerBagData(OfflinePlayer player, Inventory inventory) {
this.player = player;
this.inventory = inventory;
}
public Inventory getInventory() {
return inventory;
}
public OfflinePlayer getPlayer() {
return player;
}
public void setInventory(Inventory inventory) {
this.inventory = inventory;
}
}

View File

@@ -17,10 +17,7 @@
package net.momirealms.customfishing.data.storage;
import net.momirealms.customfishing.data.PlayerBagData;
import net.momirealms.customfishing.data.PlayerSellData;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import java.util.UUID;
@@ -29,8 +26,9 @@ public interface DataStorageInterface {
void initialize();
void disable();
Inventory loadBagData(OfflinePlayer player, boolean force);
void saveBagData(PlayerBagData playerBagData, boolean unlock);
PlayerSellData loadSellData(Player player, boolean force);
Inventory loadBagData(UUID uuid, boolean force);
void saveBagData(UUID uuid, Inventory inventory, boolean unlock);
PlayerSellData loadSellData(UUID uuid, boolean force);
void saveSellData(UUID uuid, PlayerSellData playerSellData, boolean unlock);
StorageType getStorageType();
}

View File

@@ -18,14 +18,12 @@
package net.momirealms.customfishing.data.storage;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.data.PlayerBagData;
import net.momirealms.customfishing.data.PlayerSellData;
import net.momirealms.customfishing.util.ConfigUtil;
import net.momirealms.customfishing.util.InventoryUtil;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@@ -52,25 +50,25 @@ public class FileStorageImpl implements DataStorageInterface {
}
@Override
public Inventory loadBagData(OfflinePlayer player, boolean force) {
YamlConfiguration config = ConfigUtil.readData(new File(plugin.getDataFolder(), "fishingbag_data" + File.separator + player.getUniqueId() + ".yml"));
public Inventory loadBagData(UUID uuid, boolean force) {
YamlConfiguration config = ConfigUtil.readData(new File(plugin.getDataFolder(), "fishingbag_data" + File.separator + uuid + ".yml"));
String contents = config.getString("contents");
int size = config.getInt("size", 9);
ItemStack[] itemStacks = InventoryUtil.getInventoryItems(contents);
Inventory inventory = Bukkit.createInventory(null, size, "{CustomFishing_Bag_" + player.getName() + "}");
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
Inventory inventory = Bukkit.createInventory(null, size, "{CustomFishing_Bag_" + offlinePlayer.getName() + "}");
if (itemStacks != null) inventory.setContents(itemStacks);
return inventory;
}
@Override
public void saveBagData(PlayerBagData playerBagData, boolean unlock) {
public void saveBagData(UUID uuid, Inventory inventory, boolean unlock) {
YamlConfiguration data = new YamlConfiguration();
Inventory inventory = playerBagData.getInventory();
String contents = InventoryUtil.toBase64(inventory.getContents());
data.set("contents", contents);
data.set("size", inventory.getSize());
try {
data.save(new File(plugin.getDataFolder(), "fishingbag_data" + File.separator + playerBagData.getPlayer().getUniqueId() + ".yml"));
data.save(new File(plugin.getDataFolder(), "fishingbag_data" + File.separator + uuid + ".yml"));
}
catch (IOException e) {
e.printStackTrace();
@@ -78,9 +76,8 @@ public class FileStorageImpl implements DataStorageInterface {
}
@Override
public PlayerSellData loadSellData(Player player, boolean force) {
UUID uuid = player.getUniqueId();
YamlConfiguration data = ConfigUtil.readData(new File(plugin.getDataFolder(), "sell-data" + File.separator + uuid + ".yml"));
public PlayerSellData loadSellData(UUID uuid, boolean force) {
YamlConfiguration data = ConfigUtil.readData(new File(plugin.getDataFolder(), "sell_data" + File.separator + uuid + ".yml"));
int date = data.getInt("date");
double money = data.getDouble("earnings");
return new PlayerSellData(money, date);
@@ -92,10 +89,15 @@ public class FileStorageImpl implements DataStorageInterface {
data.set("date", playerSellData.getDate());
data.set("earnings", playerSellData.getMoney());
try {
data.save(new File(plugin.getDataFolder(), "sell-data" + File.separator + uuid + ".yml"));
data.save(new File(plugin.getDataFolder(), "sell_data" + File.separator + uuid + ".yml"));
}
catch (IOException e) {
e.printStackTrace();
}
}
@Override
public StorageType getStorageType() {
return StorageType.YAML;
}
}

View File

@@ -18,13 +18,11 @@
package net.momirealms.customfishing.data.storage;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.data.PlayerBagData;
import net.momirealms.customfishing.data.PlayerSellData;
import net.momirealms.customfishing.util.AdventureUtil;
import net.momirealms.customfishing.util.InventoryUtil;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@@ -58,11 +56,12 @@ public class MySQLStorageImpl implements DataStorageInterface {
}
@Override
public Inventory loadBagData(OfflinePlayer player, boolean force) {
public Inventory loadBagData(UUID uuid, boolean force) {
Inventory inventory = null;
String sql = String.format(SqlConstants.SQL_SELECT_BAG_BY_UUID, sqlConnection.getTablePrefix() + "_" + "fishingbag");
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
try (Connection connection = sqlConnection.getConnectionAndCheck(); PreparedStatement statement = connection.prepareStatement(sql)) {
statement.setString(1, player.getUniqueId().toString());
statement.setString(1, uuid.toString());
ResultSet rs = statement.executeQuery();
if (rs.next()) {
int version = rs.getInt(2);
@@ -74,13 +73,13 @@ 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_" + player.getName() + "}");
inventory = Bukkit.createInventory(null, size, "{CustomFishing_Bag_" + offlinePlayer.getName() + "}");
if (itemStacks != null) inventory.setContents(itemStacks);
lockData(player.getUniqueId(), "fishingbag");
lockData(uuid, "fishingbag");
}
else {
inventory = Bukkit.createInventory(null, 9, "{CustomFishing_Bag_" + player.getName() + "}");
insertBagData(player.getUniqueId(), InventoryUtil.toBase64(inventory.getContents()));
inventory = Bukkit.createInventory(null, 9, "{CustomFishing_Bag_" + offlinePlayer.getName() + "}");
insertBagData(uuid, InventoryUtil.toBase64(inventory.getContents()));
}
} catch (SQLException e) {
e.printStackTrace();
@@ -89,25 +88,17 @@ public class MySQLStorageImpl implements DataStorageInterface {
}
@Override
public void saveBagData(PlayerBagData playerBagData, boolean unlock) {
UUID uuid = playerBagData.getPlayer().getUniqueId();
Inventory inventory = playerBagData.getInventory();
public void saveBagData(UUID uuid, Inventory inventory, boolean unlock) {
String contents = InventoryUtil.toBase64(inventory.getContents());
if (contents == null) contents = "";
updateBagData(uuid, inventory.getSize(), contents, unlock);
}
/**
* Whether the data is loaded
* @param player player
* @return success or not
*/
@Override
public PlayerSellData loadSellData(Player player, boolean force) {
public PlayerSellData loadSellData(UUID uuid, boolean force) {
PlayerSellData playerSellData = null;
String sql = String.format(SqlConstants.SQL_SELECT_SELL_BY_UUID, sqlConnection.getTablePrefix() + "_" + "selldata");
try (Connection connection = sqlConnection.getConnectionAndCheck(); PreparedStatement statement = connection.prepareStatement(sql)) {
statement.setString(1, player.getUniqueId().toString());
statement.setString(1, uuid.toString());
ResultSet rs = statement.executeQuery();
if (rs.next()) {
int version = rs.getInt(2);
@@ -119,12 +110,12 @@ public class MySQLStorageImpl implements DataStorageInterface {
int date = rs.getInt(3);
int money = rs.getInt(4);
playerSellData = new PlayerSellData(money, date);
lockData(player.getUniqueId(), "selldata");
lockData(uuid, "selldata");
}
else {
Calendar calendar = Calendar.getInstance();
playerSellData = new PlayerSellData(0, (calendar.get(Calendar.MONTH) +1)* 100 + calendar.get(Calendar.DATE));
insertSellData(player.getUniqueId(), playerSellData.getDate());
insertSellData(uuid, playerSellData.getDate());
}
} catch (SQLException e) {
e.printStackTrace();
@@ -137,6 +128,11 @@ public class MySQLStorageImpl implements DataStorageInterface {
updateSellData(uuid, playerSellData.getDate(), (int) playerSellData.getMoney(), unlock);
}
@Override
public StorageType getStorageType() {
return StorageType.SQL;
}
private void createTableIfNotExist(String table, String sqlStat) {
String sql = String.format(sqlStat, table);
try (Connection connection = sqlConnection.getConnectionAndCheck(); PreparedStatement statement = connection.prepareStatement(sql)) {

View File

@@ -0,0 +1,6 @@
package net.momirealms.customfishing.data.storage;
public enum StorageType {
SQL,
YAML
}

View File

@@ -35,10 +35,6 @@ public class Effect {
private boolean canLavaFishing;
private boolean hasSpecialRod;
public double getSizeMultiplier() {
return sizeMultiplier + 1;
}
public void setSizeMultiplier(double sizeMultiplier) {
this.sizeMultiplier = sizeMultiplier;
}
@@ -113,13 +109,17 @@ public class Effect {
if (anotherEffect.getTimeModifier() != 0) this.timeModifier += (anotherEffect.getTimeModifier() - 1);
if (anotherEffect.getDoubleLootChance() != 0) this.doubleLootChance += anotherEffect.getDoubleLootChance();
if (anotherEffect.getDifficulty() != 0) this.difficulty += anotherEffect.getDifficulty();
if (anotherEffect.getScoreMultiplier() != 0) this.scoreMultiplier += anotherEffect.getScoreMultiplier();
if (anotherEffect.getSizeMultiplier() != 0) this.sizeMultiplier += anotherEffect.getSizeMultiplier();
if (anotherEffect.getScoreMultiplier() != 0) this.scoreMultiplier += (anotherEffect.getScoreMultiplier() - 1);
if (anotherEffect.getSizeMultiplier() != 0) this.sizeMultiplier += (anotherEffect.getSizeMultiplier() - 1);
if (anotherEffect.canLavaFishing()) this.canLavaFishing = true;
}
public double getScoreMultiplier() {
return scoreMultiplier + 1;
return scoreMultiplier;
}
public double getSizeMultiplier() {
return sizeMultiplier;
}
public boolean hasSpecialRod() {

View File

@@ -114,13 +114,14 @@ public class Competition {
List<String> newMessage = new ArrayList<>();
PlaceholderManager placeholderManager = CustomFishing.getInstance().getIntegrationManager().getPlaceholderManager();
for (String endMsg : competitionConfig.getEndMessage()) {
List<String> placeholders = new ArrayList<>(placeholderManager.detectPlaceholders(endMsg));
List<String> placeholders = new ArrayList<>(placeholderManager.detectBetterPlaceholders(endMsg));
for (String placeholder : placeholders) {
if (placeholder.endsWith("_player%")) {
System.out.println(placeholder);
if (placeholder.endsWith("_player}")) {
int rank = Integer.parseInt(placeholder.substring(1, placeholder.length() - 8));
endMsg = endMsg.replace(placeholder, Optional.ofNullable(ranking.getPlayerAt(rank)).orElse(MessageManager.noPlayer));
}
else if (placeholder.endsWith("_score%")) {
else if (placeholder.endsWith("_score}")) {
int rank = Integer.parseInt(placeholder.substring(1, placeholder.length() - 7));
float score = ranking.getScoreAt(rank);
endMsg = endMsg.replace(placeholder, score == 0 ? MessageManager.noScore : String.format("%.1f", score));

View File

@@ -30,8 +30,8 @@ public class DroppedItem extends Loot {
private float basicPrice;
private float sizeBonus;
public DroppedItem(String key, String nick, String material, MiniGameConfig[] fishingGames, int weight, boolean showInFinder, double score, boolean randomDurability) {
super(key, nick, fishingGames, weight, showInFinder, score);
public DroppedItem(String key, String nick, String material, MiniGameConfig[] fishingGames, int weight, boolean showInFinder, double score, boolean randomDurability, boolean disableBar) {
super(key, nick, fishingGames, weight, showInFinder, score, disableBar);
this.material = material;
this.randomDurability = randomDurability;
}

View File

@@ -23,11 +23,12 @@ import net.momirealms.customfishing.object.action.ActionInterface;
public class Loot {
public static Loot EMPTY = new Loot("null", "null", new MiniGameConfig[0], 0, false, 0d);
public static Loot EMPTY = new Loot("null", "null", new MiniGameConfig[0], 0, false, 0d, false);
protected final String key;
protected final String nick;
protected String group;
protected boolean disableBar;
protected final boolean showInFinder;
protected ActionInterface[] successActions;
protected ActionInterface[] failureActions;
@@ -38,13 +39,14 @@ public class Loot {
protected final int weight;
protected final double score;
public Loot(String key, String nick, MiniGameConfig[] fishingGames, int weight, boolean showInFinder, double score) {
public Loot(String key, String nick, MiniGameConfig[] fishingGames, int weight, boolean showInFinder, double score, boolean disableBar) {
this.key = key;
this.nick = nick;
this.weight = weight;
this.showInFinder = showInFinder;
this.score = score;
this.fishingGames = fishingGames;
this.disableBar = disableBar;
}
public MiniGameConfig[] getFishingGames() {
@@ -118,4 +120,8 @@ public class Loot {
public void setRequirements(RequirementInterface[] requirements) {
this.requirements = requirements;
}
public boolean isDisableBar() {
return disableBar;
}
}

View File

@@ -26,8 +26,8 @@ public class Mob extends Loot{
private final int mobLevel;
private final MobVector mobVector;
public Mob(String key, String nick, MiniGameConfig[] fishingGames, int weight, boolean showInFinder, double score, String mobID, int mobLevel, MobVector mobVector) {
super(key, nick, fishingGames, weight, showInFinder, score);
public Mob(String key, String nick, MiniGameConfig[] fishingGames, int weight, boolean showInFinder, double score, String mobID, int mobLevel, MobVector mobVector, boolean disableBar) {
super(key, nick, fishingGames, weight, showInFinder, score, disableBar);
this.mobID = mobID;
this.mobLevel = mobLevel;
this.mobVector = mobVector;

View File

@@ -35,7 +35,8 @@ public class ActivatedTotem extends BukkitRunnable {
public static int id = 127616121;
private int timer;
private final TotemConfig totem;
private final Location location;
private final Location bottomLoc;
private final Location coreLoc;
private final Set<Player> nearbyPlayerSet;
private final int[] entityID;
private final boolean hasHolo;
@@ -43,17 +44,18 @@ public class ActivatedTotem extends BukkitRunnable {
private final FishingManager fishingManager;
private final int direction;
public ActivatedTotem(Location location, TotemConfig totem, FishingManager fishingManager, int direction) {
public ActivatedTotem(Location coreLoc, TotemConfig totem, FishingManager fishingManager, int direction) {
this.fishingManager = fishingManager;
this.totem = totem;
this.location = location;
this.coreLoc = coreLoc;
this.bottomLoc = coreLoc.clone().subtract(0, totem.getOriginalModel().getCorePos().getY(), 0);
this.entityID = new int[totem.getHoloText().length];
for (int i = 0; i < totem.getHoloText().length; i++) {
this.entityID[i] = id++;
}
this.hasHolo = totem.getHoloText() != null;
this.nearbyPlayerSet = Collections.synchronizedSet(new HashSet<>());
this.particleTimerTask = new TotemParticle(location, totem.getRadius(), totem.getParticle());
this.particleTimerTask = new TotemParticle(bottomLoc, totem.getRadius(), totem.getParticle());
this.particleTimerTask.runTaskTimerAsynchronously(CustomFishing.getInstance(), 0, 4);
this.direction = direction;
}
@@ -68,7 +70,7 @@ public class ActivatedTotem extends BukkitRunnable {
}
HashSet<Player> temp = new HashSet<>(nearbyPlayerSet);
Collection<Player> nearbyPlayers = location.getNearbyPlayers(totem.getRadius());
Collection<Player> nearbyPlayers = bottomLoc.getNearbyPlayers(totem.getRadius());
for (Player player : temp) {
if (nearbyPlayers.remove(player)) {
@@ -95,7 +97,7 @@ public class ActivatedTotem extends BukkitRunnable {
for (Player newComer : nearbyPlayers) {
if (hasHolo) {
for (int i = 0; i < entityID.length; i++) {
CustomFishing.getProtocolManager().sendServerPacket(newComer, ArmorStandUtil.getSpawnPacket(entityID[i], location.clone().add(0.5, totem.getHoloOffset() + i * 0.4, 0.5)));
CustomFishing.getProtocolManager().sendServerPacket(newComer, ArmorStandUtil.getSpawnPacket(entityID[i], bottomLoc.clone().add(0.5, totem.getHoloOffset() + i * 0.4, 0.5)));
CustomFishing.getProtocolManager().sendServerPacket(newComer, ArmorStandUtil.getMetaPacket(entityID[i],
totem.getHoloText()[entityID.length - 1 - i].replace("{time}", String.valueOf(totem.getDuration() - timer))
.replace("{max_time}", String.valueOf(totem.getDuration()))
@@ -118,8 +120,8 @@ public class ActivatedTotem extends BukkitRunnable {
public void stop() {
this.particleTimerTask.cancel();
cancel();
fishingManager.removeTotem(location);
CustomFishing.getInstance().getTotemManager().clearBreakDetectCache(totem.getFinalModel(), location, direction);
fishingManager.removeTotem(coreLoc);
CustomFishing.getInstance().getTotemManager().clearBreakDetectCache(totem.getFinalModel(), bottomLoc, direction);
if (hasHolo) {
for (Player player : nearbyPlayerSet) {
for (int j : entityID) {

View File

@@ -17,6 +17,7 @@
package net.momirealms.customfishing.integration.papi;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.object.Function;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -29,14 +30,18 @@ import java.util.regex.Pattern;
public class PlaceholderManager extends Function {
private final Pattern placeholderPattern = Pattern.compile("%([^%]*)%");
private CustomFishing plugin;
private final Pattern basicPattern = Pattern.compile("%([^%]*)%");
private final Pattern betterPattern = Pattern.compile("\\{(.+?)\\}");
private CompetitionPapi competitionPapi;
private StatisticsPapi statisticsPapi;
private boolean hasPlaceholderAPI = false;
public PlaceholderManager() {
public PlaceholderManager(CustomFishing plugin) {
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
hasPlaceholderAPI = true;
this.competitionPapi = new CompetitionPapi();
//this.statisticsPapi = new StatisticsPapi(plugin);
}
}
@@ -50,17 +55,27 @@ public class PlaceholderManager extends Function {
@Override
public void load() {
if (competitionPapi != null) competitionPapi.register();
//if (statisticsPapi != null) statisticsPapi.register();
}
@Override
public void unload() {
if (this.competitionPapi != null) competitionPapi.unregister();
//if (this.statisticsPapi != null) statisticsPapi.unregister();
}
public List<String> detectPlaceholders(String text){
public List<String> detectBasicPlaceholders(String text){
if (text == null || !text.contains("%")) return Collections.emptyList();
List<String> placeholders = new ArrayList<>();
Matcher matcher = placeholderPattern.matcher(text);
Matcher matcher = basicPattern.matcher(text);
while (matcher.find()) placeholders.add(matcher.group());
return placeholders;
}
public List<String> detectBetterPlaceholders(String text){
if (text == null || !(text.contains("{") && text.contains("}"))) return Collections.emptyList();
List<String> placeholders = new ArrayList<>();
Matcher matcher = betterPattern.matcher(text);
while (matcher.find()) placeholders.add(matcher.group());
return placeholders;
}

View File

@@ -0,0 +1,41 @@
package net.momirealms.customfishing.integration.papi;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.momirealms.customfishing.CustomFishing;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class StatisticsPapi extends PlaceholderExpansion {
private CustomFishing plugin;
public StatisticsPapi(CustomFishing plugin) {
this.plugin = plugin;
}
@Override
public @NotNull String getIdentifier() {
return "fishingstats";
}
@Override
public @NotNull String getAuthor() {
return "XiaoMoMi";
}
@Override
public @NotNull String getVersion() {
return "1.0";
}
@Override
public boolean persist() {
return true;
}
@Override
public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) {
return "null";
}
}

View File

@@ -17,9 +17,7 @@
package net.momirealms.customfishing.integration.quest;
import com.electro2560.dev.cluescrolls.api.ClueDataPair;
import com.electro2560.dev.cluescrolls.api.ClueScrollsAPI;
import com.electro2560.dev.cluescrolls.api.CustomClue;
import com.electro2560.dev.cluescrolls.api.*;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.api.event.FishResultEvent;
import net.momirealms.customfishing.fishing.FishResult;
@@ -28,26 +26,16 @@ import org.bukkit.event.Listener;
public class ClueScrollCFQuest implements Listener {
private final CustomClue fishClue;
private final CustomClue mobClue;
private final CustomClue commonClue;
public ClueScrollCFQuest() {
commonClue = ClueScrollsAPI.getInstance().registerCustomClue(CustomFishing.getInstance(), "fish");
fishClue = ClueScrollsAPI.getInstance().registerCustomClue(CustomFishing.getInstance(), "catch_item");
mobClue = ClueScrollsAPI.getInstance().registerCustomClue(CustomFishing.getInstance(), "catch_mob");
commonClue = ClueScrollsAPI.getInstance().registerCustomClue(CustomFishing.getInstance(), "fish", new ClueConfigData("fish_id", DataType.STRING));
}
@EventHandler
public void onFish(FishResultEvent event) {
if (event.isCancelled()) return;
if (event.getResult() == FishResult.FAILURE) return;
commonClue.handle(event.getPlayer(), event.isDouble() ? 2 : 1, new ClueDataPair("id", event.getLoot_id()));
if (event.getResult() == FishResult.CATCH_SPECIAL_ITEM || event.getResult() == FishResult.CATCH_VANILLA_ITEM) {
fishClue.handle(event.getPlayer(), event.isDouble() ? 2 : 1, new ClueDataPair("id", event.getLoot_id()));
}
if (event.getResult() == FishResult.CATCH_MOB) {
mobClue.handle(event.getPlayer(), 1, new ClueDataPair("id", event.getLoot_id()));
}
commonClue.handle(event.getPlayer(), event.isDouble() ? 2 : 1, new ClueDataPair("fish_id", event.getLoot_id()));
}
}

View File

@@ -25,7 +25,6 @@ import de.tr7zw.changeme.nbtapi.NBTItem;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.data.PlayerBagData;
import net.momirealms.customfishing.listener.InventoryListener;
import net.momirealms.customfishing.listener.JoinQuitListener;
import net.momirealms.customfishing.listener.WindowPacketListener;
@@ -34,6 +33,7 @@ import net.momirealms.customfishing.util.AdventureUtil;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.inventory.InventoryClickEvent;
@@ -43,14 +43,14 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitTask;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
public class BagDataManager extends Function {
private final ConcurrentHashMap<UUID, PlayerBagData> dataMap;
private final HashSet<PlayerBagData> tempData;
private final ConcurrentHashMap<UUID, Inventory> dataMap;
private final HashMap<UUID, Inventory> tempData;
private final InventoryListener inventoryListener;
private final WindowPacketListener windowPacketListener;
private final JoinQuitListener joinQuitListener;
@@ -61,7 +61,7 @@ public class BagDataManager extends Function {
public BagDataManager(CustomFishing plugin) {
this.plugin = plugin;
this.dataMap = new ConcurrentHashMap<>();
this.tempData = new HashSet<>();
this.tempData = new HashMap<>();
this.triedTimes = new HashMap<>();
this.inventoryListener = new InventoryListener(this);
@@ -71,8 +71,8 @@ public class BagDataManager extends Function {
this.timerSave = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, () -> {
AdventureUtil.consoleMessage("[CustomFishing] Saving Fishing bag data...");
DataManager dataManager = plugin.getDataManager();
for (PlayerBagData playerBagData : dataMap.values()) {
dataManager.getDataStorageInterface().saveBagData(playerBagData, false);
for (Map.Entry<UUID, Inventory> entry : dataMap.entrySet()) {
dataManager.getDataStorageInterface().saveBagData(entry.getKey(), entry.getValue(), false);
}
AdventureUtil.consoleMessage("[CustomFishing] Fishing bag data saved for " + dataMap.size() + " online players.");
}, 12000, 12000);
@@ -95,16 +95,19 @@ public class BagDataManager extends Function {
public void disable() {
unload();
for (PlayerBagData playerBagData : dataMap.values()) {
DataManager dataManager = CustomFishing.getInstance().getDataManager();
dataManager.getDataStorageInterface().saveBagData(playerBagData, true);
DataManager dataManager = plugin.getDataManager();
for (Map.Entry<UUID, Inventory> entry : dataMap.entrySet()) {
for (HumanEntity humanEntity : entry.getValue().getViewers()) {
humanEntity.closeInventory();
}
dataManager.getDataStorageInterface().saveBagData(entry.getKey(), entry.getValue(), false);
}
dataMap.clear();
tempData.clear();
timerSave.cancel();
}
public PlayerBagData getPlayerBagData(UUID uuid) {
public Inventory getPlayerBagData(UUID uuid) {
return dataMap.get(uuid);
}
@@ -112,36 +115,36 @@ public class BagDataManager extends Function {
Player owner = ownerOffline.getPlayer();
//not online
if (owner == null) {
Inventory inventory = plugin.getDataManager().getDataStorageInterface().loadBagData(ownerOffline, force);
Inventory inventory = plugin.getDataManager().getDataStorageInterface().loadBagData(ownerOffline.getUniqueId(), force);
if (inventory == null) {
AdventureUtil.playerMessage(viewer, "<red>[CustomFishing] Failed to load bag data for player " + ownerOffline.getName());
AdventureUtil.playerMessage(viewer, "<red>This might be caused when the target player is online but on another server");
AdventureUtil.playerMessage(viewer, "<red>Use /fishingbag open [Player] --force to ignore this warning");
return;
}
PlayerBagData playerBagData = new PlayerBagData(ownerOffline, inventory);
tempData.add(playerBagData);
tempData.put(ownerOffline.getUniqueId(), inventory);
viewer.openInventory(inventory);
}
//online
else {
PlayerBagData playerBagData = dataMap.get(owner.getUniqueId());
if (playerBagData == null) {
Inventory inventory = dataMap.get(owner.getUniqueId());
if (inventory == null) {
AdventureUtil.consoleMessage("<red>[CustomFishing] Bag data is not loaded for player " + owner.getName());
}
else {
openGui(owner, viewer, playerBagData);
openGui(owner, viewer, inventory);
}
}
}
@Override
public void onQuit(Player player) {
PlayerBagData playerBagData = dataMap.remove(player.getUniqueId());
UUID uuid = player.getUniqueId();
Inventory inventory = dataMap.remove(uuid);
triedTimes.remove(player.getUniqueId());
if (playerBagData != null) {
if (inventory != null) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
plugin.getDataManager().getDataStorageInterface().saveBagData(playerBagData, true);
plugin.getDataManager().getDataStorageInterface().saveBagData(uuid, inventory, true);
});
}
}
@@ -155,24 +158,19 @@ public class BagDataManager extends Function {
public void joinReadData(Player player, boolean force) {
if (player == null || !player.isOnline()) return;
Inventory inventory = plugin.getDataManager().getDataStorageInterface().loadBagData(player, force);
Inventory inventory = plugin.getDataManager().getDataStorageInterface().loadBagData(player.getUniqueId(), force);
if (inventory != null) {
PlayerBagData playerBagData = new PlayerBagData(player, inventory);
dataMap.put(player.getUniqueId(), playerBagData);
dataMap.put(player.getUniqueId(), inventory);
}
// If sql exception or data is locked
else if (!force) {
// can still try to load
if (!checkTriedTimes(player.getUniqueId())) {
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> {
joinReadData(player, false);
}, 20);
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> joinReadData(player, false), 20);
}
// tried 3 times
else {
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> {
joinReadData(player, true);
}, 20);
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> joinReadData(player, true), 20);
}
}
}
@@ -200,9 +198,8 @@ public class BagDataManager extends Function {
@Override
public void onClickInventory(InventoryClickEvent event) {
final Player player = (Player) event.getWhoClicked();
PlayerBagData playerBagData = dataMap.get(player.getUniqueId());
if (playerBagData == null) return;
if (playerBagData.getInventory() == event.getInventory()) {
Inventory fishingBagInv = dataMap.get(player.getUniqueId());
if (fishingBagInv == event.getInventory()) {
ItemStack currentItem = event.getCurrentItem();
if (currentItem == null || currentItem.getType() == Material.AIR) return;
NBTItem nbtItem = new NBTItem(currentItem);
@@ -226,9 +223,9 @@ public class BagDataManager extends Function {
public void onCloseInventory(InventoryCloseEvent event) {
final Player player = (Player) event.getPlayer();
Inventory inventory = event.getInventory();
PlayerBagData playerBagData = dataMap.get(player.getUniqueId());
if (playerBagData != null) {
if (inventory == playerBagData.getInventory()) {
Inventory fishingBagInv = dataMap.get(player.getUniqueId());
if (fishingBagInv != null) {
if (inventory == fishingBagInv) {
for (ItemStack itemStack : event.getInventory().getContents()) {
if (itemStack == null || itemStack.getType() == Material.AIR) continue;
NBTItem nbtItem = new NBTItem(itemStack);
@@ -238,19 +235,18 @@ public class BagDataManager extends Function {
}
return;
}
for (PlayerBagData temp : tempData) {
if (temp.getInventory() == inventory) {
tempData.remove(temp);
for (Map.Entry<UUID, Inventory> entry : tempData.entrySet()) {
if (entry.getValue() == inventory) {
tempData.remove(entry.getKey());
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
plugin.getDataManager().getDataStorageInterface().saveBagData(temp, true);
plugin.getDataManager().getDataStorageInterface().saveBagData(entry.getKey(), entry.getValue(), true);
});
}
}
}
}
public void openGui(Player owner, Player viewer, PlayerBagData playerBagData) {
Inventory inventory = playerBagData.getInventory();
public void openGui(Player owner, Player viewer, Inventory inventory) {
int size = 1;
for (int i = 6; i > 1; i--) {
if (owner.hasPermission("fishingbag.rows." + i)) {
@@ -259,10 +255,10 @@ public class BagDataManager extends Function {
}
}
if (size * 9 != inventory.getSize()) {
ItemStack[] itemStacks = playerBagData.getInventory().getContents();
ItemStack[] itemStacks = inventory.getContents();
Inventory newInv = Bukkit.createInventory(null, size * 9, "{CustomFishing_Bag_" + owner.getName() + "}");
newInv.setContents(itemStacks);
playerBagData.setInventory(newInv);
dataMap.put(owner.getUniqueId(), newInv);
viewer.openInventory(newInv);
}
else {
@@ -270,7 +266,7 @@ public class BagDataManager extends Function {
}
}
public boolean checkTriedTimes(UUID uuid) {
private boolean checkTriedTimes(UUID uuid) {
Integer previous = triedTimes.get(uuid);
if (previous == null) {
triedTimes.put(uuid, 1);

View File

@@ -38,7 +38,7 @@ import java.util.*;
public class CompetitionManager extends Function {
private CustomFishing plugin;
private final CustomFishing plugin;
// Competitions that can be triggered at a specified time
private final HashMap<String, CompetitionConfig> competitionsT;
// Competitions that can be triggered with a command
@@ -83,81 +83,71 @@ public class CompetitionManager extends Function {
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
Set<String> keys = config.getKeys(false);
for (String key : keys) {
ConfigurationSection section = config.getConfigurationSection(key);
if (section == null) continue;
ConfigurationSection competitionSection = config.getConfigurationSection(key);
if (competitionSection == null) continue;
boolean enableBsb = competitionSection.getBoolean("bossbar.enable", false);
BossBarConfig bossBarConfig = new BossBarConfig(
competitionSection.getStringList("bossbar.text").toArray(new String[0]),
BossBarOverlay.valueOf(competitionSection.getString("bossbar.overlay","SOLID").toUpperCase()),
BarColor.valueOf(competitionSection.getString("bossbar.color","WHITE").toUpperCase()),
competitionSection.getInt("bossbar.refresh-rate",10),
competitionSection.getInt("bossbar.switch-interval", 200)
);
HashMap<String, ActionInterface[]> rewardsMap = new HashMap<>();
Objects.requireNonNull(competitionSection.getConfigurationSection("prize")).getKeys(false).forEach(rank -> {
List<ActionInterface> rewards = new ArrayList<>();
if (competitionSection.contains("prize." + rank + ".messages"))
rewards.add(new MessageActionImpl(competitionSection.getStringList("prize." + rank + ".messages").toArray(new String[0]), null));
if (competitionSection.contains("prize." + rank + ".commands"))
rewards.add(new CommandActionImpl(competitionSection.getStringList("prize." + rank + ".commands").toArray(new String[0]), null));
rewardsMap.put(rank, rewards.toArray(new ActionInterface[0]));
});
CompetitionConfig competitionConfig = new CompetitionConfig(
competitionSection.getInt("duration",600),
competitionSection.getInt("min-players",1),
competitionSection.getStringList("broadcast.start"),
competitionSection.getStringList("broadcast.end"),
competitionSection.getStringList("command.start"),
competitionSection.getStringList("command.end"),
competitionSection.getStringList("command.join"),
CompetitionGoal.valueOf(competitionSection.getString("goal", "RANDOM")),
bossBarConfig,
enableBsb,
rewardsMap
);
if (competitionSection.contains("start-weekday")) {
List<Integer> days = new ArrayList<>();
for (String weekDay : competitionSection.getStringList("start-weekday")) {
switch (weekDay) {
case "Sunday" -> days.add(1);
case "Monday" -> days.add(2);
case "Tuesday" -> days.add(3);
case "Wednesday" -> days.add(4);
case "Thursday" -> days.add(5);
case "Friday" -> days.add(6);
case "Saturday" -> days.add(7);
default -> AdventureUtil.consoleMessage("[CustomFishing] Unknown weekday: " + weekDay);
}
}
competitionConfig.setWeekday(days);
}
if (competitionSection.contains("start-date")) {
List<Integer> days = new ArrayList<>();
for (String weekDay : competitionSection.getStringList("start-date")) {
days.add(Integer.parseInt(weekDay));
}
competitionConfig.setDate(days);
}
competitionSection.getStringList("start-time").forEach(time -> competitionsT.put(time, competitionConfig));
competitionsC.put(key, competitionConfig);
amount++;
}
}
AdventureUtil.consoleMessage("[CustomFishing] Loaded <green>" + amount + " <gray>competition(s)");
YamlConfiguration config = ConfigUtil.getConfig("competitions/default.yml");
Set<String> keys = config.getKeys(false);
keys.forEach(key -> {
boolean enableBsb = config.getBoolean(key + ".bossbar.enable", false);
BossBarConfig bossBarConfig = new BossBarConfig(
config.getStringList(key + ".bossbar.text").toArray(new String[0]),
BossBarOverlay.valueOf(config.getString(key + ".bossbar.overlay","SOLID").toUpperCase()),
BarColor.valueOf(config.getString(key + ".bossbar.color","WHITE").toUpperCase()),
config.getInt(key + ".bossbar.refresh-rate",10),
config.getInt(key + ".bossbar.switch-interval", 200)
);
HashMap<String, ActionInterface[]> rewardsMap = new HashMap<>();
Objects.requireNonNull(config.getConfigurationSection(key + ".prize")).getKeys(false).forEach(rank -> {
List<ActionInterface> rewards = new ArrayList<>();
if (config.contains(key + ".prize." + rank + ".messages"))
rewards.add(new MessageActionImpl(config.getStringList(key + ".prize." + rank + ".messages").toArray(new String[0]), null));
if (config.contains(key + ".prize." + rank + ".commands"))
rewards.add(new CommandActionImpl(config.getStringList(key + ".prize." + rank + ".commands").toArray(new String[0]), null));
rewardsMap.put(rank, rewards.toArray(new ActionInterface[0]));
});
CompetitionConfig competitionConfig = new CompetitionConfig(
config.getInt(key + ".duration",600),
config.getInt(key + ".min-players",1),
config.getStringList(key + ".broadcast.start"),
config.getStringList(key + ".broadcast.end"),
config.getStringList(key + ".command.start"),
config.getStringList(key + ".command.end"),
config.getStringList(key + ".command.join"),
CompetitionGoal.valueOf(config.getString(key + ".goal", "RANDOM")),
bossBarConfig,
enableBsb,
rewardsMap
);
if (config.contains(key + ".start-weekday")) {
List<Integer> days = new ArrayList<>();
for (String weekDay : config.getStringList(key + ".start-weekday")) {
switch (weekDay) {
case "Sunday" -> days.add(1);
case "Monday" -> days.add(2);
case "Tuesday" -> days.add(3);
case "Wednesday" -> days.add(4);
case "Thursday" -> days.add(5);
case "Friday" -> days.add(6);
case "Saturday" -> days.add(7);
default -> AdventureUtil.consoleMessage("[CustomFishing] Unknown weekday: " + weekDay);
}
}
competitionConfig.setWeekday(days);
}
if (config.contains(key + ".start-date")) {
List<Integer> days = new ArrayList<>();
for (String weekDay : config.getStringList(key + ".start-date")) {
days.add(Integer.parseInt(weekDay));
}
competitionConfig.setDate(days);
}
config.getStringList(key + ".start-time").forEach(time -> competitionsT.put(time, competitionConfig));
competitionsC.put(key, competitionConfig);
});
}
public HashMap<String, CompetitionConfig> getCompetitionsT() {

View File

@@ -34,7 +34,6 @@ public class ConfigManager {
public static boolean whiteOrBlack;
public static String priority;
public static String lang;
public static boolean otherLootBar;
public static boolean enableVanillaLoot;
public static boolean enableMcMMOLoot;
public static double vanillaLootRatio;
@@ -47,7 +46,7 @@ public class ConfigManager {
public static boolean convertMMOItems;
public static boolean preventPickUp;
public static boolean enableFishingBag;
public static boolean alwaysFishingBar;
public static boolean otherLootHasFishingBar;
public static boolean allRodsFishInLava;
public static boolean enableSuccessTitle;
public static String[] successTitle;
@@ -76,13 +75,15 @@ public class ConfigManager {
public static boolean disableBar;
public static boolean instantBar;
public static String fishingBagTitle;
public static boolean bStats;
public static HashSet<Material> bagWhiteListItems;
public static boolean enableStatistics;
public static void load() {
ConfigUtil.update("config.yml");
YamlConfiguration config = ConfigUtil.getConfig("config.yml");
lang = config.getString("lang","english");
bStats = config.getBoolean("metrics", true);
loadMechanics(config);
loadTitle(config);
loadFishingWorlds(config);
@@ -100,8 +101,7 @@ public class ConfigManager {
private static void loadMechanics(YamlConfiguration config) {
disableBar = config.getBoolean("mechanics.disable-bar-mechanic", false);
instantBar = config.getBoolean("mechanics.instant-bar", false);
alwaysFishingBar = config.getBoolean("mechanics.other-loots.fishing-bar", true);
otherLootBar = config.getBoolean("mechanics.other-loots.fishing-bar", true);
otherLootHasFishingBar = config.getBoolean("mechanics.other-loots.fishing-bar", true);
enableVanillaLoot = config.getBoolean("mechanics.other-loots.vanilla.enable", true);
vanillaLootRatio = config.getDouble("mechanics.other-loots.vanilla.ratio", 0.4);
enableMcMMOLoot = config.getBoolean("mechanics.other-loots.mcMMO.enable", false);

View File

@@ -21,23 +21,19 @@ import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.data.storage.DataStorageInterface;
import net.momirealms.customfishing.data.storage.FileStorageImpl;
import net.momirealms.customfishing.data.storage.MySQLStorageImpl;
import net.momirealms.customfishing.data.storage.StorageType;
import net.momirealms.customfishing.object.Function;
import net.momirealms.customfishing.util.ConfigUtil;
import org.bukkit.configuration.file.YamlConfiguration;
public class DataManager extends Function {
private final DataStorageInterface dataStorageInterface;
private CustomFishing plugin;
private DataStorageInterface dataStorageInterface;
private final CustomFishing plugin;
private StorageType storageType;
public DataManager(CustomFishing plugin) {
this.plugin = plugin;
YamlConfiguration config = ConfigUtil.getConfig("database.yml");
if (config.getString("data-storage-method","YAML").equalsIgnoreCase("YAML")) {
this.dataStorageInterface = new FileStorageImpl(plugin);
} else {
this.dataStorageInterface = new MySQLStorageImpl(plugin);
}
load();
}
@@ -45,13 +41,33 @@ public class DataManager extends Function {
return dataStorageInterface;
}
private boolean loadStorageMode() {
YamlConfiguration config = ConfigUtil.getConfig("database.yml");
if (config.getString("data-storage-method","YAML").equalsIgnoreCase("YAML")) {
if (storageType != StorageType.YAML) {
this.dataStorageInterface = new FileStorageImpl(plugin);
this.storageType = StorageType.YAML;
return true;
}
} else {
if (storageType != StorageType.SQL) {
this.dataStorageInterface = new MySQLStorageImpl(plugin);
this.storageType = StorageType.SQL;
return true;
}
}
return false;
}
@Override
public void load() {
this.dataStorageInterface.initialize();
if (loadStorageMode()) this.dataStorageInterface.initialize();
}
@Override
public void unload() {
this.dataStorageInterface.disable();
YamlConfiguration config = ConfigUtil.getConfig("database.yml");
StorageType st = config.getString("data-storage-method","YAML").equalsIgnoreCase("YAML") ? StorageType.YAML : StorageType.SQL;
if (this.dataStorageInterface != null && dataStorageInterface.getStorageType() != st) this.dataStorageInterface.disable();
}
}

View File

@@ -158,6 +158,7 @@ public class EffectManager extends Function {
for (String key : keys) {
ConfigurationSection rodSection = config.getConfigurationSection(key);
if (rodSection == null) continue;
rodSection.set("material", "fishing_rod");
Item item = new Item(rodSection, key);
rodItems.put(key, ItemStackUtil.addIdentifier(ItemStackUtil.getFromItem(item), "rod", key));
if (rodSection.contains("effect")) {
@@ -186,8 +187,8 @@ public class EffectManager extends Function {
case "time" -> effect.setTimeModifier(section.getDouble(modifier));
case "difficulty" -> effect.setDifficulty(section.getInt(modifier));
case "double-loot" -> effect.setDoubleLootChance(section.getDouble(modifier));
case "score" -> effect.setScoreMultiplier(section.getDouble(modifier) - 1);
case "size-multiply" -> effect.setSizeMultiplier(section.getDouble(modifier) - 1);
case "score" -> effect.setScoreMultiplier(section.getDouble(modifier));
case "size-multiply" -> effect.setSizeMultiplier(section.getDouble(modifier));
case "lava-fishing" -> effect.setCanLavaFishing(section.getBoolean(modifier, false));
}
}

View File

@@ -22,11 +22,9 @@ import de.tr7zw.changeme.nbtapi.NBTItem;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.api.event.*;
import net.momirealms.customfishing.data.PlayerBagData;
import net.momirealms.customfishing.fishing.*;
import net.momirealms.customfishing.fishing.bar.FishingBar;
import net.momirealms.customfishing.fishing.bar.ModeOneBar;
@@ -54,7 +52,6 @@ import net.momirealms.customfishing.util.AdventureUtil;
import net.momirealms.customfishing.util.FakeItemUtil;
import net.momirealms.customfishing.util.ItemStackUtil;
import net.momirealms.customfishing.util.LocationUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
@@ -78,6 +75,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class FishingManager extends Function {
@@ -248,9 +247,8 @@ public class FishingManager extends Function {
}
if (ConfigManager.enableFishingBag && noBait) {
PlayerBagData playerBagData = plugin.getBagDataManager().getPlayerBagData(player.getUniqueId());
if (playerBagData != null) {
Inventory baitInv = playerBagData.getInventory();
Inventory baitInv = plugin.getBagDataManager().getPlayerBagData(player.getUniqueId());
if (baitInv != null) {
for (int i = 0; i < baitInv.getSize(); i++) {
ItemStack itemStack = baitInv.getItem(i);
if (itemStack == null || itemStack.getType() == Material.AIR) continue;
@@ -373,18 +371,22 @@ public class FishingManager extends Function {
if (ConfigManager.enableVanillaLoot) {
// Not a vanilla loot
if (ConfigManager.vanillaLootRatio < Math.random()) {
event.setCancelled(true);
if (loot != null) {
vanillaLoot.remove(player);
if (loot.isDisableBar()) {
noBarWaterReelIn(event);
return;
}
}
else {
vanillaLoot.put(player, new VanillaLoot(item.getItemStack(), event.getExpToDrop()));
}
event.setCancelled(true);
showFishingBar(player, loot);
}
// Is vanilla loot
else {
if (ConfigManager.alwaysFishingBar) {
if (ConfigManager.otherLootHasFishingBar) {
event.setCancelled(true);
vanillaLoot.put(player, new VanillaLoot(item.getItemStack(), event.getExpToDrop()));
showFishingBar(player, null);
@@ -400,6 +402,10 @@ public class FishingManager extends Function {
AdventureUtil.playerMessage(player, MessageManager.prefix + MessageManager.noLoot);
}
else {
if (loot.isDisableBar()) {
noBarWaterReelIn(event);
return;
}
event.setCancelled(true);
showFishingBar(player, loot);
}
@@ -507,6 +513,10 @@ public class FishingManager extends Function {
if (bobberCheckTask != null && bobberCheckTask.isHooked()) {
Loot loot = nextLoot.get(player);
if (loot == Loot.EMPTY) return;
if (loot.isDisableBar()) {
noBarLavaReelIn(event);
return;
}
showFishingBar(player, loot);
event.setCancelled(true);
}
@@ -521,13 +531,7 @@ public class FishingManager extends Function {
}
if (Competition.currentCompetition != null) {
float score;
if (Competition.currentCompetition.getGoal() == CompetitionGoal.MAX_SIZE || Competition.currentCompetition.getGoal() == CompetitionGoal.TOTAL_SIZE) {
score = getSize(drop);
}
else {
score = (float) ((float) droppedItem.getScore() * scoreMultiplier);
}
float score = Competition.currentCompetition.getGoal() == CompetitionGoal.MAX_SIZE || Competition.currentCompetition.getGoal() == CompetitionGoal.TOTAL_SIZE ? getSize(drop) : (float) ((float) droppedItem.getScore() * scoreMultiplier);
Competition.currentCompetition.refreshData(player, score, fishResultEvent.isDouble());
Competition.currentCompetition.tryAddBossBarToPlayer(player);
}
@@ -590,8 +594,8 @@ public class FishingManager extends Function {
private void dropItem(Player player, Location location, boolean isDouble, ItemStack itemStack) {
if (itemStack.getType() == Material.AIR) return;
Entity item = location.getWorld().dropItem(location, itemStack);
Vector vector = player.getLocation().subtract(location).toVector().multiply(0.1);
vector = vector.setY((vector.getY()+0.2) * 1.15);
Vector vector = player.getLocation().subtract(location).toVector().multiply(0.105);
vector = vector.setY((vector.getY()+0.19) * 1.15);
item.setVelocity(vector);
if (isDouble) {
Entity item2 = location.getWorld().dropItem(location, itemStack);
@@ -637,12 +641,7 @@ public class FishingManager extends Function {
}
if (Competition.currentCompetition != null) {
float score;
if (Competition.currentCompetition.getGoal() == CompetitionGoal.MAX_SIZE || Competition.currentCompetition.getGoal() == CompetitionGoal.TOTAL_SIZE) {
score = 0;
}
else score = (float) loot.getScore();
float score = Competition.currentCompetition.getGoal() == CompetitionGoal.MAX_SIZE || Competition.currentCompetition.getGoal() == CompetitionGoal.TOTAL_SIZE ? 0 : (float) loot.getScore();
Competition.currentCompetition.refreshData(player, (float) (score * scoreMultiplier), false);
Competition.currentCompetition.tryAddBossBarToPlayer(player);
}
@@ -655,24 +654,18 @@ public class FishingManager extends Function {
@NotNull
private Component getTitleComponent(ItemStack itemStack, String text) {
Component component;
if (text.contains("{loot}")){
text = text.replace("{loot}","|");
if (text.startsWith("|")){
component = getDisplayName(itemStack).append(MiniMessage.miniMessage().deserialize(AdventureUtil.replaceLegacy(text.substring(1))));
}
else if (text.endsWith("|")){
component = MiniMessage.miniMessage().deserialize(AdventureUtil.replaceLegacy(text.substring(0,text.length() - 1))).append(getDisplayName(itemStack));
}
else {
String[] titleSplit = StringUtils.split(text, "|");
component = MiniMessage.miniMessage().deserialize(AdventureUtil.replaceLegacy(titleSplit[0])).append(getDisplayName(itemStack)).append(MiniMessage.miniMessage().deserialize(AdventureUtil.replaceLegacy(titleSplit[1])));
}
Component titleComponent = Component.text("");
int startIndex = 0;
int lootIndex;
while ((lootIndex = text.indexOf("{loot}", startIndex)) != -1) {
String before = text.substring(startIndex, lootIndex);
titleComponent = titleComponent.append(AdventureUtil.getComponentFromMiniMessage(before));
startIndex = lootIndex + 6;
titleComponent = titleComponent.append(getDisplayName(itemStack));
}
else {
component = MiniMessage.miniMessage().deserialize(AdventureUtil.replaceLegacy(text));
}
return component;
String after = text.substring(startIndex);
titleComponent = titleComponent.append(AdventureUtil.getComponentFromMiniMessage(after));
return titleComponent;
}
private void sendSuccessTitle(Player player, String loot) {
@@ -714,20 +707,25 @@ public class FishingManager extends Function {
private void loseDurability(Player player) {
if (player.getGameMode() == GameMode.CREATIVE) return;
Bukkit.getScheduler().runTaskLater(plugin, () -> {
PlayerInventory inventory = player.getInventory();
ItemStack mainHand = inventory.getItemInMainHand();
if (mainHand.getType() == Material.FISHING_ROD){
plugin.getIntegrationManager().loseCustomDurability(mainHand, player);
}
else {
ItemStack offHand = inventory.getItemInOffHand();
if (offHand.getType() == Material.FISHING_ROD){
plugin.getIntegrationManager().loseCustomDurability(offHand, player);
}
ItemStack rod = getFishingRod(player);
if (rod != null) {
plugin.getIntegrationManager().loseCustomDurability(rod, player);
}
}, 1);
}
private ItemStack getFishingRod(Player player) {
ItemStack mainHand = player.getInventory().getItemInMainHand();
if (mainHand.getType() == Material.FISHING_ROD) {
return mainHand;
}
ItemStack offHand = player.getInventory().getItemInOffHand();
if (offHand.getType() == Material.FISHING_ROD) {
return offHand;
}
return null;
}
public void fail(Player player, Loot loot, boolean isVanilla) {
FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.FAILURE, false, null, "null");
Bukkit.getServer().getPluginManager().callEvent(fishResultEvent);
@@ -804,16 +802,13 @@ public class FishingManager extends Function {
private void setCustomTag(ItemStack itemStack) {
if(itemStack.getType() != Material.FISHING_ROD) return;
NBTItem nbtItem = new NBTItem(itemStack);
if (nbtItem.getCompound("CustomFishing") != null) return;
if (!nbtItem.hasTag("MMOITEMS_ITEM_ID")) return;
if (nbtItem.getCompound("CustomFishing") != null || !nbtItem.hasTag("MMOITEMS_ITEM_ID")) return;
ItemStackUtil.addIdentifier(itemStack, "rod", nbtItem.getString("MMOITEMS_ITEM_ID"));
}
public boolean isCoolDown(Player player, long delay) {
long time = System.currentTimeMillis();
if (time - (coolDown.getOrDefault(player, time - delay)) < delay) return true;
coolDown.put(player, time);
return false;
return coolDown.computeIfAbsent(player, k -> time - delay) + delay > time;
}
private void enchantBonus(Effect initialEffect, ItemStack itemStack) {
@@ -828,24 +823,22 @@ public class FishingManager extends Function {
}
public List<Loot> getPossibleLootList(FishingCondition fishingCondition, boolean finder, Collection<Loot> values) {
List<Loot> available = new ArrayList<>();
outer:
for (Loot loot : values) {
if (finder && !loot.isShowInFinder()) continue;
RequirementInterface[] requirements = loot.getRequirements();
if (requirements == null){
available.add(loot);
}
else {
for (RequirementInterface requirement : requirements) {
if (!requirement.isConditionMet(fishingCondition)) {
continue outer;
}
}
available.add(loot);
Stream<Loot> stream = values.stream();
if (finder) {
stream = stream.filter(Loot::isShowInFinder);
}
return stream.filter(loot -> {
RequirementInterface[] requirements = loot.getRequirements();
if (requirements == null) {
return true;
}
for (RequirementInterface requirement : requirements) {
if (!requirement.isConditionMet(fishingCondition)) {
return false;
}
}
return available;
return true;
}).collect(Collectors.toList());
}
@Override
@@ -907,10 +900,9 @@ public class FishingManager extends Function {
}
}
Location bottomLoc = coreLoc.clone().subtract(0, totem.getOriginalModel().getCorePos().getY(), 0);
ActivatedTotem activatedTotem = new ActivatedTotem(bottomLoc, totem, this, direction);
ActivatedTotem activatedTotem = new ActivatedTotem(coreLoc, totem, this, direction);
activatedTotem.runTaskTimer(plugin, 10, 20);
activeTotemMap.put(LocationUtils.getSimpleLocation(bottomLoc), activatedTotem);
activeTotemMap.put(LocationUtils.getSimpleLocation(coreLoc), activatedTotem);
}
private void useFinder(Player player) {
@@ -933,43 +925,26 @@ public class FishingManager extends Function {
}
private void showFishingBar(Player player, @Nullable Loot loot){
MiniGameConfig game;
if (loot != null && loot.getFishingGames() != null) {
game = loot.getFishingGames()[new Random().nextInt(loot.getFishingGames().length)];
}
else {
game = plugin.getBarMechanicManager().getRandomGame();
}
int difficult = game.getRandomDifficulty();
Effect effect = nextEffect.get(player);
if (effect != null) {
difficult += effect.getDifficulty();
}
FishHookEvent fishHookEvent = new FishHookEvent(player, difficult);
MiniGameConfig game = (loot != null && loot.getFishingGames() != null)
? loot.getFishingGames()[new Random().nextInt(loot.getFishingGames().length)]
: plugin.getBarMechanicManager().getRandomGame();
int difficult = game.getRandomDifficulty() + nextEffect.getOrDefault(player, new Effect()).getDifficulty();
FishHookEvent fishHookEvent = new FishHookEvent(player, Math.max(1, difficult));
Bukkit.getPluginManager().callEvent(fishHookEvent);
if (fishHookEvent.isCancelled()) {
return;
}
difficult = fishHookEvent.getDifficulty();
if (difficult < 1) {
difficult = 1;
}
FishingBar fishingBar = game.getRandomBar();
FishingGame fishingGame = null;
if (fishingBar instanceof ModeOneBar modeOneBar) {
ModeOneGame modeOneGame = new ModeOneGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, difficult, modeOneBar);
modeOneGame.runTaskTimer(plugin, 0, 1);
fishingPlayerMap.put(player, modeOneGame);
fishingGame = new ModeOneGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, fishHookEvent.getDifficulty(), modeOneBar);
}
else if (fishingBar instanceof ModeTwoBar modeTwoBar) {
ModeTwoGame modeTwoGame = new ModeTwoGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, difficult, modeTwoBar);
modeTwoGame.runTaskTimer(plugin, 0, 1);
fishingPlayerMap.put(player, modeTwoGame);
fishingGame = new ModeTwoGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, fishHookEvent.getDifficulty(), modeTwoBar);
}
else if (fishingBar instanceof ModeThreeBar modeThreeBar) {
ModeThreeGame modeThreeGame = new ModeThreeGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, difficult, modeThreeBar);
modeThreeGame.runTaskTimer(plugin, 0, 1);
fishingPlayerMap.put(player, modeThreeGame);
fishingGame = new ModeThreeGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, fishHookEvent.getDifficulty(), modeThreeBar);
}
if (fishingGame != null) {
fishingGame.runTaskTimer(plugin, 0, 1);
fishingPlayerMap.put(player, fishingGame);
}
if (vanillaLoot.get(player) == null && loot != null){
for (ActionInterface action : loot.getHookActions()) {
@@ -987,7 +962,6 @@ public class FishingManager extends Function {
vanillaLoot.remove(player);
BobberCheckTask task = hookCheckTaskMap.remove(player);
if (task != null) task.stop();
// prevent bar duplication
removeBobber(player);
}
@@ -1014,8 +988,8 @@ public class FishingManager extends Function {
else return GsonComponentSerializer.gson().deserialize("{\"translate\":\"item.minecraft." + type + "\"}");
}
public void removeTotem(Location location) {
activeTotemMap.remove(LocationUtils.getSimpleLocation(location));
public void removeTotem(Location coreLoc) {
activeTotemMap.remove(LocationUtils.getSimpleLocation(coreLoc));
}
public void removePlayerFromLavaFishing(Player player) {
@@ -1023,16 +997,12 @@ public class FishingManager extends Function {
}
public float getSize(ItemStack itemStack) {
NBTItem nbtItem = new NBTItem(itemStack);
NBTCompound fishMeta = nbtItem.getCompound("FishMeta");
if (fishMeta != null) {
return fishMeta.getFloat("size");
}
return 0;
NBTCompound fishMeta = new NBTItem(itemStack).getCompound("FishMeta");
return fishMeta != null ? fishMeta.getFloat("size") : 0;
}
public void addTotemBreakDetectToCache(SimpleLocation part, SimpleLocation bottom) {
breakDetectionMap.put(part, bottom);
public void addTotemBreakDetectToCache(SimpleLocation part, SimpleLocation coreLoc) {
breakDetectionMap.put(part, coreLoc);
}
public void removeTotemBreakDetectFromCache(SimpleLocation part) {
@@ -1041,12 +1011,13 @@ public class FishingManager extends Function {
@Override
public void onBreakBlock(BlockBreakEvent event) {
final Block block = event.getBlock();
SimpleLocation bottomLoc = breakDetectionMap.get(LocationUtils.getSimpleLocation(block.getLocation()));
if (bottomLoc == null) return;
ActivatedTotem activatedTotem = activeTotemMap.get(bottomLoc);
if (activatedTotem == null) return;
activatedTotem.stop();
SimpleLocation coreLoc = breakDetectionMap.get(LocationUtils.getSimpleLocation(event.getBlock().getLocation()));
if (coreLoc != null) {
ActivatedTotem activatedTotem = activeTotemMap.get(coreLoc);
if (activatedTotem != null) {
activatedTotem.stop();
}
}
}
public void removeBobber(Player player) {
@@ -1064,8 +1035,7 @@ public class FishingManager extends Function {
@Override
public void onConsumeItem(PlayerItemConsumeEvent event) {
ItemStack itemStack = event.getItem();
NBTItem nbtItem = new NBTItem(itemStack);
NBTCompound nbtCompound = nbtItem.getCompound("CustomFishing");
NBTCompound nbtCompound = new NBTItem(itemStack).getCompound("CustomFishing");
if (nbtCompound == null) return;
if (!nbtCompound.getString("type").equals("loot")) return;
String lootKey = nbtCompound.getString("id");

View File

@@ -63,7 +63,7 @@ public class IntegrationManager extends Function {
public IntegrationManager(CustomFishing plugin) {
this.plugin = plugin;
this.pluginManager = Bukkit.getPluginManager();
this.placeholderManager = new PlaceholderManager();
this.placeholderManager = new PlaceholderManager(plugin);
this.blockInterface = new VanillaBlockImpl();
}

View File

@@ -113,7 +113,8 @@ public class LootManager extends Function {
new MobVector(
mobSection.getDouble("vector.horizontal",1.1),
mobSection.getDouble("vector.vertical",1.3)
)
),
mobSection.getBoolean("disable-bar-mechanic", false)
);
setActions(mobSection, loot);
@@ -152,7 +153,8 @@ public class LootManager extends Function {
lootSection.getInt("weight",10),
lootSection.getBoolean("show-in-fishfinder", true),
lootSection.getDouble("score"),
lootSection.getBoolean("random-durability", false)
lootSection.getBoolean("random-durability", false),
lootSection.getBoolean("disable-bar-mechanic", false)
);
if (lootSection.contains("size")) {

View File

@@ -56,6 +56,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
public class SellManager extends Function {
@@ -150,7 +151,7 @@ public class SellManager extends Function {
public void joinReadData(Player player, boolean force) {
if (player == null || !player.isOnline()) return;
PlayerSellData sellData = plugin.getDataManager().getDataStorageInterface().loadSellData(player, force);
PlayerSellData sellData = plugin.getDataManager().getDataStorageInterface().loadSellData(player.getUniqueId(), force);
if (sellData != null) {
sellDataMap.put(player.getUniqueId(), sellData);
}

View File

@@ -0,0 +1,4 @@
package net.momirealms.customfishing.manager;
public class StatisticsManager {
}

View File

@@ -18,7 +18,6 @@
package net.momirealms.customfishing.manager;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.fishing.requirements.*;
import net.momirealms.customfishing.fishing.totem.CorePos;
import net.momirealms.customfishing.fishing.totem.FinalModel;
import net.momirealms.customfishing.fishing.totem.OriginalModel;
@@ -112,7 +111,7 @@ public class TotemManager extends Function {
}
private void loadBlocks() {
YamlConfiguration config = ConfigUtil.getConfig("totem-blocks/default.yml");
YamlConfiguration config = ConfigUtil.getConfig("totem_blocks/default.yml");
config.getKeys(false).forEach(key -> blockIDs.put(key, config.getString(key)));
config.getKeys(false).forEach(key -> invertedIDs.put(config.getString(key), key));
}
@@ -427,7 +426,7 @@ public class TotemManager extends Function {
return 0;
}
public void removeModel(FinalModel model, Location location, int direction) {
public void removeModel(FinalModel model, Location coreLoc, int direction) {
BlockInterface blockInterface = plugin.getIntegrationManager().getBlockInterface();
@@ -440,7 +439,7 @@ public class TotemManager extends Function {
int length = model.getLength();
int width = model.getWidth();
Location startLoc = location.clone().subtract(0, yOffset, 0);
Location startLoc = coreLoc.clone().subtract(0, yOffset, 0);
switch (direction) {
case 1:
@@ -455,7 +454,7 @@ public class TotemManager extends Function {
if (!model.getElement(x, z, i).equals("*")) {
blockInterface.replaceBlock(loc.clone().add(x, 0, z), model.getElement(x, z, i));
}
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(x, 0, z)), LocationUtils.getSimpleLocation(startLoc));
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(x, 0, z)), LocationUtils.getSimpleLocation(coreLoc));
}
}
break;
@@ -471,7 +470,7 @@ public class TotemManager extends Function {
if (!model.getElement(x, z, i).equals("*")){
blockInterface.replaceBlock(loc.clone().add(-x, 0, -z), model.getElement(x, z, i));
}
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(-x, 0, -z)), LocationUtils.getSimpleLocation(startLoc));
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(-x, 0, -z)), LocationUtils.getSimpleLocation(coreLoc));
}
}
break;
@@ -487,7 +486,7 @@ public class TotemManager extends Function {
if (!model.getElement(x, z, i).equals("*")){
blockInterface.replaceBlock(loc.clone().add(z, 0, -x), model.getElement(x, z, i));
}
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(z, 0, -x)), LocationUtils.getSimpleLocation(startLoc));
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(z, 0, -x)), LocationUtils.getSimpleLocation(coreLoc));
}
}
break;
@@ -503,7 +502,7 @@ public class TotemManager extends Function {
if (!model.getElement(x, z, i).equals("*")){
blockInterface.replaceBlock(loc.clone().add(-z, 0, x), model.getElement(x, z, i));
}
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(-z, 0, x)), LocationUtils.getSimpleLocation(startLoc));
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(-z, 0, x)), LocationUtils.getSimpleLocation(coreLoc));
}
}
break;
@@ -519,7 +518,7 @@ public class TotemManager extends Function {
if (!model.getElement(x, z, i).equals("*")){
blockInterface.replaceBlock(loc.clone().add(z, 0, x), model.getElement(x, z, i));
}
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(z, 0, x)), LocationUtils.getSimpleLocation(startLoc));
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(z, 0, x)), LocationUtils.getSimpleLocation(coreLoc));
}
}
break;
@@ -535,7 +534,7 @@ public class TotemManager extends Function {
if (!model.getElement(x, z, i).equals("*")){
blockInterface.replaceBlock(loc.clone().add(-z, 0, -x), model.getElement(x, z, i));
}
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(-z, 0, -x)), LocationUtils.getSimpleLocation(startLoc));
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(-z, 0, -x)), LocationUtils.getSimpleLocation(coreLoc));
}
}
break;
@@ -551,7 +550,7 @@ public class TotemManager extends Function {
if (!model.getElement(x, z, i).equals("*")){
blockInterface.replaceBlock(loc.clone().add(x, 0, -z), model.getElement(x, z, i));
}
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(x, 0, -z)), LocationUtils.getSimpleLocation(startLoc));
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(x, 0, -z)), LocationUtils.getSimpleLocation(coreLoc));
}
}
break;
@@ -567,22 +566,20 @@ public class TotemManager extends Function {
if (!model.getElement(x, z, i).equals("*")){
blockInterface.replaceBlock(loc.clone().add(-x, 0, z), model.getElement(x, z, i));
}
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(-x, 0, z)), LocationUtils.getSimpleLocation(startLoc));
plugin.getFishingManager().addTotemBreakDetectToCache(LocationUtils.getSimpleLocation(loc.clone().add(-x, 0, z)), LocationUtils.getSimpleLocation(coreLoc));
}
}
break;
}
}
public void clearBreakDetectCache(FinalModel model, Location location, int direction) {
public void clearBreakDetectCache(FinalModel model, Location startLoc, int direction) {
CorePos corePos = model.getCorePos();
int xOffset = corePos.getX();
int yOffset = corePos.getY();
int zOffset = corePos.getZ();
int height = model.getHeight();
int length = model.getLength();
int width = model.getWidth();
Location startLoc = location.clone().subtract(0, yOffset, 0);
switch (direction) {
case 1:
for (int i = 0; i < height; i++) {

View File

@@ -41,7 +41,7 @@ public class DynamicText {
}
private void analyze(String value) {
List<String> placeholdersOwner = new ArrayList<>(CustomFishing.getInstance().getIntegrationManager().getPlaceholderManager().detectPlaceholders(value));
List<String> placeholdersOwner = new ArrayList<>(CustomFishing.getInstance().getIntegrationManager().getPlaceholderManager().detectBasicPlaceholders(value));
String origin = value;
for (String placeholder : placeholdersOwner) {
origin = origin.replace(placeholder, "%s");

View File

@@ -32,6 +32,10 @@ import java.time.Duration;
public class AdventureUtil {
public static Component getComponentFromMiniMessage(String text) {
return MiniMessage.miniMessage().deserialize(replaceLegacy(text));
}
/**
* Send a message to a command sender
* @param sender sender

View File

@@ -59,16 +59,16 @@ example:
- ' <#B0C4DE>Start fishing to participate!'
- ''
- '<#D4F2E7>◣─────────────────────────◢'
# You can add unlimited player rank info by using %x_player% & %x_score%
# You can add unlimited player rank info by using {x_player} {x_score}
end:
- '<#D4F2E7>◤─────────────────────────◥'
- ''
- ' <gray>[<#87CEFA>🎣<gray>] <gradient:#F0F8FF:#87CEFA:#F0F8FF>Fishing Competition'
- ''
- ' <#E1FFFF>Results:'
- ' <gradient:#FFF8DC:#FFD700:#FFF8DC>No.①: %1_player% - %1_score%'
- ' <gradient:#F5FFFA:#F5F5F5:#F5FFFA>No.②: %2_player% - %2_score%'
- ' <gradient:#D2B48C:#CD853F:#D2B48C>No.③: %3_player% - %3_score%'
- ' <gradient:#FFF8DC:#FFD700:#FFF8DC>No.①: {1_player} - {1_score}'
- ' <gradient:#F5FFFA:#F5F5F5:#F5FFFA>No.②: {2_player} - {2_score}'
- ' <gradient:#D2B48C:#CD853F:#D2B48C>No.③: {3_player} - {3_score}'
- ''
- '<#D4F2E7>◣─────────────────────────◢'

View File

@@ -1,5 +1,8 @@
# Don't change
config-version: '16'
config-version: '17'
# bStats
metrics: true
# Wiki: https://mo-mi.gitbook.io/xiaomomi-plugins/
# chinese/english/spanish

View File

@@ -2,6 +2,9 @@ rainbow_fish:
# Enable
# 是否启用
enable: false
# Disable bar mechanic for a certain loot
# 为某个战利品关闭捕鱼条机制
disable-bar-mechanic: false
# Nick is what to show in fish finder and titles
# 昵称将在标题和找鱼器信息中显示
nick: 'Example Fish'