Fixing Waterremover and deadlock
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
abd3246d85
Commit
684ed70219
@ -1,11 +1,11 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
class WaterRemover_10 {
|
class WaterRemover_10 {
|
||||||
private WaterRemover_10(){}
|
private WaterRemover_10(){}
|
||||||
|
|
||||||
static boolean isWater(Material type){
|
static boolean isWater(Block block){
|
||||||
return WaterRemover_8.isWater(type);
|
return WaterRemover_8.isWater(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
class WaterRemover_12 {
|
class WaterRemover_12 {
|
||||||
private WaterRemover_12(){}
|
private WaterRemover_12(){}
|
||||||
|
|
||||||
static boolean isWater(Material type){
|
static boolean isWater(Block block){
|
||||||
return WaterRemover_8.isWater(type);
|
return WaterRemover_8.isWater(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,21 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.block.data.Waterlogged;
|
||||||
|
|
||||||
class WaterRemover_14 {
|
class WaterRemover_14 {
|
||||||
private WaterRemover_14(){}
|
private WaterRemover_14(){}
|
||||||
|
|
||||||
static boolean isWater(Material type){
|
static boolean isWater(Block block){
|
||||||
return type == Material.WATER;
|
if(block.getType() == Material.WATER)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
BlockData data = block.getBlockData();
|
||||||
|
if(!(data instanceof Waterlogged))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return ((Waterlogged) data).isWaterlogged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public class TechHider_15 {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cached = packet.deepClone();
|
cached = packet.shallowClone();
|
||||||
ITechHider.packetCache.put(packet, cached);
|
ITechHider.packetCache.put(packet, cached);
|
||||||
e.setPacket(cached);
|
e.setPacket(cached);
|
||||||
StructureModifier<List<NbtBase<?>>> list = cached.getListNbtModifier();
|
StructureModifier<List<NbtBase<?>>> list = cached.getListNbtModifier();
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
class WaterRemover_15 {
|
class WaterRemover_15 {
|
||||||
private WaterRemover_15(){}
|
private WaterRemover_15(){}
|
||||||
|
|
||||||
static boolean isWater(Material type){
|
static boolean isWater(Block block){
|
||||||
return WaterRemover_14.isWater(type);
|
return WaterRemover_14.isWater(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
public class WaterRemover_8 {
|
public class WaterRemover_8 {
|
||||||
private WaterRemover_8(){}
|
private WaterRemover_8(){}
|
||||||
|
|
||||||
static boolean isWater(Material type){
|
static boolean isWater(Block block){
|
||||||
|
Material type = block.getType();
|
||||||
return type == Material.WATER || type == Material.STATIONARY_WATER;
|
return type == Material.WATER || type == Material.STATIONARY_WATER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
class WaterRemover_9 {
|
class WaterRemover_9 {
|
||||||
private WaterRemover_9(){}
|
private WaterRemover_9(){}
|
||||||
|
|
||||||
static boolean isWater(Material type){
|
static boolean isWater(Block block){
|
||||||
return WaterRemover_8.isWater(type);
|
return WaterRemover_8.isWater(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public class WaterRemover {
|
|||||||
|
|
||||||
private WaterRemover(){}
|
private WaterRemover(){}
|
||||||
|
|
||||||
private static final Map<Location, Integer> explodedBlocks = new HashMap<>();
|
private static final Map<Location, Integer> explodedBlocks = Collections.synchronizedMap(new HashMap<>());
|
||||||
private static Set<Block> waterList = new HashSet<>();
|
private static Set<Block> waterList = new HashSet<>();
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
@ -25,18 +25,16 @@ public class WaterRemover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void add(List<Block> l) {
|
public static void add(List<Block> l) {
|
||||||
synchronized (explodedBlocks){
|
|
||||||
l.forEach((Block b) -> explodedBlocks.put(b.getLocation(), 0));
|
l.forEach((Block b) -> explodedBlocks.put(b.getLocation(), 0));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static void wateredCheck() {
|
private static void wateredCheck() {
|
||||||
synchronized (explodedBlocks){
|
try{
|
||||||
Iterator<Map.Entry<Location, Integer>> it = explodedBlocks.entrySet().iterator();
|
Iterator<Map.Entry<Location, Integer>> it = explodedBlocks.entrySet().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Map.Entry<Location, Integer> e = it.next();
|
Map.Entry<Location, Integer> e = it.next();
|
||||||
Block b = e.getKey().getBlock();
|
Block b = e.getKey().getBlock();
|
||||||
if (isWater(b.getType()))
|
if (isWater(b))
|
||||||
waterList.add(b);
|
waterList.add(b);
|
||||||
|
|
||||||
if(b.getType() != Material.AIR){
|
if(b.getType() != Material.AIR){
|
||||||
@ -48,6 +46,8 @@ public class WaterRemover {
|
|||||||
if(e.getValue() > 15)
|
if(e.getValue() > 15)
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
|
}catch(ConcurrentModificationException e){
|
||||||
|
wateredCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public class WaterRemover {
|
|||||||
while(it.hasNext()){
|
while(it.hasNext()){
|
||||||
Block b = it.next();
|
Block b = it.next();
|
||||||
blocksToRemove.addAll(getSourceBlocksOfWater(b));
|
blocksToRemove.addAll(getSourceBlocksOfWater(b));
|
||||||
if (!isWater(b.getType()))
|
if (!isWater(b))
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,13 +72,13 @@ public class WaterRemover {
|
|||||||
|
|
||||||
private static void collectBlocks(Block anchor, Set<Block> collected, Set<Block> visitedBlocks) {
|
private static void collectBlocks(Block anchor, Set<Block> collected, Set<Block> visitedBlocks) {
|
||||||
if(
|
if(
|
||||||
!isWater(anchor.getType()) ||
|
!isWater(anchor) ||
|
||||||
visitedBlocks.contains(anchor)
|
visitedBlocks.contains(anchor)
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
visitedBlocks.add(anchor);
|
visitedBlocks.add(anchor);
|
||||||
if (isWater(anchor.getType()))
|
if (isWater(anchor))
|
||||||
collected.add(anchor);
|
collected.add(anchor);
|
||||||
|
|
||||||
if(visitedBlocks.size() > 100) {
|
if(visitedBlocks.size() > 100) {
|
||||||
@ -92,20 +92,20 @@ public class WaterRemover {
|
|||||||
collectBlocks(anchor.getRelative(BlockFace.WEST), collected, visitedBlocks);
|
collectBlocks(anchor.getRelative(BlockFace.WEST), collected, visitedBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWater(Material type){
|
public static boolean isWater(Block block){
|
||||||
switch(Core.getVersion()){
|
switch(Core.getVersion()){
|
||||||
case 15:
|
case 15:
|
||||||
return WaterRemover_15.isWater(type);
|
return WaterRemover_15.isWater(block);
|
||||||
case 14:
|
case 14:
|
||||||
return WaterRemover_14.isWater(type);
|
return WaterRemover_14.isWater(block);
|
||||||
case 10:
|
case 10:
|
||||||
return WaterRemover_10.isWater(type);
|
return WaterRemover_10.isWater(block);
|
||||||
case 9:
|
case 9:
|
||||||
return WaterRemover_9.isWater(type);
|
return WaterRemover_9.isWater(block);
|
||||||
case 8:
|
case 8:
|
||||||
return WaterRemover_8.isWater(type);
|
return WaterRemover_8.isWater(block);
|
||||||
default:
|
default:
|
||||||
return WaterRemover_12.isWater(type);
|
return WaterRemover_12.isWater(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,11 @@ package de.steamwar.fightsystem.winconditions;
|
|||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.utils.WaterRemover;
|
import de.steamwar.fightsystem.utils.WaterRemover;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@ -96,8 +95,7 @@ public class WinconditionWaterTechKO extends Wincondition {
|
|||||||
for(int x = minX; x <= maxX; x++) {
|
for(int x = minX; x <= maxX; x++) {
|
||||||
for(int y = minY; y <= maxY; y++) {
|
for(int y = minY; y <= maxY; y++) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
Material type = WORLD.getBlockAt(x, y, z).getType();
|
if (WaterRemover.isWater(WORLD.getBlockAt(x, y, z)))
|
||||||
if (WaterRemover.isWater(type))
|
|
||||||
teamWater.add(new Location(WORLD, x, y, z));
|
teamWater.add(new Location(WORLD, x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren