mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-19 15:09:25 +00:00
3.6.29
This commit is contained in:
@@ -31,6 +31,7 @@ import net.momirealms.customcrops.api.core.world.Pos3;
|
||||
import net.momirealms.customcrops.api.event.DropItemActionEvent;
|
||||
import net.momirealms.customcrops.api.misc.value.MathValue;
|
||||
import net.momirealms.customcrops.api.util.EventUtils;
|
||||
import net.momirealms.customcrops.api.util.LocationUtils;
|
||||
import net.momirealms.customcrops.api.util.PlayerUtils;
|
||||
import net.momirealms.customcrops.common.util.RandomUtils;
|
||||
import org.bukkit.Location;
|
||||
@@ -87,7 +88,7 @@ public class ActionDropItem<T> extends AbstractBuiltInAction<T> {
|
||||
if (toInv && player != null) {
|
||||
PlayerUtils.giveItem(player, itemToDrop, itemToDrop.getAmount());
|
||||
} else {
|
||||
location.getWorld().dropItemNaturally(location, itemToDrop);
|
||||
location.getWorld().dropItemNaturally(LocationUtils.toBlockCenterLocation(location), itemToDrop);
|
||||
}
|
||||
}
|
||||
}, location);
|
||||
|
||||
@@ -32,6 +32,7 @@ import net.momirealms.customcrops.api.core.world.Pos3;
|
||||
import net.momirealms.customcrops.api.event.QualityCropActionEvent;
|
||||
import net.momirealms.customcrops.api.misc.value.MathValue;
|
||||
import net.momirealms.customcrops.api.util.EventUtils;
|
||||
import net.momirealms.customcrops.api.util.LocationUtils;
|
||||
import net.momirealms.customcrops.api.util.PlayerUtils;
|
||||
import net.momirealms.customcrops.common.util.RandomUtils;
|
||||
import org.bukkit.Location;
|
||||
@@ -94,7 +95,7 @@ public class ActionQualityCrops<T> extends AbstractBuiltInAction<T> {
|
||||
if (toInv && player != null) {
|
||||
PlayerUtils.giveItem(player, itemStack, itemStack.getAmount());
|
||||
} else {
|
||||
location.getWorld().dropItemNaturally(location, itemStack);
|
||||
location.getWorld().dropItemNaturally(LocationUtils.toBlockCenterLocation(location), itemStack);
|
||||
}
|
||||
}
|
||||
}, location);
|
||||
|
||||
@@ -55,6 +55,14 @@ public interface WorldManager extends Reloadable {
|
||||
*/
|
||||
int getDate(World world);
|
||||
|
||||
/**
|
||||
* Loads a CustomCrops world
|
||||
*
|
||||
* @param world The CustomCrops world
|
||||
* @return The loaded CustomCropsWorld instance, it might be another instance if it's already loaded
|
||||
*/
|
||||
CustomCropsWorld<?> loadWorld(CustomCropsWorld<?> world);
|
||||
|
||||
/**
|
||||
* Loads a CustomCrops world based on the specified Bukkit world.
|
||||
*
|
||||
|
||||
@@ -30,6 +30,7 @@ import net.momirealms.customcrops.api.util.TagUtils;
|
||||
import net.momirealms.customcrops.common.helper.GsonHelper;
|
||||
import net.momirealms.customcrops.common.util.Key;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -84,7 +85,7 @@ public class SlimeWorldAdaptorR1 extends AbstractWorldAdaptor<SlimeWorld> implem
|
||||
public void onWorldLoad(LoadSlimeWorldEvent event) {
|
||||
World world = Bukkit.getWorld(event.getSlimeWorld().getName());
|
||||
if (!BukkitCustomCropsPlugin.getInstance().getWorldManager().isMechanicEnabled(world)) return;
|
||||
BukkitCustomCropsPlugin.getInstance().getWorldManager().loadWorld(world);
|
||||
BukkitCustomCropsPlugin.getInstance().getWorldManager().loadWorld(adapt(event.getSlimeWorld()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=3.6.28
|
||||
project_version=3.6.29
|
||||
config_version=42
|
||||
project_group=net.momirealms
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class BukkitWorldManager implements WorldManager, Listener {
|
||||
|
||||
private final BukkitCustomCropsPlugin plugin;
|
||||
private final TreeSet<WorldAdaptor<?>> adaptors = new TreeSet<>();
|
||||
private final ConcurrentHashMap<String, CustomCropsWorld<?>> worlds = new ConcurrentHashMap<>();
|
||||
@@ -193,6 +192,25 @@ public class BukkitWorldManager implements WorldManager, Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomCropsWorld<?> loadWorld(CustomCropsWorld<?> world) {
|
||||
Optional<CustomCropsWorld<?>> optionalWorld = getWorld(world.worldName());
|
||||
if (optionalWorld.isPresent()) {
|
||||
CustomCropsWorld<?> customCropsWorld = optionalWorld.get();
|
||||
customCropsWorld.setting(Optional.ofNullable(worldSettings.get(world.worldName())).orElse(defaultWorldSetting));
|
||||
return customCropsWorld;
|
||||
}
|
||||
world.setting(Optional.ofNullable(worldSettings.get(world.worldName())).orElse(defaultWorldSetting));
|
||||
world.setTicking(true);
|
||||
this.worlds.put(world.worldName(), world);
|
||||
for (Chunk chunk : world.bukkitWorld().getLoadedChunks()) {
|
||||
ChunkPos pos = ChunkPos.fromBukkitChunk(chunk);
|
||||
loadLoadedChunk(world, pos);
|
||||
notifyOfflineUpdates(world, pos);
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomCropsWorld<?> loadWorld(World world) {
|
||||
Optional<CustomCropsWorld<?>> optionalWorld = getWorld(world);
|
||||
|
||||
Reference in New Issue
Block a user