fix: issues with tab menu capitalisation

This commit is contained in:
Sekwah 2023-12-18 02:03:03 +00:00
parent 9ccf7b1d13
commit 81e8876079
7 changed files with 69 additions and 5 deletions

View File

@ -15,6 +15,7 @@ import com.sekwah.advancedportals.core.services.DestinationServices;
import com.sekwah.advancedportals.core.services.PortalServices;
import com.sekwah.advancedportals.core.tags.activation.DestiTag;
import com.sekwah.advancedportals.core.tags.activation.NameTag;
import com.sekwah.advancedportals.core.tags.activation.TriggerBlockTag;
import com.sekwah.advancedportals.core.util.GameScheduler;
import com.sekwah.advancedportals.core.util.InfoLogger;
import com.sekwah.advancedportals.core.util.Lang;
@ -109,6 +110,7 @@ public class AdvancedPortalsCore {
private void registerTags() {
this.tagRegistry.registerTag(new NameTag());
this.tagRegistry.registerTag(new DestiTag());
this.tagRegistry.registerTag(new TriggerBlockTag());
}
/**

View File

@ -171,11 +171,7 @@ public class CommandWithSubCommands implements CommandTemplate {
if(tabList == null) {
return null;
}
for(String arg : tabList.toArray(new String[0])) {
if(!arg.startsWith(lastArg.toLowerCase())) {
tabList.remove(arg);
}
}
tabList.removeIf(arg -> !arg.startsWith(lastArg));
return tabList;
}
}

View File

@ -1,8 +1,10 @@
package com.sekwah.advancedportals.core.commands.subcommands.common;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.commands.SubCommand;
import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer;
import com.sekwah.advancedportals.core.serializeddata.DataTag;
import com.sekwah.advancedportals.core.util.InfoLogger;
import com.sekwah.advancedportals.core.util.TagReader;
import com.sekwah.advancedportals.core.warphandler.Tag;

View File

@ -1,5 +1,6 @@
package com.sekwah.advancedportals.core.connector.containers;
import java.util.List;
import java.util.UUID;
public interface ServerContainer {
@ -10,6 +11,8 @@ public interface ServerContainer {
PlayerContainer getPlayer(UUID name);
List<String> getTriggerBlocks();
PlayerContainer[] getPlayers();
}

View File

@ -0,0 +1,50 @@
package com.sekwah.advancedportals.core.tags.activation;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.connector.containers.ServerContainer;
import com.sekwah.advancedportals.core.registry.TagTarget;
import com.sekwah.advancedportals.core.services.DestinationServices;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag;
import java.util.List;
import java.util.stream.Collectors;
public class TriggerBlockTag implements Tag.AutoComplete {
@Inject
private ServerContainer serverContainer;
public static String TAG_NAME = "triggerblock";
private final TagType[] tagTypes = new TagType[]{ TagType.PORTAL };
@Override
public TagType[] getTagTypes() {
return tagTypes;
}
@Override
public String getName() {
return TAG_NAME;
}
@Override
public String[] getAliases() {
return null;
}
@Override
public String description() {
return Lang.translate("tag.triggerblock.description");
}
@Override
public List<String> autoComplete(String argData) {
return serverContainer.getTriggerBlocks().stream()
.filter(s -> s.startsWith(argData))
.collect(Collectors.toList());
}
}

View File

@ -149,3 +149,4 @@ items.interact.right=Right Click
tag.desti.description=Sets the destination of the portal
tag.name.error.nospaces= The name cannot contain spaces.
tag.triggerblock.description=Sets the trigger block/s of the portal. Comma seperated or multi tag.

View File

@ -3,13 +3,18 @@ package com.sekwah.advancedportals.spigot.connector.container;
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.connector.containers.ServerContainer;
import com.sekwah.advancedportals.core.connector.containers.WorldContainer;
import org.bukkit.Material;
import org.bukkit.Server;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class SpigotServerContainer implements ServerContainer {
private final Server server;
private final List<String> triggerBlockList = Arrays.stream(Material.values()).filter(Material::isBlock).map(Enum::name)
.toList();
public SpigotServerContainer(Server server) {
this.server = server;
@ -45,6 +50,11 @@ public class SpigotServerContainer implements ServerContainer {
}
}
@Override
public List<String> getTriggerBlocks() {
return this.triggerBlockList;
}
@Override
public PlayerContainer[] getPlayers() {
return server.getOnlinePlayers().stream()