Implement teleportation to island in 'VisitRequest' accept method (#9)
Fixed the accept function in the 'VisitRequest' class by adding teleportation to the island of the target. Additionally, validation checks for this were added. Specifically, it now verifies the existence of both the player and the requested island before carrying out the teleportation command.
This commit is contained in:
parent
2b69335b2e
commit
69cd686d04
|
|
@ -1,7 +1,9 @@
|
|||
package com.alttd.cometskyblock.request;
|
||||
|
||||
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
||||
import com.alttd.cometskyblock.island.Island;
|
||||
import com.alttd.cometskyblock.island.IslandPlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class VisitRequest extends Request {
|
||||
|
|
@ -26,7 +28,18 @@ public class VisitRequest extends Request {
|
|||
return;
|
||||
}
|
||||
target().sendRichMessage(requests().visit().targetAccept(), placeholders());
|
||||
IslandPlayer islandPlayer = IslandPlayer.getIslandPlayer(target().getUniqueId());
|
||||
if (islandPlayer == null) {
|
||||
requester().sendRichMessage("<red>You requested a teleport to a player who does not exist</red>");
|
||||
return;
|
||||
}
|
||||
Island island = Island.getIsland(islandPlayer.islandUUID());
|
||||
if (island == null) {
|
||||
requester().sendRichMessage("<red>The player who's island you requested to teleport to does not have an island</red>");
|
||||
return;
|
||||
}
|
||||
requester().sendRichMessage(requests().visit().requesterAccept(), placeholders());
|
||||
requester().teleportAsync(plugin.worldGenerator().loadIslandWorld(island.worldName()).getSpawnLocation());
|
||||
super.accept();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user