mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-25 03:55:23 +01:00
chore: switch /portal update to import
This commit is contained in:
parent
ffddd87922
commit
471c2aa011
@ -122,7 +122,6 @@ public class PortalServices {
|
|||||||
playerData.setInPortal(portal.getName());
|
playerData.setInPortal(portal.getName());
|
||||||
var strength = configRepository.getThrowbackStrength();
|
var strength = configRepository.getThrowbackStrength();
|
||||||
PlayerUtils.throwPlayerBack(player, strength);
|
PlayerUtils.throwPlayerBack(player, strength);
|
||||||
|
|
||||||
return PortalActivationResult.PORTAL_DENIED;
|
return PortalActivationResult.PORTAL_DENIED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class PermissionTag implements Tag.Activation {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public String[] getAliases() {
|
public String[] getAliases() {
|
||||||
return new String[0];
|
return aliases;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.sekwah.advancedportals.core.tags;
|
package com.sekwah.advancedportals.core.tags;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
||||||
import com.sekwah.advancedportals.core.portal.AdvancedPortal;
|
|
||||||
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;
|
||||||
import com.sekwah.advancedportals.core.services.PlayerDataServices;
|
import com.sekwah.advancedportals.core.services.PlayerDataServices;
|
||||||
@ -10,11 +8,10 @@ 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 java.util.Random;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class PortalEventTag implements Tag.Activation, Tag.Creation {
|
public class PortalEventTag implements Tag.Activation {
|
||||||
@Inject
|
@Inject
|
||||||
PlayerDataServices playerDataServices;
|
PlayerDataServices playerDataServices;
|
||||||
|
|
||||||
@ -24,7 +21,9 @@ public class PortalEventTag implements Tag.Activation, Tag.Creation {
|
|||||||
@Inject
|
@Inject
|
||||||
private InfoLogger infoLogger;
|
private InfoLogger infoLogger;
|
||||||
|
|
||||||
public static String TAG_NAME = "cooldown";
|
public static String TAG_NAME = "portalEvent";
|
||||||
|
|
||||||
|
private final String[] aliases = new String[] {"delayed"};
|
||||||
|
|
||||||
private final TagType[] tagTypes = new TagType[] {TagType.PORTAL};
|
private final TagType[] tagTypes = new TagType[] {TagType.PORTAL};
|
||||||
|
|
||||||
@ -41,55 +40,27 @@ public class PortalEventTag implements Tag.Activation, Tag.Creation {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public String[] getAliases() {
|
public String[] getAliases() {
|
||||||
return null;
|
return new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String description() {
|
public String description() {
|
||||||
return Lang.translate("tag.cooldown.description");
|
return Lang.translate("tag.permission.description");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean preActivated(TagTarget target, PlayerContainer player,
|
public boolean preActivated(TagTarget target, PlayerContainer player,
|
||||||
ActivationData activationData,
|
ActivationData activeData, String[] argData) {
|
||||||
String[] argData) {
|
if (!player.hasPermission(argData[1])) {
|
||||||
var playerData = playerDataServices.getPlayerData(player);
|
player.sendMessage(Lang.translate("portal.error.nopermission"));
|
||||||
if (target instanceof AdvancedPortal portal) {
|
|
||||||
var portalName = portal.getName();
|
|
||||||
if (playerData.hasPortalCooldown(portalName)) {
|
|
||||||
var cooldown = (int) Math.ceil(
|
|
||||||
playerData.getPortalCooldownLeft(portalName) / 1000D);
|
|
||||||
player.sendMessage(Lang.translateInsertVariables(
|
|
||||||
"portal.cooldown.individual", cooldown,
|
|
||||||
Lang.translate(cooldown == 1 ? "time.second"
|
|
||||||
: "time.seconds")));
|
|
||||||
if (configRepository.playFailSound()) {
|
|
||||||
player.playSound("block.portal.travel", 0.05f,
|
|
||||||
new Random().nextFloat() * 0.4F + 0.8F);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postActivated(TagTarget target, PlayerContainer player,
|
public void postActivated(TagTarget target, PlayerContainer player,
|
||||||
ActivationData activationData, String[] argData) {
|
ActivationData activationData, String[] argData) {
|
||||||
if (activationData.hasActivated()) {
|
|
||||||
if (target instanceof AdvancedPortal portal) {
|
|
||||||
var playerData = playerDataServices.getPlayerData(player);
|
|
||||||
try {
|
|
||||||
playerData.setPortalCooldown(
|
|
||||||
portal.getName(), Integer.parseInt(argData[0]) * 1000);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
infoLogger.warning(
|
|
||||||
"Cooldown tag failed to set cooldown for portal: "
|
|
||||||
+ portal.getName() + " with value: " + argData[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -97,22 +68,4 @@ public class PortalEventTag implements Tag.Activation, Tag.Creation {
|
|||||||
ActivationData activationData, String[] argData) {
|
ActivationData activationData, String[] argData) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean created(TagTarget target, PlayerContainer player,
|
|
||||||
String[] argData) {
|
|
||||||
try {
|
|
||||||
Integer.parseInt(argData[0]);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
player.sendMessage(Lang.translate("messageprefix.negative")
|
|
||||||
+ Lang.translate("tag.cooldown.fail"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void destroyed(TagTarget target, PlayerContainer player,
|
|
||||||
String[] argData) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -119,11 +119,11 @@ command.selector= You have been given a portal selector.
|
|||||||
command.selector.help=Gives you a portal region selector
|
command.selector.help=Gives you a portal region selector
|
||||||
command.selector.detailedhelp=Gives you a portal selector to select the regions for making portals.
|
command.selector.detailedhelp=Gives you a portal selector to select the regions for making portals.
|
||||||
|
|
||||||
command.portal.update= &e%1$s &aportals and &e%2$s &adestinations will be imported. Please type &e/portal update confirm &ato confirm this action. &7Config values will not be imported.
|
command.portal.import= &e%1$s &aportals and &e%2$s &adestinations will be imported. Please type &e/portal import confirm &ato confirm this action. &7Config values will not be imported.
|
||||||
command.portal.update.confirm= &aImporting portals and destinations.
|
command.portal.import.confirm= &aImporting portals and destinations.
|
||||||
command.portal.update.complete= &aImported &e%1$s &aportals and &e%2$s &adestinations.
|
command.portal.import.complete= &aImported &e%1$s &aportals and &e%2$s &adestinations.
|
||||||
command.portal.update.help=Imports portals and destinations from the old format.
|
command.portal.import.help=Imports portals and destinations from the old format.
|
||||||
command.portal.update.detailedhelp=Imports portals and destinations from the old format. This not overwrite any existing portals and destinations with the same name.
|
command.portal.import.detailedhelp=Imports portals and destinations from the old format. This not overwrite any existing portals and destinations with the same name.
|
||||||
|
|
||||||
command.portalblock= You have been given a &ePortal Block&a!
|
command.portalblock= You have been given a &ePortal Block&a!
|
||||||
|
|
||||||
@ -174,6 +174,7 @@ tag.desti.description=Sets the destination of the portal
|
|||||||
tag.name.error.nospaces= The name cannot contain spaces.
|
tag.name.error.nospaces= The name cannot contain spaces.
|
||||||
tag.triggerblock.description=Sets the trigger block/s of the portal. Comma separated or multi tag.
|
tag.triggerblock.description=Sets the trigger block/s of the portal. Comma separated or multi tag.
|
||||||
tag.command.description=Sets a command on the post activation of the portal. Comma separated or multi tag.
|
tag.command.description=Sets a command on the post activation of the portal. Comma separated or multi tag.
|
||||||
|
tag.portalEvent.description=Triggers the portal from portal events rather than the player entering the portal. (survival nether portal)
|
||||||
|
|
||||||
tag.cooldown.fail= The cooldown must be a number.
|
tag.cooldown.fail= The cooldown must be a number.
|
||||||
tag.command.nopermission= You do not have permission to create a command at %1$s command level
|
tag.command.nopermission= You do not have permission to create a command at %1$s command level
|
||||||
@ -182,3 +183,4 @@ tag.command.disabled= Command portals are &edisabled &con this server. Please co
|
|||||||
tag.command.op.disabled= Op command portals are &edisabled &con this server. Please contact a server admin if this is an issue.
|
tag.command.op.disabled= Op command portals are &edisabled &con this server. Please contact a server admin if this is an issue.
|
||||||
tag.command.console.disabled= Console command portals are &edisabled &con this server. Please contact a server admin if this is an issue.
|
tag.command.console.disabled= Console command portals are &edisabled &con this server. Please contact a server admin if this is an issue.
|
||||||
tag.command.permswildcard.disabled= Wildcard &e*&c permission command portals are &edisabled &con this server. Please contact a server admin if this is an issue.
|
tag.command.permswildcard.disabled= Wildcard &e*&c permission command portals are &edisabled &con this server. Please contact a server admin if this is an issue.
|
||||||
|
|
||||||
|
@ -10,39 +10,37 @@ import com.sekwah.advancedportals.core.services.DestinationServices;
|
|||||||
import com.sekwah.advancedportals.core.services.PortalServices;
|
import com.sekwah.advancedportals.core.services.PortalServices;
|
||||||
import com.sekwah.advancedportals.core.util.Lang;
|
import com.sekwah.advancedportals.core.util.Lang;
|
||||||
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
|
||||||
import com.sekwah.advancedportals.spigot.commands.subcommands.portal.update.ConfigAccessor;
|
import com.sekwah.advancedportals.spigot.commands.subcommands.portal.importer.ConfigAccessor;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
public class UpdatePortalSubCommand implements SubCommand {
|
public class ImportPortalSubCommand implements SubCommand {
|
||||||
@Inject
|
|
||||||
PortalServices portalServices;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
DestinationServices destinationServices;
|
DestinationServices destinationServices;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
PortalServices portalService;
|
PortalServices portalServices;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSenderContainer sender, String[] args) {
|
public void onCommand(CommandSenderContainer sender, String[] args) {
|
||||||
if (args.length > 1 && "confirm".equals(args[1])) {
|
if (args.length > 1 && "confirm".equals(args[1])) {
|
||||||
sender.sendMessage(Lang.translate("messageprefix.positive")
|
sender.sendMessage(Lang.translate("messageprefix.positive")
|
||||||
+ Lang.translateInsertVariables(
|
+ Lang.translateInsertVariables(
|
||||||
"command.portal.update.confirm"));
|
"command.portal.import.confirm"));
|
||||||
int destinations = importDestinations();
|
int destinations = importDestinations();
|
||||||
int portals = importPortals();
|
int portals = importPortals();
|
||||||
sender.sendMessage(
|
sender.sendMessage(
|
||||||
Lang.translate("messageprefix.positive")
|
Lang.translate("messageprefix.positive")
|
||||||
+ Lang.translateInsertVariables(
|
+ Lang.translateInsertVariables(
|
||||||
"command.portal.update.complete", portals, destinations));
|
"command.portal.import.complete", portals, destinations));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(Lang.translate("messageprefix.positive")
|
sender.sendMessage(Lang.translate("messageprefix.positive")
|
||||||
+ Lang.translateInsertVariables(
|
+ Lang.translateInsertVariables(
|
||||||
"command.portal.update", getPortalCount(),
|
"command.portal.import", getPortalCount(),
|
||||||
getDestinationCount()));
|
getDestinationCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +110,7 @@ public class UpdatePortalSubCommand implements SubCommand {
|
|||||||
.toList()
|
.toList()
|
||||||
.forEach(args::remove);
|
.forEach(args::remove);
|
||||||
|
|
||||||
var portal = portalService.createPortal(pos1, pos2, args);
|
var portal = portalServices.createPortal(pos1, pos2, args);
|
||||||
|
|
||||||
if (portal != null)
|
if (portal != null)
|
||||||
count++;
|
count++;
|
||||||
@ -185,11 +183,11 @@ public class UpdatePortalSubCommand implements SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBasicHelpText() {
|
public String getBasicHelpText() {
|
||||||
return Lang.translate("command.portal.update.help");
|
return Lang.translate("command.portal.import.help");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDetailedHelpText() {
|
public String getDetailedHelpText() {
|
||||||
return Lang.translate("command.portal.update.detailedhelp");
|
return Lang.translate("command.portal.import.detailedhelp");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.sekwah.advancedportals.spigot.commands.subcommands.portal.update;
|
package com.sekwah.advancedportals.spigot.commands.subcommands.portal.importer;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
Loading…
Reference in New Issue
Block a user