1.15 #111
@ -1,11 +1,11 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
class WaterRemover_10 {
|
||||
private WaterRemover_10(){}
|
||||
|
||||
static boolean isWater(Material type){
|
||||
return WaterRemover_8.isWater(type);
|
||||
static boolean isWater(Block block){
|
||||
return WaterRemover_8.isWater(block);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
class WaterRemover_12 {
|
||||
private WaterRemover_12(){}
|
||||
|
||||
static boolean isWater(Material type){
|
||||
return WaterRemover_8.isWater(type);
|
||||
static boolean isWater(Block block){
|
||||
return WaterRemover_8.isWater(block);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,21 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
|
||||
class WaterRemover_14 {
|
||||
private WaterRemover_14(){}
|
||||
|
||||
static boolean isWater(Material type){
|
||||
return type == Material.WATER;
|
||||
static boolean isWater(Block block){
|
||||
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;
|
||||
}
|
||||
|
||||
cached = packet.deepClone();
|
||||
cached = packet.shallowClone();
|
||||
ITechHider.packetCache.put(packet, cached);
|
||||
e.setPacket(cached);
|
||||
StructureModifier<List<NbtBase<?>>> list = cached.getListNbtModifier();
|
||||
|
@ -1,11 +1,11 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
class WaterRemover_15 {
|
||||
private WaterRemover_15(){}
|
||||
|
||||
static boolean isWater(Material type){
|
||||
return WaterRemover_14.isWater(type);
|
||||
static boolean isWater(Block block){
|
||||
return WaterRemover_14.isWater(block);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public class 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;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
class WaterRemover_9 {
|
||||
private WaterRemover_9(){}
|
||||
|
||||
static boolean isWater(Material type){
|
||||
return WaterRemover_8.isWater(type);
|
||||
static boolean isWater(Block block){
|
||||
return WaterRemover_8.isWater(block);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class 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<>();
|
||||
|
||||
public static void init() {
|
||||
@ -25,18 +25,16 @@ public class WaterRemover {
|
||||
}
|
||||
|
||||
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() {
|
||||
synchronized (explodedBlocks){
|
||||
try{
|
||||
Iterator<Map.Entry<Location, Integer>> it = explodedBlocks.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<Location, Integer> e = it.next();
|
||||
Block b = e.getKey().getBlock();
|
||||
if (isWater(b.getType()))
|
||||
if (isWater(b))
|
||||
waterList.add(b);
|
||||
|
||||
if(b.getType() != Material.AIR){
|
||||
@ -48,6 +46,8 @@ public class WaterRemover {
|
||||
if(e.getValue() > 15)
|
||||
it.remove();
|
||||
}
|
||||
}catch(ConcurrentModificationException e){
|
||||
wateredCheck();
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public class WaterRemover {
|
||||
while(it.hasNext()){
|
||||
Block b = it.next();
|
||||
blocksToRemove.addAll(getSourceBlocksOfWater(b));
|
||||
if (!isWater(b.getType()))
|
||||
if (!isWater(b))
|
||||
it.remove();
|
||||
}
|
||||
|
||||
@ -72,13 +72,13 @@ public class WaterRemover {
|
||||
|
||||
private static void collectBlocks(Block anchor, Set<Block> collected, Set<Block> visitedBlocks) {
|
||||
if(
|
||||
!isWater(anchor.getType()) ||
|
||||
!isWater(anchor) ||
|
||||
visitedBlocks.contains(anchor)
|
||||
)
|
||||
return;
|
||||
|
||||
visitedBlocks.add(anchor);
|
||||
if (isWater(anchor.getType()))
|
||||
if (isWater(anchor))
|
||||
collected.add(anchor);
|
||||
|
||||
if(visitedBlocks.size() > 100) {
|
||||
@ -92,20 +92,20 @@ public class WaterRemover {
|
||||
collectBlocks(anchor.getRelative(BlockFace.WEST), collected, visitedBlocks);
|
||||
}
|
||||
|
||||
public static boolean isWater(Material type){
|
||||
public static boolean isWater(Block block){
|
||||
switch(Core.getVersion()){
|
||||
case 15:
|
||||
return WaterRemover_15.isWater(type);
|
||||
return WaterRemover_15.isWater(block);
|
||||
case 14:
|
||||
return WaterRemover_14.isWater(type);
|
||||
return WaterRemover_14.isWater(block);
|
||||
case 10:
|
||||
return WaterRemover_10.isWater(type);
|
||||
return WaterRemover_10.isWater(block);
|
||||
case 9:
|
||||
return WaterRemover_9.isWater(type);
|
||||
return WaterRemover_9.isWater(block);
|
||||
case 8:
|
||||
return WaterRemover_8.isWater(type);
|
||||
return WaterRemover_8.isWater(block);
|
||||
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.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.WaterRemover;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@ -96,8 +95,7 @@ public class WinconditionWaterTechKO extends Wincondition {
|
||||
for(int x = minX; x <= maxX; x++) {
|
||||
for(int y = minY; y <= maxY; y++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
Material type = WORLD.getBlockAt(x, y, z).getType();
|
||||
if (WaterRemover.isWater(type))
|
||||
if (WaterRemover.isWater(WORLD.getBlockAt(x, y, z)))
|
||||
teamWater.add(new Location(WORLD, x, y, z));
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren