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-05-26 00:30:42 +08:00
parent 0b2049290d
commit e788d12afd
4 changed files with 15 additions and 7 deletions

View File

@@ -54,6 +54,7 @@ public final class CustomCrops extends JavaPlugin {
List<WrappedChatComponent> components = packet.getChatComponents().getValues();
for (WrappedChatComponent component : components) {
if(component.toString().contains("Ender Chest")){
//component.setJson("{\"text\":\"收纳袋\"}");
component.setJson("{\"translate\":\"container.enderchest\"}");
packet.getChatComponents().write(components.indexOf(component), component);
}

View File

@@ -10,6 +10,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
public class BackUp {
public static void backUpData(){
Date date = new Date();
@@ -22,13 +23,11 @@ public class BackUp {
try {
BackUp.backUp(crop_data,cropBackUp);
} catch (IOException e) {
e.printStackTrace();
}
try {
BackUp.backUp(sprinkler_data,sprinklerBackUp);
} catch (IOException e) {
e.printStackTrace();
}

View File

@@ -3,13 +3,15 @@ package net.momirealms.customcrops.DataManager;
import dev.lone.itemsadder.api.CustomBlock;
import net.momirealms.customcrops.CustomCrops;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
public class MaxCropsPerChunk {
static FileConfiguration config = CustomCrops.instance.getConfig();
public static boolean maxCropsPerChunk(Location location){
FileConfiguration config = CustomCrops.instance.getConfig();
if(!config.getBoolean("config.enable-limit")){
return false;
}
@@ -24,10 +26,10 @@ public class MaxCropsPerChunk {
Label_out:
for (int i = 0; i < 16; ++i) {
for (int j = 0; j < 16; ++j) {
final Location square = chunkLocation.clone().add((double)i, 0.0, (double)j);
Location square = chunkLocation.clone().add(i, 0.0, j);
for (int k = minY; k <= maxY; ++k) {
square.add(0.0, 1.0, 0.0);
Blcok b = location.getWorld().getBlcokAt(square);
Block b = location.getWorld().getBlockAt(square);
if(CustomBlock.byAlreadyPlaced(b)!= null){
if (CustomBlock.byAlreadyPlaced(b).getNamespacedID().contains("stage")) {
if (n++ > maxAmount) {

View File

@@ -7,8 +7,11 @@ import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
public class MaxSprinklersPerChunk {
static FileConfiguration config = CustomCrops.instance.getConfig();
public static boolean maxSprinklersPerChunk(Location location){
FileConfiguration config = CustomCrops.instance.getConfig();
if(!config.getBoolean("config.enable-limit")){
return false;
}
@@ -24,7 +27,7 @@ public class MaxSprinklersPerChunk {
Label_out:
for (int i = 0; i < 16; ++i) {
for (int j = 0; j < 16; ++j) {
final Location square = chunkLocation.clone().add((double)(i+0.5), 0.5, (double)(j+0.5));
Location square = chunkLocation.clone().add(i+0.5, 0.5, j+0.5);
for (int k = minY; k <= maxY; ++k) {
square.add(0.0, 1.0, 0.0);
if(IAFurniture.getFromLocation(square, world)){
@@ -37,4 +40,7 @@ public class MaxSprinklersPerChunk {
}
return n > maxAmount;
}
public static boolean alreadyPlaced(Location location){
return IAFurniture.getFromLocation(location.clone().add(0.5, 1.5, 0.5), location.getWorld());
}
}