Adding coloring and arrows
Dieser Commit ist enthalten in:
Ursprung
0a376c1f1c
Commit
7e1785f8df
69
src/de/steamwar/spectatesystem/ColorConverter.java
Normale Datei
69
src/de/steamwar/spectatesystem/ColorConverter.java
Normale Datei
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
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.spectatesystem;
|
||||||
|
|
||||||
|
import de.steamwar.core.Core;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ColorConverter {
|
||||||
|
private ColorConverter(){}
|
||||||
|
|
||||||
|
private static final Map<ChatColor, DyeColor> chat2dye = new EnumMap<>(ChatColor.class);
|
||||||
|
|
||||||
|
static{
|
||||||
|
chat2dye.put(ChatColor.WHITE, DyeColor.WHITE);
|
||||||
|
chat2dye.put(ChatColor.GOLD, DyeColor.ORANGE);
|
||||||
|
chat2dye.put(ChatColor.LIGHT_PURPLE, DyeColor.MAGENTA);
|
||||||
|
chat2dye.put(ChatColor.BLUE, DyeColor.LIGHT_BLUE);
|
||||||
|
chat2dye.put(ChatColor.YELLOW, DyeColor.YELLOW);
|
||||||
|
chat2dye.put(ChatColor.GREEN, DyeColor.LIME);
|
||||||
|
chat2dye.put(ChatColor.RED, DyeColor.RED);
|
||||||
|
chat2dye.put(ChatColor.DARK_GRAY, DyeColor.GRAY);
|
||||||
|
chat2dye.put(ChatColor.DARK_AQUA, DyeColor.CYAN);
|
||||||
|
chat2dye.put(ChatColor.DARK_PURPLE, DyeColor.PURPLE);
|
||||||
|
chat2dye.put(ChatColor.DARK_BLUE, DyeColor.BLUE);
|
||||||
|
chat2dye.put(ChatColor.AQUA, DyeColor.CYAN);
|
||||||
|
chat2dye.put(ChatColor.DARK_GREEN, DyeColor.GREEN);
|
||||||
|
chat2dye.put(ChatColor.DARK_RED, DyeColor.RED);
|
||||||
|
chat2dye.put(ChatColor.BLACK, DyeColor.BLACK);
|
||||||
|
//Rosa 9pink, Braun 3brown
|
||||||
|
|
||||||
|
switch(Core.getVersion()){
|
||||||
|
case 8:
|
||||||
|
case 9:
|
||||||
|
case 10:
|
||||||
|
case 12:
|
||||||
|
chat2dye.put(ChatColor.GRAY, DyeColor.valueOf("SILVER"));
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
case 15:
|
||||||
|
default:
|
||||||
|
chat2dye.put(ChatColor.GRAY, DyeColor.valueOf("LIGHT_GRAY"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DyeColor chat2dye(ChatColor color){
|
||||||
|
return chat2dye.get(color);
|
||||||
|
}
|
||||||
|
}
|
@ -48,8 +48,6 @@ public class Config {
|
|||||||
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;
|
||||||
private static final int TeamRedPasteX;
|
|
||||||
private 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;
|
||||||
@ -76,6 +74,9 @@ public class Config {
|
|||||||
public static final int ObfuscateWith;
|
public static final int ObfuscateWith;
|
||||||
public static final String ObfuscateWithTag;
|
public static final String ObfuscateWithTag;
|
||||||
|
|
||||||
|
public static final String TeamRedPrefix;
|
||||||
|
public static final String TeamBluePrefix;
|
||||||
|
|
||||||
public static final int port = 2222;
|
public static final int port = 2222;
|
||||||
|
|
||||||
static{
|
static{
|
||||||
@ -140,8 +141,6 @@ public class Config {
|
|||||||
|
|
||||||
TeamBluePasteX = TeamBlueCornerX + SchemsizeX / 2;
|
TeamBluePasteX = TeamBlueCornerX + SchemsizeX / 2;
|
||||||
TeamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2;
|
TeamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2;
|
||||||
TeamRedPasteX = TeamBluePasteX + TeamBluetoReddistanceX;
|
|
||||||
TeamRedPasteZ = TeamBluePasteZ + TeamBluetoReddistanceZ;
|
|
||||||
|
|
||||||
SpecSpawn = new Location(world,
|
SpecSpawn = new Location(world,
|
||||||
TeamBluePasteX + TeamBluetoReddistanceX/2.0,
|
TeamBluePasteX + TeamBluetoReddistanceX/2.0,
|
||||||
@ -201,5 +200,8 @@ public class Config {
|
|||||||
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
|
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
|
||||||
ObfuscateWithTag = config.getString("Techhider.ObfuscateWithTag");
|
ObfuscateWithTag = config.getString("Techhider.ObfuscateWithTag");
|
||||||
TechhiderActive = config.getBoolean("Techhider.Active");
|
TechhiderActive = config.getBoolean("Techhider.Active");
|
||||||
|
|
||||||
|
TeamRedPrefix = config.getString("Output.TeamRedPrefix");
|
||||||
|
TeamBluePrefix = config.getString("Output.TeamBluePrefix");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.spectatesystem;
|
package de.steamwar.spectatesystem;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import de.steamwar.spectatesystem.elements.RArrow;
|
||||||
import de.steamwar.spectatesystem.elements.REntity;
|
import de.steamwar.spectatesystem.elements.REntity;
|
||||||
import de.steamwar.spectatesystem.elements.RPlayer;
|
import de.steamwar.spectatesystem.elements.RPlayer;
|
||||||
import de.steamwar.spectatesystem.elements.RTnT;
|
import de.steamwar.spectatesystem.elements.RTnT;
|
||||||
@ -111,6 +113,21 @@ class PacketProcessor {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void playerItem() throws IOException {
|
||||||
|
int entityId = source.rInt();
|
||||||
|
String item = source.rString();
|
||||||
|
boolean enchanted = source.rBoolean();
|
||||||
|
String slot = source.rString();
|
||||||
|
|
||||||
|
((RPlayer)REntity.getEntity(entityId)).setItem(item, enchanted, slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void spawnArrow() throws IOException {
|
||||||
|
int entityId = source.rInt();
|
||||||
|
|
||||||
|
new RArrow(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
private void send(ChatMessageType type) throws IOException {
|
private void send(ChatMessageType type) throws IOException {
|
||||||
String message = source.rString();
|
String message = source.rString();
|
||||||
|
|
||||||
@ -178,26 +195,17 @@ class PacketProcessor {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pasteSchem(int cornerX, int cornerY, int cornerZ, boolean rotate) throws IOException {
|
private void pasteSchem(int cornerX, int cornerY, int cornerZ, boolean rotate, String prefix) throws IOException {
|
||||||
int schemId = source.rInt();
|
int schemId = source.rInt();
|
||||||
|
|
||||||
Schematic schem = Schematic.getSchemFromDB(schemId);
|
Schematic schem = Schematic.getSchemFromDB(schemId);
|
||||||
//DyeColor c = ColorConverter.chat2dye(color);
|
DyeColor c = ColorConverter.chat2dye(ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", "")));
|
||||||
try {
|
try {
|
||||||
Paster.pasteSchematic(schem, cornerX, cornerY, cornerZ, rotate);
|
EditSession e = Paster.pasteSchematic(schem, cornerX, cornerY, cornerZ, rotate);
|
||||||
|
Paster.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||||
} catch (NoClipboardException e) {
|
} catch (NoClipboardException e) {
|
||||||
throw new IOException("Could not load Clipboard", e);
|
throw new IOException("Could not load Clipboard", e);
|
||||||
}
|
}
|
||||||
//Paster.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void playerItem() throws IOException {
|
|
||||||
int entityId = source.rInt();
|
|
||||||
String item = source.rString();
|
|
||||||
boolean enchanted = source.rBoolean();
|
|
||||||
String slot = source.rString();
|
|
||||||
|
|
||||||
((RPlayer)REntity.getEntity(entityId)).setItem(item, enchanted, slot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void process(){
|
private void process(){
|
||||||
@ -228,6 +236,9 @@ class PacketProcessor {
|
|||||||
case 0x07:
|
case 0x07:
|
||||||
playerItem();
|
playerItem();
|
||||||
break;
|
break;
|
||||||
|
case 0x08:
|
||||||
|
spawnArrow();
|
||||||
|
break;
|
||||||
case 0x30:
|
case 0x30:
|
||||||
block();
|
block();
|
||||||
break;
|
break;
|
||||||
@ -247,10 +258,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);
|
pasteSchem(Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.TeamBlueRotate, Config.TeamBluePrefix);
|
||||||
break;
|
break;
|
||||||
case (byte) 0xB1:
|
case (byte) 0xB1:
|
||||||
pasteSchem(Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.TeamRedRotate);
|
pasteSchem(Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.TeamRedRotate, Config.TeamRedPrefix);
|
||||||
break;
|
break;
|
||||||
case (byte) 0xC0:
|
case (byte) 0xC0:
|
||||||
scoreboardTitle();
|
scoreboardTitle();
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren