Add IslandLeave.java
This commit is contained in:
parent
3cdf57192c
commit
46ac79503e
|
|
@ -20,12 +20,11 @@ public class IslandCommand extends PlayerSubCommand {
|
|||
registerSubCommand(new IslandRestart(plugin)); // TODO -- Add IslandRestartCommand
|
||||
registerSubCommand(new IslandAccept(plugin));
|
||||
registerSubCommand(new IslandDeny(plugin));
|
||||
registerSubCommand(new IslandLeave(plugin)); // TODO -- Add IslandLeaveCommand
|
||||
registerSubCommand(new IslandLeave(plugin));
|
||||
registerSubCommand(new IslandMembers(plugin)); // TODO -- Add IslandMembersCommand
|
||||
registerSubCommand(new IslandLevel(plugin)); // TODO -- Add IslandLevelCommand
|
||||
// registerSubCommand(new IslandTop(plugin)); // TODO -- Add IslandTopCommand
|
||||
registerSubCommand(new IslandOptions(plugin)); // TODO -- Add IslandOptionsCommand
|
||||
registerSubCommand(new IslandConfirm(plugin)); // TODO -- Add IslandConfirmCommand
|
||||
registerSubCommand(new IslandInvite(plugin)); // TODO -- Add IslandInviteCommand
|
||||
registerSubCommand(new IslandKick(plugin)); // TODO -- Add IslandKickCommand
|
||||
registerSubCommand(new IslandSetOwner(plugin)); // TODO -- Add some more output
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
package com.alttd.cometskyblock.commands.island;
|
||||
|
||||
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
||||
import com.alttd.cometskyblock.commands.PlayerSubCommand;
|
||||
import com.alttd.cometskyblock.island.IslandPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class IslandConfirm extends PlayerSubCommand {
|
||||
|
||||
public IslandConfirm(CometSkyBlockPlugin plugin) {
|
||||
super(plugin, "confirm");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(Player player, IslandPlayer islandPlayer, String[] args) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ public class IslandInvite extends PlayerSubCommand {
|
|||
public boolean execute(Player player, IslandPlayer islandPlayer, String[] args) {
|
||||
MessageConfiguration.Commands.Island.Invite invite = plugin.messagesConfiguration().get().commands().island().invite();
|
||||
if (islandPlayer.islandId() == 0) {
|
||||
player.sendRichMessage(invite.noIsland());
|
||||
player.sendRichMessage(plugin.messagesConfiguration().get().commands().island().noIsland());
|
||||
return true;
|
||||
}
|
||||
if (args.length < 1) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ package com.alttd.cometskyblock.commands.island;
|
|||
|
||||
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
||||
import com.alttd.cometskyblock.commands.PlayerSubCommand;
|
||||
import com.alttd.cometskyblock.configuration.MessageConfiguration;
|
||||
import com.alttd.cometskyblock.island.Island;
|
||||
import com.alttd.cometskyblock.island.IslandPlayer;
|
||||
import com.alttd.cometskyblock.request.LeaveRequest;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class IslandLeave extends PlayerSubCommand {
|
||||
|
|
@ -13,6 +16,17 @@ public class IslandLeave extends PlayerSubCommand {
|
|||
|
||||
@Override
|
||||
public boolean execute(Player player, IslandPlayer islandPlayer, String[] args) {
|
||||
MessageConfiguration.Commands.Island.Leave leave = plugin.messagesConfiguration().get().commands().island().leave();
|
||||
if (islandPlayer.islandId() == 0) {
|
||||
player.sendRichMessage(plugin.messagesConfiguration().get().commands().island().noIsland());
|
||||
return true;
|
||||
}
|
||||
Island island = Island.getIsland(islandPlayer.islandUUID());
|
||||
if (islandPlayer.islandOwner() && !island.members().isEmpty()) {
|
||||
player.sendRichMessage(leave.islandHasMembers());
|
||||
return true;
|
||||
}
|
||||
islandPlayer.request(new LeaveRequest(plugin, player, player));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public class MessageConfiguration implements Configuration {
|
|||
@ConfigSerializable @Getter
|
||||
public static class Island {
|
||||
String commandUsage = "Wrong usage: try /island help";
|
||||
String noIsland = "<red>You need an island to run this command.";
|
||||
|
||||
private Help help = new Help();
|
||||
@ConfigSerializable @Getter
|
||||
|
|
@ -61,7 +62,7 @@ public class MessageConfiguration implements Configuration {
|
|||
Leave leave = new Leave();
|
||||
@ConfigSerializable @Getter
|
||||
public static class Leave {
|
||||
|
||||
String islandHasMembers = "You can not leave your island if it has members!";
|
||||
}
|
||||
|
||||
Members members = new Members();
|
||||
|
|
@ -98,7 +99,6 @@ public class MessageConfiguration implements Configuration {
|
|||
@ConfigSerializable @Getter
|
||||
public static class Invite {
|
||||
String inviteSelf = "<red>You can not invite yourself to this island.";
|
||||
String noIsland = "<red>You need an island to run this command.";
|
||||
String targetOffline = "<red><target> not found, is the player online?";
|
||||
String targetHasIsland = "<red><target> already has an island and can not be invited.";
|
||||
}
|
||||
|
|
@ -168,6 +168,15 @@ public class MessageConfiguration implements Configuration {
|
|||
String created = "Island restart request created type <yellow>/island restart confirm</yellow> or <yellow>/island restart deny</yellow>.<newline><red>This action can not be reversed!";
|
||||
String cancelled = "You have cancelled your island restart request!";
|
||||
}
|
||||
|
||||
private Leave leave = new Leave();
|
||||
|
||||
@ConfigSerializable @Getter
|
||||
public static class Leave {
|
||||
String created = "Type <yellow>/island accept</yellow> or <yellow>/island deny</yellow> to confirm.<newline><red>This action can not be reversed if you are the island owner!";
|
||||
String accept = "You have left your island.";
|
||||
String denied = "You have cancelled your request.";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,11 @@ public class IslandPlayer extends YamlConfiguration {
|
|||
}
|
||||
|
||||
public void islandUUID(UUID uuid) {
|
||||
set("island.uuid", uuid.toString());
|
||||
if (uuid == null) {
|
||||
set("island.uuid", null);
|
||||
} else {
|
||||
set("island.uuid", uuid.toString());
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
package com.alttd.cometskyblock.request;
|
||||
|
||||
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
||||
import com.alttd.cometskyblock.island.IslandPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LeaveRequest extends Request {
|
||||
|
||||
public LeaveRequest(CometSkyBlockPlugin plugin, Player requester, Player target) {
|
||||
super(plugin, requester, target);
|
||||
|
||||
requester.sendRichMessage(requests().leave().created(), placeholders());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept() {
|
||||
if (!target().isOnline() || !requester().isOnline()) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
requester().sendRichMessage(requests().leave().accept(), placeholders());
|
||||
IslandPlayer islandPlayer = IslandPlayer.getIslandPlayer(requester().getUniqueId());
|
||||
islandPlayer.islandId(0);
|
||||
islandPlayer.islandUUID(null);
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
Location spawnLocation = world.getSpawnLocation();
|
||||
requester().teleport(spawnLocation);
|
||||
super.accept();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deny() {
|
||||
if (!target().isOnline() || !requester().isOnline()) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
requester().sendRichMessage(requests().leave().denied(), placeholders());
|
||||
super.deny();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user