Remove usages of JoinedCharSequence (#2062)

This commit is contained in:
Hannes Greule 2023-01-11 00:07:24 +01:00 committed by GitHub
parent 452f968f07
commit bb0e201c52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 12 deletions

View File

@ -1,5 +1,9 @@
package com.fastasyncworldedit.core.util; package com.fastasyncworldedit.core.util;
/**
* @deprecated Unused, will be removed in the future. Use String concatenation instead.
*/
@Deprecated(forRemoval = true, since = "TODO")
public class JoinedCharSequence implements CharSequence { public class JoinedCharSequence implements CharSequence {
private char join; private char join;

View File

@ -20,7 +20,6 @@
package com.sk89q.worldedit.world.block; package com.sk89q.worldedit.world.block;
import com.fastasyncworldedit.core.command.SuggestInputParseException; import com.fastasyncworldedit.core.command.SuggestInputParseException;
import com.fastasyncworldedit.core.util.JoinedCharSequence;
import com.fastasyncworldedit.core.util.StringMan; import com.fastasyncworldedit.core.util.StringMan;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.input.ParserContext;
@ -1923,23 +1922,19 @@ public final class BlockTypes {
public static final BlockType ZOMBIE_WALL_HEAD = init(); public static final BlockType ZOMBIE_WALL_HEAD = init();
private static Field[] fieldsTmp; private static Field[] fieldsTmp;
private static JoinedCharSequence joined;
private static int initIndex = 0; private static int initIndex = 0;
public static BlockType init() { public static BlockType init() {
if (fieldsTmp == null) { if (fieldsTmp == null) {
fieldsTmp = BlockTypes.class.getDeclaredFields(); fieldsTmp = BlockTypes.class.getDeclaredFields();
BlockTypesCache.$NAMESPACES.isEmpty(); // initialize cache BlockTypesCache.$NAMESPACES.isEmpty(); // initialize cache
joined = new JoinedCharSequence();
} }
String name = fieldsTmp[initIndex++].getName().toLowerCase(Locale.ROOT); String name = fieldsTmp[initIndex++].getName().toLowerCase(Locale.ROOT);
CharSequence fullName = joined.init(BlockType.REGISTRY.getDefaultNamespace(), ':', name); return BlockType.REGISTRY.get(name);
return BlockType.REGISTRY.getMap().get(fullName);
} }
static { static {
fieldsTmp = null; fieldsTmp = null;
joined = null;
} }
/* /*

View File

@ -19,7 +19,6 @@
package com.sk89q.worldedit.world.item; package com.sk89q.worldedit.world.item;
import com.fastasyncworldedit.core.util.JoinedCharSequence;
import com.fastasyncworldedit.core.world.block.ItemTypesCache; import com.fastasyncworldedit.core.world.block.ItemTypesCache;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
@ -2362,7 +2361,6 @@ public final class ItemTypes {
} }
private static Field[] fieldsTmp; private static Field[] fieldsTmp;
private static JoinedCharSequence joined;
private static int initIndex = 0; private static int initIndex = 0;
private static ItemType init() { private static ItemType init() {
@ -2370,11 +2368,9 @@ public final class ItemTypes {
if (fieldsTmp == null) { if (fieldsTmp == null) {
fieldsTmp = ItemTypes.class.getDeclaredFields(); fieldsTmp = ItemTypes.class.getDeclaredFields();
ItemTypesCache.init(); // force class to load ItemTypesCache.init(); // force class to load
joined = new JoinedCharSequence();
} }
String name = fieldsTmp[initIndex++].getName().toLowerCase(Locale.ROOT); String name = fieldsTmp[initIndex++].getName().toLowerCase(Locale.ROOT);
CharSequence fullName = joined.init(ItemType.REGISTRY.getDefaultNamespace(), ':', name); return ItemType.REGISTRY.get(name);
return ItemType.REGISTRY.getMap().get(fullName);
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
throw e; throw e;
@ -2383,7 +2379,6 @@ public final class ItemTypes {
static { static {
fieldsTmp = null; fieldsTmp = null;
joined = null;
} }
@Nullable @Nullable