mirror of
https://github.com/plexusorg/Module-TFMExtras.git
synced 2024-11-17 17:16:12 +00:00
start working on inviting members
This commit is contained in:
parent
f866d9f5a3
commit
66222a0c4b
@ -2,6 +2,7 @@ package dev.plex.extras;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
@ -35,7 +36,7 @@ public class TFMExtras extends PlexModule
|
||||
private ModuleConfig config;
|
||||
|
||||
@Getter
|
||||
private SlimeWorldHook slimeWorldHook = new SlimeWorldHook();
|
||||
private SlimeWorldHook slimeWorldHook;
|
||||
|
||||
@Getter
|
||||
private final IslandHandler islandHandler = new IslandHandler();
|
||||
@ -47,7 +48,7 @@ public class TFMExtras extends PlexModule
|
||||
config = new ModuleConfig(this, "tfmextras/config.yml", "config.yml");
|
||||
config.load();
|
||||
jumpPads = new JumpPads();
|
||||
if (swmEnabled())
|
||||
if (enableIslands())
|
||||
{
|
||||
slimeWorldHook = new SlimeWorldHook();
|
||||
}
|
||||
@ -58,7 +59,7 @@ public class TFMExtras extends PlexModule
|
||||
@Override
|
||||
public void enable()
|
||||
{
|
||||
if (swmEnabled())
|
||||
if (enableIslands())
|
||||
{
|
||||
slimeWorldHook.onEnable(this);
|
||||
registerCommand(new SlimeManagerCommand());
|
||||
@ -118,13 +119,15 @@ public class TFMExtras extends PlexModule
|
||||
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
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
// Unregistering listeners / commands is handled by Plex
|
||||
if (swmEnabled())
|
||||
if (enableIslands())
|
||||
{
|
||||
slimeWorldHook.onDisable(this);
|
||||
}
|
||||
@ -169,16 +172,16 @@ public class TFMExtras extends PlexModule
|
||||
return Collections.unmodifiableSet(classes);
|
||||
}
|
||||
|
||||
public boolean swmEnabled()
|
||||
public boolean enableIslands()
|
||||
{
|
||||
try
|
||||
{
|
||||
Class.forName("com.infernalsuite.aswm.api.exceptions.UnknownWorldException");
|
||||
return true;
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
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;
|
||||
@ -8,6 +10,7 @@ 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;
|
||||
@ -22,8 +25,9 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
@CommandParameters(name = "myworld", usage = "/<command> <create | goto | manage | members | shared | add | remove | settings> [player]")
|
||||
@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
|
||||
{
|
||||
@ -119,6 +123,34 @@ public class MyWorldCommand extends PlexCommand
|
||||
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;
|
||||
}
|
||||
|
@ -27,10 +27,13 @@ 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))
|
||||
|
Loading…
Reference in New Issue
Block a user