9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-25 01:49:28 +00:00
This commit is contained in:
Xiao-MoMi
2023-02-08 21:47:29 +08:00
parent c573213c0d
commit 7db78b437a
12 changed files with 53 additions and 13 deletions

View File

@@ -4,7 +4,7 @@ plugins {
}
group = 'net.momirealms'
version = '1.2.21'
version = '1.2.23'
repositories {
mavenCentral()
@@ -48,8 +48,9 @@ repositories {
dependencies {
compileOnly fileTree(dir:'libs',includes:['*.jar'])
implementation fileTree(dir:'libs',includes:['BiomeAPI.jar'])
compileOnly('io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT')
compileOnly 'com.github.angeschossen:LandsAPI:6.26.18'
compileOnly('com.github.angeschossen:LandsAPI:6.26.18')
compileOnly('com.zaxxer:HikariCP:5.0.1')
compileOnly('com.github.Archy-X:AureliumSkills:Beta1.3.6')
compileOnly('com.github.TechFortress:GriefPrevention:16.18')
@@ -106,6 +107,7 @@ shadowJar {
relocate 'de.tr7zw', 'net.momirealms.customfishing.libs.de.tr7zw'
relocate 'net.kyori', 'net.momirealms.customfishing.libs.net.kyori'
relocate 'org.bstats', 'net.momirealms.customfishing.libs.org.bstats'
relocate 'net.momirealms.biomeapi', 'net.momirealms.customfishing.libs.net.momirealms.biomeapi'
}
tasks.register("delete", Delete).get().delete("build/libs/"+project.name+"-"+project.version+".jar")

BIN
libs/BiomeAPI.jar Normal file

Binary file not shown.

View File

@@ -20,10 +20,12 @@ package net.momirealms.customfishing;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.momirealms.biomeapi.BiomeAPI;
import net.momirealms.customfishing.commands.FishingBagCommand;
import net.momirealms.customfishing.commands.PluginCommand;
import net.momirealms.customfishing.commands.SellFishCommand;
import net.momirealms.customfishing.helper.LibraryLoader;
import net.momirealms.customfishing.helper.VersionHelper;
import net.momirealms.customfishing.manager.*;
import net.momirealms.customfishing.util.AdventureUtil;
import net.momirealms.customfishing.util.ConfigUtil;
@@ -35,7 +37,6 @@ public final class CustomFishing extends JavaPlugin {
public static CustomFishing plugin;
public static BukkitAudiences adventure;
public static String version;
public static ProtocolManager protocolManager;
private IntegrationManager integrationManager;
private FishingManager fishingManager;
@@ -47,6 +48,7 @@ public final class CustomFishing extends JavaPlugin {
private TotemManager totemManager;
private DataManager dataManager;
private SellManager sellManager;
private VersionHelper versionHelper;
// _ooOoo_
// o8888888o
@@ -83,7 +85,6 @@ public final class CustomFishing extends JavaPlugin {
public void onEnable() {
adventure = BukkitAudiences.create(this);
protocolManager = ProtocolLibrary.getProtocolManager();
version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
this.fishingManager = new FishingManager();
this.dataManager = new DataManager();
@@ -95,6 +96,7 @@ public final class CustomFishing extends JavaPlugin {
this.totemManager = new TotemManager(this);
this.sellManager = new SellManager();
this.bagDataManager = new BagDataManager();
this.versionHelper = new VersionHelper();
reloadConfig();
registerCommands();
@@ -188,4 +190,8 @@ public final class CustomFishing extends JavaPlugin {
public DataManager getDataManager() {
return dataManager;
}
public VersionHelper getVersionHelper() {
return versionHelper;
}
}

View File

@@ -18,7 +18,6 @@
package net.momirealms.customfishing.competition.ranking;
import net.momirealms.customfishing.competition.CompetitionPlayer;
import net.momirealms.customfishing.manager.MessageManager;
import java.util.*;

View File

@@ -18,7 +18,6 @@
package net.momirealms.customfishing.competition.ranking;
import net.momirealms.customfishing.competition.CompetitionPlayer;
import net.momirealms.customfishing.manager.MessageManager;
import net.momirealms.customfishing.util.JedisUtil;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.resps.Tuple;

View File

@@ -0,0 +1,21 @@
package net.momirealms.customfishing.helper;
import org.bukkit.Bukkit;
public class VersionHelper {
private boolean isNewerThan1_19_R2;
private String version;
public boolean isVersionNewerThan1_19_R2() {
if (version == null) {
version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
String[] split = version.split("_");
int main_ver = Integer.parseInt(split[1]);
if (main_ver >= 20) isNewerThan1_19_R2 = true;
else if (main_ver == 19) isNewerThan1_19_R2 = Integer.parseInt(split[2].substring(1)) >= 2;
else isNewerThan1_19_R2 = false;
}
return isNewerThan1_19_R2;
}
}

View File

@@ -134,6 +134,7 @@ public class BagDataManager extends Function {
}
public void readData(Player player) {
if (player == null || !player.isOnline()) return;
Inventory inventory = CustomFishing.plugin.getDataManager().getDataStorageInterface().loadBagData(player);
if (inventory != null) {
PlayerBagData playerBagData = new PlayerBagData(player, inventory);

View File

@@ -28,9 +28,9 @@ import net.momirealms.customfishing.integration.item.*;
import net.momirealms.customfishing.integration.mob.MythicMobsMobImpl;
import net.momirealms.customfishing.integration.papi.PlaceholderManager;
import net.momirealms.customfishing.integration.quest.BattlePassCFQuest;
import net.momirealms.customfishing.integration.quest.ClueScrollCFQuest;
import net.momirealms.customfishing.integration.quest.NewBetonQuestCFQuest;
import net.momirealms.customfishing.integration.quest.OldBetonQuestCFQuest;
import net.momirealms.customfishing.integration.quest.ClueScrollCFQuest;
import net.momirealms.customfishing.integration.season.CustomCropsSeasonImpl;
import net.momirealms.customfishing.integration.season.RealisticSeasonsImpl;
import net.momirealms.customfishing.integration.skill.*;

View File

@@ -51,6 +51,7 @@ 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.inventory.PlayerInventory;
import java.util.*;
@@ -142,6 +143,7 @@ public class SellManager extends Function {
@Override
public void onJoin(Player player) {
Bukkit.getScheduler().runTaskLaterAsynchronously(CustomFishing.plugin, () -> {
if (player == null || !player.isOnline()) return;
CustomFishing.plugin.getDataManager().getDataStorageInterface().loadSellCache(player);
}, 20);
}
@@ -344,13 +346,21 @@ public class SellManager extends Function {
}
private void returnItems(List<ItemStack> itemStacks, Player player){
Inventory inventory = player.getInventory();
PlayerInventory inventory = player.getInventory();
for (ItemStack stack : itemStacks) {
if (stack == null || stack.getType() == Material.AIR) continue;
inventory.addItem(stack);
if (hasEmptySlot(inventory)) inventory.addItem(stack);
else player.getLocation().getWorld().dropItemNaturally(player.getLocation(), stack);
}
}
private boolean hasEmptySlot(PlayerInventory inventory) {
for (ItemStack itemStack : inventory.getStorageContents()) {
if (itemStack == null || itemStack.getType() == Material.AIR) return true;
}
return false;
}
private float getTotalPrice(List<ItemStack> itemStacks){
float totalPrice = 0;
for (ItemStack stack : itemStacks) {

View File

@@ -17,6 +17,8 @@
package net.momirealms.customfishing.object.requirements;
import net.momirealms.biomeapi.BiomeAPI;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.object.fishing.FishingCondition;
import java.util.List;
@@ -25,7 +27,7 @@ public record BiomeImpl(List<String> biomes) implements RequirementInterface {
@Override
public boolean isConditionMet(FishingCondition fishingCondition) {
String currentBiome = fishingCondition.getLocation().getBlock().getBiome().getKey().toString();
String currentBiome = BiomeAPI.getBiome(fishingCondition.getLocation());
for (String biome : biomes) {
if (currentBiome.equalsIgnoreCase(biome)) {
return true;

View File

@@ -54,7 +54,7 @@ public class ArmorStandUtil {
public static PacketContainer getMetaPacket(int id) {
PacketContainer metaPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
metaPacket.getIntegers().write(0, id);
if (CustomFishing.version.equals("v1_19_R2")) {
if (CustomFishing.getInstance().getVersionHelper().isVersionNewerThan1_19_R2()) {
WrappedDataWatcher wrappedDataWatcher = createDataWatcher();
List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
wrappedDataWatcher.getWatchableObjects().stream().filter(Objects::nonNull).forEach(entry -> {
@@ -71,7 +71,7 @@ public class ArmorStandUtil {
public static PacketContainer getMetaPacket(int id, String text) {
PacketContainer metaPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
metaPacket.getIntegers().write(0, id);
if (CustomFishing.version.equals("v1_19_R2")) {
if (CustomFishing.getInstance().getVersionHelper().isVersionNewerThan1_19_R2()) {
WrappedDataWatcher wrappedDataWatcher = createDataWatcher(text);
List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
wrappedDataWatcher.getWatchableObjects().stream().filter(Objects::nonNull).forEach(entry -> {

View File

@@ -37,7 +37,7 @@ public class FakeItemUtil {
public static PacketContainer getMetaPacket(int id, ItemStack itemStack) {
PacketContainer metaPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
metaPacket.getIntegers().write(0, id);
if (CustomFishing.version.equals("v1_19_R2")) {
if (CustomFishing.getInstance().getVersionHelper().isVersionNewerThan1_19_R2()) {
WrappedDataWatcher wrappedDataWatcher = createDataWatcher(itemStack);
List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
wrappedDataWatcher.getWatchableObjects().stream().filter(Objects::nonNull).forEach(entry -> {