|
47 | 47 | import java.util.concurrent.ConcurrentHashMap; |
48 | 48 | import java.util.concurrent.ConcurrentMap; |
49 | 49 |
|
| 50 | +import org.bukkit.Bukkit; |
| 51 | +import org.bukkit.Server.Spigot; |
50 | 52 | import org.bukkit.command.CommandSender; |
51 | 53 | import org.bukkit.entity.Player; |
52 | 54 | import org.bukkit.plugin.PluginManager; |
53 | 55 | import org.bukkit.plugin.java.JavaPlugin; |
| 56 | +import org.geysermc.floodgate.api.FloodgateApi; |
54 | 57 | import org.slf4j.Logger; |
55 | 58 |
|
56 | 59 | /** |
@@ -138,6 +141,8 @@ public void onEnable() { |
138 | 141 | premiumPlaceholder = new PremiumPlaceholder(this); |
139 | 142 | premiumPlaceholder.register(); |
140 | 143 | } |
| 144 | + |
| 145 | + dependencyWarnings(); |
141 | 146 | } |
142 | 147 |
|
143 | 148 | @Override |
@@ -265,7 +270,38 @@ private boolean isValidFloodgateConfigString(String key) { |
265 | 270 | logger.error("Invalid value detected for {} in FastLogin/config.yml.", key); |
266 | 271 | return false; |
267 | 272 | } |
268 | | - return true; |
269 | | - |
| 273 | + return true; |
| 274 | + } |
| 275 | + |
| 276 | + /** |
| 277 | + * Checks if a plugin is installed on the server |
| 278 | + * @param name the name of the plugin |
| 279 | + * @return true if the plugin is installed |
| 280 | + */ |
| 281 | + private boolean isPluginInstalled(String name) { |
| 282 | + //the plugin may be enabled after FastLogin, so isPluginEnabled() |
| 283 | + //won't work here |
| 284 | + return Bukkit.getServer().getPluginManager().getPlugin(name) != null; |
270 | 285 | } |
| 286 | + |
| 287 | + /** |
| 288 | + * Send warning messages to log if incompatible plugins are used |
| 289 | + */ |
| 290 | + private void dependencyWarnings() { |
| 291 | + if (isPluginInstalled("floodgate-bukkit")) { |
| 292 | + logger.warn("We have detected that you are runnging Floodgate 1.0 which is not supported by the Bukkit " |
| 293 | + + "version of FastLogin."); |
| 294 | + logger.warn("If you would like to use FastLogin with Floodgate, you can download developement builds of " |
| 295 | + + "Floodgate 2.0 from https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/dev%252F2.0/"); |
| 296 | + logger.warn("Don't forget to update Geyser to a supported version as well from " |
| 297 | + + "https://ci.opencollab.dev/job/GeyserMC/job/Geyser/job/floodgate-2.0/"); |
| 298 | + } else if (isPluginInstalled("floodgate") && isPluginInstalled("ProtocolLib")) { |
| 299 | + logger.warn("We have detected that you are runnging FastLogin alongside Floodgate and ProtocolLib."); |
| 300 | + logger.warn("Currently there is an issue with FastLogin that prevents Floodgate name prefixes from showing up " |
| 301 | + + "when it is together used with ProtocolLib."); |
| 302 | + logger.warn("If you would like to use Floodgate name prefixes, you can replace ProtocolLib with ProtocolSupport " |
| 303 | + + "which does not have this issue."); |
| 304 | + logger.warn("For more information visit https://github.com/games647/FastLogin/issues/493"); |
| 305 | + } |
| 306 | + } |
271 | 307 | } |
0 commit comments