1.0.07 WIP

This commit is contained in:
nossr50 2011-05-03 23:24:08 -07:00
parent 139f50c5d1
commit e8049597a5
15 changed files with 266 additions and 78 deletions

View File

@ -1,5 +1,16 @@
Changelog:
#Versions without changelogs probably had very small misc fixes, like tweaks to the source code
Version 1.0.07
Leaderboards ignore players with the respective stat at 0
Reconnecting to MySQL will reload player data
Fixed a NPE with MySQL's Leaderboards
Removed "Loop iteration" debug message from mcMMO
Version 1.0.06
MySQL will attempt to reconnect if the connection is closed
Breaking the bottom block of Cactus/Reeds will award the correct experience and double drops
Added support for Minecraft Statistics
Fixed NPE with /myspawn command
Version 1.0.05
PVP interactions now check for permissions before handing out any experience

View File

@ -18,9 +18,11 @@ import com.gmail.nossr50.config.LoadProperties;
public class Database {
private Connection conn;
private mcMMO plugin;
public Database() {
public Database(mcMMO instance)
{
plugin = instance;
// Load the driver instance
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
@ -92,20 +94,66 @@ public class Database {
"`world` varchar(50) NOT NULL DEFAULT ''," +
"PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
}
// write query
public boolean Write(String sql) {
try {
PreparedStatement stmt = null;
stmt = this.conn.prepareStatement(sql);
stmt.executeUpdate();
return true;
} catch(SQLException ex) {
// check if its closed
private void reconnect()
{
System.out.println("[mcMMO] Reconnecting to MySQL...");
try
{
conn = DriverManager.getConnection("jdbc:mysql://" + LoadProperties.MySQLserverName + ":" + LoadProperties.MySQLport + "/" + LoadProperties.MySQLdbName + "?user=" + LoadProperties.MySQLuserName + "&password=" + LoadProperties.MySQLdbPass);
System.out.println("[mcMMO] Connection success!");
} catch (SQLException ex)
{
System.out.println("[mcMMO] Connection to MySQL failed! Check status of MySQL server!");
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
return false;
}
try {
if(conn.isValid(5)){
Users.clearUsers();
for(Player x : plugin.getServer().getOnlinePlayers())
{
Users.addUser(x);
}
}
} catch (SQLException e) {
//Herp
}
}
// write query
public boolean Write(String sql)
{
/*
* Double check connection to MySQL
*/
try
{
if(!conn.isValid(5))
{
reconnect();
}
} catch (SQLException e)
{
e.printStackTrace();
}
try
{
PreparedStatement stmt = null;
stmt = this.conn.prepareStatement(sql);
stmt.executeUpdate();
return true;
} catch(SQLException ex) {
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
return false;
}
}
// Get Int
// only return first row / first field
@ -114,6 +162,20 @@ public class Database {
ResultSet rs = null;
Integer result = 0;
/*
* Double check connection to MySQL
*/
try
{
if(!conn.isValid(5))
{
reconnect();
}
} catch (SQLException e)
{
e.printStackTrace();
}
try {
stmt = this.conn.prepareStatement(sql);
if (stmt.executeQuery() != null) {
@ -136,6 +198,20 @@ public class Database {
// read query
public HashMap<Integer, ArrayList<String>> Read(String sql) {
/*
* Double check connection to MySQL
*/
try
{
if(!conn.isValid(5))
{
reconnect();
}
} catch (SQLException e)
{
e.printStackTrace();
}
PreparedStatement stmt = null;
ResultSet rs = null;
HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>();

View File

@ -144,14 +144,17 @@ public class Leaderboard {
//HERP
BufferedReader in = new BufferedReader(file);
StringBuilder writer = new StringBuilder();
String line = "";
for(PlayerStat p : ps)
{
if(p.name.equals("$mcMMO_DummyInfo"))
continue;
if(p.statVal == 0)
continue;
writer.append(p.name + ":" + p.statVal);
writer.append("\r\n");
}
in.close();
//Write the new file
FileWriter out = new FileWriter(theLocation);

View File

@ -3,7 +3,7 @@ package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
public class LoadProperties {
public static Boolean enableCobbleToMossy, useMySQL, cocoabeans, archeryFireRateLimit, mushrooms, toolsLoseDurabilityFromAbilities, pvpxp, miningrequirespickaxe, woodcuttingrequiresaxe, pvp, eggs, apples, myspawnclearsinventory, 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 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;

View File

@ -47,7 +47,8 @@ public class PlayerProfile
public PlayerProfile(Player player)
{
thisplayer = player;
if (LoadProperties.useMySQL) {
if (LoadProperties.useMySQL)
{
if(!loadMySQL(player)) {
addMySQLPlayer(player);
loadMySQL(player);//This is probably not needed anymore, could just delete
@ -82,6 +83,7 @@ public class PlayerProfile
myspawnworld = spawn.get(1).get(0);
myspawn = spawn.get(1).get(1) + "," + spawn.get(1).get(2) + "," + spawn.get(1).get(3);
HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.Read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes FROM "+LoadProperties.MySQLtablePrefix+"cooldowns WHERE user_id = " + id);
/*
* I'm still learning MySQL, this is a fix for adding a new table
* its not pretty but it works

View File

@ -619,7 +619,7 @@ public class m {
player.sendMessage(ChatColor.RED+"Chance to Daze: "+ChatColor.YELLOW+percentagedaze+"%");
player.sendMessage(ChatColor.RED+"Chance to Retrieve Arrows: "+ChatColor.YELLOW+percentage+"%");
player.sendMessage(ChatColor.RED+"Length of Ignition: "+ChatColor.YELLOW+(ignition / 20)+" seconds");
player.sendMessage(ChatColor.RED+"Damage+ (Rank"+rank+"): Bonus "+rank+" damage");
player.sendMessage(ChatColor.RED+"Damage+ (Rank"+rank+"):"+ChatColor.YELLOW+" Bonus "+rank+" damage");
}
if(split[0].equalsIgnoreCase("/axes")){
event.setCancelled(true);
@ -851,12 +851,13 @@ public class m {
player.sendMessage(ChatColor.DARK_AQUA+"Double Drops (All Herbs): "+ChatColor.GREEN+"Double the normal loot");
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"YOUR STATS"+ChatColor.RED+"[]---");
player.sendMessage(ChatColor.RED+"Green Terra Length: "+ChatColor.YELLOW+ticks+"s");
player.sendMessage(ChatColor.RED+"Green Thumb Chance: "+gpercentage+"%");
player.sendMessage(ChatColor.RED+"Green Thumb Stage: Wheat grows in stage "+bonus);
player.sendMessage(ChatColor.RED+"Double Drop Chance: "+percentage+"%");
player.sendMessage(ChatColor.RED+"Food+ (Rank"+rank+"): Bonus "+rank+" healing");
player.sendMessage(ChatColor.RED+"Green Thumb Chance: "+ChatColor.YELLOW+gpercentage+"%");
player.sendMessage(ChatColor.RED+"Green Thumb Stage: "+ChatColor.YELLOW+"Wheat grows in stage "+bonus);
player.sendMessage(ChatColor.RED+"Double Drop Chance: "+ChatColor.YELLOW+percentage+"%");
player.sendMessage(ChatColor.RED+"Food+ (Rank"+rank+"): "+ChatColor.YELLOW+"Bonus "+rank+" healing");
}
if(split[0].equalsIgnoreCase("/excavation")){
if(split[0].equalsIgnoreCase("/excavation"))
{
event.setCancelled(true);
int ticks = 2;
int x = PP.getExcavationInt();

View File

@ -5,6 +5,7 @@ import org.bukkit.ChatColor;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -155,6 +156,8 @@ public class mcBlockListener extends BlockListener {
if(Math.random() * 10 > 9)
blockx.getLocation().getWorld().dropItemNaturally(blockx.getLocation(), item);
}
if(blockx.getType() != Material.AIR)
player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType());
blockx.setType(Material.AIR);
}
}
@ -233,6 +236,7 @@ public class mcBlockListener extends BlockListener {
byte type = block.getData();
ItemStack item = new ItemStack(mat, 1, (byte)0, type);
block.setType(Material.AIR);
player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType());
if(LoadProperties.toolsLoseDurabilityFromAbilities)
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
@ -251,6 +255,7 @@ public class mcBlockListener extends BlockListener {
mat = Material.SNOW_BALL;
byte type = block.getData();
ItemStack item = new ItemStack(mat, 1, (byte)0, type);
player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType());
block.setType(Material.AIR);
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
}
@ -282,6 +287,7 @@ public class mcBlockListener extends BlockListener {
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), x);
}
block.setType(Material.AIR);
player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType());
}
}

View File

@ -62,7 +62,8 @@ public class mcEntityListener extends EntityListener {
/*
* CHECK FOR INVULNERABILITY
*/
if(event.getEntity() instanceof Player){
if(event.getEntity() instanceof Player)
{
Player defender = (Player)event.getEntity();
PlayerProfile PPd = Users.getProfile(defender);
if(defender != null && Config.getInstance().isGodModeToggled(defender.getName()))
@ -71,7 +72,8 @@ public class mcEntityListener extends EntityListener {
Users.addUser(defender);
}
if(event.getEntity() instanceof CraftEntity){
if(event.getEntity() instanceof CraftEntity)
{
CraftEntity cEntity = (CraftEntity)event.getEntity();
if(cEntity.getHandle() instanceof EntityLiving)
{

View File

@ -50,14 +50,18 @@ public class mcMMO extends JavaPlugin {
private Timer mcMMO_Timer = new Timer(true);
public static Database database = null;
public void onEnable() {
public void onEnable()
{
new File(maindirectory).mkdir();
mcProperties.makeProperties(Properties, log); //Make Props file
LoadProperties.loadMain(); //Load Props file
Users.getInstance().loadUsers(); //Load Users file
/*
* 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);
@ -82,14 +86,15 @@ public class mcMMO extends JavaPlugin {
if(!LoadProperties.useMySQL)
Leaderboard.makeLeaderboards(); //Make the leaderboards
for(Player player : getServer().getOnlinePlayers()){Users.addUser(player);} //In case of reload add all users back into PlayerProfile
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
mcMMO_Timer.schedule(new mcTimer(this), (long)0, (long)(1000));
}
private void mcLoadMySQL() {
public void mcLoadMySQL()
{
if (LoadProperties.useMySQL) {
// create database object
database = new Database();
database = new Database(this);
}
}
@ -177,4 +182,4 @@ public class mcMMO extends JavaPlugin {
public void onDisable() {
System.out.println("mcMMO was disabled.");
}
}
}

View File

@ -313,6 +313,7 @@ public class mcPlayerListener extends PlayerListener {
* MYSQL LEADERBOARDS
*/
{
String powerlevel = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics";
if(split.length >= 2 && Skills.isSkill(split[1]))
{
/*
@ -336,12 +337,12 @@ public class mcPlayerListener extends PlayerListener {
}
//If a page number is specified
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.Read("SELECT "+lowercase+", user_id FROM "
+LoadProperties.MySQLtablePrefix+"skills ORDER BY `"+LoadProperties.MySQLtablePrefix+"skills`.`"+lowercase+"` DESC ");
+LoadProperties.MySQLtablePrefix+"skills WHERE "+lowercase+" > 0 ORDER BY `"+LoadProperties.MySQLtablePrefix+"skills`.`"+lowercase+"` DESC ");
for(int i=n;i<=n+10;i++)
{
if (i > userslist.size())
break;
if (i > userslist.size() || mcMMO.database.Read("SELECT user FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
break;
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));
}
@ -349,10 +350,10 @@ public class mcPlayerListener extends PlayerListener {
}
//If no page number is specified
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.Read("SELECT "+lowercase+", user_id FROM "
+LoadProperties.MySQLtablePrefix+"skills ORDER BY `"+LoadProperties.MySQLtablePrefix+"skills`.`"+lowercase+"` DESC ");
+LoadProperties.MySQLtablePrefix+"skills WHERE "+lowercase+" > 0 ORDER BY `"+LoadProperties.MySQLtablePrefix+"skills`.`"+lowercase+"` DESC ");
for(int i=1;i<=10;i++) //i<=userslist.size()
{
if (i > userslist.size())
if (i > userslist.size() || mcMMO.database.Read("SELECT user FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
break;
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));
@ -373,22 +374,22 @@ public class mcPlayerListener extends PlayerListener {
n = n * (n2-1);
}
//If a page number is specified
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.Read("SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics, user_id FROM "
+LoadProperties.MySQLtablePrefix+"skills ORDER BY taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics DESC ");
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.Read("SELECT "+powerlevel+", user_id FROM "
+LoadProperties.MySQLtablePrefix+"skills WHERE "+powerlevel+" > 0 ORDER BY taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics DESC ");
for(int i=n;i<=n+10;i++)
{
if (i > userslist.size())
break;
if (i > userslist.size() || mcMMO.database.Read("SELECT user FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
break;
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));
}
return;
}
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.Read("SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics, user_id FROM "
+LoadProperties.MySQLtablePrefix+"skills ORDER BY taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics DESC ");
+LoadProperties.MySQLtablePrefix+"skills WHERE "+powerlevel+" > 0 ORDER BY taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics DESC ");
for(int i=1;i<=10;i++)
{
if (i > userslist.size())
if (i > userslist.size() || mcMMO.database.Read("SELECT user FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
break;
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));
@ -836,13 +837,8 @@ public class mcPlayerListener extends PlayerListener {
//player.sendMessage("MMO DEBUG CODE 5");
mySpawn.setWorld(plugin.getServer().getWorlds().get(0));
}
//player.sendMessage("MMO DEBUG CODE 3");
player.teleportTo(mySpawn); //It's done twice because teleporting from one world to another is weird
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("MMO DEBUG CODE 4");
if(LoadProperties.myspawnclearsinventory)
player.sendMessage("Traveled to your MySpawn");
} else {
player.sendMessage(ChatColor.RED+"Configure your myspawn first with a bed.");
}

View File

@ -20,7 +20,8 @@ public class mcTimer extends TimerTask{
public void run() {
Player[] playerlist = plugin.getServer().getOnlinePlayers();
for(Player player : playerlist){
for(Player player : playerlist)
{
PlayerProfile PP = Users.getProfile(player);
if(player == null)
continue;
@ -38,12 +39,13 @@ public class mcTimer extends TimerTask{
/*
* PLAYER BLEED MONITORING
*/
if(thecount % 2 == 0 && player != null && PP != null && PP.getBleedTicks() >= 1){
if(thecount % 2 == 0 && PP != null && PP.getBleedTicks() >= 1){
player.damage(2);
PP.decreaseBleedTicks();
}
if(mcPermissions.getInstance().regeneration(player) && PP != null && System.currentTimeMillis() >= PP.getRecentlyHurt() + 60000){
if(mcPermissions.getInstance().regeneration(player) && PP != null && System.currentTimeMillis() >= PP.getRecentlyHurt() + 60000)
{
if(thecount == 10 || thecount == 20 || thecount == 30 || thecount == 40){
if(player != null &&
player.getHealth() > 0 && player.getHealth() < 20
@ -75,9 +77,11 @@ public class mcTimer extends TimerTask{
if(thecount % 2 == 0)
Swords.bleedSimulate();
if(thecount < 40){
if(thecount < 40)
{
thecount++;
} else {
} else
{
thecount = 1;
}
}

View File

@ -165,25 +165,80 @@ public class Herbalism {
if(block.getData() != (byte) 5){
//Cactus
if(type == 81){
mat = Material.getMaterial(block.getTypeId());
is = new ItemStack(mat, 1, (byte)0, (byte)0);
if(player != null){
if(Math.random() * 1000 <= PP.getHerbalismInt()){
loc.getWorld().dropItemNaturally(loc, is);
}
//Setup the loop
World world = block.getWorld();
Block[] blockArray = new Block[3];
blockArray[0] = block;
blockArray[1] = world.getBlockAt(block.getX(), block.getY()+1, block.getZ());
blockArray[2] = world.getBlockAt(block.getX(), block.getY()+2, block.getZ());
Material[] materialArray = new Material[3];
materialArray[0] = blockArray[0].getType();
materialArray[1] = blockArray[1].getType();
materialArray[2] = blockArray[2].getType();
byte[] byteArray = new byte[3];
byteArray[0] = blockArray[0].getData();
byteArray[1] = blockArray[0].getData();
byteArray[2] = blockArray[0].getData();
int x = 0;
for(Block target : blockArray)
{
if(materialArray[x] == Material.CACTUS)
{
is = new ItemStack(Material.CACTUS, 1, (byte)0, (byte)0);
if(byteArray[x] != (byte) 5)
{
if(Math.random() * 1000 <= PP.getHerbalismInt())
{
loc.getWorld().dropItemNaturally(target.getLocation(), is);
}
PP.addHerbalismXP(3 * LoadProperties.xpGainMultiplier);
}
}
x++;
}
PP.addHerbalismXP(3 * LoadProperties.xpGainMultiplier);
}
//Sugar Canes
if(type == 83){
is = new ItemStack(Material.SUGAR_CANE, 1, (byte)0, (byte)0);
if(player != null){
if(Math.random() * 1000 <= PP.getHerbalismInt()){
loc.getWorld().dropItemNaturally(loc, is);
}
//Setup the loop
World world = block.getWorld();
Block[] blockArray = new Block[3];
blockArray[0] = block;
blockArray[1] = world.getBlockAt(block.getX(), block.getY()+1, block.getZ());
blockArray[2] = world.getBlockAt(block.getX(), block.getY()+2, block.getZ());
Material[] materialArray = new Material[3];
materialArray[0] = blockArray[0].getType();
materialArray[1] = blockArray[1].getType();
materialArray[2] = blockArray[2].getType();
byte[] byteArray = new byte[3];
byteArray[0] = blockArray[0].getData();
byteArray[1] = blockArray[0].getData();
byteArray[2] = blockArray[0].getData();
int x = 0;
for(Block target : blockArray)
{
if(materialArray[x] == Material.SUGAR_CANE_BLOCK)
{
is = new ItemStack(Material.SUGAR_CANE, 1, (byte)0, (byte)0);
//Check for being placed by the player
if(byteArray[x] != (byte) 5)
{
if(Math.random() * 1000 <= PP.getHerbalismInt())
{
loc.getWorld().dropItemNaturally(target.getLocation(), is);
}
PP.addHerbalismXP(3 * LoadProperties.xpGainMultiplier);
}
}
x++;
}
PP.addHerbalismXP(3 * LoadProperties.xpGainMultiplier);
}
//Pumpkins
if((type == 91 || type == 86) && !Config.getInstance().isBlockWatched(block)){
mat = Material.getMaterial(block.getTypeId());

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.skills;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -22,7 +23,8 @@ public class Mining {
plugin = instance;
}
public static void superBreakerCheck(Player player, Block block, Plugin pluginx){
public static void superBreakerCheck(Player player, Block block, Plugin pluginx)
{
PlayerProfile PP = Users.getProfile(player);
if(m.isMiningPick(player.getItemInHand())){
if(block != null){
@ -53,7 +55,8 @@ public class Mining {
}
}
public static void blockProcSimulate(Block block){
public static void blockProcSimulate(Block block)
{
Location loc = block.getLocation();
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
@ -99,7 +102,8 @@ public class Mining {
loc.getWorld().dropItemNaturally(loc, item);
}
}
public static void blockProcCheck(Block block, Player player){
public static void blockProcCheck(Block block, Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(player != null){
if(Math.random() * 1000 <= PP.getMiningInt()){
@ -108,7 +112,8 @@ public class Mining {
}
}
}
public static void miningBlockCheck(Player player, Block block){
public static void miningBlockCheck(Player player, Block block)
{
PlayerProfile PP = Users.getProfile(player);
if(Config.getInstance().isBlockWatched(block) || block.getData() == (byte) 5)
return;
@ -185,7 +190,8 @@ public class Mining {
int xp = 0;
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
if(block.getTypeId() == 1 || block.getTypeId() == 24){
if(block.getTypeId() == 1 || block.getTypeId() == 24)
{
if(!Config.getInstance().isBlockWatched(block) && block.getData() != (byte) 5){
xp += 3;
blockProcCheck(block, player);
@ -198,10 +204,12 @@ public class Mining {
}
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//NETHERRACK
if(block.getTypeId() == 87){
if(block.getTypeId() == 87)
{
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
xp += 3;
blockProcCheck(block, player);
@ -210,10 +218,12 @@ public class Mining {
mat = Material.getMaterial(87);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//GLOWSTONE
if(block.getTypeId() == 89){
if(block.getTypeId() == 89)
{
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
xp += 3;
blockProcCheck(block, player);
@ -222,10 +232,12 @@ public class Mining {
mat = Material.getMaterial(348);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//COAL
if(block.getTypeId() == 16){
if(block.getTypeId() == 16)
{
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
xp += 10;
blockProcCheck(block, player);
@ -234,10 +246,12 @@ public class Mining {
mat = Material.getMaterial(263);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//GOLD
if(block.getTypeId() == 14 && m.getTier(player) >= 3){
if(block.getTypeId() == 14 && m.getTier(player) >= 3)
{
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
xp += 35;
blockProcCheck(block, player);
@ -245,10 +259,12 @@ public class Mining {
}
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//OBSIDIAN
if(block.getTypeId() == 49 && m.getTier(player) >= 4){
if(block.getTypeId() == 49 && m.getTier(player) >= 4)
{
if(LoadProperties.toolsLoseDurabilityFromAbilities)
m.damageTool(player, (short) 104);
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
@ -259,10 +275,12 @@ public class Mining {
mat = Material.getMaterial(49);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//DIAMOND
if(block.getTypeId() == 56 && m.getTier(player) >= 3){
if(block.getTypeId() == 56 && m.getTier(player) >= 3)
{
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
xp += 75;
blockProcCheck(block, player);
@ -271,10 +289,12 @@ public class Mining {
mat = Material.getMaterial(264);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//IRON
if(block.getTypeId() == 15 && m.getTier(player) >= 2){
if(block.getTypeId() == 15 && m.getTier(player) >= 2)
{
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
xp += 25;
blockProcCheck(block, player);
@ -282,11 +302,14 @@ public class Mining {
}
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//REDSTONE
if((block.getTypeId() == 73 || block.getTypeId() == 74) && m.getTier(player) >= 4){
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
if((block.getTypeId() == 73 || block.getTypeId() == 74) && m.getTier(player) >= 4)
{
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5)
{
xp += 15;
blockProcCheck(block, player);
blockProcCheck(block, player);
@ -296,9 +319,11 @@ public class Mining {
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
if(Math.random() * 10 > 5){
if(Math.random() * 10 > 5)
{
loc.getWorld().dropItemNaturally(loc, item);
}
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//LAPUS
@ -314,6 +339,7 @@ public class Mining {
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
if(block.getData() != (byte) 5)

View File

@ -85,7 +85,8 @@ public class Swords {
int targets = 0;
Entity x = event.getEntity();
targets = m.getTier(attacker);
for(Entity derp : x.getWorld().getEntities()){
for(Entity derp : x.getWorld().getEntities())
{
if(m.getDistance(x.getLocation(), derp.getLocation()) < 5){
if(derp instanceof Player){
Player target = (Player)derp;

View File

@ -1,3 +1,3 @@
name: mcMMO
main: com.gmail.nossr50.mcMMO
version: 1.0.05
version: 1.0.07