All changes up to 0.7.8

This commit is contained in:
nossr50 2011-02-24 06:30:42 -08:00
parent 0d208a6f1b
commit 35759ddf1f
5 changed files with 130 additions and 26 deletions

View File

@ -1,5 +1,13 @@
Changelog:
#Versions without changelogs probably had very small misc fixes, like tweaks to the source code#
Version 0.7.8
Massive tweaks to XP gain for Archery, Swords, Axes, Unarmed
Version 0.7.7
Minor tweak to how players are added to the flat file
Fixed some nullpointer exceptions when players die
Version 0.7.6
Fixed being able to repair diamond armor with below 50 skill
Myspawn now supports multiple worlds, clearing myspawn will set it to the first world created by the server
Version 0.7.5
Removed random checks for herbalism XP
Herbalism is now called properly (This should fix gaining no xp or double drops)

View File

@ -5,6 +5,8 @@ import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
@ -12,6 +14,7 @@ import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerItemEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.plugin.*;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
@ -27,11 +30,14 @@ public class mcPlayerListener extends PlayerListener {
}
public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
if(mcPermissions.getInstance().mySpawn(player)){
if(mcUsers.getProfile(player).getMySpawn(player) != null)
event.setRespawnLocation(mcUsers.getProfile(player).getMySpawn(player));
}
//HELLO CODE PEAKERS!
Location mySpawn = mcUsers.getProfile(player).getMySpawn(player);
if(mcUsers.getProfile(player).getMySpawnWorld() != null && !mcUsers.getProfile(player).getMySpawnWorld().equals("")){
mySpawn.setWorld(plugin.getServer().getWorld(mcUsers.getProfile(player).getMySpawnWorld()));
}
if(mcPermissions.getInstance().mySpawn(player)){
if(mcUsers.getProfile(player).getMySpawn(player) != null)
event.setRespawnLocation(mySpawn);
}
}
public Player[] getPlayersOnline() {
return plugin.getServer().getOnlinePlayers();
@ -114,10 +120,11 @@ public class mcPlayerListener extends PlayerListener {
*/
if(mcPermissions.getInstance().mySpawn(player) && split[0].equalsIgnoreCase("/"+mcLoadProperties.clearmyspawn)){
event.setCancelled(true);
double x = player.getWorld().getSpawnLocation().getX();
double y = player.getWorld().getSpawnLocation().getY();
double z = player.getWorld().getSpawnLocation().getZ();
mcUsers.getProfile(player).setMySpawn(x, y, z);
double x = plugin.getServer().getWorlds().get(0).getSpawnLocation().getX();
double y = plugin.getServer().getWorlds().get(0).getSpawnLocation().getY();
double z = plugin.getServer().getWorlds().get(0).getSpawnLocation().getZ();
String worldname = plugin.getServer().getWorlds().get(0).getName();
mcUsers.getProfile(player).setMySpawn(x, y, z, worldname);
player.sendMessage(ChatColor.DARK_AQUA+"Myspawn is now cleared.");
}
if(mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase("/"+mcLoadProperties.mmoedit)){
@ -248,7 +255,8 @@ public class mcPlayerListener extends PlayerListener {
double x = player.getLocation().getX();
double y = player.getLocation().getY();
double z = player.getLocation().getZ();
mcUsers.getProfile(player).setMySpawn(x, y, z);
String myspawnworld = player.getWorld().getName();
mcUsers.getProfile(player).setMySpawn(x, y, z, myspawnworld);
player.sendMessage(ChatColor.DARK_AQUA + "Myspawn has been set to your current location.");
}
/*
@ -405,6 +413,9 @@ public class mcPlayerListener extends PlayerListener {
player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.RED + "Off");
}
}
/*
* MYSPAWN
*/
if(split[0].equalsIgnoreCase("/"+mcLoadProperties.myspawn)){
if(!mcPermissions.getInstance().mySpawn(player)){
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions.");
@ -414,7 +425,20 @@ public class mcPlayerListener extends PlayerListener {
if(mcUsers.getProfile(player).getMySpawn(player) != null){
player.getInventory().clear();
player.setHealth(20);
player.teleportTo(mcUsers.getProfile(player).getMySpawn(player));
Location mySpawn = mcUsers.getProfile(player).getMySpawn(player);
//player.sendMessage("mcMMO DEBUG CODE 1");
if(mcUsers.getProfile(player).getMySpawnWorld() != null && !mcUsers.getProfile(player).getMySpawnWorld().equals("")){
mySpawn.setWorld(plugin.getServer().getWorld(mcUsers.getProfile(player).getMySpawnWorld()));
//player.sendMessage("mcMMO DEBUG CODE 2");
} else {
//player.sendMessage("mcMMO DEBUG CODE 5");
mySpawn.setWorld(plugin.getServer().getWorlds().get(0));
}
//player.sendMessage("mcMMO DEBUG CODE 3");
player.teleportTo(mySpawn);
player.teleportTo(mySpawn);
//Two lines of teleporting to prevent a bug when players try teleporting from one world to another bringing them to that worlds spawn at first.
//player.sendMessage("mcMMO DEBUG CODE 4");
player.sendMessage("Inventory cleared & health restored");
}else{
player.sendMessage(ChatColor.RED+"Configure your myspawn first with /setmyspawn");

View File

@ -153,9 +153,10 @@ class PlayerList
class PlayerProfile
{
protected final Logger log = Logger.getLogger("Minecraft");
private String playerName, gather, wgather, woodcutting, repair, mining, party, myspawn, unarmed, herbalism, excavation,
private String playerName, gather, wgather, woodcutting, repair, mining, party, myspawn, myspawnworld, unarmed, herbalism, excavation,
archery, swords, axes, invite, acrobatics, repairgather, unarmedgather, herbalismgather, excavationgather, archerygather, swordsgather, axesgather, acrobaticsgather;
private boolean dead;
Player thisplayer;
char defaultColor;
String location = "mcmmo.users";
@ -172,8 +173,10 @@ class PlayerList
{
//Declare things
playerName = player.getName();
thisplayer = player;
party = new String();
myspawn = new String();
myspawnworld = new String();
mining = new String();
repair = new String();
repairgather = new String();
@ -285,6 +288,8 @@ class PlayerList
axesgather = character[21];
if(character.length > 22)
acrobaticsgather = character[22];
if(character.length > 23)
myspawnworld = character[23];
in.close();
return true;
}
@ -346,6 +351,7 @@ class PlayerList
writer.append(swordsgather+":");
writer.append(axesgather+":");
writer.append(acrobaticsgather+":");
writer.append(myspawnworld+":");
writer.append("\r\n");
}
}
@ -389,6 +395,7 @@ class PlayerList
out.append(0+":"); //swordsgather
out.append(0+":"); //axesgather
out.append(0+":"); //acrobaticsgather
out.append(thisplayer.getWorld().getName());
//Add more in the same format as the line above
out.newLine();
@ -1170,9 +1177,13 @@ class PlayerList
return false;
}
}
public String getMySpawnWorld(){
return myspawnworld;
}
//Save a users spawn location
public void setMySpawn(double x, double y, double z){
public void setMySpawn(double x, double y, double z, String myspawnworldlocation){
myspawn = x+","+y+","+z;
myspawnworld = myspawnworldlocation;
save();
}
public String getX(){
@ -1198,7 +1209,7 @@ class PlayerList
return dead;
}
public Location getMySpawn(Player player){
Location loc = player.getLocation();
Location loc = player.getWorld().getSpawnLocation();
if(isDouble(getX()) && isDouble(getY()) && isDouble(getX())){
loc.setX(Double.parseDouble(mcUsers.getProfile(player).getX()));
loc.setY(Double.parseDouble(mcUsers.getProfile(player).getY()));

View File

@ -11,6 +11,7 @@ import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Pig;
import org.bukkit.entity.PigZombie;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Spider;
@ -132,8 +133,16 @@ public class mcm {
if(defender.getHealth() <= 0)
mcm.getInstance().simulateNaturalDrops(defender);
//XP
if(Math.random() * 10 > 7){
mcUsers.getProfile(attacker).addArcheryGather(1);
if(x instanceof Creeper)
mcUsers.getProfile(attacker).addArcheryGather(10);
if(x instanceof Spider)
mcUsers.getProfile(attacker).addArcheryGather(7);
if(x instanceof Skeleton)
mcUsers.getProfile(attacker).addArcheryGather(5);
if(x instanceof Zombie)
mcUsers.getProfile(attacker).addArcheryGather(3);
if(x instanceof PigZombie)
mcUsers.getProfile(attacker).addArcheryGather(7);
if(mcUsers.getProfile(attacker).getArcheryGatherInt() >= (mcUsers.getProfile(attacker).getArcheryInt() + 5) * mcLoadProperties.xpmodifier){
int skillups = 0;
while(mcUsers.getProfile(attacker).getArcheryGatherInt() >= (mcUsers.getProfile(attacker).getArcheryInt() +5) * mcLoadProperties.xpmodifier){
@ -144,7 +153,6 @@ public class mcm {
attacker.sendMessage(ChatColor.YELLOW+"Archery skill increased by "+skillups+"."+" Total ("+mcUsers.getProfile(attacker).getArchery()+")");
}
}
}
/*
* Defender is Animals
*/
@ -945,7 +953,16 @@ public class mcm {
if(isSwords(attacker.getItemInHand())
&& defender.getHealth() > 0
&& mcPermissions.getInstance().swords(attacker)){
mcUsers.getProfile(attacker).addSwordsGather(1);
if(x instanceof Creeper)
mcUsers.getProfile(attacker).addSwordsGather(10);
if(x instanceof Spider)
mcUsers.getProfile(attacker).addSwordsGather(7);
if(x instanceof Skeleton)
mcUsers.getProfile(attacker).addSwordsGather(5);
if(x instanceof Zombie)
mcUsers.getProfile(attacker).addSwordsGather(3);
if(x instanceof PigZombie)
mcUsers.getProfile(attacker).addSwordsGather(7);
if(mcUsers.getProfile(attacker).getSwordsGatherInt() >= (mcUsers.getProfile(attacker).getSwordsInt() + 5) * mcLoadProperties.xpmodifier){
int skillups = 0;
while(mcUsers.getProfile(attacker).getSwordsGatherInt() >= (mcUsers.getProfile(attacker).getSwordsInt() +5) * mcLoadProperties.xpmodifier){
@ -959,7 +976,17 @@ public class mcm {
if(isAxes(attacker.getItemInHand())
&& defender.getHealth() > 0
&& mcPermissions.getInstance().axes(attacker)){
mcUsers.getProfile(attacker).addAxesGather(1);
mcUsers.getProfile(attacker).addAxesGather(1);
if(x instanceof Creeper)
mcUsers.getProfile(attacker).addAxesGather(10);
if(x instanceof Spider)
mcUsers.getProfile(attacker).addAxesGather(7);
if(x instanceof Skeleton)
mcUsers.getProfile(attacker).addAxesGather(5);
if(x instanceof Zombie)
mcUsers.getProfile(attacker).addAxesGather(3);
if(x instanceof PigZombie)
mcUsers.getProfile(attacker).addAxesGather(7);
if(mcUsers.getProfile(attacker).getAxesGatherInt() >= (mcUsers.getProfile(attacker).getAxesInt() + 5) * mcLoadProperties.xpmodifier){
int skillups = 0;
while(mcUsers.getProfile(attacker).getAxesGatherInt() >= (mcUsers.getProfile(attacker).getAxesInt() +5) * mcLoadProperties.xpmodifier){
@ -1003,7 +1030,16 @@ public class mcm {
defender.setHealth(calculateDamage(defender, 8));
}
//XP
mcUsers.getProfile(attacker).addUnarmedGather(1);
if(x instanceof Creeper)
mcUsers.getProfile(attacker).addUnarmedGather(20);
if(x instanceof Spider)
mcUsers.getProfile(attacker).addUnarmedGather(15);
if(x instanceof Skeleton)
mcUsers.getProfile(attacker).addUnarmedGather(10);
if(x instanceof Zombie)
mcUsers.getProfile(attacker).addUnarmedGather(5);
if(x instanceof PigZombie)
mcUsers.getProfile(attacker).addUnarmedGather(15);
if(mcUsers.getProfile(attacker).getUnarmedGatherInt() >= (mcUsers.getProfile(attacker).getUnarmedInt() + 5) * mcLoadProperties.xpmodifier){
int skillups = 0;
while(mcUsers.getProfile(attacker).getUnarmedGatherInt() >= (mcUsers.getProfile(attacker).getUnarmedInt() +5) * mcLoadProperties.xpmodifier){
@ -1453,11 +1489,17 @@ public class mcm {
* ARMOR
*/
if(mcm.getInstance().isArmor(is) && block.getTypeId() == 42){
if(mcm.getInstance().isDiamondArmor(is) && mcm.getInstance().hasDiamond(player)){
/*
* DIAMOND ARMOR
*/
if(mcm.getInstance().isDiamondArmor(is) && mcm.getInstance().hasDiamond(player) && mcUsers.getProfile(player).getRepairInt() >= 50){
mcm.getInstance().removeDiamond(player);
player.getItemInHand().setDurability(mcm.getInstance().getArmorRepairAmount(is, player));
mcUsers.getProfile(player).addRepairGather(20);
} else if (mcm.getInstance().isIronArmor(is) && mcm.getInstance().hasIron(player)){
/*
* IRON ARMOR
*/
mcm.getInstance().removeIron(player);
player.getItemInHand().setDurability(mcm.getInstance().getArmorRepairAmount(is, player));
/*
@ -1472,11 +1514,17 @@ public class mcm {
* TOOLS
*/
if(mcm.getInstance().isTools(is) && block.getTypeId() == 42){
/*
* IRON TOOLS
*/
if(mcm.getInstance().isIronTools(is) && mcm.getInstance().hasIron(player)){
is.setDurability(mcm.getInstance().getToolRepairAmount(is, durability, player));
mcm.getInstance().removeIron(player);
mcUsers.getProfile(player).addRepairGather(5);
} else if (mcm.getInstance().isDiamondTools(is) && mcm.getInstance().hasDiamond(player) && mcUsers.getProfile(player).getRepairInt() >= 50){ //Check if its diamond and the player has diamonds
/*
* DIAMOND TOOLS
*/
is.setDurability(mcm.getInstance().getToolRepairAmount(is, durability, player));
mcm.getInstance().removeDiamond(player);
mcUsers.getProfile(player).addRepairGather(20);
@ -1512,7 +1560,7 @@ public class mcm {
if(type == 59 && block.getData() == (byte) 0x7){
mat = Material.getMaterial(296);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
mcUsers.getProfile(player).addHerbalismGather(3);
mcUsers.getProfile(player).addHerbalismGather(5);
if(mcUsers.getProfile(player).getHerbalismInt() >= 50 && mcUsers.getProfile(player).getHerbalismInt() < 150){
if(Math.random() * 10 > 8)
loc.getWorld().dropItemNaturally(loc, is);
@ -1536,10 +1584,10 @@ public class mcm {
if(!mcConfig.getInstance().isBlockWatched(block)){
//player.sendMessage("DEBUG CODE 2");
if(type == 39 || type == 40){
mcUsers.getProfile(player).addHerbalismGather(20);
mcUsers.getProfile(player).addHerbalismGather(10);
}
if(type == 37 || type == 38){
mcUsers.getProfile(player).addHerbalismGather(2);
mcUsers.getProfile(player).addHerbalismGather(3);
}
}
if(mcUsers.getProfile(player).getHerbalismGatherInt() >= (mcUsers.getProfile(player).getHerbalismInt() + 5) * mcLoadProperties.xpmodifier){
@ -1560,12 +1608,14 @@ public class mcm {
if(type == 2 && mcUsers.getProfile(player).getExcavationInt() > 250){
//CHANCE TO GET EGGS
if(mcLoadProperties.eggs == true && Math.random() * 100 > 99){
mcUsers.getProfile(player).addExcavationGather(10);
mat = Material.getMaterial(344);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
}
//CHANCE TO GET APPLES
if(mcLoadProperties.apples == true && Math.random() * 100 > 99){
mcUsers.getProfile(player).addExcavationGather(10);
mat = Material.getMaterial(260);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
@ -1573,10 +1623,11 @@ public class mcm {
}
//DIRT SAND OR GRAVEL
if(type == 3 || type == 13 || type == 2 || type == 12){
mcUsers.getProfile(player).addExcavationGather(2);
mcUsers.getProfile(player).addExcavationGather(3);
if(mcUsers.getProfile(player).getExcavationInt() > 750){
//CHANCE TO GET CAKE
if(mcLoadProperties.cake == true && Math.random() * 2000 > 1999){
mcUsers.getProfile(player).addExcavationGather(300);
mat = Material.getMaterial(354);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
@ -1585,6 +1636,7 @@ public class mcm {
if(mcUsers.getProfile(player).getExcavationInt() > 150){
//CHANCE TO GET MUSIC
if(mcLoadProperties.music == true && Math.random() * 2000 > 1999){
mcUsers.getProfile(player).addExcavationGather(300);
mat = Material.getMaterial(2256);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
@ -1594,6 +1646,7 @@ public class mcm {
if(mcUsers.getProfile(player).getExcavationInt() > 350){
//CHANCE TO GET DIAMOND
if(mcLoadProperties.diamond == true && Math.random() * 500 > 499){
mcUsers.getProfile(player).addExcavationGather(100);
mat = Material.getMaterial(264);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
@ -1602,6 +1655,7 @@ public class mcm {
if(mcUsers.getProfile(player).getExcavationInt() > 250){
//CHANCE TO GET MUSIC
if(mcLoadProperties.music == true && Math.random() * 2000 > 1999){
mcUsers.getProfile(player).addExcavationGather(300);
mat = Material.getMaterial(2257);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
@ -1612,18 +1666,21 @@ public class mcm {
if(type == 12){
//CHANCE TO GET GLOWSTONE
if(mcLoadProperties.glowstone == true && mcUsers.getProfile(player).getExcavationInt() > 50 && Math.random() * 100 > 95){
mcUsers.getProfile(player).addExcavationGather(3);
mat = Material.getMaterial(348);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
}
//CHANCE TO GET SLOWSAND
if(mcLoadProperties.slowsand == true && mcUsers.getProfile(player).getExcavationInt() > 650 && Math.random() * 200 > 199){
mcUsers.getProfile(player).addExcavationGather(5);
mat = Material.getMaterial(88);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
}
//CHANCE TO GET DIAMOND
if(mcLoadProperties.diamond == true && mcUsers.getProfile(player).getExcavationInt() > 500 && Math.random() * 500 > 499){
mcUsers.getProfile(player).addExcavationGather(100);
mat = Material.getMaterial(264);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
@ -1633,6 +1690,7 @@ public class mcm {
if((type == 2 || type == 3) && mcUsers.getProfile(player).getExcavationInt() > 25){
//CHANCE TO GET GLOWSTONE
if(mcLoadProperties.glowstone == true && Math.random() * 100 > 95){
mcUsers.getProfile(player).addExcavationGather(5);
mat = Material.getMaterial(348);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
@ -1642,6 +1700,7 @@ public class mcm {
if(type == 13){
//CHANCE TO GET NETHERRACK
if(mcLoadProperties.netherrack == true && mcUsers.getProfile(player).getExcavationInt() > 850 && Math.random() * 200 > 199){
mcUsers.getProfile(player).addExcavationGather(3);
mat = Material.getMaterial(87);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
@ -1649,6 +1708,7 @@ public class mcm {
//CHANCE TO GET SULPHUR
if(mcLoadProperties.sulphur == true && mcUsers.getProfile(player).getExcavationInt() > 75){
if(Math.random() * 10 > 9){
mcUsers.getProfile(player).addExcavationGather(3);
mat = Material.getMaterial(289);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
@ -1657,6 +1717,7 @@ public class mcm {
//CHANCE TO GET BONES
if(mcLoadProperties.bones == true && mcUsers.getProfile(player).getExcavationInt() > 175){
if(Math.random() * 10 > 6){
mcUsers.getProfile(player).addExcavationGather(3);
mat = Material.getMaterial(352);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);

View File

@ -1,3 +1,3 @@
name: mcMMO
main: com.gmail.nossr50.mcMMO
version: 0.7.5
version: 0.7.8