Another WIP

This commit is contained in:
nossr50 2011-04-17 13:45:20 -07:00
parent 9b22c82c02
commit af372064ed
7 changed files with 44 additions and 20 deletions

View File

@ -49,13 +49,21 @@ public class PlayerProfile
if (mcLoadProperties.useMySQL) {
// if usemysql load from database
if(!loadMySQL(player)) { addMySQLPlayer(player); }
if(!loadMySQL(player)) {
addMySQLPlayer(player);
/*
* REMEMBER TO FIX THIS!
*/
loadMySQL(player); //For some reason its not loading the users after adding them, so heres this, this is a temporary solution
}
} else {
// load from flat file
if(!load()) { addPlayer(); }
}
}
public int getMySQLuserId(){
return userid;
}
public boolean loadMySQL(Player p) {
@ -65,8 +73,6 @@ public class PlayerProfile
System.out.println("User: " + userslist.get(i).get(0) + ", Lastlogin: " + userslist.get(i).get(1));
}
*/
Integer id = 0;
id = mcMMO.database.GetInt("SELECT id FROM users WHERE user = '" + p.getName() + "'");
this.userid = id;
@ -228,8 +234,7 @@ public class PlayerProfile
+", acrobatics = "+acrobaticsXP
+" WHERE user_id = "+this.userid);
}
else {
} else {
// otherwise save to flatfile
try {
//Open the file
@ -319,7 +324,7 @@ public class PlayerProfile
out.append(0+":"); //swordsXP
out.append(0+":"); //axesXP
out.append(0+":"); //acrobaticsXP
out.append(thisplayer.getWorld().getName());
out.append("");
out.append(0+":"); //taming
out.append(0+":"); //tamingXP
//Add more in the same format as the line above
@ -1681,6 +1686,10 @@ public class PlayerProfile
Location loc = new Location(player.getWorld(),(Double.parseDouble(getX())), Double.parseDouble(getY()), Double.parseDouble(getZ()));
loc.setYaw(0);
loc.setPitch(0);
if(loc.getX() != 0 && loc.getY() != 0 && loc.getZ() != 0 && loc.getWorld() != null){
return loc;
} else {
return null;
}
}
}

View File

@ -35,7 +35,7 @@ public class mcBlockListener extends BlockListener {
if(player != null && mcm.shouldBeWatched(block)){
if(block.getTypeId() != 17)
block.setData((byte) 5); //Change the byte
if(block.getTypeId() == 17)
if(block.getTypeId() == 17 || block.getTypeId() == 91 || block.getTypeId() == 86)
mcConfig.getInstance().addBlockWatch(block);
}
if(block.getTypeId() == 42 && mcLoadProperties.anvilmessages)
@ -163,6 +163,8 @@ public class mcBlockListener extends BlockListener {
PlayerProfile PP = mcUsers.getProfile(player);
ItemStack inhand = player.getItemInHand();
Block block = event.getBlock();
if(player.isOp())
player.sendMessage("mcMMO DEBUG: Byte: "+block.getData()+", ID: "+block.getTypeId());
/*
* Check if the Timer is doing its job
*/

View File

@ -179,7 +179,7 @@ public class mcHerbalism {
PP.addHerbalismXP(3 * mcLoadProperties.xpGainMultiplier);
}
//Pumpkins
if(type == 91 || type == 86){
if((type == 91 || type == 86) && !mcConfig.getInstance().isBlockWatched(block)){
mat = Material.getMaterial(block.getTypeId());
is = new ItemStack(mat, 1, (byte)0, (byte)0);
if(player != null){

View File

@ -98,7 +98,7 @@ public class mcMMO extends JavaPlugin {
mcPermissions.initialize(getServer());
mcLoadMySQL();
//mcLeaderboard.makeLeaderboards(); //Make the leaderboards
mcLeaderboard.makeLeaderboards(); //Make the leaderboards
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
}

View File

@ -76,6 +76,7 @@ public class mcPlayerListener extends PlayerListener {
if(mcPermissions.getInstance().motd(player)){
player.sendMessage(ChatColor.BLUE +"This server is running mcMMO "+plugin.getDescription().getVersion()+" type /"+ChatColor.YELLOW+mcLoadProperties.mcmmo+ChatColor.BLUE+ " for help.");
player.sendMessage(ChatColor.GREEN+"http://mcmmo.wikia.com"+ChatColor.BLUE+" - mcMMO Wiki");
player.sendMessage(ChatColor.DARK_RED+"ATTN: YOUR STATS WILL BE BACK TO NORMAL SHORTLY, WE ARE USING MySQL NOW AND I HAVE TO WRITE A MYSQL QUERY TO UPDATE YOUR STATS!");
}
}
public void onPlayerInteract(PlayerInteractEvent event) {

View File

@ -1,5 +1,12 @@
package com.gmail.nossr50;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
@ -16,7 +23,11 @@ public class mcSkills {
plugin = instance;
}
private static volatile mcSkills instance;
protected static final Logger log = Logger.getLogger("Minecraft");
public void updateSQLfromFile(Player player){
}
public static boolean cooldownOver(Player player, long oldTime, int cooldown){
long currentTime = System.currentTimeMillis();
if(currentTime - oldTime >= (cooldown * 1000)){

View File

@ -27,6 +27,15 @@ public class mcm {
plugin = instance;
}
public static boolean shouldBeWatched(Block block){
int id = block.getTypeId();
if(id == 49 || id == 81 || id == 83 || id == 86 || id == 91 || id == 1 || id == 17 || id == 42 || id == 87 || id == 89 || id == 2 || id == 3 || id == 12 || id == 13 || id == 21 || id == 15 || id == 14 || id == 56 || id == 38 || id == 37 || id == 39 || id == 40 || id == 24){
return true;
} else {
return false;
}
}
public static int getPowerLevel(Player player){
PlayerProfile PP = mcUsers.getProfile(player);
int x = 0;
@ -199,14 +208,6 @@ public class mcm {
return false;
}
}
public static boolean shouldBeWatched(Block block){
int id = block.getTypeId();
if(id == 49 || id == 81 || id == 83 || id == 86 || id == 91 || id == 1 || id == 17 || id == 42 || id == 87 || id == 89 || id == 2 || id == 3 || id == 12 || id == 13 || id == 21 || id == 15 || id == 14 || id == 56 || id == 38 || id == 37 || id == 39 || id == 40 || id == 24){
return true;
} else {
return false;
}
}
public static Integer calculateHealth(Integer health, Integer newvalue){
if((health + newvalue) > 20){
return 20;