mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-06-26 06:24:51 +02:00
Add teleport-message flag
This commit is contained in:
parent
4c351fb0e3
commit
20f89ea2ae
|
@ -25,6 +25,7 @@
|
|||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.util.MessagingUtil;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.BanList.Type;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -190,9 +191,13 @@ public void teleport(Location location, String successMessage, String failMessag
|
|||
PaperLib.teleportAsync(getPlayer(), BukkitAdapter.adapt(location))
|
||||
.thenApply(success -> {
|
||||
if (success) {
|
||||
print(successMessage);
|
||||
if (successMessage != null && !successMessage.isEmpty()) {
|
||||
MessagingUtil.sendStringToChat(this, successMessage);
|
||||
}
|
||||
} else {
|
||||
printError(failMessage);
|
||||
if (failMessage != null && !failMessage.isEmpty()) {
|
||||
printError(failMessage);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
});
|
||||
|
|
|
@ -1111,8 +1111,10 @@ public void teleport(CommandContext args, Actor sender) throws CommandException
|
|||
}
|
||||
}
|
||||
|
||||
player.teleport(teleportLocation,
|
||||
"Teleported you to the region '" + existing.getId() + "'.",
|
||||
String message = existing.getFlag(Flags.TELE_MESSAGE);
|
||||
message = message == null ? Flags.TELE_MESSAGE.getDefault() : message;
|
||||
message = message == null ? "" : message.replace("%id%", existing.getId());
|
||||
player.teleport(teleportLocation, message,
|
||||
"Unable to teleport to region '" + existing.getId() + "'.");
|
||||
}
|
||||
|
||||
|
|
|
@ -134,6 +134,8 @@ public final class Flags {
|
|||
public static final LocationFlag TELE_LOC = register(new LocationFlag("teleport", RegionGroup.MEMBERS));
|
||||
public static final LocationFlag SPAWN_LOC = register(new LocationFlag("spawn", RegionGroup.MEMBERS));
|
||||
|
||||
public static final StringFlag TELE_MESSAGE = register(new StringFlag("teleport-message", "\u00A7dTeleported you to the region '%id%'."));
|
||||
|
||||
// idk?
|
||||
public static final StateFlag INVINCIBILITY = register(new StateFlag("invincible", false));
|
||||
public static final StateFlag FALL_DAMAGE = register(new StateFlag("fall-damage", true));
|
||||
|
|
Loading…
Reference in New Issue
Block a user