From f86d574b5d596bc04994ca9454bf8f6025532780 Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 7 Feb 2022 20:30:04 +0100 Subject: [PATCH] Fixed some shit --- .../listeners/RideOperatorListener.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/java/nl/iobyte/themeparkconnector/listeners/RideOperatorListener.java b/src/main/java/nl/iobyte/themeparkconnector/listeners/RideOperatorListener.java index 6e52a45..975a090 100644 --- a/src/main/java/nl/iobyte/themeparkconnector/listeners/RideOperatorListener.java +++ b/src/main/java/nl/iobyte/themeparkconnector/listeners/RideOperatorListener.java @@ -1,18 +1,13 @@ package nl.iobyte.themeparkconnector.listeners; import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.TextComponent; import nl.iobyte.themepark.ThemePark; import nl.iobyte.themepark.api.attraction.objects.Attraction; -import nl.iobyte.themepark.api.message.MessageKey; -import nl.iobyte.themepark.utils.LocationUtil; import nl.iobyte.themeparkconnector.ThemeParkConnector; +import nl.iobyte.themeparkconnector.api.client.ClientConnection; import nl.iobyte.themeparkconnector.api.config.enums.StorageKey; import nl.iobyte.themeparkconnector.api.message.Text; import nl.iobyte.themeparkconnector.api.operator.objects.AttractionOperator; -import org.bukkit.Bukkit; import org.bukkit.block.Block; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -68,12 +63,27 @@ public class RideOperatorListener implements Listener { return; Player player = e.getPlayer(); - if(!ThemePark.getInstance().getAPI().getAttractionService().hasAttraction(id)) { + Attraction attraction = ThemePark.getInstance().getAPI().getAttractionService().getAttractionByName(id); + if(attraction == null) { player.sendMessage(Text.color("&6&lThemeParkConnectorMC &f➢ &4No attraction with ID: &f"+id)); return; } - Bukkit.dispatchCommand(player, "tpc connect "+id); + AttractionOperator operator = ThemeParkConnector.getInstance().getAPI().getOperatorService().getOperator(attraction.getID()); + if(operator == null) { + player.sendMessage(Text.color("&6&lThemeParkConnectorMC &f➢ &4There is no operator for this attraction")); + return; + } + + ClientConnection client = ThemeParkConnector.getInstance().getAPI().getNetworkingService().getClient( + player.getUniqueId() + ); + if(!operator.canClientConnect(client)) { + player.sendMessage(Text.color("&6&lThemeParkConnectorMC &f➢ &4You can't connect to the operator of this attraction")); + return; + } + + client.publishURL(attraction.getID()); } }