13
0

Push current changes

Dieser Commit ist enthalten in:
Lixfel 2020-10-15 22:23:11 +02:00
Ursprung 1a63993de1
Commit aef57c490e
5 geänderte Dateien mit 37 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -62,7 +62,7 @@ class PacketProcessor {
if(user == null)
throw new IOException("Unknown user " + userId);
new RPlayer(user.getUUID(), user.getUserName(), entityId);
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> new RPlayer(user.getUUID(), user.getUserName(), entityId));
}
private void entityMoves() throws IOException{
@ -74,13 +74,13 @@ class PacketProcessor {
float yaw = source.rFloat();
byte headYaw = source.rByte();
REntity.getEntity(entityId).move(locX, locY, locZ, yaw, pitch, headYaw);
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> REntity.getEntity(entityId).move(locX, locY, locZ, yaw, pitch, headYaw));
}
private void entityDespawns() throws IOException{
int entityId = source.rInt();
REntity.getEntity(entityId).remove();
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> REntity.getEntity(entityId).remove());
}
private void entitySneak() throws IOException {
@ -123,7 +123,7 @@ class PacketProcessor {
boolean enchanted = source.rBoolean();
String slot = source.rString();
((RPlayer)REntity.getEntity(entityId)).setItem(item, enchanted, slot);
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> ((RPlayer)REntity.getEntity(entityId)).setItem(item, enchanted, slot));
}
private void arrowSpawn() throws IOException {

Datei anzeigen

@ -33,7 +33,7 @@ public abstract class REntity {
protected static final WorldServer world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
private static Map<Integer, REntity> entities = new HashMap<>();
private static final Map<Integer, REntity> entities = new HashMap<>();
private final int internalId;
protected final Entity entity;
@ -67,6 +67,14 @@ public abstract class REntity {
return entities.get(internalId);
}
public static void removeAll(){
while(!entities.isEmpty()){
REntity entity = entities.values().iterator().next();
System.out.println("Has to remove manually entity " + entity.internalId);
entity.remove();
}
}
public void move(double x, double y, double z, float yaw, float pitch, byte headYaw){
entity.setLocation(x, y, z, yaw, pitch);
entity.setHeadRotation(headYaw);

Datei anzeigen

@ -15,6 +15,8 @@ import de.steamwar.spectatesystem.Config;
import de.steamwar.spectatesystem.SpectateSystem;
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;
@ -70,9 +72,9 @@ public class BlockTextCreator {
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){
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);
BlockVector3 v = BlockVector3.ZERO.subtract(- charOffset + length / 2, 0, 0).subtract(offset);
v = transform.apply(v.toVector3()).toBlockPoint();
v = v.add(x, y, z);
@ -83,17 +85,21 @@ public class BlockTextCreator {
e.flushSession();
}
private static void pasteText(String text, int x, int y, int z, AffineTransform transform){
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);
pasteChar(characters[i], offsets[i], length, x, y, z, transform, c);
Paster.replaceTeamColor(
WorldEdit.getInstance().getEditSessionFactory().getEditSession(WORLD, -1),
c,
x, y, z, length, 6, 0);
}
private static void pasteForTeam(int teamId, int x, int z, boolean rotate){
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){
@ -101,11 +107,12 @@ public class BlockTextCreator {
z += Config.SchemsizeZ / 2;
}else
z -= Config.SchemsizeZ / 2;
pasteText(team.getTeamKuerzel(), x, Config.upperArenaBorder, z, aT);
DyeColor c = ColorConverter.chat2dye(ChatColor.getByChar(ChatColor.getLastColors(color).replace("§", "")));
pasteText(team.getTeamKuerzel(), x, Config.upperArenaBorder, z, aT, c);
}
public static void pasteTeamNames(int teamBlueId, int teamRedId){
pasteForTeam(teamBlueId, Config.TeamBluePasteX, Config.TeamBluePasteZ, Config.TeamBlueRotate);
pasteForTeam(teamRedId, Config.TeamRedPasteX, Config.TeamRedPasteZ, Config.TeamRedRotate);
pasteForTeam(teamBlueId, Config.TeamBluePasteX, Config.TeamBluePasteZ, Config.TeamBlueRotate, Config.TeamBluePrefix);
pasteForTeam(teamRedId, Config.TeamRedPasteX, Config.TeamRedPasteZ, Config.TeamRedRotate, Config.TeamRedPrefix);
}
}

Datei anzeigen

@ -59,8 +59,12 @@ public class Paster {
private static final Set<BaseBlock> CARPET_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock());
public static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){
replaceTeamColor(e, c, cornerX, cornerY, cornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ);
}
public static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ, int sizeX, int sizeY, int sizeZ){
BlockVector3 corner3 = BlockVector3.at(cornerX, cornerY, cornerZ);
BlockVector3 schemsize3 = BlockVector3.at(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ);
BlockVector3 schemsize3 = BlockVector3.at(sizeX, sizeY, sizeZ);
CuboidRegion region = new CuboidRegion(corner3, corner3.add(schemsize3));
try {
e.replaceBlocks(region, WOOL_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock());

Datei anzeigen

@ -20,15 +20,9 @@
package de.steamwar.spectatesystem.util;
import de.steamwar.spectatesystem.SpectateSystem;
import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk;
import net.minecraft.server.v1_15_R1.PlayerChunkMap;
import de.steamwar.spectatesystem.elements.REntity;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class WorldLoader {
private WorldLoader(){}
@ -37,6 +31,8 @@ public class WorldLoader {
public static void reloadWorld(){
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> {
REntity.removeAll();
/*
Chunk[] chunks = world.getLoadedChunks();
PlayerChunkMap playerChunkMap = ((CraftWorld)world).getHandle().getChunkProvider().playerChunkMap;
for(long l : playerChunkMap.updatingChunks.keySet())
@ -46,7 +42,7 @@ public class WorldLoader {
//world.getChunkAt(chunk.getX(), chunk.getZ());
for(Player player : Bukkit.getOnlinePlayers())
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)chunk).getHandle(), 65535));
}
}*/
});
}
}