Update IslandSetOwner.java
This commit is contained in:
parent
adacce0677
commit
52d8178e28
|
|
@ -24,7 +24,7 @@ public class IslandCommand extends PlayerSubCommand {
|
|||
// registerSubCommand(new IslandTop(plugin)); // TODO -- Add IslandTopCommand
|
||||
registerSubCommand(new IslandInvite(plugin));
|
||||
registerSubCommand(new IslandKick(plugin)); // TODO -- Add IslandKickCommand
|
||||
registerSubCommand(new IslandSetOwner(plugin)); // TODO -- Add some more output
|
||||
registerSubCommand(new IslandSetOwner(plugin));
|
||||
registerSubCommand(new IslandVisit(plugin));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ 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 org.bukkit.Bukkit;
|
||||
|
|
@ -17,31 +18,33 @@ public class IslandSetOwner extends PlayerSubCommand {
|
|||
@Override
|
||||
public boolean execute(Player player, IslandPlayer islandPlayer, String[] args) {
|
||||
if (args.length < 1) {
|
||||
// Wrong usage
|
||||
player.sendRichMessage(plugin.messagesConfiguration().get().commands().island().commandUsage());
|
||||
return true;
|
||||
}
|
||||
MessageConfiguration.Commands.Island.SetOwner setOwner = plugin.messagesConfiguration().get().commands().island().setOwner();
|
||||
if (!islandPlayer.islandOwner()) {
|
||||
// You must be island owner to do this command.
|
||||
player.sendRichMessage(setOwner.notIslandOwner());
|
||||
return true;
|
||||
}
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
// Target is not online
|
||||
player.sendRichMessage(setOwner.targetOffline());
|
||||
return true;
|
||||
}
|
||||
if (target == player) {
|
||||
// You are already the island owner.
|
||||
player.sendRichMessage(setOwner.playerIsOwner());
|
||||
return true;
|
||||
}
|
||||
Island island = Island.getIsland(islandPlayer.islandUUID());
|
||||
if (island == null) {
|
||||
// Could not load island, contact administrator
|
||||
player.sendRichMessage("<red>Could not load the island. Please contact an administrator!");
|
||||
return true;
|
||||
}
|
||||
// if (!island.members().contains(target.getUniqueId())) {
|
||||
// // Target must be a member of your island
|
||||
// return true;
|
||||
// }
|
||||
if (!island.members().contains(target.getUniqueId())) {
|
||||
player.sendRichMessage(setOwner.targetNotAMember());
|
||||
return true;
|
||||
}
|
||||
// Todo - Notify online members about the change?
|
||||
island.owner(target.getUniqueId());
|
||||
islandPlayer.islandOwner(false);
|
||||
IslandPlayer.getIslandPlayer(target.getUniqueId()).islandOwner(true);
|
||||
|
|
|
|||
|
|
@ -122,7 +122,10 @@ public class MessageConfiguration implements Configuration {
|
|||
SetOwner setOwner = new SetOwner();
|
||||
@ConfigSerializable @Getter
|
||||
public static class SetOwner {
|
||||
|
||||
String notIslandOwner = "<red>You must be the island owner to do this.";
|
||||
String targetOffline = "<red><target> not found, is the player online?";
|
||||
String playerIsOwner = "<red>You are already the island owner.";
|
||||
String targetNotAMember = "<red><target> must be a member of your island.";
|
||||
}
|
||||
|
||||
Visit visit = new Visit();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user