Less deprecated warnings + Clean up

This commit is contained in:
games647 committed 2016-09-15 11:10:52 +02:00
1 parent 07d0aededa
commit 4292e9aaa0
16 files changed
+94 -58

No files matched your search

@@ -23,6 +23,16 @@ import net.md_5.bungee.config.YamlConfiguration;
public class BungeeCore extends FastLoginCore<ProxiedPlayer> {
private static Map<String, Object> generateConfigMap(Configuration config) {
Map<String, Object> configMap = Maps.newHashMap();
Collection<String> keys = config.getKeys();
for (String key : keys) {
configMap.put(key, config.get(key));
}
return configMap;
}
private final FastLoginBungee plugin;
public BungeeCore(FastLoginBungee plugin) {
@@ -93,13 +103,4 @@ public class BungeeCore extends FastLoginCore<ProxiedPlayer> {
}
}
private static Map<String, Object> generateConfigMap(Configuration config) {
Map<String, Object> configMap = Maps.newHashMap();
Collection<String> keys = config.getKeys();
for (String key : keys) {
configMap.put(key, config.get(key));
}
return configMap;
}
}
@@ -4,6 +4,7 @@ import com.github.games647.fastlogin.core.shared.LoginSource;
import java.net.InetSocketAddress;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.PendingConnection;
public class BungeeLoginSource implements LoginSource {
@@ -21,7 +22,7 @@ public class BungeeLoginSource implements LoginSource {
@Override
public void kick(String message) {
connection.disconnect(message);
connection.disconnect(TextComponent.fromLegacyText(message));
}
@Override
@@ -74,8 +74,9 @@ public class FastLoginBungee extends Plugin {
return core;
}
@Deprecated
public void setAuthPluginHook(BungeeAuthPlugin authPlugin) {
core.setAuthPlugin(authPlugin);
core.setAuthPluginHook(authPlugin);
}
public Configuration getConfig() {
@@ -91,14 +92,15 @@ public class FastLoginBungee extends Plugin {
*
* @return the auth hook for BungeeCord. null if none found
*/
@Deprecated
public BungeeAuthPlugin getBungeeAuthPlugin() {
return (BungeeAuthPlugin) core.getAuthPlugin();
return (BungeeAuthPlugin) core.getAuthPluginHook();
}
private void registerHook() {
Plugin plugin = getProxy().getPluginManager().getPlugin("BungeeAuth");
if (plugin != null) {
core.setAuthPlugin(new BungeeAuthHook());
core.setAuthPluginHook(new BungeeAuthHook());
getLogger().info("Hooked into BungeeAuth");
}
}
@@ -6,6 +6,8 @@ import com.github.games647.fastlogin.core.importer.ImportPlugin;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.plugin.Command;
public class ImportCommand extends Command {
@@ -21,7 +23,8 @@ public class ImportCommand extends Command {
@Override
public void execute(CommandSender sender, String[] args) {
if (args.length < 2) {
sender.sendMessage(ChatColor.DARK_RED + "You need to specify the import plugin and database type");
String message = ChatColor.DARK_RED + "You need to specify the import plugin and database type";
sender.sendMessage(convertFromLegacy(message));
return;
}
@@ -37,7 +40,8 @@ public class ImportCommand extends Command {
importPlugin = ImportPlugin.ELDZI;
break;
default:
sender.sendMessage(ChatColor.DARK_RED + "Unknown auto login plugin");
String message = ChatColor.DARK_RED + "Unknown auto login plugin";
sender.sendMessage(convertFromLegacy(message));
return;
}
@@ -50,7 +54,8 @@ public class ImportCommand extends Command {
sqlite = false;
break;
default:
sender.sendMessage(ChatColor.DARK_RED + "Unknown storage type to import from. Either SQLite or MySQL");
String message = ChatColor.DARK_RED + "Unknown storage type to import from. Either SQLite or MySQL";
sender.sendMessage(convertFromLegacy(message));
return;
}
@@ -60,8 +65,9 @@ public class ImportCommand extends Command {
String password = "";
if (!sqlite) {
if (args.length <= 5) {
sender.sendMessage(ChatColor.DARK_RED + "If importing from MySQL, you need to specify host database "
+ "and username passowrd too");
String message = ChatColor.DARK_RED + "If importing from MySQL, you need to specify host database "
+ "and username passowrd too";
sender.sendMessage(convertFromLegacy(message));
return;
}
@@ -75,9 +81,13 @@ public class ImportCommand extends Command {
AuthStorage storage = core.getStorage();
boolean success = core.importDatabase(importPlugin, true, storage, host, database, username, password);
if (success) {
sender.sendMessage(ChatColor.DARK_GREEN + "Successful imported the data");
sender.sendMessage(convertFromLegacy(ChatColor.DARK_GREEN + "Successful imported the data"));
} else {
sender.sendMessage(ChatColor.DARK_RED + "Failed to import the data. Check out the logs");
sender.sendMessage(convertFromLegacy(ChatColor.DARK_RED + "Failed to import the data. Check out the logs"));
}
}
private BaseComponent[] convertFromLegacy(String message) {
return TextComponent.fromLegacyText(message);
}
}
@@ -6,6 +6,7 @@ import com.github.games647.fastlogin.bungee.tasks.AsyncToggleMessage;
import com.github.games647.fastlogin.core.PlayerProfile;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import java.util.Arrays;
import net.md_5.bungee.api.ProxyServer;
@@ -16,7 +16,7 @@ public class AsyncPremiumCheck extends JoinManagement<ProxiedPlayer, BungeeLogin
private final PreLoginEvent preLoginEvent;
public AsyncPremiumCheck(FastLoginBungee plugin, PreLoginEvent preLoginEvent) {
super(plugin.getCore(), plugin.getBungeeAuthPlugin());
super(plugin.getCore(), plugin.getCore().getAuthPluginHook());
this.plugin = plugin;
this.preLoginEvent = preLoginEvent;
@@ -2,13 +2,14 @@ package com.github.games647.fastlogin.bungee.tasks;
import com.github.games647.fastlogin.bungee.BungeeLoginSession;
import com.github.games647.fastlogin.bungee.FastLoginBungee;
import com.github.games647.fastlogin.bungee.hooks.BungeeAuthPlugin;
import com.github.games647.fastlogin.core.PlayerProfile;
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import java.util.UUID;
import java.util.logging.Level;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.PendingConnection;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@@ -51,7 +52,7 @@ public class ForceLoginTask implements Runnable {
session.setAlreadySaved(true);
}
BungeeAuthPlugin authPlugin = plugin.getBungeeAuthPlugin();
AuthPlugin<ProxiedPlayer> authPlugin = plugin.getCore().getAuthPluginHook();
if (authPlugin == null) {
//save will happen on success message from bukkit
sendBukkitLoginNotification(autoRegister);
@@ -73,7 +74,7 @@ public class ForceLoginTask implements Runnable {
}
}
private void forceRegister(BungeeLoginSession session, BungeeAuthPlugin authPlugin) {
private void forceRegister(BungeeLoginSession session, AuthPlugin<ProxiedPlayer> authPlugin) {
if (session.isAlreadyLogged()) {
sendBukkitLoginNotification(true);
return;
@@ -88,12 +89,12 @@ public class ForceLoginTask implements Runnable {
String message = plugin.getCore().getMessage("auto-register");
if (message != null) {
message = message.replace("%password", password);
player.sendMessage(message);
player.sendMessage(TextComponent.fromLegacyText(message));
}
}
}
private void forceLogin(BungeeLoginSession session, BungeeAuthPlugin authPlugin) {
private void forceLogin(BungeeLoginSession session, AuthPlugin<ProxiedPlayer> authPlugin) {
if (session.isAlreadyLogged()) {
sendBukkitLoginNotification(false);
return;
@@ -105,7 +106,7 @@ public class ForceLoginTask implements Runnable {
sendBukkitLoginNotification(false);
String message = plugin.getCore().getMessage("auto-login");
if (message != null) {
player.sendMessage(message);
player.sendMessage(TextComponent.fromLegacyText(message));
}
}
}