13
0

More advanced stuff

Dieser Commit ist enthalten in:
Lixfel 2020-09-05 23:50:16 +02:00
Ursprung 7d58cb15f3
Commit 29af653c22
6 geänderte Dateien mit 46 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -43,11 +43,13 @@ public class Config {
public static final int TeamBlueCornerX; public static final int TeamBlueCornerX;
public static final int TeamBlueCornerY; public static final int TeamBlueCornerY;
public static final int TeamBlueCornerZ; public static final int TeamBlueCornerZ;
private static final int TeamBluePasteX; public static final int TeamBluePasteX;
private static final int TeamBluePasteZ; public static final int TeamBluePasteZ;
public static final int TeamRedCornerX; public static final int TeamRedCornerX;
public static final int TeamRedCornerY; public static final int TeamRedCornerY;
public static final int TeamRedCornerZ; public static final int TeamRedCornerZ;
public static final int TeamRedPasteX;
public static final int TeamRedPasteZ;
private static final int TeamBluetoReddistanceX; private static final int TeamBluetoReddistanceX;
private static final int TeamBluetoReddistanceY; private static final int TeamBluetoReddistanceY;
public static final int TeamBluetoReddistanceZ; public static final int TeamBluetoReddistanceZ;
@ -141,6 +143,8 @@ public class Config {
TeamBluePasteX = TeamBlueCornerX + SchemsizeX / 2; TeamBluePasteX = TeamBlueCornerX + SchemsizeX / 2;
TeamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2; TeamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2;
TeamRedPasteX = TeamRedCornerX + SchemsizeX / 2;
TeamRedPasteZ = TeamRedCornerZ + SchemsizeZ / 2;
SpecSpawn = new Location(world, SpecSpawn = new Location(world,
TeamBluePasteX + TeamBluetoReddistanceX/2.0, TeamBluePasteX + TeamBluetoReddistanceX/2.0,

Datei anzeigen

@ -212,12 +212,14 @@ class PacketProcessor {
Schematic schem = Schematic.getSchemFromDB(schemId); Schematic schem = Schematic.getSchemFromDB(schemId);
DyeColor c = ColorConverter.chat2dye(ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""))); DyeColor c = ColorConverter.chat2dye(ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", "")));
try { Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> {
EditSession e = Paster.pasteSchematic(schem, cornerX, cornerY, cornerZ, rotate); try {
Paster.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); EditSession e = Paster.pasteSchematic(schem, cornerX, cornerY, cornerZ, rotate);
} catch (NoClipboardException e) { Paster.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
throw new IOException("Could not load Clipboard", e); } catch (NoClipboardException | IOException e) {
} throw new SecurityException("Could not load Clipboard", e);
}
});
} }
private void scoreboardTitle() throws IOException { private void scoreboardTitle() throws IOException {
@ -291,10 +293,10 @@ class PacketProcessor {
send(ChatMessageType.SYSTEM); send(ChatMessageType.SYSTEM);
break; break;
case (byte) 0xB0: case (byte) 0xB0:
pasteSchem(Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.TeamBlueRotate, Config.TeamBluePrefix); pasteSchem(Config.TeamBluePasteX, Config.TeamBlueCornerY, Config.TeamBluePasteZ, Config.TeamBlueRotate, Config.TeamBluePrefix);
break; break;
case (byte) 0xB1: case (byte) 0xB1:
pasteSchem(Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.TeamRedRotate, Config.TeamRedPrefix); pasteSchem(Config.TeamRedPasteX, Config.TeamRedCornerY, Config.TeamRedPasteZ, Config.TeamRedRotate, Config.TeamRedPrefix);
break; break;
case (byte) 0xC0: case (byte) 0xC0:
scoreboardTitle(); scoreboardTitle();

Datei anzeigen

@ -84,6 +84,7 @@ public abstract class REntity {
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection; PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
connection.sendPacket(packet); connection.sendPacket(packet);
} }
entity.killEntity();
entities.remove(internalId); entities.remove(internalId);
} }

Datei anzeigen

@ -24,7 +24,6 @@ import com.mojang.authlib.properties.Property;
import net.minecraft.server.v1_15_R1.*; import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_15_R1.CraftServer; import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
import org.bukkit.craftbukkit.v1_15_R1.enchantments.CraftEnchantment;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -90,7 +89,7 @@ public class RPlayer extends REntity {
ItemStack stack = new ItemStack(IRegistry.ITEM.get(new MinecraftKey(item)), 1); ItemStack stack = new ItemStack(IRegistry.ITEM.get(new MinecraftKey(item)), 1);
if(enchanted) if(enchanted)
stack.addEnchantment(((CraftEnchantment)org.bukkit.enchantments.Enchantment.KNOCKBACK).getHandle(), 1); stack.addEnchantment(Enchantments.DURABILITY, 1);
PlayerInventory inventory = ((EntityPlayer)entity).inventory; PlayerInventory inventory = ((EntityPlayer)entity).inventory;
switch(slot){ switch(slot){

Datei anzeigen

@ -22,6 +22,8 @@ package de.steamwar.spectatesystem.util;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
@ -37,11 +39,13 @@ import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Material;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
public class Paster { public class Paster {
private Paster(){} private Paster(){}
@ -76,6 +80,24 @@ public class Paster {
BlockVector3 paste = BlockVector3.at(pX, pY, pZ); BlockVector3 paste = BlockVector3.at(pX, pY, pZ);
Clipboard clipboard = schematic.load(); Clipboard clipboard = schematic.load();
BlockVector3 minimum = clipboard.getRegion().getMinimumPoint();
BaseBlock obfuscateWith = BukkitAdapter.adapt(Material.valueOf(Config.ObfuscateWithTag).createBlockData()).toBaseBlock();
for(int x = 0; x < clipboard.getDimensions().getX(); x++){
for(int y = 0; y < clipboard.getDimensions().getY(); y++){
for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
BlockVector3 blockPos = minimum.add(x, y, z);
if(Config.HiddenBlockTags.contains(BukkitAdapter.adapt(clipboard.getFullBlock(blockPos).getBlockType()).name())){
try {
clipboard.setBlock(blockPos, obfuscateWith);
} catch (WorldEditException e) {
Bukkit.getLogger().log(Level.SEVERE, "Could not hide block!", e);
}
}
}
}
}
World w = new BukkitWorld(Bukkit.getWorlds().get(0)); World w = new BukkitWorld(Bukkit.getWorlds().get(0));
BlockVector3 dimensions = clipboard.getDimensions(); BlockVector3 dimensions = clipboard.getDimensions();
BlockVector3 v; BlockVector3 v;

Datei anzeigen

@ -21,10 +21,14 @@ package de.steamwar.spectatesystem.util;
import de.steamwar.spectatesystem.Config; import de.steamwar.spectatesystem.Config;
import de.steamwar.spectatesystem.SpectateSystem; import de.steamwar.spectatesystem.SpectateSystem;
import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class WorldLoader { public class WorldLoader {
private WorldLoader(){} private WorldLoader(){}
@ -36,6 +40,8 @@ public class WorldLoader {
for(Chunk chunk: world.getLoadedChunks()){ for(Chunk chunk: world.getLoadedChunks()){
world.unloadChunk(chunk.getX(), chunk.getZ(), false); world.unloadChunk(chunk.getX(), chunk.getZ(), false);
world.getChunkAt(chunk.getX(), chunk.getZ()); world.getChunkAt(chunk.getX(), chunk.getZ());
for(Player player : Bukkit.getOnlinePlayers())
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)chunk).getHandle(), 65535));
} }
}); });
Bukkit.getScheduler().runTaskLater(SpectateSystem.get(), () -> world.getBlockAt(Config.SpecSpawn).setType(Material.STONE), 100); Bukkit.getScheduler().runTaskLater(SpectateSystem.get(), () -> world.getBlockAt(Config.SpecSpawn).setType(Material.STONE), 100);