This commit is contained in:
nossr50 2011-04-27 19:36:45 -07:00
parent 07796c78b4
commit f9c941af6e
9 changed files with 307 additions and 25 deletions

View File

@ -1,6 +1,7 @@
Changelog: Changelog:
#Versions without changelogs probably had very small misc fixes, like tweaks to the source code# #Versions without changelogs probably had very small misc fixes, like tweaks to the source code#
Version 1.0 Version 1.0
Fixed duping bug with WG/Block Protection Plugins
Added Leaf Blower to WoodCutting Added Leaf Blower to WoodCutting
Different Trees give different WoodCutting XP Different Trees give different WoodCutting XP
Water changing Gravel to Clay removed Water changing Gravel to Clay removed

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Animals; import org.bukkit.entity.Animals;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Creeper; import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Monster; import org.bukkit.entity.Monster;
@ -125,6 +126,7 @@ public class Combat {
attacker.sendMessage(ChatColor.DARK_GREEN+"The Beast's Master : "+Taming.getOwnerName(event.getEntity())); attacker.sendMessage(ChatColor.DARK_GREEN+"The Beast's Master : "+Taming.getOwnerName(event.getEntity()));
else else
attacker.sendMessage(ChatColor.GRAY+"This Beast has no Master..."); attacker.sendMessage(ChatColor.GRAY+"This Beast has no Master...");
attacker.sendMessage(ChatColor.GREEN+"This beast has "+((Wolf)event.getEntity()).getHealth()+" Health");
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -132,9 +134,16 @@ public class Combat {
/* /*
* OFFENSIVE CHECKS FOR WOLVES VERSUS ENTITIES * OFFENSIVE CHECKS FOR WOLVES VERSUS ENTITIES
*/ */
if(event instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) event).getDamager() instanceof Wolf){ if(event instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) event).getDamager() instanceof Wolf)
{
//DEBUG STUFF
for(Player x : pluginx.getServer().getOnlinePlayers())
{
x.sendMessage("Wolf Versus Entity Triggered");
}
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent) event; EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent) event;
if(Taming.hasOwner(eventb.getDamager(), pluginx)){ if(Taming.hasOwner(eventb.getDamager(), pluginx))
{
Player master = Taming.getOwner(eventb.getDamager(), pluginx); Player master = Taming.getOwner(eventb.getDamager(), pluginx);
PlayerProfile PPo = Users.getProfile(master); PlayerProfile PPo = Users.getProfile(master);
@ -160,9 +169,6 @@ public class Combat {
master.sendMessage(ChatColor.GREEN+"**GORE**"); master.sendMessage(ChatColor.GREEN+"**GORE**");
} }
PPo.addTamingXP(event.getDamage() * 4);
master.sendMessage("mcMMO Debug: Event Damage "+event.getDamage());
Skills.XpCheck(master);
} }
} }
//Another offensive check for Archery //Another offensive check for Archery
@ -188,16 +194,22 @@ public class Combat {
Player master = Taming.getOwner(event.getEntity(), pluginx); Player master = Taming.getOwner(event.getEntity(), pluginx);
PlayerProfile PPo = Users.getProfile(master); PlayerProfile PPo = Users.getProfile(master);
/*
* TEMPORARY FIX AS WOLVES AREN'T TRIGGERING DAMAGE EVENTS WHEN ATTACKING NON PLAYERS AT THE TIME OF WRITING
*/
PPo.addTamingXP(event.getDamage() * 3);
Skills.XpCheck(master);
//Shock-Proof //Shock-Proof
if((event.getCause() == DamageCause.ENTITY_EXPLOSION || event.getCause() == DamageCause.BLOCK_EXPLOSION) && PPo.getTamingInt() >= 500) if((event.getCause() == DamageCause.ENTITY_EXPLOSION || event.getCause() == DamageCause.BLOCK_EXPLOSION) && PPo.getTamingInt() >= 500)
{ {
event.setDamage(event.getDamage() / 6); event.setDamage(2);
} }
//Thick Fur //Thick Fur
if(PPo.getTamingInt() >= 250) if(PPo.getTamingInt() >= 250)
event.setDamage(event.getDamage() / 2); event.setDamage(event.getDamage() / 2);
master.sendMessage("mcMMO Debug: Wolf Damage Taken "+event.getDamage()); master.sendMessage("mcMMO Debug: Wolf Damage Taken "+event.getDamage());
} }
} }
} }

View File

@ -41,7 +41,7 @@ public class Database {
//Create the DB structure //Create the DB structure
public void createStructure(){ public void createStructure(){
Write("CREATE TABLE IF NOT EXISTS `"+LoadProperties.MySQLtablePrefix+"users` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT," + Write("CREATE TABLE IF NOT EXISTS `"+LoadProperties.MySQLtablePrefix+"users` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT," +
"`user` varchar(30) NOT NULL," + "`user` varchar(40) NOT NULL," +
"`lastlogin` int(32) unsigned NOT NULL," + "`lastlogin` int(32) unsigned NOT NULL," +
"`party` varchar(100) NOT NULL DEFAULT ''," + "`party` varchar(100) NOT NULL DEFAULT ''," +
"PRIMARY KEY (`id`)," + "PRIMARY KEY (`id`)," +
@ -106,8 +106,10 @@ public class Database {
if (stmt.executeQuery() != null) { if (stmt.executeQuery() != null) {
stmt.executeQuery(); stmt.executeQuery();
rs = stmt.getResultSet(); rs = stmt.getResultSet();
rs.next(); if(rs.next()){
result = rs.getInt(1); result = rs.getInt(1);
}
else { result = 0; }
} }
} }
catch (SQLException ex) { catch (SQLException ex) {

View File

@ -70,6 +70,10 @@ public class Users {
public static void addUser(Player player){ public static void addUser(Player player){
players.put(player, new PlayerProfile(player)); players.put(player, new PlayerProfile(player));
} }
public static void clearUsers()
{
players.clear();
}
public static void removeUser(Player player){ public static void removeUser(Player player){

View File

@ -81,8 +81,8 @@ public class PlayerProfile
myspawn = spawn.get(1).get(1) + "," + spawn.get(1).get(2) + "," + spawn.get(1).get(3); myspawn = spawn.get(1).get(1) + "," + spawn.get(1).get(2) + "," + spawn.get(1).get(3);
HashMap<Integer, ArrayList<String>> skills = mcMMO.database.Read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics FROM "+LoadProperties.MySQLtablePrefix+"skills WHERE user_id = " + id); HashMap<Integer, ArrayList<String>> skills = mcMMO.database.Read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics FROM "+LoadProperties.MySQLtablePrefix+"skills WHERE user_id = " + id);
taming = skills.get(1).get(0); taming = skills.get(1).get(0);
mining = skills.get(1).get(1);; mining = skills.get(1).get(1);
repair = skills.get(1).get(2);; repair = skills.get(1).get(2);
woodcutting = skills.get(1).get(3); woodcutting = skills.get(1).get(3);
unarmed = skills.get(1).get(4); unarmed = skills.get(1).get(4);
herbalism = skills.get(1).get(5); herbalism = skills.get(1).get(5);
@ -93,8 +93,8 @@ public class PlayerProfile
acrobatics = skills.get(1).get(10); acrobatics = skills.get(1).get(10);
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); 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);
tamingXP = experience.get(1).get(0); tamingXP = experience.get(1).get(0);
miningXP = experience.get(1).get(1);; miningXP = experience.get(1).get(1);
repairXP = experience.get(1).get(2);; repairXP = experience.get(1).get(2);
woodCuttingXP = experience.get(1).get(3); woodCuttingXP = experience.get(1).get(3);
unarmedXP = experience.get(1).get(4); unarmedXP = experience.get(1).get(4);
herbalismXP = experience.get(1).get(5); herbalismXP = experience.get(1).get(5);
@ -204,6 +204,7 @@ public class PlayerProfile
// if we are using mysql save to database // if we are using mysql save to database
if (LoadProperties.useMySQL) { if (LoadProperties.useMySQL) {
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid); mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET party = '"+this.party+"' WHERE id = " +this.userid);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"spawn SET world = '" + this.myspawnworld + "', x = " +getX()+", y = "+getY()+", z = "+getZ()+" WHERE user_id = "+this.userid); mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"spawn SET world = '" + this.myspawnworld + "', x = " +getX()+", y = "+getY()+", z = "+getZ()+" WHERE user_id = "+this.userid);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"skills SET " mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"skills SET "
+" taming = "+taming +" taming = "+taming
@ -1263,7 +1264,7 @@ public class PlayerProfile
} }
public boolean isDouble(String string){ public boolean isDouble(String string){
try { try {
//Double x = Double.valueOf(string); Double x = Double.valueOf(string);
} }
catch(NumberFormatException nFE) { catch(NumberFormatException nFE) {
return false; return false;

View File

@ -4,6 +4,9 @@ import java.io.BufferedReader;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -20,16 +23,48 @@ import com.gmail.nossr50.skills.*;
import com.gmail.nossr50.party.*; import com.gmail.nossr50.party.*;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.FakeBlockBreakEvent; import com.gmail.nossr50.datatypes.FakeBlockBreakEvent;
public class m { public class m {
public static final Logger log = Logger.getLogger("Minecraft");
/* /*
* I'm storing my functions/methods in here in an unorganized manner. Spheal with it. * I'm storing my misc functions/methods in here in an unorganized manner. Spheal with it.
*/ */
private static mcMMO plugin; private static mcMMO plugin;
public m(mcMMO instance) { public m(mcMMO instance) {
plugin = instance; plugin = instance;
} }
//The lazy way to default to 0
public static int getInt(String string)
{
if(isInt(string))
{
return Integer.valueOf(string);
}
else
{
return 0;
}
}
public static Double getDouble(String string)
{
if(isDouble(string))
{
return Double.valueOf(string);
}
else
{
return (double) 0;
}
}
public static boolean isDouble(String string)
{
try {
Double x = Double.valueOf(string);
}
catch(NumberFormatException nFE) {
return false;
}
return true;
}
public static boolean shouldBeWatched(Block block){ public static boolean shouldBeWatched(Block block){
int id = block.getTypeId(); 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){ 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){
@ -300,6 +335,180 @@ public class m {
return false; return false;
} }
} }
public static void convertToMySQL(Plugin pluginx)
{
if(!LoadProperties.useMySQL)
return;
String location = "plugins/mcMMO/mcmmo.users";
try {
//Open the user file
FileReader file = new FileReader(location);
BufferedReader in = new BufferedReader(file);
String line = "";
String x = null, y = null, z = null, playerName = null, mining = null, myspawn = null, party = null, miningXP = null, woodcutting = null, woodCuttingXP = null, repair = null, unarmed = null, herbalism = null,
excavation = null, archery = null, swords = null, axes = null, acrobatics = null, repairXP = null, unarmedXP = null, herbalismXP = null, excavationXP = null, archeryXP = null, swordsXP = null, axesXP = null,
acrobaticsXP = null, myspawnworld = null, taming = null, tamingXP = null;
int id = 0;
while((line = in.readLine()) != null)
{
//Find if the line contains the player we want.
String[] character = line.split(":");
playerName = character[0];
if(playerName == null)
continue;
//Get Mining
if(character.length > 1)
mining = character[1];
//Myspawn
if(character.length > 2)
myspawn = character[2];
//Party
if(character.length > 3)
party = character[3];
//Mining XP
if(character.length > 4)
miningXP = character[4];
if(character.length > 5)
woodcutting = character[5];
if(character.length > 6)
woodCuttingXP = character[6];
if(character.length > 7)
repair = character[7];
if(character.length > 8)
unarmed = character[8];
if(character.length > 9)
herbalism = character[9];
if(character.length > 10)
excavation = character[10];
if(character.length > 11)
archery = character[11];
if(character.length > 12)
swords = character[12];
if(character.length > 13)
axes = character[13];
if(character.length > 14)
acrobatics = character[14];
if(character.length > 15)
repairXP = character[15];
if(character.length > 16)
unarmedXP = character[16];
if(character.length > 17)
herbalismXP = character[17];
if(character.length > 18)
excavationXP = character[18];
if(character.length > 19)
archeryXP = character[19];
if(character.length > 20)
swordsXP = character[20];
if(character.length > 21)
axesXP = character[21];
if(character.length > 22)
acrobaticsXP = character[22];
if(character.length > 23)
myspawnworld = character[23];
if(character.length > 24)
taming = character[24];
if(character.length > 25)
tamingXP = character[25];
//Check to see if the user is in the DB
id = mcMMO.database.GetInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
//Prepare some variables
/*
if(myspawn != null && myspawn.length() > 0)
{
String[] split = myspawn.split(",");
x = split[0];
y = split[1];
z = split[2];
}
*/
/*
if(myspawnworld.equals("") || myspawnworld == null)
myspawnworld = pluginx.getServer().getWorlds().get(0).toString();
*/
if(id > 0)
{
//Update the skill values
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET lastlogin = " + 0 + " WHERE id = " + id);
//if(getDouble(x) > 0 && getDouble(y) > 0 && getDouble(z) > 0)
//mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"spawn SET world = '" + myspawnworld + "', x = " +getDouble(x)+", y = "+getDouble(y)+", z = "+getDouble(z)+" WHERE user_id = "+id);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"skills SET "
+" taming = taming+"+getInt(taming)
+", mining = mining+"+getInt(mining)
+", repair = repair+"+getInt(repair)
+", woodcutting = woodcutting+"+getInt(woodcutting)
+", unarmed = unarmed+"+getInt(unarmed)
+", herbalism = herbalism+"+getInt(herbalism)
+", excavation = excavation+"+getInt(excavation)
+", archery = archery+" +getInt(archery)
+", swords = swords+" +getInt(swords)
+", axes = axes+"+getInt(axes)
+", acrobatics = acrobatics+"+getInt(acrobatics)
+" WHERE user_id = "+id);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"experience SET "
+" taming = "+getInt(tamingXP)
+", mining = "+getInt(miningXP)
+", repair = "+getInt(repairXP)
+", woodcutting = "+getInt(woodCuttingXP)
+", unarmed = "+getInt(unarmedXP)
+", herbalism = "+getInt(herbalismXP)
+", excavation = "+getInt(excavationXP)
+", archery = " +getInt(archeryXP)
+", swords = " +getInt(swordsXP)
+", axes = "+getInt(axesXP)
+", acrobatics = "+getInt(acrobaticsXP)
+" WHERE user_id = "+id);
}
else
{
//Create the user in the DB
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")");
id = mcMMO.database.GetInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
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+")");
//Update the skill values
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET lastlogin = " + 0 + " WHERE id = " + id);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET party = '"+party+"' WHERE id = " +id);
/*
if(getDouble(x) > 0 && getDouble(y) > 0 && getDouble(z) > 0)
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"spawn SET world = '" + myspawnworld + "', x = " +getDouble(x)+", y = "+getDouble(y)+", z = "+getDouble(z)+" WHERE user_id = "+id);
*/
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"skills SET "
+" taming = "+getInt(taming)
+", mining = "+getInt(mining)
+", repair = "+getInt(repair)
+", woodcutting = "+getInt(woodcutting)
+", unarmed = "+getInt(unarmed)
+", herbalism = "+getInt(herbalism)
+", excavation = "+getInt(excavation)
+", archery = " +getInt(archery)
+", swords = " +getInt(swords)
+", axes = "+getInt(axes)
+", acrobatics = "+getInt(acrobatics)
+" WHERE user_id = "+id);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"experience SET "
+" taming = "+getInt(tamingXP)
+", mining = "+getInt(miningXP)
+", repair = "+getInt(repairXP)
+", woodcutting = "+getInt(woodCuttingXP)
+", unarmed = "+getInt(unarmedXP)
+", herbalism = "+getInt(herbalismXP)
+", excavation = "+getInt(excavationXP)
+", archery = " +getInt(archeryXP)
+", swords = " +getInt(swordsXP)
+", axes = "+getInt(axesXP)
+", acrobatics = "+getInt(acrobaticsXP)
+" WHERE user_id = "+id);
}
}
in.close();
} catch (Exception e) {
log.log(Level.SEVERE, "Exception while reading "
+ location + " (Are you sure you formatted it correctly?)", e);
}
}
public static void mmoHelpCheck(String[] split, Player player, PlayerChatEvent event){ public static void mmoHelpCheck(String[] split, Player player, PlayerChatEvent event){
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
if(split[0].equalsIgnoreCase("/taming")){ if(split[0].equalsIgnoreCase("/taming")){
@ -310,16 +519,20 @@ public class m {
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"TAMING"+ChatColor.RED+"[]-----"); player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"TAMING"+ChatColor.RED+"[]-----");
player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Fighting with your wolves"); player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Fighting with your wolves");
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---"); player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---");
//player.sendMessage(ChatColor.DARK_AQUA+"Tree Feller (ABILITY): "+ChatColor.GREEN+"Make trees explode");
player.sendMessage(ChatColor.DARK_AQUA+"Gore: "+ChatColor.YELLOW+ChatColor.GREEN+"Critical Strike that applies Bleed"); player.sendMessage(ChatColor.DARK_AQUA+"Gore: "+ChatColor.YELLOW+ChatColor.GREEN+"Critical Strike that applies Bleed");
player.sendMessage(ChatColor.DARK_AQUA+"Sharpened Claws: "+ChatColor.YELLOW+ChatColor.GREEN+"Damage Bonus"); player.sendMessage(ChatColor.DARK_AQUA+"Sharpened Claws: "+ChatColor.YELLOW+ChatColor.GREEN+"Damage Bonus");
player.sendMessage(ChatColor.DARK_AQUA+"Thick Fur: "+ChatColor.YELLOW+ChatColor.GREEN+"Damage Reduction"); player.sendMessage(ChatColor.DARK_AQUA+"Environmentally Aware: "+ChatColor.YELLOW+ChatColor.GREEN+"Cactus/Lava Phobia, Fall DMG Immune");
player.sendMessage(ChatColor.DARK_AQUA+"Thick Fur: "+ChatColor.YELLOW+ChatColor.GREEN+"DMG Reduction, Fire Resistance");
player.sendMessage(ChatColor.DARK_AQUA+"Shock Proof: "+ChatColor.YELLOW+ChatColor.GREEN+"Explosive Damage Reduction"); player.sendMessage(ChatColor.DARK_AQUA+"Shock Proof: "+ChatColor.YELLOW+ChatColor.GREEN+"Explosive Damage Reduction");
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"YOUR STATS"+ChatColor.RED+"[]---"); player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"YOUR STATS"+ChatColor.RED+"[]---");
if(PP.getTamingInt() < 100)
player.sendMessage(ChatColor.GRAY+"LOCKED UNTIL 100+ SKILL (ENVIRONMENTALLY AWARE)");
else
player.sendMessage(ChatColor.RED+"Environmentally Aware: "+ChatColor.YELLOW+"Wolves avoid danger");
if(PP.getTamingInt() < 250) if(PP.getTamingInt() < 250)
player.sendMessage(ChatColor.GRAY+"LOCKED UNTIL 250+ SKILL (THICK FUR)"); player.sendMessage(ChatColor.GRAY+"LOCKED UNTIL 250+ SKILL (THICK FUR)");
else else
player.sendMessage(ChatColor.RED+"Thick Fur: "+ChatColor.YELLOW+"Halved Damage"); player.sendMessage(ChatColor.RED+"Thick Fur: "+ChatColor.YELLOW+"Halved Damage, Fire Resistance");
if(PP.getTamingInt() < 500) if(PP.getTamingInt() < 500)
player.sendMessage(ChatColor.GRAY+"LOCKED UNTIL 500+ SKILL (SHOCK PROOF)"); player.sendMessage(ChatColor.GRAY+"LOCKED UNTIL 500+ SKILL (SHOCK PROOF)");
else else

View File

@ -49,7 +49,7 @@ public class mcEntityListener extends EntityListener {
} }
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
if(event.isCancelled()) if(event.isCancelled())
return; return;
/* /*
* CHECK FOR INVULNERABILITY * CHECK FOR INVULNERABILITY
*/ */
@ -71,6 +71,34 @@ public class mcEntityListener extends EntityListener {
{ {
Entity x = event.getEntity(); Entity x = event.getEntity();
DamageCause type = event.getCause(); DamageCause type = event.getCause();
if(event.getEntity() instanceof Wolf)
{
Player master = Taming.getOwner(event.getEntity(), plugin);
PlayerProfile PPo = Users.getProfile(master);
if(master == null || PPo == null)
return;
//Environmentally Aware
if((event.getCause() == DamageCause.CONTACT || event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE) && PPo.getTamingInt() >= 100)
{
if(event.getDamage() < ((Wolf) event.getEntity()).getHealth())
{
event.getEntity().teleport(Taming.getOwner(event.getEntity(), plugin).getLocation());
master.sendMessage(ChatColor.DARK_GRAY+"Your wolf scurries back to you...");
event.getEntity().setFireTicks(0);
}
}
if(event.getCause() == DamageCause.FALL && PPo.getTamingInt() >= 100)
{
event.setCancelled(true);
}
//Thick Fur
if(event.getCause() == DamageCause.FIRE_TICK)
{
event.getEntity().setFireTicks(0);
}
}
/* /*
* ACROBATICS * ACROBATICS
*/ */

View File

@ -30,6 +30,13 @@ public class mcPermissions {
private static boolean permission(Player player, String string) { private static boolean permission(Player player, String string) {
return permissionsPlugin.Security.permission(player, string); return permissionsPlugin.Security.permission(player, string);
} }
public boolean admin(Player player){
if (permissionsEnabled) {
return permission(player, "mcmmo.admin");
} else {
return true;
}
}
public boolean mcrefresh(Player player) { public boolean mcrefresh(Player player) {
if (permissionsEnabled) { if (permissionsEnabled) {
return permission(player, "mcmmo.tools.mcrefresh"); return permission(player, "mcmmo.tools.mcrefresh");

View File

@ -213,6 +213,18 @@ public class mcPlayerListener extends PlayerListener {
player.sendMessage("Type ID : "+player.getItemInHand().getTypeId()); player.sendMessage("Type ID : "+player.getItemInHand().getTypeId());
player.sendMessage("Byte Data : "+player.getItemInHand().getDurability()); player.sendMessage("Byte Data : "+player.getItemInHand().getDurability());
} }
if(split[0].equalsIgnoreCase("/mmoupdate") && mcPermissions.getInstance().admin(player))
{
event.setCancelled(true);
player.sendMessage(ChatColor.GRAY+"Starting conversion...");
Users.clearUsers();
m.convertToMySQL(plugin);
for(Player x : plugin.getServer().getOnlinePlayers())
{
Users.addUser(x);
}
player.sendMessage(ChatColor.GREEN+"Conversion finished!");
}
/* /*
* LEADER BOARD COMMAND * LEADER BOARD COMMAND
*/ */
@ -336,7 +348,7 @@ public class mcPlayerListener extends PlayerListener {
for(int i=n;i<=n+10;i++) for(int i=n;i<=n+10;i++)
{ {
if (i >= userslist.size()) if (i > userslist.size())
break; break;
HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'"); HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
player.sendMessage(String.valueOf(i)+". "+ChatColor.GREEN+userslist.get(i).get(0)+" - "+ChatColor.WHITE+username.get(1).get(0)); player.sendMessage(String.valueOf(i)+". "+ChatColor.GREEN+userslist.get(i).get(0)+" - "+ChatColor.WHITE+username.get(1).get(0));
@ -348,6 +360,8 @@ public class mcPlayerListener extends PlayerListener {
+LoadProperties.MySQLtablePrefix+"skills ORDER BY `"+LoadProperties.MySQLtablePrefix+"skills`.`"+lowercase+"` DESC "); +LoadProperties.MySQLtablePrefix+"skills ORDER BY `"+LoadProperties.MySQLtablePrefix+"skills`.`"+lowercase+"` DESC ");
for(int i=1;i<=10;i++) //i<=userslist.size() for(int i=1;i<=10;i++) //i<=userslist.size()
{ {
if (i > userslist.size())
break;
HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'"); HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
player.sendMessage(String.valueOf(i)+". "+ChatColor.GREEN+userslist.get(i).get(0)+" - "+ChatColor.WHITE+username.get(1).get(0)); player.sendMessage(String.valueOf(i)+". "+ChatColor.GREEN+userslist.get(i).get(0)+" - "+ChatColor.WHITE+username.get(1).get(0));
} }
@ -371,7 +385,7 @@ public class mcPlayerListener extends PlayerListener {
+LoadProperties.MySQLtablePrefix+"skills ORDER BY taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics DESC "); +LoadProperties.MySQLtablePrefix+"skills ORDER BY taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics DESC ");
for(int i=n;i<=n+10;i++) for(int i=n;i<=n+10;i++)
{ {
if (i >= userslist.size()) if (i > userslist.size())
break; break;
HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'"); HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
player.sendMessage(String.valueOf(i)+". "+ChatColor.GREEN+userslist.get(i).get(0)+" - "+ChatColor.WHITE+username.get(1).get(0)); player.sendMessage(String.valueOf(i)+". "+ChatColor.GREEN+userslist.get(i).get(0)+" - "+ChatColor.WHITE+username.get(1).get(0));
@ -382,7 +396,7 @@ public class mcPlayerListener extends PlayerListener {
+LoadProperties.MySQLtablePrefix+"skills ORDER BY taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics DESC "); +LoadProperties.MySQLtablePrefix+"skills ORDER BY taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics DESC ");
for(int i=1;i<=10;i++) for(int i=1;i<=10;i++)
{ {
if (i >= userslist.size()) if (i > userslist.size())
break; break;
HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'"); HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
player.sendMessage(String.valueOf(i)+". "+ChatColor.GREEN+userslist.get(i).get(0)+" - "+ChatColor.WHITE+username.get(1).get(0)); player.sendMessage(String.valueOf(i)+". "+ChatColor.GREEN+userslist.get(i).get(0)+" - "+ChatColor.WHITE+username.get(1).get(0));