mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-02-09 00:41:56 +01:00
feat: see portal info with /portal info (name)
This commit is contained in:
parent
0044008105
commit
e7b0d5e4ca
@ -164,6 +164,8 @@ public class AdvancedPortalsCore {
|
|||||||
new ListPortalsSubCommand());
|
new ListPortalsSubCommand());
|
||||||
this.portalCommand.registerSubCommand("show",
|
this.portalCommand.registerSubCommand("show",
|
||||||
new ShowPortalSubCommand());
|
new ShowPortalSubCommand());
|
||||||
|
this.portalCommand.registerSubCommand("info",
|
||||||
|
new InfoPortalSubCommand());
|
||||||
|
|
||||||
commandRegister.registerCommand("portal", this.portalCommand);
|
commandRegister.registerCommand("portal", this.portalCommand);
|
||||||
}
|
}
|
||||||
|
@ -194,19 +194,4 @@ public abstract class CreateTaggedSubCommand implements SubCommand {
|
|||||||
return o1.NAME.compareTo(o2.NAME);
|
return o1.NAME.compareTo(o2.NAME);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void printTags(CommandSenderContainer sender,
|
|
||||||
List<DataTag> dataTags) {
|
|
||||||
for (DataTag tag : dataTags) {
|
|
||||||
if (tag.VALUES.length == 1) {
|
|
||||||
sender.sendMessage(" \u00A7a" + tag.NAME + "\u00A77:\u00A7e"
|
|
||||||
+ tag.VALUES[0]);
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < tag.VALUES.length; i++) {
|
|
||||||
sender.sendMessage(" \u00A7a" + tag.NAME + "\u00A77[" + i
|
|
||||||
+ "]:\u00A7e" + tag.VALUES[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class CreateDestiSubCommand extends CreateTaggedSubCommand {
|
|||||||
|
|
||||||
if (!destinationTags.isEmpty()) {
|
if (!destinationTags.isEmpty()) {
|
||||||
this.filterAndProcessTags(destinationTags);
|
this.filterAndProcessTags(destinationTags);
|
||||||
this.printTags(sender, destinationTags);
|
TagReader.printArgs(sender, destinationTags);
|
||||||
}
|
}
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
Destination destination = destinationServices.createDesti(
|
Destination destination = destinationServices.createDesti(
|
||||||
|
@ -72,7 +72,7 @@ public class CreatePortalSubCommand extends CreateTaggedSubCommand {
|
|||||||
|
|
||||||
if (!portalTags.isEmpty()) {
|
if (!portalTags.isEmpty()) {
|
||||||
this.filterAndProcessTags(portalTags);
|
this.filterAndProcessTags(portalTags);
|
||||||
this.printTags(sender, portalTags);
|
TagReader.printArgs(sender, portalTags);
|
||||||
}
|
}
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ public class CreatePortalSubCommand extends CreateTaggedSubCommand {
|
|||||||
sender.sendMessage(Lang.translate("messageprefix.positive")
|
sender.sendMessage(Lang.translate("messageprefix.positive")
|
||||||
+ Lang.translate("command.create.complete"));
|
+ Lang.translate("command.create.complete"));
|
||||||
sender.sendMessage(Lang.translate("command.create.tags"));
|
sender.sendMessage(Lang.translate("command.create.tags"));
|
||||||
this.printTags(sender, portal.getArgs());
|
TagReader.printArgs(sender, portal.getArgs());
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(Lang.translate("messageprefix.negative")
|
sender.sendMessage(Lang.translate("messageprefix.negative")
|
||||||
+ Lang.translate("command.create.error"));
|
+ Lang.translate("command.create.error"));
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.sekwah.advancedportals.core.commands.subcommands.portal;
|
||||||
|
|
||||||
|
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.services.PortalServices;
|
||||||
|
import com.sekwah.advancedportals.core.util.Lang;
|
||||||
|
import com.sekwah.advancedportals.core.util.TagReader;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class InfoPortalSubCommand implements SubCommand {
|
||||||
|
@Inject
|
||||||
|
PortalServices portalServices;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCommand(CommandSenderContainer sender, String[] args) {
|
||||||
|
if (args.length > 1) {
|
||||||
|
var portalName = args[1];
|
||||||
|
var portal = portalServices.getPortal(portalName);
|
||||||
|
if(portal == null) {
|
||||||
|
sender.sendMessage(Lang.translate("messageprefix.negative")
|
||||||
|
+ Lang.translateInsertVariables("command.portal.info.notfound", portalName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sender.sendMessage(Lang.translate("messageprefix.positive")
|
||||||
|
+ Lang.translateInsertVariables("command.portal.info.complete", portalName));
|
||||||
|
TagReader.printArgs(sender, portal.getArgs());
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(Lang.translate("command.portal.info.noname"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSenderContainer sender) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSenderContainer sender,
|
||||||
|
String[] args) {
|
||||||
|
return portalServices.getPortalNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBasicHelpText() {
|
||||||
|
return Lang.translate("command.portal.list.help");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDetailedHelpText() {
|
||||||
|
return Lang.translate("command.portal.list.help");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.sekwah.advancedportals.core.connector.containers;
|
||||||
|
|
||||||
|
public enum GameMode {
|
||||||
|
SURVIVAL,
|
||||||
|
CREATIVE,
|
||||||
|
ADVENTURE,
|
||||||
|
SPECTATOR
|
||||||
|
}
|
@ -40,4 +40,6 @@ public interface PlayerContainer extends EntityContainer {
|
|||||||
void playSound(String sound, float volume, float pitch);
|
void playSound(String sound, float volume, float pitch);
|
||||||
|
|
||||||
ServerContainer getServer();
|
ServerContainer getServer();
|
||||||
|
|
||||||
|
GameMode getGameMode();
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,10 @@ public class PortalServices {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AdvancedPortal getPortal(String portalName) {
|
||||||
|
return portalCache.get(portalName);
|
||||||
|
}
|
||||||
|
|
||||||
public enum PortalActivationResult {
|
public enum PortalActivationResult {
|
||||||
NOT_IN_PORTAL,
|
NOT_IN_PORTAL,
|
||||||
PORTAL_TELEPORTED,
|
PORTAL_TELEPORTED,
|
||||||
|
@ -7,6 +7,7 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository;
|
|||||||
import com.sekwah.advancedportals.core.util.Lang;
|
import com.sekwah.advancedportals.core.util.Lang;
|
||||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
|
public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
|
||||||
|
@ -11,8 +11,8 @@ import com.sekwah.advancedportals.core.util.Lang;
|
|||||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class CooldownTag implements Tag.Activation, Tag.Creation {
|
public class CooldownTag implements Tag.Activation, Tag.Creation {
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -10,8 +10,9 @@ import com.sekwah.advancedportals.core.services.DestinationServices;
|
|||||||
import com.sekwah.advancedportals.core.util.Lang;
|
import com.sekwah.advancedportals.core.util.Lang;
|
||||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||||
import java.util.List;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split {
|
public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split {
|
||||||
public static String TAG_NAME = "destination";
|
public static String TAG_NAME = "destination";
|
||||||
|
@ -4,8 +4,9 @@ import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
|||||||
import com.sekwah.advancedportals.core.registry.TagTarget;
|
import com.sekwah.advancedportals.core.registry.TagTarget;
|
||||||
import com.sekwah.advancedportals.core.util.Lang;
|
import com.sekwah.advancedportals.core.util.Lang;
|
||||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||||
import java.util.List;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the destination or portal.
|
* The name of the destination or portal.
|
||||||
|
@ -8,6 +8,7 @@ import com.sekwah.advancedportals.core.util.InfoLogger;
|
|||||||
import com.sekwah.advancedportals.core.util.Lang;
|
import com.sekwah.advancedportals.core.util.Lang;
|
||||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ public class PermissionTag implements Tag.Activation {
|
|||||||
|
|
||||||
private final String[] aliases = new String[] {"perm"};
|
private final String[] aliases = new String[] {"perm"};
|
||||||
|
|
||||||
private final TagType[] tagTypes = new TagType[] {TagType.PORTAL};
|
private final TagType[] tagTypes = new TagType[] {TagType.PORTAL, TagType.DESTINATION};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TagType[] getTagTypes() {
|
public TagType[] getTagTypes() {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.sekwah.advancedportals.core.tags;
|
package com.sekwah.advancedportals.core.tags;
|
||||||
|
|
||||||
|
import com.sekwah.advancedportals.core.connector.containers.GameMode;
|
||||||
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
||||||
import com.sekwah.advancedportals.core.registry.TagTarget;
|
import com.sekwah.advancedportals.core.registry.TagTarget;
|
||||||
import com.sekwah.advancedportals.core.repository.ConfigRepository;
|
import com.sekwah.advancedportals.core.repository.ConfigRepository;
|
||||||
@ -55,6 +56,9 @@ public class PortalEventTag implements Tag.Activation, Tag.AutoComplete, Tag.Den
|
|||||||
@Override
|
@Override
|
||||||
public boolean preActivated(TagTarget target, PlayerContainer player,
|
public boolean preActivated(TagTarget target, PlayerContainer player,
|
||||||
ActivationData activeData, String[] argData) {
|
ActivationData activeData, String[] argData) {
|
||||||
|
if(player.getGameMode() == GameMode.CREATIVE) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return !Objects.equals(argData[0], "true") || activeData.getTriggerType() == TriggerType.PORTAL;
|
return !Objects.equals(argData[0], "true") || activeData.getTriggerType() == TriggerType.PORTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,9 @@ import com.google.inject.Inject;
|
|||||||
import com.sekwah.advancedportals.core.connector.containers.ServerContainer;
|
import com.sekwah.advancedportals.core.connector.containers.ServerContainer;
|
||||||
import com.sekwah.advancedportals.core.util.Lang;
|
import com.sekwah.advancedportals.core.util.Lang;
|
||||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||||
import java.util.List;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TriggerBlockTag implements Tag.AutoComplete, Tag.Split {
|
public class TriggerBlockTag implements Tag.AutoComplete, Tag.Split {
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.sekwah.advancedportals.core.util;
|
package com.sekwah.advancedportals.core.util;
|
||||||
|
|
||||||
|
import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer;
|
||||||
import com.sekwah.advancedportals.core.serializeddata.DataTag;
|
import com.sekwah.advancedportals.core.serializeddata.DataTag;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TagReader {
|
public class TagReader {
|
||||||
public static boolean isClosedString(String[] args) {
|
public static boolean isClosedString(String[] args) {
|
||||||
@ -94,4 +96,21 @@ public class TagReader {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void printArgs(CommandSenderContainer sender,
|
||||||
|
List<DataTag> dataTags) {
|
||||||
|
for (DataTag tag : dataTags) {
|
||||||
|
if (tag.VALUES.length == 1) {
|
||||||
|
sender.sendMessage(" \u00A7a" + tag.NAME + "\u00A77:\u00A7e"
|
||||||
|
+ tag.VALUES[0]);
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < tag.VALUES.length; i++) {
|
||||||
|
sender.sendMessage(" \u00A7a" + tag.NAME + "\u00A77[" + i
|
||||||
|
+ "]:\u00A7e" + tag.VALUES[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,10 @@ value needs spaces use the format tag:"value with spaces"
|
|||||||
command.createdesti.complete= The destination has been successfully
|
command.createdesti.complete= The destination has been successfully
|
||||||
created.
|
created.
|
||||||
|
|
||||||
|
command.portal.info.complete= Portal information for &e%1$s&a:
|
||||||
|
command.portal.info.notfound= No portal by the name &e%1$s &cwas found.
|
||||||
|
|
||||||
|
|
||||||
command.create.tags=&aTags&7:
|
command.create.tags=&aTags&7:
|
||||||
|
|
||||||
command.playeronly= Sorry but that command can only be run by a player.
|
command.playeronly= Sorry but that command can only be run by a player.
|
||||||
|
@ -2,6 +2,7 @@ package com.sekwah.advancedportals.spigot.connector.container;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||||
|
import com.sekwah.advancedportals.core.connector.containers.GameMode;
|
||||||
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
||||||
import com.sekwah.advancedportals.core.connector.containers.ServerContainer;
|
import com.sekwah.advancedportals.core.connector.containers.ServerContainer;
|
||||||
import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
|
import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
|
||||||
@ -105,6 +106,15 @@ public class SpigotPlayerContainer
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameMode getGameMode() {
|
||||||
|
try {
|
||||||
|
return GameMode.valueOf(this.player.getGameMode().name());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return GameMode.SURVIVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return this.player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user