9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-26 18:39:17 +00:00
This commit is contained in:
Xiao-MoMi
2023-04-22 19:57:26 +08:00
parent a324df1576
commit 6346820fff
7 changed files with 21 additions and 12 deletions

View File

@@ -196,6 +196,10 @@ public class PlatformManager extends Function {
void onInteractSomething(Player player, Location location, String id, @Nullable BlockFace blockFace, Cancellable event) {
if (!plugin.getWorldDataManager().isWorldAllowed(location.getWorld())) {
return;
}
ItemStack item_in_hand = player.getInventory().getItemInMainHand();
String item_in_hand_id = plugin.getPlatformInterface().getItemStackID(item_in_hand);

View File

@@ -33,8 +33,7 @@ public enum CCSeason {
this.display = display;
}
@Override
public String toString() {
public String getDisplay() {
return display;
}
}

View File

@@ -54,9 +54,10 @@ public class SeasonManager extends Function {
}
public CCSeason getSeason(String world) {
if (ConfigManager.syncSeason) world = ConfigManager.referenceWorld;
SeasonData seasonData = seasonMap.get(world);
if (seasonData == null) return CCSeason.UNKNOWN;
SeasonData seasonData = seasonMap.get(ConfigManager.syncSeason ? ConfigManager.referenceWorld : world);
if (seasonData == null) {
return CCSeason.UNKNOWN;
}
return seasonData.getSeason();
}
@@ -66,7 +67,7 @@ public class SeasonManager extends Function {
}
public int getDate(String world) {
SeasonData seasonData = seasonMap.get(world);
SeasonData seasonData = seasonMap.get(ConfigManager.syncSeason ? ConfigManager.referenceWorld : world);
if (seasonData == null) return -1;
return seasonData.getDate();
}

View File

@@ -116,8 +116,13 @@ public class CCWorld extends Function {
e.printStackTrace();
}
}
YamlConfiguration dataFile = ConfigUtils.readData(new File(CustomCrops.getInstance().getDataFolder().getParentFile().getParentFile(), ConfigManager.worldFolderPath + worldName + File.separator + "customcrops" + File.separator + "data.yml"));
if (ConfigManager.enableSeason && !ConfigManager.rsHook) {
YamlConfiguration dataFile;
if (ConfigManager.worldFolderPath.equals("")) {
dataFile = ConfigUtils.readData(new File(CustomCrops.getInstance().getDataFolder().getParentFile().getParentFile(), worldName + File.separator + "customcrops" + File.separator + "data.yml"));
} else {
dataFile = ConfigUtils.readData(new File(ConfigManager.worldFolderPath + worldName + File.separator + "customcrops" + File.separator + "data.yml"));
}
if (ConfigManager.enableSeason) {
SeasonData seasonData;
if (dataFile.contains("season") && dataFile.contains("date")) {
seasonData = new SeasonData(worldName, CCSeason.valueOf(dataFile.getString("season")), dataFile.getInt("date"));

View File

@@ -56,7 +56,7 @@ public class SetSeasonCommand extends AbstractSubCommand {
}
seasonData.changeSeason(ccSeason);
CustomCrops.getInstance().getSeasonManager().loadSeasonData(seasonData);
AdventureUtils.sendMessage(sender, MessageManager.prefix + MessageManager.setSeason.replace("{world}", args.get(0)).replace("{season}", ccSeason.toString()));
AdventureUtils.sendMessage(sender, MessageManager.prefix + MessageManager.setSeason.replace("{world}", args.get(0)).replace("{season}", ccSeason.getDisplay()));
return true;
} catch (IllegalArgumentException e) {
AdventureUtils.sendMessage(sender, MessageManager.prefix + MessageManager.seasonNotExist.replace("{season}", args.get(1)));

View File

@@ -61,7 +61,7 @@ public class SeasonPapi extends PlaceholderExpansion {
case "season" -> {
Player online_player = player.getPlayer();
if (online_player == null) return null;
return plugin.getIntegrationManager().getSeasonInterface().getSeason(player.getPlayer().getWorld().getName()).toString();
return plugin.getIntegrationManager().getSeasonInterface().getSeason(player.getPlayer().getWorld().getName()).getDisplay();
}
case "date" -> {
Player online_player = player.getPlayer();
@@ -73,7 +73,7 @@ public class SeasonPapi extends PlaceholderExpansion {
case 2 -> {
switch (split[0]) {
case "season" -> {
return plugin.getIntegrationManager().getSeasonInterface().getSeason(split[1]).toString();
return plugin.getIntegrationManager().getSeasonInterface().getSeason(split[1]).getDisplay();
}
case "date" -> {
return String.valueOf(plugin.getIntegrationManager().getSeasonInterface().getDate(split[1]));