Skip to content

Commit

Permalink
fix: issues with tab menu capitalisation
Browse files Browse the repository at this point in the history
  • Loading branch information
sekwah41 committed Dec 18, 2023
1 parent ad7a482 commit fd0f011
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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;
Expand Down Expand Up @@ -109,6 +110,7 @@ public void onEnable() {
private void registerTags() {
this.tagRegistry.registerTag(new NameTag());
this.tagRegistry.registerTag(new DestiTag());
this.tagRegistry.registerTag(new TriggerBlockTag());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ public List<String> filterTabResults(List<String> tabList, String lastArg) {
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;
}
}
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sekwah.advancedportals.core.connector.containers;

import java.util.List;
import java.util.UUID;

public interface ServerContainer {
Expand All @@ -10,6 +11,8 @@ public interface ServerContainer {

PlayerContainer getPlayer(UUID name);

List<String> getTriggerBlocks();

PlayerContainer[] getPlayers();

}
Original file line number Diff line number Diff line change
@@ -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());
}
}
1 change: 1 addition & 0 deletions lang/src/main/resources/lang/en_GB.lang
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,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.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
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;
Expand Down Expand Up @@ -45,6 +50,11 @@ public PlayerContainer getPlayer(UUID name) {
}
}

@Override
public List<String> getTriggerBlocks() {
return this.triggerBlockList;
}

@Override
public PlayerContainer[] getPlayers() {
return server.getOnlinePlayers().stream()
Expand Down

0 comments on commit fd0f011

Please sign in to comment.