1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-02-18 05:11:32 +01:00

Include blocks from restrictedBlocks list when breaking with silktouch

This commit is contained in:
Zrips 2017-06-22 14:09:52 +03:00
parent 820e88c573
commit abd278dd09
3 changed files with 14 additions and 35 deletions

View File

@ -6,14 +6,11 @@ import java.util.Map.Entry;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.BlockProtection;
import com.gamingmesh.jobs.container.DBAction;
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
import com.gamingmesh.jobs.stuff.Debug;
public class BlockProtectionManager {
@ -38,20 +35,7 @@ public class BlockProtectionManager {
return i;
}
// public void add(Block block, boolean paid) {
// add(block, -1L, paid);
// }
//
// public void add(Block block) {
// add(block, -1L, true);
// }
// public void add(Block block, Long time, boolean paid) {
// add(block.getLocation(), time, paid);
// }
public void add(Block block, Integer cd) {
Debug.D("adding block timer " + cd);
add(block, cd, true);
}
@ -72,14 +56,6 @@ public class BlockProtectionManager {
addP(loc, -1L, paid);
}
// public void add(Block block, Long time) {
// add(block.getLocation(), time, true);
// }
//
// public void add(Location loc, Long time) {
// add(loc, time, true);
// }
public BlockProtection addP(Location loc, Long time, boolean paid) {
String v = loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ();
HashMap<String, HashMap<String, HashMap<String, BlockProtection>>> regions = map.get(loc.getWorld());
@ -177,4 +153,9 @@ public class BlockProtectionManager {
time = Jobs.getGCManager().globalblocktimer;
return time;
}
@SuppressWarnings("deprecation")
public boolean isInBp(Block block) {
return Jobs.getRestrictedBlockManager().restrictedBlocksTimer.get(block.getTypeId()) != null;
}
}

View File

@ -714,22 +714,17 @@ public abstract class JobsDAO {
ResultSet res = null;
try {
prest = conn.prepareStatement("SELECT userid, COUNT(*) AS amount, sum(level) AS totallvl FROM `" + prefix
prest = conn.prepareStatement("SELECT userid, COUNT(*) AS amount, sum(level) AS totallvl FROM `" + prefix
+ "jobs` GROUP BY userid ORDER BY totallvl DESC LIMIT " + start + ",20;");
res = prest.executeQuery();
while (res.next()) {
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(res.getInt("userid"));
if (info == null)
continue;
if (info.getName() == null)
continue;
TopList top = new TopList(info, res.getInt("totallvl"), 0);
names.add(top);
}
} catch (SQLException e) {

View File

@ -290,11 +290,14 @@ public class JobsPaymentListener implements Listener {
ItemStack item = Jobs.getNms().getItemInMainHand(player);
// Protection for block break with silktouch
if (Jobs.getGCManager().useSilkTouchProtection && item != null)
for (Entry<Enchantment, Integer> one : item.getEnchantments().entrySet())
if (one.getKey().getName().equalsIgnoreCase("SILK_TOUCH"))
return;
if (Jobs.getGCManager().useSilkTouchProtection && item != null) {
for (Entry<Enchantment, Integer> one : item.getEnchantments().entrySet()) {
if (one.getKey().getName().equalsIgnoreCase("SILK_TOUCH")) {
if (Jobs.getBpManager().isInBp(block))
return;
}
}
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
if (jPlayer == null)
return;