78 lines
2.4 KiB
Java
Raw Normal View History

2013-11-01 23:28:39 -07:00
package me.kaZep.Base;
import org.bukkit.Bukkit;
2013-11-23 12:06:26 -07:00
import org.bukkit.Location;
2013-11-01 23:28:39 -07:00
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class PlayerData {
int buildamt=10;
Material lastblocktype=null;
long lastinteracttime=0;
long lastminetime=0;
int minestreak=0;
2013-11-23 12:06:26 -07:00
Location clickedblock1=null; //Stores the location of a clicked block.
2013-11-01 23:28:39 -07:00
Player data=null;
public PlayerData(Player p) {
this.data=p;
this.lastblocktype=Material.DIRT;
2013-11-16 21:08:52 -07:00
lastinteracttime=Main.SERVER_TICK_TIME;
lastminetime=Main.SERVER_TICK_TIME;
2013-11-01 23:28:39 -07:00
minestreak=0;
}
public boolean CheckMineStreak() {
//Increases mining streak by one if the miner hasn't stopped mining for more than 10 seconds.
//Resets when the miner hasn't mined for 10 seconds.
//If it reaches 10 blocks, we assume the miner is mining, and we need to do something about it.
//Attempt to spawn Charge Zombie II's in rooms that are unlit.
2013-11-16 21:08:52 -07:00
if (Main.SERVER_TICK_TIME>lastminetime+200) {
2013-11-01 23:28:39 -07:00
//Reset. Too much time has passed.
2013-11-16 21:08:52 -07:00
lastminetime=Main.SERVER_TICK_TIME;
2013-11-01 23:28:39 -07:00
minestreak=0;
} else {
minestreak++;
2013-11-16 21:08:52 -07:00
lastminetime=Main.SERVER_TICK_TIME;
2013-11-01 23:28:39 -07:00
if (minestreak>10) {
minestreak=0;
return true;
}
}
return false;
}
public boolean GoodInteract() {
//A good interact is doing their part of the job.
buildamt--;
if (buildamt<=0) {
buildamt=0;
return true;
} else {
2013-11-05 00:50:22 -07:00
if (buildamt>100) {
buildamt=100; //This is the upper bound of this value.
2013-11-01 23:28:39 -07:00
}
return false;
}
//Use this whenever you do a good interaction. Check the return value to see if we are allowed to gain exp from it.
}
public void BadInteract(Material blockType) {
//This method will add to the list of blocks created/destroyed, in an attempt to detect any further attempts to not be allowed to destroy things.
//This event should be called whenever a bad interaction happens.
if (blockType!=this.lastblocktype) {
//We are interacting with a different type of block. Give more lee-way for this block.
buildamt+=1;
this.lastblocktype=blockType;
} else {
//This is a block type we are dealing with from beforehand. We will need to add more to buildamt to make sure we are not cheating the system.
buildamt+=2;
}
}
2013-11-23 12:06:26 -07:00
public void SetClickedBlock(Location l) {
clickedblock1 = l;
}
public Location GetClickedBlock() {
return clickedblock1;
}
2013-11-01 23:28:39 -07:00
public Player getPlayer() {
return data;
}
}