mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-24 01:19:28 +00:00
[Compatibility] Oraxen 2.0 support
This commit is contained in:
@@ -23,13 +23,16 @@ import net.momirealms.customcrops.api.mechanic.item.*;
|
||||
import net.momirealms.customcrops.api.mechanic.misc.CRotation;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface ItemManager extends Reloadable {
|
||||
|
||||
@@ -325,6 +328,53 @@ public interface ItemManager extends Reloadable {
|
||||
@Nullable
|
||||
Crop.Stage getCropStageByStageID(String id);
|
||||
|
||||
void handlePlayerInteractBlock(
|
||||
Player player,
|
||||
Block clickedBlock,
|
||||
BlockFace clickedFace,
|
||||
Cancellable event
|
||||
);
|
||||
|
||||
void handlePlayerInteractAir(
|
||||
Player player,
|
||||
Cancellable event
|
||||
);
|
||||
|
||||
void handlePlayerBreakBlock(
|
||||
Player player,
|
||||
Block brokenBlock,
|
||||
String blockID,
|
||||
Cancellable event
|
||||
);
|
||||
|
||||
void handlePlayerInteractFurniture(
|
||||
Player player,
|
||||
Location location,
|
||||
String id,
|
||||
Entity baseEntity,
|
||||
Cancellable event
|
||||
);
|
||||
|
||||
void handlePlayerPlaceFurniture(
|
||||
Player player,
|
||||
Location location,
|
||||
String id,
|
||||
Cancellable event
|
||||
);
|
||||
|
||||
void handlePlayerBreakFurniture(
|
||||
Player player,
|
||||
Location location,
|
||||
String id,
|
||||
Cancellable event
|
||||
);
|
||||
|
||||
void handlePlayerPlaceBlock(Player player, Block block, String blockID, Cancellable event);
|
||||
|
||||
void handleEntityTramplingBlock(Entity entity, Block block, Cancellable event);
|
||||
|
||||
void handleExplosion(Entity entity, List<Block> blocks, Cancellable event);
|
||||
|
||||
/**
|
||||
* Update a pot's block state
|
||||
*
|
||||
|
||||
@@ -15,19 +15,18 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.mechanic.item.custom;
|
||||
package net.momirealms.customcrops.api.mechanic.item;
|
||||
|
||||
import net.momirealms.customcrops.api.CustomCropsPlugin;
|
||||
import net.momirealms.customcrops.api.event.BoneMealDispenseEvent;
|
||||
import net.momirealms.customcrops.api.manager.ConfigManager;
|
||||
import net.momirealms.customcrops.api.manager.ItemManager;
|
||||
import net.momirealms.customcrops.api.manager.VersionManager;
|
||||
import net.momirealms.customcrops.api.manager.WorldManager;
|
||||
import net.momirealms.customcrops.api.mechanic.item.*;
|
||||
import net.momirealms.customcrops.api.mechanic.requirement.State;
|
||||
import net.momirealms.customcrops.api.mechanic.world.SimpleLocation;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldCrop;
|
||||
import net.momirealms.customcrops.mechanic.item.ItemManagerImpl;
|
||||
import net.momirealms.customcrops.util.EventUtils;
|
||||
import net.momirealms.customcrops.api.util.EventUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -56,10 +55,10 @@ import java.util.Optional;
|
||||
|
||||
public abstract class AbstractCustomListener implements Listener {
|
||||
|
||||
protected ItemManagerImpl itemManager;
|
||||
protected ItemManager itemManager;
|
||||
private final HashSet<Material> CUSTOM_MATERIAL = new HashSet<>();
|
||||
|
||||
public AbstractCustomListener(ItemManagerImpl itemManager) {
|
||||
public AbstractCustomListener(ItemManager itemManager) {
|
||||
this.itemManager = itemManager;
|
||||
this.CUSTOM_MATERIAL.addAll(
|
||||
List.of(
|
||||
@@ -15,14 +15,13 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.mechanic.item;
|
||||
package net.momirealms.customcrops.api.mechanic.item;
|
||||
|
||||
import net.momirealms.customcrops.api.manager.VersionManager;
|
||||
import net.momirealms.customcrops.api.mechanic.misc.CRotation;
|
||||
import net.momirealms.customcrops.api.util.DisplayEntityUtils;
|
||||
import net.momirealms.customcrops.api.util.LocationUtils;
|
||||
import net.momirealms.customcrops.util.ConfigUtils;
|
||||
import net.momirealms.customcrops.util.DisplayEntityUtils;
|
||||
import net.momirealms.customcrops.util.RotationUtils;
|
||||
import net.momirealms.customcrops.api.util.StringUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -38,7 +37,7 @@ public interface CustomProvider {
|
||||
void placeCustomBlock(Location location, String id);
|
||||
|
||||
default void placeBlock(Location location, String id) {
|
||||
if (ConfigUtils.isVanillaItem(id)) {
|
||||
if (StringUtils.isCapitalLetter(id)) {
|
||||
location.getBlock().setType(Material.valueOf(id));
|
||||
} else {
|
||||
placeCustomBlock(location, id);
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.momirealms.customcrops.util;
|
||||
package net.momirealms.customcrops.api.util;
|
||||
|
||||
import net.momirealms.customcrops.api.mechanic.misc.CRotation;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.util;
|
||||
package net.momirealms.customcrops.api.util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Cancellable;
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.momirealms.customcrops.api.util;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
public static boolean isCapitalLetter(String item) {
|
||||
char[] chars = item.toCharArray();
|
||||
for (char character : chars) {
|
||||
if ((character < 65 || character > 90) && character != 95) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ plugins {
|
||||
allprojects {
|
||||
|
||||
project.group = "net.momirealms"
|
||||
project.version = "3.4.6"
|
||||
project.version = "3.4.7-BETA"
|
||||
|
||||
apply<JavaPlugin>()
|
||||
apply(plugin = "java")
|
||||
@@ -44,6 +44,7 @@ allprojects {
|
||||
maven("https://repo.rapture.pw/repository/maven-releases/")
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
|
||||
maven("https://repo.xenondevs.xyz/releases/")
|
||||
maven("https://repo.oraxen.com/snapshots/")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
42
oraxen-legacy/.gitignore
vendored
Normal file
42
oraxen-legacy/.gitignore
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
.gradle
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
5
oraxen-legacy/build.gradle.kts
Normal file
5
oraxen-legacy/build.gradle.kts
Normal file
@@ -0,0 +1,5 @@
|
||||
dependencies {
|
||||
compileOnly(project(":api"))
|
||||
compileOnly("dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT")
|
||||
compileOnly("com.github.oraxen:oraxen:1.172.0")
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.mechanic.item.custom.oraxenlegacy;
|
||||
|
||||
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureBreakEvent;
|
||||
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureInteractEvent;
|
||||
import io.th0rgal.oraxen.api.events.furniture.OraxenFurniturePlaceEvent;
|
||||
import io.th0rgal.oraxen.api.events.noteblock.OraxenNoteBlockBreakEvent;
|
||||
import io.th0rgal.oraxen.api.events.noteblock.OraxenNoteBlockPlaceEvent;
|
||||
import io.th0rgal.oraxen.api.events.stringblock.OraxenStringBlockBreakEvent;
|
||||
import io.th0rgal.oraxen.api.events.stringblock.OraxenStringBlockPlaceEvent;
|
||||
import net.momirealms.customcrops.api.manager.ItemManager;
|
||||
import net.momirealms.customcrops.api.mechanic.item.AbstractCustomListener;
|
||||
import net.momirealms.customcrops.api.util.LocationUtils;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class LegacyOraxenListener extends AbstractCustomListener {
|
||||
|
||||
public LegacyOraxenListener(ItemManager itemManager) {
|
||||
super(itemManager);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onBreakCustomNoteBlock(OraxenNoteBlockBreakEvent event) {
|
||||
this.itemManager.handlePlayerBreakBlock(
|
||||
event.getPlayer(),
|
||||
event.getBlock(),
|
||||
event.getMechanic().getItemID(),
|
||||
event
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onBreakCustomStringBlock(OraxenStringBlockBreakEvent event) {
|
||||
this.itemManager.handlePlayerBreakBlock(
|
||||
event.getPlayer(),
|
||||
event.getBlock(),
|
||||
event.getMechanic().getItemID(),
|
||||
event
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onPlaceCustomBlock(OraxenNoteBlockPlaceEvent event) {
|
||||
super.onPlaceBlock(
|
||||
event.getPlayer(),
|
||||
event.getBlock(),
|
||||
event.getMechanic().getItemID(),
|
||||
event
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onPlaceCustomBlock(OraxenStringBlockPlaceEvent event) {
|
||||
super.onPlaceBlock(
|
||||
event.getPlayer(),
|
||||
event.getBlock(),
|
||||
event.getMechanic().getItemID(),
|
||||
event
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onPlaceFurniture(OraxenFurniturePlaceEvent event) {
|
||||
super.onPlaceFurniture(
|
||||
event.getPlayer(),
|
||||
event.getBlock().getLocation(),
|
||||
event.getMechanic().getItemID(),
|
||||
event
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onBreakFurniture(OraxenFurnitureBreakEvent event) {
|
||||
super.onBreakFurniture(
|
||||
event.getPlayer(),
|
||||
LocationUtils.toBlockLocation(event.getBaseEntity().getLocation()),
|
||||
event.getMechanic().getItemID(),
|
||||
event
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onInteractFurniture(OraxenFurnitureInteractEvent event) {
|
||||
super.onInteractFurniture(
|
||||
event.getPlayer(),
|
||||
LocationUtils.toBlockLocation(event.getBaseEntity().getLocation()),
|
||||
event.getMechanic().getItemID(),
|
||||
event.getBaseEntity(),
|
||||
event
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.mechanic.item.custom.oraxenlegacy;
|
||||
|
||||
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 net.momirealms.customcrops.api.mechanic.item.CustomProvider;
|
||||
import net.momirealms.customcrops.api.util.LogUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Rotation;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class LegacyOraxenProvider implements CustomProvider {
|
||||
|
||||
@Override
|
||||
public boolean removeBlock(Location location) {
|
||||
Block block = location.getBlock();
|
||||
if (block.getType() == Material.AIR) {
|
||||
return false;
|
||||
}
|
||||
block.setType(Material.AIR);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeCustomBlock(Location location, String id) {
|
||||
OraxenBlocks.place(id, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity placeFurniture(Location location, String id) {
|
||||
Entity entity = OraxenFurniture.place(id, location, Rotation.NONE, BlockFace.UP);
|
||||
if (entity == null) {
|
||||
LogUtils.warn("Furniture(" + id +") doesn't exist in Oraxen configs. Please double check if that furniture exists.");
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFurniture(Entity entity) {
|
||||
OraxenFurniture.remove(entity, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockID(Block block) {
|
||||
Mechanic mechanic = OraxenBlocks.getOraxenBlock(block.getLocation());
|
||||
if (mechanic == null) {
|
||||
return block.getType().name();
|
||||
}
|
||||
return mechanic.getItemID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemID(ItemStack itemStack) {
|
||||
return OraxenItems.getIdByItem(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack(String id) {
|
||||
if (id == null) return new ItemStack(Material.AIR);
|
||||
ItemBuilder builder = OraxenItems.getItemById(id);
|
||||
if (builder == null) {
|
||||
return null;
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityID(Entity entity) {
|
||||
FurnitureMechanic mechanic = OraxenFurniture.getFurnitureMechanic(entity);
|
||||
if (mechanic == null) {
|
||||
return entity.getType().name();
|
||||
}
|
||||
return mechanic.getItemID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFurniture(Entity entity) {
|
||||
return OraxenFurniture.isFurniture(entity);
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ dependencies {
|
||||
|
||||
// Items
|
||||
compileOnly("com.github.LoneDev6:api-itemsadder:3.6.2-beta-r3-b")
|
||||
compileOnly("com.github.oraxen:oraxen:1.172.0")
|
||||
compileOnly("io.th0rgal:oraxen:2.0-SNAPSHOT")
|
||||
compileOnly("pers.neige.neigeitems:NeigeItems:1.16.24")
|
||||
compileOnly("net.Indyuce:MMOItems-API:6.9.2-SNAPSHOT")
|
||||
compileOnly("io.lumine:MythicLib-dist:1.6-SNAPSHOT")
|
||||
@@ -48,6 +48,7 @@ dependencies {
|
||||
compileOnly(files("libs/RealisticSeasons-api.jar"))
|
||||
|
||||
implementation(project(":api"))
|
||||
implementation(project(":oraxen-legacy"))
|
||||
implementation(project(":legacy-api"))
|
||||
compileOnly("net.kyori:adventure-api:4.16.0")
|
||||
compileOnly("net.kyori:adventure-platform-bukkit:4.3.2")
|
||||
|
||||
@@ -38,7 +38,7 @@ import net.momirealms.customcrops.mechanic.misc.migrator.Migration;
|
||||
import net.momirealms.customcrops.mechanic.requirement.RequirementManagerImpl;
|
||||
import net.momirealms.customcrops.mechanic.world.WorldManagerImpl;
|
||||
import net.momirealms.customcrops.scheduler.SchedulerImpl;
|
||||
import net.momirealms.customcrops.util.EventUtils;
|
||||
import net.momirealms.customcrops.api.util.EventUtils;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ import net.momirealms.customcrops.mechanic.misc.TempFakeItem;
|
||||
import net.momirealms.customcrops.mechanic.world.block.MemoryCrop;
|
||||
import net.momirealms.customcrops.util.ClassUtils;
|
||||
import net.momirealms.customcrops.util.ConfigUtils;
|
||||
import net.momirealms.customcrops.util.EventUtils;
|
||||
import net.momirealms.customcrops.api.util.EventUtils;
|
||||
import net.momirealms.customcrops.util.ItemUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
@@ -40,13 +40,15 @@ import net.momirealms.customcrops.api.mechanic.world.SimpleLocation;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.*;
|
||||
import net.momirealms.customcrops.api.util.LocationUtils;
|
||||
import net.momirealms.customcrops.api.util.LogUtils;
|
||||
import net.momirealms.customcrops.mechanic.item.custom.AbstractCustomListener;
|
||||
import net.momirealms.customcrops.api.mechanic.item.AbstractCustomListener;
|
||||
import net.momirealms.customcrops.mechanic.item.custom.crucible.CrucibleListener;
|
||||
import net.momirealms.customcrops.mechanic.item.custom.crucible.CrucibleProvider;
|
||||
import net.momirealms.customcrops.mechanic.item.custom.itemsadder.ItemsAdderListener;
|
||||
import net.momirealms.customcrops.mechanic.item.custom.itemsadder.ItemsAdderProvider;
|
||||
import net.momirealms.customcrops.mechanic.item.custom.oraxen.OraxenListener;
|
||||
import net.momirealms.customcrops.mechanic.item.custom.oraxen.OraxenProvider;
|
||||
import net.momirealms.customcrops.mechanic.item.custom.oraxenlegacy.LegacyOraxenListener;
|
||||
import net.momirealms.customcrops.mechanic.item.custom.oraxenlegacy.LegacyOraxenProvider;
|
||||
import net.momirealms.customcrops.mechanic.item.function.CFunction;
|
||||
import net.momirealms.customcrops.mechanic.item.function.FunctionResult;
|
||||
import net.momirealms.customcrops.mechanic.item.function.FunctionTrigger;
|
||||
@@ -58,7 +60,7 @@ import net.momirealms.customcrops.mechanic.item.impl.WateringCanConfig;
|
||||
import net.momirealms.customcrops.mechanic.item.impl.fertilizer.*;
|
||||
import net.momirealms.customcrops.mechanic.world.block.*;
|
||||
import net.momirealms.customcrops.util.ConfigUtils;
|
||||
import net.momirealms.customcrops.util.EventUtils;
|
||||
import net.momirealms.customcrops.api.util.EventUtils;
|
||||
import net.momirealms.customcrops.util.ItemUtils;
|
||||
import net.momirealms.customcrops.util.RotationUtils;
|
||||
import org.bukkit.*;
|
||||
@@ -126,8 +128,13 @@ public class ItemManagerImpl implements ItemManager {
|
||||
this.stage2CropStageMap = new HashMap<>();
|
||||
this.deadCrops = new HashSet<>();
|
||||
if (Bukkit.getPluginManager().getPlugin("Oraxen") != null) {
|
||||
listener = new OraxenListener(this);
|
||||
customProvider = new OraxenProvider();
|
||||
if (Bukkit.getPluginManager().getPlugin("Oraxen").getDescription().getVersion().startsWith("2")) {
|
||||
listener = new OraxenListener(this);
|
||||
customProvider = new OraxenProvider();
|
||||
} else {
|
||||
listener = new LegacyOraxenListener(this);
|
||||
customProvider = new LegacyOraxenProvider();
|
||||
}
|
||||
} else if (Bukkit.getPluginManager().getPlugin("ItemsAdder") != null) {
|
||||
listener = new ItemsAdderListener(this);
|
||||
customProvider = new ItemsAdderProvider();
|
||||
@@ -2328,6 +2335,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public void handlePlayerInteractBlock(
|
||||
Player player,
|
||||
@@ -2358,6 +2366,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
.ifPresent(itemFunctions -> handleFunctions(itemFunctions, condition, event));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePlayerInteractAir(
|
||||
Player player,
|
||||
Cancellable event
|
||||
@@ -2377,6 +2386,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
.ifPresent(cFunctions -> handleFunctions(cFunctions, condition, event));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePlayerBreakBlock(
|
||||
Player player,
|
||||
Block brokenBlock,
|
||||
@@ -2395,6 +2405,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
.ifPresent(cFunctions -> handleFunctions(cFunctions, new BreakBlockWrapper(player, brokenBlock), event));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public void handlePlayerInteractFurniture(
|
||||
Player player,
|
||||
@@ -2423,6 +2434,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
.ifPresent(cFunctions -> handleFunctions(cFunctions, condition, event));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePlayerPlaceFurniture(
|
||||
Player player,
|
||||
Location location,
|
||||
@@ -2442,6 +2454,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
.ifPresent(cFunctions -> handleFunctions(cFunctions, new PlaceFurnitureWrapper(player, location, id), event));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePlayerBreakFurniture(
|
||||
Player player,
|
||||
Location location,
|
||||
@@ -2461,6 +2474,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
.ifPresent(cFunctions -> handleFunctions(cFunctions, new BreakFurnitureWrapper(player, location, id), event));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePlayerPlaceBlock(Player player, Block block, String blockID, Cancellable event) {
|
||||
if (!plugin.getWorldManager().isMechanicEnabled(player.getWorld()))
|
||||
return;
|
||||
@@ -2475,6 +2489,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
.ifPresent(cFunctions -> handleFunctions(cFunctions, new PlaceBlockWrapper(player, block, blockID), event));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEntityTramplingBlock(Entity entity, Block block, Cancellable event) {
|
||||
if (entity instanceof Player player) {
|
||||
handlePlayerBreakBlock(player, block, "FARMLAND", event);
|
||||
@@ -2542,6 +2557,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleExplosion(Entity entity, List<Block> blocks, Cancellable event) {
|
||||
List<Location> locationsToRemove = new ArrayList<>();
|
||||
List<Location> locationsToRemoveBlock = new ArrayList<>();
|
||||
|
||||
@@ -19,7 +19,7 @@ package net.momirealms.customcrops.mechanic.item.custom.crucible;
|
||||
|
||||
import io.lumine.mythiccrucible.events.MythicFurniturePlaceEvent;
|
||||
import net.momirealms.customcrops.mechanic.item.ItemManagerImpl;
|
||||
import net.momirealms.customcrops.mechanic.item.custom.AbstractCustomListener;
|
||||
import net.momirealms.customcrops.api.mechanic.item.AbstractCustomListener;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class CrucibleListener extends AbstractCustomListener {
|
||||
|
||||
@@ -27,7 +27,7 @@ import io.lumine.mythiccrucible.items.blocks.CustomBlockManager;
|
||||
import io.lumine.mythiccrucible.items.furniture.Furniture;
|
||||
import io.lumine.mythiccrucible.items.furniture.FurnitureManager;
|
||||
import net.momirealms.customcrops.api.util.LogUtils;
|
||||
import net.momirealms.customcrops.mechanic.item.CustomProvider;
|
||||
import net.momirealms.customcrops.api.mechanic.item.CustomProvider;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
@@ -20,7 +20,7 @@ package net.momirealms.customcrops.mechanic.item.custom.itemsadder;
|
||||
import dev.lone.itemsadder.api.CustomFurniture;
|
||||
import dev.lone.itemsadder.api.Events.*;
|
||||
import net.momirealms.customcrops.mechanic.item.ItemManagerImpl;
|
||||
import net.momirealms.customcrops.mechanic.item.custom.AbstractCustomListener;
|
||||
import net.momirealms.customcrops.api.mechanic.item.AbstractCustomListener;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import dev.lone.itemsadder.api.CustomBlock;
|
||||
import dev.lone.itemsadder.api.CustomFurniture;
|
||||
import dev.lone.itemsadder.api.CustomStack;
|
||||
import net.momirealms.customcrops.api.util.LogUtils;
|
||||
import net.momirealms.customcrops.mechanic.item.CustomProvider;
|
||||
import net.momirealms.customcrops.api.mechanic.item.CustomProvider;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
|
||||
package net.momirealms.customcrops.mechanic.item.custom.oraxen;
|
||||
|
||||
import io.th0rgal.oraxen.api.events.custom_block.noteblock.OraxenNoteBlockBreakEvent;
|
||||
import io.th0rgal.oraxen.api.events.custom_block.noteblock.OraxenNoteBlockPlaceEvent;
|
||||
import io.th0rgal.oraxen.api.events.custom_block.stringblock.OraxenStringBlockBreakEvent;
|
||||
import io.th0rgal.oraxen.api.events.custom_block.stringblock.OraxenStringBlockPlaceEvent;
|
||||
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureBreakEvent;
|
||||
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureInteractEvent;
|
||||
import io.th0rgal.oraxen.api.events.furniture.OraxenFurniturePlaceEvent;
|
||||
import io.th0rgal.oraxen.api.events.noteblock.OraxenNoteBlockBreakEvent;
|
||||
import io.th0rgal.oraxen.api.events.noteblock.OraxenNoteBlockPlaceEvent;
|
||||
import io.th0rgal.oraxen.api.events.stringblock.OraxenStringBlockBreakEvent;
|
||||
import io.th0rgal.oraxen.api.events.stringblock.OraxenStringBlockPlaceEvent;
|
||||
import net.momirealms.customcrops.api.util.LocationUtils;
|
||||
import net.momirealms.customcrops.mechanic.item.ItemManagerImpl;
|
||||
import net.momirealms.customcrops.mechanic.item.custom.AbstractCustomListener;
|
||||
import net.momirealms.customcrops.api.mechanic.item.AbstractCustomListener;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class OraxenListener extends AbstractCustomListener {
|
||||
@@ -98,10 +98,10 @@ public class OraxenListener extends AbstractCustomListener {
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onInteractFurniture(OraxenFurnitureInteractEvent event) {
|
||||
super.onInteractFurniture(
|
||||
event.getPlayer(),
|
||||
LocationUtils.toBlockLocation(event.getBaseEntity().getLocation()),
|
||||
event.getMechanic().getItemID(),
|
||||
event.getBaseEntity(),
|
||||
event.player(),
|
||||
LocationUtils.toBlockLocation(event.baseEntity().getLocation()),
|
||||
event.mechanic().getItemID(),
|
||||
event.baseEntity(),
|
||||
event
|
||||
);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import io.th0rgal.oraxen.items.ItemBuilder;
|
||||
import io.th0rgal.oraxen.mechanics.Mechanic;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
|
||||
import net.momirealms.customcrops.api.util.LogUtils;
|
||||
import net.momirealms.customcrops.mechanic.item.CustomProvider;
|
||||
import net.momirealms.customcrops.api.mechanic.item.CustomProvider;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Rotation;
|
||||
@@ -66,7 +66,7 @@ public class OraxenProvider implements CustomProvider {
|
||||
|
||||
@Override
|
||||
public String getBlockID(Block block) {
|
||||
Mechanic mechanic = OraxenBlocks.getOraxenBlock(block.getLocation());
|
||||
Mechanic mechanic = OraxenBlocks.getCustomBlockMechanic(block.getLocation());
|
||||
if (mechanic == null) {
|
||||
return block.getType().name();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import net.momirealms.customcrops.api.mechanic.world.season.Season;
|
||||
import net.momirealms.customcrops.api.scheduler.CancellableTask;
|
||||
import net.momirealms.customcrops.api.scheduler.Scheduler;
|
||||
import net.momirealms.customcrops.api.util.LogUtils;
|
||||
import net.momirealms.customcrops.util.EventUtils;
|
||||
import net.momirealms.customcrops.api.util.EventUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -2,4 +2,5 @@ rootProject.name = 'CustomCrops'
|
||||
include(":plugin")
|
||||
include(":api")
|
||||
include(":legacy-api")
|
||||
include 'oraxen-legacy'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user