mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-29 03:49:07 +00:00
1.0.6
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
package net.momirealms.customfishing;
|
||||
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.momirealms.customcrops.helper.Log;
|
||||
import net.momirealms.customfishing.competition.CompetitionConfig;
|
||||
import net.momirealms.customfishing.competition.Goal;
|
||||
import net.momirealms.customfishing.competition.bossbar.BossBarConfig;
|
||||
@@ -92,12 +93,15 @@ public class ConfigReader{
|
||||
public static boolean needSpecialRod;
|
||||
public static boolean competition;
|
||||
public static boolean convertMMOItems;
|
||||
public static boolean loseDurability;
|
||||
public static boolean rsSeason;
|
||||
public static boolean ccSeason;
|
||||
public static String season_papi;
|
||||
public static String lang;
|
||||
public static int fishFinderCoolDown;
|
||||
public static double timeMultiply;
|
||||
public static SkillXP skillXP;
|
||||
public static int version;
|
||||
public static String version;
|
||||
|
||||
public static void loadConfig() {
|
||||
|
||||
@@ -169,20 +173,38 @@ public class ConfigReader{
|
||||
season = config.getBoolean("config.season.enable");
|
||||
if (!papi && season) {
|
||||
season = false;
|
||||
}
|
||||
|
||||
if (season) {
|
||||
season_papi = config.getString("config.season.papi");
|
||||
}else {
|
||||
season_papi = null;
|
||||
season_papi = config.getString("config.season.papi");
|
||||
}
|
||||
|
||||
vanillaDrop = config.getBoolean("config.vanilla-loot-when-no-custom-fish");
|
||||
convertMMOItems = config.getBoolean("config.convert-MMOITEMS");
|
||||
needOpenWater = config.getBoolean("config.need-open-water");
|
||||
needSpecialRod = config.getBoolean("config.need-special-rod");
|
||||
rsSeason = false;
|
||||
if (config.getBoolean("config.integrations.RealisticSeasons",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("RealisticSeasons") == null) Log.warn("Failed to initialize RealisticSeasons!");
|
||||
else {
|
||||
rsSeason = true;
|
||||
AdventureManager.consoleMessage("<gradient:#0070B3:#A0EACF>[CustomFishing] </gradient><color:#00BFFF>RealisticSeasons <color:#E1FFFF>Hooked!");
|
||||
}
|
||||
}
|
||||
ccSeason = false;
|
||||
if (config.getBoolean("config.integrations.CustomCrops",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("CustomCrops") == null) Log.warn("Failed to initialize CustomCrops!");
|
||||
else {
|
||||
ccSeason = true;
|
||||
AdventureManager.consoleMessage("<gradient:#0070B3:#A0EACF>[CustomFishing] </gradient><color:#00BFFF>CustomCrops <color:#E1FFFF>Hooked!");
|
||||
}
|
||||
}
|
||||
|
||||
version = config.getInt("config-version");
|
||||
if (rsSeason || ccSeason){
|
||||
season = true;
|
||||
}
|
||||
|
||||
vanillaDrop = config.getBoolean("config.vanilla-loot-when-no-custom-fish", true);
|
||||
convertMMOItems = config.getBoolean("config.convert-MMOITEMS", false);
|
||||
needOpenWater = config.getBoolean("config.need-open-water", false);
|
||||
needSpecialRod = config.getBoolean("config.need-special-rod", false);
|
||||
loseDurability = config.getBoolean("config.rod-lose-durability", true);
|
||||
|
||||
version = config.getString("config-version");
|
||||
fishFinderCoolDown = config.getInt("config.fishfinder-cooldown");
|
||||
timeMultiply = config.getDouble("config.time-multiply");
|
||||
lang = config.getString("config.lang","cn");
|
||||
|
||||
@@ -76,7 +76,7 @@ public final class CustomFishing extends JavaPlugin {
|
||||
Bukkit.getPluginManager().registerEvents(new PapiReload(), this);
|
||||
}
|
||||
ConfigReader.tryEnableJedis();
|
||||
if (ConfigReader.Config.version != 2){
|
||||
if (!Objects.equals(ConfigReader.Config.version, "3")){
|
||||
UpdateConfig.update();
|
||||
}
|
||||
AdventureManager.consoleMessage("<gradient:#0070B3:#A0EACF>[CustomFishing] </gradient><color:#E1FFFF>Plugin Enabled!");
|
||||
|
||||
@@ -154,6 +154,9 @@ public class TabComplete implements TabCompleter {
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
if (args[2].equalsIgnoreCase("get")){
|
||||
return Arrays.asList("1","16","64");
|
||||
}
|
||||
}else if (args[1].equalsIgnoreCase("util")){
|
||||
if (args[2].equalsIgnoreCase("give")){
|
||||
List<String> arrayList = new ArrayList<>();
|
||||
@@ -163,6 +166,9 @@ public class TabComplete implements TabCompleter {
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
if (args[2].equalsIgnoreCase("get")){
|
||||
return Arrays.asList("1","16","64");
|
||||
}
|
||||
}else if (args[1].equalsIgnoreCase("rod")){
|
||||
if (args[2].equalsIgnoreCase("give")){
|
||||
List<String> arrayList = new ArrayList<>();
|
||||
@@ -172,6 +178,9 @@ public class TabComplete implements TabCompleter {
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
if (args[2].equalsIgnoreCase("get")){
|
||||
return Arrays.asList("1","16","64");
|
||||
}
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("bait")){
|
||||
if (args[2].equalsIgnoreCase("give")){
|
||||
@@ -182,6 +191,31 @@ public class TabComplete implements TabCompleter {
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
if (args[2].equalsIgnoreCase("get")){
|
||||
return Arrays.asList("1","16","64");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args.length == 6){
|
||||
if (args[0].equalsIgnoreCase("items")){
|
||||
if (args[1].equalsIgnoreCase("loot")){
|
||||
if (args[2].equalsIgnoreCase("give")){
|
||||
return Arrays.asList("1","16","64");
|
||||
}
|
||||
}else if (args[1].equalsIgnoreCase("util")){
|
||||
if (args[2].equalsIgnoreCase("give")){
|
||||
return Arrays.asList("1","16","64");
|
||||
}
|
||||
}else if (args[1].equalsIgnoreCase("rod")){
|
||||
if (args[2].equalsIgnoreCase("give")){
|
||||
return List.of("1");
|
||||
}
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("bait")){
|
||||
if (args[2].equalsIgnoreCase("give")){
|
||||
return Arrays.asList("1","16","64");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.momirealms.customfishing.hook;
|
||||
|
||||
import net.momirealms.customcrops.api.CustomCropsAPI;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class CustomCropsSeason {
|
||||
|
||||
public static String getSeason(World world){
|
||||
return CustomCropsAPI.getSeason(world.getName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.momirealms.customfishing.hook;
|
||||
|
||||
import me.casperge.realisticseasons.api.SeasonsAPI;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class RealisticSeason {
|
||||
public static String getSeason(World world){
|
||||
SeasonsAPI seasonsapi = SeasonsAPI.getInstance();
|
||||
switch (seasonsapi.getSeason(world)){
|
||||
case SPRING -> {
|
||||
return "spring";
|
||||
}
|
||||
case SUMMER -> {
|
||||
return "summer";
|
||||
}
|
||||
case WINTER -> {
|
||||
return "winter";
|
||||
}
|
||||
case FALL -> {
|
||||
return "autumn";
|
||||
}
|
||||
}
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,6 @@ public class mcMMO implements SkillXP{
|
||||
|
||||
@Override
|
||||
public void addXp(Player player, double amount) {
|
||||
ExperienceAPI.addXP(player, "Fishing", (int) amount, "UNKNOWN");
|
||||
ExperienceAPI.addRawXP(player, "FISHING", (float) amount, "UNKNOWN");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
@@ -62,6 +64,7 @@ public class PlayerListener implements Listener {
|
||||
private final HashMap<Player, Long> coolDown = new HashMap<>();
|
||||
private final HashMap<Player, Loot> nextLoot = new HashMap<>();
|
||||
private final HashMap<Player, Modifier> modifiers = new HashMap<>();
|
||||
private final HashMap<Player, FishHook> hooks = new HashMap<>();
|
||||
public static ConcurrentHashMap<Player, FishingPlayer> fishingPlayers = new ConcurrentHashMap<>();
|
||||
|
||||
@EventHandler
|
||||
@@ -80,6 +83,8 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
coolDown.put(player, time);
|
||||
|
||||
hooks.put(player, event.getHook());
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(CustomFishing.instance, ()->{
|
||||
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
@@ -271,17 +276,17 @@ public class PlayerListener implements Listener {
|
||||
new Timer(player, difficult, layout)
|
||||
)
|
||||
);
|
||||
if (lootInstance.getHookCommands() != null){
|
||||
lootInstance.getHookCommands().forEach(command ->{
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replace("{player}", player.getName()));
|
||||
});
|
||||
}
|
||||
if (lootInstance.getHookMsg() != null){
|
||||
lootInstance.getHookMsg().forEach(msg -> {
|
||||
AdventureManager.playerMessage(player, msg.replace("{loot}",lootInstance.getNick()).replace("{player}", player.getName()));
|
||||
});
|
||||
}
|
||||
Bukkit.getScheduler().runTask(CustomFishing.instance, ()->{
|
||||
if (lootInstance.getHookCommands() != null){
|
||||
lootInstance.getHookCommands().forEach(command ->{
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replace("{player}", player.getName()));
|
||||
});
|
||||
}
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, lootInstance.getTime()/50,3));
|
||||
});
|
||||
});
|
||||
@@ -330,7 +335,6 @@ public class PlayerListener implements Listener {
|
||||
});
|
||||
}
|
||||
if (lootInstance.getCommands() != null){
|
||||
//执行指令
|
||||
lootInstance.getCommands().forEach(command ->{
|
||||
String finalCommand = command.
|
||||
replaceAll("\\{x}", String.valueOf(Math.round(location.getX()))).
|
||||
@@ -349,6 +353,27 @@ public class PlayerListener implements Listener {
|
||||
if (lootInstance.getSkillXP() != 0){
|
||||
ConfigReader.Config.skillXP.addXp(player, lootInstance.getSkillXP());
|
||||
}
|
||||
if (ConfigReader.Config.loseDurability){
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
ItemStack mainHand = inventory.getItemInMainHand();
|
||||
if (mainHand.getType() == Material.FISHING_ROD){
|
||||
Damageable damageable = (Damageable) mainHand.getItemMeta();
|
||||
if (damageable.hasDamage()) System.out.println(1);
|
||||
damageable.setDamage(damageable.getDamage() + 1);
|
||||
Bukkit.getScheduler().runTaskLater(CustomFishing.instance, ()->{
|
||||
mainHand.setItemMeta((ItemMeta) damageable);
|
||||
},1);
|
||||
}else {
|
||||
ItemStack offHand = inventory.getItemInOffHand();
|
||||
if (offHand.getType() == Material.FISHING_ROD){
|
||||
Damageable damageable = (Damageable) offHand.getItemMeta();
|
||||
damageable.setDamage(damageable.getDamage() + 1);
|
||||
Bukkit.getScheduler().runTaskLater(CustomFishing.instance, ()->{
|
||||
offHand.setItemMeta((ItemMeta) damageable);
|
||||
},1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CompetitionSchedule.competition != null && CompetitionSchedule.competition.isGoingOn()){
|
||||
float score = (float) (lootInstance.getScore() * modifiers.get(player).getScoreModifier());
|
||||
CompetitionSchedule.competition.refreshRanking(player.getName(), score);
|
||||
@@ -380,6 +405,10 @@ public class PlayerListener implements Listener {
|
||||
public void onQUit(PlayerQuitEvent event){
|
||||
Player player = event.getPlayer();
|
||||
player.removePotionEffect(PotionEffectType.SLOW);
|
||||
if (hooks.get(player) != null){
|
||||
hooks.get(player).remove();
|
||||
}
|
||||
hooks.remove(player);
|
||||
coolDown.remove(player);
|
||||
nextLoot.remove(player);
|
||||
modifiers.remove(player);
|
||||
|
||||
@@ -19,6 +19,8 @@ package net.momirealms.customfishing.requirements;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.momirealms.customfishing.ConfigReader;
|
||||
import net.momirealms.customfishing.hook.CustomCropsSeason;
|
||||
import net.momirealms.customfishing.hook.RealisticSeason;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.List;
|
||||
@@ -31,7 +33,14 @@ public record Season(List<String> seasons) implements Requirement {
|
||||
|
||||
@Override
|
||||
public boolean isConditionMet(FishingCondition fishingCondition) {
|
||||
String currentSeason = ChatColor.stripColor(PlaceholderAPI.setPlaceholders(fishingCondition.getPlayer(), ConfigReader.Config.season_papi));
|
||||
String currentSeason;
|
||||
if (ConfigReader.Config.rsSeason){
|
||||
currentSeason = RealisticSeason.getSeason(fishingCondition.getLocation().getWorld());
|
||||
}else if(ConfigReader.Config.ccSeason){
|
||||
currentSeason = CustomCropsSeason.getSeason(fishingCondition.getLocation().getWorld());
|
||||
}else {
|
||||
currentSeason = ChatColor.stripColor(PlaceholderAPI.setPlaceholders(fishingCondition.getPlayer(), ConfigReader.Config.season_papi));
|
||||
}
|
||||
for (String season : seasons) {
|
||||
if (season.equalsIgnoreCase(currentSeason)) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user