2011-09-12 10:47:57 +02:00
/ *
This file is part of mcMMO .
mcMMO is free software : you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
mcMMO is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with mcMMO . If not , see < http : //www.gnu.org/licenses/>.
* /
2011-04-16 23:35:17 +02:00
package com.gmail.nossr50.datatypes ;
import java.io.BufferedReader ;
import java.io.BufferedWriter ;
import java.io.FileReader ;
import java.io.FileWriter ;
import java.util.HashMap ;
import java.util.ArrayList ;
import java.util.logging.Level ;
import java.util.logging.Logger ;
2011-08-06 05:04:44 +02:00
import org.bukkit.Bukkit ;
2011-04-16 23:35:17 +02:00
import org.bukkit.Location ;
import org.bukkit.entity.Player ;
2011-04-20 22:56:25 +02:00
import com.gmail.nossr50.config.LoadProperties ;
2011-07-19 16:17:14 +02:00
import com.gmail.nossr50.m ;
2011-04-16 23:35:17 +02:00
import com.gmail.nossr50.mcMMO ;
public class PlayerProfile
{
protected final Logger log = Logger . getLogger ( " Minecraft " ) ;
2011-07-10 02:18:00 +02:00
2011-08-19 17:40:14 +02:00
//HUD
2011-08-23 03:22:16 +02:00
private HUDType hud ;
2011-08-19 17:40:14 +02:00
2011-07-10 02:18:00 +02:00
//MISC
private String party , myspawn , myspawnworld , invite ;
//TOGGLES
2011-09-12 12:36:26 +02:00
private boolean partyhud = true , spoutcraft = false , filling = false , xpbarlocked = false , placedAnvil = false , partyChatMode = false , adminChatMode = false , godMode = false , greenTerraMode , partyChatOnly = false , greenTerraInformed = true , berserkInformed = true , skullSplitterInformed = true , gigaDrillBreakerInformed = true ,
2011-04-16 23:35:17 +02:00
superBreakerInformed = true , serratedStrikesInformed = true , treeFellerInformed = true , dead , abilityuse = true , treeFellerMode , superBreakerMode , gigaDrillBreakerMode ,
2011-07-10 02:18:00 +02:00
serratedStrikesMode , hoePreparationMode = false , shovelPreparationMode = false , swordsPreparationMode = false , fistsPreparationMode = false , pickaxePreparationMode = false , axePreparationMode = false , skullSplitterMode , berserkMode ;
//TIMESTAMPS
2011-04-16 23:35:17 +02:00
//ATS = (Time of) Activation Time Stamp
//DATS = (Time of) Deactivation Time Stamp
2011-09-14 21:45:06 +02:00
private int recentlyHurt = 0 , berserkATS = 0 , berserkDATS = 0 , gigaDrillBreakerATS = 0 , gigaDrillBreakerDATS = 0 ,
2011-07-10 02:18:00 +02:00
respawnATS = 0 , mySpawnATS = 0 , greenTerraATS = 0 , greenTerraDATS = 0 , superBreakerATS = 0 , superBreakerDATS = 0 , serratedStrikesATS = 0 , serratedStrikesDATS = 0 , treeFellerATS = 0 , treeFellerDATS = 0 ,
skullSplitterATS = 0 , skullSplitterDATS = 0 , hoePreparationATS = 0 , axePreparationATS = 0 , pickaxePreparationATS = 0 , fistsPreparationATS = 0 , shovelPreparationATS = 0 , swordsPreparationATS = 0 ;
2011-04-16 23:35:17 +02:00
2011-08-16 11:33:34 +02:00
private SkillType lastgained = null , skillLock = null ;
2011-08-05 05:01:52 +02:00
2011-07-10 02:18:00 +02:00
//MySQL STUFF
2011-08-05 05:01:52 +02:00
private int xpbarinc = 0 , lastlogin = 0 , userid = 0 , bleedticks = 0 ;
2011-07-10 02:18:00 +02:00
//MAGIC STUFF
private int mana = 0 ;
private int greenDyeCycleSel = 0 , greenDyeCycle = 0 , blueDyeCycle = 0 , blueDyeCycleSel = 0 ;
public boolean dyeChanged = false ;
private String playername ;
//Time to HashMap this shiz
2011-07-19 16:17:14 +02:00
HashMap < SkillType , Integer > skills = new HashMap < SkillType , Integer > ( ) ; //Skills and XP
HashMap < SkillType , Integer > skillsXp = new HashMap < SkillType , Integer > ( ) ; //Skills and XP
2011-07-16 09:52:15 +02:00
String location = " plugins/mcMMO/FlatFileStuff/mcmmo.users " ;
2011-04-16 23:35:17 +02:00
public PlayerProfile ( Player player )
{
2011-08-23 03:22:16 +02:00
hud = LoadProperties . defaulthud ;
2011-07-10 02:18:00 +02:00
//Setup the HashMap for the skills
2011-08-06 05:44:33 +02:00
for ( SkillType skillType : SkillType . values ( ) )
{
if ( skillType ! = SkillType . ALL )
{
skills . put ( skillType , 0 ) ;
skillsXp . put ( skillType , 0 ) ;
}
}
2011-07-10 02:18:00 +02:00
playername = player . getName ( ) ;
2011-05-04 08:24:08 +02:00
if ( LoadProperties . useMySQL )
{
2011-04-17 22:45:20 +02:00
if ( ! loadMySQL ( player ) ) {
addMySQLPlayer ( player ) ;
2011-04-28 10:49:40 +02:00
loadMySQL ( player ) ; //This is probably not needed anymore, could just delete
}
2011-04-16 23:35:17 +02:00
} else {
if ( ! load ( ) ) { addPlayer ( ) ; }
}
2011-07-10 02:18:00 +02:00
lastlogin = ( ( Long ) ( System . currentTimeMillis ( ) / 1000 ) ) . intValue ( ) ;
2011-04-16 23:35:17 +02:00
}
2011-07-10 02:18:00 +02:00
public int getLastLogin ( )
{
return lastlogin ;
2011-04-30 22:53:08 +02:00
}
2011-07-10 02:18:00 +02:00
public int getMySQLuserId ( )
{
2011-04-17 22:45:20 +02:00
return userid ;
}
2011-04-16 23:35:17 +02:00
2011-07-10 02:18:00 +02:00
public boolean loadMySQL ( Player p )
{
2011-04-16 23:35:17 +02:00
Integer id = 0 ;
2011-04-26 06:10:38 +02:00
id = mcMMO . database . GetInt ( " SELECT id FROM " + LoadProperties . MySQLtablePrefix + " users WHERE user = ' " + p . getName ( ) + " ' " ) ;
2011-04-27 00:54:56 +02:00
if ( id = = 0 )
return false ;
2011-04-16 23:35:17 +02:00
this . userid = id ;
if ( id > 0 ) {
2011-08-21 03:23:38 +02:00
HashMap < Integer , ArrayList < String > > huds = mcMMO . database . Read ( " SELECT hudtype FROM " + LoadProperties . MySQLtablePrefix + " huds WHERE user_id = " + id ) ;
if ( huds . get ( 1 ) = = null )
{
mcMMO . database . Write ( " INSERT INTO " + LoadProperties . MySQLtablePrefix + " huds (user_id) VALUES ( " + id + " ) " ) ;
} else {
2011-08-23 03:22:16 +02:00
if ( huds . get ( 1 ) . get ( 0 ) ! = null )
{
2011-08-21 03:23:38 +02:00
for ( HUDType x : HUDType . values ( ) )
{
if ( x . toString ( ) . equals ( huds . get ( 1 ) . get ( 0 ) ) )
{
hud = x ;
}
}
2011-08-23 03:22:16 +02:00
} else {
hud = LoadProperties . defaulthud ;
}
2011-08-21 03:23:38 +02:00
}
2011-04-26 06:10:38 +02:00
HashMap < Integer , ArrayList < String > > users = mcMMO . database . Read ( " SELECT lastlogin, party FROM " + LoadProperties . MySQLtablePrefix + " users WHERE id = " + id ) ;
2011-07-10 02:18:00 +02:00
//lastlogin = Integer.parseInt(users.get(1).get(0));
2011-04-16 23:35:17 +02:00
party = users . get ( 1 ) . get ( 1 ) ;
2011-04-26 06:10:38 +02:00
HashMap < Integer , ArrayList < String > > spawn = mcMMO . database . Read ( " SELECT world, x, y, z FROM " + LoadProperties . MySQLtablePrefix + " spawn WHERE user_id = " + id ) ;
2011-04-16 23:35:17 +02:00
myspawnworld = spawn . get ( 1 ) . get ( 0 ) ;
myspawn = spawn . get ( 1 ) . get ( 1 ) + " , " + spawn . get ( 1 ) . get ( 2 ) + " , " + spawn . get ( 1 ) . get ( 3 ) ;
2011-04-30 22:53:08 +02:00
HashMap < Integer , ArrayList < String > > cooldowns = mcMMO . database . Read ( " SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes FROM " + LoadProperties . MySQLtablePrefix + " cooldowns WHERE user_id = " + id ) ;
/ *
* I ' m still learning MySQL , this is a fix for adding a new table
* its not pretty but it works
* /
if ( cooldowns . get ( 1 ) = = null )
{
mcMMO . database . Write ( " INSERT INTO " + LoadProperties . MySQLtablePrefix + " cooldowns (user_id) VALUES ( " + id + " ) " ) ;
}
else
{
2011-08-05 05:01:52 +02:00
superBreakerDATS = Integer . valueOf ( cooldowns . get ( 1 ) . get ( 0 ) ) ;
treeFellerDATS = Integer . valueOf ( cooldowns . get ( 1 ) . get ( 1 ) ) ;
berserkDATS = Integer . valueOf ( cooldowns . get ( 1 ) . get ( 2 ) ) ;
greenTerraDATS = Integer . valueOf ( cooldowns . get ( 1 ) . get ( 3 ) ) ;
gigaDrillBreakerDATS = Integer . valueOf ( cooldowns . get ( 1 ) . get ( 4 ) ) ;
serratedStrikesDATS = Integer . valueOf ( cooldowns . get ( 1 ) . get ( 5 ) ) ;
skullSplitterDATS = Integer . valueOf ( cooldowns . get ( 1 ) . get ( 6 ) ) ;
2011-04-30 22:53:08 +02:00
}
2011-07-19 16:17:14 +02:00
HashMap < Integer , ArrayList < String > > stats = mcMMO . database . Read ( " SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics FROM " + LoadProperties . MySQLtablePrefix + " skills WHERE user_id = " + id ) ;
skills . put ( SkillType . TAMING , Integer . valueOf ( stats . get ( 1 ) . get ( 0 ) ) ) ;
skills . put ( SkillType . MINING , Integer . valueOf ( stats . get ( 1 ) . get ( 1 ) ) ) ;
skills . put ( SkillType . REPAIR , Integer . valueOf ( stats . get ( 1 ) . get ( 2 ) ) ) ;
skills . put ( SkillType . WOODCUTTING , Integer . valueOf ( stats . get ( 1 ) . get ( 3 ) ) ) ;
skills . put ( SkillType . UNARMED , Integer . valueOf ( stats . get ( 1 ) . get ( 4 ) ) ) ;
skills . put ( SkillType . HERBALISM , Integer . valueOf ( stats . get ( 1 ) . get ( 5 ) ) ) ;
skills . put ( SkillType . EXCAVATION , Integer . valueOf ( stats . get ( 1 ) . get ( 6 ) ) ) ;
skills . put ( SkillType . ARCHERY , Integer . valueOf ( stats . get ( 1 ) . get ( 7 ) ) ) ;
skills . put ( SkillType . SWORDS , Integer . valueOf ( stats . get ( 1 ) . get ( 8 ) ) ) ;
skills . put ( SkillType . AXES , Integer . valueOf ( stats . get ( 1 ) . get ( 9 ) ) ) ;
skills . put ( SkillType . ACROBATICS , Integer . valueOf ( stats . get ( 1 ) . get ( 10 ) ) ) ;
2011-04-26 06:10:38 +02:00
HashMap < Integer , ArrayList < String > > experience = mcMMO . database . Read ( " SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics FROM " + LoadProperties . MySQLtablePrefix + " experience WHERE user_id = " + id ) ;
2011-07-19 16:17:14 +02:00
skillsXp . put ( SkillType . TAMING , Integer . valueOf ( experience . get ( 1 ) . get ( 0 ) ) ) ;
skillsXp . put ( SkillType . MINING , Integer . valueOf ( experience . get ( 1 ) . get ( 1 ) ) ) ;
skillsXp . put ( SkillType . REPAIR , Integer . valueOf ( experience . get ( 1 ) . get ( 2 ) ) ) ;
skillsXp . put ( SkillType . WOODCUTTING , Integer . valueOf ( experience . get ( 1 ) . get ( 3 ) ) ) ;
skillsXp . put ( SkillType . UNARMED , Integer . valueOf ( experience . get ( 1 ) . get ( 4 ) ) ) ;
skillsXp . put ( SkillType . HERBALISM , Integer . valueOf ( experience . get ( 1 ) . get ( 5 ) ) ) ;
skillsXp . put ( SkillType . EXCAVATION , Integer . valueOf ( experience . get ( 1 ) . get ( 6 ) ) ) ;
skillsXp . put ( SkillType . ARCHERY , Integer . valueOf ( experience . get ( 1 ) . get ( 7 ) ) ) ;
skillsXp . put ( SkillType . SWORDS , Integer . valueOf ( experience . get ( 1 ) . get ( 8 ) ) ) ;
skillsXp . put ( SkillType . AXES , Integer . valueOf ( experience . get ( 1 ) . get ( 9 ) ) ) ;
skillsXp . put ( SkillType . ACROBATICS , Integer . valueOf ( experience . get ( 1 ) . get ( 10 ) ) ) ;
2011-04-16 23:35:17 +02:00
return true ;
}
else {
return false ;
}
}
public void addMySQLPlayer ( Player p ) {
Integer id = 0 ;
2011-04-26 06:10:38 +02:00
mcMMO . database . Write ( " INSERT INTO " + LoadProperties . MySQLtablePrefix + " users (user, lastlogin) VALUES (' " + p . getName ( ) + " ', " + System . currentTimeMillis ( ) / 1000 + " ) " ) ;
id = mcMMO . database . GetInt ( " SELECT id FROM " + LoadProperties . MySQLtablePrefix + " users WHERE user = ' " + p . getName ( ) + " ' " ) ;
2011-04-30 22:53:08 +02:00
mcMMO . database . Write ( " INSERT INTO " + LoadProperties . MySQLtablePrefix + " cooldowns (user_id) VALUES ( " + id + " ) " ) ;
2011-04-26 06:10:38 +02:00
mcMMO . database . Write ( " INSERT INTO " + LoadProperties . MySQLtablePrefix + " spawn (user_id) VALUES ( " + id + " ) " ) ;
mcMMO . database . Write ( " INSERT INTO " + LoadProperties . MySQLtablePrefix + " skills (user_id) VALUES ( " + id + " ) " ) ;
mcMMO . database . Write ( " INSERT INTO " + LoadProperties . MySQLtablePrefix + " experience (user_id) VALUES ( " + id + " ) " ) ;
2011-04-16 23:35:17 +02:00
this . userid = id ;
}
public boolean load ( )
{
try {
//Open the user file
FileReader file = new FileReader ( location ) ;
BufferedReader in = new BufferedReader ( file ) ;
String line = " " ;
while ( ( line = in . readLine ( ) ) ! = null )
{
//Find if the line contains the player we want.
String [ ] character = line . split ( " : " ) ;
2011-07-10 02:18:00 +02:00
if ( ! character [ 0 ] . equals ( playername ) ) { continue ; }
2011-04-16 23:35:17 +02:00
//Get Mining
2011-07-19 16:17:14 +02:00
if ( character . length > 1 & & m . isInt ( character [ 1 ] ) )
skills . put ( SkillType . MINING , Integer . valueOf ( character [ 1 ] ) ) ;
2011-04-16 23:35:17 +02:00
//Myspawn
if ( character . length > 2 )
myspawn = character [ 2 ] ;
//Party
if ( character . length > 3 )
party = character [ 3 ] ;
//Mining XP
2011-07-19 16:17:14 +02:00
if ( character . length > 4 & & m . isInt ( character [ 4 ] ) )
skillsXp . put ( SkillType . MINING , Integer . valueOf ( character [ 4 ] ) ) ;
if ( character . length > 5 & & m . isInt ( character [ 5 ] ) )
skills . put ( SkillType . WOODCUTTING , Integer . valueOf ( character [ 5 ] ) ) ;
if ( character . length > 6 & & m . isInt ( character [ 6 ] ) )
skillsXp . put ( SkillType . WOODCUTTING , Integer . valueOf ( character [ 6 ] ) ) ;
if ( character . length > 7 & & m . isInt ( character [ 7 ] ) )
skills . put ( SkillType . REPAIR , Integer . valueOf ( character [ 7 ] ) ) ;
if ( character . length > 8 & & m . isInt ( character [ 8 ] ) )
skills . put ( SkillType . UNARMED , Integer . valueOf ( character [ 8 ] ) ) ;
if ( character . length > 9 & & m . isInt ( character [ 9 ] ) )
skills . put ( SkillType . HERBALISM , Integer . valueOf ( character [ 9 ] ) ) ;
if ( character . length > 10 & & m . isInt ( character [ 10 ] ) )
skills . put ( SkillType . EXCAVATION , Integer . valueOf ( character [ 10 ] ) ) ;
if ( character . length > 11 & & m . isInt ( character [ 11 ] ) )
skills . put ( SkillType . ARCHERY , Integer . valueOf ( character [ 11 ] ) ) ;
if ( character . length > 12 & & m . isInt ( character [ 12 ] ) )
skills . put ( SkillType . SWORDS , Integer . valueOf ( character [ 12 ] ) ) ;
if ( character . length > 13 & & m . isInt ( character [ 13 ] ) )
skills . put ( SkillType . AXES , Integer . valueOf ( character [ 13 ] ) ) ;
if ( character . length > 14 & & m . isInt ( character [ 14 ] ) )
skills . put ( SkillType . ACROBATICS , Integer . valueOf ( character [ 14 ] ) ) ;
if ( character . length > 15 & & m . isInt ( character [ 15 ] ) )
skillsXp . put ( SkillType . REPAIR , Integer . valueOf ( character [ 15 ] ) ) ;
if ( character . length > 16 & & m . isInt ( character [ 16 ] ) )
skillsXp . put ( SkillType . UNARMED , Integer . valueOf ( character [ 16 ] ) ) ;
if ( character . length > 17 & & m . isInt ( character [ 17 ] ) )
skillsXp . put ( SkillType . HERBALISM , Integer . valueOf ( character [ 17 ] ) ) ;
if ( character . length > 18 & & m . isInt ( character [ 18 ] ) )
skillsXp . put ( SkillType . EXCAVATION , Integer . valueOf ( character [ 18 ] ) ) ;
if ( character . length > 19 & & m . isInt ( character [ 19 ] ) )
skillsXp . put ( SkillType . ARCHERY , Integer . valueOf ( character [ 19 ] ) ) ;
if ( character . length > 20 & & m . isInt ( character [ 20 ] ) )
skillsXp . put ( SkillType . SWORDS , Integer . valueOf ( character [ 20 ] ) ) ;
if ( character . length > 21 & & m . isInt ( character [ 21 ] ) )
skillsXp . put ( SkillType . AXES , Integer . valueOf ( character [ 21 ] ) ) ;
if ( character . length > 22 & & m . isInt ( character [ 22 ] ) )
skillsXp . put ( SkillType . ACROBATICS , Integer . valueOf ( character [ 22 ] ) ) ;
if ( character . length > 23 & & m . isInt ( character [ 23 ] ) )
2011-04-16 23:35:17 +02:00
myspawnworld = character [ 23 ] ;
2011-07-19 16:17:14 +02:00
if ( character . length > 24 & & m . isInt ( character [ 24 ] ) )
skills . put ( SkillType . TAMING , Integer . valueOf ( character [ 24 ] ) ) ;
if ( character . length > 25 & & m . isInt ( character [ 25 ] ) )
skillsXp . put ( SkillType . TAMING , Integer . valueOf ( character [ 25 ] ) ) ;
2011-04-30 22:53:08 +02:00
if ( character . length > 26 )
2011-08-05 05:01:52 +02:00
berserkDATS = Integer . valueOf ( character [ 26 ] ) ;
2011-04-30 22:53:08 +02:00
if ( character . length > 27 )
2011-08-05 05:01:52 +02:00
gigaDrillBreakerDATS = Integer . valueOf ( character [ 27 ] ) ;
2011-04-30 22:53:08 +02:00
if ( character . length > 28 )
2011-08-05 05:01:52 +02:00
treeFellerDATS = Integer . valueOf ( character [ 28 ] ) ;
2011-04-30 22:53:08 +02:00
if ( character . length > 29 )
2011-08-05 05:01:52 +02:00
greenTerraDATS = Integer . valueOf ( character [ 29 ] ) ;
2011-04-30 22:53:08 +02:00
if ( character . length > 30 )
2011-08-05 05:01:52 +02:00
serratedStrikesDATS = Integer . valueOf ( character [ 30 ] ) ;
2011-04-30 22:53:08 +02:00
if ( character . length > 31 )
2011-08-05 05:01:52 +02:00
skullSplitterDATS = Integer . valueOf ( character [ 31 ] ) ;
2011-04-30 22:53:08 +02:00
if ( character . length > 32 )
2011-08-05 05:01:52 +02:00
superBreakerDATS = Integer . valueOf ( character [ 32 ] ) ;
2011-08-21 03:23:38 +02:00
if ( character . length > 33 )
{
for ( HUDType x : HUDType . values ( ) )
{
2011-08-23 03:22:16 +02:00
if ( x . toString ( ) . equalsIgnoreCase ( character [ 33 ] ) )
2011-08-21 03:23:38 +02:00
{
hud = x ;
}
}
}
2011-04-16 23:35:17 +02:00
in . close ( ) ;
return true ;
}
in . close ( ) ;
} catch ( Exception e ) {
log . log ( Level . SEVERE , " Exception while reading "
+ location + " (Are you sure you formatted it correctly?) " , e ) ;
}
return false ;
}
public void save ( )
{
2011-04-26 06:10:38 +02:00
Long timestamp = System . currentTimeMillis ( ) / 1000 ; //Convert to seconds
2011-04-16 23:35:17 +02:00
// if we are using mysql save to database
2011-08-03 01:48:55 +02:00
if ( LoadProperties . useMySQL )
{
2011-08-21 03:23:38 +02:00
mcMMO . database . Write ( " UPDATE " + LoadProperties . MySQLtablePrefix + " huds SET "
+ " hudtype = ' " + hud . toString ( ) + " ' WHERE user_id = " + this . userid ) ;
2011-04-26 06:10:38 +02:00
mcMMO . database . Write ( " UPDATE " + LoadProperties . MySQLtablePrefix + " users SET lastlogin = " + timestamp . intValue ( ) + " WHERE id = " + this . userid ) ;
2011-04-28 04:36:45 +02:00
mcMMO . database . Write ( " UPDATE " + LoadProperties . MySQLtablePrefix + " users SET party = ' " + this . party + " ' WHERE id = " + this . userid ) ;
2011-04-26 06:10:38 +02:00
mcMMO . database . Write ( " UPDATE " + LoadProperties . MySQLtablePrefix + " spawn SET world = ' " + this . myspawnworld + " ', x = " + getX ( ) + " , y = " + getY ( ) + " , z = " + getZ ( ) + " WHERE user_id = " + this . userid ) ;
2011-04-30 22:53:08 +02:00
mcMMO . database . Write ( " UPDATE " + LoadProperties . MySQLtablePrefix + " cooldowns SET "
2011-08-05 05:01:52 +02:00
+ " mining = " + ( superBreakerDATS )
+ " , woodcutting = " + ( treeFellerDATS )
+ " , unarmed = " + ( berserkDATS )
+ " , herbalism = " + ( greenTerraDATS )
+ " , excavation = " + ( gigaDrillBreakerDATS )
+ " , swords = " + ( serratedStrikesDATS )
+ " , axes = " + ( skullSplitterDATS )
2011-04-30 22:53:08 +02:00
+ " WHERE user_id = " + this . userid ) ;
2011-04-26 06:10:38 +02:00
mcMMO . database . Write ( " UPDATE " + LoadProperties . MySQLtablePrefix + " skills SET "
2011-07-19 16:17:14 +02:00
+ " taming = " + skills . get ( SkillType . TAMING )
+ " , mining = " + skills . get ( SkillType . MINING )
+ " , repair = " + skills . get ( SkillType . REPAIR )
+ " , woodcutting = " + skills . get ( SkillType . WOODCUTTING )
+ " , unarmed = " + skills . get ( SkillType . UNARMED )
+ " , herbalism = " + skills . get ( SkillType . HERBALISM )
+ " , excavation = " + skills . get ( SkillType . EXCAVATION )
+ " , archery = " + skills . get ( SkillType . ARCHERY )
+ " , swords = " + skills . get ( SkillType . SWORDS )
+ " , axes = " + skills . get ( SkillType . AXES )
+ " , acrobatics = " + skills . get ( SkillType . ACROBATICS )
2011-04-16 23:35:17 +02:00
+ " WHERE user_id = " + this . userid ) ;
2011-04-26 06:10:38 +02:00
mcMMO . database . Write ( " UPDATE " + LoadProperties . MySQLtablePrefix + " experience SET "
2011-07-19 16:17:14 +02:00
+ " taming = " + skillsXp . get ( SkillType . TAMING )
+ " , mining = " + skillsXp . get ( SkillType . MINING )
+ " , repair = " + skillsXp . get ( SkillType . REPAIR )
+ " , woodcutting = " + skillsXp . get ( SkillType . WOODCUTTING )
+ " , unarmed = " + skillsXp . get ( SkillType . UNARMED )
+ " , herbalism = " + skillsXp . get ( SkillType . HERBALISM )
+ " , excavation = " + skillsXp . get ( SkillType . EXCAVATION )
+ " , archery = " + skillsXp . get ( SkillType . ARCHERY )
+ " , swords = " + skillsXp . get ( SkillType . SWORDS )
+ " , axes = " + skillsXp . get ( SkillType . AXES )
+ " , acrobatics = " + skillsXp . get ( SkillType . ACROBATICS )
2011-04-16 23:35:17 +02:00
+ " WHERE user_id = " + this . userid ) ;
2011-08-03 01:48:55 +02:00
} else
{
2011-04-16 23:35:17 +02:00
// otherwise save to flatfile
try {
//Open the file
FileReader file = new FileReader ( location ) ;
BufferedReader in = new BufferedReader ( file ) ;
StringBuilder writer = new StringBuilder ( ) ;
String line = " " ;
//While not at the end of the file
while ( ( line = in . readLine ( ) ) ! = null )
{
//Read the line in and copy it to the output it's not the player
//we want to edit
2011-07-10 02:18:00 +02:00
if ( ! line . split ( " : " ) [ 0 ] . equalsIgnoreCase ( playername ) )
2011-04-16 23:35:17 +02:00
{
writer . append ( line ) . append ( " \ r \ n " ) ;
//Otherwise write the new player information
} else {
2011-07-10 02:18:00 +02:00
writer . append ( playername + " : " ) ;
2011-07-19 16:17:14 +02:00
writer . append ( skills . get ( SkillType . MINING ) + " : " ) ;
2011-04-16 23:35:17 +02:00
writer . append ( myspawn + " : " ) ;
writer . append ( party + " : " ) ;
2011-07-19 16:17:14 +02:00
writer . append ( skillsXp . get ( SkillType . MINING ) + " : " ) ;
writer . append ( skills . get ( SkillType . WOODCUTTING ) + " : " ) ;
writer . append ( skillsXp . get ( SkillType . WOODCUTTING ) + " : " ) ;
writer . append ( skills . get ( SkillType . REPAIR ) + " : " ) ;
writer . append ( skills . get ( SkillType . UNARMED ) + " : " ) ;
writer . append ( skills . get ( SkillType . HERBALISM ) + " : " ) ;
writer . append ( skills . get ( SkillType . EXCAVATION ) + " : " ) ;
writer . append ( skills . get ( SkillType . ARCHERY ) + " : " ) ;
writer . append ( skills . get ( SkillType . SWORDS ) + " : " ) ;
writer . append ( skills . get ( SkillType . AXES ) + " : " ) ;
writer . append ( skills . get ( SkillType . ACROBATICS ) + " : " ) ;
writer . append ( skillsXp . get ( SkillType . REPAIR ) + " : " ) ;
writer . append ( skillsXp . get ( SkillType . UNARMED ) + " : " ) ;
writer . append ( skillsXp . get ( SkillType . HERBALISM ) + " : " ) ;
writer . append ( skillsXp . get ( SkillType . EXCAVATION ) + " : " ) ;
writer . append ( skillsXp . get ( SkillType . ARCHERY ) + " : " ) ;
writer . append ( skillsXp . get ( SkillType . SWORDS ) + " : " ) ;
writer . append ( skillsXp . get ( SkillType . AXES ) + " : " ) ;
writer . append ( skillsXp . get ( SkillType . ACROBATICS ) + " : " ) ;
2011-04-16 23:35:17 +02:00
writer . append ( myspawnworld + " : " ) ;
2011-07-19 16:17:14 +02:00
writer . append ( skills . get ( SkillType . TAMING ) + " : " ) ;
writer . append ( skillsXp . get ( SkillType . TAMING ) + " : " ) ;
2011-04-30 22:53:08 +02:00
//Need to store the DATS of abilities nao
//Berserk, Gigadrillbreaker, Tree Feller, Green Terra, Serrated Strikes, Skull Splitter, Super Breaker
2011-08-05 05:01:52 +02:00
writer . append ( String . valueOf ( berserkDATS ) + " : " ) ;
writer . append ( String . valueOf ( gigaDrillBreakerDATS ) + " : " ) ;
writer . append ( String . valueOf ( treeFellerDATS ) + " : " ) ;
writer . append ( String . valueOf ( greenTerraDATS ) + " : " ) ;
writer . append ( String . valueOf ( serratedStrikesDATS ) + " : " ) ;
writer . append ( String . valueOf ( skullSplitterDATS ) + " : " ) ;
writer . append ( String . valueOf ( superBreakerDATS ) + " : " ) ;
2011-08-21 03:23:38 +02:00
writer . append ( hud . toString ( ) + " : " ) ;
2011-04-16 23:35:17 +02:00
writer . append ( " \ r \ n " ) ;
}
}
in . close ( ) ;
//Write the new file
FileWriter out = new FileWriter ( location ) ;
out . write ( writer . toString ( ) ) ;
out . close ( ) ;
} catch ( Exception e ) {
log . log ( Level . SEVERE , " Exception while writing to " + location + " (Are you sure you formatted it correctly?) " , e ) ;
}
}
}
public void addPlayer ( )
{
try {
//Open the file to write the player
FileWriter file = new FileWriter ( location , true ) ;
BufferedWriter out = new BufferedWriter ( file ) ;
//Add the player to the end
2011-07-10 02:18:00 +02:00
out . append ( playername + " : " ) ;
2011-04-16 23:35:17 +02:00
out . append ( 0 + " : " ) ; //mining
out . append ( myspawn + " : " ) ;
out . append ( party + " : " ) ;
out . append ( 0 + " : " ) ; //XP
out . append ( 0 + " : " ) ; //woodcutting
out . append ( 0 + " : " ) ; //woodCuttingXP
out . append ( 0 + " : " ) ; //repair
out . append ( 0 + " : " ) ; //unarmed
out . append ( 0 + " : " ) ; //herbalism
out . append ( 0 + " : " ) ; //excavation
out . append ( 0 + " : " ) ; //archery
out . append ( 0 + " : " ) ; //swords
out . append ( 0 + " : " ) ; //axes
out . append ( 0 + " : " ) ; //acrobatics
out . append ( 0 + " : " ) ; //repairXP
out . append ( 0 + " : " ) ; //unarmedXP
out . append ( 0 + " : " ) ; //herbalismXP
out . append ( 0 + " : " ) ; //excavationXP
out . append ( 0 + " : " ) ; //archeryXP
out . append ( 0 + " : " ) ; //swordsXP
out . append ( 0 + " : " ) ; //axesXP
out . append ( 0 + " : " ) ; //acrobaticsXP
2011-07-10 02:18:00 +02:00
out . append ( myspawnworld + " : " ) ;
2011-04-16 23:35:17 +02:00
out . append ( 0 + " : " ) ; //taming
out . append ( 0 + " : " ) ; //tamingXP
2011-04-30 22:53:08 +02:00
out . append ( 0 + " : " ) ; //DATS
out . append ( 0 + " : " ) ; //DATS
out . append ( 0 + " : " ) ; //DATS
out . append ( 0 + " : " ) ; //DATS
out . append ( 0 + " : " ) ; //DATS
out . append ( 0 + " : " ) ; //DATS
out . append ( 0 + " : " ) ; //DATS
2011-08-23 03:22:16 +02:00
out . append ( LoadProperties . defaulthud . toString ( ) + " : " ) ; //HUD
2011-04-30 22:53:08 +02:00
2011-04-16 23:35:17 +02:00
//Add more in the same format as the line above
out . newLine ( ) ;
out . close ( ) ;
} catch ( Exception e ) {
log . log ( Level . SEVERE , " Exception while writing to " + location + " (Are you sure you formatted it correctly?) " , e ) ;
}
}
2011-09-12 12:36:26 +02:00
public void togglePartyHUD ( )
{
partyhud = ! partyhud ;
}
public boolean getPartyHUD ( )
{
return partyhud ;
}
2011-08-19 17:40:14 +02:00
public void toggleSpoutEnabled ( )
{
spoutcraft = ! spoutcraft ;
}
public boolean isFilling ( )
{
return filling ;
}
public void toggleFilling ( )
{
filling = ! filling ;
}
public HUDType getHUDType ( )
{
return hud ;
}
public void setHUDType ( HUDType type )
{
hud = type ;
2011-09-12 12:36:26 +02:00
save ( ) ;
2011-08-19 17:40:14 +02:00
}
2011-08-16 11:33:34 +02:00
public boolean getXpBarLocked ( )
{
return xpbarlocked ;
}
public void toggleXpBarLocked ( )
{
xpbarlocked = ! xpbarlocked ;
}
2011-08-05 05:01:52 +02:00
public int getXpBarInc ( )
{
return xpbarinc ;
}
public void setXpBarInc ( int newvalue )
{
xpbarinc = newvalue ;
}
2011-08-16 11:33:34 +02:00
public void setSkillLock ( SkillType newvalue )
{
skillLock = newvalue ;
}
public SkillType getSkillLock ( )
{
return skillLock ;
}
2011-08-05 05:01:52 +02:00
public void setLastGained ( SkillType newvalue )
{
lastgained = newvalue ;
}
public SkillType getLastGained ( )
{
return lastgained ;
}
2011-04-16 23:35:17 +02:00
2011-07-10 02:18:00 +02:00
public boolean getAdminChatMode ( ) { return adminChatMode ; }
public boolean getPartyChatMode ( ) { return partyChatMode ; }
2011-09-29 21:45:14 +02:00
2011-07-10 02:18:00 +02:00
public boolean getGodMode ( ) { return godMode ; }
2011-07-20 19:25:40 +02:00
public void togglePlacedAnvil ( )
{
placedAnvil = ! placedAnvil ;
}
public Boolean getPlacedAnvil ( )
{
return placedAnvil ;
}
2011-07-10 02:18:00 +02:00
public void toggleAdminChat ( )
{
adminChatMode = ! adminChatMode ;
}
public void toggleGodMode ( )
{
godMode = ! godMode ;
}
public void togglePartyChat ( )
{
partyChatMode = ! partyChatMode ;
}
public void setMana ( int newvalue )
{
mana = newvalue ;
}
public int getCurrentMana ( )
{
return mana ;
}
public void setDyeChanged ( Boolean bool )
{
dyeChanged = bool ;
}
public boolean getDyeChanged ( )
{
return dyeChanged ;
}
public void setBlueDyeCycle ( int newvalue )
{
blueDyeCycle = newvalue ;
}
public int getBlueDyeCycle ( )
{
return blueDyeCycle ;
}
public void setBlueDyeCycleSel ( int newvalue )
{
blueDyeCycleSel = newvalue ;
}
public int getBlueDyeCycleSel ( )
{
return blueDyeCycleSel ;
}
public void setGreenDyeCycle ( int newvalue )
{
greenDyeCycle = newvalue ;
}
public int getGreenDyeCycle ( )
{
return greenDyeCycle ;
}
public void setGreenDyeCycleSel ( int newvalue )
{
greenDyeCycleSel = newvalue ;
}
public int getGreenDyeCycleSel ( )
{
return greenDyeCycleSel ;
}
2011-04-16 23:35:17 +02:00
public boolean isPlayer ( String player )
{
2011-07-10 02:18:00 +02:00
return player . equals ( playername ) ;
2011-04-16 23:35:17 +02:00
}
public boolean getPartyChatOnlyToggle ( ) { return partyChatOnly ; }
public void togglePartyChatOnly ( ) { partyChatOnly = ! partyChatOnly ; }
public boolean getAbilityUse ( ) {
return abilityuse ;
}
2011-07-19 16:17:14 +02:00
public void toggleAbilityUse ( )
{
abilityuse = ! abilityuse ;
2011-04-16 23:35:17 +02:00
}
public long getMySpawnATS ( ) {
return mySpawnATS ;
}
2011-08-05 05:01:52 +02:00
public void setMySpawnATS ( long newvalue )
{
mySpawnATS = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
2011-07-19 16:17:14 +02:00
public void decreaseBleedTicks ( )
{
bleedticks - - ;
2011-04-16 23:35:17 +02:00
}
public Integer getBleedTicks ( ) {
return bleedticks ;
}
public void setBleedTicks ( Integer newvalue ) {
bleedticks = newvalue ;
}
public void addBleedTicks ( Integer newvalue ) {
bleedticks + = newvalue ;
}
/ *
* EXPLOIT PREVENTION
* /
public long getRespawnATS ( ) { return respawnATS ; }
2011-08-05 05:01:52 +02:00
public void setRespawnATS ( long newvalue ) { respawnATS = ( int ) ( newvalue / 1000 ) ; }
2011-04-16 23:35:17 +02:00
/ *
* HOE PREPARATION
* /
public boolean getHoePreparationMode ( ) {
return hoePreparationMode ;
}
public void setHoePreparationMode ( Boolean bool ) {
hoePreparationMode = bool ;
}
public long getHoePreparationATS ( ) {
return hoePreparationATS ;
}
public void setHoePreparationATS ( long newvalue ) {
2011-08-05 05:01:52 +02:00
hoePreparationATS = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
/ *
* SWORDS PREPARATION
* /
public boolean getSwordsPreparationMode ( ) {
return swordsPreparationMode ;
}
public void setSwordsPreparationMode ( Boolean bool ) {
swordsPreparationMode = bool ;
}
public long getSwordsPreparationATS ( ) {
return swordsPreparationATS ;
}
public void setSwordsPreparationATS ( long newvalue ) {
2011-08-05 05:01:52 +02:00
swordsPreparationATS = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
/ *
* SHOVEL PREPARATION
* /
public boolean getShovelPreparationMode ( ) {
return shovelPreparationMode ;
}
public void setShovelPreparationMode ( Boolean bool ) {
shovelPreparationMode = bool ;
}
public long getShovelPreparationATS ( ) {
return shovelPreparationATS ;
}
public void setShovelPreparationATS ( long newvalue ) {
2011-08-05 05:01:52 +02:00
shovelPreparationATS = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
/ *
* FISTS PREPARATION
* /
public boolean getFistsPreparationMode ( ) {
return fistsPreparationMode ;
}
public void setFistsPreparationMode ( Boolean bool ) {
fistsPreparationMode = bool ;
}
public long getFistsPreparationATS ( ) {
return fistsPreparationATS ;
}
public void setFistsPreparationATS ( long newvalue ) {
2011-08-05 05:01:52 +02:00
fistsPreparationATS = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
/ *
* AXE PREPARATION
* /
public boolean getAxePreparationMode ( ) {
return axePreparationMode ;
}
public void setAxePreparationMode ( Boolean bool ) {
axePreparationMode = bool ;
}
public long getAxePreparationATS ( ) {
return axePreparationATS ;
}
public void setAxePreparationATS ( long newvalue ) {
2011-08-05 05:01:52 +02:00
axePreparationATS = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
/ *
* PICKAXE PREPARATION
* /
public boolean getPickaxePreparationMode ( ) {
return pickaxePreparationMode ;
}
public void setPickaxePreparationMode ( Boolean bool ) {
pickaxePreparationMode = bool ;
}
public long getPickaxePreparationATS ( ) {
return pickaxePreparationATS ;
}
public void setPickaxePreparationATS ( long newvalue ) {
2011-08-05 05:01:52 +02:00
pickaxePreparationATS = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
/ *
* GREEN TERRA MODE
* /
public boolean getGreenTerraInformed ( ) { return greenTerraInformed ; }
public void setGreenTerraInformed ( Boolean bool ) {
greenTerraInformed = bool ;
}
public boolean getGreenTerraMode ( ) {
return greenTerraMode ;
}
public void setGreenTerraMode ( Boolean bool ) {
greenTerraMode = bool ;
}
public long getGreenTerraActivatedTimeStamp ( ) { return greenTerraATS ; }
public void setGreenTerraActivatedTimeStamp ( Long newvalue ) {
2011-08-05 05:01:52 +02:00
greenTerraATS = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
public long getGreenTerraDeactivatedTimeStamp ( ) { return greenTerraDATS ; }
public void setGreenTerraDeactivatedTimeStamp ( Long newvalue ) {
2011-08-05 05:01:52 +02:00
greenTerraDATS = ( int ) ( newvalue / 1000 ) ;
2011-04-30 22:53:08 +02:00
save ( ) ;
2011-04-16 23:35:17 +02:00
}
/ *
* BERSERK MODE
* /
public boolean getBerserkInformed ( ) { return berserkInformed ; }
public void setBerserkInformed ( Boolean bool ) {
berserkInformed = bool ;
}
public boolean getBerserkMode ( ) {
return berserkMode ;
}
public void setBerserkMode ( Boolean bool ) {
berserkMode = bool ;
}
public long getBerserkActivatedTimeStamp ( ) { return berserkATS ; }
public void setBerserkActivatedTimeStamp ( Long newvalue ) {
2011-08-05 05:01:52 +02:00
berserkATS = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
public long getBerserkDeactivatedTimeStamp ( ) { return berserkDATS ; }
public void setBerserkDeactivatedTimeStamp ( Long newvalue ) {
2011-08-05 05:01:52 +02:00
berserkDATS = ( int ) ( newvalue / 1000 ) ;
2011-04-30 22:53:08 +02:00
save ( ) ;
2011-04-16 23:35:17 +02:00
}
/ *
* SKULL SPLITTER
* /
public boolean getSkullSplitterInformed ( ) { return skullSplitterInformed ; }
public void setSkullSplitterInformed ( Boolean bool ) {
skullSplitterInformed = bool ;
}
public boolean getSkullSplitterMode ( ) {
return skullSplitterMode ;
}
public void setSkullSplitterMode ( Boolean bool ) {
skullSplitterMode = bool ;
}
public long getSkullSplitterActivatedTimeStamp ( ) { return skullSplitterATS ; }
public void setSkullSplitterActivatedTimeStamp ( Long newvalue ) {
2011-08-05 05:01:52 +02:00
skullSplitterATS = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
public long getSkullSplitterDeactivatedTimeStamp ( ) { return skullSplitterDATS ; }
public void setSkullSplitterDeactivatedTimeStamp ( Long newvalue ) {
2011-08-05 05:01:52 +02:00
skullSplitterDATS = ( int ) ( newvalue / 1000 ) ;
2011-04-30 22:53:08 +02:00
save ( ) ;
2011-04-16 23:35:17 +02:00
}
/ *
* SERRATED STRIKES
* /
public boolean getSerratedStrikesInformed ( ) { return serratedStrikesInformed ; }
public void setSerratedStrikesInformed ( Boolean bool ) {
serratedStrikesInformed = bool ;
}
public boolean getSerratedStrikesMode ( ) {
return serratedStrikesMode ;
}
public void setSerratedStrikesMode ( Boolean bool ) {
serratedStrikesMode = bool ;
}
public long getSerratedStrikesActivatedTimeStamp ( ) { return serratedStrikesATS ; }
public void setSerratedStrikesActivatedTimeStamp ( Long newvalue ) {
2011-08-05 05:01:52 +02:00
serratedStrikesATS = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
public long getSerratedStrikesDeactivatedTimeStamp ( ) { return serratedStrikesDATS ; }
public void setSerratedStrikesDeactivatedTimeStamp ( Long newvalue ) {
2011-08-05 05:01:52 +02:00
serratedStrikesDATS = ( int ) ( newvalue / 1000 ) ;
2011-04-30 22:53:08 +02:00
save ( ) ;
2011-04-16 23:35:17 +02:00
}
/ *
* GIGA DRILL BREAKER
* /
public boolean getGigaDrillBreakerInformed ( ) { return gigaDrillBreakerInformed ; }
public void setGigaDrillBreakerInformed ( Boolean bool ) {
gigaDrillBreakerInformed = bool ;
}
public boolean getGigaDrillBreakerMode ( ) {
return gigaDrillBreakerMode ;
}
public void setGigaDrillBreakerMode ( Boolean bool ) {
gigaDrillBreakerMode = bool ;
}
public long getGigaDrillBreakerActivatedTimeStamp ( ) { return gigaDrillBreakerATS ; }
public void setGigaDrillBreakerActivatedTimeStamp ( Long newvalue ) {
2011-08-05 05:01:52 +02:00
gigaDrillBreakerATS = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
public long getGigaDrillBreakerDeactivatedTimeStamp ( ) { return gigaDrillBreakerDATS ; }
public void setGigaDrillBreakerDeactivatedTimeStamp ( Long newvalue ) {
2011-08-05 05:01:52 +02:00
gigaDrillBreakerDATS = ( int ) ( newvalue / 1000 ) ;
2011-04-30 22:53:08 +02:00
save ( ) ;
2011-04-16 23:35:17 +02:00
}
/ *
* TREE FELLER STUFF
* /
public boolean getTreeFellerInformed ( ) { return treeFellerInformed ; }
public void setTreeFellerInformed ( Boolean bool ) {
treeFellerInformed = bool ;
}
public boolean getTreeFellerMode ( ) {
return treeFellerMode ;
}
public void setTreeFellerMode ( Boolean bool ) {
treeFellerMode = bool ;
}
public long getTreeFellerActivatedTimeStamp ( ) { return treeFellerATS ; }
public void setTreeFellerActivatedTimeStamp ( Long newvalue ) {
2011-08-05 05:01:52 +02:00
treeFellerATS = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
public long getTreeFellerDeactivatedTimeStamp ( ) { return treeFellerDATS ; }
public void setTreeFellerDeactivatedTimeStamp ( Long newvalue ) {
2011-08-05 05:01:52 +02:00
treeFellerDATS = ( int ) ( newvalue / 1000 ) ;
2011-04-30 22:53:08 +02:00
save ( ) ;
2011-04-16 23:35:17 +02:00
}
/ *
* MINING
* /
public boolean getSuperBreakerInformed ( ) { return superBreakerInformed ; }
public void setSuperBreakerInformed ( Boolean bool ) {
superBreakerInformed = bool ;
}
public boolean getSuperBreakerMode ( ) {
return superBreakerMode ;
}
public void setSuperBreakerMode ( Boolean bool ) {
superBreakerMode = bool ;
}
public long getSuperBreakerActivatedTimeStamp ( ) { return superBreakerATS ; }
public void setSuperBreakerActivatedTimeStamp ( Long newvalue ) {
2011-08-05 05:01:52 +02:00
superBreakerATS = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
public long getSuperBreakerDeactivatedTimeStamp ( ) { return superBreakerDATS ; }
public void setSuperBreakerDeactivatedTimeStamp ( Long newvalue ) {
2011-08-05 05:01:52 +02:00
superBreakerDATS = ( int ) ( newvalue / 1000 ) ;
2011-04-30 22:53:08 +02:00
save ( ) ;
2011-04-16 23:35:17 +02:00
}
public long getRecentlyHurt ( ) {
return recentlyHurt ;
}
public void setRecentlyHurt ( long newvalue ) {
2011-08-05 05:01:52 +02:00
recentlyHurt = ( int ) ( newvalue / 1000 ) ;
2011-04-16 23:35:17 +02:00
}
2011-07-19 16:17:14 +02:00
public void skillUp ( SkillType skillType , int newvalue )
2011-07-10 02:18:00 +02:00
{
2011-07-19 16:17:14 +02:00
skills . put ( skillType , skills . get ( skillType ) + newvalue ) ;
2011-04-16 23:35:17 +02:00
save ( ) ;
}
2011-07-19 16:17:14 +02:00
public Integer getSkillLevel ( SkillType skillType )
2011-04-16 23:35:17 +02:00
{
2011-07-19 16:17:14 +02:00
return skills . get ( skillType ) ;
2011-04-16 23:35:17 +02:00
}
2011-07-19 16:17:14 +02:00
public Integer getSkillXpLevel ( SkillType skillType )
2011-04-16 23:35:17 +02:00
{
2011-07-19 16:17:14 +02:00
return skillsXp . get ( skillType ) ;
2011-04-16 23:35:17 +02:00
}
2011-07-19 16:17:14 +02:00
public void resetSkillXp ( SkillType skillType )
2011-04-16 23:35:17 +02:00
{
2011-07-19 16:17:14 +02:00
skills . put ( skillType , 0 ) ;
2011-07-10 02:18:00 +02:00
}
2011-09-03 03:49:13 +02:00
2011-09-06 02:02:11 +02:00
/ * *
* Adds XP to the player , this ignores skill modifiers
* @param skillType The skill to add XP to
* @param newvalue The amount of XP to add
* /
public void addXPOverride ( SkillType skillType , int newvalue )
{
if ( skillType = = SkillType . ALL )
{
for ( SkillType x : SkillType . values ( ) )
{
if ( x = = SkillType . ALL )
continue ;
skillsXp . put ( x , skillsXp . get ( x ) + newvalue ) ;
}
} else {
int xp = newvalue ;
xp = xp * LoadProperties . xpGainMultiplier ;
skillsXp . put ( skillType , skillsXp . get ( skillType ) + xp ) ;
lastgained = skillType ;
}
}
/ * *
* Adds XP to the player , this is affected by skill modifiers
* @param skillType The skill to add XP to
* @param newvalue The amount of XP to add
* /
2011-07-19 16:17:14 +02:00
public void addXP ( SkillType skillType , int newvalue )
2011-07-10 02:18:00 +02:00
{
2011-07-19 16:17:14 +02:00
if ( skillType = = SkillType . ALL )
{
2011-08-19 17:40:14 +02:00
for ( SkillType x : SkillType . values ( ) )
{
if ( x = = SkillType . ALL )
continue ;
skillsXp . put ( x , skillsXp . get ( x ) + newvalue ) ;
}
2011-04-16 23:35:17 +02:00
} else {
2011-08-19 17:40:14 +02:00
int xp = newvalue ;
switch ( skillType )
{
case TAMING :
xp = ( int ) ( xp / LoadProperties . tamingxpmodifier ) ;
break ;
case MINING :
xp = ( int ) ( xp / LoadProperties . miningxpmodifier ) ;
break ;
case WOODCUTTING :
xp = ( int ) ( xp / LoadProperties . woodcuttingxpmodifier ) ;
break ;
case REPAIR :
xp = ( int ) ( xp / LoadProperties . repairxpmodifier ) ;
break ;
case HERBALISM :
xp = ( int ) ( xp / LoadProperties . herbalismxpmodifier ) ;
break ;
case ACROBATICS :
xp = ( int ) ( xp / LoadProperties . acrobaticsxpmodifier ) ;
break ;
case SWORDS :
xp = ( int ) ( xp / LoadProperties . swordsxpmodifier ) ;
break ;
case ARCHERY :
xp = ( int ) ( xp / LoadProperties . archeryxpmodifier ) ;
break ;
case UNARMED :
xp = ( int ) ( xp / LoadProperties . unarmedxpmodifier ) ;
break ;
case EXCAVATION :
xp = ( int ) ( xp / LoadProperties . excavationxpmodifier ) ;
break ;
case AXES :
xp = ( int ) ( xp / LoadProperties . axesxpmodifier ) ;
break ;
}
2011-08-20 00:15:53 +02:00
xp = xp * LoadProperties . xpGainMultiplier ;
2011-08-19 17:40:14 +02:00
skillsXp . put ( skillType , skillsXp . get ( skillType ) + xp ) ;
2011-08-20 00:15:53 +02:00
lastgained = skillType ;
2011-04-16 23:35:17 +02:00
}
2011-07-19 16:17:14 +02:00
//save();
2011-04-16 23:35:17 +02:00
}
2011-09-03 03:49:13 +02:00
2011-07-19 16:17:14 +02:00
public void removeXP ( SkillType skillType , int newvalue )
2011-07-16 09:12:26 +02:00
{
2011-07-19 16:17:14 +02:00
if ( skillType = = SkillType . ALL )
2011-07-16 09:12:26 +02:00
{
2011-07-19 16:17:14 +02:00
skillsXp . put ( SkillType . TAMING , skillsXp . get ( SkillType . TAMING ) - newvalue ) ;
skillsXp . put ( SkillType . MINING , skillsXp . get ( SkillType . MINING ) - newvalue ) ;
skillsXp . put ( SkillType . WOODCUTTING , skillsXp . get ( SkillType . WOODCUTTING ) - newvalue ) ;
skillsXp . put ( SkillType . REPAIR , skillsXp . get ( SkillType . REPAIR ) - newvalue ) ;
skillsXp . put ( SkillType . HERBALISM , skillsXp . get ( SkillType . HERBALISM ) - newvalue ) ;
skillsXp . put ( SkillType . ACROBATICS , skillsXp . get ( SkillType . ACROBATICS ) - newvalue ) ;
skillsXp . put ( SkillType . SWORDS , skillsXp . get ( SkillType . SWORDS ) - newvalue ) ;
skillsXp . put ( SkillType . ARCHERY , skillsXp . get ( SkillType . ARCHERY ) - newvalue ) ;
skillsXp . put ( SkillType . UNARMED , skillsXp . get ( SkillType . UNARMED ) - newvalue ) ;
skillsXp . put ( SkillType . EXCAVATION , skillsXp . get ( SkillType . EXCAVATION ) - newvalue ) ;
skillsXp . put ( SkillType . AXES , skillsXp . get ( SkillType . AXES ) - newvalue ) ;
} else {
skillsXp . put ( skillType , skillsXp . get ( skillType ) - newvalue ) ;
2011-04-16 23:35:17 +02:00
}
2011-08-05 05:01:52 +02:00
//save();
2011-04-16 23:35:17 +02:00
}
2011-07-16 09:12:26 +02:00
public void acceptInvite ( )
{
2011-04-16 23:35:17 +02:00
party = invite ;
invite = " " ;
}
2011-07-16 09:12:26 +02:00
public void modifyInvite ( String invitename )
{
2011-04-16 23:35:17 +02:00
invite = invitename ;
}
public String getInvite ( ) { return invite ; }
2011-07-10 02:18:00 +02:00
2011-07-19 16:17:14 +02:00
public void modifyskill ( SkillType skillType , int newvalue )
{
if ( skillType = = SkillType . ALL )
{
skills . put ( SkillType . TAMING , newvalue ) ;
skills . put ( SkillType . MINING , newvalue ) ;
skills . put ( SkillType . WOODCUTTING , newvalue ) ;
skills . put ( SkillType . REPAIR , newvalue ) ;
skills . put ( SkillType . HERBALISM , newvalue ) ;
skills . put ( SkillType . ACROBATICS , newvalue ) ;
skills . put ( SkillType . SWORDS , newvalue ) ;
skills . put ( SkillType . ARCHERY , newvalue ) ;
skills . put ( SkillType . UNARMED , newvalue ) ;
skills . put ( SkillType . EXCAVATION , newvalue ) ;
skills . put ( SkillType . AXES , newvalue ) ;
2011-07-10 02:18:00 +02:00
2011-07-19 16:17:14 +02:00
skillsXp . put ( SkillType . TAMING , 0 ) ;
skillsXp . put ( SkillType . MINING , 0 ) ;
skillsXp . put ( SkillType . WOODCUTTING , 0 ) ;
skillsXp . put ( SkillType . REPAIR , 0 ) ;
skillsXp . put ( SkillType . HERBALISM , 0 ) ;
skillsXp . put ( SkillType . ACROBATICS , 0 ) ;
skillsXp . put ( SkillType . SWORDS , 0 ) ;
skillsXp . put ( SkillType . ARCHERY , 0 ) ;
skillsXp . put ( SkillType . UNARMED , 0 ) ;
skillsXp . put ( SkillType . EXCAVATION , 0 ) ;
skillsXp . put ( SkillType . AXES , 0 ) ;
2011-07-10 02:18:00 +02:00
} else {
2011-07-19 16:17:14 +02:00
skills . put ( skillType , newvalue ) ;
skillsXp . put ( skillType , newvalue ) ;
2011-04-16 23:35:17 +02:00
}
save ( ) ;
}
2011-07-19 16:17:14 +02:00
public Integer getXpToLevel ( SkillType skillType )
2011-07-16 09:12:26 +02:00
{
2011-08-20 19:25:48 +02:00
return ( int ) ( ( 1020 + ( skills . get ( skillType ) * 20 ) ) ) ;
2011-08-19 17:40:14 +02:00
}
2011-07-19 16:17:14 +02:00
//Store the player's party
2011-04-16 23:35:17 +02:00
public void setParty ( String newParty )
{
party = newParty ;
save ( ) ;
}
//Retrieve the player's party
public String getParty ( ) { return party ; }
//Remove party
public void removeParty ( ) {
party = null ;
save ( ) ;
}
//Retrieve whether or not the player is in a party
2011-07-16 09:12:26 +02:00
public boolean inParty ( )
{
2011-04-16 23:35:17 +02:00
if ( party ! = null & & ! party . equals ( " " ) & & ! party . equals ( " null " ) ) {
return true ;
} else {
return false ;
}
}
2011-07-16 09:12:26 +02:00
2011-04-16 23:35:17 +02:00
//Retrieve whether or not the player has an invite
public boolean hasPartyInvite ( ) {
if ( invite ! = null & & ! invite . equals ( " " ) & & ! invite . equals ( " null " ) ) {
return true ;
} else {
return false ;
}
}
2011-08-06 05:04:44 +02:00
public String getMySpawnWorld ( )
{
2011-04-16 23:35:17 +02:00
if ( myspawnworld ! = null & & ! myspawnworld . equals ( " " ) & & ! myspawnworld . equals ( " null " ) ) {
return myspawnworld ;
} else {
2011-08-06 05:04:44 +02:00
return Bukkit . getServer ( ) . getWorlds ( ) . get ( 0 ) . toString ( ) ;
2011-04-16 23:35:17 +02:00
}
}
//Save a users spawn location
public void setMySpawn ( double x , double y , double z , String myspawnworldlocation ) {
myspawn = x + " , " + y + " , " + z ;
myspawnworld = myspawnworldlocation ;
save ( ) ;
}
public String getX ( ) {
2011-04-30 00:50:55 +02:00
if ( myspawn ! = null )
{
2011-04-16 23:35:17 +02:00
String [ ] split = myspawn . split ( " , " ) ;
2011-04-30 00:50:55 +02:00
return split [ 0 ] ;
}
else
return null ;
2011-04-16 23:35:17 +02:00
}
public String getY ( ) {
2011-04-30 00:50:55 +02:00
if ( myspawn ! = null )
{
2011-04-16 23:35:17 +02:00
String [ ] split = myspawn . split ( " , " ) ;
2011-04-30 00:50:55 +02:00
return split [ 1 ] ;
}
else
return null ;
2011-04-16 23:35:17 +02:00
}
public String getZ ( ) {
2011-04-30 00:50:55 +02:00
if ( myspawn ! = null )
{
2011-04-16 23:35:17 +02:00
String [ ] split = myspawn . split ( " , " ) ;
2011-04-30 00:50:55 +02:00
return split [ 2 ] ;
}
else
return null ;
2011-04-16 23:35:17 +02:00
}
public boolean isDead ( ) {
return dead ;
}
2011-08-06 05:04:44 +02:00
public Location getMySpawn ( Player player )
2011-07-10 02:18:00 +02:00
{
2011-04-28 10:49:40 +02:00
Location loc = null ;
2011-07-10 02:18:00 +02:00
if ( myspawn ! = null )
{
2011-07-19 16:17:14 +02:00
if ( m . isDouble ( getX ( ) ) & & m . isDouble ( getY ( ) ) & & m . isDouble ( getZ ( ) ) )
2011-04-30 00:50:55 +02:00
loc = new Location ( player . getWorld ( ) , ( Double . parseDouble ( getX ( ) ) ) , Double . parseDouble ( getY ( ) ) , Double . parseDouble ( getZ ( ) ) ) ;
2011-07-10 02:18:00 +02:00
else
return null ;
2011-04-30 00:50:55 +02:00
} else
return null ;
2011-04-28 10:49:40 +02:00
2011-04-16 23:35:17 +02:00
loc . setYaw ( 0 ) ;
loc . setPitch ( 0 ) ;
2011-08-06 04:53:33 +02:00
if ( loc . getX ( ) ! = 0 & & loc . getY ( ) ! = 0 & & loc . getZ ( ) ! = 0 & & loc . getWorld ( ) ! = null )
{
2011-08-06 05:04:44 +02:00
if ( Bukkit . getServer ( ) . getWorld ( this . getMySpawnWorld ( ) ) ! = null )
loc . setWorld ( Bukkit . getServer ( ) . getWorld ( this . getMySpawnWorld ( ) ) ) ;
else
loc . setWorld ( Bukkit . getServer ( ) . getWorlds ( ) . get ( 0 ) ) ;
2011-04-17 22:45:20 +02:00
return loc ;
} else {
return null ;
}
2011-04-16 23:35:17 +02:00
}
}