9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-23 00:49:33 +00:00
This commit is contained in:
Xiao-MoMi
2022-08-31 00:05:40 +08:00
parent c225cb4d84
commit d4e8c1ce85
14 changed files with 60 additions and 29 deletions

View File

@@ -5,7 +5,7 @@ plugins {
group = 'net.momirealms' group = 'net.momirealms'
version = '1.6.1.0' version = '1.6.1.2'
repositories { repositories {
mavenCentral() mavenCentral()
@@ -63,8 +63,10 @@ dependencies {
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.7' compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.7'
compileOnly 'com.github.LoneDev6:api-itemsadder:3.2.3c' compileOnly 'com.github.LoneDev6:api-itemsadder:3.2.3c'
compileOnly 'com.palmergames.bukkit.towny:towny:0.98.2.0' compileOnly 'com.palmergames.bukkit.towny:towny:0.98.2.0'
compileOnly fileTree(dir:'libs',includes:['*.jar']) compileOnly 'com.willfp:EcoSkills:1.72.0'
compileOnly 'com.willfp:eco:6.38.3'
compileOnly 'com.github.Zrips:Jobs:4.17.2' compileOnly 'com.github.Zrips:Jobs:4.17.2'
compileOnly fileTree(dir:'libs',includes:['*.jar'])
implementation("net.kyori:adventure-api:4.11.0") implementation("net.kyori:adventure-api:4.11.0")
implementation('net.kyori:adventure-platform-bukkit:4.1.2') implementation('net.kyori:adventure-platform-bukkit:4.1.2')
implementation("net.kyori:adventure-text-minimessage:4.11.0") implementation("net.kyori:adventure-text-minimessage:4.11.0")

View File

@@ -47,6 +47,7 @@ public class ConfigReader {
public static HashMap<String, Fertilizer> FERTILIZERS = new HashMap<>(); public static HashMap<String, Fertilizer> FERTILIZERS = new HashMap<>();
public static HashMap<String, WateringCan> CANS = new HashMap<>(); public static HashMap<String, WateringCan> CANS = new HashMap<>();
public static HashMap<String, Sprinkler> SPRINKLERS = new HashMap<>(); public static HashMap<String, Sprinkler> SPRINKLERS = new HashMap<>();
public static boolean useRedis;
public static YamlConfiguration getConfig(String configName) { public static YamlConfiguration getConfig(String configName) {
File file = new File(CustomCrops.plugin.getDataFolder(), configName); File file = new File(CustomCrops.plugin.getDataFolder(), configName);
@@ -239,6 +240,10 @@ public class ConfigReader {
if(Bukkit.getPluginManager().getPlugin("EcoSkills") == null) Log.warn("Failed to initialize EcoSkills!"); if(Bukkit.getPluginManager().getPlugin("EcoSkills") == null) Log.warn("Failed to initialize EcoSkills!");
else {skillXP = new EcoSkill();hookMessage("EcoSkills");} else {skillXP = new EcoSkill();hookMessage("EcoSkills");}
} }
if(config.getBoolean("config.integration.JobsReborn",false)){
if(Bukkit.getPluginManager().getPlugin("Jobs") == null) Log.warn("Failed to initialize Jobs!");
else {skillXP = new JobsReborn();hookMessage("JobsReborn");}
}
} }
} }
@@ -288,7 +293,7 @@ public class ConfigReader {
CANS.put(namespacedID, wateringCan); CANS.put(namespacedID, wateringCan);
}); });
} }
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><white>" + CANS.size() + " <color:#FFEBCD>cans loaded!"); AdventureManager.consoleMessage("[CustomCrops] Loaded <green>" + CANS.size() + " <gray>watering-cans");
SPRINKLERS.clear(); SPRINKLERS.clear();
if (config.contains("sprinkler")){ if (config.contains("sprinkler")){
@@ -302,7 +307,7 @@ public class ConfigReader {
SPRINKLERS.put(twoD, sprinklerData); SPRINKLERS.put(twoD, sprinklerData);
}); });
} }
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><white>" + SPRINKLERS.size()/2 + "<color:#FFEBCD> sprinklers loaded!"); AdventureManager.consoleMessage("[CustomCrops] Loaded <green>" + SPRINKLERS.size()/2 + "<gray> sprinklers");
} }
} }
@@ -324,8 +329,8 @@ public class ConfigReader {
if (greenhouse) range = config.getInt("season.greenhouse.range",7); if (greenhouse) range = config.getInt("season.greenhouse.range",7);
seasonChange = config.getBoolean("season.auto-season-change.enable",false); seasonChange = config.getBoolean("season.auto-season-change.enable",false);
duration = config.getInt("season.auto-season-change.duration",28); duration = config.getInt("season.auto-season-change.duration",28);
if (seasonChange) AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><color:#FFEBCD>Season Change mode: <gold>Auto"); if (seasonChange) AdventureManager.consoleMessage("[CustomCrops] Season Change mode: <gold>Auto");
else AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><color:#FFEBCD>Season Change mode: <gold>Command"); else AdventureManager.consoleMessage("[CustomCrops] Season Change mode: <gold>Command");
} }
} }
} }
@@ -480,7 +485,7 @@ public class ConfigReader {
}else {cropInstance.setDropIALoot(false);} }else {cropInstance.setDropIALoot(false);}
CROPS.put(key, cropInstance); CROPS.put(key, cropInstance);
}); });
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><white>" + CROPS.size() + " <color:#FFEBCD>crops loaded!"); AdventureManager.consoleMessage("[CustomCrops] Loaded<green> " + CROPS.size() + " <gray>crops");
} }
public static void fertilizerLoad(){ public static void fertilizerLoad(){
@@ -540,7 +545,7 @@ public class ConfigReader {
FERTILIZERS.put(id, yieldIncreasing); FERTILIZERS.put(id, yieldIncreasing);
}); });
} }
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><white>" + FERTILIZERS.size() + " <color:#FFEBCD>fertilizers loaded!"); AdventureManager.consoleMessage("[CustomCrops] Loaded <green>" + FERTILIZERS.size() + " <gray>fertilizers");
} }
public static class Sounds{ public static class Sounds{
@@ -585,11 +590,15 @@ public class ConfigReader {
public static void tryEnableJedis(){ public static void tryEnableJedis(){
YamlConfiguration configuration = ConfigReader.getConfig("redis.yml"); YamlConfiguration configuration = ConfigReader.getConfig("redis.yml");
JedisUtil.useRedis = configuration.getBoolean("redis.enable", false); if (configuration.getBoolean("redis.enable", false)){
if (JedisUtil.useRedis) JedisUtil.initializeRedis(configuration); useRedis = true;
JedisUtil.initializeRedis(configuration);
}else {
useRedis = false;
}
} }
private static void hookMessage(String plugin){ private static void hookMessage(String plugin){
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>" + plugin + " <color:#FFEBCD>Hooked!"); AdventureManager.consoleMessage("[CustomCrops] <gold>" + plugin + " <color:#FFEBCD>Hooked!");
} }
} }

View File

@@ -24,7 +24,7 @@ import net.momirealms.customcrops.datamanager.*;
import net.momirealms.customcrops.datamanager.CropManager; import net.momirealms.customcrops.datamanager.CropManager;
import net.momirealms.customcrops.datamanager.SprinklerManager; import net.momirealms.customcrops.datamanager.SprinklerManager;
import net.momirealms.customcrops.helper.LibraryLoader; import net.momirealms.customcrops.helper.LibraryLoader;
import net.momirealms.customcrops.hook.Placeholders; import net.momirealms.customcrops.integrations.Placeholders;
import net.momirealms.customcrops.listener.*; import net.momirealms.customcrops.listener.*;
import net.momirealms.customcrops.listener.itemframe.BreakBlockI; import net.momirealms.customcrops.listener.itemframe.BreakBlockI;
import net.momirealms.customcrops.listener.itemframe.BreakFurnitureI; import net.momirealms.customcrops.listener.itemframe.BreakFurnitureI;
@@ -73,33 +73,31 @@ public final class CustomCrops extends JavaPlugin {
public void onEnable() { public void onEnable() {
adventure = BukkitAudiences.create(plugin); adventure = BukkitAudiences.create(plugin);
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><color:#FFEBCD>Running on " + Bukkit.getVersion()); AdventureManager.consoleMessage("[CustomCrops] Running on <white>" + Bukkit.getVersion());
ConfigReader.reloadConfig(); ConfigReader.reloadConfig();
if (!Objects.equals(ConfigReader.Config.version, "3")){ if (!Objects.equals(ConfigReader.Config.version, "5")){
ConfigUtil.update(); ConfigUtil.update();
} }
if(Bukkit.getPluginManager().getPlugin("PlaceHolderAPI") != null){ if(Bukkit.getPluginManager().getPlugin("PlaceHolderAPI") != null){
placeholders = new Placeholders(); placeholders = new Placeholders();
placeholders.register(); placeholders.register();
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>PlaceHolderAPI <color:#FFEBCD>Hooked!");
Bukkit.getPluginManager().registerEvents(new PapiReload(), this); Bukkit.getPluginManager().registerEvents(new PapiReload(), this);
} }
Objects.requireNonNull(Bukkit.getPluginCommand("customcrops")).setExecutor(new Executor(this)); Objects.requireNonNull(Bukkit.getPluginCommand("customcrops")).setExecutor(new Executor(this));
Objects.requireNonNull(Bukkit.getPluginCommand("customcrops")).setTabCompleter(new Completer()); Objects.requireNonNull(Bukkit.getPluginCommand("customcrops")).setTabCompleter(new Completer());
//公用事件
Bukkit.getPluginManager().registerEvents(new ItemSpawn(), this); Bukkit.getPluginManager().registerEvents(new ItemSpawn(), this);
Bukkit.getPluginManager().registerEvents(new JoinAndQuit(), this); Bukkit.getPluginManager().registerEvents(new JoinAndQuit(), this);
ConfigReader.tryEnableJedis(); ConfigReader.tryEnableJedis();
if (ConfigReader.Season.enable){ if (ConfigReader.Season.enable){
this.seasonManager = new SeasonManager(); this.seasonManager = new SeasonManager();
this.seasonManager.loadData(); this.seasonManager.loadData();
} }
this.sprinklerManager = new SprinklerManager(); this.sprinklerManager = new SprinklerManager();
this.sprinklerManager.loadData(); this.sprinklerManager.loadData();
this.potManager = new PotManager(); this.potManager = new PotManager();
@@ -107,14 +105,14 @@ public final class CustomCrops extends JavaPlugin {
this.cropTimer = new CropTimer(); this.cropTimer = new CropTimer();
if (ConfigReader.Config.cropMode.equalsIgnoreCase("item_frame")){ if (ConfigReader.Config.cropMode.equalsIgnoreCase("item_frame")){
this.cropManager = new CropManager(true); this.cropManager = new CropManager(true);
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><color:#F5DEB3>Crop Mode: ItemFrame"); AdventureManager.consoleMessage("[CustomCrops] Crop Mode: <color:#F5DEB3>ItemFrame");
Bukkit.getPluginManager().registerEvents(new RightClickI(), this); Bukkit.getPluginManager().registerEvents(new RightClickI(), this);
Bukkit.getPluginManager().registerEvents(new BreakBlockI(), this); Bukkit.getPluginManager().registerEvents(new BreakBlockI(), this);
Bukkit.getPluginManager().registerEvents(new BreakFurnitureI(), this); Bukkit.getPluginManager().registerEvents(new BreakFurnitureI(), this);
Bukkit.getPluginManager().registerEvents(new InteractFurnitureI(), this); Bukkit.getPluginManager().registerEvents(new InteractFurnitureI(), this);
}else{ }else{
this.cropManager = new CropManager(false); this.cropManager = new CropManager(false);
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><color:#F5DEB3>Crop Mode: TripWire"); AdventureManager.consoleMessage("[CustomCrops] Crop Mode: <color:#F5DEB3>TripWire");
Bukkit.getPluginManager().registerEvents(new RightClickT(), this); Bukkit.getPluginManager().registerEvents(new RightClickT(), this);
Bukkit.getPluginManager().registerEvents(new BreakBlockT(), this); Bukkit.getPluginManager().registerEvents(new BreakBlockT(), this);
Bukkit.getPluginManager().registerEvents(new BreakFurnitureT(), this); Bukkit.getPluginManager().registerEvents(new BreakFurnitureT(), this);

View File

@@ -816,7 +816,7 @@ public class CropManager{
} }
private HashSet<String> getPlayers(){ private HashSet<String> getPlayers(){
if (JedisUtil.useRedis){ if (ConfigReader.useRedis){
return JedisUtil.getPlayers(); return JedisUtil.getPlayers();
}else { }else {
return new HashSet<>(JoinAndQuit.onlinePlayers); return new HashSet<>(JoinAndQuit.onlinePlayers);

View File

@@ -17,7 +17,7 @@
package net.momirealms.customcrops.datamanager; package net.momirealms.customcrops.datamanager;
import net.momirealms.customcrops.hook.RealisticSeason; import net.momirealms.customcrops.integrations.RealisticSeason;
import net.momirealms.customcrops.utils.AdventureManager; import net.momirealms.customcrops.utils.AdventureManager;
import net.momirealms.customcrops.ConfigReader; import net.momirealms.customcrops.ConfigReader;
import net.momirealms.customcrops.CustomCrops; import net.momirealms.customcrops.CustomCrops;

View File

@@ -338,7 +338,7 @@ public class SprinklerManager {
} }
private HashSet<String> getPlayers(){ private HashSet<String> getPlayers(){
if (JedisUtil.useRedis){ if (ConfigReader.useRedis){
return JedisUtil.getPlayers(); return JedisUtil.getPlayers();
}else { }else {
return new HashSet<>(JoinAndQuit.onlinePlayers); return new HashSet<>(JoinAndQuit.onlinePlayers);

View File

@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customcrops.hook; package net.momirealms.customcrops.integrations;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.momirealms.customcrops.ConfigReader; import net.momirealms.customcrops.ConfigReader;

View File

@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customcrops.hook; package net.momirealms.customcrops.integrations;
import me.casperge.realisticseasons.api.SeasonsAPI; import me.casperge.realisticseasons.api.SeasonsAPI;
import org.bukkit.World; import org.bukkit.World;

View File

@@ -1,9 +1,28 @@
package net.momirealms.customcrops.integrations.skill; package net.momirealms.customcrops.integrations.skill;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.List;
public class JobsReborn implements SkillXP{ public class JobsReborn implements SkillXP{
@Override @Override
public void addXp(Player player, double amount) { public void addXp(Player player, double amount) {
JobsPlayer jobsPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jobsPlayer != null) {
List<JobProgression> jobs = jobsPlayer.getJobProgression();
Job job = Jobs.getJob("Farmer");
for (JobProgression progression : jobs)
if (progression.getJob().equals(job)){
progression.addExperience(amount);
}
}
} }
} }

View File

@@ -1,5 +1,6 @@
package net.momirealms.customcrops.listener; package net.momirealms.customcrops.listener;
import net.momirealms.customcrops.ConfigReader;
import net.momirealms.customcrops.utils.JedisUtil; import net.momirealms.customcrops.utils.JedisUtil;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@@ -17,13 +18,13 @@ public class JoinAndQuit implements Listener {
@EventHandler @EventHandler
public void onJoin(PlayerJoinEvent event){ public void onJoin(PlayerJoinEvent event){
if (JedisUtil.useRedis) JedisUtil.addPlayer(event.getPlayer().getName()); if (ConfigReader.useRedis) JedisUtil.addPlayer(event.getPlayer().getName());
else onlinePlayers.add(event.getPlayer().getName()); else onlinePlayers.add(event.getPlayer().getName());
} }
@EventHandler @EventHandler
public void onQuit(PlayerQuitEvent event){ public void onQuit(PlayerQuitEvent event){
if (JedisUtil.useRedis) JedisUtil.remPlayer(event.getPlayer().getName()); if (ConfigReader.useRedis) JedisUtil.remPlayer(event.getPlayer().getName());
else onlinePlayers.remove(event.getPlayer().getName()); else onlinePlayers.remove(event.getPlayer().getName());
coolDown.remove(event.getPlayer()); coolDown.remove(event.getPlayer());
} }

View File

@@ -15,7 +15,6 @@ import java.util.List;
public class JedisUtil { public class JedisUtil {
private static JedisPool jedisPool; private static JedisPool jedisPool;
public static boolean useRedis;
public static Jedis getJedis(){ public static Jedis getJedis(){
return jedisPool.getResource(); return jedisPool.getResource();

View File

@@ -1,5 +1,5 @@
#Don't change #Don't change
config-version: '4' config-version: '5'
#Want to sell the crops? #Want to sell the crops?
#Try this plugin: https://www.spigotmc.org/resources/shipping-bin.104591/ #Try this plugin: https://www.spigotmc.org/resources/shipping-bin.104591/
@@ -67,6 +67,7 @@ config:
mcMMO: false mcMMO: false
MMOCore: false MMOCore: false
EcoSkills: false EcoSkills: false
JobsReborn: false
#integration to sync seasons #integration to sync seasons
RealisticSeasons: false RealisticSeasons: false

View File

@@ -22,6 +22,7 @@ softdepend:
- EcoSkills - EcoSkills
- CrashClaim - CrashClaim
- RealisticSeasons - RealisticSeasons
- Jobs
commands: commands:
customcrops: customcrops:
usage: /customcrops <args> usage: /customcrops <args>

View File

@@ -1,5 +1,5 @@
#请不要修改此值 #请不要修改此值
config-version: '4' config-version: '5'
config: config:
@@ -59,6 +59,7 @@ config:
mcMMO: false mcMMO: false
MMOCore: false MMOCore: false
EcoSkills: false EcoSkills: false
JobsReborn: false
#季节同步 #季节同步
RealisticSeasons: false RealisticSeasons: false