mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-23 00:49:33 +00:00
1.5.1
This commit is contained in:
@@ -348,7 +348,6 @@ public class ConfigReader {
|
|||||||
forceSave = config.getString("messages.force-save");
|
forceSave = config.getString("messages.force-save");
|
||||||
beforePlant = config.getString("messages.before-plant");
|
beforePlant = config.getString("messages.before-plant");
|
||||||
|
|
||||||
|
|
||||||
hasCropInfo = config.getBoolean("hologram.grow-info.enable");
|
hasCropInfo = config.getBoolean("hologram.grow-info.enable");
|
||||||
if (hasCropInfo){
|
if (hasCropInfo){
|
||||||
cropTime = config.getInt("hologram.grow-info.duration");
|
cropTime = config.getInt("hologram.grow-info.duration");
|
||||||
|
|||||||
@@ -120,8 +120,9 @@ public class Executor implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "test" -> {
|
case "cleandata" -> {
|
||||||
plugin.getCropManager().testData();
|
plugin.getCropManager().cleanData();
|
||||||
|
plugin.getSprinklerManager().cleanData();
|
||||||
}
|
}
|
||||||
case "setseason" -> {
|
case "setseason" -> {
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
|
|||||||
@@ -50,15 +50,6 @@ public class CropManager {
|
|||||||
this.data = YamlConfiguration.loadConfiguration(file);
|
this.data = YamlConfiguration.loadConfiguration(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testData(){
|
|
||||||
for (int i = -200; i <= 200; i++){
|
|
||||||
for (int j = -200; j <= 200; j++){
|
|
||||||
Location location = new Location(Bukkit.getWorld("world"), i, 91,j);
|
|
||||||
Cache.put(location, "tomato");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//保存数据
|
//保存数据
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
File file = new File(CustomCrops.instance.getDataFolder(), "data" + File.separator + "crop.yml");
|
File file = new File(CustomCrops.instance.getDataFolder(), "data" + File.separator + "crop.yml");
|
||||||
@@ -80,6 +71,17 @@ public class CropManager {
|
|||||||
Cache.clear();
|
Cache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//隐藏指令,清除无用数据
|
||||||
|
public void cleanData(){
|
||||||
|
data.getKeys(false).forEach(world -> {
|
||||||
|
data.getConfigurationSection(world).getKeys(false).forEach(chunk ->{
|
||||||
|
if (data.getConfigurationSection(world + "." + chunk).getKeys(false).size() == 0){
|
||||||
|
data.set(world + "." + chunk, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//农作物生长
|
//农作物生长
|
||||||
public void cropGrow(String worldName){
|
public void cropGrow(String worldName){
|
||||||
Long time1 = System.currentTimeMillis();
|
Long time1 = System.currentTimeMillis();
|
||||||
|
|||||||
@@ -51,6 +51,16 @@ public class SprinklerManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cleanData(){
|
||||||
|
data.getKeys(false).forEach(world -> {
|
||||||
|
data.getConfigurationSection(world).getKeys(false).forEach(chunk ->{
|
||||||
|
if (data.getConfigurationSection(world + "." + chunk).getKeys(false).size() == 0){
|
||||||
|
data.set(world + "." + chunk, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void updateData(){
|
public void updateData(){
|
||||||
Cache.forEach((location, sprinklerData) -> {
|
Cache.forEach((location, sprinklerData) -> {
|
||||||
String world = location.getWorld().getName();
|
String world = location.getWorld().getName();
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ public class RightClick implements Listener {
|
|||||||
Action action = event.getAction();
|
Action action = event.getAction();
|
||||||
if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK){
|
if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK){
|
||||||
ItemStack itemStack = event.getItem();
|
ItemStack itemStack = event.getItem();
|
||||||
if (itemStack == null && action == Action.RIGHT_CLICK_BLOCK){
|
if (itemStack == null){
|
||||||
|
if (action != Action.RIGHT_CLICK_BLOCK) return;
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
Location location = block.getLocation();
|
Location location = block.getLocation();
|
||||||
CustomBlock customBlock = CustomBlock.byAlreadyPlaced(block);
|
CustomBlock customBlock = CustomBlock.byAlreadyPlaced(block);
|
||||||
@@ -108,8 +109,7 @@ public class RightClick implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
}else {
|
||||||
}
|
|
||||||
NBTItem nbtItem = new NBTItem(itemStack);
|
NBTItem nbtItem = new NBTItem(itemStack);
|
||||||
NBTCompound nbtCompound = nbtItem.getCompound("itemsadder");
|
NBTCompound nbtCompound = nbtItem.getCompound("itemsadder");
|
||||||
if (nbtCompound != null){
|
if (nbtCompound != null){
|
||||||
@@ -313,6 +313,7 @@ public class RightClick implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuit(PlayerQuitEvent event){
|
public void onQuit(PlayerQuitEvent event){
|
||||||
|
|||||||
@@ -15,12 +15,14 @@ config:
|
|||||||
|
|
||||||
#生长时间点(tick)
|
#生长时间点(tick)
|
||||||
#洒水器将会在农作物全部完成生长后开始工作
|
#洒水器将会在农作物全部完成生长后开始工作
|
||||||
|
#1000代表上午7点,农作物陆续开始生长
|
||||||
grow-time:
|
grow-time:
|
||||||
- 1000
|
- 1000
|
||||||
|
|
||||||
#生长的时间(秒)
|
#生长的时间(秒)
|
||||||
#农作物将在90秒内随机完成生长以避免在短时间内大量方块替换造成卡顿
|
#农作物将在90秒内随机完成生长以避免在短时间内大量方块替换造成卡顿
|
||||||
#但也不建议设置过长时间,否则内存无法及时释放,区块会被持续加载
|
#但也不建议设置过长时间,否则内存无法及时释放,区块会被持续加载
|
||||||
|
#配合上方的默认时间点,意思为每天上午7点后,农作物将在90秒内完成生长过程
|
||||||
time-to-grow: 90
|
time-to-grow: 90
|
||||||
|
|
||||||
#产物品质
|
#产物品质
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: CustomCrops
|
name: CustomCrops
|
||||||
version: '1.5.0-SNAPSHOT'
|
version: '1.5.1'
|
||||||
main: net.momirealms.customcrops.CustomCrops
|
main: net.momirealms.customcrops.CustomCrops
|
||||||
api-version: 1.16
|
api-version: 1.16
|
||||||
depend:
|
depend:
|
||||||
|
|||||||
Reference in New Issue
Block a user