Omni-Replay #280
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
@ -27,6 +28,7 @@ import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -38,7 +40,6 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import de.steamwar.sql.NoClipboardException;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -102,7 +103,7 @@ public class FightTeam_14 {
|
||||
}
|
||||
}
|
||||
|
||||
static void pasteSchematic(Clipboard clipboard, Region region, boolean rotate) throws NoClipboardException {
|
||||
static void pasteSchematic(Clipboard clipboard, Region region, boolean rotate) {
|
||||
BlockVector3 paste = BlockVector3.at(region.centerX(), region.getMinY(), region.centerZ());
|
||||
|
||||
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||
@ -134,6 +135,23 @@ public class FightTeam_14 {
|
||||
e.flushSession();
|
||||
}
|
||||
|
||||
static void pasteChar(Clipboard character, int charOffset, int length, int x, int y, int z, AffineTransform aT){
|
||||
BlockVector3 offset = character.getRegion().getMinimumPoint().subtract(character.getOrigin());
|
||||
BlockVector3 v = BlockVector3.ZERO.subtract(- charOffset + length / 2, 0, 0).subtract(offset);
|
||||
v = aT.apply(v.toVector3()).toBlockPoint();
|
||||
v = v.add(x, y, z);
|
||||
|
||||
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1);
|
||||
ClipboardHolder ch = new ClipboardHolder(character);
|
||||
ch.setTransform(aT);
|
||||
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(true).build());
|
||||
e.flushSession();
|
||||
}
|
||||
|
||||
static Clipboard loadSchem(NBTInputStream stream) throws IOException {
|
||||
return new SpongeSchematicReader(stream).read();
|
||||
}
|
||||
|
||||
public static boolean checkPistonMoving(Block block){
|
||||
return block.getType() == Material.MOVING_PISTON;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -29,6 +30,7 @@ import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.SchematicReader;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
@ -37,7 +39,6 @@ import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import de.steamwar.sql.NoClipboardException;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -99,7 +100,7 @@ public class FightTeam_8 {
|
||||
}
|
||||
}
|
||||
|
||||
static void pasteSchematic(Clipboard clipboard, Region paste, boolean rotate) throws NoClipboardException {
|
||||
static void pasteSchematic(Clipboard clipboard, Region paste, boolean rotate) {
|
||||
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||
Vector dimensions = clipboard.getDimensions();
|
||||
Vector v = new Vector(paste.centerX(), paste.getMinY(), paste.centerZ());
|
||||
@ -129,6 +130,24 @@ public class FightTeam_8 {
|
||||
e.flushQueue();
|
||||
}
|
||||
|
||||
static void pasteChar(Clipboard character, int charOffset, int length, int x, int y, int z, AffineTransform aT){
|
||||
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||
Vector offset = character.getRegion().getMinimumPoint().subtract(character.getOrigin());
|
||||
Vector v = Vector.ZERO.subtract(- charOffset + length / 2, 0, 0).subtract(offset);
|
||||
v = aT.apply(v).toBlockPoint();
|
||||
v = v.add(x, y, z);
|
||||
|
||||
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
|
||||
ClipboardHolder ch = new ClipboardHolder(character, w.getWorldData());
|
||||
ch.setTransform(aT);
|
||||
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(v).build());
|
||||
e.flushQueue();
|
||||
}
|
||||
|
||||
static Clipboard loadSchem(NBTInputStream stream) throws IOException {
|
||||
return new SchematicReader(stream).read(new BukkitWorld(Bukkit.getWorlds().get(0)).getWorldData());
|
||||
}
|
||||
|
||||
public static boolean checkPistonMoving(Block block){
|
||||
return block.getType() == Material.PISTON_MOVING_PIECE;
|
||||
}
|
||||
|
@ -71,6 +71,10 @@ public class Region {
|
||||
return maxZ;
|
||||
}
|
||||
|
||||
public int getSizeZ() {
|
||||
return maxZ - minZ;
|
||||
}
|
||||
|
||||
public double posToChunk(int pos){
|
||||
return pos / 16.0;
|
||||
}
|
||||
|
@ -19,8 +19,11 @@
|
||||
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import de.steamwar.core.VersionedCallable;
|
||||
import de.steamwar.core.VersionedRunnable;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
@ -30,7 +33,6 @@ import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import de.steamwar.sql.NoClipboardException;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
@ -39,10 +41,14 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class FightSchematic extends StateDependent {
|
||||
|
||||
@ -75,7 +81,7 @@ public class FightSchematic extends StateDependent {
|
||||
clipboard = schem.load();
|
||||
} catch (IOException e) {
|
||||
team.broadcast(FightSystem.PREFIX + "§cKonnte die Schematic nicht laden!");
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Couldn't load Schematic " + schem.getSchemName(), e);
|
||||
Bukkit.getLogger().log(Level.SEVERE, e, () -> "Couldn't load Schematic " + schem.getSchemName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,33 +117,38 @@ public class FightSchematic extends StateDependent {
|
||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste);
|
||||
}
|
||||
|
||||
private void paste(){
|
||||
FreezeWorld freezer = new FreezeWorld();
|
||||
private void replaceTeamColor(Clipboard clipboard){
|
||||
DyeColor c = ArenaMode.AntiPrepare.contains(Config.mode) ? ColorConverter.chat2dye(team.getColor()) : DyeColor.PINK;
|
||||
|
||||
try {
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||
try {
|
||||
FightTeam_8.replaceTeamColor(clipboard, c);
|
||||
FightTeam_8.pasteSchematic(clipboard, region, rotate);
|
||||
} catch (NoClipboardException | WorldEditException ex) {
|
||||
throw new SecurityException("Error pasting schematic", ex);
|
||||
} catch (WorldEditException ex) {
|
||||
throw new SecurityException("Error recoloring schematic", ex);
|
||||
}
|
||||
}, 8), new VersionedRunnable(() -> {
|
||||
}, 8),
|
||||
new VersionedRunnable(() -> {
|
||||
try {
|
||||
FightTeam_12.replaceTeamColor(clipboard, c);
|
||||
FightTeam_8.pasteSchematic(clipboard, region, rotate);
|
||||
} catch (NoClipboardException | WorldEditException ex) {
|
||||
throw new SecurityException("Error pasting schematic", ex);
|
||||
} catch (WorldEditException ex) {
|
||||
throw new SecurityException("Error recoloring schematic", ex);
|
||||
}
|
||||
}, 12), new VersionedRunnable(() -> {
|
||||
}, 12),
|
||||
new VersionedRunnable(() -> {
|
||||
try {
|
||||
FightTeam_14.replaceTeamColor(clipboard, c);
|
||||
FightTeam_14.pasteSchematic(clipboard, region, rotate);
|
||||
} catch (NoClipboardException | WorldEditException ex) {
|
||||
throw new SecurityException("Error pasting schematic", ex);
|
||||
} catch (WorldEditException ex) {
|
||||
throw new SecurityException("Error recoloring schematic", ex);
|
||||
}
|
||||
}, 14));
|
||||
}
|
||||
|
||||
private void paste(){
|
||||
FreezeWorld freezer = new FreezeWorld();
|
||||
|
||||
try {
|
||||
replaceTeamColor(clipboard);
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.pasteSchematic(clipboard, region, rotate), 8),
|
||||
new VersionedRunnable(() -> FightTeam_14.pasteSchematic(clipboard, region, rotate), 14));
|
||||
} catch (SecurityException securityException) {
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic");
|
||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), FightSystem::setPreSchemState);
|
||||
@ -148,6 +159,62 @@ public class FightSchematic extends StateDependent {
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40);
|
||||
}
|
||||
|
||||
private Clipboard loadTextSchem(String schemName){
|
||||
return VersionedCallable.call(new VersionedCallable<>(() -> FightTeam_8.loadSchem(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + schemName + ".schematic"))))), 8),
|
||||
new VersionedCallable<>(() -> FightTeam_14.loadSchem(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + schemName + ".schem"))))), 14));
|
||||
}
|
||||
|
||||
public void pasteTeamName(){
|
||||
List<Clipboard> characters = new ArrayList<>();
|
||||
for(char c : team.getName().toCharArray()){
|
||||
try {
|
||||
try {
|
||||
characters.add(loadTextSchem(c == '/' ? "slash" : String.valueOf(c)));
|
||||
} catch (RuntimeException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not display character {} due to missing file!", c);
|
||||
characters.add(loadTextSchem(""));
|
||||
}
|
||||
}catch (RuntimeException e) {
|
||||
throw new SecurityException("Could not load text", e);
|
||||
}
|
||||
}
|
||||
|
||||
//Calc character sizes
|
||||
int[] lengthes = new int[characters.size()];
|
||||
for(int i = 0; i < lengthes.length; i++)
|
||||
lengthes[i] = characters.get(i).getDimensions().getBlockX();
|
||||
|
||||
//Calc character offsets
|
||||
int[] offsets = new int[lengthes.length];
|
||||
int previousOffset = 0;
|
||||
for(int i = 0; i < offsets.length; i++){
|
||||
offsets[i] = previousOffset;
|
||||
previousOffset += lengthes[i] + 1; // 1 is the distance between characters
|
||||
}
|
||||
|
||||
int length = lengthes.length == 0 ? 0 : lengthes[lengthes.length - 1] + offsets[offsets.length - 1];
|
||||
|
||||
int z = team.getSchemRegion().centerZ();
|
||||
AffineTransform aT = new AffineTransform();
|
||||
|
||||
if(rotate){
|
||||
aT = aT.rotateY(180);
|
||||
z += team.getSchemRegion().getSizeZ() / 2;
|
||||
}else{
|
||||
z -= team.getSchemRegion().getSizeZ() / 2;
|
||||
}
|
||||
|
||||
for(int i = 0; i < characters.size(); i++){
|
||||
replaceTeamColor(characters.get(i));
|
||||
pasteChar(characters.get(i), offsets[i], length, team.getSchemRegion().centerX(), team.getExtendRegion().getMaxY(), z, aT);
|
||||
}
|
||||
}
|
||||
|
||||
private void pasteChar(Clipboard character, int charOffset, int length, int x, int y, int z, AffineTransform aT){
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.pasteChar(character, charOffset, length, x, y, z, aT), 8),
|
||||
new VersionedRunnable(() -> FightTeam_14.pasteChar(character, charOffset, length, x, y, z, aT), 14));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
if(!Config.ReplaceObsidianBedrock)
|
||||
|
@ -54,9 +54,9 @@ public class FightTeam implements IFightTeam{
|
||||
private final Map<Player, FightPlayer> players = new HashMap<>();
|
||||
private final Set<Player> invited = new HashSet<>();
|
||||
|
||||
private final String name;
|
||||
private final String prefix;
|
||||
private final ChatColor color;
|
||||
private String name;
|
||||
private String prefix;
|
||||
private ChatColor color;
|
||||
private final FightSchematic schematic;
|
||||
private final Team team;
|
||||
private final boolean blue;
|
||||
@ -72,13 +72,11 @@ public class FightTeam implements IFightTeam{
|
||||
this.spawn = spawn;
|
||||
this.schemRegion = schemRegion;
|
||||
this.extendRegion = extendRegion;
|
||||
this.name = name;
|
||||
this.prefix = prefix;
|
||||
this.ready = false;
|
||||
this.skip = false;
|
||||
this.blue = blue;
|
||||
this.designatedLeader = designatedLeader;
|
||||
this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
||||
setPrefixAndName(prefix, name);
|
||||
this.schematic = new FightSchematic(this, rotate);
|
||||
new KitLoader();
|
||||
new SpectateHandler();
|
||||
@ -94,6 +92,12 @@ public class FightTeam implements IFightTeam{
|
||||
team.setAllowFriendlyFire(false);
|
||||
}
|
||||
|
||||
public void setPrefixAndName(String prefix, String name){
|
||||
this.name = name;
|
||||
this.prefix = prefix;
|
||||
this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
||||
}
|
||||
|
||||
public UUID getDesignatedLeader(){
|
||||
return designatedLeader;
|
||||
}
|
||||
@ -296,13 +300,17 @@ public class FightTeam implements IFightTeam{
|
||||
public void pasteSchem(Schematic schematic){
|
||||
setSchem(schematic);
|
||||
|
||||
if(Config.test())
|
||||
if(Config.test() || RecordSystem.isReplaying())
|
||||
this.schematic.enable();
|
||||
else if(Fight.getOpposite(this).hasSchematic()){
|
||||
FightSystem.setPostSchemState();
|
||||
}
|
||||
}
|
||||
|
||||
public void pasteTeamName(){
|
||||
schematic.pasteTeamName();
|
||||
}
|
||||
|
||||
public void setSchem(Schematic schematic){
|
||||
this.schematic.setSchematic(schematic);
|
||||
broadcast(FightSystem.PREFIX + "§7Das §e" + Config.GameName + " " + schematic.getSchemName() + " §7wird für den Kampf verwendet!");
|
||||
|
@ -54,7 +54,6 @@ public class FightScoreboard implements Listener, ScoreboardCallback {
|
||||
return scoreboard;
|
||||
}
|
||||
|
||||
private boolean replaying = false;
|
||||
private int index = 0;
|
||||
|
||||
private String title = "";
|
||||
@ -113,7 +112,7 @@ public class FightScoreboard implements Listener, ScoreboardCallback {
|
||||
}
|
||||
|
||||
private void updateScoreboard() {
|
||||
if(replaying)
|
||||
if(RecordSystem.isReplaying())
|
||||
return;
|
||||
|
||||
if ((index++ / 5) % 2 == 0) {
|
||||
@ -125,10 +124,6 @@ public class FightScoreboard implements Listener, ScoreboardCallback {
|
||||
}
|
||||
}
|
||||
|
||||
public void setReplaying(boolean replaying) {
|
||||
this.replaying = replaying;
|
||||
}
|
||||
|
||||
public void setTitle(String t) {
|
||||
scores.clear();
|
||||
title = t;
|
||||
|
@ -1,150 +0,0 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.record;
|
||||
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||
import de.steamwar.sql.Team;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class BlockTextCreator {
|
||||
private BlockTextCreator(){}
|
||||
|
||||
private static final int BETWEEN_CHARACTERS_WIDTH = 1;
|
||||
|
||||
private static final World WORLD = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||
|
||||
|
||||
private static BlockArrayClipboard[] createText(String text){
|
||||
List<BlockArrayClipboard> result = new ArrayList<>();
|
||||
for(char c : text.toCharArray()){
|
||||
try {
|
||||
try {
|
||||
result.add((BlockArrayClipboard) new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + nameConversion(c) + ".schem"))))).read());
|
||||
} catch (FileNotFoundException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not display character " + c + " due to missing file!");
|
||||
result.add((BlockArrayClipboard) new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/.schem"))))).read());
|
||||
}
|
||||
}catch (IOException e) {
|
||||
throw new SecurityException("Could not load text", e);
|
||||
}
|
||||
}
|
||||
return result.toArray(new BlockArrayClipboard[0]);
|
||||
}
|
||||
|
||||
private static String nameConversion(char c) {
|
||||
switch (Character.toUpperCase(c)) {
|
||||
case '/':
|
||||
return "slash";
|
||||
default:
|
||||
return c + "";
|
||||
}
|
||||
}
|
||||
|
||||
private static int[] characterSize(BlockArrayClipboard[] characters){
|
||||
int[] lengthes = new int[characters.length];
|
||||
for(int i = 0; i < lengthes.length; i++)
|
||||
lengthes[i] = characters[i].getDimensions().getBlockX();
|
||||
return lengthes;
|
||||
}
|
||||
|
||||
private static int[] textOffsets(int[] lengthes){
|
||||
int[] offsets = new int[lengthes.length];
|
||||
int previousOffset = 0;
|
||||
for(int i = 0; i < offsets.length; i++){
|
||||
offsets[i] = previousOffset;
|
||||
previousOffset += lengthes[i] + BETWEEN_CHARACTERS_WIDTH;
|
||||
}
|
||||
return offsets;
|
||||
}
|
||||
|
||||
private static int textLength(int[] lengthes, int[] offsets){
|
||||
if(lengthes.length == 0)
|
||||
return 0;
|
||||
return lengthes[lengthes.length - 1] + offsets[offsets.length - 1];
|
||||
}
|
||||
|
||||
private static void pasteChar(BlockArrayClipboard character, int charOffset, int length, int x, int y, int z, AffineTransform transform, DyeColor c){
|
||||
BlockVector3 offset = character.getRegion().getMinimumPoint().subtract(character.getOrigin());
|
||||
BlockVector3 v = BlockVector3.ZERO.subtract(- charOffset + length / 2, 0, 0).subtract(offset);
|
||||
v = transform.apply(v.toVector3()).toBlockPoint();
|
||||
v = v.add(x, y, z);
|
||||
|
||||
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(WORLD, -1);
|
||||
ClipboardHolder ch = new ClipboardHolder(character);
|
||||
ch.setTransform(transform);
|
||||
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(true).build());
|
||||
e.flushSession();
|
||||
}
|
||||
|
||||
private static void pasteText(String text, int x, int y, int z, AffineTransform transform, DyeColor c){
|
||||
BlockArrayClipboard[] characters = createText(text);
|
||||
int[] lengthes = characterSize(characters);
|
||||
int[] offsets = textOffsets(lengthes);
|
||||
int length = textLength(lengthes, offsets);
|
||||
|
||||
for(int i = 0; i < characters.length; i++)
|
||||
pasteChar(characters[i], offsets[i], length, x, y, z, transform, c);
|
||||
Paster.replaceTeamColor(
|
||||
WorldEdit.getInstance().getEditSessionFactory().getEditSession(WORLD, -1),
|
||||
c,
|
||||
x - length / 2, y, z, length, 6, 0);
|
||||
}
|
||||
|
||||
private static void pasteForTeam(int teamId, int x, int z, boolean rotate, String color){
|
||||
Team team = Team.get(teamId);
|
||||
AffineTransform aT = new AffineTransform();
|
||||
if(rotate){
|
||||
aT = aT.rotateY(180);
|
||||
z += Config.SchemsizeZ / 2;
|
||||
}else
|
||||
z -= Config.SchemsizeZ / 2;
|
||||
DyeColor c = ColorConverter.chat2dye(ChatColor.getByChar(ChatColor.getLastColors(color).replace("§", "")));
|
||||
pasteText(team.getTeamKuerzel(), x, Config.upperArenaBorder + 10, z, aT, c);
|
||||
}
|
||||
|
||||
public static void pasteTeamNames(int teamBlueId, int teamRedId){
|
||||
pasteForTeam(teamBlueId, Config.TeamBluePasteX, Config.TeamBluePasteZ, Config.TeamBlueRotate, Config.TeamBluePrefix);
|
||||
pasteForTeam(teamRedId, Config.TeamRedPasteX, Config.TeamRedPasteZ, Config.TeamRedRotate, Config.TeamRedPrefix);
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ import de.steamwar.fightsystem.fight.FreezeWorld;
|
||||
import de.steamwar.fightsystem.listener.FightScoreboard;
|
||||
import de.steamwar.fightsystem.utils.TechHider;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import de.steamwar.sql.Team;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@ -39,7 +40,6 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -57,7 +57,7 @@ class PacketProcessor {
|
||||
|
||||
public PacketProcessor(PacketSource source){
|
||||
this.source = source;
|
||||
FightScoreboard.getScoreboard().setReplaying(true);
|
||||
RecordSystem.setReplaying(true);
|
||||
if(source.async()) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FightSystem.getPlugin(), this::process);
|
||||
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::runSync, 1, 1);
|
||||
@ -253,7 +253,16 @@ class PacketProcessor {
|
||||
int blueId = source.rInt();
|
||||
int redId = source.rInt();
|
||||
|
||||
execSync(() -> BlockTextCreator.pasteTeamNames(blueId, redId));
|
||||
execSync(() -> {
|
||||
pasteForTeam(blueId, Fight.getBlueTeam());
|
||||
pasteForTeam(redId, Fight.getRedTeam());
|
||||
});
|
||||
}
|
||||
|
||||
private void pasteForTeam(int teamId, FightTeam fightTeam){
|
||||
Team team = Team.get(teamId);
|
||||
fightTeam.setPrefixAndName("§" + team.getTeamColor(), team.getTeamKuerzel());
|
||||
fightTeam.pasteTeamName();
|
||||
}
|
||||
|
||||
private void scoreboardTitle() throws IOException {
|
||||
@ -271,10 +280,10 @@ class PacketProcessor {
|
||||
|
||||
private void endReplay(){
|
||||
REntity.dieAll();
|
||||
FightScoreboard.getScoreboard().setReplaying(false);
|
||||
freezer.disable();
|
||||
//TODO: Stop server if singular replay
|
||||
FightWorld.resetWorld();
|
||||
RecordSystem.setReplaying(false);
|
||||
}
|
||||
|
||||
private void bow() throws IOException {
|
||||
@ -393,7 +402,7 @@ class PacketProcessor {
|
||||
tickFinished = true;
|
||||
break;
|
||||
default:
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Unknown packet recieved, closing: " + packetType);
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Unknown packet {} recieved, closing.", packetType);
|
||||
source.close();
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,16 @@ import org.bukkit.util.Vector;
|
||||
public class RecordSystem {
|
||||
private RecordSystem(){}
|
||||
|
||||
private static boolean replaying = false;
|
||||
|
||||
public static boolean isReplaying(){
|
||||
return replaying;
|
||||
}
|
||||
|
||||
public static void setReplaying(boolean replaying){
|
||||
RecordSystem.replaying = replaying;
|
||||
}
|
||||
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
|
||||
public static void init(){
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren