9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-22 08:29:35 +00:00
This commit is contained in:
XiaoMoMi
2024-03-10 08:45:34 +08:00
parent 1b05db11c9
commit d18ab3ef49
13 changed files with 31 additions and 13 deletions

View File

@@ -25,7 +25,7 @@ public record WaterBar(String left, String empty, String full, String right) {
public String getWaterBar(int current, int max) {
return left +
String.valueOf(full).repeat(current) +
String.valueOf(full).repeat(Math.min(current, max)) +
String.valueOf(empty).repeat(Math.max(max - current, 0)) +
right;
}

View File

@@ -43,6 +43,7 @@ public class State {
setArg("{x}", String.valueOf(location.getBlockX()));
setArg("{y}", String.valueOf(location.getBlockY()));
setArg("{z}", String.valueOf(location.getBlockZ()));
setArg("{world}", location.getWorld().getName());
}
public Player getPlayer() {

View File

@@ -8,7 +8,7 @@ plugins {
allprojects {
project.group = "net.momirealms"
project.version = "3.4.0.0"
project.version = "3.4.0.1"
apply<JavaPlugin>()
apply(plugin = "java")

View File

@@ -69,7 +69,7 @@ public interface CustomProvider {
default void removeAnythingAt(Location location) {
if (!removeBlock(location)) {
Collection<Entity> entities = location.getWorld().getNearbyEntities(location.toCenterLocation(), 0.5,0.5,0.5);
Collection<Entity> entities = location.getWorld().getNearbyEntities(location.toCenterLocation(), 0.5,0.51,0.5);
entities.removeIf(entity -> {
EntityType type = entity.getType();
return type != EntityType.ITEM_FRAME

View File

@@ -2009,11 +2009,11 @@ public class ItemManagerImpl implements ItemManager {
SimpleLocation simpleLocation = SimpleLocation.of(location);
Optional<WorldPot> optionalPot = plugin.getWorldManager().getPotAt(simpleLocation);
if (optionalPot.isEmpty()) {
LogUtils.warn("Found a pot without data broken by " + state.getPlayer().getName() + " at " + simpleLocation);
plugin.debug("Found a pot without data broken by " + state.getPlayer().getName() + " at " + simpleLocation);
return FunctionResult.RETURN;
}
if (!optionalPot.get().getKey().equals(pot.getKey())) {
LogUtils.warn("Found a pot having inconsistent data broken by " + state.getPlayer().getName() + " at " + simpleLocation + ".");
plugin.debug("Found a pot having inconsistent data broken by " + state.getPlayer().getName() + " at " + simpleLocation + ".");
plugin.getWorldManager().removePotAt(simpleLocation);
return FunctionResult.RETURN;
}

View File

@@ -32,6 +32,7 @@ import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.*;
import org.bukkit.event.entity.EntityChangeBlockEvent;
@@ -79,7 +80,7 @@ public abstract class AbstractCustomListener implements Listener {
);
}
@EventHandler (ignoreCancelled = true)
@EventHandler (ignoreCancelled = true, priority = EventPriority.LOW)
public void onBreakBlock(BlockBreakEvent event) {
Player player = event.getPlayer();
this.itemManager.handlePlayerBreakBlock(

View File

@@ -66,7 +66,7 @@ public class OraxenListener extends AbstractCustomListener {
public void onBreakFurniture(OraxenFurnitureBreakEvent event) {
super.onBreakFurniture(
event.getPlayer(),
event.getBlock().getLocation(),
event.getBaseEntity().getLocation().toBlockLocation(),
event.getMechanic().getItemID(),
event
);
@@ -76,7 +76,7 @@ public class OraxenListener extends AbstractCustomListener {
public void onInteractFurniture(OraxenFurnitureInteractEvent event) {
super.onInteractFurniture(
event.getPlayer(),
event.getBlock().getLocation(),
event.getBaseEntity().getLocation().toBlockLocation(),
event.getMechanic().getItemID(),
event.getBaseEntity(),
event

View File

@@ -21,8 +21,10 @@ import io.th0rgal.oraxen.api.OraxenBlocks;
import io.th0rgal.oraxen.api.OraxenFurniture;
import io.th0rgal.oraxen.api.OraxenItems;
import io.th0rgal.oraxen.items.ItemBuilder;
import io.th0rgal.oraxen.mechanics.Mechanic;
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanic;
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanic;
import net.momirealms.customcrops.mechanic.item.CustomProvider;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -65,7 +67,7 @@ public class OraxenProvider implements CustomProvider {
@Override
public String getBlockID(Block block) {
NoteBlockMechanic mechanic = OraxenBlocks.getNoteBlockMechanic(block);
Mechanic mechanic = OraxenBlocks.getOraxenBlock(block.getLocation());
if (mechanic == null) {
return block.getType().name();
}

View File

@@ -68,6 +68,11 @@ public class MemoryCrop extends AbstractCustomCropsBlock implements WorldCrop {
@Override
public void setPoint(int point) {
if (point < 0) return;
int max = getConfig().getMaxPoints();
if (point > max) {
point = max;
}
setData("point", new IntTag("point", point));
}

View File

@@ -74,6 +74,11 @@ public class MemoryPot extends AbstractCustomCropsBlock implements WorldPot {
@Override
public void setWater(int water) {
if (water < 0) return;
int max = getConfig().getStorage();
if (water > max) {
water = max;
}
setData("water", new IntTag("water", water));
}

View File

@@ -58,6 +58,11 @@ public class MemorySprinkler extends AbstractCustomCropsBlock implements WorldSp
@Override
public void setWater(int water) {
if (water < 0) return;
int max = getConfig().getStorage();
if (water > max) {
water = max;
}
setData("water", new IntTag("water", water));
}

View File

@@ -20,9 +20,9 @@ tomato:
- Spring
- Autumn
not-met-actions:
message_action:
actionbar_action:
type: message
value: "It's not a good season to plant tomato"
value: '<red><bold>[X] It''s not a good season to plant tomato'
# Event settings
events:
plant:

View File

@@ -22,5 +22,4 @@ softdepend:
- EcoSkills
- Jobs
- RealisticSeasons
- AdvancedSeasons
- SlimeWorldManager
- AdvancedSeasons