Adds an option for silent stargates which don't print teleportation messages or errors to the player's chat #7
This commit is contained in:
parent
4566c15350
commit
8c4cf16375
@ -59,7 +59,8 @@ stargate.option -- Allow use of all options
|
||||
stargate.option.backwards -- Allow use of 'B'ackwards
|
||||
stargate.option.show -- Allow use of 'S'how
|
||||
stargate.option.nonetwork -- Allow use of 'N'oNetwork
|
||||
stargate.option.random -- Allow use of 'Random' stargates
|
||||
stargate.option.random -- Allow use of 'R'andom stargates
|
||||
stargate.option.silent -- Allow use of S'i'lent stargates
|
||||
|
||||
stargate.create -- Allow creating Stargates on any network (Override all create permissions)
|
||||
stargate.create.personal -- Allow creating Stargates on network {playername}
|
||||
@ -129,6 +130,7 @@ section). See the Custom Gate Layout section to learn how to add custom gates.
|
||||
- 'R' is for random gates. These follow standard permissions of gates, but have a random exit location every time a
|
||||
player enters.
|
||||
- 'U' is for a gate connecting to another through bungee
|
||||
- 'I' is for a silent gate, which does not output anything to the chat while teleporting. Increases immersion
|
||||
|
||||
The options are the single letter, not the word. So to make a private hidden gate, your 4th line would be 'PH'.
|
||||
|
||||
@ -376,6 +378,7 @@ bungeeSign=Teleport to
|
||||
|
||||
- Makes containers no longer open when used as buttons
|
||||
- Validates and updates stargate buttons when the plugin is loaded or reloaded
|
||||
- Adds an option to make a stargate silent (no text in chat when teleporting) for better immersion on RP servers
|
||||
|
||||
#### \[Version 0.9.0.5] EpicKnarvik97 fork
|
||||
|
||||
|
@ -119,7 +119,9 @@ public class PlayerEventListener implements Listener {
|
||||
//Just teleport the player like normal
|
||||
new PlayerTeleporter(destination, player).teleport(entrancePortal, event);
|
||||
}
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString("teleportMsg"));
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString("teleportMsg"));
|
||||
}
|
||||
entrancePortal.getPortalOpener().closePortal(false);
|
||||
}
|
||||
|
||||
@ -159,7 +161,7 @@ public class PlayerEventListener implements Listener {
|
||||
|
||||
//Decide if the user should be teleported to another bungee server
|
||||
if (entrancePortal.getOptions().isBungee()) {
|
||||
if (BungeeHelper.bungeeTeleport(player, entrancePortal, event)) {
|
||||
if (BungeeHelper.bungeeTeleport(player, entrancePortal, event) && !entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString("teleportMsg"));
|
||||
}
|
||||
return false;
|
||||
@ -241,7 +243,9 @@ public class PlayerEventListener implements Listener {
|
||||
boolean deny = PermissionHelper.cannotAccessNetwork(player, portal.getNetwork());
|
||||
|
||||
if (PermissionHelper.portalAccessDenied(player, portal, deny)) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
if (!portal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -89,7 +89,9 @@ public class VehicleEventListener implements Listener {
|
||||
//On the assumption that a non-player cannot sit in the driver's seat and since some portals can only be open
|
||||
// to one player at a time, we only need to check if the portal is open to the driver.
|
||||
if (!entrancePortal.getPortalOpener().isOpenFor(player)) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -118,7 +120,9 @@ public class VehicleEventListener implements Listener {
|
||||
//Teleport the vehicle and inform the user if the vehicle was teleported
|
||||
boolean teleported = new VehicleTeleporter(destinationPortal, vehicle).teleport(entrancePortal);
|
||||
if (teleported) {
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString("teleportMsg"));
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendSuccessMessage(player, Stargate.getString("teleportMsg"));
|
||||
}
|
||||
entrancePortal.getPortalOpener().closePortal(false);
|
||||
}
|
||||
}
|
||||
@ -152,7 +156,9 @@ public class VehicleEventListener implements Listener {
|
||||
private static boolean playerCanTeleport(Player player, Portal entrancePortal, Portal destinationPortal) {
|
||||
//Make sure the user can access the portal
|
||||
if (PermissionHelper.cannotAccessPortal(player, entrancePortal, destinationPortal)) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
}
|
||||
entrancePortal.getPortalOpener().closePortal(false);
|
||||
return false;
|
||||
}
|
||||
@ -160,7 +166,7 @@ public class VehicleEventListener implements Listener {
|
||||
//Check if the player is able to afford the teleport fee
|
||||
int cost = Stargate.getEconomyConfig().getUseCost(player, entrancePortal, destinationPortal);
|
||||
boolean canAffordFee = cost <= 0 || Stargate.getEconomyConfig().canAffordFee(player, cost);
|
||||
if (!canAffordFee) {
|
||||
if (!canAffordFee && !entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("ecoInFunds"));
|
||||
}
|
||||
return canAffordFee;
|
||||
|
@ -248,7 +248,9 @@ public class PortalActivator {
|
||||
|
||||
//If no destinations are available, just tell the player and quit
|
||||
if (destinations.size() == 0) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("destEmpty"));
|
||||
if (!portal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("destEmpty"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,12 @@ public enum PortalOption {
|
||||
/**
|
||||
* This option allows a portal to teleport to another server connected through BungeeCord
|
||||
*/
|
||||
BUNGEE('u', "stargate.admin.bungee", 20);
|
||||
BUNGEE('u', "stargate.admin.bungee", 20),
|
||||
|
||||
/**
|
||||
* This option allows a portal which does not display a teleportation message, for better immersion
|
||||
*/
|
||||
SILENT('i', "stargate.option.silent", 21);
|
||||
|
||||
private final char characterRepresentation;
|
||||
private final String permissionString;
|
||||
|
@ -165,4 +165,16 @@ public class PortalOptions {
|
||||
return this.options.get(PortalOption.BUNGEE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether this portal is silent
|
||||
*
|
||||
* <p>A silent portal does not output anything to the chat when teleporting. This option is mainly useful to keep
|
||||
* the immersion during teleportation (for role-playing servers or similar).</p>
|
||||
*
|
||||
* @return <p>Whether this portal is silent</p>
|
||||
*/
|
||||
public boolean isSilent() {
|
||||
return this.options.get(PortalOption.SILENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -181,7 +181,9 @@ public final class BungeeHelper {
|
||||
public static boolean bungeeTeleport(Player player, Portal entrancePortal, PlayerMoveEvent event) {
|
||||
//Check if bungee is actually enabled
|
||||
if (!Stargate.getGateConfig().enableBungee()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("bungeeDisabled"));
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("bungeeDisabled"));
|
||||
}
|
||||
entrancePortal.getPortalOpener().closePortal(false);
|
||||
return false;
|
||||
}
|
||||
|
@ -33,7 +33,9 @@ public final class PermissionHelper {
|
||||
|
||||
//Destination is invalid or the same portal. Send an error message
|
||||
if (destination == null || destination == portal) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("invalidMsg"));
|
||||
if (!portal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("invalidMsg"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -49,19 +51,25 @@ public final class PermissionHelper {
|
||||
//Deny access if another player has activated the portal, and it's still in use
|
||||
if (!portal.getOptions().isFixed() && portal.getPortalActivator().isActive() &&
|
||||
portal.getActivePlayer() != player) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
if (!portal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//Check if the player can use the private gate
|
||||
if (portal.getOptions().isPrivate() && !PermissionHelper.canUsePrivatePortal(player, portal)) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
if (!portal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//Destination is currently in use by another player, blocking teleportation
|
||||
if (destination.isOpen() && !destination.getOptions().isAlwaysOn()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("blockMsg"));
|
||||
if (!portal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("blockMsg"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -374,7 +382,9 @@ public final class PermissionHelper {
|
||||
|
||||
//Not open for this player
|
||||
if (!entrancePortal.getPortalOpener().isOpenFor(player)) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
}
|
||||
new PlayerTeleporter(entrancePortal, player).teleport(entrancePortal, event);
|
||||
return true;
|
||||
}
|
||||
@ -386,7 +396,9 @@ public final class PermissionHelper {
|
||||
|
||||
//Player cannot access portal
|
||||
if (PermissionHelper.cannotAccessPortal(player, entrancePortal, destination)) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
if (!entrancePortal.getOptions().isSilent()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
}
|
||||
new PlayerTeleporter(entrancePortal, player).teleport(entrancePortal, event);
|
||||
entrancePortal.getPortalOpener().closePortal(false);
|
||||
return true;
|
||||
|
@ -121,7 +121,8 @@ public final class PortalFileHelper {
|
||||
builder.append(options.isShown()).append(':');
|
||||
builder.append(options.isNoNetwork()).append(':');
|
||||
builder.append(options.isRandom()).append(':');
|
||||
builder.append(options.isBungee());
|
||||
builder.append(options.isBungee()).append(':');
|
||||
builder.append(options.isSilent());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -249,7 +250,8 @@ public final class PortalFileHelper {
|
||||
|
||||
//Load extra portal data
|
||||
String destination = (portalData.length > 8) ? portalData[8] : "";
|
||||
String network = (portalData.length > 9 && !portalData[9].isEmpty()) ? portalData[9] : Stargate.getDefaultNetwork();
|
||||
String network = (portalData.length > 9 && !portalData[9].isEmpty()) ? portalData[9] :
|
||||
Stargate.getDefaultNetwork();
|
||||
String ownerString = (portalData.length > 10) ? portalData[10] : "";
|
||||
|
||||
//Get the owner from the owner string
|
||||
|
@ -97,6 +97,7 @@ permissions:
|
||||
stargate.option.show: true
|
||||
stargate.option.nonetwork: true
|
||||
stargate.option.random: true
|
||||
stargate.option.silent: true
|
||||
stargate.option.hidden:
|
||||
description: Allows the creation of a hidden stargate
|
||||
default: false
|
||||
@ -121,6 +122,9 @@ permissions:
|
||||
stargate.option.random:
|
||||
description: Allows the creation of a stargate with a random destination
|
||||
default: false
|
||||
stargate.option.silent:
|
||||
description: Allows the creation of a stargate which does not output anything to the chat
|
||||
default: false
|
||||
stargate.admin.hidden:
|
||||
description: Allows this player to see all hidden stargates
|
||||
default: false
|
||||
|
Loading…
x
Reference in New Issue
Block a user