The released version of 1.0, now to brace for cruel months of no internet.

This commit is contained in:
nossr50 2011-04-28 01:49:40 -07:00
parent f9c941af6e
commit ecb03aebaf
15 changed files with 499 additions and 450 deletions

View File

@ -1,6 +1,7 @@
Changelog:
#Versions without changelogs probably had very small misc fixes, like tweaks to the source code#
Version 1.0
Players can now repair Stone/Wood tools
Fixed duping bug with WG/Block Protection Plugins
Added Leaf Blower to WoodCutting
Different Trees give different WoodCutting XP

View File

@ -119,7 +119,9 @@ public class Combat {
//Taming Debug Stuff
if(event.getEntity() instanceof Wolf)
{
if(attacker.getItemInHand().getTypeId() == 352)
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(event.getEntity(), pluginx)))
event.setCancelled(true);
if(attacker.getItemInHand().getTypeId() == 352 && mcPermissions.getInstance().taming(attacker))
{
attacker.sendMessage(ChatColor.GREEN+"**You examine the Wolf using Beast Lore**");
if(Taming.getOwnerName(event.getEntity()) != null)
@ -136,11 +138,6 @@ public class Combat {
*/
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;
if(Taming.hasOwner(eventb.getDamager(), pluginx))
{
@ -197,8 +194,10 @@ public class Combat {
/*
* TEMPORARY FIX AS WOLVES AREN'T TRIGGERING DAMAGE EVENTS WHEN ATTACKING NON PLAYERS AT THE TIME OF WRITING
*/
if(!event.isCancelled()){
PPo.addTamingXP(event.getDamage() * 3);
Skills.XpCheck(master);
}
//Shock-Proof
if((event.getCause() == DamageCause.ENTITY_EXPLOSION || event.getCause() == DamageCause.BLOCK_EXPLOSION) && PPo.getTamingInt() >= 500)

View File

@ -147,6 +147,8 @@ public class Leaderboard {
String line = "";
for(PlayerStat p : ps)
{
if(p.name.equals("$mcMMO_DummyInfo"))
continue;
writer.append(p.name + ":" + p.statVal);
writer.append("\r\n");
}

View File

@ -43,7 +43,7 @@ public class Users {
FileWriter writer = null;
try {
writer = new FileWriter(location);
writer.write("#Storage place for user information\r\n");
//writer.write("#Storage place for user information\r\n");
} catch (Exception e) {
log.log(Level.SEVERE, "Exception while creating " + location, e);
} finally {
@ -57,7 +57,6 @@ public class Users {
}
} else {
//properties = new PropertiesFile(location);
try {
load();
} catch (IOException e) {

View File

@ -33,7 +33,7 @@ public class LoadProperties {
MySQLuserName = properties.getString("MySQLuserName", "defaultusername");
MySQLtablePrefix = properties.getString("MySQLTablePrefix", "mcmmo_");
MySQLport = properties.getInteger("MySQLport", 3306);
useMySQL = properties.getBoolean("mysql", false);
useMySQL = properties.getBoolean("UseMySQL", false);
/*
* OTHER

View File

@ -25,8 +25,8 @@ import com.gmail.nossr50.skills.*;
public class PlayerProfile
{
protected final Logger log = Logger.getLogger("Minecraft");
private String taming, tamingXP, playerName, miningXP, woodCuttingXP, woodcutting, repair, mining, party, myspawn, myspawnworld, unarmed, herbalism, excavation,
archery, swords, axes, invite, acrobatics, repairXP, unarmedXP, herbalismXP, excavationXP, archeryXP, swordsXP, axesXP, acrobaticsXP;
private String taming="0", tamingXP="0", miningXP="0", woodCuttingXP="0", woodcutting="0", repair="0", mining="0", party, myspawn, myspawnworld, unarmed="0", herbalism="0", excavation="0",
archery="0", swords="0", axes="0", invite, acrobatics="0", repairXP="0", unarmedXP="0", herbalismXP="0", excavationXP="0", archeryXP="0", swordsXP="0", axesXP="0", acrobaticsXP="0";
private boolean greenTerraMode, partyChatOnly = false, greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true,
superBreakerInformed = true, serratedStrikesInformed = true, treeFellerInformed = true, dead, abilityuse = true, treeFellerMode, superBreakerMode, gigaDrillBreakerMode,
serratedStrikesMode, hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode, pickaxePreparationMode, axePreparationMode, skullSplitterMode, berserkMode;
@ -46,21 +46,17 @@ public class PlayerProfile
public PlayerProfile(Player player)
{
thisplayer = player;
if (LoadProperties.useMySQL) {
// if usemysql load from database
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
loadMySQL(player);//This is probably not needed anymore, could just delete
}
} else {
// load from flat file
if(!load()) { addPlayer(); }
}
}
public int getMySQLuserId(){
return userid;
}
@ -131,7 +127,7 @@ public class PlayerProfile
//Find if the line contains the player we want.
String[] character = line.split(":");
if(!character[0].equals(playerName)){continue;}
if(!character[0].equals(thisplayer.getName())){continue;}
//Get Mining
if(character.length > 1)
@ -247,13 +243,13 @@ public class PlayerProfile
{
//Read the line in and copy it to the output it's not the player
//we want to edit
if(!line.split(":")[0].equalsIgnoreCase(playerName))
if(!line.split(":")[0].equalsIgnoreCase(thisplayer.getName()))
{
writer.append(line).append("\r\n");
//Otherwise write the new player information
} else {
writer.append(playerName + ":");
writer.append(thisplayer.getName() + ":");
writer.append(mining + ":");
writer.append(myspawn + ":");
writer.append(party+":");
@ -300,7 +296,7 @@ public class PlayerProfile
BufferedWriter out = new BufferedWriter(file);
//Add the player to the end
out.append(playerName + ":");
out.append(thisplayer.getName() + ":");
out.append(0 + ":"); //mining
out.append(myspawn+":");
out.append(party+":");
@ -338,7 +334,7 @@ public class PlayerProfile
public boolean isPlayer(String player)
{
return player.equals(playerName);
return player.equals(thisplayer.getName());
}
public boolean getPartyChatOnlyToggle(){return partyChatOnly;}
public void togglePartyChatOnly(){partyChatOnly = !partyChatOnly;}
@ -918,8 +914,7 @@ public class PlayerProfile
}
public int getTamingInt(){
if(isInt(taming)){
int x = Integer.parseInt(taming);
return x;
return Integer.parseInt(taming);
} else{
return 0;
}
@ -1255,7 +1250,7 @@ public class PlayerProfile
public boolean isInt(String string){
try {
//int x = Integer.parseInt(string);
int x = Integer.parseInt(string);
}
catch(NumberFormatException nFE) {
return false;
@ -1448,7 +1443,7 @@ public class PlayerProfile
return 0;
}
}
public void addXpToSkill(int newvalue, String skillname){
public void addXpToSkill(int newvalue, String skillname, Player targetPlayer){
if(!isInt(tamingXP))
tamingXP = String.valueOf(0);
if(!isInt(miningXP))
@ -1506,20 +1501,20 @@ public class PlayerProfile
axesXP = String.valueOf(Integer.valueOf(axesXP)+newvalue);
}
if(skillname.toLowerCase().equals("all")){
tamingXP = String.valueOf(Integer.valueOf(tamingXP)+newvalue);
miningXP = String.valueOf(Integer.valueOf(miningXP)+newvalue);
woodCuttingXP = String.valueOf(Integer.valueOf(woodCuttingXP)+newvalue);
repairXP = String.valueOf(Integer.valueOf(repairXP)+newvalue);
herbalismXP = String.valueOf(Integer.valueOf(herbalismXP)+newvalue);
acrobaticsXP = String.valueOf(Integer.valueOf(acrobaticsXP)+newvalue);
swordsXP = String.valueOf(Integer.valueOf(swordsXP)+newvalue);
archeryXP = String.valueOf(Integer.valueOf(archeryXP)+newvalue);
unarmedXP = String.valueOf(Integer.valueOf(unarmedXP)+newvalue);
excavationXP = String.valueOf(Integer.valueOf(excavationXP)+newvalue);
axesXP = String.valueOf(Integer.valueOf(axesXP)+newvalue);
tamingXP = String.valueOf(getTamingXPInt()+newvalue);
miningXP = String.valueOf(getMiningXPInt()+newvalue);
woodCuttingXP = String.valueOf(getWoodCuttingXPInt()+newvalue);
repairXP = String.valueOf(getRepairXPInt()+newvalue);
herbalismXP = String.valueOf(getHerbalismXPInt()+newvalue);
acrobaticsXP = String.valueOf(getAcrobaticsXPInt()+newvalue);
swordsXP = String.valueOf(getSwordsXPInt()+newvalue);
archeryXP = String.valueOf(getArcheryXPInt()+newvalue);
unarmedXP = String.valueOf(getUnarmedXPInt()+newvalue);
excavationXP = String.valueOf(getExcavationXPInt()+newvalue);
axesXP = String.valueOf(getAxesXPInt()+newvalue);
}
save();
Skills.XpCheck(thisplayer);
Skills.XpCheck(targetPlayer);
}
public void modifyskill(int newvalue, String skillname){
if(skillname.toLowerCase().equals("taming")){
@ -1682,7 +1677,12 @@ public class PlayerProfile
return dead;
}
public Location getMySpawn(Player player){
Location loc = new Location(player.getWorld(),(Double.parseDouble(getX())), Double.parseDouble(getY()), Double.parseDouble(getZ()));
Location loc = null;
if(isDouble(getX()) && isDouble(getY()) && isDouble(getZ()))
loc = new Location(player.getWorld(),(Double.parseDouble(getX())), Double.parseDouble(getY()), Double.parseDouble(getZ()));
else
return null;
loc.setYaw(0);
loc.setPitch(0);
if(loc.getX() != 0 && loc.getY() != 0 && loc.getZ() != 0 && loc.getWorld() != null){

View File

@ -14,16 +14,28 @@ public class Tree {
public void add(String p, int in)
{
if(root == null)
if(root == null){
root = new TreeNode(p, in);
}
else
root.add(p,in);
}
public PlayerStat[] inOrder()
{
if(root != null){
ArrayList<PlayerStat> order = root.inOrder(new ArrayList<PlayerStat>());
return order.toArray(new PlayerStat[order.size()]);
} else {
//Throw some dummy info in case the users file is empty
//It's not a good fix but its better than rewriting the whole system
ArrayList<PlayerStat> x = new ArrayList<PlayerStat>();
PlayerStat y = new PlayerStat();
y.name = "$mcMMO_DummyInfo";
y.statVal = 0;
x.add(y);
return x.toArray(new PlayerStat[x.size()]);
}
}
}

View File

@ -348,13 +348,14 @@ public class m {
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;
int id = 0, theCount = 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)
//Check for things we don't want put in the DB
if(playerName == null || playerName.equals("null") || playerName.equals("#Storage place for user information"))
continue;
//Get Mining
@ -429,6 +430,7 @@ public class m {
*/
if(id > 0)
{
theCount++;
//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)
@ -462,6 +464,7 @@ public class m {
}
else
{
theCount++;
//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 + "'");
@ -503,6 +506,7 @@ public class m {
+" WHERE user_id = "+id);
}
}
System.out.println("[mcMMO] MySQL Updated from users file, "+theCount+" items added/updated to MySQL DB");
in.close();
} catch (Exception e) {
log.log(Level.SEVERE, "Exception while reading "
@ -517,8 +521,10 @@ public class m {
String percentage = String.valueOf((skillvalue / 1000) * 100);
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+"Wolves getting harmed");
player.sendMessage(ChatColor.GRAY+"**NOTE** Offensive skills are bugged due to a bukkit bug");
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---");
player.sendMessage(ChatColor.DARK_AQUA+"Beast Lore: "+ChatColor.YELLOW+ChatColor.GREEN+"Bone-whacking inspects wolves");
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+"Environmentally Aware: "+ChatColor.YELLOW+ChatColor.GREEN+"Cactus/Lava Phobia, Fall DMG Immune");
@ -869,8 +875,8 @@ public class m {
if(split[0].equalsIgnoreCase("/"+LoadProperties.mcmmo)){
event.setCancelled(true);
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"mMO"+ChatColor.RED+"[]-----");
player.sendMessage(ChatColor.YELLOW+"mMO is an RPG server mod for minecraft.");
player.sendMessage(ChatColor.YELLOW+"There are many skills added by mMO to minecraft.");
player.sendMessage(ChatColor.YELLOW+"mcMMO is an RPG server mod for minecraft.");
player.sendMessage(ChatColor.YELLOW+"There are many skills added by mcMMO to minecraft.");
player.sendMessage(ChatColor.YELLOW+"They can do anything from giving a chance");
player.sendMessage(ChatColor.YELLOW+"for double drops to letting you break materials instantly.");
player.sendMessage(ChatColor.YELLOW+"For example, by harvesting logs from trees you will gain");
@ -885,13 +891,13 @@ public class m {
player.sendMessage(ChatColor.YELLOW+"For example, if you hold a Mining Pick and right click");
player.sendMessage(ChatColor.YELLOW+"you will ready your Pickaxe, attack mining materials");
player.sendMessage(ChatColor.YELLOW+"and then "+ChatColor.RED+"Super Breaker "+ChatColor.YELLOW+"will activate.");
player.sendMessage(ChatColor.GREEN+"Find out mMO commands with "+ChatColor.DARK_AQUA+"/"+LoadProperties.mcc);
player.sendMessage(ChatColor.GREEN+"Find out mcMMO commands with "+ChatColor.DARK_AQUA+"/"+LoadProperties.mcc);
player.sendMessage(ChatColor.GREEN+"You can donate via paypal to"+ChatColor.DARK_RED+" nossr50@gmail.com");
}
if(split[0].equalsIgnoreCase("/"+LoadProperties.mcc)){
event.setCancelled(true);
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.YELLOW+"mMO Commands"+ChatColor.RED+"[]---");
player.sendMessage("/"+LoadProperties.stats+ChatColor.RED+" - View your mMO stats");
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.YELLOW+"mcMMO Commands"+ChatColor.RED+"[]---");
player.sendMessage("/"+LoadProperties.stats+ChatColor.RED+" - View your mcMMO stats");
if(mcPermissions.getInstance().party(player)){
player.sendMessage(ChatColor.GREEN+"--PARTY COMMANDS--");
player.sendMessage("/"+LoadProperties.party+" [party name] "+ChatColor.RED+"- Create/Join designated party");

View File

@ -53,14 +53,13 @@ public class mcMMO extends JavaPlugin {
public void onEnable() {
mcMMO_Timer.schedule(new mcTimer(this), (long)0, (long)(1000));
new File(maindirectory).mkdir();
//Check if props file exists, if not make it
mcProperties.makeProperties(Properties, log);
//Load the file
LoadProperties.loadMain();
Users.getInstance().loadUsers();
for(Player player : getServer().getOnlinePlayers()){
Users.addUser(player);
}
mcProperties.makeProperties(Properties, log); //Make Props file
LoadProperties.loadMain(); //Load Props file
Users.getInstance().loadUsers(); //Load Users file
for(Player player : getServer().getOnlinePlayers()){Users.addUser(player);} //In case of reload add all users back into PlayerProfile
/*
* REGISTER EVENTS
*/
PluginManager pm = getServer().getPluginManager();
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this);
@ -80,6 +79,7 @@ public class mcMMO extends JavaPlugin {
PluginDescriptionFile pdfFile = this.getDescription();
mcPermissions.initialize(getServer());
mcLoadMySQL();
if(LoadProperties.useMySQL)
database.createStructure(); //Make Structure
if(!LoadProperties.useMySQL)
Leaderboard.makeLeaderboards(); //Make the leaderboards
@ -124,7 +124,7 @@ public class mcMMO extends JavaPlugin {
}
public void addXp(Player player, String skillname, Integer newvalue){
PlayerProfile PP = Users.getProfile(player);
PP.addXpToSkill(newvalue, skillname);
PP.addXpToSkill(newvalue, skillname, player);
Skills.XpCheck(player);
}
public void modifySkill(Player player, String skillname, Integer newvalue){

View File

@ -77,8 +77,7 @@ public class mcPlayerListener extends PlayerListener {
return null;
}
public void onPlayerLogin(PlayerLoginEvent event) {
Player player = event.getPlayer();
Users.addUser(player);
Users.addUser(event.getPlayer());
}
public void onPlayerQuit(PlayerQuitEvent event) {
Users.removeUser(event.getPlayer());
@ -86,8 +85,8 @@ public class mcPlayerListener extends PlayerListener {
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if(mcPermissions.getInstance().motd(player)){
player.sendMessage(ChatColor.BLUE +"This server is running MMO "+plugin.getDescription().getVersion()+" type /"+ChatColor.YELLOW+LoadProperties.mcmmo+ChatColor.BLUE+ " for help.");
player.sendMessage(ChatColor.GREEN+"http://mmo.wikia.com"+ChatColor.BLUE+" - MMO Wiki");
player.sendMessage(ChatColor.BLUE +"This server is running mcMMO "+plugin.getDescription().getVersion()+" type /"+ChatColor.YELLOW+LoadProperties.mcmmo+ChatColor.BLUE+ " for help.");
player.sendMessage(ChatColor.GREEN+"http://mcmmo.wikia.com"+ChatColor.BLUE+" - mcMMO Wiki");
}
}
public void onPlayerInteract(PlayerInteractEvent event) {
@ -96,17 +95,6 @@ public class mcPlayerListener extends PlayerListener {
Action action = event.getAction();
Block block = event.getClickedBlock();
//Archery Nerf
if(action == Action.LEFT_CLICK_AIR)
{
if(player.getItemInHand().getTypeId() == 352)
{
Block targetBlock = player.getTargetBlock(null, 20);
player.sendMessage("Target Block TypeID = "+targetBlock.getTypeId());
player.sendMessage("Target Block Byte Data = "+targetBlock.getData());
player.sendMessage("Wold Entity List SIZE : "+targetBlock.getWorld().getEntities().size());
player.sendMessage("Chunk Entity List SIZE : "+targetBlock.getChunk().getEntities().length);
}
}
if(player.getItemInHand().getTypeId() == 261 && LoadProperties.archeryFireRateLimit){
if(System.currentTimeMillis() < PP.getArcheryShotATS() + 1000){
/*
@ -213,6 +201,10 @@ public class mcPlayerListener extends PlayerListener {
player.sendMessage("Type ID : "+player.getItemInHand().getTypeId());
player.sendMessage("Byte Data : "+player.getItemInHand().getDurability());
}
/*
* FFS -> MySQL
*/
if(split[0].equalsIgnoreCase("/mmoupdate") && mcPermissions.getInstance().admin(player))
{
event.setCancelled(true);
@ -225,6 +217,7 @@ public class mcPlayerListener extends PlayerListener {
}
player.sendMessage(ChatColor.GREEN+"Conversion finished!");
}
/*
* LEADER BOARD COMMAND
*/
@ -533,17 +526,15 @@ public class mcPlayerListener extends PlayerListener {
if(split.length == 4){
if(isPlayer(split[1]) && m.isInt(split[3]) && Skills.isSkill(split[2])){
int newvalue = Integer.valueOf(split[3]);
Users.getProfile(getPlayer(split[1])).addXpToSkill(newvalue, split[2]);
Users.getProfile(getPlayer(split[1])).addXpToSkill(newvalue, split[2], getPlayer(split[1]));
getPlayer(split[1]).sendMessage(ChatColor.GREEN+"Experience granted!");
player.sendMessage(ChatColor.RED+split[2]+" has been modified.");
}
}
else if(split.length == 3){
if(m.isInt(split[2]) && Skills.isSkill(split[1])){
else if(split.length == 3 && m.isInt(split[2]) && Skills.isSkill(split[1])){
int newvalue = Integer.valueOf(split[2]);
PP.addXpToSkill(newvalue, split[1]);
PP.addXpToSkill(newvalue, split[1], player);
player.sendMessage(ChatColor.RED+split[1]+" has been modified.");
}
} else {
player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.addxp+" playername skillname xp");
}

View File

@ -35,28 +35,29 @@ public class Repair {
/*
* DIAMOND ARMOR
*/
if(isDiamondArmor(is) && hasDiamond(player) && PP.getRepairInt() >= LoadProperties.repairdiamondlevel){
removeDiamond(player);
player.getItemInHand().setDurability(getArmorRepairAmount(is, player));
if(isDiamondArmor(is) && hasItem(player, 264) && PP.getRepairInt() >= LoadProperties.repairdiamondlevel){
removeItem(player, 264);
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
player.sendMessage(String.valueOf(durabilityBefore - durabilityAfter));
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 6); //Boost XP
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} else if (isIronArmor(is) && hasIron(player)){
}
else if (isIronArmor(is) && hasItem(player, 265)){
/*
* IRON ARMOR
*/
removeIron(player);
player.getItemInHand().setDurability(getArmorRepairAmount(is, player));
removeItem(player, 265);
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 2); //Boost XP
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
//GOLD ARMOR
} else if (isGoldArmor(is) && hasGold(player)){
removeGold(player);
player.getItemInHand().setDurability(getArmorRepairAmount(is, player));
} else if (isGoldArmor(is) && hasItem(player, 266)){
removeItem(player, 266);
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 4); //Boost XP of Gold to around Iron
@ -69,15 +70,48 @@ public class Repair {
* TOOLS
*/
if(isTools(is)){
/*
* IRON TOOLS
*/
if(isIronTools(is) && hasIron(player)){
removeIron(player);
if(isStoneTools(is) && hasItem(player, 4)){
removeItem(player, 4);
/*
* Repair Durability and calculate dif
*/
player.getItemInHand().setDurability(getToolRepairAmount(is, player));
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
//STONE NERF
dif = (short) (dif / 2);
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} else if(isWoodTools(is) && hasItem(player, 5)){
removeItem(player, 5);
/*
* Repair Durability and calculate dif
*/
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
//WOOD NERF
dif = (short) (dif / 2);
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} else if(isIronTools(is) && hasItem(player, 265)){
removeItem(player, 265);
/*
* Repair Durability and calculate dif
*/
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
@ -87,12 +121,12 @@ public class Repair {
if(m.isHoe(is))
dif = (short) (dif / 2);
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} else if (isDiamondTools(is) && hasDiamond(player) && PP.getRepairInt() >= LoadProperties.repairdiamondlevel){ //Check if its diamond and the player has diamonds
} else if (isDiamondTools(is) && hasItem(player, 264) && PP.getRepairInt() >= LoadProperties.repairdiamondlevel){ //Check if its diamond and the player has diamonds
/*
* DIAMOND TOOLS
*/
player.getItemInHand().setDurability(getToolRepairAmount(is, player));
removeDiamond(player);
player.getItemInHand().setDurability(getRepairAmount(is, player));
removeItem(player, 264);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
@ -102,9 +136,9 @@ public class Repair {
if(m.isHoe(is))
dif = (short) (dif / 2);
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} else if(isGoldTools(is) && hasGold(player)){
player.getItemInHand().setDurability(getToolRepairAmount(is, player));
removeGold(player);
} else if(isGoldTools(is) && hasItem(player, 266)){
player.getItemInHand().setDurability(getRepairAmount(is, player));
removeItem(player, 266);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 7.6); //Boost XP for Gold to that of around Iron
@ -165,13 +199,29 @@ public class Repair {
public static boolean isTools(ItemStack is){
if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292 || //IRON
is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293 || //DIAMOND
is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284) //GOLD
is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || //GOLD
is.getTypeId() == 268 || is.getTypeId() == 269 || is.getTypeId() == 270 || is.getTypeId() == 271 || //WOOD
is.getTypeId() == 272 || is.getTypeId() == 273 || is.getTypeId() == 274 || is.getTypeId() == 275) //STONE
{
return true;
} else {
return false;
}
}
public static boolean isStoneTools(ItemStack is){
if(is.getTypeId() == 272 || is.getTypeId() == 273 || is.getTypeId() == 274 || is.getTypeId() == 275){
return true;
} else {
return false;
}
}
public static boolean isWoodTools(ItemStack is){
if(is.getTypeId() == 268 || is.getTypeId() == 269 || is.getTypeId() == 270 || is.getTypeId() == 271){
return true;
} else {
return false;
}
}
public static boolean isGoldTools(ItemStack is){
if(is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || is.getTypeId() == 294){
return true;
@ -196,10 +246,10 @@ public class Repair {
return false;
}
}
public static void removeIron(Player player){
public static void removeItem(Player player, int typeid){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == 265){
if(x != null && x.getTypeId() == typeid){
if(x.getAmount() == 1){
x.setTypeId(0);
x.setAmount(0);
@ -212,60 +262,10 @@ public class Repair {
}
}
}
public static void removeGold(Player player){
public static boolean hasItem(Player player, int typeid){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == 266){
if(x.getAmount() == 1){
x.setTypeId(0);
x.setAmount(0);
player.getInventory().setContents(inventory);
} else{
x.setAmount(x.getAmount() - 1);
player.getInventory().setContents(inventory);
}
return;
}
}
}
public static void removeDiamond(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == 264){
if(x.getAmount() == 1){
x.setTypeId(0);
x.setAmount(0);
player.getInventory().setContents(inventory);
} else{
x.setAmount(x.getAmount() - 1);
player.getInventory().setContents(inventory);
}
return;
}
}
}
public static boolean hasGold(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == 266){
return true;
}
}
return false;
}
public static boolean hasDiamond(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == 264){
return true;
}
}
return false;
}
public static boolean hasIron(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == 265){
if(x != null && x.getTypeId() == typeid){
return true;
}
}
@ -285,11 +285,46 @@ public class Repair {
}
return durability;
}
public static short getToolRepairAmount(ItemStack is, Player player){
public static short getRepairAmount(ItemStack is, Player player){
short durability = is.getDurability();
short ramt = 0;
switch(is.getTypeId())
{
/*
* TOOLS
*/
//WOOD SWORD
case 268:
ramt = 30;
break;
//WOOD SHOVEL
case 269:
ramt = 60;
break;
//WOOD PICKAXE
case 270:
ramt = 20;
break;
//WOOD AXE
case 271:
ramt = 20;
break;
//STONE SWORD
case 272:
ramt = 44;
break;
//STONE SHOVEL
case 273:
ramt = 132;
break;
//STONE PICKAXE
case 274:
ramt = 44;
break;
//STONE AXE
case 275:
ramt = 44;
break;
//GOLD SHOVEL
case 284:
ramt = 33;
@ -350,15 +385,9 @@ public class Repair {
case 294:
ramt = 17;
break;
}
return repairCalculate(player, durability, ramt);
}
//This determines how much we repair
public static short getArmorRepairAmount(ItemStack is, Player player){
short durability = is.getDurability();
short ramt = 0;
switch(is.getTypeId())
{
/*
* ARMOR
*/
case 306:
ramt = 27;
break;
@ -396,27 +425,28 @@ public class Repair {
ramt = 20;
break;
}
if(durability < 0)
durability = 0;
return repairCalculate(player, durability, ramt);
}
public static void needMoreVespeneGas(ItemStack is, Player player){
PlayerProfile PP = Users.getProfile(player);
if ((isDiamondTools(is) || isDiamondArmor(is)) && PP.getRepairInt() < LoadProperties.repairdiamondlevel){
player.sendMessage(ChatColor.DARK_RED +"You're not adept enough to repair Diamond");
} else if (isDiamondTools(is) && !hasDiamond(player) || isIronTools(is) && !hasIron(player) || isGoldTools(is) && !hasGold(player)){
if(isDiamondTools(is) && !hasDiamond(player))
} else if (isDiamondTools(is) && !hasItem(player, 264) || isIronTools(is) && !hasItem(player, 265) || isGoldTools(is) && !hasItem(player, 266)){
if(isDiamondTools(is) && !hasItem(player, 264))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds");
if(isIronTools(is) && !hasIron(player))
if(isIronTools(is) && !hasItem(player, 265))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron");
//herp
if(isGoldTools(is) && !hasGold(player))
if(isGoldTools(is) && !hasItem(player, 266))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GOLD+"Gold");
} else if (isDiamondArmor(is) && !hasDiamond(player)){
if(isWoodTools(is) && !hasItem(player, 5))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.DARK_GREEN+"Wood");
if(isStoneTools(is) && !hasItem(player, 4))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+"Stone");
} else if (isDiamondArmor(is) && !hasItem(player, 264)){
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds");
} else if (isIronArmor(is) && !hasIron(player)){
} else if (isIronArmor(is) && !hasItem(player, 265)){
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron");
} else if (isGoldArmor(is) && !hasGold(player)){
} else if (isGoldArmor(is) && !hasItem(player, 266)){
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GOLD+"Gold");
} else if (is.getAmount() > 1)
player.sendMessage(ChatColor.DARK_RED+"You can't repair stacked items");

View File

@ -1,14 +1,8 @@
package com.gmail.nossr50.skills;
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;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -26,10 +20,7 @@ import com.gmail.nossr50.datatypes.PlayerStat;
public class Skills {
private static mcMMO plugin;
public Skills(mcMMO instance) {
plugin = instance;
}
private static volatile Skills instance;
protected static final Logger log = Logger.getLogger("Minecraft");
@ -359,7 +350,8 @@ public class Skills {
/*
* TAMING
*/
if(player != null && PP.getTamingXPInt() >= PP.getXpToLevel("taming")){
if(player != null){
if(PP.getTamingXPInt() >= PP.getXpToLevel("taming")){
int skillups = 0;
while(PP.getTamingXPInt() >= PP.getXpToLevel("taming")){
skillups++;
@ -370,16 +362,18 @@ public class Skills {
* Leaderboard updating stuff
*/
PlayerStat ps = new PlayerStat();
if(!LoadProperties.useMySQL){
ps.statVal = PP.getTamingInt();
ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "taming");
if(player != null && PP.getTaming() != null)
player.sendMessage(ChatColor.YELLOW+"Taming skill increased by "+skillups+"."+" Total ("+PP.getTaming()+")");
}
if(player != null && PP != null && PP.getTaming() != null)
player.sendMessage(ChatColor.YELLOW+"Taming skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getTaming()+")");
}
/*
* ACROBATICS
*/
if(player != null && PP.getAcrobaticsXPInt() >= PP.getXpToLevel("acrobatics")){
if(PP.getAcrobaticsXPInt() >= PP.getXpToLevel("acrobatics")){
int skillups = 0;
while(PP.getAcrobaticsXPInt() >= PP.getXpToLevel("acrobatics")){
skillups++;
@ -389,13 +383,15 @@ public class Skills {
/*
* Leaderboard updating stuff
*/
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat();
ps.statVal = PP.getAcrobaticsInt();
ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "acrobatics");
}
if(player != null && PP.getAcrobatics() != null)
player.sendMessage(ChatColor.YELLOW+"Acrobatics skill increased by "+skillups+"."+" Total ("+PP.getAcrobatics()+")");
if(player != null && PP != null && PP.getAcrobatics() != null)
player.sendMessage(ChatColor.YELLOW+"Acrobatics skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getAcrobatics()+")");
}
/*
* ARCHERY
@ -410,13 +406,14 @@ public class Skills {
/*
* Leaderboard updating stuff
*/
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat();
ps.statVal = PP.getArcheryInt();
ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "archery");
if(player != null && PP.getArchery() != null)
player.sendMessage(ChatColor.YELLOW+"Archery skill increased by "+skillups+"."+" Total ("+PP.getArchery()+")");
}
if(player != null && PP != null && PP.getArchery() != null)
player.sendMessage(ChatColor.YELLOW+"Archery skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getArchery()+")");
}
/*
* SWORDS
@ -431,13 +428,15 @@ public class Skills {
/*
* Leaderboard updating stuff
*/
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat();
ps.statVal = PP.getSwordsInt();
ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "swords");
}
if(player != null && PP.getSwords() != null)
player.sendMessage(ChatColor.YELLOW+"Swords skill increased by "+skillups+"."+" Total ("+PP.getSwords()+")");
if(player != null && PP != null && PP.getSwords() != null)
player.sendMessage(ChatColor.YELLOW+"Swords skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getSwords()+")");
}
/*
* AXES
@ -452,13 +451,14 @@ public class Skills {
/*
* Leaderboard updating stuff
*/
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat();
ps.statVal = PP.getAxesInt();
ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "axes");
if(player != null && PP.getAxes() != null)
player.sendMessage(ChatColor.YELLOW+"Axes skill increased by "+skillups+"."+" Total ("+PP.getAxes()+")");
}
if(player != null && PP != null && PP.getAxes() != null)
player.sendMessage(ChatColor.YELLOW+"Axes skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getAxes()+")");
}
/*
* UNARMED
@ -473,13 +473,14 @@ public class Skills {
/*
* Leaderboard updating stuff
*/
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat();
ps.statVal = PP.getUnarmedInt();
ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "unarmed");
if(player != null && PP.getUnarmed() != null)
player.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by "+skillups+"."+" Total ("+PP.getUnarmed()+")");
}
if(player != null && PP != null && PP.getUnarmed() != null)
player.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getUnarmed()+")");
}
/*
* HERBALISM
@ -494,13 +495,14 @@ public class Skills {
/*
* Leaderboard updating stuff
*/
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat();
ps.statVal = PP.getHerbalismInt();
ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "herbalism");
if(player != null && PP.getHerbalism() != null)
player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by "+skillups+"."+" Total ("+PP.getHerbalism()+")");
}
if(player != null && PP != null && PP.getHerbalism() != null)
player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getHerbalism()+")");
}
/*
* MINING
@ -515,13 +517,14 @@ public class Skills {
/*
* Leaderboard updating stuff
*/
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat();
ps.statVal = PP.getMiningInt();
ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "mining");
if(player != null && PP.getMining() != null)
player.sendMessage(ChatColor.YELLOW+"Mining skill increased by "+skillups+"."+" Total ("+PP.getMining()+")");
}
if(player != null && PP != null && PP.getMining() != null)
player.sendMessage(ChatColor.YELLOW+"Mining skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getMining()+")");
}
/*
* WOODCUTTING
@ -536,13 +539,14 @@ public class Skills {
/*
* Leaderboard updating stuff
*/
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat();
ps.statVal = PP.getWoodCuttingInt();
ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "woodcutting");
if(player != null && PP.getWoodCutting() != null)
player.sendMessage(ChatColor.YELLOW+"WoodCutting skill increased by "+skillups+"."+" Total ("+PP.getWoodCutting()+")");
}
if(player != null && PP != null && PP.getWoodCutting() != null)
player.sendMessage(ChatColor.YELLOW+"WoodCutting skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getWoodCutting()+")");
}
/*
* REPAIR
@ -557,13 +561,14 @@ public class Skills {
/*
* Leaderboard updating stuff
*/
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat();
ps.statVal = PP.getRepairInt();
ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "repair");
if(player != null && PP.getRepair() != null)
player.sendMessage(ChatColor.YELLOW+"Repair skill increased by "+skillups+"."+" Total ("+PP.getRepair()+")");
}
if(player != null && PP != null && PP.getRepair() != null)
player.sendMessage(ChatColor.YELLOW+"Repair skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getRepair()+")");
}
/*
* EXCAVATION
@ -578,22 +583,26 @@ public class Skills {
/*
* Leaderboard updating stuff
*/
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat();
ps.statVal = PP.getExcavationInt();
ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "excavation");
if(player != null && PP.getExcavation() != null)
player.sendMessage(ChatColor.YELLOW+"Excavation skill increased by "+skillups+"."+" Total ("+PP.getExcavation()+")");
}
if(player != null && PP != null && PP.getExcavation() != null)
player.sendMessage(ChatColor.YELLOW+"Excavation skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getExcavation()+")");
}
}
/*
* Leaderboard updating stuff
*/
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat();
ps.statVal = m.getPowerLevel(player);
ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "powerlevel");
}
}
public static boolean isSkill(String skillname){
skillname = skillname.toLowerCase();
if(skillname.equals("all")){

View File

@ -121,7 +121,7 @@ public class Swords {
{
Player defender = (Player)event.getEntity();
PlayerProfile PPd = Users.getProfile(defender);
if(m.isSwords(defender.getItemInHand())&& mcPermissions.getInstance().swords(defender))
if(m.isSwords(defender.getItemInHand()) && mcPermissions.getInstance().swords(defender))
{
if(PPd.getSwordsInt() >= 600)
{

View File

@ -1,3 +1,3 @@
name: mcMMO
main: com.gmail.nossr50.mcMMO
version: 1.0 WIP
version: 1.0