mirror of
https://github.com/plexusorg/Module-TFMExtras.git
synced 2026-06-04 07:36:54 +00:00
Remove AWSM
This commit is contained in:
@@ -7,10 +7,6 @@ import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.config.ModuleConfig;
|
||||
import dev.plex.extras.command.slime.MyWorldCommand;
|
||||
import dev.plex.extras.command.slime.SlimeManagerCommand;
|
||||
import dev.plex.extras.hook.SlimeWorldHook;
|
||||
import dev.plex.extras.island.storage.IslandHandler;
|
||||
import dev.plex.extras.jumppads.JumpPads;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.module.PlexModule;
|
||||
@@ -35,12 +31,6 @@ public class TFMExtras extends PlexModule
|
||||
@Getter
|
||||
private ModuleConfig config;
|
||||
|
||||
@Getter
|
||||
private SlimeWorldHook slimeWorldHook;
|
||||
|
||||
@Getter
|
||||
private final IslandHandler islandHandler = new IslandHandler();
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
@@ -48,24 +38,12 @@ public class TFMExtras extends PlexModule
|
||||
config = new ModuleConfig(this, "tfmextras/config.yml", "config.yml");
|
||||
config.load();
|
||||
jumpPads = new JumpPads();
|
||||
if (enableIslands())
|
||||
{
|
||||
slimeWorldHook = new SlimeWorldHook();
|
||||
}
|
||||
// PlexLog.debug(String.valueOf(config.getInt("server.jumppad_strength")));
|
||||
// PlexLog.log("Test map: {0}", StringUtils.join(SQLUtil.createTable(Lists.newArrayList(), PlayerWorld.class), "\n"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable()
|
||||
{
|
||||
if (enableIslands())
|
||||
{
|
||||
slimeWorldHook.onEnable(this);
|
||||
registerCommand(new SlimeManagerCommand());
|
||||
registerCommand(new MyWorldCommand());
|
||||
}
|
||||
|
||||
getClassesFrom("dev.plex.extras.command").forEach(aClass ->
|
||||
{
|
||||
if (PlexCommand.class.isAssignableFrom(aClass) && aClass.isAnnotationPresent(CommandParameters.class) && aClass.isAnnotationPresent(CommandPermissions.class))
|
||||
@@ -110,17 +88,6 @@ public class TFMExtras extends PlexModule
|
||||
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("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 and visit it using /myworld goto!");
|
||||
addDefaultMessage("playerWorldExists", "<red>Hey! Your world seems to already exist, go to it using /myworld goto");
|
||||
addDefaultMessage("selfPlayerWorldNotFound", "<red>Hey! You don't seem to own a world yet. Go ahead and run /myworld create and then run /myworld for more help!");
|
||||
addDefaultMessage("playerWorldNotFound", "<red>Hey! This player's world does not seem to exist. Are they online?");
|
||||
addDefaultMessage("worldLoadError", "<red>Hey! It looks like something went wrong when this world was being loaded in, please try asking the player (or if it is yours, then rejoin) to rejoin and if not, tell the world owner to contact support on our <click:open_url:https://discord.gg/6QcT7K2Bkw><bold>Discord</bold></click>");
|
||||
addDefaultMessage("cannotAccessIsland", "<red>Unfortunately you cannot access this player's island!");
|
||||
addDefaultMessage("islandPermissionUpdated", "<green>Your island permission for {0} has been updated to {1}.", "0 - Permission name", "1 - New value");
|
||||
addDefaultMessage("cantModifyIsland", "<red>You can't modify this player's island!");
|
||||
addDefaultMessage("cantVisitIsland", "<red>You can't visit this player's island!");
|
||||
addDefaultMessage("islandMemberExists", "<red>This player is already a member of your island!");
|
||||
addDefaultMessage("receivedInviteForIsland", "<green>You have been invited to join "); //TODO: Finish this message... my laptop isn't liking minecraft so I can't do formatting for it, and do receivedInviteForIsland message
|
||||
addDefaultMessage("playersExpelled", "<gray>Pushed away players: <white><em>{0}", "0 - The list of players");
|
||||
addDefaultMessage("enchantList", "<dark_gray>All possible enchantments are for this item are: <gray>{0}", "0 - A comma-separated list of enchantment names");
|
||||
addDefaultMessage("enchantAddAll", "<gray>Added all possible enchantments for this item.");
|
||||
@@ -137,10 +104,6 @@ public class TFMExtras extends PlexModule
|
||||
public void disable()
|
||||
{
|
||||
// Unregistering listeners / commands is handled by Plex
|
||||
if (enableIslands())
|
||||
{
|
||||
slimeWorldHook.onDisable(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static Location getRandomLocation(World world)
|
||||
@@ -182,16 +145,4 @@ public class TFMExtras extends PlexModule
|
||||
return Collections.unmodifiableSet(classes);
|
||||
}
|
||||
|
||||
public boolean enableIslands()
|
||||
{
|
||||
try
|
||||
{
|
||||
Class.forName("com.infernalsuite.aswm.api.exceptions.UnknownWorldException");
|
||||
return true;
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
package dev.plex.extras.command.slime;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.PlayerNotFoundException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import dev.plex.extras.island.PlayerWorld;
|
||||
import dev.plex.extras.island.info.IslandPermissions;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "myworld", usage = "/<command> <create | goto | info | invite | remove | settings> [player]")
|
||||
@CommandPermissions(permission = "plex.tfmextras.myworld", source = RequiredCommandSource.IN_GAME)
|
||||
public class MyWorldCommand extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
|
||||
{
|
||||
assert player != null;
|
||||
if (args.length == 0)
|
||||
{
|
||||
return usage();
|
||||
}
|
||||
if (!TFMExtras.getModule().enableIslands())
|
||||
{
|
||||
return mmString("<red>Islands are not enabled on this server!");
|
||||
}
|
||||
switch (args[0].toLowerCase())
|
||||
{
|
||||
case "create" ->
|
||||
{
|
||||
if (TFMExtras.getModule().getSlimeWorldHook().isWorldLoaded(player.getUniqueId().toString()))
|
||||
{
|
||||
return messageComponent("playerWorldExists");
|
||||
}
|
||||
TFMExtras.getModule().getSlimeWorldHook().createPlayerWorld(player.getUniqueId());
|
||||
return messageComponent("createdPlayerWorld");
|
||||
}
|
||||
case "goto" ->
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (!TFMExtras.getModule().getSlimeWorldHook().isWorldLoaded(player.getUniqueId().toString()))
|
||||
{
|
||||
return messageComponent("selfPlayerWorldNotFound");
|
||||
}
|
||||
World world = Bukkit.getWorld(player.getUniqueId().toString());
|
||||
if (world == null)
|
||||
{
|
||||
return messageComponent("worldLoadError");
|
||||
}
|
||||
player.teleportAsync(world.getSpawnLocation());
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1f, 1f);
|
||||
return null;
|
||||
}
|
||||
final Player target = Bukkit.getPlayer(args[1]);
|
||||
if (target == null)
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
if (!TFMExtras.getModule().getSlimeWorldHook().isWorldLoaded(target.getUniqueId().toString()))
|
||||
{
|
||||
return messageComponent("playerWorldNotFound");
|
||||
}
|
||||
World world = Bukkit.getWorld(target.getUniqueId().toString());
|
||||
if (world == null)
|
||||
{
|
||||
return messageComponent("worldLoadError");
|
||||
}
|
||||
final PlayerWorld playerWorld = TFMExtras.getModule().getIslandHandler().loadedIslands().get(target.getUniqueId());
|
||||
if (playerWorld != null)
|
||||
{
|
||||
if (playerWorld.visitPermission() == IslandPermissions.NOBODY || (playerWorld.visitPermission() == IslandPermissions.MEMBERS && !playerWorld.members().contains(target.getUniqueId())))
|
||||
{
|
||||
return messageComponent("cannotAccessIsland");
|
||||
}
|
||||
}
|
||||
player.teleportAsync(world.getSpawnLocation());
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1f, 1f);
|
||||
return null;
|
||||
}
|
||||
case "settings" ->
|
||||
{
|
||||
if (!TFMExtras.getModule().getSlimeWorldHook().isWorldLoaded(player.getUniqueId().toString()))
|
||||
{
|
||||
return messageComponent("selfPlayerWorldNotFound");
|
||||
}
|
||||
if (args.length != 3)
|
||||
{
|
||||
return usage("/myworld settings <interact | edit | visit> <nobody | anyone | members>");
|
||||
}
|
||||
if (!args[1].equalsIgnoreCase("interact") && !args[1].equalsIgnoreCase("edit") && !args[1].equalsIgnoreCase("visit"))
|
||||
{
|
||||
return usage("/myworld settings <interact | edit | visit> <nobody | anyone | members>");
|
||||
}
|
||||
final PlayerWorld playerWorld = TFMExtras.getModule().getIslandHandler().loadedIslands().get(player.getUniqueId());
|
||||
try {
|
||||
final IslandPermissions permissions = IslandPermissions.valueOf(args[2].toUpperCase());
|
||||
switch (args[1].toLowerCase())
|
||||
{
|
||||
case "interact" -> playerWorld.interactPermission(permissions);
|
||||
case "edit" -> playerWorld.editPermission(permissions);
|
||||
case "visit" -> playerWorld.visitPermission(permissions);
|
||||
}
|
||||
return messageComponent("islandPermissionUpdated", args[1].toUpperCase(), permissions.name());
|
||||
|
||||
} catch (IllegalArgumentException e)
|
||||
{
|
||||
return usage("/myworld settings <interact | edit | visit> <nobody | anyone | members>");
|
||||
}
|
||||
}
|
||||
|
||||
case "invite" -> {
|
||||
final PlexPlayer plexPlayer = DataUtils.getPlayer(args[1], false);
|
||||
if (plexPlayer == null)
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
||||
if (!TFMExtras.getModule().getSlimeWorldHook().isWorldLoaded(player.getUniqueId().toString()))
|
||||
{
|
||||
return messageComponent("selfPlayerWorldNotFound");
|
||||
}
|
||||
|
||||
final PlayerWorld playerWorld = TFMExtras.getModule().getIslandHandler().loadedIslands().get(player.getUniqueId());
|
||||
if (playerWorld.members().contains(plexPlayer.getPlayer().getUniqueId()))
|
||||
{
|
||||
return messageComponent("islandMemberExists");
|
||||
}
|
||||
playerWorld.pendingInvites().add(plexPlayer.getUuid());
|
||||
if (Bukkit.getPlayer(plexPlayer.getUuid()) != null)
|
||||
{
|
||||
final Player target = Bukkit.getPlayer(plexPlayer.getUuid());
|
||||
assert target != null;
|
||||
target.sendMessage(messageComponent("receivedInviteForIsland", player.getName()));
|
||||
}
|
||||
|
||||
return messageComponent("sentInviteToIsland");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("create", "goto", "manage", "members", "shared", "add", "remove", "settings");
|
||||
}
|
||||
if (args.length == 2)
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
package dev.plex.extras.command.slime;
|
||||
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "slimemanager", usage = "/<command> <delete | list> [world | all]", description = "Manages the slime worlds handled by the plugin")
|
||||
@CommandPermissions(source = RequiredCommandSource.CONSOLE, permission = "plex.tfmextras.slimemanager")
|
||||
public class SlimeManagerCommand extends PlexCommand
|
||||
{
|
||||
private ScheduledTask task = null;
|
||||
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
return usage();
|
||||
}
|
||||
if (!TFMExtras.getModule().enableIslands())
|
||||
{
|
||||
return mmString("<red>SlimeWorldManager is not on this server!");
|
||||
}
|
||||
try
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("delete"))
|
||||
{
|
||||
if (args.length != 2)
|
||||
{
|
||||
return usage("/slimemanager delete <world | all>");
|
||||
}
|
||||
String argument = args[1];
|
||||
if (TFMExtras.getModule().getSlimeWorldHook().getLoader().listWorlds().isEmpty())
|
||||
{
|
||||
return mmString("<red>There are currently no loaded worlds.");
|
||||
}
|
||||
else if (!argument.equalsIgnoreCase("all") && TFMExtras.getModule().getSlimeWorldHook().getLoader().listWorlds().stream().noneMatch(s -> s.equalsIgnoreCase(argument)))
|
||||
{
|
||||
return mmString("<red>There is no world called " + argument);
|
||||
}
|
||||
if (task != null)
|
||||
{
|
||||
if (argument.equalsIgnoreCase("all"))
|
||||
{
|
||||
TFMExtras.getModule().getSlimeWorldHook().getLoader().listWorlds().forEach(s ->
|
||||
TFMExtras.getModule().getSlimeWorldHook().deleteWorld(s));
|
||||
if (task != null && !task.isCancelled())
|
||||
{
|
||||
task.cancel();
|
||||
task = null;
|
||||
}
|
||||
return mmString("<green>Successfully permanently deleted all slime module loaded worlds!");
|
||||
}
|
||||
else
|
||||
{
|
||||
TFMExtras.getModule().getSlimeWorldHook().deleteWorld(argument);
|
||||
if (task != null && !task.isCancelled())
|
||||
{
|
||||
task.cancel();
|
||||
task = null;
|
||||
}
|
||||
return mmString("<green>Successfully permanently deleted the world <dark_green>" + argument);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
task = Bukkit.getGlobalRegionScheduler().runDelayed(plugin, scheduledTask ->
|
||||
{
|
||||
this.task = null;
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<red>You did not confirm the deletion in time!"));
|
||||
}, 10 * 20L);
|
||||
return mmString("<green>Run this command again to confirm deletion.");
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
return mmString("<blue>Current worlds: <white>" + StringUtils.join(TFMExtras.getModule().getSlimeWorldHook().getLoader().listWorlds(), ", "));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PlexLog.debug("{0}: {1}", e.getClass().getName(), e.getMessage());
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("delete", "list");
|
||||
}
|
||||
if (args.length == 2)
|
||||
{
|
||||
return TFMExtras.getModule().getSlimeWorldHook().loadedWorlds().stream().toList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
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();
|
||||
}
|
||||
@@ -1,261 +0,0 @@
|
||||
package dev.plex.extras.hook;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.infernalsuite.aswm.api.SlimePlugin;
|
||||
import com.infernalsuite.aswm.api.exceptions.CorruptedWorldException;
|
||||
import com.infernalsuite.aswm.api.exceptions.NewerFormatException;
|
||||
import com.infernalsuite.aswm.api.exceptions.UnknownWorldException;
|
||||
import com.infernalsuite.aswm.api.exceptions.WorldAlreadyExistsException;
|
||||
import com.infernalsuite.aswm.api.exceptions.WorldLockedException;
|
||||
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.Plex;
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import dev.plex.extras.island.PlayerWorld;
|
||||
import dev.plex.extras.island.info.IslandPermissions;
|
||||
import dev.plex.util.PlexLog;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
|
||||
/**
|
||||
* @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> loadedWorlds = Sets.newHashSet();
|
||||
|
||||
// private final List<>
|
||||
|
||||
@Getter
|
||||
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();
|
||||
|
||||
try (Connection connection = Plex.get().getSqlConnection().getCon())
|
||||
{
|
||||
connection.prepareStatement("ALTER TABLE `islands` ADD COLUMN IF NOT EXISTS `interactPermission` VARCHAR(10);").execute();
|
||||
|
||||
} catch (SQLException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
TFMExtras.getModule().getIslandHandler().createTables();
|
||||
TFMExtras.getModule().getIslandHandler().loadIslands();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable(TFMExtras module)
|
||||
{
|
||||
PlexLog.log("<green>Disabling SWM Hook");
|
||||
AtomicInteger i = new AtomicInteger();
|
||||
loadedWorlds.forEach(s ->
|
||||
{
|
||||
final World world = Bukkit.getWorld(s);
|
||||
if (world != null)
|
||||
{
|
||||
Bukkit.unloadWorld(world, true);
|
||||
i.getAndIncrement();
|
||||
}
|
||||
});
|
||||
|
||||
loadedWorlds.clear();
|
||||
|
||||
CompletableFuture.runAsync(() ->
|
||||
{
|
||||
TFMExtras.getModule().getIslandHandler().loadedIslands().values().forEach(playerWorld -> TFMExtras.getModule().getIslandHandler().updateIsland(playerWorld));
|
||||
TFMExtras.getModule().getIslandHandler().loadedIslands().clear();
|
||||
});
|
||||
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);
|
||||
} 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);
|
||||
|
||||
loadedWorlds.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);
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new WorldLoadEvent(world));
|
||||
|
||||
PlexLog.debug("Loaded {0}", s);
|
||||
});
|
||||
} catch (IOException | IllegalArgumentException ex)
|
||||
{
|
||||
PlexLog.error(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWorldLoaded(String world)
|
||||
{
|
||||
return loadedWorlds.stream().anyMatch(s -> s.equals(world));
|
||||
}
|
||||
|
||||
public void deleteWorld(String world)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Bukkit.getWorld(world) != null)
|
||||
{
|
||||
Bukkit.unloadWorld(world, false);
|
||||
}
|
||||
this.loader.deleteWorld(world);
|
||||
} catch (UnknownWorldException | IOException e)
|
||||
{
|
||||
PlexLog.error(e.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);
|
||||
} catch (WorldLockedException | CorruptedWorldException | NewerFormatException | UnknownWorldException |
|
||||
IOException | IllegalArgumentException ex)
|
||||
{
|
||||
PlexLog.error(ex.getMessage());
|
||||
}
|
||||
|
||||
} catch (IOException e)
|
||||
{
|
||||
PlexLog.error(STORAGE_FAILURE);
|
||||
} catch (WorldLockedException | UnknownWorldException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
loadedWorlds.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);
|
||||
|
||||
final WorldLoadEvent event = new WorldLoadEvent(world);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
final PlayerWorld playerWorld = new PlayerWorld(uuid, Lists.newArrayList(), IslandPermissions.NOBODY, IslandPermissions.ANYONE, IslandPermissions.ANYONE);
|
||||
|
||||
TFMExtras.getModule().getIslandHandler().insertIsland(playerWorld);
|
||||
TFMExtras.getModule().getIslandHandler().loadedIslands().put(uuid, playerWorld);
|
||||
|
||||
return Pair.of(world, newWorld);
|
||||
}
|
||||
|
||||
public Set<String> loadedWorlds()
|
||||
{
|
||||
return this.loadedWorlds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SlimePlugin plugin()
|
||||
{
|
||||
return (SlimePlugin) Bukkit.getPluginManager().getPlugin("SlimeWorldManager");
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package dev.plex.extras.island;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import dev.plex.extras.island.info.IslandPermissions;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* @author Taah
|
||||
* @since 9:26 PM [24-08-2023]
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
//@SQLTable("player_worlds")
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(fluent = true)
|
||||
public class PlayerWorld
|
||||
{
|
||||
// @PrimaryKey
|
||||
private final UUID owner;
|
||||
private final List<UUID> members;
|
||||
private final List<UUID> pendingInvites = Lists.newArrayList();
|
||||
|
||||
private IslandPermissions editPermission;
|
||||
private IslandPermissions visitPermission;
|
||||
private IslandPermissions interactPermission;
|
||||
|
||||
|
||||
public boolean addMember(UUID member)
|
||||
{
|
||||
if (members.contains(member))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
CompletableFuture.runAsync(() -> TFMExtras.getModule().getIslandHandler().insertMember(this.owner, member));
|
||||
this.members.add(member);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeMember(UUID member)
|
||||
{
|
||||
if (!members.contains(member))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
CompletableFuture.runAsync(() -> TFMExtras.getModule().getIslandHandler().deleteMember(this.owner, member));
|
||||
this.members.remove(member);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package dev.plex.extras.island.info;
|
||||
|
||||
/**
|
||||
* @author Taah
|
||||
* @since 10:44 PM [05-01-2024]
|
||||
*/
|
||||
public enum IslandPermissions
|
||||
{
|
||||
ANYONE,
|
||||
NOBODY,
|
||||
MEMBERS
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
package dev.plex.extras.island.storage;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.extras.island.PlayerWorld;
|
||||
import dev.plex.extras.island.info.IslandPermissions;
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Taah
|
||||
* @since 10:53 PM [05-01-2024]
|
||||
*/
|
||||
public class IslandHandler
|
||||
{
|
||||
//TODO: Create Table statements
|
||||
private static final String LOAD_ISLANDS = "SELECT * FROM `islands`;";
|
||||
private static final String LOAD_MEMBERS = "SELECT * FROM `island_members`;";
|
||||
private static final String INSERT_ISLAND = "INSERT INTO `islands` (`owner`, `editPermission`, `visitPermission`, `interactPermission`) VALUES(?, ?, ?, ?);";
|
||||
private static final String INSERT_MEMBER = "INSERT INTO `island_members` (`uuid`, `island_owner_uuid`) VALUES(?, ?);";
|
||||
private static final String DELETE_ISLAND = "DELETE FROM `islands` WHERE `owner`=?;";
|
||||
private static final String DELETE_MEMBER = "DELETE FROM `island_members` WHERE `uuid`=? AND `island_owner_uuid`=?;";
|
||||
private static final String UPDATE_ISLAND = "UPDATE `islands` SET `editPermission`=?, `visitPermission`=?, `interactPermission`=? WHERE `owner`=?;";
|
||||
private static final String CREATE_ISLANDS_TABLE = "CREATE TABLE IF NOT EXISTS `islands` (`owner` VARCHAR(36) NOT NULL PRIMARY KEY, `editPermission` VARCHAR(10), `visitPermission` VARCHAR(10), `interactPermission` VARCHAR(10));";
|
||||
private static final String CREATE_MEMBERS_TABLE = "CREATE TABLE IF NOT EXISTS `island_members` (`uuid` VARCHAR(36), `island_owner_uuid` VARCHAR(36));";
|
||||
|
||||
@Getter
|
||||
@Accessors(fluent = true)
|
||||
private final Map<UUID, PlayerWorld> loadedIslands = Maps.newHashMap();
|
||||
|
||||
public void createTables()
|
||||
{
|
||||
try (Connection connection = Plex.get().getSqlConnection().getCon())
|
||||
{
|
||||
connection.prepareStatement(CREATE_ISLANDS_TABLE).execute();
|
||||
connection.prepareStatement(CREATE_MEMBERS_TABLE).execute();
|
||||
} catch (SQLException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public void loadIslands()
|
||||
{
|
||||
// Member to Islands Mapping
|
||||
final Map<UUID, List<UUID>> mappedMembers = Maps.newHashMap();
|
||||
|
||||
try (Connection connection = Plex.get().getSqlConnection().getCon())
|
||||
{
|
||||
final PreparedStatement loadIslands = connection.prepareStatement(LOAD_ISLANDS);
|
||||
final PreparedStatement loadMembers = connection.prepareStatement(LOAD_MEMBERS);
|
||||
|
||||
final ResultSet membersQuery = loadMembers.executeQuery();
|
||||
while (membersQuery.next())
|
||||
{
|
||||
final UUID uuid = UUID.fromString(membersQuery.getString("uuid"));
|
||||
List<UUID> islands = mappedMembers.getOrDefault(uuid, Lists.newArrayList());
|
||||
islands.add(UUID.fromString(membersQuery.getString("island_owner_uuid")));
|
||||
mappedMembers.put(uuid, islands);
|
||||
}
|
||||
|
||||
|
||||
final ResultSet islandsQuery = loadIslands.executeQuery();
|
||||
while (islandsQuery.next())
|
||||
{
|
||||
final UUID owner = UUID.fromString(islandsQuery.getString("owner"));
|
||||
final List<UUID> members = mappedMembers.entrySet().stream().filter(uuiduuidEntry -> uuiduuidEntry.getValue().stream().anyMatch(owners -> owners.equals(owner))).map(Map.Entry::getKey).toList();
|
||||
final IslandPermissions editPerm = IslandPermissions.valueOf(islandsQuery.getString("editPermission").toUpperCase());
|
||||
final IslandPermissions visitPerm = IslandPermissions.valueOf(islandsQuery.getString("visitPermission").toUpperCase());
|
||||
|
||||
final String interactPermission = islandsQuery.getString("interactPermission");
|
||||
|
||||
final IslandPermissions interactPerm = interactPermission == null ? IslandPermissions.NOBODY : IslandPermissions.valueOf(interactPermission.toUpperCase());
|
||||
loadedIslands.put(owner, new PlayerWorld(owner, members, editPerm, visitPerm, interactPerm));
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void insertIsland(PlayerWorld world)
|
||||
{
|
||||
try (Connection connection = Plex.get().getSqlConnection().getCon())
|
||||
{
|
||||
final PreparedStatement statement = connection.prepareStatement(INSERT_ISLAND);
|
||||
statement.setString(1, world.owner().toString());
|
||||
statement.setString(2, world.editPermission().name());
|
||||
statement.setString(3, world.visitPermission().name());
|
||||
statement.setString(4, world.interactPermission().name());
|
||||
|
||||
statement.execute();
|
||||
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void insertMember(UUID islandOwner, UUID member)
|
||||
{
|
||||
try (Connection connection = Plex.get().getSqlConnection().getCon())
|
||||
{
|
||||
final PreparedStatement statement = connection.prepareStatement(INSERT_MEMBER);
|
||||
statement.setString(1, member.toString());
|
||||
statement.setString(2, islandOwner.toString());
|
||||
statement.execute();
|
||||
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteMember(UUID islandOwner, UUID member)
|
||||
{
|
||||
try (Connection connection = Plex.get().getSqlConnection().getCon())
|
||||
{
|
||||
final PreparedStatement statement = connection.prepareStatement(DELETE_MEMBER);
|
||||
statement.setString(1, member.toString());
|
||||
statement.setString(2, islandOwner.toString());
|
||||
statement.execute();
|
||||
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteIsland(UUID islandOwner)
|
||||
{
|
||||
try (Connection connection = Plex.get().getSqlConnection().getCon())
|
||||
{
|
||||
final PreparedStatement statement = connection.prepareStatement(DELETE_ISLAND);
|
||||
statement.setString(1, islandOwner.toString());
|
||||
statement.execute();
|
||||
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateIsland(PlayerWorld world)
|
||||
{
|
||||
try (Connection connection = Plex.get().getSqlConnection().getCon())
|
||||
{
|
||||
final PreparedStatement statement = connection.prepareStatement(UPDATE_ISLAND);
|
||||
statement.setString(1, world.editPermission().name());
|
||||
statement.setString(2, world.visitPermission().name());
|
||||
statement.setString(3, world.interactPermission().name());
|
||||
statement.setString(4, world.owner().toString());
|
||||
|
||||
statement.executeUpdate();
|
||||
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,11 +3,8 @@ package dev.plex.extras.listener;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class PlayerListener extends PlexListener
|
||||
@@ -39,15 +36,4 @@ public class PlayerListener extends PlexListener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void unloadWorld(PlayerQuitEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
// PlexLog.debug("Slime World Loaded: {0}", TFMExtras.getModule().getSlimeWorldHook().isWorldLoaded(player.getUniqueId().toString()));
|
||||
// PlexLog.debug("World Loaded: {0}", Bukkit.getWorld(player.getUniqueId().toString()) != null);
|
||||
if (TFMExtras.getModule().enableIslands() && TFMExtras.getModule().getSlimeWorldHook().isWorldLoaded(player.getUniqueId().toString()) && Bukkit.getWorld(player.getUniqueId().toString()) != null)
|
||||
{
|
||||
Bukkit.unloadWorld(player.getUniqueId().toString(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
package dev.plex.extras.listener;
|
||||
|
||||
import dev.plex.extras.TFMExtras;
|
||||
import dev.plex.extras.island.PlayerWorld;
|
||||
import dev.plex.extras.island.info.IslandPermissions;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class WorldListener extends PlexListener
|
||||
{
|
||||
@EventHandler
|
||||
public void onBuild(BlockPlaceEvent event)
|
||||
{
|
||||
if (!TFMExtras.getModule().enableIslands()) return;
|
||||
if (!TFMExtras.getModule().getSlimeWorldHook().isWorldLoaded(event.getPlayer().getWorld().getName())) return;
|
||||
final UUID worldOwner = UUID.fromString(event.getPlayer().getWorld().getName());
|
||||
final PlayerWorld world = TFMExtras.getModule().getIslandHandler().loadedIslands().get(worldOwner);
|
||||
if (world.owner().equals(event.getPlayer().getUniqueId())) return;
|
||||
if (world.editPermission() == IslandPermissions.NOBODY)
|
||||
{
|
||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("cantModifyIsland"));
|
||||
event.setCancelled(true);
|
||||
event.setBuild(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (world.editPermission() == IslandPermissions.MEMBERS && !world.members().contains(event.getPlayer().getUniqueId()))
|
||||
{
|
||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("cantModifyIsland"));
|
||||
event.setCancelled(true);
|
||||
event.setBuild(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (!TFMExtras.getModule().enableIslands()) return;
|
||||
if (!TFMExtras.getModule().getSlimeWorldHook().isWorldLoaded(event.getPlayer().getWorld().getName())) return;
|
||||
final UUID worldOwner = UUID.fromString(event.getPlayer().getWorld().getName());
|
||||
final PlayerWorld world = TFMExtras.getModule().getIslandHandler().loadedIslands().get(worldOwner);
|
||||
if (world.owner().equals(event.getPlayer().getUniqueId())) return;
|
||||
if (world.editPermission() == IslandPermissions.NOBODY)
|
||||
{
|
||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("cantModifyIsland"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (world.editPermission() == IslandPermissions.MEMBERS && !world.members().contains(event.getPlayer().getUniqueId()))
|
||||
{
|
||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("cantModifyIsland"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (!TFMExtras.getModule().enableIslands()) return;
|
||||
if (!TFMExtras.getModule().getSlimeWorldHook().isWorldLoaded(event.getPlayer().getWorld().getName())) return;
|
||||
final UUID worldOwner = UUID.fromString(event.getPlayer().getWorld().getName());
|
||||
final PlayerWorld world = TFMExtras.getModule().getIslandHandler().loadedIslands().get(worldOwner);
|
||||
if (world.owner().equals(event.getPlayer().getUniqueId())) return;
|
||||
if (world.interactPermission() == IslandPermissions.NOBODY)
|
||||
{
|
||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("cantModifyIsland"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (world.interactPermission() == IslandPermissions.MEMBERS && !world.members().contains(event.getPlayer().getUniqueId()))
|
||||
{
|
||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("cantModifyIsland"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldChange(PlayerChangedWorldEvent event)
|
||||
{
|
||||
if (!TFMExtras.getModule().enableIslands()) return;
|
||||
if (!TFMExtras.getModule().getSlimeWorldHook().isWorldLoaded(event.getPlayer().getWorld().getName())) return;
|
||||
final UUID worldOwner = UUID.fromString(event.getPlayer().getWorld().getName());
|
||||
final PlayerWorld world = TFMExtras.getModule().getIslandHandler().loadedIslands().get(worldOwner);
|
||||
if (world.owner().equals(event.getPlayer().getUniqueId())) return;
|
||||
if (world.visitPermission() == IslandPermissions.NOBODY)
|
||||
{
|
||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("cantVisitIsland"));
|
||||
event.getPlayer().teleportAsync(event.getFrom().getSpawnLocation());
|
||||
return;
|
||||
}
|
||||
|
||||
if (world.visitPermission() == IslandPermissions.MEMBERS && !world.members().contains(event.getPlayer().getUniqueId()))
|
||||
{
|
||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("cantVisitIsland"));
|
||||
event.getPlayer().teleportAsync(event.getFrom().getSpawnLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user