forked from SteamWar/SteamWar
Sync with base branch
This commit is contained in:
@@ -110,6 +110,7 @@ public class FightSystem extends JavaPlugin {
|
||||
|
||||
hullHider = new HullHider();
|
||||
techHider = new TechHiderWrapper(hullHider);
|
||||
FightSystem.getHullHider().getHullMap().values().forEach(hull -> hull.fill(true));
|
||||
|
||||
|
||||
FileSource.startReplay();
|
||||
|
||||
@@ -158,6 +158,8 @@ public class FightSchematic extends StateDependent {
|
||||
FreezeWorld freezer = new FreezeWorld();
|
||||
|
||||
team.teleportToSpawn();
|
||||
// TODO: Implement hull generation based on clipboard content!
|
||||
FightSystem.getHullHider().fill(team, false);
|
||||
Vector dims = WorldeditWrapper.impl.getDimensions(clipboard);
|
||||
WorldeditWrapper.impl.pasteClipboard(
|
||||
clipboard,
|
||||
|
||||
@@ -68,6 +68,13 @@ public class FightWorld extends StateDependent {
|
||||
}
|
||||
|
||||
public static void resetWorld() {
|
||||
World backup = new WorldCreator(Config.world.getName() + "/backup").createWorld();
|
||||
assert backup != null;
|
||||
Config.ArenaRegion.forEachChunk((x, z) -> {
|
||||
CraftbukkitWrapper.impl.resetChunk(Config.world, backup, x, z);
|
||||
});
|
||||
Bukkit.unloadWorld(backup, false);
|
||||
|
||||
List<Entity> entities = new ArrayList<>();
|
||||
Recording.iterateOverEntities(Objects::nonNull, entity -> {
|
||||
if (entity.getType() != EntityType.PLAYER && (!Config.GameModeConfig.Arena.Leaveable || Config.ArenaRegion.inRegion(entity.getLocation()))) {
|
||||
@@ -77,14 +84,12 @@ public class FightWorld extends StateDependent {
|
||||
entities.forEach(Entity::remove);
|
||||
entities.clear();
|
||||
|
||||
World backup = new WorldCreator(Config.world.getName() + "/backup").createWorld();
|
||||
assert backup != null;
|
||||
FightSystem.getHullHider().getHullMap().values().forEach(hull -> hull.fill(true));
|
||||
|
||||
Config.ArenaRegion.forEachChunk((x, z) -> {
|
||||
CraftbukkitWrapper.impl.resetChunk(Config.world, backup, x, z);
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
de.steamwar.core.CraftbukkitWrapper.sendChunk(p, x, z);
|
||||
}
|
||||
});
|
||||
Bukkit.unloadWorld(backup, false);
|
||||
}
|
||||
}
|
||||
@@ -165,6 +165,15 @@ public class Hull {
|
||||
rentities.remove(entity);
|
||||
}
|
||||
|
||||
public void fill(boolean visible) {
|
||||
visibility.set(0, visibility.size(), visible);
|
||||
occluding.set(0, occluding.size(), !visible);
|
||||
uncoveredSurface.clear();
|
||||
for (BitSet directionalVisibility : visibilityDirections.values()) {
|
||||
directionalVisibility.set(0, directionalVisibility.size(), visible);
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
visibility.clear();
|
||||
occluding.clear();
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
@@ -28,17 +26,9 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.Recording;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.network.protocol.game.ClientboundExplodePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundLevelEventPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -54,8 +44,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class HullHider implements Listener {
|
||||
|
||||
@@ -79,10 +67,13 @@ public class HullHider implements Listener {
|
||||
|
||||
public void initialize(FightTeam team) {
|
||||
if (!TechHiderWrapper.ENABLED) return;
|
||||
|
||||
hullMap.get(team).initialize();
|
||||
}
|
||||
|
||||
public void fill(FightTeam team, boolean visible) {
|
||||
if (!TechHiderWrapper.ENABLED) return;
|
||||
hullMap.get(team).fill(visible);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
|
||||
+11
-4
@@ -38,6 +38,7 @@ import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -60,7 +61,7 @@ public class TechHiderWrapper extends StateDependent implements Listener {
|
||||
|
||||
|
||||
public TechHiderWrapper(HullHider hullHider) {
|
||||
super(ENABLED, FightState.Schem);
|
||||
super(ENABLED, FightState.All);
|
||||
Set<Block> blocksToObfuscate = Config.GameModeConfig.Techhider.HiddenBlocks.stream()
|
||||
.map(CraftMagicNumbers::getBlock)
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
@@ -91,6 +92,7 @@ public class TechHiderWrapper extends StateDependent implements Listener {
|
||||
return !hiddenRegion.inRegion(blockX, blockY, blockZ) || !blocksToObfuscate.contains(block);
|
||||
}
|
||||
|
||||
// TODO will require entity tracking on the netty thread to prevent future race conditions
|
||||
@Override
|
||||
public boolean isPlayerPrivilegedToAccessEntity(Player p, int entityId) {
|
||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftWorld) p.getWorld()).getHandle().moonrise$getEntityLookup().get(entityId);
|
||||
@@ -99,12 +101,12 @@ public class TechHiderWrapper extends StateDependent implements Listener {
|
||||
return !hullHider.isBlockHidden(p, nmsEntity.getBlockX(), nmsEntity.getBlockY(), nmsEntity.getBlockZ());
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerPrivilegedToAccessBlocEntity(Player p, int blockX, int blockY, int blockZ, BlockEntityType<?> type) {
|
||||
public boolean isPlayerPrivilegedToAccessBlockEntity(Player p, int blockX, int blockY, int blockZ, BlockEntityType<?> type) {
|
||||
Region hiddenRegion = getHiddenRegion(p);
|
||||
return !hiddenRegion.inRegion(blockX, blockY, blockZ) || !blockEntityTypeToObfuscate.contains(type);
|
||||
}
|
||||
@@ -113,9 +115,14 @@ public class TechHiderWrapper extends StateDependent implements Listener {
|
||||
public boolean isEveryonePrivilegedToAccessAllDataWithinChunk(int chunkX, int chunkZ) {
|
||||
return getHiddenRegions().stream().allMatch(region -> region.chunkOutside(chunkX, chunkZ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerPrivalegedToPerformAction(Player p) {
|
||||
return !(p.getGameMode() == GameMode.SPECTATOR);
|
||||
}
|
||||
};
|
||||
|
||||
new StateDependentListener(ENABLED, FightState.Schem, this);
|
||||
new StateDependentListener(ENABLED, FightState.All, this);
|
||||
register();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user