mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2026-01-04 15:41:46 +00:00
2.0.11
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'net.momirealms'
|
group = 'net.momirealms'
|
||||||
version = '2.0.10'
|
version = '2.0.11'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ public class ConfigUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void reloadConfigs() {
|
public static void reloadConfigs() {
|
||||||
|
|
||||||
MainConfig.load();
|
MainConfig.load();
|
||||||
BasicItemConfig.load();
|
BasicItemConfig.load();
|
||||||
CropConfig.load();
|
CropConfig.load();
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public interface AntiGrief {
|
|||||||
boolean canPlace(Location location, Player player);
|
boolean canPlace(Location location, Player player);
|
||||||
|
|
||||||
static boolean testBreak(Player player, Location location) {
|
static boolean testBreak(Player player, Location location) {
|
||||||
|
if (player.isOp()) return true;
|
||||||
for (AntiGrief antiGrief : MainConfig.antiGriefs) {
|
for (AntiGrief antiGrief : MainConfig.antiGriefs) {
|
||||||
if(!antiGrief.canBreak(location, player)) {
|
if(!antiGrief.canBreak(location, player)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -37,6 +38,7 @@ public interface AntiGrief {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean testPlace(Player player, Location location) {
|
static boolean testPlace(Player player, Location location) {
|
||||||
|
if (player.isOp()) return true;
|
||||||
for (AntiGrief antiGrief : MainConfig.antiGriefs) {
|
for (AntiGrief antiGrief : MainConfig.antiGriefs) {
|
||||||
if(!antiGrief.canPlace(location, player)) {
|
if(!antiGrief.canPlace(location, player)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -192,7 +192,6 @@ public abstract class HandlerP extends Function {
|
|||||||
player,
|
player,
|
||||||
location.add(0, MainConfig.sprinklerInfoY - 1,0),
|
location.add(0, MainConfig.sprinklerInfoY - 1,0),
|
||||||
MainConfig.sprinklerInfoDuration);
|
MainConfig.sprinklerInfoDuration);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean useSurveyor(Location potLoc, String id, Player player) {
|
public boolean useSurveyor(Location potLoc, String id, Player player) {
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import net.momirealms.customcrops.managers.CropManager;
|
|||||||
import net.momirealms.customcrops.objects.Sprinkler;
|
import net.momirealms.customcrops.objects.Sprinkler;
|
||||||
import net.momirealms.customcrops.utils.AdventureUtil;
|
import net.momirealms.customcrops.utils.AdventureUtil;
|
||||||
import net.momirealms.customcrops.utils.FurnitureUtil;
|
import net.momirealms.customcrops.utils.FurnitureUtil;
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|||||||
@@ -24,10 +24,7 @@ import dev.lone.itemsadder.api.Events.*;
|
|||||||
import net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import net.momirealms.customcrops.CustomCrops;
|
import net.momirealms.customcrops.CustomCrops;
|
||||||
import net.momirealms.customcrops.api.crop.Crop;
|
import net.momirealms.customcrops.api.crop.Crop;
|
||||||
import net.momirealms.customcrops.api.event.SeedPlantEvent;
|
|
||||||
import net.momirealms.customcrops.api.event.WaterPotEvent;
|
import net.momirealms.customcrops.api.event.WaterPotEvent;
|
||||||
import net.momirealms.customcrops.api.utils.CCSeason;
|
|
||||||
import net.momirealms.customcrops.api.utils.SeasonUtils;
|
|
||||||
import net.momirealms.customcrops.config.*;
|
import net.momirealms.customcrops.config.*;
|
||||||
import net.momirealms.customcrops.integrations.AntiGrief;
|
import net.momirealms.customcrops.integrations.AntiGrief;
|
||||||
import net.momirealms.customcrops.integrations.customplugin.HandlerP;
|
import net.momirealms.customcrops.integrations.customplugin.HandlerP;
|
||||||
@@ -36,26 +33,19 @@ import net.momirealms.customcrops.integrations.customplugin.itemsadder.listeners
|
|||||||
import net.momirealms.customcrops.managers.CropManager;
|
import net.momirealms.customcrops.managers.CropManager;
|
||||||
import net.momirealms.customcrops.managers.CustomWorld;
|
import net.momirealms.customcrops.managers.CustomWorld;
|
||||||
import net.momirealms.customcrops.objects.WaterCan;
|
import net.momirealms.customcrops.objects.WaterCan;
|
||||||
import net.momirealms.customcrops.objects.requirements.PlantingCondition;
|
|
||||||
import net.momirealms.customcrops.objects.requirements.RequirementInterface;
|
|
||||||
import net.momirealms.customcrops.utils.AdventureUtil;
|
import net.momirealms.customcrops.utils.AdventureUtil;
|
||||||
import net.momirealms.customcrops.utils.FurnitureUtil;
|
|
||||||
import net.momirealms.customcrops.utils.LimitationUtil;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.ItemFrame;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
public abstract class ItemsAdderHandler extends HandlerP {
|
public abstract class ItemsAdderHandler extends HandlerP {
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,11 @@
|
|||||||
|
|
||||||
package net.momirealms.customcrops.integrations.customplugin.oraxen;
|
package net.momirealms.customcrops.integrations.customplugin.oraxen;
|
||||||
|
|
||||||
import io.th0rgal.oraxen.events.OraxenFurnitureBreakEvent;
|
import io.th0rgal.oraxen.api.OraxenItems;
|
||||||
import io.th0rgal.oraxen.events.OraxenFurnitureInteractEvent;
|
import io.th0rgal.oraxen.api.events.OraxenFurnitureBreakEvent;
|
||||||
import io.th0rgal.oraxen.events.OraxenNoteBlockBreakEvent;
|
import io.th0rgal.oraxen.api.events.OraxenFurnitureInteractEvent;
|
||||||
import io.th0rgal.oraxen.events.OraxenNoteBlockInteractEvent;
|
import io.th0rgal.oraxen.api.events.OraxenNoteBlockBreakEvent;
|
||||||
import io.th0rgal.oraxen.items.OraxenItems;
|
import io.th0rgal.oraxen.api.events.OraxenNoteBlockInteractEvent;
|
||||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureFactory;
|
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureFactory;
|
||||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
|
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
|
||||||
import io.th0rgal.oraxen.utils.drops.Drop;
|
import io.th0rgal.oraxen.utils.drops.Drop;
|
||||||
@@ -55,7 +55,7 @@ public class OraxenFrameHandler extends OraxenHandler {
|
|||||||
public void onBreakNoteBlock(OraxenNoteBlockBreakEvent event) {
|
public void onBreakNoteBlock(OraxenNoteBlockBreakEvent event) {
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
String id = event.getNoteBlockMechanic().getItemID();
|
String id = event.getMechanic().getItemID();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location location = event.getBlock().getLocation();
|
Location location = event.getBlock().getLocation();
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ public class OraxenFrameHandler extends OraxenHandler {
|
|||||||
public void onBreakFurniture(OraxenFurnitureBreakEvent event) {
|
public void onBreakFurniture(OraxenFurnitureBreakEvent event) {
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
String id = event.getFurnitureMechanic().getItemID();
|
String id = event.getMechanic().getItemID();
|
||||||
if (id == null) return;
|
if (id == null) return;
|
||||||
|
|
||||||
Sprinkler sprinkler = SprinklerConfig.SPRINKLERS_3D.get(id);
|
Sprinkler sprinkler = SprinklerConfig.SPRINKLERS_3D.get(id);
|
||||||
@@ -128,7 +128,11 @@ public class OraxenFrameHandler extends OraxenHandler {
|
|||||||
final ItemStack itemInHand = event.getItemInHand();
|
final ItemStack itemInHand = event.getItemInHand();
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
|
|
||||||
String blockID = event.getNoteBlockMechanic().getItemID();
|
long time = System.currentTimeMillis();
|
||||||
|
if (time - (coolDown.getOrDefault(player, time - 50)) < 50) return;
|
||||||
|
coolDown.put(player, time);
|
||||||
|
|
||||||
|
String blockID = event.getMechanic().getItemID();
|
||||||
if (blockID.equals(BasicItemConfig.dryPot) || blockID.equals(BasicItemConfig.wetPot)) {
|
if (blockID.equals(BasicItemConfig.dryPot) || blockID.equals(BasicItemConfig.wetPot)) {
|
||||||
|
|
||||||
Location seedLoc = block.getLocation().clone().add(0,1,0);
|
Location seedLoc = block.getLocation().clone().add(0,1,0);
|
||||||
@@ -158,7 +162,7 @@ public class OraxenFrameHandler extends OraxenHandler {
|
|||||||
public void onInteractFurniture(OraxenFurnitureInteractEvent event) {
|
public void onInteractFurniture(OraxenFurnitureInteractEvent event) {
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
String id = event.getFurnitureMechanic().getItemID();
|
String id = event.getMechanic().getItemID();
|
||||||
if (id == null) return;
|
if (id == null) return;
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|||||||
@@ -19,15 +19,12 @@ package net.momirealms.customcrops.integrations.customplugin.oraxen;
|
|||||||
|
|
||||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||||
import io.th0rgal.oraxen.events.*;
|
import io.th0rgal.oraxen.api.OraxenItems;
|
||||||
import io.th0rgal.oraxen.items.OraxenItems;
|
import io.th0rgal.oraxen.api.events.*;
|
||||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
|
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
|
||||||
import net.momirealms.customcrops.CustomCrops;
|
import net.momirealms.customcrops.CustomCrops;
|
||||||
import net.momirealms.customcrops.api.crop.Crop;
|
import net.momirealms.customcrops.api.crop.Crop;
|
||||||
import net.momirealms.customcrops.api.event.SeedPlantEvent;
|
|
||||||
import net.momirealms.customcrops.api.event.WaterPotEvent;
|
import net.momirealms.customcrops.api.event.WaterPotEvent;
|
||||||
import net.momirealms.customcrops.api.utils.CCSeason;
|
|
||||||
import net.momirealms.customcrops.api.utils.SeasonUtils;
|
|
||||||
import net.momirealms.customcrops.config.*;
|
import net.momirealms.customcrops.config.*;
|
||||||
import net.momirealms.customcrops.integrations.customplugin.HandlerP;
|
import net.momirealms.customcrops.integrations.customplugin.HandlerP;
|
||||||
import net.momirealms.customcrops.integrations.customplugin.oraxen.listeners.OraxenBlockListener;
|
import net.momirealms.customcrops.integrations.customplugin.oraxen.listeners.OraxenBlockListener;
|
||||||
@@ -35,19 +32,13 @@ import net.momirealms.customcrops.integrations.customplugin.oraxen.listeners.Ora
|
|||||||
import net.momirealms.customcrops.managers.CropManager;
|
import net.momirealms.customcrops.managers.CropManager;
|
||||||
import net.momirealms.customcrops.managers.CustomWorld;
|
import net.momirealms.customcrops.managers.CustomWorld;
|
||||||
import net.momirealms.customcrops.objects.WaterCan;
|
import net.momirealms.customcrops.objects.WaterCan;
|
||||||
import net.momirealms.customcrops.objects.requirements.PlantingCondition;
|
|
||||||
import net.momirealms.customcrops.objects.requirements.RequirementInterface;
|
|
||||||
import net.momirealms.customcrops.utils.AdventureUtil;
|
import net.momirealms.customcrops.utils.AdventureUtil;
|
||||||
import net.momirealms.customcrops.utils.FurnitureUtil;
|
|
||||||
import net.momirealms.customcrops.utils.LimitationUtil;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.ItemFrame;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
@@ -84,7 +75,7 @@ public abstract class OraxenHandler extends HandlerP {
|
|||||||
//scarecrow place
|
//scarecrow place
|
||||||
public void placeScarecrow(OraxenFurniturePlaceEvent event) {
|
public void placeScarecrow(OraxenFurniturePlaceEvent event) {
|
||||||
if (!MainConfig.enableCrow) return;
|
if (!MainConfig.enableCrow) return;
|
||||||
FurnitureMechanic mechanic = event.getFurnitureMechanic();
|
FurnitureMechanic mechanic = event.getMechanic();
|
||||||
String id = mechanic.getItemID();
|
String id = mechanic.getItemID();
|
||||||
if (!id.equals(BasicItemConfig.scarecrow)) return;
|
if (!id.equals(BasicItemConfig.scarecrow)) return;
|
||||||
Location location = event.getItemFrame().getLocation();
|
Location location = event.getItemFrame().getLocation();
|
||||||
|
|||||||
@@ -18,29 +18,28 @@
|
|||||||
package net.momirealms.customcrops.integrations.customplugin.oraxen;
|
package net.momirealms.customcrops.integrations.customplugin.oraxen;
|
||||||
|
|
||||||
import io.th0rgal.oraxen.OraxenPlugin;
|
import io.th0rgal.oraxen.OraxenPlugin;
|
||||||
|
import io.th0rgal.oraxen.api.OraxenBlocks;
|
||||||
|
import io.th0rgal.oraxen.api.OraxenItems;
|
||||||
import io.th0rgal.oraxen.items.ItemBuilder;
|
import io.th0rgal.oraxen.items.ItemBuilder;
|
||||||
import io.th0rgal.oraxen.items.OraxenItems;
|
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureFactory;
|
||||||
|
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.noteblock.NoteBlockMechanic;
|
||||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanicFactory;
|
import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanicFactory;
|
||||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanicListener;
|
|
||||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanic;
|
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanic;
|
||||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanicFactory;
|
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanicFactory;
|
||||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanicListener;
|
|
||||||
import net.momirealms.customcrops.integrations.customplugin.CustomInterface;
|
import net.momirealms.customcrops.integrations.customplugin.CustomInterface;
|
||||||
|
import net.momirealms.customcrops.utils.FurnitureUtil;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.Rotation;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.ItemFrame;
|
import org.bukkit.entity.ItemFrame;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.persistence.PersistentDataContainer;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import static io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic.FURNITURE_KEY;
|
|
||||||
|
|
||||||
public class OraxenHook implements CustomInterface {
|
public class OraxenHook implements CustomInterface {
|
||||||
|
|
||||||
public static NamespacedKey FURNITURE = new NamespacedKey(OraxenPlugin.get(), "furniture");
|
public static NamespacedKey FURNITURE = new NamespacedKey(OraxenPlugin.get(), "furniture");
|
||||||
@@ -65,12 +64,12 @@ public class OraxenHook implements CustomInterface {
|
|||||||
public String getBlockID(Location location) {
|
public String getBlockID(Location location) {
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
if (block.getType() == Material.TRIPWIRE) {
|
if (block.getType() == Material.TRIPWIRE) {
|
||||||
StringBlockMechanic mechanic = StringBlockMechanicListener.getStringMechanic(block);
|
StringBlockMechanic mechanic = OraxenBlocks.getStringMechanic(block);
|
||||||
if (mechanic == null) return null;
|
if (mechanic == null) return null;
|
||||||
else return mechanic.getItemID();
|
else return mechanic.getItemID();
|
||||||
}
|
}
|
||||||
else if (block.getType() == Material.NOTE_BLOCK) {
|
else if (block.getType() == Material.NOTE_BLOCK) {
|
||||||
NoteBlockMechanic mechanic = NoteBlockMechanicListener.getNoteBlockMechanic(block);
|
NoteBlockMechanic mechanic = OraxenBlocks.getNoteBlockMechanic(block);
|
||||||
if (mechanic == null) return null;
|
if (mechanic == null) return null;
|
||||||
else return mechanic.getItemID();
|
else return mechanic.getItemID();
|
||||||
}
|
}
|
||||||
@@ -94,18 +93,8 @@ public class OraxenHook implements CustomInterface {
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public ItemFrame placeFurniture(Location location, String id) {
|
public ItemFrame placeFurniture(Location location, String id) {
|
||||||
ItemBuilder itemBuilder = OraxenItems.getItemById(id);
|
FurnitureMechanic mechanic = (FurnitureMechanic) FurnitureFactory.getInstance().getMechanic(id);
|
||||||
if (itemBuilder == null) return null;
|
return mechanic.place(Rotation.NONE, 0, BlockFace.UP, location, null);
|
||||||
return location.getWorld().spawn(location, ItemFrame.class, (ItemFrame frame) -> {
|
|
||||||
frame.setVisible(false);
|
|
||||||
frame.setFixed(false);
|
|
||||||
frame.setPersistent(true);
|
|
||||||
frame.setItemDropChance(0);
|
|
||||||
frame.setItem(itemBuilder.build(), false);
|
|
||||||
frame.setFacingDirection(BlockFace.UP, true);
|
|
||||||
PersistentDataContainer pdc = frame.getPersistentDataContainer();
|
|
||||||
pdc.set(FURNITURE_KEY, PersistentDataType.STRING, id);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package net.momirealms.customcrops.integrations.customplugin.oraxen;
|
package net.momirealms.customcrops.integrations.customplugin.oraxen;
|
||||||
|
|
||||||
import io.th0rgal.oraxen.events.*;
|
import io.th0rgal.oraxen.api.OraxenItems;
|
||||||
import io.th0rgal.oraxen.items.OraxenItems;
|
import io.th0rgal.oraxen.api.events.*;
|
||||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
|
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
|
||||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanic;
|
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanic;
|
||||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanicFactory;
|
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanicFactory;
|
||||||
@@ -49,50 +49,14 @@ public class OraxenWireHandler extends OraxenHandler{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBreakNoteBlock(OraxenNoteBlockBreakEvent event) {
|
public void onBreakNoteBlock(OraxenNoteBlockBreakEvent event) {
|
||||||
if (event.isCancelled()) return;
|
|
||||||
|
|
||||||
// not necessary because string break event would be triggered too
|
// not necessary because string break event would be triggered too
|
||||||
|
|
||||||
// String id = event.getNoteBlockMechanic().getItemID();
|
|
||||||
// if (id.equals(BasicItemConfig.dryPot) || id.equals(BasicItemConfig.wetPot)) {
|
|
||||||
//
|
|
||||||
// Location location = event.getBlock().getLocation();
|
|
||||||
// Player player = event.getPlayer();
|
|
||||||
//
|
|
||||||
// if (!AntiGrief.testBreak(player, location)) {
|
|
||||||
// event.setCancelled(true);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// super.onBreakPot(location);
|
|
||||||
//
|
|
||||||
// Location seedLocation = location.clone().add(0,1,0);
|
|
||||||
// StringBlockMechanic mechanic = StringBlockMechanicListener.getStringMechanic(seedLocation.getBlock());
|
|
||||||
// if (mechanic == null) return;
|
|
||||||
// String seedID = mechanic.getItemID();
|
|
||||||
//
|
|
||||||
// if (seedID.contains("_stage_")) {
|
|
||||||
|
|
||||||
// seedLocation.getBlock().setType(Material.AIR);
|
|
||||||
// if (seedID.equals(BasicItemConfig.deadCrop)) return;
|
|
||||||
//ripe or not
|
|
||||||
// if (hasNextStage(seedID)) {
|
|
||||||
// Drop drop = mechanic.getDrop();
|
|
||||||
// if (drop != null && player.getGameMode() != GameMode.CREATIVE) {
|
|
||||||
// drop.spawns(location, new ItemStack(Material.AIR));
|
|
||||||
// }
|
|
||||||
// super.onBreakUnripeCrop(location);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// super.onBreakRipeCrop(seedLocation, seedID, player, false, false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBreakStringBlock(OraxenStringBlockBreakEvent event) {
|
public void onBreakStringBlock(OraxenStringBlockBreakEvent event) {
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
StringBlockMechanic mechanic = event.getStringBlockMechanic();
|
StringBlockMechanic mechanic = event.getMechanic();
|
||||||
String id = mechanic.getItemID();
|
String id = mechanic.getItemID();
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
@@ -134,7 +98,7 @@ public class OraxenWireHandler extends OraxenHandler{
|
|||||||
public void onBreakFurniture(OraxenFurnitureBreakEvent event) {
|
public void onBreakFurniture(OraxenFurnitureBreakEvent event) {
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
FurnitureMechanic mechanic = event.getFurnitureMechanic();
|
FurnitureMechanic mechanic = event.getMechanic();
|
||||||
if (mechanic == null) return;
|
if (mechanic == null) return;
|
||||||
String id = mechanic.getItemID();
|
String id = mechanic.getItemID();
|
||||||
Sprinkler sprinkler = SprinklerConfig.SPRINKLERS_3D.get(id);
|
Sprinkler sprinkler = SprinklerConfig.SPRINKLERS_3D.get(id);
|
||||||
@@ -157,7 +121,7 @@ public class OraxenWireHandler extends OraxenHandler{
|
|||||||
if (!AntiGrief.testPlace(player, blockLoc)) return;
|
if (!AntiGrief.testPlace(player, blockLoc)) return;
|
||||||
if (!canProceedAction(player, blockLoc)) return;
|
if (!canProceedAction(player, blockLoc)) return;
|
||||||
|
|
||||||
FurnitureMechanic mechanic = event.getFurnitureMechanic();
|
FurnitureMechanic mechanic = event.getMechanic();
|
||||||
if (mechanic == null) return;
|
if (mechanic == null) return;
|
||||||
String id = mechanic.getItemID();
|
String id = mechanic.getItemID();
|
||||||
Sprinkler sprinkler = SprinklerConfig.SPRINKLERS_3D.get(id);
|
Sprinkler sprinkler = SprinklerConfig.SPRINKLERS_3D.get(id);
|
||||||
@@ -174,6 +138,10 @@ public class OraxenWireHandler extends OraxenHandler{
|
|||||||
Location potLoc = event.getBlock().getLocation();
|
Location potLoc = event.getBlock().getLocation();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
if (time - (coolDown.getOrDefault(player, time - 50)) < 50) return;
|
||||||
|
coolDown.put(player, time);
|
||||||
|
|
||||||
if (!AntiGrief.testPlace(player, potLoc)) return;
|
if (!AntiGrief.testPlace(player, potLoc)) return;
|
||||||
if (super.tryMisc(event.getPlayer(), itemInHand, potLoc)) return;
|
if (super.tryMisc(event.getPlayer(), itemInHand, potLoc)) return;
|
||||||
if (event.getBlockFace() != BlockFace.UP) return;
|
if (event.getBlockFace() != BlockFace.UP) return;
|
||||||
@@ -205,7 +173,7 @@ public class OraxenWireHandler extends OraxenHandler{
|
|||||||
coolDown.put(player, time);
|
coolDown.put(player, time);
|
||||||
|
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
final String id = event.getStringBlockMechanic().getItemID();
|
final String id = event.getMechanic().getItemID();
|
||||||
|
|
||||||
if (id.contains("_stage_")) {
|
if (id.contains("_stage_")) {
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,10 @@
|
|||||||
|
|
||||||
package net.momirealms.customcrops.integrations.customplugin.oraxen.listeners;
|
package net.momirealms.customcrops.integrations.customplugin.oraxen.listeners;
|
||||||
|
|
||||||
import io.th0rgal.oraxen.events.OraxenNoteBlockBreakEvent;
|
import io.th0rgal.oraxen.api.events.OraxenNoteBlockBreakEvent;
|
||||||
import io.th0rgal.oraxen.events.OraxenNoteBlockInteractEvent;
|
import io.th0rgal.oraxen.api.events.OraxenNoteBlockInteractEvent;
|
||||||
import io.th0rgal.oraxen.events.OraxenStringBlockBreakEvent;
|
import io.th0rgal.oraxen.api.events.OraxenStringBlockBreakEvent;
|
||||||
import io.th0rgal.oraxen.events.OraxenStringBlockInteractEvent;
|
import io.th0rgal.oraxen.api.events.OraxenStringBlockInteractEvent;
|
||||||
import net.momirealms.customcrops.integrations.customplugin.oraxen.OraxenHandler;
|
import net.momirealms.customcrops.integrations.customplugin.oraxen.OraxenHandler;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|||||||
@@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
package net.momirealms.customcrops.integrations.customplugin.oraxen.listeners;
|
package net.momirealms.customcrops.integrations.customplugin.oraxen.listeners;
|
||||||
|
|
||||||
import io.th0rgal.oraxen.events.OraxenFurnitureBreakEvent;
|
import io.th0rgal.oraxen.api.events.OraxenFurnitureBreakEvent;
|
||||||
import io.th0rgal.oraxen.events.OraxenFurnitureInteractEvent;
|
import io.th0rgal.oraxen.api.events.OraxenFurnitureInteractEvent;
|
||||||
import io.th0rgal.oraxen.events.OraxenFurniturePlaceEvent;
|
import io.th0rgal.oraxen.api.events.OraxenFurniturePlaceEvent;
|
||||||
import net.momirealms.customcrops.integrations.customplugin.oraxen.OraxenHandler;
|
import net.momirealms.customcrops.integrations.customplugin.oraxen.OraxenHandler;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class ResidenceHook implements AntiGrief {
|
|||||||
@Override
|
@Override
|
||||||
public boolean canBreak(Location location, Player player) {
|
public boolean canBreak(Location location, Player player) {
|
||||||
ClaimedResidence res = com.bekvon.bukkit.residence.Residence.getInstance().getResidenceManager().getByLoc(location);
|
ClaimedResidence res = com.bekvon.bukkit.residence.Residence.getInstance().getResidenceManager().getByLoc(location);
|
||||||
if(res!=null){
|
if (res != null) {
|
||||||
ResidencePermissions perms = res.getPermissions();
|
ResidencePermissions perms = res.getPermissions();
|
||||||
return perms.playerHas(player, Flags.destroy, true);
|
return perms.playerHas(player, Flags.destroy, true);
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ public class ResidenceHook implements AntiGrief {
|
|||||||
@Override
|
@Override
|
||||||
public boolean canPlace(Location location, Player player) {
|
public boolean canPlace(Location location, Player player) {
|
||||||
ClaimedResidence res = com.bekvon.bukkit.residence.Residence.getInstance().getResidenceManager().getByLoc(location);
|
ClaimedResidence res = com.bekvon.bukkit.residence.Residence.getInstance().getResidenceManager().getByLoc(location);
|
||||||
if(res!=null){
|
if (res != null) {
|
||||||
ResidencePermissions perms = res.getPermissions();
|
ResidencePermissions perms = res.getPermissions();
|
||||||
return perms.playerHas(player, Flags.build, true);
|
return perms.playerHas(player, Flags.build, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ public class WorldGuardHook implements AntiGrief {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlace(Location location, Player player) {
|
public boolean canPlace(Location location, Player player) {
|
||||||
if (player.isOp()) return true;
|
|
||||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||||
World world = BukkitAdapter.adapt(location.getWorld());
|
World world = BukkitAdapter.adapt(location.getWorld());
|
||||||
WorldGuardPlatform platform = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform();
|
WorldGuardPlatform platform = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform();
|
||||||
@@ -48,7 +47,6 @@ public class WorldGuardHook implements AntiGrief {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBreak(Location location, Player player) {
|
public boolean canBreak(Location location, Player player) {
|
||||||
if (player.isOp()) return true;
|
|
||||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||||
World world = BukkitAdapter.adapt(location.getWorld());
|
World world = BukkitAdapter.adapt(location.getWorld());
|
||||||
WorldGuardPlatform platform = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform();
|
WorldGuardPlatform platform = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform();
|
||||||
|
|||||||
Reference in New Issue
Block a user