mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-20 07:01:22 +01:00
Better check for block protection when its being broken not by player
This commit is contained in:
parent
9863b4719f
commit
458393b211
@ -79,6 +79,7 @@ import com.gamingmesh.jobs.listeners.McMMOlistener;
|
|||||||
import com.gamingmesh.jobs.listeners.MythicMobsListener;
|
import com.gamingmesh.jobs.listeners.MythicMobsListener;
|
||||||
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
||||||
import com.gamingmesh.jobs.stuff.ActionBar;
|
import com.gamingmesh.jobs.stuff.ActionBar;
|
||||||
|
import com.gamingmesh.jobs.stuff.Debug;
|
||||||
import com.gamingmesh.jobs.stuff.JobsClassLoader;
|
import com.gamingmesh.jobs.stuff.JobsClassLoader;
|
||||||
import com.gamingmesh.jobs.stuff.Loging;
|
import com.gamingmesh.jobs.stuff.Loging;
|
||||||
import com.gamingmesh.jobs.stuff.TabComplete;
|
import com.gamingmesh.jobs.stuff.TabComplete;
|
||||||
@ -807,6 +808,9 @@ public class Jobs extends JavaPlugin {
|
|||||||
if (jobinfo == null)
|
if (jobinfo == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!isBpOk(jPlayer.getPlayer(), info.getType(), block, true))
|
||||||
|
return;
|
||||||
|
|
||||||
Double income = jobinfo.getIncome(1, numjobs);
|
Double income = jobinfo.getIncome(1, numjobs);
|
||||||
Double pointAmount = jobinfo.getPoints(1, numjobs);
|
Double pointAmount = jobinfo.getPoints(1, numjobs);
|
||||||
|
|
||||||
@ -851,9 +855,6 @@ public class Jobs extends JavaPlugin {
|
|||||||
income = 0D;
|
income = 0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isBpOk(jPlayer, info, block))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (income == 0D && pointAmount == 0D)
|
if (income == 0D && pointAmount == 0D)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -876,7 +877,8 @@ public class Jobs extends JavaPlugin {
|
|||||||
|
|
||||||
if (jobinfo == null)
|
if (jobinfo == null)
|
||||||
continue;
|
continue;
|
||||||
|
if (!isBpOk(jPlayer.getPlayer(), info.getType(), block, true))
|
||||||
|
return;
|
||||||
Double income = jobinfo.getIncome(level, numjobs);
|
Double income = jobinfo.getIncome(level, numjobs);
|
||||||
Double pointAmount = jobinfo.getPoints(level, numjobs);
|
Double pointAmount = jobinfo.getPoints(level, numjobs);
|
||||||
Double expAmount = jobinfo.getExperience(level, numjobs);
|
Double expAmount = jobinfo.getExperience(level, numjobs);
|
||||||
@ -972,9 +974,6 @@ public class Jobs extends JavaPlugin {
|
|||||||
expAmount = 0D;
|
expAmount = 0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isBpOk(jPlayer, info, block))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (income == 0D && pointAmount == 0D && expAmount == 0D)
|
if (income == 0D && pointAmount == 0D && expAmount == 0D)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1009,14 +1008,14 @@ public class Jobs extends JavaPlugin {
|
|||||||
|
|
||||||
if (prog.addExperience(expAmount))
|
if (prog.addExperience(expAmount))
|
||||||
pManager.performLevelUp(jPlayer, prog.getJob(), oldLevel);
|
pManager.performLevelUp(jPlayer, prog.getJob(), oldLevel);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isBpOk(JobsPlayer jPlayer, ActionInfo info, Block block) {
|
private static boolean isBpOk(Player player, ActionType type, Block block, boolean inform) {
|
||||||
if (block != null && Jobs.getGCManager().useBlockProtection) {
|
if (block != null && Jobs.getGCManager().useBlockProtection) {
|
||||||
if (info.getType() == ActionType.BREAK) {
|
if (type == ActionType.BREAK) {
|
||||||
BlockProtection bp = Jobs.getBpManager().getBp(block.getLocation());
|
BlockProtection bp = Jobs.getBpManager().getBp(block.getLocation());
|
||||||
|
|
||||||
if (bp != null) {
|
if (bp != null) {
|
||||||
@ -1025,9 +1024,15 @@ public class Jobs extends JavaPlugin {
|
|||||||
return false;
|
return false;
|
||||||
Integer cd = Jobs.getBpManager().getBlockDelayTime(block);
|
Integer cd = Jobs.getBpManager().getBlockDelayTime(block);
|
||||||
|
|
||||||
if (time > System.currentTimeMillis() && bp.isPaid() && bp.getAction() != DBAction.DELETE) {
|
if (time < System.currentTimeMillis() && bp.getAction() != DBAction.DELETE) {
|
||||||
|
Jobs.getBpManager().remove(block);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((time > System.currentTimeMillis() || bp.isPaid()) && bp.getAction() != DBAction.DELETE) {
|
||||||
int sec = Math.round((time - System.currentTimeMillis()) / 1000);
|
int sec = Math.round((time - System.currentTimeMillis()) / 1000);
|
||||||
Jobs.getActionBar().send(jPlayer.getPlayer(), Jobs.getLanguage().getMessage("message.blocktimer", "[time]", sec));
|
if (inform)
|
||||||
|
Jobs.getActionBar().send(player, Jobs.getLanguage().getMessage("message.blocktimer", "[time]", sec));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1042,14 +1047,27 @@ public class Jobs extends JavaPlugin {
|
|||||||
Jobs.getBpManager().add(block, System.currentTimeMillis() + (Jobs.getGCManager().globalblocktimer * 1000));
|
Jobs.getBpManager().add(block, System.currentTimeMillis() + (Jobs.getGCManager().globalblocktimer * 1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (info.getType() == ActionType.PLACE) {
|
} else if (type == ActionType.PLACE) {
|
||||||
|
Debug.D("place");
|
||||||
BlockProtection bp = Jobs.getBpManager().getBp(block.getLocation());
|
BlockProtection bp = Jobs.getBpManager().getBp(block.getLocation());
|
||||||
if (bp != null) {
|
if (bp != null) {
|
||||||
|
Debug.D("bpp not null here");
|
||||||
Long time = bp.getTime();
|
Long time = bp.getTime();
|
||||||
if (time != -1) {
|
if (time != -1) {
|
||||||
if (time > System.currentTimeMillis() && bp.isPaid() && bp.getAction() != DBAction.DELETE) {
|
|
||||||
|
Debug.D("time is " + (time < System.currentTimeMillis()));
|
||||||
|
if (time < System.currentTimeMillis() && bp.getAction() != DBAction.DELETE) {
|
||||||
|
Jobs.getBpManager().remove(block);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.D("place " + ((time > System.currentTimeMillis() || bp.isPaid()) && bp.getAction() != DBAction.DELETE));
|
||||||
|
|
||||||
|
if ((time > System.currentTimeMillis() || bp.isPaid()) && bp.getAction() != DBAction.DELETE) {
|
||||||
|
Debug.D("here mufyn");
|
||||||
int sec = Math.round((time - System.currentTimeMillis()) / 1000);
|
int sec = Math.round((time - System.currentTimeMillis()) / 1000);
|
||||||
Jobs.getActionBar().send(jPlayer.getPlayer(), Jobs.getLanguage().getMessage("message.blocktimer", "[time]", sec));
|
if (inform)
|
||||||
|
Jobs.getActionBar().send(player, Jobs.getLanguage().getMessage("message.blocktimer", "[time]", sec));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (bp.isPaid()) {
|
} else if (bp.isPaid()) {
|
||||||
@ -1261,7 +1279,7 @@ public class Jobs extends JavaPlugin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void consoleMsg(String msg){
|
public static void consoleMsg(String msg) {
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,12 +40,12 @@ public class bp implements Cmd {
|
|||||||
BlockProtection bp = Jobs.getBpManager().getBp(l);
|
BlockProtection bp = Jobs.getBpManager().getBp(l);
|
||||||
if (bp != null) {
|
if (bp != null) {
|
||||||
Long time = bp.getTime();
|
Long time = bp.getTime();
|
||||||
if (bp.getAction() == DBAction.DELETE)
|
// if (bp.getAction() == DBAction.DELETE)
|
||||||
continue;
|
// continue;
|
||||||
if (time != -1 && time < System.currentTimeMillis()) {
|
// if (time != -1 && time < System.currentTimeMillis()) {
|
||||||
Jobs.getBpManager().remove(l);
|
// Jobs.getBpManager().remove(l);
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
changedBlocks.add(l.getBlock());
|
changedBlocks.add(l.getBlock());
|
||||||
if (time == -1)
|
if (time == -1)
|
||||||
player.sendBlockChange(l, Material.STAINED_GLASS, (byte) 15);
|
player.sendBlockChange(l, Material.STAINED_GLASS, (byte) 15);
|
||||||
|
@ -13,6 +13,7 @@ import com.gamingmesh.jobs.Jobs;
|
|||||||
import com.gamingmesh.jobs.container.BlockProtection;
|
import com.gamingmesh.jobs.container.BlockProtection;
|
||||||
import com.gamingmesh.jobs.container.DBAction;
|
import com.gamingmesh.jobs.container.DBAction;
|
||||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||||
|
import com.gamingmesh.jobs.stuff.Debug;
|
||||||
|
|
||||||
public class BlockProtectionManager {
|
public class BlockProtectionManager {
|
||||||
|
|
||||||
@ -54,6 +55,7 @@ public class BlockProtectionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void add(Block block, Integer cd, boolean paid) {
|
public void add(Block block, Integer cd, boolean paid) {
|
||||||
|
Debug.D("cd: " +cd);
|
||||||
if (cd == null)
|
if (cd == null)
|
||||||
return;
|
return;
|
||||||
if (cd != -1)
|
if (cd != -1)
|
||||||
@ -97,6 +99,7 @@ public class BlockProtectionManager {
|
|||||||
chunks.put(chunk, Bpm);
|
chunks.put(chunk, Bpm);
|
||||||
regions.put(region, chunks);
|
regions.put(region, chunks);
|
||||||
map.put(loc.getWorld(), regions);
|
map.put(loc.getWorld(), regions);
|
||||||
|
Debug.D("added new " + Bp.getAction());
|
||||||
return Bp;
|
return Bp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,11 +78,13 @@ import com.gamingmesh.jobs.actions.ItemActionInfo;
|
|||||||
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
||||||
import com.gamingmesh.jobs.container.ActionType;
|
import com.gamingmesh.jobs.container.ActionType;
|
||||||
import com.gamingmesh.jobs.container.BlockProtection;
|
import com.gamingmesh.jobs.container.BlockProtection;
|
||||||
|
import com.gamingmesh.jobs.container.DBAction;
|
||||||
import com.gamingmesh.jobs.container.ExploreRespond;
|
import com.gamingmesh.jobs.container.ExploreRespond;
|
||||||
import com.gamingmesh.jobs.container.FastPayment;
|
import com.gamingmesh.jobs.container.FastPayment;
|
||||||
import com.gamingmesh.jobs.container.JobProgression;
|
import com.gamingmesh.jobs.container.JobProgression;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||||
|
import com.gamingmesh.jobs.stuff.Debug;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
public class JobsPaymentListener implements Listener {
|
public class JobsPaymentListener implements Listener {
|
||||||
@ -329,8 +331,11 @@ public class JobsPaymentListener implements Listener {
|
|||||||
|
|
||||||
if (Jobs.getGCManager().useBlockProtection) {
|
if (Jobs.getGCManager().useBlockProtection) {
|
||||||
BlockProtection bp = Jobs.getBpManager().getBp(block.getLocation());
|
BlockProtection bp = Jobs.getBpManager().getBp(block.getLocation());
|
||||||
if (bp == null)
|
Debug.D("bp is null " + (bp == null));
|
||||||
|
if (bp == null || bp.getAction() == DBAction.DELETE)
|
||||||
Jobs.getBpManager().add(block, Jobs.getBpManager().getBlockDelayTime(block), false);
|
Jobs.getBpManager().add(block, Jobs.getBpManager().getBlockDelayTime(block), false);
|
||||||
|
// else
|
||||||
|
// Debug.D("bp is " + bp.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
|
Loading…
Reference in New Issue
Block a user