games647 / FlexibleLogin

A Sponge minecraft server plugin for second factor authentication

Home Page:https://forums.spongepowered.org/t/8872

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem Login, register with PHP in Mysql

MacKey-255 opened this issue · comments

Hello, I have a problem with my minecraft forge server (Forge: forge-1.12.2-14.23.4.2705 AND SPONGEFORGE: spongeforge-1.12.2-2705-7.1.0-BETA-3218), when I register a user in the database, when logging in the server is not logged in, but it shows an error in the console.

ERROR:

[23:43:16] [Server thread/INFO] [nucleus]: MacKey ran the command: /login password
[23:43:16] [pool-3-thread-20/ERROR] [Sponge]: The Scheduler tried to run the task Login Query owned by Plugin{id=flexiblelogin, name=FlexibleLogin, version=0.17.3, description=Second Auth plugin for Sponge Minecraft servers, url=https://github.com/games647/FlexibleLogin, source=./mods/1.12.2/flexiblelogin-0.17.3.jar}, but an error occured.
java.nio.BufferUnderflowException: null
	at java.nio.Buffer.nextGetIndex(Buffer.java:506) ~[?:1.8.0_151]
	at java.nio.HeapByteBuffer.getLong(HeapByteBuffer.java:412) ~[?:1.8.0_151]
	at com.github.games647.flexiblelogin.Account.<init>(Account.java:73) ~[Account.class:?]
	at com.github.games647.flexiblelogin.Database.loadAccount(Database.java:210) ~[Database.class:?]
	at com.github.games647.flexiblelogin.Database.loadAccount(Database.java:193) ~[Database.class:?]
	at com.github.games647.flexiblelogin.tasks.LoginTask.run(LoginTask.java:54) ~[LoginTask.class:?]
	at org.spongepowered.api.scheduler.Task$Builder.lambda$execute$0(Task.java:139) ~[Task$Builder.class:1.12.2-2705-7.1.0-BETA-3218]
	at org.spongepowered.common.scheduler.SchedulerBase.lambda$startTask$0(SchedulerBase.java:186) ~[SchedulerBase.class:1.12.2-2705-7.1.0-BETA-3218]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_151]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_151]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_151]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_151]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]

CODE PHP:

// Create UUID String
$uuid = Util::constructOfflinePlayerUuid("MacKey");

$element = array(
            'uuid' => $uuid,
            'username' => "MacKey",
            'hash' => password_hash("password", PASSWORD_BCRYPT),
            'ip' => "127.0.0.1"
);

$sql = 'INSERT INTO flexiblelogin_users (UUID, Username, Password, IP) '
             . 'VALUES (UNHEX(REPLACE("'. $element['uuid'] .'","-","")), "'. $element['username'] .'", "'. $element['hash'] 
             .'", INET6_ATON("'. $element['ip'] .'")';
         $queryScore = $this->getEntityManager()->getConnection();    // This is equal mysql Class
         $consulta = $queryScore->prepare($sql);
         return $consulta->execute();

.SAlu2s