Less deprecated warnings + Clean up

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

View File

@ -159,8 +159,9 @@ public class FastLoginBukkit extends JavaPlugin {
*
* @return interface to any supported auth plugin
*/
@Deprecated
public BukkitAuthPlugin getAuthPlugin() {
AuthPlugin<Player> authPlugin = core.getAuthPlugin();
AuthPlugin<Player> authPlugin = core.getAuthPluginHook();
if (authPlugin == null) {
try {
Thread.sleep(1000);
@ -172,8 +173,9 @@ public class FastLoginBukkit extends JavaPlugin {
return (BukkitAuthPlugin) authPlugin;
}
@Deprecated
public void setAuthPluginHook(BukkitAuthPlugin authPlugin) {
core.setAuthPlugin(authPlugin);
core.setAuthPluginHook(authPlugin);
}
public boolean isBungeeCord() {

View File

@ -161,6 +161,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public void playNote(Location loc, byte instrument, byte note) {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -181,6 +182,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public void playEffect(Location loc, Effect effect, int data) {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -191,16 +193,19 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public void sendBlockChange(Location loc, Material material, byte data) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
@Deprecated
public boolean sendChunkChange(Location loc, int sx, int sy, int sz, byte[] data) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
@Deprecated
public void sendBlockChange(Location loc, int material, byte data) {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -476,6 +481,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public boolean isOnGround() {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -511,6 +517,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public void setTexturePack(String url) {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -561,11 +568,13 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public void sendTitle(String title, String subtitle) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
@Deprecated
public void resetTitle() {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -686,11 +695,13 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public ItemStack getItemInHand() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
@Deprecated
public void setItemInHand(ItemStack item) {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -751,6 +762,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance) {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -761,6 +773,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public Block getTargetBlock(HashSet<Byte> transparent, int maxDistance) {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -771,6 +784,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public List<Block> getLastTwoTargetBlocks(HashSet<Byte> transparent, int maxDistance) {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -816,6 +830,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public int _INVALID_getLastDamage() {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -826,6 +841,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public void _INVALID_setLastDamage(int damage) {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -1226,6 +1242,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public void _INVALID_damage(int amount) {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -1236,6 +1253,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public void _INVALID_damage(int amount, Entity source) {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -1246,6 +1264,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public int _INVALID_getHealth() {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -1256,6 +1275,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public void _INVALID_setHealth(int health) {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -1266,6 +1286,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public int _INVALID_getMaxHealth() {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -1276,6 +1297,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public void _INVALID_setMaxHealth(int health) {
throw new UnsupportedOperationException("Not supported yet.");
}
@ -1331,6 +1353,7 @@ public class FakePlayer implements Player {
}
@Override
@Deprecated
public void setBanned(boolean banned) {
throw new UnsupportedOperationException("Not supported yet.");
}

View File

@ -1,9 +1,9 @@
package com.github.games647.fastlogin.bukkit.listener;
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
import com.github.games647.fastlogin.bukkit.tasks.ForceLoginTask;
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
import com.github.games647.fastlogin.bukkit.hooks.BukkitAuthPlugin;
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
import com.google.common.base.Charsets;
import com.google.common.collect.Sets;
import com.google.common.io.ByteArrayDataInput;
@ -80,7 +80,7 @@ public class BungeeCordListener implements PluginMessageListener {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
BukkitAuthPlugin authPlugin = plugin.getAuthPlugin();
AuthPlugin<Player> authPlugin = plugin.getCore().getAuthPluginHook();
try {
//we need to check if the player is registered on Bukkit too
if (authPlugin == null || !authPlugin.isRegistered(playerName)) {

View File

@ -4,8 +4,8 @@ import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketEvent;
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
import com.github.games647.fastlogin.core.shared.JoinManagement;
import com.github.games647.fastlogin.core.PlayerProfile;
import com.github.games647.fastlogin.core.shared.JoinManagement;
import java.util.Random;
import java.util.logging.Level;
@ -23,7 +23,7 @@ public class NameCheckTask extends JoinManagement<Player, ProtocolLibLoginSource
private final String username;
public NameCheckTask(FastLoginBukkit plugin, PacketEvent packetEvent, Random random, Player player, String username) {
super(plugin.getCore(), plugin.getAuthPlugin());
super(plugin.getCore(), plugin.getCore().getAuthPluginHook());
this.plugin = plugin;
this.packetEvent = packetEvent;

View File

@ -19,7 +19,7 @@ public class ProtocolSupportListener extends JoinManagement<Player, ProtocolLogi
protected final FastLoginBukkit plugin;
public ProtocolSupportListener(FastLoginBukkit plugin) {
super(plugin.getCore(), plugin.getAuthPlugin());
super(plugin.getCore(), plugin.getCore().getAuthPluginHook());
this.plugin = plugin;
}
@ -27,7 +27,7 @@ public class ProtocolSupportListener extends JoinManagement<Player, ProtocolLogi
@EventHandler(ignoreCancelled = true)
public void onLoginStart(PlayerLoginStartEvent loginStartEvent) {
plugin.setServerStarted();
if (loginStartEvent.isLoginDenied() || plugin.getAuthPlugin() == null) {
if (loginStartEvent.isLoginDenied() || plugin.getCore().getAuthPluginHook() == null) {
return;
}

View File

@ -63,8 +63,8 @@ public class DelayedAuthHook implements Runnable {
return false;
}
if (plugin.getAuthPlugin() == null) {
plugin.getCore().setAuthPlugin(authPluginHook);
if (plugin.getCore().getAuthPluginHook() == null) {
plugin.getCore().setAuthPluginHook(authPluginHook);
}
return true;

View File

@ -2,9 +2,9 @@ package com.github.games647.fastlogin.bukkit.tasks;
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
import com.github.games647.fastlogin.bukkit.hooks.BukkitAuthPlugin;
import com.github.games647.fastlogin.core.AuthStorage;
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;
@ -45,7 +45,7 @@ public class ForceLoginTask implements Runnable {
//check if it's the same player as we checked before
if (session.isVerified() && player.getName().equals(session.getUsername())) {
//premium player
BukkitAuthPlugin authPlugin = plugin.getAuthPlugin();
AuthPlugin<Player> authPlugin = plugin.getCore().getAuthPluginHook();
if (authPlugin == null) {
//maybe only bungeecord plugin
sendSuccessNotification();
@ -85,7 +85,7 @@ public class ForceLoginTask implements Runnable {
}
}
private boolean forceRegister(BukkitAuthPlugin authPlugin, Player player) {
private boolean forceRegister(AuthPlugin<Player> authPlugin, Player player) {
plugin.getLogger().log(Level.FINE, "Register player {0}", player.getName());
String generatedPassword = plugin.getCore().getPasswordGenerator().getRandomPassword(player);
@ -99,7 +99,7 @@ public class ForceLoginTask implements Runnable {
return success;
}
private boolean forceLogin(BukkitAuthPlugin authPlugin, Player player) {
private boolean forceLogin(AuthPlugin<Player> authPlugin, Player player) {
plugin.getLogger().log(Level.FINE, "Logging player {0} in", player.getName());
boolean success = authPlugin.forceLogin(player);

View File

@ -15,17 +15,9 @@ dev-url: ${project.url}
load: STARTUP
softdepend:
# We require either ProtocolLib or ProtocolSupport
# We depend either ProtocolLib or ProtocolSupport
- ProtocolSupport
- ProtocolLib
# Auth plugins - we delay the hook
# - xAuth
# - AuthMe
# - LogIt
# - CrazyLogin
# - LoginSecurity
# - RoyalAuth
# - UltraAuth
commands:
${project.parent.name}:

View File

@ -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;
}
}

View File

@ -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

View File

@ -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");
}
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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));
}
}
}

View File

@ -26,7 +26,10 @@ import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
public abstract class FastLoginCore<T> {
/**
* @param <P> Player class
*/
public abstract class FastLoginCore<P> {
public static <K, V> ConcurrentMap<K, V> buildCache(int expireAfterWrite, int maxSize) {
CompatibleCacheBuilder<Object, Object> builder = CompatibleCacheBuilder.newBuilder();
@ -67,8 +70,8 @@ public abstract class FastLoginCore<T> {
private MojangApiConnector mojangApiConnector;
private AuthStorage storage;
private PasswordGenerator<T> passwordGenerator = new DefaultPasswordGenerator<>();
private AuthPlugin<T> authPlugin;
private PasswordGenerator<P> passwordGenerator = new DefaultPasswordGenerator<>();
private AuthPlugin<P> authPlugin;
public FastLoginCore(Map<String, Object> config) {
this.pendingLogins = FastLoginCore.buildCache(5, 0);
@ -164,11 +167,11 @@ public abstract class FastLoginCore<T> {
return sharedConfig;
}
public PasswordGenerator<T> getPasswordGenerator() {
public PasswordGenerator<P> getPasswordGenerator() {
return passwordGenerator;
}
public void setPasswordGenerator(PasswordGenerator<T> passwordGenerator) {
public void setPasswordGenerator(PasswordGenerator<P> passwordGenerator) {
this.passwordGenerator = passwordGenerator;
}
@ -180,11 +183,11 @@ public abstract class FastLoginCore<T> {
return pendingConfirms;
}
public AuthPlugin<T> getAuthPlugin() {
public AuthPlugin<P> getAuthPluginHook() {
return authPlugin;
}
public void setAuthPlugin(AuthPlugin<T> authPlugin) {
public void setAuthPluginHook(AuthPlugin<P> authPlugin) {
this.authPlugin = authPlugin;
}