Merging with solarcloud7's repair customization pull request, changed some values to represent defaults of mcMMO.

Merge branch 'patch-1' of https://github.com/solarcloud7/vminecraft-plugin into solarcloud7-patch-1

Conflicts:
	mcMMO/com/gmail/nossr50/config/LoadProperties.java
This commit is contained in:
nossr50 2011-05-03 23:54:06 -07:00
commit e9099a286a
8 changed files with 80 additions and 49 deletions

View File

@ -5,6 +5,7 @@ Leaderboards ignore players with the respective stat at 0
Reconnecting to MySQL will reload player data Reconnecting to MySQL will reload player data
Fixed a NPE with MySQL's Leaderboards Fixed a NPE with MySQL's Leaderboards
Removed "Loop iteration" debug message from mcMMO Removed "Loop iteration" debug message from mcMMO
Added more repair customization by solarcloud7
Version 1.0.06 Version 1.0.06
MySQL will attempt to reconnect if the connection is closed MySQL will attempt to reconnect if the connection is closed

View File

@ -373,12 +373,12 @@ public class Combat {
} }
if(PPa.getArcheryInt() >= 1000){ if(PPa.getArcheryInt() >= 1000){
if(Math.random() * 1000 <= 500){ if(Math.random() * 1000 <= 500){
defender.teleportTo(loc); defender.teleport(loc);
defender.sendMessage(ChatColor.DARK_RED+"Touched Fuzzy. Felt Dizzy."); defender.sendMessage(ChatColor.DARK_RED+"Touched Fuzzy. Felt Dizzy.");
attacker.sendMessage("Target was "+ChatColor.DARK_RED+"Dazed"); attacker.sendMessage("Target was "+ChatColor.DARK_RED+"Dazed");
} }
} else if(Math.random() * 2000 <= PPa.getArcheryInt()){ } else if(Math.random() * 2000 <= PPa.getArcheryInt()){
defender.teleportTo(loc); defender.teleport(loc);
defender.sendMessage(ChatColor.DARK_RED+"Touched Fuzzy. Felt Dizzy."); defender.sendMessage(ChatColor.DARK_RED+"Touched Fuzzy. Felt Dizzy.");
attacker.sendMessage("Target was "+ChatColor.DARK_RED+"Dazed"); attacker.sendMessage("Target was "+ChatColor.DARK_RED+"Dazed");
} }

View File

@ -12,6 +12,7 @@ import java.sql.PreparedStatement;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.avaje.ebeaninternal.server.lib.sql.DataSourceException;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
@ -27,7 +28,7 @@ public class Database {
try { try {
Class.forName("com.mysql.jdbc.Driver").newInstance(); Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) { } catch (Exception ex) {
// handle the error throw new DataSourceException("Failed to initialize JDBC driver");
} }
// make the connection // make the connection

View File

@ -51,7 +51,7 @@ public class Item {
if(player != null){ if(player != null){
if(player.getLocation().getWorld().getBlockAt(block.getX(), y, block.getZ()).getType() != Material.AIR){ if(player.getLocation().getWorld().getBlockAt(block.getX(), y, block.getZ()).getType() != Material.AIR){
player.sendMessage("**CHIMAERA WING FAILED!**"); player.sendMessage("**CHIMAERA WING FAILED!**");
player.teleportTo(player.getLocation().getWorld().getBlockAt(block.getX(), (y - 1), block.getZ()).getLocation()); player.teleport(player.getLocation().getWorld().getBlockAt(block.getX(), (y - 1), block.getZ()).getLocation());
return; return;
} }
} }
@ -61,11 +61,11 @@ public class Item {
if(mySpawn != null && plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)) != null) if(mySpawn != null && plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)) != null)
mySpawn.setWorld(plugin.getServer().getWorld(PP.getMySpawnWorld(plugin))); mySpawn.setWorld(plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)));
if(mySpawn != null){ if(mySpawn != null){
player.teleportTo(mySpawn);//Do it twice to prevent weird stuff player.teleport(mySpawn);//Do it twice to prevent weird stuff
player.teleportTo(mySpawn); player.teleport(mySpawn);
} }
} else { } else {
player.teleportTo(player.getWorld().getSpawnLocation()); player.teleport(player.getWorld().getSpawnLocation());
} }
player.sendMessage("**CHIMAERA WING**"); player.sendMessage("**CHIMAERA WING**");
} else if (!Skills.cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= 10) { } else if (!Skills.cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= 10) {

View File

@ -4,8 +4,8 @@ import com.gmail.nossr50.mcMMO;
public class LoadProperties { public class LoadProperties {
public static Boolean enableCobbleToMossy, useMySQL, cocoabeans, archeryFireRateLimit, mushrooms, toolsLoseDurabilityFromAbilities, pvpxp, miningrequirespickaxe, woodcuttingrequiresaxe, pvp, eggs, apples, cake, music, diamond, glowstone, slowsand, sulphur, netherrack, bones, coal, clay, anvilmessages; public static Boolean enableCobbleToMossy, useMySQL, cocoabeans, archeryFireRateLimit, mushrooms, toolsLoseDurabilityFromAbilities, pvpxp, miningrequirespickaxe, woodcuttingrequiresaxe, pvp, eggs, apples, cake, music, diamond, glowstone, slowsand, sulphur, netherrack, bones, coal, clay, anvilmessages;
public static String MySQLtablePrefix, MySQLuserName, MySQLserverName, MySQLdbName, MySQLdbPass, mctop, addxp, mcability, mcmmo, mcc, mcrefresh, mcitem, mcgod, stats, mmoedit, ptp, party, myspawn, setmyspawn, whois, invite, accept, clearmyspawn; public static String MySQLtablePrefix, MySQLuserName, MySQLserverName, MySQLdbName, MySQLdbPass, mctop, addxp, mcability, mcmmo, mcc, mcrefresh, mcitem, mcgod, stats, mmoedit, ptp, party, myspawn, setmyspawn, whois, invite, accept, clearmyspawn, nWood, nStone, nIron, nGold, nDiamond;;
public static int MySQLport, xpGainMultiplier, superBreakerCooldown, greenTerraCooldown, gigaDrillBreakerCooldown, treeFellerCooldown, berserkCooldown, serratedStrikeCooldown, skullSplitterCooldown, abilityDurabilityLoss, feathersConsumedByChimaeraWing, pvpxprewardmodifier, repairdiamondlevel, globalxpmodifier, tamingxpmodifier, miningxpmodifier, repairxpmodifier, woodcuttingxpmodifier, unarmedxpmodifier, herbalismxpmodifier, excavationxpmodifier, archeryxpmodifier, swordsxpmodifier, axesxpmodifier, acrobaticsxpmodifier; public static int MySQLport, xpGainMultiplier, superBreakerCooldown, greenTerraCooldown, gigaDrillBreakerCooldown, treeFellerCooldown, berserkCooldown, serratedStrikeCooldown, skullSplitterCooldown, abilityDurabilityLoss, feathersConsumedByChimaeraWing, pvpxprewardmodifier, repairdiamondlevel, globalxpmodifier, tamingxpmodifier, miningxpmodifier, repairxpmodifier, woodcuttingxpmodifier, unarmedxpmodifier, herbalismxpmodifier, excavationxpmodifier, archeryxpmodifier, swordsxpmodifier, axesxpmodifier, acrobaticsxpmodifier, rWood, rStone, rIron, rGold, rDiamond;;
public static void loadMain(){ public static void loadMain(){
String propertiesFile = mcMMO.maindirectory + "mcmmo.properties"; String propertiesFile = mcMMO.maindirectory + "mcmmo.properties";
@ -73,6 +73,20 @@ public class LoadProperties {
* ANVIL MESSAGES * ANVIL MESSAGES
*/ */
anvilmessages = properties.getBoolean("anvilMessages", true); anvilmessages = properties.getBoolean("anvilMessages", true);
/*
* ANVIL REPAIR (REQUIRED ITEM) AND (NAME OF ITEM)
*/
rGold = properties.getInteger("GoldRepairItemNumber", 266);
nGold = properties.getString("GoldItemRepairName", "Gold Bars");
rStone = properties.getInteger("CobblestoneRepairItemNumber", 4);
nStone = properties.getString("CobblestoneItemRepairName", "Cobblestone");
rWood = properties.getInteger("WoodRepairItemNumber", 5);
nWood = properties.getString("WoodItemRepairName", "Wood Planks");
rDiamond = properties.getInteger("DiamondRepairItemNumber", 264);
nDiamond = properties.getString("DiamondItemRepairName", "Diamond Ore");
rIron = properties.getInteger("IronRepairItemNumber", 265);
nIron = properties.getString("IronItemRepairName", "Iron Bars");
/* /*
* EXCAVATION LOOT TOGGLES * EXCAVATION LOOT TOGGLES
*/ */

View File

@ -5,6 +5,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
public class FakeBlockBreakEvent extends BlockBreakEvent { public class FakeBlockBreakEvent extends BlockBreakEvent {
private static final long serialVersionUID = 1L;
public FakeBlockBreakEvent(Block theBlock, Player player) { public FakeBlockBreakEvent(Block theBlock, Player player) {
super(theBlock, player); super(theBlock, player);
} }

View File

@ -9,10 +9,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -31,7 +28,6 @@ import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.skills.Herbalism; import com.gmail.nossr50.skills.Herbalism;
import com.gmail.nossr50.skills.Repair; import com.gmail.nossr50.skills.Repair;
import com.gmail.nossr50.skills.Skills; import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Taming;
public class mcPlayerListener extends PlayerListener { public class mcPlayerListener extends PlayerListener {
@ -557,7 +553,7 @@ public class mcPlayerListener extends PlayerListener {
Player target = getPlayer(split[1]); Player target = getPlayer(split[1]);
PlayerProfile PPt = Users.getProfile(target); PlayerProfile PPt = Users.getProfile(target);
if(PP.getParty().equals(PPt.getParty())){ if(PP.getParty().equals(PPt.getParty())){
player.teleportTo(target); player.teleport(target);
player.sendMessage(ChatColor.GREEN+"You have teleported to "+target.getName()); player.sendMessage(ChatColor.GREEN+"You have teleported to "+target.getName());
target.sendMessage(ChatColor.GREEN+player.getName() + " has teleported to you."); target.sendMessage(ChatColor.GREEN+player.getName() + " has teleported to you.");
} }
@ -837,8 +833,8 @@ public class mcPlayerListener extends PlayerListener {
//player.sendMessage("MMO DEBUG CODE 5"); //player.sendMessage("MMO DEBUG CODE 5");
mySpawn.setWorld(plugin.getServer().getWorlds().get(0)); mySpawn.setWorld(plugin.getServer().getWorlds().get(0));
} }
player.teleportTo(mySpawn); //It's done twice because teleporting from one world to another is weird player.teleport(mySpawn); //It's done twice because teleporting from one world to another is weird
player.teleportTo(mySpawn); player.teleport(mySpawn);
} else { } else {
player.sendMessage(ChatColor.RED+"Configure your myspawn first with a bed."); player.sendMessage(ChatColor.RED+"Configure your myspawn first with a bed.");
} }

View File

@ -20,6 +20,21 @@ public class Repair {
} }
private static volatile Repair instance; private static volatile Repair instance;
/*
* Repair requirements for each material
*/
private static int rGold = LoadProperties.rGold;
private static String nGold = LoadProperties.nGold;
private static int rStone = LoadProperties.rStone;
private static String nStone = LoadProperties.nStone;
private static int rWood = LoadProperties.rWood;
private static String nWood = LoadProperties.nWood;
private static int rDiamond = LoadProperties.rDiamond;
private static String nDiamond = LoadProperties.nDiamond;
private static int rIron = LoadProperties.rIron;
private static String nIron = LoadProperties.nIron;
public static void repairCheck(Player player, ItemStack is, Block block){ public static void repairCheck(Player player, ItemStack is, Block block){
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
short durabilityBefore = player.getItemInHand().getDurability(); short durabilityBefore = player.getItemInHand().getDurability();
@ -35,8 +50,8 @@ public class Repair {
/* /*
* DIAMOND ARMOR * DIAMOND ARMOR
*/ */
if(isDiamondArmor(is) && hasItem(player, 264) && PP.getRepairInt() >= LoadProperties.repairdiamondlevel){ if(isDiamondArmor(is) && hasItem(player, rDiamond) && PP.getRepairInt() >= LoadProperties.repairdiamondlevel){
removeItem(player, 264); removeItem(player, rDiamond);
player.getItemInHand().setDurability(getRepairAmount(is, player)); player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability(); durabilityAfter = player.getItemInHand().getDurability();
player.sendMessage(String.valueOf(durabilityBefore - durabilityAfter)); player.sendMessage(String.valueOf(durabilityBefore - durabilityAfter));
@ -44,19 +59,19 @@ public class Repair {
dif = (short) (dif * 6); //Boost XP dif = (short) (dif * 6); //Boost XP
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier); PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} }
else if (isIronArmor(is) && hasItem(player, 265)){ else if (isIronArmor(is) && hasItem(player, rIron)){
/* /*
* IRON ARMOR * IRON ARMOR
*/ */
removeItem(player, 265); removeItem(player, rIron);
player.getItemInHand().setDurability(getRepairAmount(is, player)); player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability(); durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter); dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 2); //Boost XP dif = (short) (dif * 2); //Boost XP
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier); PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
//GOLD ARMOR //GOLD ARMOR
} else if (isGoldArmor(is) && hasItem(player, 266)){ } else if (isGoldArmor(is) && hasItem(player, rGold)){
removeItem(player, 266); removeItem(player, rGold);
player.getItemInHand().setDurability(getRepairAmount(is, player)); player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability(); durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter); dif = (short) (durabilityBefore - durabilityAfter);
@ -70,8 +85,8 @@ public class Repair {
* TOOLS * TOOLS
*/ */
if(isTools(is)){ if(isTools(is)){
if(isStoneTools(is) && hasItem(player, 4)){ if(isStoneTools(is) && hasItem(player, rStone)){
removeItem(player, 4); removeItem(player, rStone);
/* /*
* Repair Durability and calculate dif * Repair Durability and calculate dif
*/ */
@ -88,8 +103,8 @@ public class Repair {
dif = (short) (dif / 2); dif = (short) (dif / 2);
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier); PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} else if(isWoodTools(is) && hasItem(player, 5)){ } else if(isWoodTools(is) && hasItem(player,rWood)){
removeItem(player, 5); removeItem(player,rWood);
/* /*
* Repair Durability and calculate dif * Repair Durability and calculate dif
*/ */
@ -106,8 +121,8 @@ public class Repair {
dif = (short) (dif / 2); dif = (short) (dif / 2);
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier); PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} else if(isIronTools(is) && hasItem(player, 265)){ } else if(isIronTools(is) && hasItem(player, rIron)){
removeItem(player, 265); removeItem(player, rIron);
/* /*
* Repair Durability and calculate dif * Repair Durability and calculate dif
*/ */
@ -121,12 +136,12 @@ public class Repair {
if(m.isHoe(is)) if(m.isHoe(is))
dif = (short) (dif / 2); dif = (short) (dif / 2);
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier); PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} else if (isDiamondTools(is) && hasItem(player, 264) && PP.getRepairInt() >= LoadProperties.repairdiamondlevel){ //Check if its diamond and the player has diamonds } else if (isDiamondTools(is) && hasItem(player, rDiamond) && PP.getRepairInt() >= LoadProperties.repairdiamondlevel){ //Check if its diamond and the player has diamonds
/* /*
* DIAMOND TOOLS * DIAMOND TOOLS
*/ */
player.getItemInHand().setDurability(getRepairAmount(is, player)); player.getItemInHand().setDurability(getRepairAmount(is, player));
removeItem(player, 264); removeItem(player, rDiamond);
durabilityAfter = player.getItemInHand().getDurability(); durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter); dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is)) if(m.isShovel(is))
@ -136,9 +151,9 @@ public class Repair {
if(m.isHoe(is)) if(m.isHoe(is))
dif = (short) (dif / 2); dif = (short) (dif / 2);
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier); PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} else if(isGoldTools(is) && hasItem(player, 266)){ } else if(isGoldTools(is) && hasItem(player, rGold)){
player.getItemInHand().setDurability(getRepairAmount(is, player)); player.getItemInHand().setDurability(getRepairAmount(is, player));
removeItem(player, 266); removeItem(player, rGold);
durabilityAfter = player.getItemInHand().getDurability(); durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter); dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 7.6); //Boost XP for Gold to that of around Iron dif = (short) (dif * 7.6); //Boost XP for Gold to that of around Iron
@ -279,7 +294,9 @@ public class Repair {
if(checkPlayerProcRepair(player)){ if(checkPlayerProcRepair(player)){
ramt = (short) (ramt * 2); ramt = (short) (ramt * 2);
} }
//player.sendMessage(ChatColor.DARK_RED + "test " +ChatColor.BLUE+ );
durability-=ramt; durability-=ramt;
// player.sendMessage(ChatColor.DARK_RED + "durability " +ChatColor.BLUE+ durability);
if(durability < 0){ if(durability < 0){
durability = 0; durability = 0;
} }
@ -431,23 +448,23 @@ public class Repair {
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
if ((isDiamondTools(is) || isDiamondArmor(is)) && PP.getRepairInt() < LoadProperties.repairdiamondlevel){ if ((isDiamondTools(is) || isDiamondArmor(is)) && PP.getRepairInt() < LoadProperties.repairdiamondlevel){
player.sendMessage(ChatColor.DARK_RED +"You're not adept enough to repair Diamond"); player.sendMessage(ChatColor.DARK_RED +"You're not adept enough to repair Diamond");
} else if (isDiamondTools(is) && !hasItem(player, 264) || isIronTools(is) && !hasItem(player, 265) || isGoldTools(is) && !hasItem(player, 266)){ } else if (isDiamondTools(is) && !hasItem(player, rDiamond) || isIronTools(is) && !hasItem(player, rIron) || isGoldTools(is) && !hasItem(player, rGold)){
if(isDiamondTools(is) && !hasItem(player, 264)) if(isDiamondTools(is) && !hasItem(player, rDiamond))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds"); player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ nDiamond);
if(isIronTools(is) && !hasItem(player, 265)) if(isIronTools(is) && !hasItem(player, rIron))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron"); player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ nIron);
if(isGoldTools(is) && !hasItem(player, 266)) if(isGoldTools(is) && !hasItem(player, rGold))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GOLD+"Gold"); player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GOLD+nGold);
if(isWoodTools(is) && !hasItem(player, 5)) if(isWoodTools(is) && !hasItem(player,rWood))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.DARK_GREEN+"Wood"); player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.DARK_GREEN+ nWood);
if(isStoneTools(is) && !hasItem(player, 4)) if(isStoneTools(is) && !hasItem(player, rStone))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+"Stone"); player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+nStone);
} else if (isDiamondArmor(is) && !hasItem(player, 264)){ } else if (isDiamondArmor(is) && !hasItem(player, rDiamond)){
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds"); player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ nDiamond);
} else if (isIronArmor(is) && !hasItem(player, 265)){ } else if (isIronArmor(is) && !hasItem(player, rIron)){
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron"); player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ nIron);
} else if (isGoldArmor(is) && !hasItem(player, 266)){ } else if (isGoldArmor(is) && !hasItem(player, rGold)){
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GOLD+"Gold"); player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GOLD+ nGold);
} else if (is.getAmount() > 1) } else if (is.getAmount() > 1)
player.sendMessage(ChatColor.DARK_RED+"You can't repair stacked items"); player.sendMessage(ChatColor.DARK_RED+"You can't repair stacked items");
} }