Some methods of MCBansAPI don't work correctly.
ucchyocean opened this issue · 17 comments
Hi,
MCBansAPI does not work correctly.
Please check the following.
Regarding MCBansAPI#kick method
This method does not work on MCBans v4.3.2. MCBans said "xxx is not online!" always.
[03:16:49] [Server thread/INFO]: [Honeychest] successfully rolled back stolen items from player ucchy at location (world:-126,78,-44) [03:16:49] [Thread-11/INFO]: [MCBans] �ucchy is not online!
Maybe, "MCBans#getPlayer(plugin, uuid)" method returns null always. Please check this.
(MCBansAPI#kick method works correctly on MCBans v4.3.1.)
Regarding MCBansAPI#localBan method
This method throws NullPointerException. I checked with MCBans v4.3.1 and v4.3.2.
[03:31:08] [Server thread/INFO]: [MCBans] Plugin Honeychest tried to local ban player ucchy [03:31:08] [Server thread/INFO]: �[Honeychest]� �Player�ucchy was caught stealing from honeychest. [03:31:08] [Server thread/INFO]: �Stolen Item(s): �-(1x DIAMOND_SWORD) [03:31:08] [Server thread/INFO]: [Honeychest] successfully rolled back stolen items from player ucchy at location (world:-126,78,-44) [03:31:08] [Thread-24/INFO]: PlayerBanEvent : ucchy [03:31:08] [Thread-24/WARN]: Exception in thread "Thread-24" [03:31:08] [Thread-24/WARN]: java.lang.NullPointerException [03:31:08] [Thread-24/WARN]: at com.mcbans.firestar.mcbans.request.Ban.run(Ban.java:114) [03:31:08] [Thread-24/WARN]: at java.lang.Thread.run(Thread.java:744)
Thanks and regards,
Ucchy
Maybe, "MCBans#getPlayer(plugin, uuid)" method returns null always. Please check this.
public static Player getPlayer(Plugin plugin, String UUID)
isn't strictly an McBans API method. In order to get a Player
object from a UUID, it may be better to use Bukkit.getPlayer(String UUID)
, as the getPlayer()
method in McBans.java only returns online players.
This method throws NullPointerException. I checked with MCBans v4.3.1 and v4.3.2.
The NullPointerException being triggered may also be due to an error in the UUID being parsed to the localBan()
method. Line 114 of Ban.java reads if(!playerUUID.equals("")){
, which could mean that the public static Player getPlayer(Plugin plugin, String UUID)
found in McBans.java could be returning a String equal to ""
.
Thanks,
psgs 🌴
Maybe, "MCBans#getPlayer(plugin, uuid)" method returns null always. Please check this.
public static Player getPlayer(Plugin plugin, String UUID)
isn't strictly an McBans API method.
Yes. Your said is right.
In order to get a
Player
object from a UUID, it may be better to useBukkit.getPlayer(String UUID)
, as thegetPlayer()
method in McBans.java only returns online players.
Yes. I know.
But I want to check MCBansAPI#kick method. This method returns "xxx is not online!" error always. Why?
MCBansAPI#kick method of MCBans v4.3.1 works correctly. Why?
I decompiled MCBans v4.3.2 for debug. (Sorry! Firestar did not commit MCBans v4.3.2 source codes.)
I found strange point.
I thought this is a reason that MCBansAPI#kick method returns "xxx is not online!" error. So please check this point.
This method throws NullPointerException. I checked with MCBans v4.3.1 and v4.3.2.
The NullPointerException being triggered may also be due to an error in the UUID being parsed to the
localBan()
method. Line 114 of Ban.java readsif(!playerUUID.equals("")){
, which could mean that thepublic static Player getPlayer(Plugin plugin, String UUID)
found in McBans.java could be returning a String equal to""
.
Yes. I know.
I set "" String, but this method threw NullPointerException at same position.
Did you check that??
@ucchyocean, McBans is throwing a NullPointerException and returning an Offline Player error because you're using the getPlayer()
method in McBans.java to get a Player's UUID, instead of Bukkit.getPlayer()
😉
McBans is throwing a NullPointerException and returning an Offline Player error because you're using the
getPlayer()
method in McBans.java to get a Player's UUID, instead ofBukkit.getPlayer()
No.
I used MCBans#getPlayer() method just for debug. I don't use that MCBans#getPlayer() method in my plugin.
@ucchyocean, Are you able to provide a full StackTrace (error log) of the error's you're receiving? A snippet of the code you're using to access the McBans API may also be useful in determining how we can fix this issue 😄
The uuid detection in the plugin has been removed to allow the plugin to work on all versions. MCBans handles all player=>UUID and UUID=> player on the API side of mcbans. api.mcbans.com
@PSGS OK. Here.
https://gist.github.com/ucchyocean/e0a8860737613a6c99ab
Regarding MCBansAPI#kick method, please see L169 and L173 and L178.
MCBans said "xxx is not online!", and the player was not kicked.
My plugin code is here.
https://github.com/ucchyocean/Honeychest/blob/master/src/main/java/syam/Honeychest/bans/BanHandler.java#L192
Regarding MCBansAPI#localBan method, please see L343-345 and L364-366.
MCBans threw NullPointerException.
The player was kicked, but he was not banned.
My plugin code is here.
https://github.com/ucchyocean/Honeychest/blob/master/src/main/java/syam/Honeychest/bans/BanHandler.java#L179
The uuid detection in the plugin has been removed to allow the plugin to work on all versions. MCBans handles all player=>UUID and UUID=> player on the API side of mcbans. api.mcbans.com
OK. Thanks. I understood.
Probably this method will not be a cause of "xxx is not online!" error.
What considers you as a cause?
@firestar No.
OK. I made small plugin for test.
https://github.com/ucchyocean/MCBansAPITestPlugin/blob/master/src/main/java/jp/ucchy/test/TestPlugin.java
I checked MCBansAPI#kick method. This method said "xxx is not online!" error in sender's display.
https://gist.github.com/ucchyocean/7a8d38e7e0c034df5bb4#file-gistfile1-txt-L250-L253
And I checked MCBansAPI#localBan method. This method throws NullPointerException always.
Please see this log file.
https://gist.github.com/ucchyocean/7a8d38e7e0c034df5bb4#file-gistfile1-txt-L254-L271
The player was not kicked, and he was not banned.
MCBansAPI#kick method of MCBans v4.3.1 works correctly.
But v4.3.2 is NG.
MCBansAPI#localBan method throws NullPointerException always.
Both of v4.3.1 and v4.3.2 are NG.
My sample plugin is here. https://github.com/ucchyocean/MCBansAPITestPlugin/blob/master/release/MCBansAPITestPlugin.jar?raw=true
Please check this issue and fix it. Thanks.
I think the following line is cause of NullPointerException.
https://github.com/MCBans/MCBans/blob/master/src/com/mcbans/firestar/mcbans/api/MCBansAPI.java#L45
Please change this line from
Ban banControl = new Ban(plugin, type.getActionName(), targetName, targetIP, senderName, reason, duration, measure);
to
Ban banControl = new Ban(plugin, type.getActionName(), targetName, targetUUID, targetIP, senderName, senderUUID, reason, duration, measure, null, false);
I fixed this NPE. Please review and merge pull request #78.
Regarding MCBansAPI#kick method, "xxx is not online!" error. I found a workaround.
If MCBansAPI was gave the targetUUID, MCBans could not find the target player.
If MCBansAPI was gave the empty targetUUID, MCBans could find the target player.
Please see the following fix.
https://github.com/ucchyocean/MCBansAPITestPlugin/blob/master/src/main/java/jp/ucchy/test/TestPlugin.java#L49-L50
Now I can kick by MCBansAPI. But I feel strange about this point. Is it OK?
Regarding NPE, thank you so much to merge pull request #78.
You saved me! :D
Regarding MCBansAPI#kick method error, I will use workaround.
But please remember to implement MCBans#getPlayer() method.
I close this issue. Thank you so much!
The same problem is reported in honeypot plugin.
http://dev.bukkit.org/bukkit-plugins/honeypot/#c222
Please release the fixed version.
New version released http://forums.mcbans.com/threads/mcbans-4-3-4-and-mcbans-proxy-1-3-1.2432/