FastLogin icon indicating copy to clipboard operation
FastLogin copied to clipboard

Api problems

Open Mark7888 opened this issue 5 years ago • 9 comments

I'm a bit new in Bukkit Plugin developing, and i have some problems... I have written a code, like this:


import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
import com.github.games647.fastlogin.core.PremiumStatus;

public class TestClass extends JavaPlugin implements Listener
{
	@Override
	public void onEnable()
	{
		getServer().getPluginManager().registerEvents((Listener)this, this);
		Bukkit.getLogger().info("Plugin started");
	}


	@SuppressWarnings("deprecation")
	@EventHandler
	public void onPlayerJoinEvent(PlayerLoginEvent event)
	{
		Player player = event.getPlayer();
		
		PremiumStatus status = JavaPlugin.getPlugin(FastLoginBukkit.class).getStatus(player.getUniqueId());
		
		if(status.equals(PremiumStatus.PREMIUM))
		{
			Bukkit.getLogger().info("Premium");
		}
		else if(status.equals(PremiumStatus.CRACKED))
		{
			Bukkit.getLogger().info("Cracked");
		}
		else
		{
			Bukkit.getLogger().info("Unknown");
		}
	}
}

But i can't use it. When i start my server, the FastLogin plugin writes this, and dont let players join. And anyway, it writes me "Unknown", but idk why.

[00:44:26 WARN]: [FastLogin] No support offline Auth plugin found.
[00:44:26 WARN]: [FastLogin] No auth plugin were found by this plugin (other plugins could hook into this after the initialization of this plugin)and BungeeCord is deactivated. Either one or both of the checks have to pass in order to use this plugin

[00:44:46 INFO]: Unknown
[00:44:46 INFO]: Disconnecting com.mojang.authlib.GameProfile@3b49f11d[id=12685344-5c0a-3c3a-bf9e-49d5af15699a,name=Mark7888,properties={},legacy=false] (/127.0.0.1:50869): žcServer is not fully started yet. Please retry
[00:44:46 INFO]: com.mojang.authlib.GameProfile@3b49f11d[id=12685344-5c0a-3c3a-bf9e-49d5af15699a,name=Mark7888,properties={},legacy=false] (/127.0.0.1:50869) lost connection: žcServer is not fully started yet. Please retry

I'm connecting with a premium account, and it writes "legacy=false". What did i wrong?

I feel, i'm making a fool of myself now, but can someone help me, how can i make this thing working? I'm writing an own login plugin, and i need only to know, if the player is premium or not.

( Used FastLogin version: Build #943 (Mon May 18 14:11:18 UTC 2020) )

Mark7888 avatar Jun 25 '20 22:06 Mark7888

FastLogin in spigot will receive the premium status delayed. See the documentation on the API method:

https://github.com/games647/FastLogin/blob/de1487b6aae79bbbb054bc3d8f883bf159aff1d9/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java#L152-L153

You should delay your request until the data is received.

TuxCoding avatar Jun 26 '20 08:06 TuxCoding

Okay, thank you. And why can't anyone connect to the server? Why is it writing "Server is not fully started yet"? I think, it's because I'm not using supported login plugin. But how can i solve it?

Mark7888 avatar Jun 26 '20 08:06 Mark7888

Use a auth plugin or if you using a custom one you have register it here: https://github.com/games647/FastLogin/blob/de1487b6aae79bbbb054bc3d8f883bf159aff1d9/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java#L231

TuxCoding avatar Jun 26 '20 13:06 TuxCoding

Could you please give me a bit code examle, because when i try to use it, i get error. Whith this:

AuthPlugin<Player> auth;
JavaPlugin.getPlugin(FastLoginCore.class).setAuthPluginHook(auth);

I get this:

The method getPlugin(Class<T>) in the type JavaPlugin is not applicable for the arguments (Class<FastLoginCore>)

But when i try to use like this:

AuthPlugin<Player> auth;
FastLoginCore.setAuthPluginHook(auth);

I get this:

Cannot make a static reference to the non-static method setAuthPluginHook(AuthPlugin) from the type FastLoginCore

I dont really understand this part of java 😞

Mark7888 avatar Jun 26 '20 20:06 Mark7888

FastLoginCore is not a JavaPlugin FastLoginBukkit is. Core is the common component between all platform, you can get it with getCore().

TuxCoding avatar Jun 27 '20 11:06 TuxCoding

Actually the code seems to be working, but there is one problem. I connected with my premium (legacy) account, and it wrote, i am cracked. Here is the code: https://pastebin.com/rjgBsgVM

What did I do wrong?

Mark7888 avatar Jun 27 '20 15:06 Mark7888

The plugin reports only the way how the players are authenticated. If they are not registered as premium, then FastLogin cannot know that. FastLogin tries to make some assumptions based on the name and then request a premium authentication, but this have to be activated.

Furthermore you should actually implement the force* methods. They are currently doing nothing. If you don't want to create a custom auth plugin, you have choose one of the supported ones.

TuxCoding avatar Jun 27 '20 18:06 TuxCoding

I have a custom auth plugin. But i dont want to use this one to autologin, i just want to know, if the specific player premium or not. I dont want anything else. Just to know, if the player with paid client or not

I just want a simple method, what adds the player to the Premium list, when it connects, if it has premium client. The others will be done by my plugin.

Mark7888 avatar Jun 27 '20 19:06 Mark7888

I have a custom auth plugin. But i dont want to use this one to autologin, i just want to know, if the specific player premium or not. I dont want anything else. Just to know, if the player with paid client or not

For that it needs to enforce onlinemode logins. You could still turn off autologin in the configuration anyway.

I just want a simple method, what adds the player to the Premium list, when it connects, if it has premium client. The others will be done by my plugin.

See the FAQ. There is no way to just do it. FastLogin only knows the premium status if it requested it and the player didn't disconnect.

TuxCoding avatar Jun 29 '20 14:06 TuxCoding