mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Excavation fleshed out. Basic herbalism stuff added.
This commit is contained in:
parent
56f8eb55f7
commit
d87cc62822
@ -42,6 +42,8 @@ public class mcBlockListener extends BlockListener {
|
||||
if(block.getTypeId() == 17){
|
||||
mcm.getInstance().woodCuttingProcCheck(player, block, loc);
|
||||
}
|
||||
mcm.getInstance().herbalismProcCheck(block, player);
|
||||
mcm.getInstance().excavationProcCheck(block, player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class mcEntityListener extends EntityListener {
|
||||
defender.setHealth(calculateDamage(defender, 8));
|
||||
}
|
||||
//XP
|
||||
if(Math.random() * 10 > 8){
|
||||
if(attacker.getItemInHand().getTypeId() == 0 && Math.random() * 10 > 8){
|
||||
mcUsers.getProfile(attacker).skillUpUnarmed(1);
|
||||
attacker.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by 1. Total ("+mcUsers.getProfile(attacker).getUnarmed()+")");
|
||||
}
|
||||
@ -98,7 +98,7 @@ public class mcEntityListener extends EntityListener {
|
||||
return;
|
||||
}
|
||||
//XP
|
||||
if(Math.random() * 10 > 9){
|
||||
if(attacker.getItemInHand().getTypeId() == 0 && Math.random() * 10 > 9){
|
||||
mcUsers.getProfile(attacker).skillUpUnarmed(1);
|
||||
attacker.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by 1. Total ("+mcUsers.getProfile(attacker).getUnarmed()+")");
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ public class mcMMO extends JavaPlugin {
|
||||
pm.registerEvent(Event.Type.BLOCK_FLOW, blockListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_ITEM, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, Priority.Normal, this);
|
||||
//Displays a message when plugin is loaded
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerItemEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class mcPlayerListener extends PlayerListener {
|
||||
@ -17,6 +18,13 @@ public class mcPlayerListener extends PlayerListener {
|
||||
public mcPlayerListener(mcMMO instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(mcUsers.getProfile(player).getMySpawn(player) != null);
|
||||
event.setRespawnLocation(mcUsers.getProfile(player).getMySpawn(player));
|
||||
if(spawn != null)
|
||||
event.setRespawnLocation(spawn);
|
||||
}
|
||||
public Player[] getPlayersOnline() {
|
||||
return plugin.getServer().getOnlinePlayers();
|
||||
}
|
||||
@ -74,6 +82,32 @@ public class mcPlayerListener extends PlayerListener {
|
||||
Block block = event.getBlockClicked();
|
||||
Player player = event.getPlayer();
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is.getTypeId() == 297){
|
||||
if(mcUsers.getProfile(player).getHerbalismInt() >= 50){
|
||||
player.setHealth(player.getHealth() + 2);
|
||||
} else if (mcUsers.getProfile(player).getHerbalismInt() > 150 && mcUsers.getProfile(player).getHerbalismInt() < 250){
|
||||
player.setHealth(player.getHealth() + 4);
|
||||
} else if (mcUsers.getProfile(player).getHerbalismInt() > 250 && mcUsers.getProfile(player).getHerbalismInt() < 400){
|
||||
player.setHealth(player.getHealth() + 5);
|
||||
} else if (mcUsers.getProfile(player).getHerbalismInt() > 400 && mcUsers.getProfile(player).getHerbalismInt() < 750){
|
||||
player.setHealth(player.getHealth() + 6);
|
||||
} else if (mcUsers.getProfile(player).getHerbalismInt() > 750){
|
||||
player.setHealth(player.getHealth() + 8);
|
||||
}
|
||||
}
|
||||
if(is.getTypeId() == 297){
|
||||
if(mcUsers.getProfile(player).getHerbalismInt() >= 50){
|
||||
player.setHealth(player.getHealth() + 1);
|
||||
} else if (mcUsers.getProfile(player).getHerbalismInt() > 150 && mcUsers.getProfile(player).getHerbalismInt() < 250){
|
||||
player.setHealth(player.getHealth() + 2);
|
||||
} else if (mcUsers.getProfile(player).getHerbalismInt() > 250 && mcUsers.getProfile(player).getHerbalismInt() < 400){
|
||||
player.setHealth(player.getHealth() + 3);
|
||||
} else if (mcUsers.getProfile(player).getHerbalismInt() > 400 && mcUsers.getProfile(player).getHerbalismInt() < 750){
|
||||
player.setHealth(player.getHealth() + 4);
|
||||
} else if (mcUsers.getProfile(player).getHerbalismInt() > 750){
|
||||
player.setHealth(player.getHealth() + 6);
|
||||
}
|
||||
}
|
||||
if(block != null && block.getTypeId() == 42 && player.getItemInHand().getDurability() <= 0){
|
||||
player.sendMessage(ChatColor.YELLOW+"That is at full durability.");
|
||||
return;
|
||||
@ -231,7 +265,6 @@ public class mcPlayerListener extends PlayerListener {
|
||||
player.sendMessage(ChatColor.DARK_GREEN + "Unarmed Skill: " + mcUsers.getProfile(player).getUnarmed());
|
||||
player.sendMessage(ChatColor.DARK_GREEN + "Herbalism Skill: " + mcUsers.getProfile(player).getHerbalism());
|
||||
player.sendMessage(ChatColor.DARK_GREEN + "Excavation Skill: " + mcUsers.getProfile(player).getExcavation());
|
||||
player.sendMessage(ChatColor.GRAY + "Increases depending on the material you mine");
|
||||
}
|
||||
//Party command
|
||||
if(split[0].equalsIgnoreCase("/party")){
|
||||
|
@ -223,6 +223,100 @@ public class mcm {
|
||||
mcm.getInstance().blockProcCheck(block, player);
|
||||
}
|
||||
}
|
||||
public void herbalismProcCheck(Block block, Player player){
|
||||
int type = block.getTypeId();
|
||||
if(type == 39 || type == 40){
|
||||
mcUsers.getProfile(player).skillUpHerbalism(3);
|
||||
player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by 3. Total ("+mcUsers.getProfile(player).getHerbalismInt()+")");
|
||||
}
|
||||
if(type == 37 || type == 38){
|
||||
if(Math.random() * 10 > 8){
|
||||
mcUsers.getProfile(player).skillUpHerbalism(1);
|
||||
player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by 1. Total ("+mcUsers.getProfile(player).getHerbalismInt()+")");
|
||||
}
|
||||
}
|
||||
if(type == 59){
|
||||
mcUsers.getProfile(player).skillUpHerbalism(1);
|
||||
player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by 1. Total ("+mcUsers.getProfile(player).getHerbalismInt()+")");
|
||||
}
|
||||
}
|
||||
public void excavationProcCheck(Block block, Player player){
|
||||
int type = block.getTypeId();
|
||||
Location loc = block.getLocation();
|
||||
ItemStack is = null;
|
||||
Material mat = null;
|
||||
//DIRT OR GRAVEL
|
||||
if(type == 3 || type == 13 || type == 2){
|
||||
if(Math.random() * 10 > 9){
|
||||
mcUsers.getProfile(player).skillUpExcavation(1);
|
||||
player.sendMessage(ChatColor.YELLOW+"Excavation skill increased by 1. Total ("+mcUsers.getProfile(player).getExcavationInt()+")");
|
||||
|
||||
}
|
||||
if(mcUsers.getProfile(player).getExcavationInt() > 750){
|
||||
if(Math.random() * 2000 > 1999){
|
||||
mat = Material.getMaterial(354);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
if(mcUsers.getProfile(player).getExcavationInt() > 500 && type == 3){
|
||||
if(Math.random() * 1000 > 999){
|
||||
mat = Material.getMaterial(2256);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
if(Math.random() * 1000 > 999){
|
||||
mat = Material.getMaterial(2257);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
if(Math.random() * 500 > 499){
|
||||
mat = Material.getMaterial(264);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(type == 12){
|
||||
if(Math.random() * 10 > 9){
|
||||
mcUsers.getProfile(player).skillUpExcavation(1);
|
||||
player.sendMessage(ChatColor.YELLOW+"Excavation skill increased by 1. Total ("+mcUsers.getProfile(player).getExcavationInt()+")");
|
||||
|
||||
}
|
||||
if(mcUsers.getProfile(player).getExcavationInt() > 50 && Math.random() * 100 > 95){
|
||||
mat = Material.getMaterial(348);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
if(mcUsers.getProfile(player).getExcavationInt() > 500 && Math.random() * 500 > 499){
|
||||
mat = Material.getMaterial(264);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
if(mcUsers.getProfile(player).getExcavationInt() > 125){
|
||||
if(Math.random() * 2000 > 1999){
|
||||
mat = Material.getMaterial(263);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if((type == 2 || type == 3) && mcUsers.getProfile(player).getExcavationInt() > 25){
|
||||
if(Math.random() * 10 > 7){
|
||||
mat = Material.getMaterial(348);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
if(type == 13 && mcUsers.getProfile(player).getExcavationInt() > 75){
|
||||
if(Math.random() * 10 > 7){
|
||||
mat = Material.getMaterial(289);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void woodCuttingProcCheck(Player player, Block block, Location loc){
|
||||
if(mcUsers.getProfile(player).getWoodCuttingint() > 1000){
|
||||
Material mat = Material.getMaterial(block.getTypeId());
|
||||
|
@ -1,3 +1,3 @@
|
||||
name: mcMMO
|
||||
main: com.bukkit.nossr50.mcMMO.mcMMO
|
||||
version: 0.2.1
|
||||
version: 0.3
|
Loading…
Reference in New Issue
Block a user