mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Another WIP
This commit is contained in:
parent
9b22c82c02
commit
af372064ed
@ -49,13 +49,21 @@ public class PlayerProfile
|
|||||||
|
|
||||||
if (mcLoadProperties.useMySQL) {
|
if (mcLoadProperties.useMySQL) {
|
||||||
// if usemysql load from database
|
// 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 {
|
} else {
|
||||||
// load from flat file
|
// load from flat file
|
||||||
if(!load()) { addPlayer(); }
|
if(!load()) { addPlayer(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public int getMySQLuserId(){
|
||||||
|
return userid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean loadMySQL(Player p) {
|
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));
|
System.out.println("User: " + userslist.get(i).get(0) + ", Lastlogin: " + userslist.get(i).get(1));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
Integer id = 0;
|
Integer id = 0;
|
||||||
id = mcMMO.database.GetInt("SELECT id FROM users WHERE user = '" + p.getName() + "'");
|
id = mcMMO.database.GetInt("SELECT id FROM users WHERE user = '" + p.getName() + "'");
|
||||||
this.userid = id;
|
this.userid = id;
|
||||||
@ -228,8 +234,7 @@ public class PlayerProfile
|
|||||||
+", acrobatics = "+acrobaticsXP
|
+", acrobatics = "+acrobaticsXP
|
||||||
+" WHERE user_id = "+this.userid);
|
+" WHERE user_id = "+this.userid);
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// otherwise save to flatfile
|
// otherwise save to flatfile
|
||||||
try {
|
try {
|
||||||
//Open the file
|
//Open the file
|
||||||
@ -319,7 +324,7 @@ public class PlayerProfile
|
|||||||
out.append(0+":"); //swordsXP
|
out.append(0+":"); //swordsXP
|
||||||
out.append(0+":"); //axesXP
|
out.append(0+":"); //axesXP
|
||||||
out.append(0+":"); //acrobaticsXP
|
out.append(0+":"); //acrobaticsXP
|
||||||
out.append(thisplayer.getWorld().getName());
|
out.append("");
|
||||||
out.append(0+":"); //taming
|
out.append(0+":"); //taming
|
||||||
out.append(0+":"); //tamingXP
|
out.append(0+":"); //tamingXP
|
||||||
//Add more in the same format as the line above
|
//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()));
|
Location loc = new Location(player.getWorld(),(Double.parseDouble(getX())), Double.parseDouble(getY()), Double.parseDouble(getZ()));
|
||||||
loc.setYaw(0);
|
loc.setYaw(0);
|
||||||
loc.setPitch(0);
|
loc.setPitch(0);
|
||||||
return loc;
|
if(loc.getX() != 0 && loc.getY() != 0 && loc.getZ() != 0 && loc.getWorld() != null){
|
||||||
|
return loc;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class mcBlockListener extends BlockListener {
|
|||||||
if(player != null && mcm.shouldBeWatched(block)){
|
if(player != null && mcm.shouldBeWatched(block)){
|
||||||
if(block.getTypeId() != 17)
|
if(block.getTypeId() != 17)
|
||||||
block.setData((byte) 5); //Change the byte
|
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);
|
mcConfig.getInstance().addBlockWatch(block);
|
||||||
}
|
}
|
||||||
if(block.getTypeId() == 42 && mcLoadProperties.anvilmessages)
|
if(block.getTypeId() == 42 && mcLoadProperties.anvilmessages)
|
||||||
@ -163,6 +163,8 @@ public class mcBlockListener extends BlockListener {
|
|||||||
PlayerProfile PP = mcUsers.getProfile(player);
|
PlayerProfile PP = mcUsers.getProfile(player);
|
||||||
ItemStack inhand = player.getItemInHand();
|
ItemStack inhand = player.getItemInHand();
|
||||||
Block block = event.getBlock();
|
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
|
* Check if the Timer is doing its job
|
||||||
*/
|
*/
|
||||||
|
@ -179,7 +179,7 @@ public class mcHerbalism {
|
|||||||
PP.addHerbalismXP(3 * mcLoadProperties.xpGainMultiplier);
|
PP.addHerbalismXP(3 * mcLoadProperties.xpGainMultiplier);
|
||||||
}
|
}
|
||||||
//Pumpkins
|
//Pumpkins
|
||||||
if(type == 91 || type == 86){
|
if((type == 91 || type == 86) && !mcConfig.getInstance().isBlockWatched(block)){
|
||||||
mat = Material.getMaterial(block.getTypeId());
|
mat = Material.getMaterial(block.getTypeId());
|
||||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||||
if(player != null){
|
if(player != null){
|
||||||
|
@ -98,7 +98,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
mcPermissions.initialize(getServer());
|
mcPermissions.initialize(getServer());
|
||||||
mcLoadMySQL();
|
mcLoadMySQL();
|
||||||
|
|
||||||
//mcLeaderboard.makeLeaderboards(); //Make the leaderboards
|
mcLeaderboard.makeLeaderboards(); //Make the leaderboards
|
||||||
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
|
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,7 @@ public class mcPlayerListener extends PlayerListener {
|
|||||||
if(mcPermissions.getInstance().motd(player)){
|
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.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.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) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package com.gmail.nossr50;
|
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.ChatColor;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -16,7 +23,11 @@ public class mcSkills {
|
|||||||
plugin = instance;
|
plugin = instance;
|
||||||
}
|
}
|
||||||
private static volatile mcSkills 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){
|
public static boolean cooldownOver(Player player, long oldTime, int cooldown){
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
if(currentTime - oldTime >= (cooldown * 1000)){
|
if(currentTime - oldTime >= (cooldown * 1000)){
|
||||||
|
@ -27,6 +27,15 @@ public class mcm {
|
|||||||
plugin = instance;
|
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){
|
public static int getPowerLevel(Player player){
|
||||||
PlayerProfile PP = mcUsers.getProfile(player);
|
PlayerProfile PP = mcUsers.getProfile(player);
|
||||||
int x = 0;
|
int x = 0;
|
||||||
@ -199,15 +208,7 @@ public class mcm {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static boolean shouldBeWatched(Block block){
|
public static Integer calculateHealth(Integer health, Integer newvalue){
|
||||||
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){
|
if((health + newvalue) > 20){
|
||||||
return 20;
|
return 20;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user