From 558ee1c92c2f51766b77a82863e83969c38e6ec3 Mon Sep 17 00:00:00 2001 From: games647 Date: Sat, 20 Aug 2016 17:38:47 +0200 Subject: [PATCH] Fix console support for cracked/premium commands (Fixes# 62) --- CHANGELOG.md | 1 + .../fastlogin/bukkit/commands/CrackedCommand.java | 12 ++++++++---- .../fastlogin/bukkit/commands/PremiumCommand.java | 12 ++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e790833d..7a4b4040 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * Fix third-party not premium player detection * Fix ProtocolSupport BungeeCord +* Fix duplicate logins for BungeeAuth users ######1.7.1 diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/commands/CrackedCommand.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/commands/CrackedCommand.java index c3a71212..48741c33 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/commands/CrackedCommand.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/commands/CrackedCommand.java @@ -2,6 +2,7 @@ package com.github.games647.fastlogin.bukkit.commands; import com.github.games647.fastlogin.bukkit.FastLoginBukkit; import com.github.games647.fastlogin.core.PlayerProfile; +import com.google.common.collect.Iterables; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; @@ -99,10 +100,13 @@ public class CrackedCommand implements CommandExecutor { if (sender instanceof Player) { notifiyBungeeCord((Player) sender, target); } else { - plugin.getLogger().info("No player online to send a plugin message to the proxy"); - //todo: add console support -// Player firstPlayer = Iterables.getFirst(Bukkit.getOnlinePlayers(), null); -// notifiyBungeeCord(firstPlayer, target); + Player firstPlayer = Iterables.getFirst(Bukkit.getOnlinePlayers(), null); + if (firstPlayer == null) { + plugin.getLogger().info("No player online to send a plugin message to the proxy"); + return; + } + + notifiyBungeeCord(firstPlayer, target); } } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/commands/PremiumCommand.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/commands/PremiumCommand.java index 1d74a8f8..171a2cc3 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/commands/PremiumCommand.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/commands/PremiumCommand.java @@ -2,6 +2,7 @@ package com.github.games647.fastlogin.bukkit.commands; import com.github.games647.fastlogin.bukkit.FastLoginBukkit; import com.github.games647.fastlogin.core.PlayerProfile; +import com.google.common.collect.Iterables; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; @@ -117,10 +118,13 @@ public class PremiumCommand implements CommandExecutor { if (sender instanceof Player) { notifiyBungeeCord((Player) sender, target); } else { - plugin.getLogger().info("No player online to send a plugin message to the proxy"); - //todo: add console support -// Player firstPlayer = Iterables.getFirst(Bukkit.getOnlinePlayers(), null); -// notifiyBungeeCord(firstPlayer, target); + Player firstPlayer = Iterables.getFirst(Bukkit.getOnlinePlayers(), null); + if (firstPlayer == null) { + plugin.getLogger().info("No player online to send a plugin message to the proxy"); + return; + } + + notifiyBungeeCord(firstPlayer, target); } }