mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Fleshed out Mining/Woodcutting skills. Fixed several bugs with the FFS. Secret update #2.
This commit is contained in:
parent
7f8b3632e4
commit
4fe7f4f26e
@ -1,9 +1,16 @@
|
|||||||
package com.bukkit.nossr50.mcMMO;
|
package com.bukkit.nossr50.mcMMO;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
import org.bukkit.event.block.BlockDamageEvent;
|
||||||
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
import org.bukkit.event.block.BlockListener;
|
import org.bukkit.event.block.BlockListener;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class mcBlockListener extends BlockListener {
|
public class mcBlockListener extends BlockListener {
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
@ -11,38 +18,235 @@ public class mcBlockListener extends BlockListener {
|
|||||||
public mcBlockListener(final mcMMO plugin) {
|
public mcBlockListener(final mcMMO plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
|
Block block = event.getBlock();
|
||||||
|
mcConfig.getInstance().addBlockWatch(block);
|
||||||
|
}
|
||||||
|
public void blockProcSimulate(Block block){
|
||||||
|
Location loc = block.getLocation();
|
||||||
|
Material mat = Material.getMaterial(block.getTypeId());
|
||||||
|
byte damage = 0;
|
||||||
|
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
|
||||||
|
if(block.getTypeId() != 73 && block.getTypeId() != 74 && block.getTypeId() != 56 && block.getTypeId() != 21 && block.getTypeId() != 1 && block.getTypeId() != 16)
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
if(block.getTypeId() == 73 || block.getTypeId() == 74){
|
||||||
|
mat = Material.getMaterial(331);
|
||||||
|
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
//Since redstone gives 4-5, lets simulate that
|
||||||
|
if(Math.random() * 10 > 5){
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(block.getTypeId() == 21){
|
||||||
|
mat = Material.getMaterial(331);
|
||||||
|
item = new ItemStack(mat, 1, (byte)0,(byte)0x4);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
}
|
||||||
|
if(block.getTypeId() == 56){
|
||||||
|
mat = Material.getMaterial(264);
|
||||||
|
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
}
|
||||||
|
if(block.getTypeId() == 1){
|
||||||
|
mat = Material.getMaterial(4);
|
||||||
|
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
}
|
||||||
|
if(block.getTypeId() == 16){
|
||||||
|
mat = Material.getMaterial(263);
|
||||||
|
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void blockProcCheck(Block block, Player player){
|
||||||
|
Location loc = block.getLocation();
|
||||||
|
if(mcUsers.getProfile(player).getMiningInt() > 3000){
|
||||||
|
blockProcSimulate(block);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(mcUsers.getProfile(player).getMiningInt() > 2000){
|
||||||
|
if((Math.random() * 10) > 2){
|
||||||
|
blockProcSimulate(block);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mcUsers.getProfile(player).getMiningInt() > 750){
|
||||||
|
if((Math.random() * 10) > 4){
|
||||||
|
blockProcSimulate(block);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mcUsers.getProfile(player).getMiningInt() > 150){
|
||||||
|
if((Math.random() * 10) > 6){
|
||||||
|
blockProcSimulate(block);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mcUsers.getProfile(player).getMiningInt() > 25){
|
||||||
|
if((Math.random() * 10) > 8){
|
||||||
|
blockProcSimulate(block);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
//put all Block related code here
|
//put all Block related code here
|
||||||
public void onBlockDamage(BlockDamageEvent event) {
|
public void onBlockDamage(BlockDamageEvent event) {
|
||||||
//STARTED(0), DIGGING(1), BROKEN(3), STOPPED(2);
|
//STARTED(0), DIGGING(1), BROKEN(3), STOPPED(2);
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
int dmg = event.getDamageLevel().getLevel();
|
Location loc = block.getLocation();
|
||||||
if(dmg == 3){
|
int dmg = event.getDamageLevel().getLevel();
|
||||||
|
//Smooth Stone
|
||||||
|
if(dmg == 3 && !mcConfig.getInstance().isBlockWatched(block)){
|
||||||
|
if(block.getTypeId() == 1){
|
||||||
mcUsers.getProfile(player).addgather(1);
|
mcUsers.getProfile(player).addgather(1);
|
||||||
|
blockProcCheck(block, player);
|
||||||
|
}
|
||||||
|
//COAL
|
||||||
|
if(block.getTypeId() == 16){
|
||||||
|
mcUsers.getProfile(player).addgather(3);
|
||||||
|
blockProcCheck(block, player);
|
||||||
|
}
|
||||||
|
//GOLD
|
||||||
|
if(block.getTypeId() == 14){
|
||||||
|
mcUsers.getProfile(player).addgather(20);
|
||||||
|
blockProcCheck(block, player);
|
||||||
|
}
|
||||||
|
//DIAMOND
|
||||||
|
if(block.getTypeId() == 56){
|
||||||
|
mcUsers.getProfile(player).addgather(50);
|
||||||
|
blockProcCheck(block, player);
|
||||||
|
}
|
||||||
|
//IRON
|
||||||
|
if(block.getTypeId() == 15){
|
||||||
|
mcUsers.getProfile(player).addgather(10);
|
||||||
|
blockProcCheck(block, player);
|
||||||
|
}
|
||||||
|
//REDSTONE
|
||||||
|
if(block.getTypeId() == 73 || block.getTypeId() == 74){
|
||||||
|
mcUsers.getProfile(player).addgather(15);
|
||||||
|
blockProcCheck(block, player);
|
||||||
|
}
|
||||||
|
//LAPUS
|
||||||
|
if(block.getTypeId() == 21){
|
||||||
|
mcUsers.getProfile(player).addgather(50);
|
||||||
|
blockProcCheck(block, player);
|
||||||
|
}
|
||||||
|
//Give skill for woodcutting
|
||||||
|
if(block.getTypeId() == 17)
|
||||||
|
mcUsers.getProfile(player).addwgather(1);
|
||||||
|
|
||||||
|
if(mcUsers.getProfile(player).getwgatheramt() > 10){
|
||||||
|
while(mcUsers.getProfile(player).getwgatheramt() > 10){
|
||||||
|
mcUsers.getProfile(player).removewgather(10);
|
||||||
|
mcUsers.getProfile(player).skillUpWoodcutting(1);
|
||||||
|
player.sendMessage(ChatColor.YELLOW+"Wood Cutting skill increased by 1. Total ("+mcUsers.getProfile(player).getWoodCutting()+")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mcUsers.getProfile(player).getgatheramt() > 50){
|
||||||
|
while(mcUsers.getProfile(player).getgatheramt() > 50){
|
||||||
|
mcUsers.getProfile(player).removegather(50);
|
||||||
|
mcUsers.getProfile(player).skillUpMining(1);
|
||||||
|
player.sendMessage(ChatColor.YELLOW+"Mining skill increased by 1. Total ("+mcUsers.getProfile(player).getMining()+")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* WOODCUTTING
|
||||||
|
*/
|
||||||
|
if(block.getTypeId() == 17){
|
||||||
|
if(mcUsers.getProfile(player).getWoodCuttingint() > 1000){
|
||||||
|
Material mat = Material.getMaterial(block.getTypeId());
|
||||||
|
byte damage = 0;
|
||||||
|
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(mcUsers.getProfile(player).getWoodCuttingint() > 750){
|
||||||
|
if((Math.random() * 10) > 2){
|
||||||
|
Material mat = Material.getMaterial(block.getTypeId());
|
||||||
|
byte damage = 0;
|
||||||
|
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mcUsers.getProfile(player).getWoodCuttingint() > 300){
|
||||||
|
if((Math.random() * 10) > 4){
|
||||||
|
Material mat = Material.getMaterial(block.getTypeId());
|
||||||
|
byte damage = 0;
|
||||||
|
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mcUsers.getProfile(player).getWoodCuttingint() > 100){
|
||||||
|
if((Math.random() * 10) > 6){
|
||||||
|
Material mat = Material.getMaterial(block.getTypeId());
|
||||||
|
byte damage = 0;
|
||||||
|
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mcUsers.getProfile(player).getWoodCuttingint() > 10){
|
||||||
|
if((Math.random() * 10) > 8){
|
||||||
|
Material mat = Material.getMaterial(block.getTypeId());
|
||||||
|
byte damage = 0;
|
||||||
|
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
|
||||||
|
block.getWorld().dropItemNaturally(loc, item);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//GOLD ORE = 14
|
//GOLD ORE = 14
|
||||||
//DIAMOND ORE = 56
|
//DIAMOND ORE = 56
|
||||||
//REDSTONE = 73 && 74
|
//REDSTONE = 73 && 74
|
||||||
|
|
||||||
if(block.getTypeId() == 1){
|
|
||||||
int t = player.getItemInHand().getTypeId();
|
|
||||||
int q;
|
|
||||||
//If stone tools
|
|
||||||
if(t == 272 || t == 273 || t == 274 || t == 275){
|
|
||||||
q = 3;
|
|
||||||
//If iron tools
|
|
||||||
} else if (t == 256 || t == 257 || t == 258 || t == 267){
|
|
||||||
q = 2;
|
|
||||||
//If wooden tools
|
|
||||||
} else if (t == 268 || t == 269 || t == 270 || t == 271){
|
|
||||||
q = 4;
|
|
||||||
//If Diamond tools
|
|
||||||
} else if (t == 276 || t == 277 || t == 278 || t == 279){
|
|
||||||
q = 1;
|
|
||||||
} else {
|
|
||||||
q = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void onBlockFlow(BlockFromToEvent event) {
|
||||||
|
//Code borrowed from WorldGuard by sk89q
|
||||||
|
World world = event.getBlock().getWorld();
|
||||||
|
int radius = 1;
|
||||||
|
Block blockFrom = event.getBlock();
|
||||||
|
Block blockTo = event.getToBlock();
|
||||||
|
|
||||||
|
boolean isWater = blockFrom.getTypeId() == 8 || blockFrom.getTypeId() == 9;
|
||||||
|
boolean isLava = blockFrom.getTypeId() == 10 || blockFrom.getTypeId() == 11;
|
||||||
|
|
||||||
|
int ox = blockTo.getX();
|
||||||
|
int oy = blockTo.getY();
|
||||||
|
int oz = blockTo.getZ();
|
||||||
|
|
||||||
|
if(blockTo.getTypeId() == 9 || blockTo.getTypeId() == 8){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int cx = -radius; cx <= radius; cx++) {
|
||||||
|
for (int cy = -radius; cy <= radius; cy++) {
|
||||||
|
for (int cz = -radius; cz <= radius; cz++) {
|
||||||
|
Block dirt = world.getBlockAt(ox + cx, oy + cy, oz + cz);
|
||||||
|
//If block is dirt
|
||||||
|
if (isWater == true &&
|
||||||
|
dirt.getTypeId() == 13) {
|
||||||
|
//Change
|
||||||
|
dirt.setTypeId(82);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,10 +2,16 @@ package com.bukkit.nossr50.mcMMO;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
public class mcConfig {
|
public class mcConfig {
|
||||||
private static volatile mcConfig instance;
|
private static volatile mcConfig instance;
|
||||||
static ArrayList<String> adminChatList = new ArrayList<String>();
|
static ArrayList<String> adminChatList = new ArrayList<String>();
|
||||||
|
static ArrayList<Block> blockWatchList = new ArrayList<Block>();
|
||||||
static ArrayList<String> partyChatList = new ArrayList<String>();
|
static ArrayList<String> partyChatList = new ArrayList<String>();
|
||||||
|
public boolean isBlockWatched(Block block) {return blockWatchList.contains(block);}
|
||||||
|
public void removeBlockWatch(Block block) {blockWatchList.remove(blockWatchList.indexOf(block));}
|
||||||
|
public void addBlockWatch(Block block) {blockWatchList.add(block);}
|
||||||
public boolean isAdminToggled(String playerName) {return adminChatList.contains(playerName);}
|
public boolean isAdminToggled(String playerName) {return adminChatList.contains(playerName);}
|
||||||
public boolean isPartyToggled(String playerName) {return partyChatList.contains(playerName);}
|
public boolean isPartyToggled(String playerName) {return partyChatList.contains(playerName);}
|
||||||
public void removePartyToggled(String playerName) {partyChatList.remove(partyChatList.indexOf(playerName));}
|
public void removePartyToggled(String playerName) {partyChatList.remove(partyChatList.indexOf(playerName));}
|
||||||
|
@ -36,6 +36,8 @@ public class mcMMO extends JavaPlugin {
|
|||||||
pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Monitor, this);
|
pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Monitor, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_FLOW, blockListener, Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
|
||||||
//Displays a message when plugin is loaded
|
//Displays a message when plugin is loaded
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
PluginDescriptionFile pdfFile = this.getDescription();
|
||||||
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
|
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
|
||||||
|
@ -20,8 +20,7 @@ public class mcPlayerListener extends PlayerListener {
|
|||||||
player.sendMessage(ChatColor.DARK_RED+"Welcome to /v/ - Minecraft");
|
player.sendMessage(ChatColor.DARK_RED+"Welcome to /v/ - Minecraft");
|
||||||
player.sendMessage(ChatColor.DARK_RED+"Steam Group: vminecraft");
|
player.sendMessage(ChatColor.DARK_RED+"Steam Group: vminecraft");
|
||||||
player.sendMessage(ChatColor.AQUA + "This server is running mcMMO type /stats for your information");
|
player.sendMessage(ChatColor.AQUA + "This server is running mcMMO type /stats for your information");
|
||||||
player.sendMessage(ChatColor.GREEN + "Use "+ChatColor.YELLOW+"/party "+ChatColor.GREEN+"to create/join parties and");
|
player.sendMessage(ChatColor.GREEN + "Use "+ChatColor.YELLOW+"/party "+ChatColor.GREEN+"to create/join parties");
|
||||||
player.sendMessage(ChatColor.GREEN+"to check who is in your current party.");
|
|
||||||
player.sendMessage(ChatColor.GREEN + "Use "+ChatColor.YELLOW+"/p"+ChatColor.GREEN+" to toggle party chat");
|
player.sendMessage(ChatColor.GREEN + "Use "+ChatColor.YELLOW+"/p"+ChatColor.GREEN+" to toggle party chat");
|
||||||
player.sendMessage(ChatColor.GREEN + "Use "+ChatColor.YELLOW+"/ptp "+ChatColor.GREEN+"to teleport to party members");
|
player.sendMessage(ChatColor.GREEN + "Use "+ChatColor.YELLOW+"/ptp "+ChatColor.GREEN+"to teleport to party members");
|
||||||
player.sendMessage("Set your spawn with "+ChatColor.YELLOW+"/setmyspawn"+ChatColor.WHITE+", Travel to it with /myspawn");
|
player.sendMessage("Set your spawn with "+ChatColor.YELLOW+"/setmyspawn"+ChatColor.WHITE+", Travel to it with /myspawn");
|
||||||
@ -65,9 +64,11 @@ public class mcPlayerListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
if(isPlayer(split[1])){
|
if(isPlayer(split[1])){
|
||||||
Player target = getPlayer(split[1]);
|
Player target = getPlayer(split[1]);
|
||||||
|
if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(target).getParty())){
|
||||||
player.teleportTo(target);
|
player.teleportTo(target);
|
||||||
player.sendMessage(ChatColor.GREEN+"You have teleport to "+target.getName());
|
player.sendMessage(ChatColor.GREEN+"You have teleported to "+target.getName());
|
||||||
target.sendMessage(ChatColor.GREEN+player.getName() + " has teleported to you.");
|
target.sendMessage(ChatColor.GREEN+player.getName() + " has teleported to you.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(player.isOp() && split[0].equalsIgnoreCase("/whois")){
|
if(player.isOp() && split[0].equalsIgnoreCase("/whois")){
|
||||||
@ -87,7 +88,8 @@ public class mcPlayerListener extends PlayerListener {
|
|||||||
player.sendMessage("Health: "+target.getHealth()+ChatColor.GRAY+" (20 is full health)");
|
player.sendMessage("Health: "+target.getHealth()+ChatColor.GRAY+" (20 is full health)");
|
||||||
player.sendMessage("OP: " + target.isOp());
|
player.sendMessage("OP: " + target.isOp());
|
||||||
player.sendMessage(ChatColor.GREEN+"~~mcMMO stats~~");
|
player.sendMessage(ChatColor.GREEN+"~~mcMMO stats~~");
|
||||||
player.sendMessage("Gathering Skill: "+mcUsers.getProfile(target).getgather());
|
player.sendMessage("Mining Skill: "+mcUsers.getProfile(target).getMining());
|
||||||
|
player.sendMessage("Woodcutting Skill: "+mcUsers.getProfile(target).getWoodCutting());
|
||||||
player.sendMessage(ChatColor.GREEN+"~~COORDINATES~~");
|
player.sendMessage(ChatColor.GREEN+"~~COORDINATES~~");
|
||||||
player.sendMessage("X: "+x);
|
player.sendMessage("X: "+x);
|
||||||
player.sendMessage("Y: "+y);
|
player.sendMessage("Y: "+y);
|
||||||
@ -108,9 +110,9 @@ public class mcPlayerListener extends PlayerListener {
|
|||||||
if(split[0].equalsIgnoreCase("/stats")){
|
if(split[0].equalsIgnoreCase("/stats")){
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.DARK_GREEN + "mcMMO stats");
|
player.sendMessage(ChatColor.DARK_GREEN + "mcMMO stats");
|
||||||
player.sendMessage(ChatColor.DARK_GREEN + "Gathering Skill: " + mcUsers.getProfile(player).getgather());
|
player.sendMessage(ChatColor.DARK_GREEN + "Mining Skill: " + mcUsers.getProfile(player).getMining());
|
||||||
player.sendMessage(ChatColor.GRAY + "Increases as you gather materials from the world");
|
player.sendMessage(ChatColor.DARK_GREEN+"Woodcutting Skill: "+mcUsers.getProfile(player).getWoodCutting());
|
||||||
player.sendMessage(ChatColor.GRAY + "Effect: Increases chance to gather more than one of a rare material");
|
player.sendMessage(ChatColor.GRAY + "Increases depending on the material you mine");
|
||||||
}
|
}
|
||||||
//Party command
|
//Party command
|
||||||
if(split[0].equalsIgnoreCase("/party")){
|
if(split[0].equalsIgnoreCase("/party")){
|
||||||
@ -168,10 +170,14 @@ public class mcPlayerListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(split[0].equalsIgnoreCase("/myspawn")){
|
if(split[0].equalsIgnoreCase("/myspawn")){
|
||||||
|
if(mcUsers.getProfile(player).getMySpawn(player) != null){
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
player.setHealth(20);
|
player.setHealth(20);
|
||||||
player.teleportTo(mcUsers.getProfile(player).getMySpawn(player));
|
player.teleportTo(mcUsers.getProfile(player).getMySpawn(player));
|
||||||
player.sendMessage("Inventory cleared & health restored");
|
player.sendMessage("Inventory cleared & health restored");
|
||||||
|
}else{
|
||||||
|
player.sendMessage(ChatColor.RED+"Configure your myspawn first with /setmyspawn");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(split[0].equalsIgnoreCase("/spawn")){
|
if(split[0].equalsIgnoreCase("/spawn")){
|
||||||
if(spawn != null){
|
if(spawn != null){
|
||||||
|
@ -154,7 +154,7 @@ class PlayerList
|
|||||||
class PlayerProfile
|
class PlayerProfile
|
||||||
{
|
{
|
||||||
protected final Logger log = Logger.getLogger("Minecraft");
|
protected final Logger log = Logger.getLogger("Minecraft");
|
||||||
private String playerName, gather, party, myspawn;
|
private String playerName, gather, wgather, woodcutting, mining, party, myspawn;
|
||||||
private boolean dead;
|
private boolean dead;
|
||||||
char defaultColor;
|
char defaultColor;
|
||||||
|
|
||||||
@ -174,7 +174,14 @@ class PlayerList
|
|||||||
playerName = player.getName();
|
playerName = player.getName();
|
||||||
party = new String();
|
party = new String();
|
||||||
myspawn = new String();
|
myspawn = new String();
|
||||||
|
mining = new String();
|
||||||
|
//mining = "0";
|
||||||
|
wgather = new String();
|
||||||
|
//wgather = "0";
|
||||||
|
woodcutting = new String();
|
||||||
|
//woodcutting = "0";
|
||||||
gather = new String();
|
gather = new String();
|
||||||
|
//gather = "0";
|
||||||
party = null;
|
party = null;
|
||||||
dead = false;
|
dead = false;
|
||||||
|
|
||||||
@ -196,13 +203,22 @@ class PlayerList
|
|||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
if(!character[0].equals(playerName)){continue;}
|
if(!character[0].equals(playerName)){continue;}
|
||||||
|
|
||||||
//Get gather
|
//Get Mining
|
||||||
if(character.length > 1)
|
if(character.length > 1)
|
||||||
gather = character[1];
|
mining = character[1];
|
||||||
|
//Myspawn
|
||||||
if(character.length > 2)
|
if(character.length > 2)
|
||||||
myspawn = character[2];
|
myspawn = character[2];
|
||||||
|
//Party
|
||||||
if(character.length > 3)
|
if(character.length > 3)
|
||||||
party = character[3];
|
party = character[3];
|
||||||
|
//Mining Gather
|
||||||
|
if(character.length > 4)
|
||||||
|
gather = character[4];
|
||||||
|
if(character.length > 5)
|
||||||
|
woodcutting = character[5];
|
||||||
|
if(character.length > 6)
|
||||||
|
wgather = character[6];
|
||||||
in.close();
|
in.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -242,9 +258,12 @@ class PlayerList
|
|||||||
//Otherwise write the new player information
|
//Otherwise write the new player information
|
||||||
} else {
|
} else {
|
||||||
writer.append(playerName + ":");
|
writer.append(playerName + ":");
|
||||||
writer.append(gather + ":");
|
writer.append(mining + ":");
|
||||||
writer.append(myspawn + ":");
|
writer.append(myspawn + ":");
|
||||||
writer.append(party+":");
|
writer.append(party+":");
|
||||||
|
writer.append(gather+":");
|
||||||
|
writer.append(woodcutting+":");
|
||||||
|
writer.append(wgather+":");
|
||||||
writer.append("\r\n");
|
writer.append("\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,9 +285,12 @@ class PlayerList
|
|||||||
|
|
||||||
//Add the player to the end
|
//Add the player to the end
|
||||||
out.append(playerName + ":");
|
out.append(playerName + ":");
|
||||||
out.append(gather + ":");
|
out.append(0 + ":");
|
||||||
out.append(myspawn+":");
|
out.append(myspawn+":");
|
||||||
out.append(party+":");
|
out.append(party+":");
|
||||||
|
out.append(0+":");
|
||||||
|
out.append(0+":");
|
||||||
|
out.append(0+":");
|
||||||
//Add more in the same format as the line above
|
//Add more in the same format as the line above
|
||||||
|
|
||||||
out.newLine();
|
out.newLine();
|
||||||
@ -288,29 +310,129 @@ class PlayerList
|
|||||||
{
|
{
|
||||||
return player.getName().equals(playerName);
|
return player.getName().equals(playerName);
|
||||||
}
|
}
|
||||||
|
public void skillUpMining(int newmining){
|
||||||
|
int x = 0;
|
||||||
|
if(mining != null){
|
||||||
|
if(isInt(mining)){
|
||||||
|
x = Integer.parseInt(mining);
|
||||||
|
}else {
|
||||||
|
mining = "0";
|
||||||
|
x = Integer.parseInt(mining);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x += newmining;
|
||||||
|
mining = Integer.toString(x);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
public void skillUpWoodcutting(int newskill){
|
||||||
|
int x = 0;
|
||||||
|
if(woodcutting != null){
|
||||||
|
if(isInt(woodcutting)){
|
||||||
|
x = Integer.parseInt(woodcutting);
|
||||||
|
}else {
|
||||||
|
woodcutting = "0";
|
||||||
|
x = Integer.parseInt(woodcutting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x += newskill;
|
||||||
|
woodcutting = Integer.toString(x);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
public String getMining(){
|
||||||
|
return mining;
|
||||||
|
}
|
||||||
|
public int getMiningInt(){
|
||||||
|
if(isInt(mining)){
|
||||||
|
int x = Integer.parseInt(mining);
|
||||||
|
return x;
|
||||||
|
} else{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int getWoodCuttingint(){
|
||||||
|
if(isInt(woodcutting)){
|
||||||
|
int x = Integer.parseInt(woodcutting);
|
||||||
|
return x;
|
||||||
|
} else{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public String getWoodCutting(){
|
||||||
|
return woodcutting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addwgather(int newgather)
|
||||||
|
{
|
||||||
|
int x = 0;
|
||||||
|
if(isInt(wgather)){
|
||||||
|
x = Integer.parseInt(wgather);
|
||||||
|
}
|
||||||
|
x += newgather;
|
||||||
|
wgather = String.valueOf(x);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
public void removewgather(int newgather){
|
||||||
|
int x = 0;
|
||||||
|
if(isInt(wgather)){
|
||||||
|
x = Integer.parseInt(wgather);
|
||||||
|
}
|
||||||
|
x -= newgather;
|
||||||
|
wgather = String.valueOf(x);
|
||||||
|
save();
|
||||||
|
}
|
||||||
public void addgather(int newgather)
|
public void addgather(int newgather)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
if(isInt(gather)){
|
if(isInt(gather)){
|
||||||
x = Integer.parseInt(gather);
|
x = Integer.parseInt(gather);
|
||||||
|
} else {
|
||||||
|
x = 0;
|
||||||
}
|
}
|
||||||
x += newgather;
|
x += newgather;
|
||||||
gather = String.valueOf(x);
|
gather = String.valueOf(x);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
public void removegather(int newgather){
|
||||||
|
int x = 0;
|
||||||
|
if(isInt(gather)){
|
||||||
|
x = Integer.parseInt(gather);
|
||||||
|
}
|
||||||
|
x -= newgather;
|
||||||
|
gather = String.valueOf(x);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isInt(String string){
|
public boolean isInt(String string){
|
||||||
try {
|
try {
|
||||||
int x = Integer.parseInt(gather);
|
int x = Integer.parseInt(string);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
catch(NumberFormatException nFE) {
|
catch(NumberFormatException nFE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
//Returns player gather
|
//Returns player gather
|
||||||
public String getgather() { return gather; }
|
public String getgather() { return gather; }
|
||||||
|
public String getwgather() { return wgather; }
|
||||||
|
|
||||||
|
public int getwgatheramt() {
|
||||||
|
if(isInt(wgather)){
|
||||||
|
return Integer.parseInt(getwgather());
|
||||||
|
} else {
|
||||||
|
wgather = "0";
|
||||||
|
save();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int getgatheramt() {
|
||||||
|
if(isInt(gather)){
|
||||||
|
return Integer.parseInt(getgather());
|
||||||
|
} else {
|
||||||
|
gather = "0";
|
||||||
|
save();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Store the player's party
|
//Store the player's party
|
||||||
public void setParty(String newParty)
|
public void setParty(String newParty)
|
||||||
|
Loading…
Reference in New Issue
Block a user