mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 16:39:36 +00:00
1.6.1.2
This commit is contained in:
@@ -47,6 +47,7 @@ public class ConfigReader {
|
||||
public static HashMap<String, Fertilizer> FERTILIZERS = new HashMap<>();
|
||||
public static HashMap<String, WateringCan> CANS = new HashMap<>();
|
||||
public static HashMap<String, Sprinkler> SPRINKLERS = new HashMap<>();
|
||||
public static boolean useRedis;
|
||||
|
||||
public static YamlConfiguration getConfig(String 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!");
|
||||
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);
|
||||
});
|
||||
}
|
||||
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();
|
||||
if (config.contains("sprinkler")){
|
||||
@@ -302,7 +307,7 @@ public class ConfigReader {
|
||||
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);
|
||||
seasonChange = config.getBoolean("season.auto-season-change.enable",false);
|
||||
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");
|
||||
else AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><color:#FFEBCD>Season Change mode: <gold>Command");
|
||||
if (seasonChange) AdventureManager.consoleMessage("[CustomCrops] Season Change mode: <gold>Auto");
|
||||
else AdventureManager.consoleMessage("[CustomCrops] Season Change mode: <gold>Command");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -480,7 +485,7 @@ public class ConfigReader {
|
||||
}else {cropInstance.setDropIALoot(false);}
|
||||
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(){
|
||||
@@ -540,7 +545,7 @@ public class ConfigReader {
|
||||
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{
|
||||
@@ -585,11 +590,15 @@ public class ConfigReader {
|
||||
|
||||
public static void tryEnableJedis(){
|
||||
YamlConfiguration configuration = ConfigReader.getConfig("redis.yml");
|
||||
JedisUtil.useRedis = configuration.getBoolean("redis.enable", false);
|
||||
if (JedisUtil.useRedis) JedisUtil.initializeRedis(configuration);
|
||||
if (configuration.getBoolean("redis.enable", false)){
|
||||
useRedis = true;
|
||||
JedisUtil.initializeRedis(configuration);
|
||||
}else {
|
||||
useRedis = false;
|
||||
}
|
||||
}
|
||||
|
||||
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!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import net.momirealms.customcrops.datamanager.*;
|
||||
import net.momirealms.customcrops.datamanager.CropManager;
|
||||
import net.momirealms.customcrops.datamanager.SprinklerManager;
|
||||
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.itemframe.BreakBlockI;
|
||||
import net.momirealms.customcrops.listener.itemframe.BreakFurnitureI;
|
||||
@@ -73,33 +73,31 @@ public final class CustomCrops extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
|
||||
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();
|
||||
if (!Objects.equals(ConfigReader.Config.version, "3")){
|
||||
if (!Objects.equals(ConfigReader.Config.version, "5")){
|
||||
ConfigUtil.update();
|
||||
}
|
||||
|
||||
if(Bukkit.getPluginManager().getPlugin("PlaceHolderAPI") != null){
|
||||
placeholders = new Placeholders();
|
||||
placeholders.register();
|
||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><gold>PlaceHolderAPI <color:#FFEBCD>Hooked!");
|
||||
Bukkit.getPluginManager().registerEvents(new PapiReload(), this);
|
||||
}
|
||||
|
||||
Objects.requireNonNull(Bukkit.getPluginCommand("customcrops")).setExecutor(new Executor(this));
|
||||
Objects.requireNonNull(Bukkit.getPluginCommand("customcrops")).setTabCompleter(new Completer());
|
||||
|
||||
//公用事件
|
||||
Bukkit.getPluginManager().registerEvents(new ItemSpawn(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new JoinAndQuit(), this);
|
||||
|
||||
ConfigReader.tryEnableJedis();
|
||||
|
||||
if (ConfigReader.Season.enable){
|
||||
this.seasonManager = new SeasonManager();
|
||||
this.seasonManager.loadData();
|
||||
}
|
||||
|
||||
this.sprinklerManager = new SprinklerManager();
|
||||
this.sprinklerManager.loadData();
|
||||
this.potManager = new PotManager();
|
||||
@@ -107,14 +105,14 @@ public final class CustomCrops extends JavaPlugin {
|
||||
this.cropTimer = new CropTimer();
|
||||
if (ConfigReader.Config.cropMode.equalsIgnoreCase("item_frame")){
|
||||
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 BreakBlockI(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new BreakFurnitureI(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new InteractFurnitureI(), this);
|
||||
}else{
|
||||
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 BreakBlockT(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new BreakFurnitureT(), this);
|
||||
|
||||
@@ -816,7 +816,7 @@ public class CropManager{
|
||||
}
|
||||
|
||||
private HashSet<String> getPlayers(){
|
||||
if (JedisUtil.useRedis){
|
||||
if (ConfigReader.useRedis){
|
||||
return JedisUtil.getPlayers();
|
||||
}else {
|
||||
return new HashSet<>(JoinAndQuit.onlinePlayers);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
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.ConfigReader;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
|
||||
@@ -338,7 +338,7 @@ public class SprinklerManager {
|
||||
}
|
||||
|
||||
private HashSet<String> getPlayers(){
|
||||
if (JedisUtil.useRedis){
|
||||
if (ConfigReader.useRedis){
|
||||
return JedisUtil.getPlayers();
|
||||
}else {
|
||||
return new HashSet<>(JoinAndQuit.onlinePlayers);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* 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 net.momirealms.customcrops.ConfigReader;
|
||||
@@ -15,7 +15,7 @@
|
||||
* 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 org.bukkit.World;
|
||||
@@ -1,9 +1,28 @@
|
||||
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 java.util.List;
|
||||
|
||||
public class JobsReborn implements SkillXP{
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.momirealms.customcrops.listener;
|
||||
|
||||
import net.momirealms.customcrops.ConfigReader;
|
||||
import net.momirealms.customcrops.utils.JedisUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -17,13 +18,13 @@ public class JoinAndQuit implements Listener {
|
||||
|
||||
@EventHandler
|
||||
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());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
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());
|
||||
coolDown.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import java.util.List;
|
||||
public class JedisUtil {
|
||||
|
||||
private static JedisPool jedisPool;
|
||||
public static boolean useRedis;
|
||||
|
||||
public static Jedis getJedis(){
|
||||
return jedisPool.getResource();
|
||||
|
||||
Reference in New Issue
Block a user