9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-22 16:39:36 +00:00
This commit is contained in:
Xiao-MoMi
2022-06-14 02:06:42 +08:00
parent a7ada230cd
commit a1f53c4ad7
9 changed files with 52 additions and 65 deletions

43
pom.xml
View File

@@ -12,7 +12,7 @@
<name>CustomCrops</name>
<properties>
<java.version>1.16</java.version>
<java.version>16</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@@ -48,32 +48,22 @@
</repositories>
<dependencies>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.8.0</version>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.LoneDev6</groupId>
<artifactId>api-itemsadder</artifactId>
<version>3.1.0b</version>
<version>3.1.6</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -87,25 +77,20 @@
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<relocations>
<relocation>
<pattern>de.themoep.minedown</pattern>
<shadedPattern>net.momirealms.customcrops.Libs.minedown</shadedPattern>
</relocation>
</relocations>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>

View File

@@ -67,9 +67,9 @@ public final class CustomCrops extends JavaPlugin {
//检测papi依赖
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null){
new Placeholders(this).register();
MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] 检测到PlaceHolderAPI 已启用季节变量!",Bukkit.getConsoleSender());
MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &f检测到PlaceHolderAPI 已启用季节变量!",Bukkit.getConsoleSender());
}
MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] 自定义农作物插件已启用!作者:小默米 QQ:3266959688",Bukkit.getConsoleSender());
MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &f自定义农作物插件已启用!作者:小默米 QQ:3266959688",Bukkit.getConsoleSender());
}
@Override
@@ -85,6 +85,6 @@ public final class CustomCrops extends JavaPlugin {
//备份
BackUp.backUpData();
MessageManager.consoleMessage(("&#ccfbff-#ef96c5&[CustomCrops] 自定义农作物插件已卸载!作者:小默米 QQ:3266959688"),Bukkit.getConsoleSender());
MessageManager.consoleMessage(("&#ccfbff-#ef96c5&[CustomCrops] &f自定义农作物插件已卸载!作者:小默米 QQ:3266959688"),Bukkit.getConsoleSender());
}
}

View File

@@ -18,7 +18,6 @@ import javax.annotation.ParametersAreNonnullByDefault;
public class CommandHandler implements CommandExecutor {
@Override
@ParametersAreNonnullByDefault
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

View File

@@ -1,18 +1,17 @@
package net.momirealms.customcrops.commands;
import net.momirealms.customcrops.datamanager.ConfigManager;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.jetbrains.annotations.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class CommandTabComplete implements TabCompleter {
@Override
@ParametersAreNonnullByDefault
public @Nullable List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {

View File

@@ -1,8 +1,10 @@
package net.momirealms.customcrops.datamanager;
import dev.lone.itemsadder.api.CustomBlock;
import net.momirealms.customcrops.CustomCrops;
import net.momirealms.customcrops.utils.Crop;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -169,18 +171,33 @@ public class ConfigManager {
}else {
crop.setWillReturn(false);
}
if(cropConfig.getConfigurationSection("crops."+key).contains("season")){
crop.setSeasons(StringUtils.split( cropConfig.getString("crops."+key+".season"), ","));
if(Config.season){
if(cropConfig.getConfigurationSection("crops."+key).contains("season")){
crop.setSeasons(StringUtils.split( cropConfig.getString("crops."+key+".season"), ","));
}else {
MessageManager.consoleMessage("&c[CustomCrops] 错误!在启用季节模式的情况下未设置农作物 &f"+ key +" &c的生长季节!", Bukkit.getConsoleSender());
return;
}
}
if(cropConfig.getConfigurationSection("crops."+key).contains("gigantic")){
crop.setWillGiant(true);
crop.setGiant(cropConfig.getString("crops."+key+".gigantic"));
crop.setGiantChance(cropConfig.getDouble("crops."+key+".gigantic-chance"));
if(cropConfig.getConfigurationSection("crops."+key).contains("gigantic-chance")){
crop.setGiantChance(cropConfig.getDouble("crops."+key+".gigantic-chance"));
}else {
MessageManager.consoleMessage("&c[CustomCrops] 错误!未设置农作物 &f"+ key +" &c的巨大化概率!", Bukkit.getConsoleSender());
return;
}
}else {
crop.setWillGiant(false);
}
CONFIG.put(key, crop);
});
if(keys.size() == CONFIG.size()){
MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &f成功载入 &a" + CONFIG.size() + " &f种农作物", Bukkit.getConsoleSender());
}else {
MessageManager.consoleMessage("&c[CustomCrops] crops.yml配置存在错误请根据上述提示仔细检查!", Bukkit.getConsoleSender());
}
}
catch (Exception e) {
e.printStackTrace();

View File

@@ -11,7 +11,6 @@ import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.scheduler.BukkitScheduler;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;

View File

@@ -10,24 +10,13 @@ public class NextSeason {
public static void changeSeason(){
FileConfiguration config = CustomCrops.instance.getConfig();
String currentSeason = ConfigManager.Config.current;
String nextSeason;
switch (Objects.requireNonNull(currentSeason)) {
case "spring":
nextSeason = "summer";
break;
case "summer":
nextSeason = "autumn";
break;
case "autumn":
nextSeason = "winter";
break;
case "winter":
nextSeason = "spring";
break;
default:
nextSeason = null;
break;
}
String nextSeason = switch (Objects.requireNonNull(currentSeason)) {
case "spring" -> "summer";
case "summer" -> "autumn";
case "autumn" -> "winter";
case "winter" -> "spring";
default -> null;
};
if(nextSeason != null){
config.set("current-season", nextSeason);
ConfigManager.Config.current = nextSeason;

View File

@@ -1,17 +1,14 @@
package net.momirealms.customcrops.utils;
import dev.lone.itemsadder.api.CustomFurniture;
import net.momirealms.customcrops.CustomCrops;
import net.momirealms.customcrops.datamanager.ConfigManager;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
public class IAFurniture {
static FileConfiguration config = CustomCrops.instance.getConfig();
//放置IA自定义家具
public static void placeFurniture(String name, Location location){
CustomFurniture.spawn(name,location.getWorld().getBlockAt(location));
@@ -22,7 +19,7 @@ public class IAFurniture {
for(Entity entity : world.getNearbyEntities(location,0,0,0)){
if(entity instanceof ArmorStand){
if(CustomFurniture.byAlreadySpawned((ArmorStand) entity) != null){
if(CustomFurniture.byAlreadySpawned((ArmorStand) entity).getNamespacedID().equalsIgnoreCase(config.getString("config.sprinkler-1")) || CustomFurniture.byAlreadySpawned((ArmorStand) entity).getNamespacedID().equalsIgnoreCase(config.getString("config.sprinkler-2"))){
if(CustomFurniture.byAlreadySpawned((ArmorStand) entity).getNamespacedID().equalsIgnoreCase(ConfigManager.Config.sprinkler_1) || CustomFurniture.byAlreadySpawned((ArmorStand) entity).getNamespacedID().equalsIgnoreCase(ConfigManager.Config.sprinkler_2)){
return true;
}
}

View File

@@ -1,9 +1,11 @@
name: CustomCrops
version: '1.4.3'
version: '1.4.4'
main: net.momirealms.customcrops.CustomCrops
api-version: 1.16
depend: [ ItemsAdder ]
softdepend: [ PlaceholderAPI ]
depend:
- ItemsAdder
softdepend:
- PlaceholderAPI
authors: [ XiaoMoMi ]
commands:
customcrops: