HullHider v2 #408
@ -21,6 +21,7 @@ package de.steamwar.fightsystem.utils;
|
|||||||
|
|
||||||
import com.comphenix.tinyprotocol.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
@ -56,4 +57,11 @@ public class BlockIdWrapper14 implements BlockIdWrapper {
|
|||||||
getTypeAndData.invoke(nworld, pos, blockData, 1042);
|
getTypeAndData.invoke(nworld, pos, blockData, 1042);
|
||||||
flagDirty.invoke(getChunkProvider.invoke(nworld), pos);
|
flagDirty.invoke(getChunkProvider.invoke(nworld), pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Reflection.MethodInvoker getMaterialByBlock = Reflection.getTypedMethod(Reflection.getClass("{obc}.util.CraftMagicNumbers"), "getMaterial", Material.class, block);
|
||||||
|
private static final Reflection.MethodInvoker getBlockByBlockData = Reflection.getTypedMethod(iBlockData, null, block);
|
||||||
|
@Override
|
||||||
|
public Material idToMaterial(int blockState) {
|
||||||
|
return (Material)getMaterialByBlock.invoke(null, getBlockByBlockData.invoke(getByCombinedId.invoke(null, blockState)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
@ -37,4 +38,13 @@ public class BlockIdWrapper8 implements BlockIdWrapper {
|
|||||||
|
|
||||||
world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false);
|
world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public Material idToMaterial(int blockState) {
|
||||||
|
if((blockState >> 4) > 256) // Illegal blockstate / corrupted replay
|
||||||
|
blockState = 0;
|
||||||
|
|
||||||
|
return Material.getMaterial(blockState >> 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -437,7 +437,10 @@ public class PacketProcessor implements Listener {
|
|||||||
if(!Config.ArenaRegion.in2dRegion(x, z))
|
if(!Config.ArenaRegion.in2dRegion(x, z))
|
||||||
return; //Outside of the arena
|
return; //Outside of the arena
|
||||||
|
|
||||||
execSync(() -> BlockIdWrapper.impl.setBlock(Config.world, x, y, z, TechHiderWrapper.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState));
|
execSync(() -> {
|
||||||
|
BlockIdWrapper.impl.setBlock(Config.world, x, y, z, TechHiderWrapper.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState);
|
||||||
|
FightSystem.getHullHider().blockUpdate(Config.world.getBlockAt(x, y, z), BlockIdWrapper.impl.idToMaterial(blockState));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void particle() throws IOException {
|
private void particle() throws IOException {
|
||||||
|
@ -21,12 +21,14 @@ package de.steamwar.fightsystem.utils;
|
|||||||
|
|
||||||
import de.steamwar.core.VersionDependent;
|
import de.steamwar.core.VersionDependent;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
public interface BlockIdWrapper {
|
public interface BlockIdWrapper {
|
||||||
BlockIdWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
BlockIdWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||||
|
|
||||||
|
Material idToMaterial(int blockState);
|
||||||
int blockToId(Block block);
|
int blockToId(Block block);
|
||||||
void setBlock(World world, int x, int y, int z, int blockState);
|
void setBlock(World world, int x, int y, int z, int blockState);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.listener.Recording;
|
import de.steamwar.fightsystem.listener.Recording;
|
||||||
@ -27,6 +28,8 @@ import de.steamwar.fightsystem.states.StateDependent;
|
|||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -43,6 +46,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class HullHider implements Listener {
|
public class HullHider implements Listener {
|
||||||
|
|
||||||
|
private static final boolean ENABLED = TechHiderWrapper.ENABLED && Core.getVersion() >= 18;
|
||||||
private final Map<FightTeam, Hull> hulls = new HashMap<>();
|
private final Map<FightTeam, Hull> hulls = new HashMap<>();
|
||||||
|
|
||||||
//SpawnPackets: PacketPlayOutSpawnEntity, PacketPlayOutSpawnEntityWeather, PacketPlayOutSpawnEntityLiving, PacketPlayOutSpawnEntityPainting, PacketPlayOutSpawnEntityPlayer
|
//SpawnPackets: PacketPlayOutSpawnEntity, PacketPlayOutSpawnEntityWeather, PacketPlayOutSpawnEntityLiving, PacketPlayOutSpawnEntityPainting, PacketPlayOutSpawnEntityPlayer
|
||||||
@ -51,11 +55,11 @@ public class HullHider implements Listener {
|
|||||||
//Other: Effect, Particle, Explosion
|
//Other: Effect, Particle, Explosion
|
||||||
//Death: DestroyEntities
|
//Death: DestroyEntities
|
||||||
public HullHider() {
|
public HullHider() {
|
||||||
if(TechHiderWrapper.ENABLED)
|
if(ENABLED)
|
||||||
Fight.teams().forEach(team -> hulls.put(team, new Hull(team)));
|
Fight.teams().forEach(team -> hulls.put(team, new Hull(team)));
|
||||||
|
|
||||||
new StateDependentListener(TechHiderWrapper.ENABLED, FightState.Schem, this);
|
new StateDependentListener(ENABLED, FightState.Schem, this);
|
||||||
new StateDependent(TechHiderWrapper.ENABLED, FightState.Schem) {
|
new StateDependent(ENABLED, FightState.Schem) {
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> addPlayer(player, true));
|
Bukkit.getOnlinePlayers().forEach(player -> addPlayer(player, true));
|
||||||
@ -65,12 +69,12 @@ public class HullHider implements Listener {
|
|||||||
public void disable() {
|
public void disable() {
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> removePlayer(player, true));
|
Bukkit.getOnlinePlayers().forEach(player -> removePlayer(player, true));
|
||||||
}
|
}
|
||||||
};
|
}.register();
|
||||||
new StateDependentTask(TechHiderWrapper.ENABLED, FightState.Schem, this::onTick, 0, 1);
|
new StateDependentTask(ENABLED, FightState.Schem, this::onTick, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize(FightTeam team) {
|
public void initialize(FightTeam team) {
|
||||||
if(!TechHiderWrapper.ENABLED)
|
if(!ENABLED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hulls.get(team).initialize();
|
hulls.get(team).initialize();
|
||||||
@ -78,14 +82,14 @@ public class HullHider implements Listener {
|
|||||||
|
|
||||||
|
|
||||||
public void addPlayer(FightTeam team, Player player) {
|
public void addPlayer(FightTeam team, Player player) {
|
||||||
if(!TechHiderWrapper.ENABLED)
|
if(!ENABLED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hulls.get(team).addPlayer(player, true);
|
hulls.get(team).addPlayer(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(FightTeam team, Player player) {
|
public void removePlayer(FightTeam team, Player player) {
|
||||||
if(!TechHiderWrapper.ENABLED)
|
if(!ENABLED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hulls.get(team).removePlayer(player, true);
|
hulls.get(team).removePlayer(player, true);
|
||||||
@ -118,10 +122,13 @@ public class HullHider implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onBlockPhysic(BlockPhysicsEvent e) {
|
public void onBlockPhysic(BlockPhysicsEvent e) {
|
||||||
if(FlatteningWrapper.impl.doRecord(e)) {
|
if(FlatteningWrapper.impl.doRecord(e))
|
||||||
for (Hull hull : hulls.values())
|
blockUpdate(e.getBlock(), e.getChangedType());
|
||||||
hull.updateBlockVisibility(e.getBlock(), e.getChangedType());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void blockUpdate(Block block, Material changedType) {
|
||||||
|
for (Hull hull : hulls.values())
|
||||||
|
hull.updateBlockVisibility(block, changedType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren