mirror of
https://github.com/plexusorg/Module-TFMExtras.git
synced 2024-12-22 17:27:36 +00:00
Add slime world support for per player worlds
Move package to dev.plex.extras to prevent any possible conflicts with main plugin
This commit is contained in:
parent
12e4dde547
commit
ea551c5427
@ -11,6 +11,9 @@ repositories {
|
|||||||
maven {
|
maven {
|
||||||
url = uri("https://nexus.telesphoreo.me/repository/plex/")
|
url = uri("https://nexus.telesphoreo.me/repository/plex/")
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
url = uri("https://repo.infernalsuite.com/repository/maven-snapshots/")
|
||||||
|
}
|
||||||
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
@ -21,6 +24,9 @@ dependencies {
|
|||||||
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
|
||||||
implementation("org.apache.commons:commons-lang3:3.12.0")
|
implementation("org.apache.commons:commons-lang3:3.12.0")
|
||||||
compileOnly("dev.plex:server:1.3")
|
compileOnly("dev.plex:server:1.3")
|
||||||
|
compileOnly("com.infernalsuite.aswm:api:1.20-R0.1-SNAPSHOT") {
|
||||||
|
exclude(group="com.flowpowered")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "dev.plex"
|
group = "dev.plex"
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
package dev.plex;
|
package dev.plex.extras;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.reflect.ClassPath;
|
import com.google.common.reflect.ClassPath;
|
||||||
|
import dev.plex.extras.hook.SlimeWorldHook;
|
||||||
|
import dev.plex.extras.listener.PlayerListener;
|
||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.config.ModuleConfig;
|
import dev.plex.config.ModuleConfig;
|
||||||
import dev.plex.jumppads.JumpPads;
|
import dev.plex.extras.jumppads.JumpPads;
|
||||||
import dev.plex.listener.JumpPadsListener;
|
import dev.plex.extras.listener.JumpPadsListener;
|
||||||
import dev.plex.listener.PlayerListener;
|
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.module.PlexModule;
|
import dev.plex.module.PlexModule;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
@ -33,6 +34,9 @@ public class TFMExtras extends PlexModule
|
|||||||
@Getter
|
@Getter
|
||||||
private ModuleConfig config;
|
private ModuleConfig config;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final SlimeWorldHook slimeWorldHook = new SlimeWorldHook();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load()
|
public void load()
|
||||||
{
|
{
|
||||||
@ -46,12 +50,14 @@ public class TFMExtras extends PlexModule
|
|||||||
@Override
|
@Override
|
||||||
public void enable()
|
public void enable()
|
||||||
{
|
{
|
||||||
registerListener(new JumpPadsListener());
|
if (slimeWorldHook.plugin() != null)
|
||||||
registerListener(new PlayerListener());
|
|
||||||
|
|
||||||
getClassesFrom("dev.plex.command").forEach(aClass ->
|
|
||||||
{
|
{
|
||||||
if (aClass.getSuperclass() == PlexCommand.class && aClass.isAnnotationPresent(CommandParameters.class) && aClass.isAnnotationPresent(CommandPermissions.class))
|
slimeWorldHook.onEnable(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
getClassesFrom("dev.plex.extras.command").forEach(aClass ->
|
||||||
|
{
|
||||||
|
if (PlexCommand.class.isAssignableFrom(aClass) && aClass.isAnnotationPresent(CommandParameters.class) && aClass.isAnnotationPresent(CommandPermissions.class))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -65,9 +71,9 @@ public class TFMExtras extends PlexModule
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
getClassesFrom("dev.plex.listener").forEach(aClass ->
|
getClassesFrom("dev.plex.extras.listener").forEach(aClass ->
|
||||||
{
|
{
|
||||||
if (aClass.getSuperclass() == PlexListener.class)
|
if (PlexListener.class.isAssignableFrom(aClass))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -88,12 +94,17 @@ public class TFMExtras extends PlexModule
|
|||||||
addDefaultMessage("attributeList", "<gold>All possible attributes: <yellow>{0}", "0 - The attribute list, each split by a new line");
|
addDefaultMessage("attributeList", "<gold>All possible attributes: <yellow>{0}", "0 - The attribute list, each split by a new line");
|
||||||
addDefaultMessage("modifiedAutoClear", "<gold>{0} will {1} have their inventory cleared when they join.", "0 - The player who will have their inventory cleared on join", "1 - Whether they had this option toggled (returns: 'no longer', 'now')");
|
addDefaultMessage("modifiedAutoClear", "<gold>{0} will {1} have their inventory cleared when they join.", "0 - The player who will have their inventory cleared on join", "1 - Whether they had this option toggled (returns: 'no longer', 'now')");
|
||||||
addDefaultMessage("modifiedAutoTeleport", "<gold>{0} will {1} be teleported automatically when they join.", "0 - The player to be teleported automatically", "1 - Whether they had this option toggled (returns: 'no longer', 'now')");
|
addDefaultMessage("modifiedAutoTeleport", "<gold>{0} will {1} be teleported automatically when they join.", "0 - The player to be teleported automatically", "1 - Whether they had this option toggled (returns: 'no longer', 'now')");
|
||||||
|
addDefaultMessage("createdPlayerWorld", "<green>Welcome to the server! We've created you a new private world where you can invite your friends! View how to use this using /myworld!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable()
|
public void disable()
|
||||||
{
|
{
|
||||||
// Unregistering listeners / commands is handled by Plex
|
// Unregistering listeners / commands is handled by Plex
|
||||||
|
if (slimeWorldHook.plugin() != null)
|
||||||
|
{
|
||||||
|
slimeWorldHook.onDisable(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getRandomLocation(World world)
|
public static Location getRandomLocation(World world)
|
@ -1,6 +1,7 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
import dev.plex.TFMExtras;
|
import dev.plex.extras.TFMExtras;
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
@ -1,5 +1,6 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
@ -1,7 +1,8 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
import dev.plex.TFMExtras;
|
import dev.plex.extras.TFMExtras;
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.PlayerNotFoundException;
|
import dev.plex.command.exception.PlayerNotFoundException;
|
@ -1,7 +1,8 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
import dev.plex.TFMExtras;
|
import dev.plex.extras.TFMExtras;
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.PlayerNotFoundException;
|
import dev.plex.command.exception.PlayerNotFoundException;
|
@ -1,5 +1,6 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.punishment.Punishment;
|
import dev.plex.punishment.Punishment;
|
@ -1,5 +1,6 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
@ -1,6 +1,7 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
@ -1,5 +1,6 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
@ -1,5 +1,6 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
@ -1,5 +1,6 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
@ -1,6 +1,7 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
@ -1,5 +1,6 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
@ -1,11 +1,12 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
import dev.plex.TFMExtras;
|
import dev.plex.extras.TFMExtras;
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.jumppads.JumpPads;
|
import dev.plex.extras.jumppads.JumpPads;
|
||||||
import dev.plex.jumppads.Mode;
|
import dev.plex.extras.jumppads.Mode;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
@ -1,5 +1,6 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.extras.command;
|
||||||
|
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
@ -26,7 +27,7 @@ public class RandomFishCommand extends PlexCommand
|
|||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
|
||||||
{
|
{
|
||||||
@Nullable Block block = player.getTargetBlock(15);
|
@Nullable Block block = player.getTargetBlockExact(15);
|
||||||
if (block == null)
|
if (block == null)
|
||||||
{
|
{
|
||||||
return MiniMessage.miniMessage().deserialize("<red>There is no block within 15 blocks of you.");
|
return MiniMessage.miniMessage().deserialize("<red>There is no block within 15 blocks of you.");
|
16
src/main/java/dev/plex/extras/hook/IHook.java
Normal file
16
src/main/java/dev/plex/extras/hook/IHook.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package dev.plex.extras.hook;
|
||||||
|
|
||||||
|
import dev.plex.extras.TFMExtras;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @since 2:16 PM [23-08-2023]
|
||||||
|
*/
|
||||||
|
public interface IHook<T> {
|
||||||
|
|
||||||
|
void onEnable(TFMExtras module);
|
||||||
|
|
||||||
|
void onDisable(TFMExtras module);
|
||||||
|
|
||||||
|
T plugin();
|
||||||
|
}
|
193
src/main/java/dev/plex/extras/hook/SlimeWorldHook.java
Normal file
193
src/main/java/dev/plex/extras/hook/SlimeWorldHook.java
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
package dev.plex.extras.hook;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import com.infernalsuite.aswm.api.SlimePlugin;
|
||||||
|
import com.infernalsuite.aswm.api.exceptions.*;
|
||||||
|
import com.infernalsuite.aswm.api.loaders.SlimeLoader;
|
||||||
|
import com.infernalsuite.aswm.api.world.SlimeWorld;
|
||||||
|
import com.infernalsuite.aswm.api.world.properties.SlimeProperties;
|
||||||
|
import com.infernalsuite.aswm.api.world.properties.SlimePropertyMap;
|
||||||
|
import dev.plex.extras.TFMExtras;
|
||||||
|
import dev.plex.util.PlexLog;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameRule;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @since 2:19 PM [23-08-2023]
|
||||||
|
*/
|
||||||
|
public class SlimeWorldHook implements IHook<SlimePlugin>
|
||||||
|
{
|
||||||
|
private static final String WORLD_NOT_FOUND = "<red>This world could not be found!";
|
||||||
|
private static final String STORAGE_FAILURE = "<red>This world cannot be stored!";
|
||||||
|
|
||||||
|
private final Set<String> LOADED_WORLDS = Sets.newHashSet();
|
||||||
|
|
||||||
|
private SlimeLoader loader;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable(TFMExtras module)
|
||||||
|
{
|
||||||
|
if (plugin() == null)
|
||||||
|
{
|
||||||
|
PlexLog.error("Cannot find SlimeWorldManager plugin");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlexLog.log("<green>Enabling SWM Hook");
|
||||||
|
|
||||||
|
this.loader = plugin().getLoader("mysql");
|
||||||
|
this.loadAllWorlds();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable(TFMExtras module)
|
||||||
|
{
|
||||||
|
PlexLog.log("<green>Disabling SWM Hook");
|
||||||
|
AtomicInteger i = new AtomicInteger();
|
||||||
|
LOADED_WORLDS.forEach(s ->
|
||||||
|
{
|
||||||
|
final World world = Bukkit.getWorld(s);
|
||||||
|
if (world != null)
|
||||||
|
{
|
||||||
|
world.save();
|
||||||
|
i.getAndIncrement();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
PlexLog.log("<green>SWM Hook saved " + i.get() + " worlds");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadAllWorlds()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.loader.listWorlds().forEach(s ->
|
||||||
|
{
|
||||||
|
final SlimePropertyMap slimePropertyMap = new SlimePropertyMap();
|
||||||
|
slimePropertyMap.setValue(SlimeProperties.PVP, false);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SlimeWorld world = this.plugin().loadWorld(this.loader, s, false, slimePropertyMap);
|
||||||
|
this.plugin().loadWorld(world);
|
||||||
|
this.loader.unlockWorld(s);
|
||||||
|
}
|
||||||
|
catch (UnknownWorldException | WorldLockedException | CorruptedWorldException | NewerFormatException | IllegalArgumentException ex)
|
||||||
|
{
|
||||||
|
PlexLog.error(ex.getMessage());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
PlexLog.error(STORAGE_FAILURE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final World world = Bukkit.getWorld(s);
|
||||||
|
if (world == null)
|
||||||
|
{
|
||||||
|
PlexLog.error(WORLD_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
|
||||||
|
world.setGameRule(GameRule.DISABLE_RAIDS, true);
|
||||||
|
world.setGameRule(GameRule.DO_INSOMNIA, false);
|
||||||
|
world.setGameRule(GameRule.DO_FIRE_TICK, false);
|
||||||
|
world.setSpawnLocation(0, 130, 0);
|
||||||
|
world.setAutoSave(true);
|
||||||
|
|
||||||
|
LOADED_WORLDS.add(s);
|
||||||
|
|
||||||
|
double configuratedSize = TFMExtras.getModule().getConfig().getDouble("player-worlds.size");
|
||||||
|
world.getWorldBorder().setCenter(world.getSpawnLocation());
|
||||||
|
world.getWorldBorder().setSize(configuratedSize == 0 ? 500 : configuratedSize);
|
||||||
|
world.getWorldBorder().setDamageAmount(0);
|
||||||
|
world.getWorldBorder().setDamageBuffer(0);
|
||||||
|
PlexLog.debug("Loaded {0}", s);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (IOException | IllegalArgumentException ex)
|
||||||
|
{
|
||||||
|
PlexLog.error(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pair<World, Boolean> createPlayerWorld(UUID uuid)
|
||||||
|
{
|
||||||
|
final SlimePropertyMap slimePropertyMap = new SlimePropertyMap();
|
||||||
|
slimePropertyMap.setValue(SlimeProperties.PVP, false);
|
||||||
|
|
||||||
|
boolean newWorld = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
slimePropertyMap.setValue(SlimeProperties.SPAWN_X, 0);
|
||||||
|
slimePropertyMap.setValue(SlimeProperties.SPAWN_Y, 130);
|
||||||
|
slimePropertyMap.setValue(SlimeProperties.SPAWN_Z, 0);
|
||||||
|
final SlimeWorld slimeWorld = this.plugin().createEmptyWorld(this.loader, uuid.toString(), false, slimePropertyMap);
|
||||||
|
this.plugin().loadWorld(slimeWorld);
|
||||||
|
newWorld = true;
|
||||||
|
}
|
||||||
|
catch (WorldAlreadyExistsException e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SlimeWorld world = this.plugin().loadWorld(this.loader, uuid.toString(), false, slimePropertyMap);
|
||||||
|
this.plugin().loadWorld(world);
|
||||||
|
this.loader.unlockWorld(uuid.toString());
|
||||||
|
}
|
||||||
|
catch (WorldLockedException | CorruptedWorldException | NewerFormatException | UnknownWorldException |
|
||||||
|
IOException | IllegalArgumentException ex)
|
||||||
|
{
|
||||||
|
PlexLog.error(ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
PlexLog.error(STORAGE_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
final World world = Bukkit.getWorld(uuid.toString());
|
||||||
|
if (world == null)
|
||||||
|
{
|
||||||
|
PlexLog.error(WORLD_NOT_FOUND);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
|
||||||
|
world.setGameRule(GameRule.DISABLE_RAIDS, true);
|
||||||
|
world.setGameRule(GameRule.DO_INSOMNIA, false);
|
||||||
|
world.setGameRule(GameRule.DO_FIRE_TICK, false);
|
||||||
|
world.setSpawnLocation(0, 130, 0);
|
||||||
|
world.setAutoSave(true);
|
||||||
|
|
||||||
|
if (newWorld)
|
||||||
|
{
|
||||||
|
world.getBlockAt(0, 128, 0).setType(Material.STONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOADED_WORLDS.add(uuid.toString());
|
||||||
|
|
||||||
|
double configuratedSize = TFMExtras.getModule().getConfig().getDouble("player-worlds.size");
|
||||||
|
world.getWorldBorder().setCenter(world.getSpawnLocation());
|
||||||
|
world.getWorldBorder().setSize(configuratedSize == 0 ? 500 : configuratedSize);
|
||||||
|
world.getWorldBorder().setDamageAmount(0);
|
||||||
|
world.getWorldBorder().setDamageBuffer(0);
|
||||||
|
|
||||||
|
return Pair.of(world, newWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SlimePlugin plugin()
|
||||||
|
{
|
||||||
|
return (SlimePlugin) Bukkit.getPluginManager().getPlugin("SlimeWorldManager");
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package dev.plex.jumppads;
|
package dev.plex.extras.jumppads;
|
||||||
|
|
||||||
import dev.plex.TFMExtras;
|
import dev.plex.extras.TFMExtras;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Tag;
|
import org.bukkit.Tag;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
@ -1,4 +1,4 @@
|
|||||||
package dev.plex.jumppads;
|
package dev.plex.extras.jumppads;
|
||||||
|
|
||||||
public enum Mode
|
public enum Mode
|
||||||
{
|
{
|
@ -1,8 +1,9 @@
|
|||||||
package dev.plex.listener;
|
package dev.plex.extras.listener;
|
||||||
|
|
||||||
import dev.plex.TFMExtras;
|
import dev.plex.extras.TFMExtras;
|
||||||
import dev.plex.jumppads.JumpPads;
|
import dev.plex.extras.jumppads.JumpPads;
|
||||||
import dev.plex.jumppads.Mode;
|
import dev.plex.extras.jumppads.Mode;
|
||||||
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
@ -1,7 +1,12 @@
|
|||||||
package dev.plex.listener;
|
package dev.plex.extras.listener;
|
||||||
|
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.TFMExtras;
|
import dev.plex.extras.TFMExtras;
|
||||||
|
import dev.plex.listener.PlexListener;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@ -34,4 +39,15 @@ public class PlayerListener extends PlexListener
|
|||||||
}.runTaskLater(Plex.get(), 1);
|
}.runTaskLater(Plex.get(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void createPlayerWorld(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final Pair<World, Boolean> world = TFMExtras.getModule().getSlimeWorldHook().createPlayerWorld(player.getUniqueId());
|
||||||
|
if (world.getRight())
|
||||||
|
{
|
||||||
|
player.sendMessage(PlexUtils.messageComponent("createdPlayerWorld"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
name: Module-TFMExtras
|
name: Module-TFMExtras
|
||||||
main: dev.plex.TFMExtras
|
main: dev.plex.extras.TFMExtras
|
||||||
description: TFM extras for Plex
|
description: TFM extras for Plex
|
||||||
version: 1.3
|
version: 1.3
|
@ -12,3 +12,5 @@ server:
|
|||||||
teleport-on-join:
|
teleport-on-join:
|
||||||
- "Taahh"
|
- "Taahh"
|
||||||
allow-unsafe-enchantments: true
|
allow-unsafe-enchantments: true
|
||||||
|
player-worlds:
|
||||||
|
size: 500
|
Loading…
Reference in New Issue
Block a user