Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<groupId>com.alpsbte</groupId>
<artifactId>PlotSystem</artifactId>
<version>4.1.4</version>
<version>4.2.0</version>

<repositories>
<!-- JitPack -->
Expand Down Expand Up @@ -99,9 +99,9 @@
</dependency>
<!-- Multiverse Core -->
<dependency>
<groupId>com.onarandombox.multiversecore</groupId>
<artifactId>Multiverse-Core</artifactId>
<version>4.3.1</version>
<groupId>org.mvplugins.multiverse.core</groupId>
<artifactId>multiverse-core</artifactId>
<version>5.3.0</version>
<scope>provided</scope>
</dependency>
<!-- ParticleNativeAPI -->
Expand All @@ -115,7 +115,7 @@
<dependency>
<groupId>com.alpsbte</groupId>
<artifactId>canvas</artifactId>
<version>1.1</version>
<version>1.3</version>
<scope>compile</scope>
</dependency>
<!-- HeadDB -->
Expand All @@ -136,7 +136,7 @@
<dependency>
<groupId>com.alpsbte.alpslib</groupId>
<artifactId>alpslib-io</artifactId>
<version>1.0.38</version>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>com.alpsbte.alpslib</groupId>
Expand All @@ -147,7 +147,7 @@
<dependency>
<groupId>com.alpsbte.alpslib</groupId>
<artifactId>alpslib-utils</artifactId>
<version>1.3.4</version>
<version>1.3.5</version>
<scope>compile</scope>
</dependency>
<!-- MariaDB Connector -->
Expand Down Expand Up @@ -187,24 +187,30 @@
</dependency>
<!-- Protocol Lib -->
<dependency>
<groupId>com.comphenix.protocol</groupId>
<groupId>net.dmulloy2</groupId>
<artifactId>ProtocolLib</artifactId>
<version>5.1.0</version>
<version>5.4.0</version>
<scope>provided</scope>
</dependency>
<!-- Fancy NPCs -->
<dependency>
<groupId>de.oliver</groupId>
<artifactId>FancyNpcs</artifactId>
<version>2.4.0</version>
<version>2.7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>li.cinnazeyy</groupId>
<artifactId>LangLibs</artifactId>
<version>1.5</version>
<artifactId>LangLibs-API</artifactId>
<version>1.5.1</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.20.0</version>
</dependency>
</dependencies>
<!-- Fast Async World Edit -->
<dependencyManagement>
Expand Down Expand Up @@ -246,7 +252,7 @@
<!-- IMPORTANT: Plugin Building Path -->
<sourceDirectory>src/main/java/</sourceDirectory>
<!-- IMPORTANT: Output File Name -->
<finalName>${project.artifactId}-${project.version}-${build.number}</finalName>
<finalName>${project.artifactId}-${project.version}${build.number}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/alpsbte/plotsystem/PlotSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import com.alpsbte.plotsystem.utils.io.LangUtil;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import de.oliver.fancynpcs.api.FancyNpcsPlugin;
Expand All @@ -61,6 +60,7 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.ipvp.canvas.MenuFunctionListener;
import org.jetbrains.annotations.NotNull;
import org.mvplugins.multiverse.core.MultiverseCoreApi;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -346,8 +346,8 @@ public static String getMultiverseInventoriesConfigPath(String worldName) {
/**
* @return Multiverse-Core instance
*/
public static MultiverseCore getMultiverseCore() {
return (MultiverseCore) plugin.getServer().getPluginManager().getPlugin("Multiverse-Core");
public static MultiverseCoreApi getMultiverseCore() {
return MultiverseCoreApi.get();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
package com.alpsbte.plotsystem.core.system.plot.generator;

import com.alpsbte.plotsystem.PlotSystem;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.flags.Flags;
Expand All @@ -37,7 +35,12 @@
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import org.bukkit.*;
import org.bukkit.entity.SpawnCategory;
import org.bukkit.generator.ChunkGenerator;
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
import org.mvplugins.multiverse.core.world.WorldManager;
import org.mvplugins.multiverse.core.world.options.ImportWorldOptions;
import org.mvplugins.multiverse.external.vavr.control.Option;

import javax.annotation.Nonnull;
import java.util.Objects;
Expand All @@ -46,7 +49,7 @@
import static net.kyori.adventure.text.Component.text;

public class PlotWorldGenerator {
private final MVWorldManager worldManager = PlotSystem.DependencyManager.getMultiverseCore().getMVWorldManager();
private final WorldManager worldManager = PlotSystem.DependencyManager.getMultiverseCore().getWorldManager();
private WorldCreator worldCreator;

private final String worldName;
Expand Down Expand Up @@ -74,17 +77,26 @@ protected void generateWorld() {
protected void createMultiverseWorld() throws Exception {
// Check if world creator is configured and add new world to multiverse world manager
if (worldCreator != null) {
if (!worldManager.isMVWorld(worldName))
worldManager.addWorld(worldName, environment, null, worldType, false,
"VoidGen:{\"caves\":false,\"decoration\":false,\"mobs\":false,\"structures\":false}", false);
if (!worldManager.isLoadedWorld(worldName)) {
worldManager.importWorld(ImportWorldOptions.worldName(worldName)
.environment(environment)
.generator("VoidGen:{\"caves\":false,\"decoration\":false,\"mobs\":false,\"structures\":false}")
.useSpawnAdjust(false)
);
}
} else {
throw new Exception("World Creator is not configured");
}
}

protected void configureWorld() {
World bukkitWorld = Bukkit.getWorld(worldName);
MultiverseWorld mvWorld = worldManager.getMVWorld(bukkitWorld);
Option<LoadedMultiverseWorld> mvWorld = worldManager.getLoadedWorld(worldName);

if (mvWorld.isEmpty()) {
PlotSystem.getPlugin().getComponentLogger().warn(text("Multiverse world" + worldName + " is not loaded! Skipping world configuration..."));
return;
}

// Set world time to midday
assert bukkitWorld != null;
Expand All @@ -100,14 +112,14 @@ protected void configureWorld() {
bukkitWorld.setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false);

// Configure multiverse world
mvWorld.setAllowFlight(true);
mvWorld.setGameMode(GameMode.CREATIVE);
mvWorld.setEnableWeather(false);
mvWorld.setDifficulty(Difficulty.PEACEFUL);
mvWorld.setAllowAnimalSpawn(false);
mvWorld.setAllowMonsterSpawn(false);
mvWorld.setAutoLoad(false);
mvWorld.setKeepSpawnInMemory(false);
mvWorld.get().setAllowFlight(true);
mvWorld.get().setGameMode(GameMode.CREATIVE);
mvWorld.get().setAllowWeather(false);
mvWorld.get().setDifficulty(Difficulty.PEACEFUL);
mvWorld.get().getEntitySpawnConfig().getSpawnCategoryConfig(SpawnCategory.ANIMAL).setSpawn(false);
mvWorld.get().getEntitySpawnConfig().getSpawnCategoryConfig(SpawnCategory.MONSTER).setSpawn(false);
mvWorld.get().setAutoLoad(false);
mvWorld.get().setKeepSpawnInMemory(false);
worldManager.saveWorldsConfig();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ public static boolean isPlayerOnPlot(@NotNull AbstractPlot plot, Player player)
return null;
}

public static boolean isPlotWorld(World world) {
return PlotSystem.DependencyManager.getMultiverseCore().getMVWorldManager().isMVWorld(world) && (PlotWorld.isOnePlotWorld(world.getName()) || PlotWorld.isCityPlotWorld(world.getName()));
public static boolean isPlotWorld(@NotNull World world) {
return PlotSystem.DependencyManager.getMultiverseCore().getWorldManager().isLoadedWorld(world) && (PlotWorld.isOnePlotWorld(world.getName()) || PlotWorld.isCityPlotWorld(world.getName()));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.alpsbte.plotsystem.core.system.plot.generator.AbstractPlotGenerator;
import com.alpsbte.plotsystem.utils.Utils;
import com.fastasyncworldedit.core.FaweAPI;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.BlockVector3;
Expand All @@ -46,6 +45,8 @@
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.mvplugins.multiverse.core.MultiverseCoreApi;
import org.mvplugins.multiverse.core.world.options.DeleteWorldOptions;

import java.io.File;
import java.io.IOException;
Expand All @@ -59,7 +60,7 @@ public class PlotWorld implements IWorld {
public static final int MAX_WORLD_HEIGHT = 256;
public static final int MIN_WORLD_HEIGHT = 5;

private final MultiverseCore mvCore = PlotSystem.DependencyManager.getMultiverseCore();
private final MultiverseCoreApi mvCore = PlotSystem.DependencyManager.getMultiverseCore();
private final String worldName;
private final AbstractPlot plot;

Expand All @@ -81,7 +82,9 @@ public <T extends AbstractPlotGenerator> boolean regenWorld(@NotNull Class<T> ge
@Override
public boolean deleteWorld() {
if (isWorldGenerated() && loadWorld()) {
if (mvCore.getMVWorldManager().deleteWorld(getWorldName(), true, true) && mvCore.saveWorldConfig()) {
if (Boolean.TRUE.equals(mvCore.getWorldManager().getWorld(getWorldName())
.map(world -> mvCore.getWorldManager().deleteWorld(DeleteWorldOptions.world(world)).isSuccess())
.getOrElse(false)) && mvCore.getWorldManager().saveWorldsConfig().isSuccess()) {
try {
File multiverseInventoriesConfig = new File(PlotSystem.DependencyManager.getMultiverseInventoriesConfigPath(getWorldName()));
File worldGuardConfig = new File(PlotSystem.DependencyManager.getWorldGuardConfigPath(getWorldName()));
Expand All @@ -102,7 +105,7 @@ public boolean loadWorld() {
if (isWorldGenerated()) {
if (isWorldLoaded()) {
return true;
} else return mvCore.getMVWorldManager().loadWorld(getWorldName()) || isWorldLoaded();
} else return mvCore.getWorldManager().loadWorld(getWorldName()).isSuccess() || isWorldLoaded();
} else PlotSystem.getPlugin().getComponentLogger().warn(text("Could not load world " + worldName + " because it is not generated!"));
return false;
}
Expand Down Expand Up @@ -145,7 +148,7 @@ public Location getSpawnPoint(BlockVector3 plotVector) {
}

// Set spawn point 1 block above the highest block at the spawn location
spawnLocation.setY(getBukkitWorld().getHighestBlockYAt((int) spawnLocation.getX(), (int) spawnLocation.getZ()) + 1);
spawnLocation.setY(getBukkitWorld().getHighestBlockYAt((int) spawnLocation.getX(), (int) spawnLocation.getZ()) + 1d);
return spawnLocation;
}
return null;
Expand Down Expand Up @@ -199,7 +202,7 @@ public boolean isWorldLoaded() {

@Override
public boolean isWorldGenerated() {
return mvCore.getMVWorldManager().getMVWorld(worldName) != null || mvCore.getMVWorldManager().getUnloadedWorlds().contains(worldName);
return mvCore.getWorldManager().getWorld(worldName).isDefined();
}

private ProtectedRegion getRegion(String regionName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import de.oliver.fancynpcs.api.FancyNpcsPlugin;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcData;
import de.oliver.fancynpcs.api.utils.SkinFetcher;
import de.oliver.fancynpcs.api.skins.SkinData;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
Expand All @@ -44,7 +44,7 @@ public class TutorialNPC {
private final String id;
private final String displayName;
private final String interactionPrompt;
private final SkinFetcher.SkinData skin;
private final SkinData skin;

private Npc npc;
private TutorialNPCHologram hologram;
Expand All @@ -61,7 +61,7 @@ public TutorialNPC(String npcId, String npcDisplayName, String npcInteractionPro
this.id = npcId;
this.displayName = npcDisplayName;
this.interactionPrompt = npcInteractionPrompt;
this.skin = new SkinFetcher.SkinData(npcId, npcSknTexture, npcSkinSignature);
this.skin = new SkinData(npcId, SkinData.SkinVariant.AUTO, npcSknTexture, npcSkinSignature);
}

/**
Expand All @@ -74,7 +74,7 @@ public void create(Location spawnPos) {

NpcData npcData = new NpcData(id, UUID.randomUUID(), spawnPos);
npc = FancyNpcsPlugin.get().getNpcAdapter().apply(npcData);
npc.getData().setSkin(skin);
npc.getData().setSkinData(skin);
npc.getData().setDisplayName(EMPTY_TAG);
npc.getData().setTurnToPlayer(true);
npc.setSaveToFile(false);
Expand Down Expand Up @@ -158,7 +158,7 @@ public String getInteractionPrompt() {
return interactionPrompt;
}

public SkinFetcher.SkinData getSkin() {
public SkinData getSkin() {
return skin;
}
}
9 changes: 5 additions & 4 deletions src/main/java/com/alpsbte/plotsystem/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import com.alpsbte.plotsystem.utils.io.LangPaths;
import com.alpsbte.plotsystem.utils.io.LangUtil;
import com.alpsbte.plotsystem.utils.items.CustomHeads;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.sk89q.worldedit.math.BlockVector2;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
Expand All @@ -53,6 +52,8 @@
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
import org.mvplugins.multiverse.external.vavr.control.Option;

import java.sql.SQLException;
import java.time.LocalDateTime;
Expand All @@ -79,14 +80,14 @@ public static Location getSpawnLocation() {

if (!Objects.requireNonNull(config.getString(ConfigPaths.SPAWN_WORLD)).equalsIgnoreCase("default")) {
try {
MultiverseWorld spawnWorld = PlotSystem.DependencyManager.getMultiverseCore().getMVWorldManager().getMVWorld(config.getString(ConfigPaths.SPAWN_WORLD));
return spawnWorld.getSpawnLocation();
Option<LoadedMultiverseWorld> spawnWorld = PlotSystem.DependencyManager.getMultiverseCore().getWorldManager().getLoadedWorld(config.getString(ConfigPaths.SPAWN_WORLD));
return spawnWorld.get().getSpawnLocation();
} catch (Exception ignore) {
PlotSystem.getPlugin().getComponentLogger().warn(text("Could not find %s in multiverse config!"), ConfigPaths.SPAWN_WORLD);
}
}

return PlotSystem.DependencyManager.getMultiverseCore().getMVWorldManager().getSpawnWorld().getSpawnLocation();
return PlotSystem.DependencyManager.getMultiverseCore().getWorldManager().getDefaultWorld().get().getSpawnLocation();
}

public static void updatePlayerInventorySlots(Player player) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
main: com.alpsbte.plotsystem.PlotSystem
version: 4.1.3
version: 4.2.0
api-version: "1.21"
name: Plot-System
author: R3tuxn & Cinnazeyy
Expand Down