9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-28 11:29:19 +00:00
This commit is contained in:
XiaoMoMi
2024-01-28 20:52:10 +08:00
parent eceee8be79
commit 518ad34045
5 changed files with 47 additions and 55 deletions

View File

@@ -1,41 +1,41 @@
/*
* 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.api.object.world;
import com.infernalsuite.aswm.api.events.LoadSlimeWorldEvent;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class SlimeWorldListener implements Listener {
private final WorldDataManager worldDataManager;
public SlimeWorldListener(WorldDataManager worldDataManager) {
this.worldDataManager = worldDataManager;
}
@EventHandler
public void onWorldLoad(LoadSlimeWorldEvent event) {
World world = Bukkit.getWorld(event.getSlimeWorld().getName());
if (world != null) {
worldDataManager.loadWorld(world);
}
}
}
///*
// * 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.api.object.world;
//
//import com.infernalsuite.aswm.api.events.LoadSlimeWorldEvent;
//import org.bukkit.Bukkit;
//import org.bukkit.World;
//import org.bukkit.event.EventHandler;
//import org.bukkit.event.Listener;
//
//public class SlimeWorldListener implements Listener {
//
// private final WorldDataManager worldDataManager;
//
// public SlimeWorldListener(WorldDataManager worldDataManager) {
// this.worldDataManager = worldDataManager;
// }
//
// @EventHandler
// public void onWorldLoad(LoadSlimeWorldEvent event) {
// World world = Bukkit.getWorld(event.getSlimeWorld().getName());
// if (world != null) {
// worldDataManager.loadWorld(world);
// }
// }
//}

View File

@@ -40,23 +40,16 @@ public class WorldDataManager extends Function {
private final ConcurrentHashMap<String, CCWorld> worldMap;
private final CustomCrops plugin;
private final WorldListener worldListener;
private SlimeWorldListener slimeWorldListener;
public WorldDataManager(CustomCrops plugin) {
this.plugin = plugin;
this.worldMap = new ConcurrentHashMap<>();
this.worldListener = new WorldListener(this);
try {
Class.forName("com.infernalsuite.aswm.api.world.SlimeWorld");
this.slimeWorldListener = new SlimeWorldListener(this);
} catch (ClassNotFoundException ignored) {
}
}
@Override
public void load() {
Bukkit.getPluginManager().registerEvents(worldListener, plugin);
if (slimeWorldListener != null) Bukkit.getPluginManager().registerEvents(slimeWorldListener, plugin);
for (CCWorld ccWorld : worldMap.values()) {
ccWorld.load();
}
@@ -65,7 +58,6 @@ public class WorldDataManager extends Function {
@Override
public void unload() {
HandlerList.unregisterAll(worldListener);
if (slimeWorldListener != null) HandlerList.unregisterAll(slimeWorldListener);
for (CCWorld ccWorld : worldMap.values()) {
ccWorld.unload();
}

View File

@@ -22,6 +22,7 @@ import de.tr7zw.changeme.nbtapi.NBTItem;
import io.th0rgal.oraxen.api.OraxenBlocks;
import io.th0rgal.oraxen.api.OraxenFurniture;
import io.th0rgal.oraxen.api.OraxenItems;
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureInteractEvent;
import io.th0rgal.oraxen.items.ItemBuilder;
import io.th0rgal.oraxen.mechanics.Mechanic;
import io.th0rgal.oraxen.mechanics.provided.gameplay.block.BlockMechanic;
@@ -73,7 +74,7 @@ public class OraxenPluginImpl implements PlatformInterface {
AdventureUtils.consoleMessage("<red>[CustomCrops] Furniture not exists: " + id);
return null;
}
Entity entity = mechanic.place(location, 0, BlockFace.UP);
Entity entity = mechanic.place(location, 0f, BlockFace.UP);
if (entity instanceof ItemFrame itemFrame)
return itemFrame;
else {