PyvesB / advanced-achievements

:fireworks: Popular plugin that adds unique and challenging achievements to Minecraft servers.
https://www.spigotmc.org/resources/83466
GNU General Public License v3.0
199 stars 215 forks source link

NullPointException in Task #18 #6

Closed martinambrus closed 8 years ago

martinambrus commented 8 years ago

Hi,

I've got a couple of achievements set up and everything worked correctly until now. I don't see any client-side warnings, only server-side exception that is recurring (I'm guessing it's doing it every time aach tries to check for achievements). Here's the error:

[17:13:04 WARN]: [AdvancedAchievements] Task #18 for AdvancedAchievements v2.2 generated an exception
java.lang.NullPointerException
        at com.hm.achievement.db.SQLDatabaseManager.hasPlayerAchievement(SQLDatabaseManager.java:508) ~[?:?]
        at com.hm.achievement.runnable.AchievePlayTimeRunnable.registerTimes(AchievePlayTimeRunnable.java:70) ~[?:?]
        at com.hm.achievement.runnable.AchievePlayTimeRunnable.run(AchievePlayTimeRunnable.java:48) ~[?:?]
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:723) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_66]

Here's my config:

#==============================O==============================#
# I---------------------------------------------------------I #
# |    Advanced Achievements 2.2 configuration - Readme     | #
#1---------------------------------------------------------1 #
#==============================o==============================#

# You can use Minecraft chat colours in messages and names, but include ' ' around the whole text.
# If you want to use a ' in a text, write two ' instead, and include additional ' ' around the whole text.
# In command rewards, PLAYER designates the name of the player who got the achievement.
# Only spaces, no tabs. Don't forget the indents, plugin won't work otherwise! 
# To check your file, use: yaml-online-parser.appspot.com
# Available mobs for the Kills section: hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html
# Available items for rewards/Crafts/Places/Breaks: hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html
# Default file: dev.bukkit.org/bukkit-plugins/advanced-achievements/pages/configuration/

#=============================O=O=============================#
# II-------------------------------------------------------II #
# |                    General  settings                    | #
#2---------------------------------------------------------2 #
#=============================o=o=============================#

# Time in seconds between each /aach book.
TimeBook: 900

# Time in seconds between each /aach list.
TimeList: 0

# Check for update on plugin launch and notify when an OP joins the game.
CheckForUpdate: true

# Set to true to activate firework effects when a player receives an achievement.
Firework: true

# Choose BALL_LARGE, BALL, BURST, CREEPER or STAR.
FireworkStyle: BALL

# Set to true to activate particle effects when receiving book and when player in top list.
AdditionalEffects: true

# Set to true to activate sound effects when receiving book and when player in top list.
Sound: true

# Set to true if you are using a version of Vault prior to 1.4.
RetroVault: false

# Set the icon of the plugin (default: shamrock, "\u2618").
Icon: "\u2618"

# Set the color of the plugin (default: 5, dark purple).
Color: '5'

# Notify other connected players when an achievement is received.
ChatNotify: false

# Separator between name, description and date on a book page.
BookSeparator: ''

# Stop stats from increasing when player in creative mode (except Connections and PlayedTime).
RestrictCreative: false

# Stop stats from increasing when player in a specific world (delete the [] before using).
ExcludedWorlds: []
#  - yourWorld1
#  - yourWorld2

# Number of players displayed on /aach top command.
TopList: 5

# Obfuscate achievements that have not yet been received in /aach list.
ObfuscateNotReceived: true

# Hide categories with no achievements yet received in /aach list.
HideNotReceivedCategories: false

# Display achievement name and description as screen titles.
TitleScreen: false

#=============================OOO=============================#
# III-----------------------------------------------------III #
# |                    Database settings                    | #
#3---------------------------------------------------------3 #
#=============================ooo=============================#

# DO NOT CHANGE OR DELETE.
DatabaseVersion: 6

# Make a daily backup of your local database.
DatabaseBackup: false

# Database type, sqlite or mysql.
DatabaseType: mysql

# Settings to link with MySQL database (ignore if sqlite).
MYSQL:
  Database: 'jdbc:mysql://localhost:3306/minecraft'
  User: root
  Password: root

#============================OO=OO============================#
# IV-------------------------------------------------------IV #
# |                  Performance settings                   | #
#4---------------------------------------------------------4 #
#============================oo=oo============================#

# DO NOT CHANGE THE FOLLOWING UNLESS YOU ARE AN EXPERIENCED USER. The intervals are in seconds.
# Frequency of play time checks for players. Smaller values give more precision but more CPU usage.
# default: 150
PlaytimeTaskInterval: 150

# Calculates distance travelled by players. Smaller values give more precision but more CPU usage.
DistanceTaskInterval: 5

# Frequency of some statistics writes to the database.
PooledRequestsTaskInterval: 60

#============================OOOOO============================#
# V---------------------------------------------------------V #
# |                  Action  achievements                   | #
#5---------------------------------------------------------5 #
#============================ooooo============================#

DistanceFoot:
  '8500':
    Message: '&e/back&f command enabled'
    Name: Traveller
    Reward:
        Command: 'pex user PLAYER add mcf.back'
  '30000':
    Message: '&e/tploc&f command enabled'
    Name: Quick Feet
    Reward:
        Command: 'pex user PLAYER add mcf.tploc'

DistanceBoat:
  '12000':
    Message: '&e/back&f command enabled'
    Name: Traveller
    Reward:
        Command: 'pex user PLAYER add mcf.back'

Breaks:
  stone:
    '100':
      Message: '100 stones broken, have some diamonds :)'
      Name: The Gift
      Reward:
        Command: 'give PLAYER diamond 25'
    '1000':
      Message: '&e10%&f experience gain boost'
      Name: Gifted
      Reward:
        Command: 'pex user PLAYER add mcmmo.perks.xp.10percentboost.all'
    '1500':
      Message: 'all skills cooldown shortened by &e1/4'
      Name: Quick Recovery
      Reward:
        Command: 'pex user PLAYER add mcmmo.perks.cooldowns.quartered'
    '2000':
      Message: 'skills activation time prolonged by &e4 seconds'
      Name: Endurance
      Reward:
        Command: 'pex user PLAYER add mcmmo.perks.activationtime.fourseconds'
    # '1500':
      # Message: '&e50%&f experience gain boost'
      # Name: Graduate
      # Reward:
        # Command: 'pex user PLAYER add mcmmo.perks.xp.50percentboost.all'
    # '3000':
      # Message: 'experience gain &edoubled&f'
      # Name: Hard at Work
      # Reward:
        # Command: 'pex user PLAYER add mcmmo.perks.xp.double.all'
    # '6000':
      # Message: '&e150%&f experience gain boost'
      # Name: Workaholic
      # Reward:
        # Command: 'pex user PLAYER add mcmmo.perks.xp.150percentboost.all'
    # '3000':
      # Message: 'experience gain &etripled&f'
      # Name: Overload
      # Reward:
        # Command: 'pex user PLAYER add mcmmo.perks.xp.triple.all'
    # '3000':
      # Message: 'experience gain &quadrupled&f'
      # Name: Impossible
      # Reward:
        # Command: 'pex user PLAYER add mcmmo.perks.xp.quadruple.all'
PlayedTime:
  '5':
    Message: Experience comes with age. You have just aged 5 hours and gained 10xp levels.
    Name: First Five
    Reward:
      Command: 'xp 10L PLAYER'
  '10':
    Message: Ten hours passed for you in this realm. Please accept this 30xp levels gift.
    Name: Experienced
    Reward:
      Command: 'xp 30L PLAYER'

#===========================OOO=OOO===========================#
# VI-------------------------------------------------------VI #
# |                  Command achievements                   | #
#6---------------------------------------------------------6 #
#===========================ooo=ooo===========================#

# Let achievement commands be given several times.
MultiCommand: true

# A player with achievement.give (or the console) can use the /aach give yourAch1 playerName 
# to give yourAch1 achievement to playerName.
#Commands:
#  yourAch1:
#    Message: You took part in the special event!
#    Name: Special Event Achievement! 

No idea what's wrong from that error alone though. Seems to be playedtime-related. Here's my playedtime table:

+--------------------------------------+------------+
| playername                           | playedtime |
+--------------------------------------+------------+
| cde563e7-7874-313a-9f5e-15c26d764062 |     255353 |
+--------------------------------------+------------+

Thanks!

martinambrus commented 8 years ago

btw, Running latest Spigot

PyvesB commented 8 years ago

Hello,

Is this issue only happening with the PlayedTime achievement? Have you tried restarting your server completely (and not just doing server or plugin reloads)?

martinambrus commented 8 years ago

Only for PlayedTime and yes, I did restart the server completely.

PyvesB commented 8 years ago

Indeed, I've been able to reproduce the bug with your configuration file. The problem seems to happen when you set more than one PlayedTime achievements. Could you please try and delete the second one, and confirm that the problem goes away?

martinambrus commented 8 years ago

Yup, the problem goes away with only a single PlayedTime achievement.

PyvesB commented 8 years ago

Ok, so we've already done half of the work by spotting the origin of the bug. I'll try to fix the problem in the coming days, and keep you updated with the progress. ;-)

PyvesB commented 8 years ago

Hello,

Here is a test version with some fixes on the PlayedTime achievement (I uploaded it on my Mega account as GitHub rejected my jar file attached to this comment): https://mega.nz/#!F8BWmApC!0nVX222MLANC6Yh9G7V6dIBfLRlkwJSxo-Epm6P5iFk

Could you please check it out and confirm that it solves your issue?

martinambrus commented 8 years ago

Thank you. I can confirm that the version from Mega doesn't exhibit any unhealthy behavior :)

PyvesB commented 8 years ago

Perfect! I will publish an official update in the upcoming hours, I recommend that you also upgrade (in case I make any additional changes and also to have the correct version number).

Anyway thank you your bug report; don't hesitate if you have any other concerns and feel free to star the project if you wish. ;-)