Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 08:10:09 +01:00
Implement prefix based team colours (based on code by @JollyAjax)
Dieser Commit ist enthalten in:
Ursprung
ca415cc719
Commit
7c0c4ee74d
@ -199,4 +199,9 @@ public class BukkitConfigAPI extends Config implements ViaVersionConfig {
|
|||||||
public List<String> getUnsupportedOptions() {
|
public List<String> getUnsupportedOptions() {
|
||||||
return UNSUPPORTED;
|
return UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean is1_13TeamColourFix() {
|
||||||
|
return getBoolean("team-colour-fix", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,4 +252,9 @@ public class BungeeConfigAPI extends Config implements ViaVersionConfig {
|
|||||||
public Map<String, Integer> getBungeeServerProtocols() {
|
public Map<String, Integer> getBungeeServerProtocols() {
|
||||||
return get("bungee-servers", Map.class, new HashMap<>());
|
return get("bungee-servers", Map.class, new HashMap<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean is1_13TeamColourFix() {
|
||||||
|
return getBoolean("team-colour-fix", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,6 +210,13 @@ public interface ViaVersionConfig {
|
|||||||
*/
|
*/
|
||||||
boolean is1_12NBTArrayFix();
|
boolean is1_12NBTArrayFix();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should we make team colours based on the last colour in team prefix
|
||||||
|
*
|
||||||
|
* @return True if enabled
|
||||||
|
*/
|
||||||
|
boolean is1_13TeamColourFix();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should we fix shift quick move action for 1.12 clients
|
* Should we fix shift quick move action for 1.12 clients
|
||||||
*
|
*
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2;
|
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.entities.Entity1_13Types;
|
import us.myles.ViaVersion.api.entities.Entity1_13Types;
|
||||||
import us.myles.ViaVersion.api.minecraft.Position;
|
import us.myles.ViaVersion.api.minecraft.Position;
|
||||||
@ -370,12 +372,16 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
|||||||
wrapper.passthrough(Type.STRING); // Collision rule
|
wrapper.passthrough(Type.STRING); // Collision rule
|
||||||
|
|
||||||
// Handle new colors
|
// Handle new colors
|
||||||
byte color = wrapper.read(Type.BYTE);
|
int colour = wrapper.read(Type.BYTE).intValue();
|
||||||
|
if (colour == -1) {
|
||||||
|
colour = 21; // -1 changed to 21
|
||||||
|
}
|
||||||
|
|
||||||
if (color == -1) // -1 changed to 21
|
if (Via.getConfig().is1_13TeamColourFix()) {
|
||||||
wrapper.write(Type.VAR_INT, 21); // RESET
|
colour = getLastColor(prefix);
|
||||||
else
|
}
|
||||||
wrapper.write(Type.VAR_INT, (int) color);
|
|
||||||
|
wrapper.write(Type.VAR_INT, colour);
|
||||||
|
|
||||||
wrapper.write(Type.STRING, legacyTextToJson(prefix)); // Prefix
|
wrapper.write(Type.STRING, legacyTextToJson(prefix)); // Prefix
|
||||||
wrapper.write(Type.STRING, legacyTextToJson(suffix)); // Suffix
|
wrapper.write(Type.STRING, legacyTextToJson(suffix)); // Suffix
|
||||||
@ -769,4 +775,33 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
|||||||
private int getNewSoundID(final int oldID) {
|
private int getNewSoundID(final int oldID) {
|
||||||
return MappingData.oldToNewSounds.get(oldID);
|
return MappingData.oldToNewSounds.get(oldID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Based on method from https://github.com/Bukkit/Bukkit/blob/master/src/main/java/org/bukkit/ChatColor.java
|
||||||
|
public int getLastColor(String input) {
|
||||||
|
int length = input.length();
|
||||||
|
|
||||||
|
for (int index = length - 1; index > -1; index--) {
|
||||||
|
char section = input.charAt(index);
|
||||||
|
if (section == ChatColor.COLOR_CHAR && index < length - 1) {
|
||||||
|
char c = input.charAt(index + 1);
|
||||||
|
ChatColor color = ChatColor.getByChar(c);
|
||||||
|
|
||||||
|
if (color != null) {
|
||||||
|
switch (color) {
|
||||||
|
case MAGIC:
|
||||||
|
case BOLD:
|
||||||
|
case STRIKETHROUGH:
|
||||||
|
case UNDERLINE:
|
||||||
|
case ITALIC:
|
||||||
|
case RESET:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return color.ordinal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ChatColor.RESET.ordinal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,8 @@ piston-animation-patch: false
|
|||||||
chat-nbt-fix: true
|
chat-nbt-fix: true
|
||||||
# Experimental - Should we fix shift quick move action for 1.12 clients (causes shift + double click not to work when moving items) (only works on 1.8-1.11.2 bukkit based servers)
|
# Experimental - Should we fix shift quick move action for 1.12 clients (causes shift + double click not to work when moving items) (only works on 1.8-1.11.2 bukkit based servers)
|
||||||
quick-move-action-fix: false
|
quick-move-action-fix: false
|
||||||
|
# Should we use prefix for team colour on 1.13 and above clients
|
||||||
|
team-colour-fix: true
|
||||||
#
|
#
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# 1.9 & 1.10 CLIENTS ON 1.8 SERVERS OPTIONS #
|
# 1.9 & 1.10 CLIENTS ON 1.8 SERVERS OPTIONS #
|
||||||
|
@ -205,4 +205,9 @@ public class SpongeConfigAPI extends Config implements ViaVersionConfig {
|
|||||||
public String getReloadDisconnectMsg() {
|
public String getReloadDisconnectMsg() {
|
||||||
return getString("reload-disconnect-msg", "Server reload, please rejoin!");
|
return getString("reload-disconnect-msg", "Server reload, please rejoin!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean is1_13TeamColourFix() {
|
||||||
|
return getBoolean("team-colour-fix", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren