9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-29 03:49:07 +00:00
This commit is contained in:
Xiao-MoMi
2022-10-21 17:07:08 +08:00
parent 69616aab3f
commit 6d3eaf682c
105 changed files with 2085 additions and 116 deletions

View File

@@ -36,7 +36,6 @@ public final class CustomFishing extends JavaPlugin {
public static CustomFishing plugin;
public static BukkitAudiences adventure;
public static ProtocolManager protocolManager;
private IntegrationManager integrationManager;
private FishingManager fishingManager;
private CompetitionManager competitionManager;
@@ -70,11 +69,12 @@ public final class CustomFishing extends JavaPlugin {
@Override
public void onLoad() {
plugin = this;
LibraryLoader.load("redis.clients","jedis","4.2.3","https://repo.maven.apache.org/maven2/");
LibraryLoader.load("redis.clients","jedis","4.3.0","https://repo.maven.apache.org/maven2/");
LibraryLoader.load("org.apache.commons","commons-pool2","2.11.1","https://repo.maven.apache.org/maven2/");
LibraryLoader.load("dev.dejvokep","boosted-yaml","1.3","https://repo.maven.apache.org/maven2/");
LibraryLoader.load("com.zaxxer","HikariCP","5.0.1","https://repo.maven.apache.org/maven2/");
LibraryLoader.load("net.objecthunter","exp4j","0.4.8","https://repo.maven.apache.org/maven2/");
LibraryLoader.load("org.mariadb.jdbc","mariadb-java-client","3.0.6","https://repo.maven.apache.org/maven2/");
}
@Override
@@ -106,6 +106,7 @@ public final class CustomFishing extends JavaPlugin {
this.lootManager.unload();
this.layoutManager.unload();
this.bagDataManager.unload();
this.bagDataManager.disable();
this.totemManager.unload();
this.sellManager.unload();
if (adventure != null) {

View File

@@ -1,3 +1,20 @@
/*
* 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.api;
public class CustomFishingAPI {

View File

@@ -1,3 +1,20 @@
/*
* 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.api.event;
import net.momirealms.customfishing.object.loot.Loot;

View File

@@ -1,3 +1,20 @@
/*
* 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.api.event;
import net.momirealms.customfishing.object.fishing.Difficulty;

View File

@@ -1,3 +1,20 @@
/*
* 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.api.event;
import net.momirealms.customfishing.object.fishing.FishResult;

View File

@@ -1,3 +1,20 @@
/*
* 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.api.event;
import net.momirealms.customfishing.object.fishing.Bonus;

View File

@@ -1,3 +1,20 @@
/*
* 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.api.event;
import net.momirealms.customfishing.object.totem.Totem;

View File

@@ -1,3 +1,20 @@
/*
* 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.commands;
import net.momirealms.customfishing.commands.subcmd.OpenCommand;

View File

@@ -1,3 +1,20 @@
/*
* 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.commands;
import net.momirealms.customfishing.CustomFishing;

View File

@@ -1,3 +1,20 @@
/*
* 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.commands.subcmd;
import net.momirealms.customfishing.commands.AbstractSubCommand;

View File

@@ -1,3 +1,20 @@
/*
* 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.commands.subcmd;
import net.momirealms.customfishing.commands.AbstractSubCommand;

View File

@@ -1,3 +1,20 @@
/*
* 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.commands.subcmd;
import net.momirealms.customfishing.commands.AbstractSubCommand;

View File

@@ -1,3 +1,20 @@
/*
* 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.commands.subcmd;
import net.momirealms.customfishing.commands.AbstractSubCommand;

View File

@@ -1,3 +1,20 @@
/*
* 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.commands.subcmd;
import net.momirealms.customfishing.commands.AbstractSubCommand;

View File

@@ -1,3 +1,20 @@
/*
* 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.commands.subcmd;
import net.momirealms.customfishing.CustomFishing;

View File

@@ -1,3 +1,20 @@
/*
* 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.commands.subcmd;
import net.momirealms.customfishing.commands.AbstractSubCommand;

View File

@@ -1,3 +1,20 @@
/*
* 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.commands.subcmd;
import net.momirealms.customfishing.commands.AbstractSubCommand;

View File

@@ -1,3 +1,20 @@
/*
* 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.competition;
import net.momirealms.customfishing.CustomFishing;

View File

@@ -1,3 +1,20 @@
/*
* 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.competition;
import net.momirealms.customfishing.competition.bossbar.BossBarConfig;

View File

@@ -1,3 +1,20 @@
/*
* 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.competition;
public enum CompetitionGoal {

View File

@@ -1,3 +1,20 @@
/*
* 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.competition;
import org.jetbrains.annotations.NotNull;

View File

@@ -1,3 +1,20 @@
/*
* 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.competition;
import net.momirealms.customfishing.CustomFishing;

View File

@@ -1,3 +1,20 @@
/*
* 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.competition.bossbar;
import net.momirealms.customfishing.CustomFishing;

View File

@@ -1,3 +1,20 @@
/*
* 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.competition.ranking;
import net.momirealms.customfishing.competition.CompetitionPlayer;

View File

@@ -1,3 +1,20 @@
/*
* 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.competition.ranking;
import net.momirealms.customfishing.competition.CompetitionPlayer;

View File

@@ -1,3 +1,20 @@
/*
* 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.competition.ranking;
import net.momirealms.customfishing.competition.CompetitionPlayer;

View File

@@ -1,3 +1,20 @@
/*
* 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;

View File

@@ -1,3 +1,20 @@
/*
* 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.storage;
import net.momirealms.customfishing.data.PlayerBagData;
@@ -6,8 +23,8 @@ import org.bukkit.inventory.Inventory;
public interface DataStorageInterface {
Inventory load(OfflinePlayer player);
void save(PlayerBagData playerBagData);
void initialize();
void disable();
Inventory loadBagData(OfflinePlayer player);
void saveBagData(PlayerBagData playerBagData);
}

View File

@@ -1,3 +1,20 @@
/*
* 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.storage;
import net.momirealms.customfishing.CustomFishing;
@@ -16,18 +33,28 @@ import java.io.IOException;
public class FileStorageImpl implements DataStorageInterface {
@Override
public Inventory load(OfflinePlayer player) {
public void initialize() {
}
@Override
public void disable() {
}
@Override
public Inventory loadBagData(OfflinePlayer player) {
YamlConfiguration config = ConfigUtil.readData(new File(CustomFishing.plugin.getDataFolder(), "fishingbag_data" + File.separator + player.getUniqueId() + ".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() + "}");
inventory.setContents(itemStacks);
if (itemStacks != null) inventory.setContents(itemStacks);
return inventory;
}
@Override
public void save(PlayerBagData playerBagData) {
public void saveBagData(PlayerBagData playerBagData) {
YamlConfiguration data = new YamlConfiguration();
Inventory inventory = playerBagData.getInventory();
String contents = InventoryUtil.toBase64(inventory.getContents());

View File

@@ -1,18 +1,134 @@
/*
* 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.storage;
import net.momirealms.customfishing.data.PlayerBagData;
import net.momirealms.customfishing.util.AdventureUtil;
import net.momirealms.customfishing.util.InventoryUtil;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.UUID;
public class MySQLStorageImpl implements DataStorageInterface {
public static SqlConnection sqlConnection = new SqlConnection();
@Override
public Inventory load(OfflinePlayer player) {
return null;
public void initialize() {
sqlConnection.createNewHikariConfiguration();
createTableIfNotExist(sqlConnection.getTablePrefix() + "_fishingbag");
}
@Override
public void save(PlayerBagData playerBagData) {
public void disable() {
sqlConnection.close();
}
@Override
public Inventory loadBagData(OfflinePlayer player) {
Inventory inventory = null;
try {
Connection connection = sqlConnection.getConnectionAndCheck();
String sql = String.format(SqlConstants.SQL_SELECT_BAG_BY_UUID, sqlConnection.getTablePrefix() + "_fishingbag");;
PreparedStatement statement = connection.prepareStatement(sql);
statement.setString(1, player.getUniqueId().toString());
ResultSet rs = statement.executeQuery();
if (rs.next()) {
int size = rs.getInt(2);
String contents = rs.getString(3);
ItemStack[] itemStacks = InventoryUtil.getInventoryItems(contents);
inventory = Bukkit.createInventory(null, size, "{CustomFishing_Bag_" + player.getName() + "}");
if (itemStacks != null) inventory.setContents(itemStacks);
}
else {
inventory = Bukkit.createInventory(null, 9, "{CustomFishing_Bag_" + player.getName() + "}");
}
} catch (SQLException e) {
e.printStackTrace();
}
return inventory;
}
@Override
public void saveBagData(PlayerBagData playerBagData) {
UUID uuid = playerBagData.getPlayer().getUniqueId();
Inventory inventory = playerBagData.getInventory();
String contents = InventoryUtil.toBase64(inventory.getContents());
if (contents == null) contents = "";
if (exists(uuid)) {
updateBagData(uuid, inventory.getSize(), contents);
}
else {
insertBagData(uuid, inventory.getSize(), contents);
}
}
private void createTableIfNotExist(String table) {
String sql = String.format(SqlConstants.SQL_CREATE_BAG_TABLE, table);
try (Connection connection = sqlConnection.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) {
statement.executeUpdate();
} catch (SQLException ex) {
AdventureUtil.consoleMessage("[CustomFishing] Failed to create table");
}
}
private void insertBagData(UUID uuid, int size, String contents) {
String sql = String.format(SqlConstants.SQL_INSERT_BAG, sqlConnection.getTablePrefix() + "_fishingbag");
try (Connection connection = sqlConnection.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) {
statement.setString(1, uuid.toString());
statement.setInt(2, size);
statement.setString(3, contents);
statement.executeUpdate();
} catch (SQLException ex) {
AdventureUtil.consoleMessage("[CustomFishing] Failed to insert data for " + uuid);
}
}
private void updateBagData(UUID uuid, int size, String contents) {
String sql = String.format(SqlConstants.SQL_UPDATE_BAG_BY_UUID, sqlConnection.getTablePrefix() + "_fishingbag");
try (Connection connection = sqlConnection.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) {
statement.setInt(1, size);
statement.setString(2, contents);
statement.setString(3, uuid.toString());
statement.executeUpdate();
} catch (SQLException ex) {
AdventureUtil.consoleMessage("[CustomFishing] Failed to update data for " + uuid);
}
}
public boolean exists(UUID uuid) {
String sql = String.format(SqlConstants.SQL_SELECT_BAG_BY_UUID, sqlConnection.getTablePrefix() + "_fishingbag");
boolean exist;
try (Connection connection = sqlConnection.getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) {
statement.setString(1, uuid.toString());
ResultSet rs = statement.executeQuery();
exist = rs.next();
} catch (SQLException ex) {
AdventureUtil.consoleMessage("[CustomFishing] Failed to select data for " + uuid);
return false;
}
return exist;
}
}

View File

@@ -0,0 +1,138 @@
/*
* 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.storage;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import com.zaxxer.hikari.pool.HikariPool;
import net.momirealms.customfishing.util.AdventureUtil;
import net.momirealms.customfishing.util.ConfigUtil;
import org.bukkit.configuration.file.YamlConfiguration;
import java.sql.Connection;
import java.sql.SQLException;
public class SqlConnection {
private boolean secondTry = false;
private boolean firstTry = false;
private boolean isFirstTry = true;
public int waitTimeOut = 10;
private HikariDataSource hikariDataSource;
private String tablePrefix;
public void createNewHikariConfiguration() {
YamlConfiguration config = ConfigUtil.getConfig("database.yml");
String storageMode = config.getString("data-storage-method", "MySQL");
HikariConfig hikariConfig = new HikariConfig();
String sql = "mysql";
if (storageMode.equalsIgnoreCase("MariaDB")) {
hikariConfig.setDriverClassName("org.mariadb.jdbc.Driver");
sql = "mariadb";
}
tablePrefix = config.getString("MySQL.table-prefix");
hikariConfig.setPoolName("[CustomFishing]");
hikariConfig.setJdbcUrl(String.format("jdbc:%s://%s/%s", sql, config.getString("MySQL.host") + ":" + config.getString("MySQL.port"), config.getString("MySQL.database")));
hikariConfig.setUsername(config.getString(storageMode + ".user"));
hikariConfig.setPassword(config.getString(storageMode + ".password"));
hikariConfig.setMaximumPoolSize(config.getInt(storageMode + ".Pool-Settings.maximum-pool-size"));
hikariConfig.setMinimumIdle(config.getInt(storageMode + ".Pool-Settings.minimum-idle"));
hikariConfig.setMaxLifetime(config.getInt(storageMode + ".Pool-Settings.maximum-lifetime"));
for (String property : config.getConfigurationSection(storageMode + ".properties").getKeys(false)) {
hikariConfig.addDataSourceProperty(property, config.getString(storageMode + ".properties." + property));
}
if (hikariConfig.getMinimumIdle() < hikariConfig.getMaximumPoolSize()) {
hikariConfig.setIdleTimeout(config.getInt(storageMode + ".Pool-Settings.idle-timeout"));
} else {
hikariConfig.setIdleTimeout(0);
}
try {
hikariDataSource = new HikariDataSource(hikariConfig);
} catch (HikariPool.PoolInitializationException e) {
AdventureUtil.consoleMessage("[CustomFishing] Failed to create sql connection");
}
}
public boolean setGlobalConnection() {
try {
createNewHikariConfiguration();
Connection connection = getConnection();
connection.close();
if (secondTry) {
AdventureUtil.consoleMessage("[CustomFishing] Successfully reconnect to SQL!");
} else {
secondTry = true;
}
return true;
} catch (SQLException e) {
AdventureUtil.consoleMessage("<red>[CustomFishing] Error! Failed to connect to SQL!</red>");
e.printStackTrace();
close();
return false;
}
}
public Connection getConnection() throws SQLException {
return hikariDataSource.getConnection();
}
public boolean canConnect() {
if (hikariDataSource == null) {
return setGlobalConnection();
}
if (hikariDataSource.isClosed()) {
return setGlobalConnection();
}
return true;
}
public void close() {
if (hikariDataSource != null && hikariDataSource.isRunning()) {
hikariDataSource.close();
}
}
public String getTablePrefix() {
return tablePrefix;
}
public Connection getConnectionAndCheck() {
if (!canConnect()) {
return null;
}
try {
return getConnection();
} catch (SQLException e) {
if (firstTry) {
firstTry = false;
close();
return getConnectionAndCheck();
} else {
firstTry = true;
AdventureUtil.consoleMessage("<red>[CustomNameplates] Error! Failed to connect to SQL!</red>");
close();
e.printStackTrace();
return null;
}
}
}
}

View File

@@ -0,0 +1,9 @@
package net.momirealms.customfishing.data.storage;
public class SqlConstants {
public static final String SQL_CREATE_BAG_TABLE = "CREATE TABLE IF NOT EXISTS `%s` ( `uuid` VARCHAR(36) NOT NULL , `size` INT(8) NOT NULL , `contents` LONGTEXT NOT NULL , PRIMARY KEY (`uuid`) )";
public static final String SQL_INSERT_BAG = "INSERT INTO `%s`(`uuid`, `size`, `contents`) VALUES (?, ?, ?)";
public static final String SQL_UPDATE_BAG_BY_UUID = "UPDATE `%s` SET `size` = ?, `contents` = ? WHERE `uuid` = ?";
public static final String SQL_SELECT_BAG_BY_UUID = "SELECT * FROM `%s` WHERE `uuid` = ?";
}

View File

@@ -1,3 +1,20 @@
/*
* 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.integration;
import org.bukkit.Location;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration;
import org.bukkit.inventory.ItemStack;
@@ -7,5 +24,4 @@ public interface ItemInterface {
@Nullable
ItemStack build(String id);
}

View File

@@ -1,3 +1,20 @@
/*
* 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.integration;
import net.momirealms.customfishing.object.loot.Mob;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration;
import org.bukkit.World;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration;
import org.bukkit.entity.Player;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration;
import net.milkbowl.vault.economy.Economy;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.block;
import dev.lone.itemsadder.api.CustomBlock;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.block;
import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanic;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.block;
import net.momirealms.customfishing.integration.BlockInterface;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.item;
import net.momirealms.customfishing.integration.ItemInterface;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.item;
import com.willfp.eco.core.items.CustomItem;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.item;
import dev.lone.itemsadder.api.CustomStack;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.item;
import net.Indyuce.mmoitems.MMOItems;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.item;
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.item;
import io.lumine.mythic.bukkit.MythicBukkit;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.item;
import io.th0rgal.oraxen.items.ItemBuilder;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.mob;
import io.lumine.mythic.api.adapters.AbstractLocation;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.papi;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
@@ -30,11 +47,14 @@ public class CompetitionPapi extends PlaceholderExpansion {
@Override
public @Nullable String onPlaceholderRequest(Player player, @NotNull String params) {
if (Competition.currentCompetition == null) return "null";
if (Competition.currentCompetition == null) return "";
switch (params) {
case "rank" -> {
return Competition.currentCompetition.getPlayerRank(player);
}
case "score" -> {
return String.format("%.1f", Competition.currentCompetition.getScore(player));
}
case "time" -> {
return String.valueOf(Competition.currentCompetition.getRemainingTime());
}

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.papi;
import me.clip.placeholderapi.PlaceholderAPI;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.season;
import net.momirealms.customcrops.api.utils.SeasonUtils;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.season;
import me.casperge.realisticseasons.api.SeasonsAPI;

View File

@@ -1,3 +1,20 @@
/*
* 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.listener;
import net.momirealms.customfishing.object.Function;

View File

@@ -1,3 +1,20 @@
/*
* 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.listener;
import net.momirealms.customfishing.object.Function;

View File

@@ -1,3 +1,20 @@
/*
* 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.listener;
import com.gamingmesh.jobs.Jobs;

View File

@@ -1,3 +1,20 @@
/*
* 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.listener;
import net.momirealms.customfishing.manager.FishingManager;

View File

@@ -1,3 +1,20 @@
/*
* 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.listener;
import de.tr7zw.changeme.nbtapi.NBTItem;

View File

@@ -1,3 +1,20 @@
/*
* 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.listener;
import net.momirealms.customfishing.manager.ConfigManager;

View File

@@ -1,3 +1,20 @@
/*
* 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.listener;
import net.momirealms.customfishing.object.Function;

View File

@@ -1,3 +1,20 @@
/*
* 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.listener;
import com.comphenix.protocol.PacketType;

View File

@@ -1,3 +1,20 @@
/*
* 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.manager;
import com.comphenix.protocol.events.PacketContainer;
@@ -10,41 +27,57 @@ import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.data.PlayerBagData;
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.listener.InventoryListener;
import net.momirealms.customfishing.listener.SimpleListener;
import net.momirealms.customfishing.listener.WindowPacketListener;
import net.momirealms.customfishing.object.Function;
import net.momirealms.customfishing.util.AdventureUtil;
import net.momirealms.customfishing.util.ConfigUtil;
import net.momirealms.customfishing.util.ItemStackUtil;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
public class BagDataManager extends Function {
public static HashMap<UUID, PlayerBagData> dataCache;
public static ConcurrentHashMap<UUID, PlayerBagData> dataCache;
public static HashSet<PlayerBagData> tempCache;
private final DataStorageInterface dataStorageInterface;
private final InventoryListener inventoryListener;
private final WindowPacketListener windowPacketListener;
private final SimpleListener simpleListener;
private final BukkitTask timerSave;
public BagDataManager() {
dataCache = new HashMap<>();
dataCache = new ConcurrentHashMap<>();
tempCache = new HashSet<>();
this.dataStorageInterface = new FileStorageImpl();
YamlConfiguration config = ConfigUtil.getConfig("database.yml");
if (config.getString("data-storage-method","YAML").equalsIgnoreCase("YAML")) {
this.dataStorageInterface = new FileStorageImpl();
} else this.dataStorageInterface = new MySQLStorageImpl();
this.dataStorageInterface.initialize();
this.inventoryListener = new InventoryListener(this);
this.windowPacketListener = new WindowPacketListener(this);
this.simpleListener = new SimpleListener(this);
this.timerSave = Bukkit.getScheduler().runTaskTimerAsynchronously(CustomFishing.plugin, () -> {
for (PlayerBagData playerBagData : dataCache.values()) {
dataStorageInterface.saveBagData(playerBagData);
}
AdventureUtil.consoleMessage("[CustomFishing] Fishing bag data saving for " + dataCache.size() + " online players...");
}, 6000, 6000);
}
@Override
@@ -61,14 +94,21 @@ public class BagDataManager extends Function {
HandlerList.unregisterAll(simpleListener);
CustomFishing.protocolManager.removePacketListener(windowPacketListener);
for (PlayerBagData playerBagData : dataCache.values()) {
dataStorageInterface.save(playerBagData);
dataStorageInterface.saveBagData(playerBagData);
}
}
public void disable() {
this.dataStorageInterface.disable();
dataCache.clear();
tempCache.clear();
timerSave.cancel();
}
public void openFishingBag(Player viewer, OfflinePlayer ownerOffline) {
Player owner = ownerOffline.getPlayer();
if (owner == null) {
Inventory inventory = dataStorageInterface.load(ownerOffline);
Inventory inventory = dataStorageInterface.loadBagData(ownerOffline);
PlayerBagData playerBagData = new PlayerBagData(ownerOffline, inventory);
tempCache.add(playerBagData);
viewer.openInventory(inventory);
@@ -89,17 +129,21 @@ public class BagDataManager extends Function {
public void onQuit(Player player) {
PlayerBagData playerBagData = dataCache.remove(player.getUniqueId());
if (playerBagData != null) {
dataStorageInterface.save(playerBagData);
Bukkit.getScheduler().runTaskAsynchronously(CustomFishing.plugin, () -> {
dataStorageInterface.saveBagData(playerBagData);
});
}
}
@Override
public void onJoin(Player player) {
readData(player);
Bukkit.getScheduler().runTaskAsynchronously(CustomFishing.plugin, () -> {
readData(player);
});
}
public PlayerBagData readData(Player player) {
Inventory inventory = dataStorageInterface.load(player);
Inventory inventory = dataStorageInterface.loadBagData(player);
PlayerBagData playerBagData = new PlayerBagData(player, inventory);
dataCache.put(player.getUniqueId(), playerBagData);
return playerBagData;
@@ -159,7 +203,9 @@ public class BagDataManager extends Function {
for (PlayerBagData temp : tempCache) {
if (temp.getInventory() == inventory) {
tempCache.remove(temp);
dataStorageInterface.save(temp);
Bukkit.getScheduler().runTaskAsynchronously(CustomFishing.plugin, () -> {
dataStorageInterface.saveBagData(temp);
});
}
}
}

View File

@@ -1,3 +1,20 @@
/*
* 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.manager;
import net.momirealms.customfishing.CustomFishing;
@@ -25,7 +42,6 @@ public class BonusManager extends Function {
public static HashMap<String, ItemStack> RODITEMS;
public static HashMap<String, Bonus> ROD;
public static HashMap<String, Bonus> ENCHANTS = new HashMap<>();
public static HashMap<String, ItemStack> UTILITEMS;
@Override

View File

@@ -1,3 +1,20 @@
/*
* 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.manager;
import net.momirealms.customfishing.competition.CompetitionConfig;

View File

@@ -1,3 +1,20 @@
/*
* 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.manager;
import net.momirealms.customfishing.integration.VaultHook;
@@ -25,8 +42,6 @@ public class ConfigManager {
public static boolean enableMcMMOLoot;
public static double vanillaLootRatio;
public static double mcMMOLootChance;
public static boolean needOpenWater;
public static boolean needRodForLoots;
public static boolean needRodToFish;
public static boolean rodLoseDurability;
public static boolean enableCompetition;
@@ -35,13 +50,11 @@ public class ConfigManager {
public static boolean preventPickUp;
public static boolean enableFishingBag;
public static boolean alwaysFishingBar;
public static String[] successTitle;
public static String[] successSubTitle;
public static int successFadeIn;
public static int successFadeStay;
public static int successFadeOut;
public static String[] failureTitle;
public static String[] failureSubTitle;
public static int failureFadeIn;
@@ -83,9 +96,7 @@ public class ConfigManager {
vanillaLootRatio = config.getDouble("mechanics.other-loots.vanilla.ratio", 0.4);
enableMcMMOLoot = config.getBoolean("mechanics.other-loots.mcMMO.enable", false);
mcMMOLootChance = config.getDouble("mechanics.other-loots.mcMMO.chance", 0.5);
needOpenWater = config.getBoolean("mechanics.need-open-water", true);
needRodForLoots = config.getBoolean("mechanics.need-special-rod.for-loots", false);
needRodToFish = config.getBoolean("mechanics.need-special-rod.to-fish", false);
needRodToFish = config.getBoolean("mechanics.need-special-rod-to-fish", false);
rodLoseDurability = config.getBoolean("mechanics.rod-lose-durability", true);
enableCompetition = config.getBoolean("mechanics.fishing-competition.enable", true);
@@ -125,13 +136,6 @@ public class ConfigManager {
JedisUtil.initializeRedis(configuration);
useRedis = true;
}
if (vaultHook) {
if (!VaultHook.initialize()) {
vaultHook = false;
AdventureUtil.consoleMessage("<red>[CustomFishing] Failed to hook into Vault!");
}
}
}
public static List<World> getWorldsList() {
if (whiteOrBlack) {

View File

@@ -1,3 +1,20 @@
/*
* 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.manager;
import de.tr7zw.changeme.nbtapi.NBTCompound;
@@ -67,7 +84,7 @@ public class FishingManager extends Function {
private final HashMap<Player, VanillaLoot> vanillaLoot;
private final ConcurrentHashMap<Player, FishingPlayer> fishingPlayerCache;
private final ConcurrentHashMap<Location, ActivatedTotem> totemCache;
private final ConcurrentHashMap<Player, BobberCheckTask> lavaFishing;
private final ConcurrentHashMap<Player, BobberCheckTask> bobberTaskCache;
public FishingManager() {
this.playerFishListener = new PlayerFishListener(this);
@@ -79,7 +96,7 @@ public class FishingManager extends Function {
this.vanillaLoot = new HashMap<>();
this.fishingPlayerCache = new ConcurrentHashMap<>();
this.totemCache = new ConcurrentHashMap<>();
this.lavaFishing = new ConcurrentHashMap<>();
this.bobberTaskCache = new ConcurrentHashMap<>();
load();
}
@@ -108,6 +125,9 @@ public class FishingManager extends Function {
if (this.pickUpListener != null) HandlerList.unregisterAll(this.pickUpListener);
if (this.mmoItemsListener != null) HandlerList.unregisterAll(this.mmoItemsListener);
if (this.jobsRebornXPListener != null) HandlerList.unregisterAll(this.jobsRebornXPListener);
for (BobberCheckTask bobberCheckTask : bobberTaskCache.values()) {
bobberCheckTask.stop();
}
}
public void onFishing(PlayerFishEvent event) {
@@ -214,6 +234,7 @@ public class FishingManager extends Function {
if (baitBonus != null) {
initialBonus.addBonus(baitBonus);
itemStack.setAmount(itemStack.getAmount() - 1);
break;
}
}
}
@@ -230,17 +251,14 @@ public class FishingManager extends Function {
nextBonus.put(player, initialBonus);
if (ConfigManager.needRodForLoots && noSpecialRod){
if (!ConfigManager.enableVanillaLoot) AdventureUtil.playerMessage(player, MessageManager.prefix + MessageManager.noRod);
nextLoot.put(player, null);
}
if (ConfigManager.needRodToFish && noSpecialRod){
nextLoot.put(player, Loot.EMPTY);
return;
}
if ((ConfigManager.needRodForLoots || ConfigManager.needRodToFish) && noSpecialRod) return;
BobberCheckTask bobberCheckTask = new BobberCheckTask(player, initialBonus, fishHook, this, lureLevel);
bobberCheckTask.runTaskTimer(CustomFishing.plugin, 1, 1);
bobberTaskCache.put(player, bobberCheckTask);
});
}
@@ -304,11 +322,14 @@ public class FishingManager extends Function {
FishingPlayer fishingPlayer = fishingPlayerCache.remove(player);
if (fishingPlayer == null) {
Loot loot = nextLoot.get(player);
if (loot == Loot.EMPTY) return;
if (ConfigManager.enableVanillaLoot) {
// Not a vanilla loot
if (ConfigManager.vanillaLootRatio < Math.random()) {
event.setCancelled(true);
Loot loot = nextLoot.get(player);
if (loot != null) {
vanillaLoot.remove(player);
}
@@ -329,7 +350,6 @@ public class FishingManager extends Function {
}
else {
// No custom loot
Loot loot = nextLoot.get(player);
if (loot == null) {
item.remove();
event.setExpToDrop(0);
@@ -354,14 +374,12 @@ public class FishingManager extends Function {
VanillaLoot vanilla = vanillaLoot.remove(player);
player.removePotionEffect(PotionEffectType.SLOW);
if (ConfigManager.needOpenWater && !event.getHook().isInOpenWater()){
AdventureUtil.playerMessage(player, MessageManager.prefix + MessageManager.notOpenWater);
return;
}
if (fishingPlayer.isSuccess()) {
if (ConfigManager.rodLoseDurability) loseDurability(player);
Location location = event.getHook().getLocation();
if (location.getBlock().getType() == Material.LAVA) {
location.add(0,0.3,0);
}
if (vanilla != null) {
dropVanillaLoot(player, vanilla, location, fishingPlayer.isDouble());
return;
@@ -389,10 +407,11 @@ public class FishingManager extends Function {
FishingPlayer fishingPlayer = fishingPlayerCache.remove(player);
if (fishingPlayer != null) {
proceedReelIn(event, player, fishingPlayer);
lavaFishing.remove(player);
bobberTaskCache.remove(player);
return;
}
if (lavaFishing.containsKey(player)) {
BobberCheckTask bobberCheckTask = bobberTaskCache.get(player);
if (bobberCheckTask != null && bobberCheckTask.isHooked()) {
showPlayerBar(player, nextLoot.get(player));
event.setCancelled(true);
}
@@ -465,9 +484,9 @@ public class FishingManager extends Function {
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.2);
vector = vector.setY((vector.getY()+0.25) * 1.2);
item.setVelocity(vector);
if (isDouble){
if (isDouble) {
Entity item2 = location.getWorld().dropItem(location, itemStack);
item2.setVelocity(vector);
}
@@ -852,7 +871,7 @@ public class FishingManager extends Function {
nextLoot.remove(player);
nextBonus.remove(player);
vanillaLoot.remove(player);
BobberCheckTask task = lavaFishing.remove(player);
BobberCheckTask task = bobberTaskCache.remove(player);
if (task != null) task.stop();
// prevent bar duplication
FishHook fishHook = hooksCache.remove(player);
@@ -887,10 +906,10 @@ public class FishingManager extends Function {
}
public void addPlayerToLavaFishing(Player player, BobberCheckTask task) {
this.lavaFishing.put(player, task);
this.bobberTaskCache.put(player, task);
}
public void removePlayerFromLavaFishing(Player player) {
this.lavaFishing.remove(player);
this.bobberTaskCache.remove(player);
}
}

View File

@@ -1,3 +1,20 @@
/*
* 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.manager;
import net.momirealms.customfishing.helper.Log;
@@ -50,6 +67,14 @@ public class IntegrationManager extends Function {
YamlConfiguration config = ConfigUtil.getConfig("config.yml");
if (ConfigManager.vaultHook) {
if (!VaultHook.initialize()) {
ConfigManager.vaultHook = false;
Log.warn("Failed to initialize Vault!");
}
else hookMessage("Vault");
}
this.blockInterface = new VanillaBlockImpl();
List<ItemInterface> itemInterfaceList = new ArrayList<>();

View File

@@ -1,3 +1,20 @@
/*
* 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.manager;
import net.momirealms.customfishing.object.Function;

View File

@@ -1,3 +1,20 @@
/*
* 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.manager;
import net.momirealms.customfishing.CustomFishing;
@@ -78,7 +95,7 @@ public class LootManager extends Function {
difficulty,
time,
weight,
config.getString(key + ".mythicmobsID", key),
config.getString(key + ".mobID", key),
config.getInt(key + ".level", 0),
new MobVector(
config.getDouble(key + ".vector.horizontal",1.1),

View File

@@ -1,3 +1,20 @@
/*
* 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.manager;
import net.momirealms.customfishing.util.ConfigUtil;

View File

@@ -1,3 +1,20 @@
/*
* 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.manager;
import com.comphenix.protocol.events.PacketContainer;
@@ -207,13 +224,13 @@ public class SellManager extends Function {
}
}
}
if (update && !isCoolDown(player, 1000)) {
Bukkit.getScheduler().runTaskLater(CustomFishing.plugin, () -> {
if (update) {
Bukkit.getScheduler().runTaskAsynchronously(CustomFishing.plugin, () -> {
ItemStack icon = ItemStackUtil.getFromItem(sellIcon.cloneWithPrice(getTotalPrice(getPlayerItems(inventory))));
for (int slot : functionIconSlots) {
inventory.setItem(slot, icon);
}
}, 1);
});
}
}

View File

@@ -1,3 +1,20 @@
/*
* 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.manager;
import net.momirealms.customfishing.CustomFishing;

View File

@@ -1,3 +1,20 @@
/*
* 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.object;
import com.comphenix.protocol.events.PacketContainer;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.action;
import org.bukkit.entity.Player;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.action;
import net.momirealms.customfishing.CustomFishing;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.action;
import net.momirealms.customfishing.util.AdventureUtil;

View File

@@ -1,12 +1,32 @@
/*
* 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.object.action;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.integration.SkillInterface;
import org.bukkit.entity.Player;
public record SkillXPImpl(double amount) implements ActionInterface {
@Override
public void doOn(Player player, Player another) {
CustomFishing.plugin.getIntegrationManager().getSkillInterface().addXp(player, amount);
SkillInterface skillInterface = CustomFishing.plugin.getIntegrationManager().getSkillInterface();
if (skillInterface == null) return;
skillInterface.addXp(player, amount);
}
}

View File

@@ -1,3 +1,20 @@
/*
* 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.object.action;
import net.kyori.adventure.key.Key;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.action;
import net.kyori.adventure.key.Key;

View File

@@ -1,12 +1,36 @@
/*
* 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.object.fishing;
import com.plotsquared.core.plot.PlotId;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.manager.ConfigManager;
import net.momirealms.customfishing.manager.FishingManager;
import net.momirealms.customfishing.manager.LootManager;
import net.momirealms.customfishing.manager.MessageManager;
import net.momirealms.customfishing.object.loot.Loot;
import net.momirealms.customfishing.util.AdventureUtil;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@@ -30,6 +54,7 @@ public class BobberCheckTask extends BukkitRunnable {
private BukkitTask cache_1;
private BukkitTask cache_2;
private BukkitTask cache_3;
private ArmorStand entityCache;
public BobberCheckTask(Player player, Bonus bonus, FishHook fishHook, FishingManager fishingManager, int lureLevel) {
this.fishHook = fishHook;
@@ -45,6 +70,9 @@ public class BobberCheckTask extends BukkitRunnable {
@Override
public void run() {
timer ++;
if (timer > 3600) {
stop();
}
if (!fishHook.isValid()) {
stop();
return;
@@ -56,7 +84,7 @@ public class BobberCheckTask extends BukkitRunnable {
}
if (hooked) {
jump_timer++;
if (jump_timer < 5) {
if (jump_timer < 4) {
return;
}
jump_timer = 0;
@@ -64,32 +92,38 @@ public class BobberCheckTask extends BukkitRunnable {
return;
}
if (first_time) {
if (jump_timer < 8) {
jump_timer++;
fishHook.setVelocity(new Vector(0,0.18 - jump_timer * 0.01,0));
return;
}
first_time = false;
randomTime();
spawnArmorStand(fishHook.getLocation());
}
fishHook.setVelocity(new Vector(0, 0.12,0));
return;
}
if (fishHook.isInWater()) {
stop();
Bukkit.getScheduler().runTaskAsynchronously(CustomFishing.plugin, () -> {
List<Loot> possibleLoots = fishingManager.getPossibleLootList(new FishingCondition(fishHook.getLocation(), player), false, LootManager.WATERLOOTS.values());
fishingManager.getNextLoot(player, bonus, possibleLoots);
});
stop();
return;
}
if (fishHook.isOnGround()) {
stop();
return;
}
if (timer > 2400) {
stop();
}
}
public void stop() {
cancel();
cancelTask();
fishingManager.removePlayerFromLavaFishing(player);
if (entityCache != null && !entityCache.isDead()) {
entityCache.remove();
entityCache = null;
}
}
public void cancelTask() {
@@ -119,13 +153,32 @@ public class BobberCheckTask extends BukkitRunnable {
if (random < ConfigManager.lavaMinTime) random = ConfigManager.lavaMinTime;
cache_1 = Bukkit.getScheduler().runTaskLater(CustomFishing.plugin, () -> {
hooked = true;
fishingManager.addPlayerToLavaFishing(player, this);
if (entityCache != null && !entityCache.isDead()) entityCache.remove();
AdventureUtil.playerSound(player, Sound.Source.NEUTRAL, Key.key("minecraft:block.pointed_dripstone.drip_lava_into_cauldron"), 1, 1);
}, random);
cache_2 = Bukkit.getScheduler().runTaskLater(CustomFishing.plugin, () -> {
hooked = false;
first_time = true;
fishingManager.removePlayerFromLavaFishing(player);
}, random + 40);
cache_3 = new LavaEffect(fishHook.getLocation()).runTaskTimerAsynchronously(CustomFishing.plugin,random - 60,1);
}
private void spawnArmorStand(Location armorLoc) {
armorLoc.setY(armorLoc.getBlockY() + 0.2);
if (entityCache != null && !entityCache.isDead()) entityCache.remove();
entityCache = armorLoc.getWorld().spawn(armorLoc, ArmorStand.class, a -> {
a.setInvisible(true);
a.setCollidable(false);
a.setInvulnerable(true);
a.setVisible(false);
a.setCustomNameVisible(false);
a.setSmall(true);
a.setGravity(false);
});
fishHook.setHookedEntity(entityCache);
}
public boolean isHooked() {
return hooked;
}
}

View File

@@ -1,3 +1,20 @@
/*
* 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.object.fishing;
import java.util.HashMap;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.fishing;
public enum FishResult {

View File

@@ -1,3 +1,20 @@
/*
* 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.object.fishing;
import net.momirealms.customfishing.CustomFishing;

View File

@@ -1,10 +1,26 @@
/*
* 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.object.fishing;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.scheduler.BukkitRunnable;
public class LavaEffect extends BukkitRunnable {
private final Location startLoc;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.fishing;
import org.bukkit.inventory.ItemStack;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.loot;
import net.momirealms.customfishing.object.fishing.Difficulty;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.loot;
import org.bukkit.Material;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.loot;
import net.momirealms.customfishing.object.action.ActionInterface;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.loot;
import net.momirealms.customfishing.object.fishing.Difficulty;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.totem;
import net.momirealms.customfishing.CustomFishing;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.totem;
import org.bukkit.Location;

View File

@@ -1,3 +1,20 @@
/*
* 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.util;
import com.comphenix.protocol.PacketType;

View File

@@ -0,0 +1,13 @@
package net.momirealms.customfishing.util;
import org.bukkit.Location;
public class BlockUtil {
public static void isInOpenLava(Location location) {
}
}

View File

@@ -1,3 +1,20 @@
/*
* 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.util;
import dev.dejvokep.boostedyaml.YamlDocument;

View File

@@ -1,8 +1,26 @@
/*
* 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.util;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.io.BukkitObjectInputStream;
import org.bukkit.util.io.BukkitObjectOutputStream;
import org.jetbrains.annotations.Nullable;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import java.io.ByteArrayInputStream;
@@ -11,15 +29,17 @@ import java.io.IOException;
public class InventoryUtil {
@Nullable
public static String toBase64(ItemStack[] contents) {
boolean convert = false;
for (ItemStack item : contents) {
if (item != null) {
for (ItemStack content : contents) {
if (content != null) {
convert = true;
break;
}
}
if (convert) {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@@ -27,19 +47,20 @@ public class InventoryUtil {
dataOutput.writeInt(contents.length);
for (ItemStack stack : contents) {
dataOutput.writeObject(stack);
for (ItemStack itemStack : contents) {
dataOutput.writeObject(itemStack);
}
dataOutput.close();
byte[] byteArr = outputStream.toByteArray();
return Base64Coder.encodeLines(byteArr);
} catch (Exception e) {
throw new IllegalStateException("Unable to save item stacks.", e);
} catch (IOException e) {
throw new RuntimeException("[CustomFishing] Data save error", e);
}
}
return null;
}
@Nullable
public static ItemStack[] getInventoryItems(String base64) {
ItemStack[] itemStacks = null;
try {
@@ -51,7 +72,7 @@ public class InventoryUtil {
}
private static ItemStack[] stacksFromBase64(String data) {
if (data == null) return new ItemStack[]{};
if (data == null || data.equals("")) return new ItemStack[]{};
ByteArrayInputStream inputStream;
try {

View File

@@ -1,3 +1,20 @@
/*
* 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.util;
import de.tr7zw.changeme.nbtapi.NBTCompound;

View File

@@ -1,3 +1,20 @@
/*
* 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.util;
import net.momirealms.customfishing.helper.Log;

View File

@@ -1,3 +1,20 @@
/*
* 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.util;
import de.tr7zw.changeme.nbtapi.NBTCompound;