diff --git a/build.gradle b/build.gradle index 21d07791..e6670a4d 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'net.momirealms' -version = '1.0' +version = '1.0.4' repositories { mavenCentral() diff --git a/src/main/java/net/momirealms/customfishing/ConfigReader.java b/src/main/java/net/momirealms/customfishing/ConfigReader.java index e021518f..c87990e1 100644 --- a/src/main/java/net/momirealms/customfishing/ConfigReader.java +++ b/src/main/java/net/momirealms/customfishing/ConfigReader.java @@ -17,12 +17,6 @@ package net.momirealms.customfishing; -import dev.dejvokep.boostedyaml.YamlDocument; -import dev.dejvokep.boostedyaml.dvs.versioning.BasicVersioning; -import dev.dejvokep.boostedyaml.settings.dumper.DumperSettings; -import dev.dejvokep.boostedyaml.settings.general.GeneralSettings; -import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings; -import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings; import net.kyori.adventure.bossbar.BossBar; import net.momirealms.customfishing.competition.CompetitionConfig; import net.momirealms.customfishing.competition.Goal; @@ -30,13 +24,10 @@ import net.momirealms.customfishing.competition.bossbar.BossBarConfig; import net.momirealms.customfishing.competition.reward.CommandImpl; import net.momirealms.customfishing.competition.reward.MessageImpl; import net.momirealms.customfishing.competition.reward.Reward; -import net.momirealms.customfishing.helper.Log; +import net.momirealms.customfishing.hook.Placeholders; +import net.momirealms.customfishing.hook.skill.*; import net.momirealms.customfishing.titlebar.Difficulty; import net.momirealms.customfishing.titlebar.Layout; -import net.momirealms.customfishing.hook.skill.Aurelium; -import net.momirealms.customfishing.hook.skill.MMOCore; -import net.momirealms.customfishing.hook.skill.SkillXP; -import net.momirealms.customfishing.hook.skill.mcMMO; import net.momirealms.customfishing.item.Bait; import net.momirealms.customfishing.item.Loot; import net.momirealms.customfishing.item.Rod; @@ -53,7 +44,6 @@ import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import java.io.File; -import java.io.IOException; import java.util.*; public class ConfigReader{ @@ -70,6 +60,7 @@ public class ConfigReader{ public static HashMap Competitions = new HashMap<>(); public static HashMap CompetitionsCommand = new HashMap<>(); + public static YamlConfiguration getConfig(String configName) { File file = new File(CustomFishing.instance.getDataFolder(), configName); if (!file.exists()) { @@ -106,15 +97,10 @@ public class ConfigReader{ public static int fishFinderCoolDown; public static double timeMultiply; public static SkillXP skillXP; + public static int version; public static void loadConfig() { - try { - YamlDocument.create(new File(CustomFishing.instance.getDataFolder(), "config.yml"), CustomFishing.instance.getResource("config.yml"), GeneralSettings.DEFAULT, LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setVersioning(new BasicVersioning("config-version")).build()); - }catch (IOException e){ - Log.warn(e.getMessage()); - } - CustomFishing.instance.saveDefaultConfig(); CustomFishing.instance.reloadConfig(); FileConfiguration config = CustomFishing.instance.getConfig(); @@ -142,8 +128,6 @@ public class ConfigReader{ if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") == null){ AdventureManager.consoleMessage("[CustomFishing] Failed to initialize PlaceholderAPI!"); papi = false; - }else { - AdventureManager.consoleMessage("[CustomFishing] PlaceholderAPI Hooked!"); } } @@ -154,7 +138,7 @@ public class ConfigReader{ CustomFishing.instance.getLogger().warning("Failed to initialize mcMMO!"); }else { skillXP = new mcMMO(); - AdventureManager.consoleMessage("[CustomCrops] mcMMO Hooked!"); + AdventureManager.consoleMessage("[CustomFishing] mcMMO Hooked!"); } } if(config.getBoolean("config.integrations.AureliumSkills",false)){ @@ -162,7 +146,7 @@ public class ConfigReader{ CustomFishing.instance.getLogger().warning("Failed to initialize AureliumSkills!"); }else { skillXP = new Aurelium(); - AdventureManager.consoleMessage("[CustomCrops] AureliumSkills Hooked!"); + AdventureManager.consoleMessage("[CustomFishing] AureliumSkills Hooked!"); } } if(config.getBoolean("config.integrations.MMOCore",false)){ @@ -170,7 +154,15 @@ public class ConfigReader{ CustomFishing.instance.getLogger().warning("Failed to initialize MMOCore!"); }else { skillXP = new MMOCore(); - AdventureManager.consoleMessage("[CustomCrops] MMOCore Hooked!"); + AdventureManager.consoleMessage("[CustomFishing] MMOCore Hooked!"); + } + } + if(config.getBoolean("config.integrations.EcoSkills",false)){ + if(Bukkit.getPluginManager().getPlugin("EcoSkills") == null){ + CustomFishing.instance.getLogger().warning("Failed to initialize EcoSkills!"); + }else { + skillXP = new EcoSkill(); + AdventureManager.consoleMessage("[CustomFishing] EcoSkills Hooked!"); } } @@ -190,6 +182,7 @@ public class ConfigReader{ needOpenWater = config.getBoolean("config.need-open-water"); needSpecialRod = config.getBoolean("config.need-special-rod"); + version = config.getInt("config-version"); fishFinderCoolDown = config.getInt("config.fishfinder-cooldown"); timeMultiply = config.getDouble("config.time-multiply"); lang = config.getString("config.lang","cn"); @@ -366,9 +359,13 @@ public class ConfigReader{ loot.setScore((float) config.getDouble("items." + key + ".score",0)); if (config.contains("items." + key + ".action.message")) - loot.setMsg(config.getString("items." + key + ".action.message")); + loot.setMsg(config.getStringList("items." + key + ".action.message")); if (config.contains("items." + key + ".action.command")) loot.setCommands(config.getStringList("items." + key + ".action.command")); + if (config.contains("items." + key + ".action-hook.message")) + loot.setHookMsg(config.getStringList("items." + key + ".action-hook.message")); + if (config.contains("items." + key + ".action-hook.command")) + loot.setHookCommands(config.getStringList("items." + key + ".action-hook.command")); if (config.contains("items." + key + ".action.exp")) loot.setExp(config.getInt("items." + key + ".action.exp")); if (config.contains("items." + key + ".layout")) @@ -486,9 +483,13 @@ public class ConfigReader{ if (config.contains("mobs." + key + ".level")) loot.setMmLevel(config.getInt("mobs." + key + ".level", 0)); if (config.contains("mobs." + key + ".action.message")) - loot.setMsg(config.getString("mobs." + key + ".action.message")); + loot.setMsg(config.getStringList("mobs." + key + ".action.message")); if (config.contains("mobs." + key + ".action.command")) loot.setCommands(config.getStringList("mobs." + key + ".action.command")); + if (config.contains("mobs." + key + ".action-hook.message")) + loot.setHookMsg(config.getStringList("mobs." + key + ".action-hook.message")); + if (config.contains("mobs." + key + ".action-hook.command")) + loot.setHookCommands(config.getStringList("mobs." + key + ".action-hook.command")); if (config.contains("mobs." + key + ".action.exp")) loot.setExp(config.getInt("mobs." + key + ".action.exp")); if (config.contains("mobs." + key + ".skill-xp")) @@ -790,6 +791,15 @@ public class ConfigReader{ if (config.contains(key + ".broadcast.end")){ competitionConfig.setEndMessage(config.getStringList(key + ".broadcast.end")); } + if (config.contains(key + ".command.join")){ + competitionConfig.setJoinCommand(config.getStringList(key + ".command.join")); + } + if (config.contains(key + ".command.start")){ + competitionConfig.setStartCommand(config.getStringList(key + ".command.start")); + } + if (config.contains(key + ".command.end")){ + competitionConfig.setEndCommand(config.getStringList(key + ".command.end")); + } if (config.contains(key + ".min-players")){ competitionConfig.setMinPlayers(config.getInt(key + ".min-players")); } diff --git a/src/main/java/net/momirealms/customfishing/CustomFishing.java b/src/main/java/net/momirealms/customfishing/CustomFishing.java index 8be383a5..28933c54 100644 --- a/src/main/java/net/momirealms/customfishing/CustomFishing.java +++ b/src/main/java/net/momirealms/customfishing/CustomFishing.java @@ -24,9 +24,12 @@ import net.momirealms.customfishing.command.TabComplete; import net.momirealms.customfishing.competition.CompetitionSchedule; import net.momirealms.customfishing.competition.bossbar.BossBarManager; import net.momirealms.customfishing.helper.LibraryLoader; +import net.momirealms.customfishing.hook.Placeholders; import net.momirealms.customfishing.listener.MMOItemsConverter; +import net.momirealms.customfishing.listener.PapiReload; import net.momirealms.customfishing.listener.PlayerListener; import net.momirealms.customfishing.utils.AdventureManager; +import net.momirealms.customfishing.utils.UpdateConfig; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; @@ -38,6 +41,7 @@ public final class CustomFishing extends JavaPlugin { public static BukkitAudiences adventure; public static MiniMessage miniMessage; private CompetitionSchedule competitionSchedule; + public static Placeholders placeholders; @Override public void onLoad(){ @@ -55,6 +59,7 @@ public final class CustomFishing extends JavaPlugin { Objects.requireNonNull(Bukkit.getPluginCommand("customfishing")).setTabCompleter(new TabComplete()); Bukkit.getPluginManager().registerEvents(new PlayerListener(),this); AdventureManager.consoleMessage("[CustomFishing] Running on " + Bukkit.getVersion()); + ConfigReader.Reload(); if (ConfigReader.Config.competition){ competitionSchedule = new CompetitionSchedule(); @@ -64,12 +69,22 @@ public final class CustomFishing extends JavaPlugin { if (ConfigReader.Config.convertMMOItems){ Bukkit.getPluginManager().registerEvents(new MMOItemsConverter(), this); } + if (ConfigReader.Config.papi){ + placeholders = new Placeholders(); + placeholders.register(); + AdventureManager.consoleMessage("[CustomFishing] PlaceholderAPI Hooked!"); + Bukkit.getPluginManager().registerEvents(new PapiReload(), this); + } ConfigReader.tryEnableJedis(); + if (ConfigReader.Config.version != 2){ + UpdateConfig.update(); + } AdventureManager.consoleMessage("[CustomFishing] Plugin Enabled!"); } @Override public void onDisable() { + if (competitionSchedule != null){ competitionSchedule.stopCheck(); competitionSchedule = null; diff --git a/src/main/java/net/momirealms/customfishing/competition/Competition.java b/src/main/java/net/momirealms/customfishing/competition/Competition.java index 2fbf731a..ad9d4f38 100644 --- a/src/main/java/net/momirealms/customfishing/competition/Competition.java +++ b/src/main/java/net/momirealms/customfishing/competition/Competition.java @@ -47,6 +47,9 @@ public class Competition { private final BossBarConfig bossBarConfig; private final List startMessage; private final List endMessage; + private final List endCommand; + private final List startCommand; + private final List joinCommand; private final HashMap> rewardsMap; public static long remainingTime; @@ -61,6 +64,9 @@ public class Competition { this.startMessage = competitionConfig.getStartMessage(); this.endMessage = competitionConfig.getEndMessage(); this.rewardsMap = competitionConfig.getRewards(); + this.startCommand = competitionConfig.getStartCommand(); + this.endCommand = competitionConfig.getEndCommand(); + this.joinCommand = competitionConfig.getJoinCommand(); } public void begin(boolean forceStart) { @@ -86,6 +92,11 @@ public class Competition { }); }); } + if (startCommand != null){ + startCommand.forEach(command -> { + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command); + }); + } } else { playerCollections.forEach(player -> { @@ -148,6 +159,11 @@ public class Competition { }); }); } + if (endCommand != null){ + endCommand.forEach(command -> { + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command); + }); + } Bukkit.getScheduler().runTaskLaterAsynchronously(CustomFishing.instance, ()-> { ranking.clear(); }, 300); @@ -211,4 +227,5 @@ public class Competition { public boolean isGoingOn() {return status;} public BossBarConfig getBossBarConfig() {return bossBarConfig;} public Ranking getRanking() {return ranking;} -} + public List getJoinCommand() {return joinCommand;} +} \ No newline at end of file diff --git a/src/main/java/net/momirealms/customfishing/competition/CompetitionConfig.java b/src/main/java/net/momirealms/customfishing/competition/CompetitionConfig.java index 17051156..920647f6 100644 --- a/src/main/java/net/momirealms/customfishing/competition/CompetitionConfig.java +++ b/src/main/java/net/momirealms/customfishing/competition/CompetitionConfig.java @@ -29,6 +29,9 @@ public class CompetitionConfig { private int minPlayers; private List startMessage; private List endMessage; + private List startCommand; + private List endCommand; + private List joinCommand; private Goal goal; private BossBarConfig bossBarConfig; private final boolean enableBossBar; @@ -41,6 +44,9 @@ public class CompetitionConfig { public void setGoal(Goal goal) {this.goal = goal;} public void setEndMessage(List endMessage) {this.endMessage = endMessage;} public void setStartMessage(List startMessage) {this.startMessage = startMessage;} + public void setStartCommand(List startCommand) {this.startCommand = startCommand;} + public void setEndCommand(List endCommand) {this.endCommand = endCommand;} + public void setJoinCommand(List joinCommand) {this.joinCommand = joinCommand;} public void setMinPlayers(int minPlayers) {this.minPlayers = minPlayers;} public HashMap> getRewards() {return rewards;} @@ -52,4 +58,7 @@ public class CompetitionConfig { public List getEndMessage() {return endMessage;} public List getStartMessage() {return startMessage;} public void setRewards(HashMap> rewards) {this.rewards = rewards;} + public List getEndCommand() {return endCommand;} + public List getJoinCommand() {return joinCommand;} + public List getStartCommand() {return startCommand;} } diff --git a/src/main/java/net/momirealms/customfishing/competition/bossbar/BossBarManager.java b/src/main/java/net/momirealms/customfishing/competition/bossbar/BossBarManager.java index 666f5176..bd455966 100644 --- a/src/main/java/net/momirealms/customfishing/competition/bossbar/BossBarManager.java +++ b/src/main/java/net/momirealms/customfishing/competition/bossbar/BossBarManager.java @@ -20,6 +20,7 @@ package net.momirealms.customfishing.competition.bossbar; import net.momirealms.customfishing.ConfigReader; import net.momirealms.customfishing.competition.CompetitionSchedule; import net.momirealms.customfishing.utils.AdventureManager; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -66,6 +67,11 @@ public class BossBarManager implements Listener { if (cache.get(player) == null) { BossBarTimer timerTask = new BossBarTimer(player, CompetitionSchedule.competition.getBossBarConfig()); cache.put(player, timerTask); + if (CompetitionSchedule.competition.getJoinCommand() != null){ + CompetitionSchedule.competition.getJoinCommand().forEach(command -> { + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command.replace("{player}", player.getName())); + }); + } } } -} +} \ No newline at end of file diff --git a/src/main/java/net/momirealms/customfishing/hook/Placeholders.java b/src/main/java/net/momirealms/customfishing/hook/Placeholders.java index eb69d9e2..91024853 100644 --- a/src/main/java/net/momirealms/customfishing/hook/Placeholders.java +++ b/src/main/java/net/momirealms/customfishing/hook/Placeholders.java @@ -17,5 +17,47 @@ package net.momirealms.customfishing.hook; -public class Placeholders { +import me.clip.placeholderapi.expansion.PlaceholderExpansion; +import net.momirealms.customfishing.ConfigReader; +import net.momirealms.customfishing.competition.Competition; +import net.momirealms.customfishing.competition.CompetitionSchedule; +import org.bukkit.OfflinePlayer; +import org.jetbrains.annotations.NotNull; + +import java.util.Optional; + +public class Placeholders extends PlaceholderExpansion { + @Override + public @NotNull String getIdentifier() { + return "competition"; + } + + @Override + public @NotNull String getAuthor() { + return "XiaoMoMi"; + } + + @Override + public @NotNull String getVersion() { + return "1.0"; + } + + @Override + public String onRequest(OfflinePlayer player, String params) { + if (params.equalsIgnoreCase("timeleft")){ + if (CompetitionSchedule.competition != null && CompetitionSchedule.competition.isGoingOn()){ + return String.valueOf(Competition.remainingTime); + }else { + return "0"; + } + } + if (params.equalsIgnoreCase("rank")){ + if (CompetitionSchedule.competition != null && CompetitionSchedule.competition.isGoingOn()){ + return Optional.ofNullable(CompetitionSchedule.competition.getRanking().getPlayerRank(player.getName())).orElse(ConfigReader.Message.noRank); + }else { + return ConfigReader.Message.noRank; + } + } + return null; + } } diff --git a/src/main/java/net/momirealms/customfishing/hook/skill/EcoSkill.java b/src/main/java/net/momirealms/customfishing/hook/skill/EcoSkill.java new file mode 100644 index 00000000..bef624ed --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/hook/skill/EcoSkill.java @@ -0,0 +1,13 @@ +package net.momirealms.customfishing.hook.skill; + +import com.willfp.ecoskills.api.EcoSkillsAPI; +import com.willfp.ecoskills.skills.Skills; +import org.bukkit.entity.Player; + +public class EcoSkill implements SkillXP{ + + @Override + public void addXp(Player player, double amount) { + EcoSkillsAPI.getInstance().giveSkillExperience(player, Skills.FISHING, amount); + } +} diff --git a/src/main/java/net/momirealms/customfishing/item/Loot.java b/src/main/java/net/momirealms/customfishing/item/Loot.java index 181cdacb..9bde48dc 100644 --- a/src/main/java/net/momirealms/customfishing/item/Loot.java +++ b/src/main/java/net/momirealms/customfishing/item/Loot.java @@ -32,7 +32,6 @@ public class Loot implements Item { private List lore; private Map nbt; private String material; - private String msg; private String mm; private String layout; private VectorUtil vectorUtil; @@ -42,7 +41,10 @@ public class Loot implements Item { private final int time; private int mmLevel; private int exp; + private List msg; private List commands; + private List hookCommands; + private List hookMsg; private String group; private List enchantment; private List itemFlags; @@ -61,7 +63,7 @@ public class Loot implements Item { public String getKey(){return this.key;} public String getNick(){return this.nick;} - public String getMsg(){return this.msg;} + public List getMsg(){return this.msg;} public String getLayout(){return this.layout;} public String getMm(){return this.mm;} public boolean isShowInFinder() {return this.showInFinder;} @@ -76,6 +78,8 @@ public class Loot implements Item { public int getExp() {return exp;} public double getSkillXP() {return skillXP;} public float getScore() {return score;} + public List getHookCommands() {return hookCommands;} + public List getHookMsg() {return hookMsg;} @Override public List getLore(){return this.lore;} @@ -101,7 +105,7 @@ public class Loot implements Item { public void setRequirements(List requirements) {this.requirements = requirements;} public void setMaterial(String material){this.material = material;} public void setNick(String nick){this.nick = nick;} - public void setMsg(String msg){this.msg = msg;} + public void setMsg(List msg){this.msg = msg;} public void setMm(String mm){this.mm = mm;} public void setLayout(String layout){this.layout = layout;} public void setVectorUtil(VectorUtil vectorUtil){this.vectorUtil = vectorUtil;} @@ -115,4 +119,6 @@ public class Loot implements Item { public void setUnbreakable(boolean unbreakable){this.unbreakable = unbreakable;} public void setSkillXP(double skillXP) {this.skillXP = skillXP;} public void setScore(float score) {this.score = score;} + public void setHookMsg(List hookMsg) {this.hookMsg = hookMsg;} + public void setHookCommands(List hookCommands) {this.hookCommands = hookCommands;} } diff --git a/src/main/java/net/momirealms/customfishing/listener/PapiReload.java b/src/main/java/net/momirealms/customfishing/listener/PapiReload.java new file mode 100644 index 00000000..c815ab2f --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/listener/PapiReload.java @@ -0,0 +1,17 @@ +package net.momirealms.customfishing.listener; + +import net.momirealms.customfishing.CustomFishing; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class PapiReload implements Listener { + + @EventHandler + public void onReload(me.clip.placeholderapi.events.ExpansionUnregisterEvent event){ + if (CustomFishing.placeholders != null){ + if (event.getExpansion().equals(CustomFishing.placeholders)){ + CustomFishing.placeholders.register(); + } + } + } +} diff --git a/src/main/java/net/momirealms/customfishing/listener/PlayerListener.java b/src/main/java/net/momirealms/customfishing/listener/PlayerListener.java index 953491eb..3219d8ef 100644 --- a/src/main/java/net/momirealms/customfishing/listener/PlayerListener.java +++ b/src/main/java/net/momirealms/customfishing/listener/PlayerListener.java @@ -240,7 +240,6 @@ public class PlayerListener implements Listener { nextLoot.put(player, availableLoots.get(pos)); return; } - nextLoot.put(player, null); }); } @@ -267,12 +266,21 @@ public class PlayerListener implements Listener { difficulty = 1; } Difficulty difficult = new Difficulty(lootInstance.getDifficulty().getTimer(), difficulty); - fishingPlayers.put(player, new FishingPlayer(System.currentTimeMillis() + lootInstance.getTime(), 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, ()->{ player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, lootInstance.getTime()/50,3)); }); @@ -290,7 +298,7 @@ public class PlayerListener implements Listener { } Loot lootInstance = nextLoot.get(player); Layout layout = ConfigReader.LAYOUT.get(fishingPlayers.get(player).getTimer().getLayout()); - int last = (fishingPlayers.get(player).getTimer().getTimerTask().getProgress() + 1)/layout.getRange(); + int last = (fishingPlayers.get(player).getTimer().getTimerTask().getProgress())/layout.getRange(); fishingPlayers.remove(player); player.removePotionEffect(PotionEffectType.SLOW); if (ConfigReader.Config.needOpenWater && !event.getHook().isInOpenWater()){ @@ -317,8 +325,9 @@ public class PlayerListener implements Listener { } } if (lootInstance.getMsg() != null){ - //发送消息 - AdventureManager.playerMessage(player, ConfigReader.Message.prefix + lootInstance.getMsg().replace("{loot}",lootInstance.getNick()).replace("{player}", player.getName())); + lootInstance.getMsg().forEach(msg -> { + AdventureManager.playerMessage(player, msg.replace("{loot}",lootInstance.getNick()).replace("{player}", player.getName())); + }); } if (lootInstance.getCommands() != null){ //执行指令 @@ -327,7 +336,7 @@ public class PlayerListener implements Listener { replaceAll("\\{x}", String.valueOf(Math.round(location.getX()))). replaceAll("\\{y}", String.valueOf(Math.round(location.getY()))). replaceAll("\\{z}", String.valueOf(Math.round(location.getZ()))). - replaceAll("\\{player}", event.getPlayer().getName()). + replaceAll("\\{player}", player.getName()). replaceAll("\\{world}", player.getWorld().getName()). replaceAll("\\{loot}", lootInstance.getNick()); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), finalCommand); diff --git a/src/main/java/net/momirealms/customfishing/utils/UpdateConfig.java b/src/main/java/net/momirealms/customfishing/utils/UpdateConfig.java new file mode 100644 index 00000000..6e55c5a6 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/utils/UpdateConfig.java @@ -0,0 +1,24 @@ +package net.momirealms.customfishing.utils; + +import dev.dejvokep.boostedyaml.YamlDocument; +import dev.dejvokep.boostedyaml.dvs.versioning.BasicVersioning; +import dev.dejvokep.boostedyaml.settings.dumper.DumperSettings; +import dev.dejvokep.boostedyaml.settings.general.GeneralSettings; +import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings; +import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings; +import net.momirealms.customfishing.CustomFishing; +import net.momirealms.customfishing.helper.Log; + +import java.io.File; +import java.io.IOException; + +public class UpdateConfig { + + public static void update(){ + try { + YamlDocument.create(new File(CustomFishing.instance.getDataFolder(), "config.yml"), CustomFishing.instance.getResource("config.yml"), GeneralSettings.DEFAULT, LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setVersioning(new BasicVersioning("config-version")).build()); + }catch (IOException e){ + Log.warn(e.getMessage()); + } + } +} diff --git a/src/main/resources/bars.yml b/src/main/resources/bars.yml index f6dedb2a..16baa687 100644 --- a/src/main/resources/bars.yml +++ b/src/main/resources/bars.yml @@ -2,6 +2,9 @@ bar1: range: 16 title: 'The fish is hooked, focus on it!' subtitle: + # + # It's not recommended to use minecraft:default + # If you insists on that, use start: '' bar: '뀄' pointer_offset: '뀂' diff --git a/src/main/resources/competition.yml b/src/main/resources/competition.yml index 26bf7b48..e7856d1e 100644 --- a/src/main/resources/competition.yml +++ b/src/main/resources/competition.yml @@ -16,9 +16,20 @@ example: enable: true color: YELLOW overlay: PROGRESS + #https://docs.adventure.kyori.net/minimessage/format.html text: 'Time Left: {time}s Rank: {rank} Time Left: {minute}m{second}s Points: {point}' refresh-rate: 10 + command: + start: + - 'say competition started!' + end: + - 'say competition ended!' + # When player join the competition + # You can execute some commands on that player + join: + - 'money give {player} 10' + broadcast: start: - ' Fishing competition⚠' diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index dc9279b0..d762611b 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,5 @@ # don't change -config-version: 1 +config-version: 2 config: #en/es/cn @@ -12,22 +12,24 @@ config: mcMMO: false MMOCore: false AureliumSkills: false + EcoSkills: false season: enable: false # Season Papi papi: '%customcrops_season%' - # If there's no custom fish in this place - # Should players get vanilla loots? - vanilla-loot-when-no-custom-fish: false - # The same to vanilla need-open-water: true # Players must use rods with CustomFishing's NBT Tags need-special-rod: false + # If there's no custom fish in this place or players don't have a special rod + # Should players get loots in vanilla way? + # This should be compatible with other fishing plugin's loot system + vanilla-loot-when-no-custom-fish: false + # Cool down time of fish finder fishfinder-cooldown: 3000 diff --git a/src/main/resources/loots.yml b/src/main/resources/loots.yml index b571f527..2fa8260b 100644 --- a/src/main/resources/loots.yml +++ b/src/main/resources/loots.yml @@ -30,6 +30,12 @@ items: command: - 'say 玩家 {player} 在 {world}, {x},{y},{z} 钓到了一条 {loot}!' exp: 10 + # Action to be triggered when fish is hooked + action-hook: + message: + - 'The fish is hooked!' + command: + - 'effect give {player} minecraft:slowness 30 10' # The weight(relative chance) of getting this fish weight: 10 # Optional diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 4a8f3fa4..d5102ad5 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -10,6 +10,7 @@ softdepend: - mcMMO - AureliumSkills - MMOCore + - EcoSkills commands: customfishing: usage: /customfishing