Merge pull request #46 from FlorianMichael/main

Changed "Protocol Hack" -> "ViaLegacy"
This commit is contained in:
RK_01 2023-10-08 11:00:20 +02:00 committed by GitHub
commit 768a5f851a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 20 deletions

View File

@ -40,7 +40,7 @@ public abstract class LegacyItemRewriter<P extends Protocol> extends RewriterBas
public LegacyItemRewriter(final P protocol, final String protocolName) { public LegacyItemRewriter(final P protocol, final String protocolName) {
super(protocol); super(protocol);
this.tagName = protocolName.replace(".", "_") + "_ProtocolHack_" + System.currentTimeMillis(); this.tagName = protocolName.replace(".", "_") + "_ViaLegacy_" + System.currentTimeMillis();
this.protocolName = protocolName; this.protocolName = protocolName;
} }
@ -134,11 +134,11 @@ public abstract class LegacyItemRewriter<P extends Protocol> extends RewriterBas
} }
private void setRemappedNameRead(final Item item, final String name) { private void setRemappedNameRead(final Item item, final String name) {
//Set protocol hack tag for later remapping //Set ViaLegacy tag for later remapping
final CompoundTag protocolHackTag = (item.tag() != null && item.tag().contains(tagName) ? item.tag().get(tagName) : new CompoundTag()); final CompoundTag viaLegacyTag = (item.tag() != null && item.tag().contains(tagName) ? item.tag().get(tagName) : new CompoundTag());
if (item.tag() == null || !item.tag().contains(tagName)) { if (item.tag() == null || !item.tag().contains(tagName)) {
protocolHackTag.put("Id", new IntTag(item.identifier())); viaLegacyTag.put("Id", new IntTag(item.identifier()));
protocolHackTag.put("Meta", new ShortTag(item.data())); viaLegacyTag.put("Meta", new ShortTag(item.data()));
} }
//Get Item tag //Get Item tag
@ -146,29 +146,29 @@ public abstract class LegacyItemRewriter<P extends Protocol> extends RewriterBas
if (tag == null) { if (tag == null) {
tag = new CompoundTag(); tag = new CompoundTag();
item.setTag(tag); item.setTag(tag);
protocolHackTag.put("RemoveTag", new IntTag(0)); viaLegacyTag.put("RemoveTag", new IntTag(0));
} }
tag.put(tagName, protocolHackTag); tag.put(tagName, viaLegacyTag);
//Set name/lore of item //Set name/lore of item
CompoundTag display = tag.get("display"); CompoundTag display = tag.get("display");
if (display == null) { if (display == null) {
display = new CompoundTag(); display = new CompoundTag();
tag.put("display", display); tag.put("display", display);
protocolHackTag.put("RemoveDisplayTag", new IntTag(0)); viaLegacyTag.put("RemoveDisplayTag", new IntTag(0));
} }
if (display.contains("Name")) { if (display.contains("Name")) {
ListTag lore = display.get("Lore"); ListTag lore = display.get("Lore");
if (lore == null) { if (lore == null) {
lore = new ListTag(); lore = new ListTag();
display.put("Lore", lore); display.put("Lore", lore);
protocolHackTag.put("RemoveLore", new IntTag(0)); viaLegacyTag.put("RemoveLore", new IntTag(0));
} }
lore.add(new StringTag("§r " + this.protocolName + " Item ID: " + item.identifier() + " (" + name + ")")); lore.add(new StringTag("§r " + this.protocolName + " Item ID: " + item.identifier() + " (" + name + ")"));
protocolHackTag.put("RemoveLastLore", new IntTag(0)); viaLegacyTag.put("RemoveLastLore", new IntTag(0));
} else { } else {
display.put("Name", new StringTag("§r" + this.protocolName + " " + name)); display.put("Name", new StringTag("§r" + this.protocolName + " " + name));
protocolHackTag.put("RemoveDisplayName", new IntTag(0)); viaLegacyTag.put("RemoveDisplayName", new IntTag(0));
} }
} }
@ -177,27 +177,27 @@ public abstract class LegacyItemRewriter<P extends Protocol> extends RewriterBas
if (!item.tag().contains(tagName)) return; if (!item.tag().contains(tagName)) return;
final CompoundTag tag = item.tag(); final CompoundTag tag = item.tag();
final CompoundTag protocolHackTag = tag.get(tagName); final CompoundTag viaLegacyTag = tag.get(tagName);
tag.remove(tagName); tag.remove(tagName);
item.setIdentifier(((IntTag) protocolHackTag.get("Id")).asInt()); item.setIdentifier(((IntTag) viaLegacyTag.get("Id")).asInt());
item.setData(((ShortTag) protocolHackTag.get("Meta")).asShort()); item.setData(((ShortTag) viaLegacyTag.get("Meta")).asShort());
if (protocolHackTag.contains("RemoveLastLore")) { if (viaLegacyTag.contains("RemoveLastLore")) {
ListTag lore = ((CompoundTag) tag.get("display")).get("Lore"); ListTag lore = ((CompoundTag) tag.get("display")).get("Lore");
List<Tag> tags = lore.getValue(); List<Tag> tags = lore.getValue();
tags.remove(lore.size() - 1); tags.remove(lore.size() - 1);
lore.setValue(tags); lore.setValue(tags);
} }
if (protocolHackTag.contains("RemoveLore")) { if (viaLegacyTag.contains("RemoveLore")) {
((CompoundTag) tag.get("display")).remove("Lore"); ((CompoundTag) tag.get("display")).remove("Lore");
} }
if (protocolHackTag.contains("RemoveDisplayName")) { if (viaLegacyTag.contains("RemoveDisplayName")) {
((CompoundTag) tag.get("display")).remove("Name"); ((CompoundTag) tag.get("display")).remove("Name");
} }
if (protocolHackTag.contains("RemoveDisplayTag")) { if (viaLegacyTag.contains("RemoveDisplayTag")) {
tag.remove("display"); tag.remove("display");
} }
if (protocolHackTag.contains("RemoveTag")) { if (viaLegacyTag.contains("RemoveTag")) {
item.setTag(null); item.setTag(null);
} }
} }

View File

@ -36,7 +36,7 @@ public abstract class GameProfileFetcher implements Provider {
protected static final Pattern PATTERN_CONTROL_CODE = Pattern.compile("(?i)\\u00A7[0-9A-FK-OR]"); protected static final Pattern PATTERN_CONTROL_CODE = Pattern.compile("(?i)\\u00A7[0-9A-FK-OR]");
private static final ThreadPoolExecutor LOADING_POOL = (ThreadPoolExecutor) Executors.newFixedThreadPool(2, new ThreadFactoryBuilder().setNameFormat("ProtocolHack GameProfile Loader #%d").setDaemon(true).build()); private static final ThreadPoolExecutor LOADING_POOL = (ThreadPoolExecutor) Executors.newFixedThreadPool(2, new ThreadFactoryBuilder().setNameFormat("ViaLegacy GameProfile Loader #%d").setDaemon(true).build());
private final LoadingCache<String, UUID> UUID_CACHE = CacheBuilder.newBuilder().expireAfterWrite(6, TimeUnit.HOURS).build(new CacheLoader<String, UUID>() { private final LoadingCache<String, UUID> UUID_CACHE = CacheBuilder.newBuilder().expireAfterWrite(6, TimeUnit.HOURS).build(new CacheLoader<String, UUID>() {
@Override @Override