mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2026-01-04 15:41:46 +00:00
improve interactions
This commit is contained in:
@@ -8,7 +8,7 @@ plugins {
|
|||||||
allprojects {
|
allprojects {
|
||||||
|
|
||||||
project.group = "net.momirealms"
|
project.group = "net.momirealms"
|
||||||
project.version = "3.4.0.1"
|
project.version = "3.4.0.2"
|
||||||
|
|
||||||
apply<JavaPlugin>()
|
apply<JavaPlugin>()
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
|
|||||||
@@ -1206,14 +1206,17 @@ public class ItemManagerImpl implements ItemManager {
|
|||||||
Optional<WorldSprinkler> optionalSprinkler = plugin.getWorldManager().getSprinklerAt(simpleLocation);
|
Optional<WorldSprinkler> optionalSprinkler = plugin.getWorldManager().getSprinklerAt(simpleLocation);
|
||||||
if (optionalSprinkler.isEmpty()) {
|
if (optionalSprinkler.isEmpty()) {
|
||||||
plugin.debug("Found a sprinkler without data interacted by " + player.getName() + " at " + location);
|
plugin.debug("Found a sprinkler without data interacted by " + player.getName() + " at " + location);
|
||||||
plugin.getWorldManager().addSprinklerAt(new MemorySprinkler(simpleLocation, sprinkler.getKey(), 0), simpleLocation);
|
WorldSprinkler newSprinkler = new MemorySprinkler(simpleLocation, sprinkler.getKey(), 0);
|
||||||
return FunctionResult.RETURN;
|
plugin.getWorldManager().addSprinklerAt(newSprinkler, simpleLocation);
|
||||||
}
|
optionalSprinkler = Optional.of(newSprinkler);
|
||||||
if (!optionalSprinkler.get().getKey().equals(sprinkler.getKey())) {
|
} else {
|
||||||
LogUtils.warn("Found a sprinkler having inconsistent data interacted by " + player.getName() + " at " + location + ".");
|
if (!optionalSprinkler.get().getKey().equals(sprinkler.getKey())) {
|
||||||
plugin.getWorldManager().addSprinklerAt(new MemorySprinkler(simpleLocation, sprinkler.getKey(), 0), simpleLocation);
|
LogUtils.warn("Found a sprinkler having inconsistent data interacted by " + player.getName() + " at " + location + ".");
|
||||||
return FunctionResult.RETURN;
|
plugin.getWorldManager().addSprinklerAt(new MemorySprinkler(simpleLocation, sprinkler.getKey(), 0), simpleLocation);
|
||||||
|
return FunctionResult.RETURN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fire the event
|
// fire the event
|
||||||
SprinklerInteractEvent interactEvent = new SprinklerInteractEvent(player, itemInHand, location, optionalSprinkler.get());
|
SprinklerInteractEvent interactEvent = new SprinklerInteractEvent(player, itemInHand, location, optionalSprinkler.get());
|
||||||
if (EventUtils.fireAndCheckCancel(interactEvent)) {
|
if (EventUtils.fireAndCheckCancel(interactEvent)) {
|
||||||
@@ -1703,7 +1706,9 @@ public class ItemManagerImpl implements ItemManager {
|
|||||||
Optional<WorldCrop> optionalCrop = plugin.getWorldManager().getCropAt(simpleLocation);
|
Optional<WorldCrop> optionalCrop = plugin.getWorldManager().getCropAt(simpleLocation);
|
||||||
if (optionalCrop.isEmpty()) {
|
if (optionalCrop.isEmpty()) {
|
||||||
plugin.debug("Found a crop without data interacted by " + player.getName() + " at " + cropLocation);
|
plugin.debug("Found a crop without data interacted by " + player.getName() + " at " + cropLocation);
|
||||||
plugin.getWorldManager().addCropAt(new MemoryCrop(simpleLocation, crop.getKey(), stage.getPoint()), simpleLocation);
|
WorldCrop newCrop = new MemoryCrop(simpleLocation, crop.getKey(), stage.getPoint());
|
||||||
|
plugin.getWorldManager().addCropAt(newCrop, simpleLocation);
|
||||||
|
optionalCrop = Optional.of(newCrop);
|
||||||
} else {
|
} else {
|
||||||
if (!optionalCrop.get().getKey().equals(crop.getKey())) {
|
if (!optionalCrop.get().getKey().equals(crop.getKey())) {
|
||||||
LogUtils.warn("Found a crop having inconsistent data interacted by " + player.getName() + " at " + cropLocation + ".");
|
LogUtils.warn("Found a crop having inconsistent data interacted by " + player.getName() + " at " + cropLocation + ".");
|
||||||
@@ -1878,14 +1883,17 @@ public class ItemManagerImpl implements ItemManager {
|
|||||||
Optional<WorldPot> optionalPot = plugin.getWorldManager().getPotAt(simpleLocation);
|
Optional<WorldPot> optionalPot = plugin.getWorldManager().getPotAt(simpleLocation);
|
||||||
if (optionalPot.isEmpty()) {
|
if (optionalPot.isEmpty()) {
|
||||||
plugin.debug("Found a pot without data interacted by " + player.getName() + " at " + location);
|
plugin.debug("Found a pot without data interacted by " + player.getName() + " at " + location);
|
||||||
plugin.getWorldManager().addPotAt(new MemoryPot(simpleLocation, pot.getKey()), simpleLocation);
|
WorldPot newPot = new MemoryPot(simpleLocation, pot.getKey());
|
||||||
return FunctionResult.RETURN;
|
plugin.getWorldManager().addPotAt(newPot, simpleLocation);
|
||||||
}
|
optionalPot = Optional.of(newPot);
|
||||||
if (!optionalPot.get().getKey().equals(pot.getKey())) {
|
} else {
|
||||||
LogUtils.warn("Found a pot having inconsistent data interacted by " + player.getName() + " at " + location + ".");
|
if (!optionalPot.get().getKey().equals(pot.getKey())) {
|
||||||
plugin.getWorldManager().addPotAt(new MemoryPot(simpleLocation, pot.getKey()), simpleLocation);
|
LogUtils.warn("Found a pot having inconsistent data interacted by " + player.getName() + " at " + location + ".");
|
||||||
return FunctionResult.RETURN;
|
plugin.getWorldManager().addPotAt(new MemoryPot(simpleLocation, pot.getKey()), simpleLocation);
|
||||||
|
return FunctionResult.RETURN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fire the event
|
// fire the event
|
||||||
PotInteractEvent interactEvent = new PotInteractEvent(player, itemInHand, location, optionalPot.get());
|
PotInteractEvent interactEvent = new PotInteractEvent(player, itemInHand, location, optionalPot.get());
|
||||||
if (EventUtils.fireAndCheckCancel(interactEvent)) {
|
if (EventUtils.fireAndCheckCancel(interactEvent)) {
|
||||||
|
|||||||
@@ -126,6 +126,17 @@ public abstract class AbstractCustomListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler (ignoreCancelled = true)
|
||||||
|
public void onBlockChange(BlockFadeEvent event) {
|
||||||
|
Block block = event.getBlock();
|
||||||
|
if (block.getType() == Material.FARMLAND) {
|
||||||
|
SimpleLocation above = SimpleLocation.of(block.getLocation()).add(0,1,0);
|
||||||
|
if (CustomCropsPlugin.get().getWorldManager().getBlockAt(above).isPresent()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler (ignoreCancelled = true)
|
@EventHandler (ignoreCancelled = true)
|
||||||
public void onTrampling(EntityChangeBlockEvent event) {
|
public void onTrampling(EntityChangeBlockEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
|||||||
Reference in New Issue
Block a user