mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 06:28:49 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
25 files changed
+51
-54
No files matched your search
@@ -41,6 +41,9 @@ jobs:
|
|||||||
modrinth-id: J6U9o3JG
|
modrinth-id: J6U9o3JG
|
||||||
modrinth-featured: false
|
modrinth-featured: false
|
||||||
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
|
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
|
||||||
|
modrinth-dependencies: |
|
||||||
|
bluemap | suggests | *
|
||||||
|
dynmap | suggests | *
|
||||||
files-primary: target/HuskHomes-Plugin-*.jar
|
files-primary: target/HuskHomes-Plugin-*.jar
|
||||||
name: HuskHomes v${{ env.version_name }}
|
name: HuskHomes v${{ env.version_name }}
|
||||||
version: ${{ env.version_name }}
|
version: ${{ env.version_name }}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
|||||||
this.manager = new Manager(this);
|
this.manager = new Manager(this);
|
||||||
|
|
||||||
// Initialize the network messenger if proxy mode is enabled
|
// Initialize the network messenger if proxy mode is enabled
|
||||||
if (getSettings().isCrossServer()) {
|
if (getSettings().doCrossServer()) {
|
||||||
initialize("message broker", (plugin) -> {
|
initialize("message broker", (plugin) -> {
|
||||||
broker = switch (settings.getBrokerType()) {
|
broker = switch (settings.getBrokerType()) {
|
||||||
case PLUGIN_MESSAGE -> new PluginMessageBroker(this);
|
case PLUGIN_MESSAGE -> new PluginMessageBroker(this);
|
||||||
@@ -391,7 +391,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
|||||||
this.locales = Annotaml.create(new File(getDataFolder(), "messages_" + settings.getLanguage() + ".yml"), languagePresets).get();
|
this.locales = Annotaml.create(new File(getDataFolder(), "messages_" + settings.getLanguage() + ".yml"), languagePresets).get();
|
||||||
|
|
||||||
// Load server from file
|
// Load server from file
|
||||||
if (settings.isCrossServer()) {
|
if (settings.doCrossServer()) {
|
||||||
this.server = Annotaml.create(new File(getDataFolder(), "server.yml"), Server.class).get();
|
this.server = Annotaml.create(new File(getDataFolder(), "server.yml"), Server.class).get();
|
||||||
} else {
|
} else {
|
||||||
this.server = new Server(Server.getDefaultServerName());
|
this.server = new Server(Server.getDefaultServerName());
|
||||||
@@ -423,8 +423,8 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
|||||||
public void registerMetrics(int metricsId) {
|
public void registerMetrics(int metricsId) {
|
||||||
try {
|
try {
|
||||||
final Metrics metrics = new Metrics(this, metricsId);
|
final Metrics metrics = new Metrics(this, metricsId);
|
||||||
metrics.addCustomChart(new SimplePie("bungee_mode", () -> Boolean.toString(getSettings().isCrossServer())));
|
metrics.addCustomChart(new SimplePie("bungee_mode", () -> Boolean.toString(getSettings().doCrossServer())));
|
||||||
if (getSettings().isCrossServer()) {
|
if (getSettings().doCrossServer()) {
|
||||||
metrics.addCustomChart(new SimplePie("messenger_type", () -> getSettings().getBrokerType().getDisplayName()));
|
metrics.addCustomChart(new SimplePie("messenger_type", () -> getSettings().getBrokerType().getDisplayName()));
|
||||||
}
|
}
|
||||||
metrics.addCustomChart(new SimplePie("language", () -> getSettings().getLanguage().toLowerCase()));
|
metrics.addCustomChart(new SimplePie("language", () -> getSettings().getLanguage().toLowerCase()));
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class BukkitEventListener extends EventListener implements Listener {
|
|||||||
// (https://jd.papermc.io/paper/1.19/com/destroystokyo/paper/event/player/PlayerSetSpawnEvent.html)
|
// (https://jd.papermc.io/paper/1.19/com/destroystokyo/paper/event/player/PlayerSetSpawnEvent.html)
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerUpdateRespawnLocation(PlayerInteractEvent event) {
|
public void onPlayerUpdateRespawnLocation(PlayerInteractEvent event) {
|
||||||
if (!(plugin.getSettings().isCrossServer() && plugin.getSettings().isGlobalRespawning())) return;
|
if (!(plugin.getSettings().doCrossServer() && plugin.getSettings().isGlobalRespawning())) return;
|
||||||
if (event.getClickedBlock() == null) return;
|
if (event.getClickedBlock() == null) return;
|
||||||
if (!(event.getClickedBlock().getBlockData() instanceof Bed
|
if (!(event.getClickedBlock().getBlockData() instanceof Bed
|
||||||
|| event.getClickedBlock().getBlockData() instanceof RespawnAnchor)) return;
|
|| event.getClickedBlock().getBlockData() instanceof RespawnAnchor)) return;
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public interface HuskHomes extends TaskRunner, EventDispatcher {
|
|||||||
* @return the {@link Position} of the spawn, or an empty {@link Optional} if it has not been set
|
* @return the {@link Position} of the spawn, or an empty {@link Optional} if it has not been set
|
||||||
*/
|
*/
|
||||||
default Optional<Position> getSpawn() {
|
default Optional<Position> getSpawn() {
|
||||||
return getSettings().isCrossServer() && getSettings().isGlobalSpawn()
|
return getSettings().doCrossServer() && getSettings().isGlobalSpawn()
|
||||||
? getDatabase().getWarp(getSettings().getGlobalSpawnName()).map(warp -> (Position) warp)
|
? getDatabase().getWarp(getSettings().getGlobalSpawnName()).map(warp -> (Position) warp)
|
||||||
: getLocalCachedSpawn().map(spawn -> spawn.getPosition(getServerName()));
|
: getLocalCachedSpawn().map(spawn -> spawn.getPosition(getServerName()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public abstract class BaseHuskHomesAPI {
|
|||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public CompletableFuture<Optional<Position>> getUserRespawnPosition(@NotNull User user) {
|
public CompletableFuture<Optional<Position>> getUserRespawnPosition(@NotNull User user) {
|
||||||
if (!plugin.getSettings().isCrossServer() || plugin.getSettings().isGlobalRespawning()) {
|
if (!plugin.getSettings().doCrossServer() || plugin.getSettings().isGlobalRespawning()) {
|
||||||
return CompletableFuture.completedFuture(Optional.empty());
|
return CompletableFuture.completedFuture(Optional.empty());
|
||||||
}
|
}
|
||||||
return plugin.supplyAsync(() -> plugin.getDatabase().getRespawnPosition(user));
|
return plugin.supplyAsync(() -> plugin.getDatabase().getRespawnPosition(user));
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class DelWarpCommand extends SavedPositionCommand<Warp> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(@NotNull CommandUser executor, @NotNull Warp warp, @NotNull String[] args) {
|
public void execute(@NotNull CommandUser executor, @NotNull Warp warp, @NotNull String[] args) {
|
||||||
if (plugin.getSettings().isPermissionRestrictWarps() && !executor.hasPermission(warp.getPermission())
|
if (plugin.getSettings().doPermissionRestrictWarps() && !executor.hasPermission(warp.getPermission())
|
||||||
&& !executor.hasPermission(Warp.getWildcardPermission())) {
|
&& !executor.hasPermission(Warp.getWildcardPermission())) {
|
||||||
plugin.getLocales().getLocale("error_no_permission")
|
plugin.getLocales().getLocale("error_no_permission")
|
||||||
.ifPresent(executor::sendMessage);
|
.ifPresent(executor::sendMessage);
|
||||||
|
|||||||
@@ -227,13 +227,12 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
|
|||||||
|
|
||||||
if (home.getMeta().getDescription().length() > 0) {
|
if (home.getMeta().getDescription().length() > 0) {
|
||||||
plugin.getLocales().getLocale("edit_home_menu_description",
|
plugin.getLocales().getLocale("edit_home_menu_description",
|
||||||
home.getMeta().getDescription().length() > 50
|
plugin.getLocales().truncateText(home.getMeta().getDescription(), 50),
|
||||||
? home.getMeta().getDescription().substring(0, 49).trim() + "…" : home.getMeta().getDescription(),
|
|
||||||
plugin.getLocales().wrapText(home.getMeta().getDescription(), 40))
|
plugin.getLocales().wrapText(home.getMeta().getDescription(), 40))
|
||||||
.ifPresent(this::add);
|
.ifPresent(this::add);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.getSettings().isCrossServer()) {
|
if (!plugin.getSettings().doCrossServer()) {
|
||||||
plugin.getLocales().getLocale("edit_home_menu_world", home.getWorld().getName())
|
plugin.getLocales().getLocale("edit_home_menu_world", home.getWorld().getName())
|
||||||
.ifPresent(this::add);
|
.ifPresent(this::add);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -135,13 +135,12 @@ public class EditWarpCommand extends SavedPositionCommand<Warp> {
|
|||||||
|
|
||||||
if (warp.getMeta().getDescription().length() > 0) {
|
if (warp.getMeta().getDescription().length() > 0) {
|
||||||
plugin.getLocales().getLocale("edit_warp_menu_description",
|
plugin.getLocales().getLocale("edit_warp_menu_description",
|
||||||
warp.getMeta().getDescription().length() > 50
|
plugin.getLocales().truncateText(warp.getMeta().getDescription(), 50),
|
||||||
? warp.getMeta().getDescription().substring(0, 49).trim() + "…" : warp.getMeta().getDescription(),
|
|
||||||
plugin.getLocales().wrapText(warp.getMeta().getDescription(), 40))
|
plugin.getLocales().wrapText(warp.getMeta().getDescription(), 40))
|
||||||
.ifPresent(this::add);
|
.ifPresent(this::add);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.getSettings().isCrossServer()) {
|
if (!plugin.getSettings().doCrossServer()) {
|
||||||
plugin.getLocales().getLocale("edit_warp_menu_world", warp.getWorld().getName()).ifPresent(this::add);
|
plugin.getLocales().getLocale("edit_warp_menu_world", warp.getWorld().getName()).ifPresent(this::add);
|
||||||
} else {
|
} else {
|
||||||
plugin.getLocales().getLocale("edit_warp_menu_world_server", warp.getWorld().getName(), warp.getServer()).ifPresent(this::add);
|
plugin.getLocales().getLocale("edit_warp_menu_world_server", warp.getWorld().getName(), warp.getServer()).ifPresent(this::add);
|
||||||
|
|||||||
@@ -97,9 +97,8 @@ public class HuskHomesCommand extends Command implements TabProvider {
|
|||||||
.filter(command -> user.hasPermission(command.getPermission()))
|
.filter(command -> user.hasPermission(command.getPermission()))
|
||||||
.map(command -> plugin.getLocales().getRawLocale("command_list_item",
|
.map(command -> plugin.getLocales().getRawLocale("command_list_item",
|
||||||
Locales.escapeText(command.getName()),
|
Locales.escapeText(command.getName()),
|
||||||
Locales.escapeText(command.getDescription().length() > 50
|
Locales.escapeText(plugin.getLocales()
|
||||||
? command.getDescription().substring(0, 49).trim() + "…"
|
.truncateText(command.getDescription(), 50)),
|
||||||
: command.getDescription()),
|
|
||||||
Locales.escapeText(plugin.getLocales()
|
Locales.escapeText(plugin.getLocales()
|
||||||
.wrapText(command.getUsage() + "\n" + command.getDescription(), 40)))
|
.wrapText(command.getUsage() + "\n" + command.getDescription(), 40)))
|
||||||
.orElse(command.getName()))
|
.orElse(command.getName()))
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public abstract class SavedPositionCommand<T extends SavedPosition> extends Comm
|
|||||||
|
|
||||||
private Optional<Warp> resolveWarp(@NotNull CommandUser executor, @NotNull String warpName) {
|
private Optional<Warp> resolveWarp(@NotNull CommandUser executor, @NotNull String warpName) {
|
||||||
final Optional<Warp> warp = plugin.getDatabase().getWarp(warpName);
|
final Optional<Warp> warp = plugin.getDatabase().getWarp(warpName);
|
||||||
if (warp.isPresent() && executor instanceof OnlineUser user && plugin.getSettings().isPermissionRestrictWarps()
|
if (warp.isPresent() && executor instanceof OnlineUser user && plugin.getSettings().doPermissionRestrictWarps()
|
||||||
&& (!user.hasPermission(Warp.getWildcardPermission()) && !user.hasPermission(Warp.getPermission(warpName)))) {
|
&& (!user.hasPermission(Warp.getWildcardPermission()) && !user.hasPermission(Warp.getPermission(warpName)))) {
|
||||||
plugin.getLocales().getLocale("error_warp_invalid", warpName)
|
plugin.getLocales().getLocale("error_warp_invalid", warpName)
|
||||||
.ifPresent(executor::sendMessage);
|
.ifPresent(executor::sendMessage);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class SetSpawnCommand extends InGameCommand {
|
|||||||
public void execute(@NotNull OnlineUser executor, @NotNull String[] args) {
|
public void execute(@NotNull OnlineUser executor, @NotNull String[] args) {
|
||||||
final Position position = executor.getPosition();
|
final Position position = executor.getPosition();
|
||||||
try {
|
try {
|
||||||
if (plugin.getSettings().isCrossServer() && plugin.getSettings().isGlobalSpawn()) {
|
if (plugin.getSettings().doCrossServer() && plugin.getSettings().isGlobalSpawn()) {
|
||||||
final String warpName = plugin.getSettings().getGlobalSpawnName();
|
final String warpName = plugin.getSettings().getGlobalSpawnName();
|
||||||
plugin.getManager().warps().createWarp(warpName, position, true);
|
plugin.getManager().warps().createWarp(warpName, position, true);
|
||||||
plugin.getLocales().getRawLocale("spawn_warp_default_description")
|
plugin.getLocales().getRawLocale("spawn_warp_default_description")
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class TpAllCommand extends InGameCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getSettings().isCrossServer()) {
|
if (plugin.getSettings().doCrossServer()) {
|
||||||
Message.builder()
|
Message.builder()
|
||||||
.target(Message.TARGET_ALL)
|
.target(Message.TARGET_ALL)
|
||||||
.type(Message.Type.TELEPORT_TO_POSITION)
|
.type(Message.Type.TELEPORT_TO_POSITION)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class WarpCommand extends SavedPositionCommand<Warp> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(@NotNull CommandUser executor, @NotNull Warp warp, @NotNull String[] args) {
|
public void execute(@NotNull CommandUser executor, @NotNull Warp warp, @NotNull String[] args) {
|
||||||
if (plugin.getSettings().isPermissionRestrictWarps()) {
|
if (plugin.getSettings().doPermissionRestrictWarps()) {
|
||||||
if (!executor.hasPermission(warp.getPermission()) && !executor.hasPermission(Warp.getWildcardPermission())) {
|
if (!executor.hasPermission(warp.getPermission()) && !executor.hasPermission(Warp.getWildcardPermission())) {
|
||||||
plugin.getLocales().getLocale("error_no_permission")
|
plugin.getLocales().getLocale("error_no_permission")
|
||||||
.ifPresent(executor::sendMessage);
|
.ifPresent(executor::sendMessage);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class WarpListCommand extends ListCommand {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private List<Warp> getItems(@NotNull CommandUser executor) {
|
private List<Warp> getItems(@NotNull CommandUser executor) {
|
||||||
List<Warp> warps = plugin.getDatabase().getWarps();
|
List<Warp> warps = plugin.getDatabase().getWarps();
|
||||||
if (plugin.getSettings().isPermissionRestrictWarps() && !executor.hasPermission(Warp.getWildcardPermission())) {
|
if (plugin.getSettings().doPermissionRestrictWarps() && !executor.hasPermission(Warp.getWildcardPermission())) {
|
||||||
warps = warps.stream()
|
warps = warps.stream()
|
||||||
.filter(warp -> executor.hasPermission(getPermission(warp.getPermission())))
|
.filter(warp -> executor.hasPermission(getPermission(warp.getPermission())))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|||||||
@@ -41,9 +41,6 @@ public class Locales {
|
|||||||
* @return An {@link Optional} containing the locale corresponding to the id, if it exists
|
* @return An {@link Optional} containing the locale corresponding to the id, if it exists
|
||||||
*/
|
*/
|
||||||
public Optional<String> getRawLocale(@NotNull String localeId) {
|
public Optional<String> getRawLocale(@NotNull String localeId) {
|
||||||
if (!rawLocales.containsKey(localeId)) { // debug
|
|
||||||
return Optional.of(localeId + " (missing locale)"); // debug
|
|
||||||
} // debug
|
|
||||||
return Optional.ofNullable(rawLocales.get(localeId)).map(StringEscapeUtils::unescapeJava);
|
return Optional.ofNullable(rawLocales.get(localeId)).map(StringEscapeUtils::unescapeJava);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ public class Settings {
|
|||||||
return stackPermissionLimits;
|
return stackPermissionLimits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPermissionRestrictWarps() {
|
public boolean doPermissionRestrictWarps() {
|
||||||
return permissionRestrictWarps;
|
return permissionRestrictWarps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,19 +341,19 @@ public class Settings {
|
|||||||
return strictTpaHereRequests;
|
return strictTpaHereRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllowUnicodeNames() {
|
public boolean doAllowUnicodeNames() {
|
||||||
return allowUnicodeNames;
|
return allowUnicodeNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllowUnicodeDescriptions() {
|
public boolean doAllowUnicodeDescriptions() {
|
||||||
return allowUnicodeDescriptions;
|
return allowUnicodeDescriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBackCommandReturnByDeath() {
|
public boolean doBackCommandReturnByDeath() {
|
||||||
return backCommandReturnByDeath;
|
return backCommandReturnByDeath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBackCommandSaveOnTeleportEvent() {
|
public boolean doBackCommandSaveOnTeleportEvent() {
|
||||||
return backCommandSaveOnTeleportEvent;
|
return backCommandSaveOnTeleportEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,18 +365,18 @@ public class Settings {
|
|||||||
return asynchronousTeleports;
|
return asynchronousTeleports;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlaySoundEffects() {
|
public boolean doPlaySoundEffects() {
|
||||||
return playSoundEffects;
|
return playSoundEffects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<String> getSoundEffect(@NotNull SoundEffectAction action) {
|
public Optional<String> getSoundEffect(@NotNull SoundEffectAction action) {
|
||||||
if (!isPlaySoundEffects()) {
|
if (!doPlaySoundEffects()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
return Optional.ofNullable(soundEffects.get(action.name().toLowerCase()));
|
return Optional.ofNullable(soundEffects.get(action.name().toLowerCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCrossServer() {
|
public boolean doCrossServer() {
|
||||||
return crossServer;
|
return crossServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public abstract class MapHook extends Hook {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !plugin.getSettings().isCrossServer() || position.getServer().equals(plugin.getServerName());
|
return !plugin.getSettings().doCrossServer() || position.getServer().equals(plugin.getServerName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class PlanHook extends Hook {
|
|||||||
|
|
||||||
private void registerDataExtension() {
|
private void registerDataExtension() {
|
||||||
try {
|
try {
|
||||||
ExtensionService.getInstance().register(new PlanDataExtension(plugin.getDatabase(), plugin.getSettings().isCrossServer()));
|
ExtensionService.getInstance().register(new PlanDataExtension(plugin.getDatabase(), plugin.getSettings().doCrossServer()));
|
||||||
} catch (IllegalStateException planIsNotEnabled) {
|
} catch (IllegalStateException planIsNotEnabled) {
|
||||||
plugin.log(Level.SEVERE, "Plan extension hook failed to register. Plan is not enabled.", planIsNotEnabled);
|
plugin.log(Level.SEVERE, "Plan extension hook failed to register. Plan is not enabled.", planIsNotEnabled);
|
||||||
// Plan is not enabled, handle exception
|
// Plan is not enabled, handle exception
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class EventListener {
|
|||||||
plugin.getDatabase().ensureUser(onlineUser);
|
plugin.getDatabase().ensureUser(onlineUser);
|
||||||
|
|
||||||
// Handle cross server checks
|
// Handle cross server checks
|
||||||
if (plugin.getSettings().isCrossServer()) {
|
if (plugin.getSettings().doCrossServer()) {
|
||||||
this.handleInboundTeleport(onlineUser);
|
this.handleInboundTeleport(onlineUser);
|
||||||
|
|
||||||
// Synchronize the global player list
|
// Synchronize the global player list
|
||||||
@@ -82,7 +82,7 @@ public class EventListener {
|
|||||||
final Optional<Position> bedPosition = teleporter.getBedSpawnPosition();
|
final Optional<Position> bedPosition = teleporter.getBedSpawnPosition();
|
||||||
if (bedPosition.isEmpty()) {
|
if (bedPosition.isEmpty()) {
|
||||||
plugin.getSpawn().ifPresent(spawn -> {
|
plugin.getSpawn().ifPresent(spawn -> {
|
||||||
if (plugin.getSettings().isCrossServer() && !spawn.getServer().equals(plugin.getServerName())) {
|
if (plugin.getSettings().doCrossServer() && !spawn.getServer().equals(plugin.getServerName())) {
|
||||||
plugin.runLater(() -> {
|
plugin.runLater(() -> {
|
||||||
try {
|
try {
|
||||||
Teleport.builder(plugin)
|
Teleport.builder(plugin)
|
||||||
@@ -126,7 +126,7 @@ public class EventListener {
|
|||||||
plugin.getManager().homes().removeUserHomes(onlineUser);
|
plugin.getManager().homes().removeUserHomes(onlineUser);
|
||||||
|
|
||||||
// Update global lists
|
// Update global lists
|
||||||
if (plugin.getSettings().isCrossServer()) {
|
if (plugin.getSettings().doCrossServer()) {
|
||||||
final List<String> localPlayerList = plugin.getLocalPlayerList().stream()
|
final List<String> localPlayerList = plugin.getLocalPlayerList().stream()
|
||||||
.filter(player -> !player.equals(onlineUser.getUsername()))
|
.filter(player -> !player.equals(onlineUser.getUsername()))
|
||||||
.toList();
|
.toList();
|
||||||
@@ -170,7 +170,7 @@ public class EventListener {
|
|||||||
* @param onlineUser the {@link OnlineUser} who died
|
* @param onlineUser the {@link OnlineUser} who died
|
||||||
*/
|
*/
|
||||||
protected final void handlePlayerDeath(@NotNull OnlineUser onlineUser) {
|
protected final void handlePlayerDeath(@NotNull OnlineUser onlineUser) {
|
||||||
if (plugin.getSettings().isBackCommandReturnByDeath() && plugin.getCommand(BackCommand.class)
|
if (plugin.getSettings().doBackCommandReturnByDeath() && plugin.getCommand(BackCommand.class)
|
||||||
.map(Command::getPermission).map(onlineUser::hasPermission).orElse(false)) {
|
.map(Command::getPermission).map(onlineUser::hasPermission).orElse(false)) {
|
||||||
plugin.getDatabase().setLastPosition(onlineUser, onlineUser.getPosition());
|
plugin.getDatabase().setLastPosition(onlineUser, onlineUser.getPosition());
|
||||||
}
|
}
|
||||||
@@ -188,13 +188,13 @@ public class EventListener {
|
|||||||
.map(command -> onlineUser.hasPermission(command.getPermission())
|
.map(command -> onlineUser.hasPermission(command.getPermission())
|
||||||
&& onlineUser.hasPermission(command.getPermission("death")))
|
&& onlineUser.hasPermission(command.getPermission("death")))
|
||||||
.orElse(false);
|
.orElse(false);
|
||||||
if (plugin.getSettings().isBackCommandReturnByDeath() && canReturnByDeath) {
|
if (plugin.getSettings().doBackCommandReturnByDeath() && canReturnByDeath) {
|
||||||
plugin.getLocales().getLocale("return_by_death_notification")
|
plugin.getLocales().getLocale("return_by_death_notification")
|
||||||
.ifPresent(onlineUser::sendMessage);
|
.ifPresent(onlineUser::sendMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Respawn the player cross-server if needed
|
// Respawn the player cross-server if needed
|
||||||
if (plugin.getSettings().isCrossServer() && plugin.getSettings().isGlobalRespawning()) {
|
if (plugin.getSettings().doCrossServer() && plugin.getSettings().isGlobalRespawning()) {
|
||||||
plugin.getDatabase().getRespawnPosition(onlineUser).ifPresent(respawnPosition -> {
|
plugin.getDatabase().getRespawnPosition(onlineUser).ifPresent(respawnPosition -> {
|
||||||
if (!respawnPosition.getServer().equals(plugin.getServerName())) {
|
if (!respawnPosition.getServer().equals(plugin.getServerName())) {
|
||||||
Teleport.builder(plugin)
|
Teleport.builder(plugin)
|
||||||
@@ -216,7 +216,7 @@ public class EventListener {
|
|||||||
* @param sourcePosition the source {@link Position} they came from
|
* @param sourcePosition the source {@link Position} they came from
|
||||||
*/
|
*/
|
||||||
protected final void handlePlayerTeleport(@NotNull OnlineUser onlineUser, @NotNull Position sourcePosition) {
|
protected final void handlePlayerTeleport(@NotNull OnlineUser onlineUser, @NotNull Position sourcePosition) {
|
||||||
if (!plugin.getSettings().isBackCommandSaveOnTeleportEvent()) {
|
if (!plugin.getSettings().doBackCommandSaveOnTeleportEvent()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +231,7 @@ public class EventListener {
|
|||||||
* @param position the new spawn point
|
* @param position the new spawn point
|
||||||
*/
|
*/
|
||||||
protected final void handlePlayerUpdateSpawnPoint(@NotNull OnlineUser onlineUser, @NotNull Position position) {
|
protected final void handlePlayerUpdateSpawnPoint(@NotNull OnlineUser onlineUser, @NotNull Position position) {
|
||||||
if (plugin.getSettings().isCrossServer() && plugin.getSettings().isGlobalRespawning()) {
|
if (plugin.getSettings().doCrossServer() && plugin.getSettings().isGlobalRespawning()) {
|
||||||
plugin.getDatabase().setRespawnPosition(onlineUser, position);
|
plugin.getDatabase().setRespawnPosition(onlineUser, position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class HomesManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void propagateCacheUpdate(@NotNull UUID homeId) {
|
private void propagateCacheUpdate(@NotNull UUID homeId) {
|
||||||
if (plugin.getSettings().isCrossServer()) {
|
if (plugin.getSettings().doCrossServer()) {
|
||||||
plugin.getOnlineUsers().stream().findAny().ifPresent(user -> Message.builder()
|
plugin.getOnlineUsers().stream().findAny().ifPresent(user -> Message.builder()
|
||||||
.type(Message.Type.UPDATE_HOME)
|
.type(Message.Type.UPDATE_HOME)
|
||||||
.scope(Message.Scope.SERVER)
|
.scope(Message.Scope.SERVER)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class Manager {
|
|||||||
|
|
||||||
// Update caches on all servers
|
// Update caches on all servers
|
||||||
protected void propagateCacheUpdate() {
|
protected void propagateCacheUpdate() {
|
||||||
if (plugin.getSettings().isCrossServer()) {
|
if (plugin.getSettings().doCrossServer()) {
|
||||||
plugin.getOnlineUsers().stream().findAny().ifPresent(user -> Message.builder()
|
plugin.getOnlineUsers().stream().findAny().ifPresent(user -> Message.builder()
|
||||||
.type(Message.Type.UPDATE_CACHES)
|
.type(Message.Type.UPDATE_CACHES)
|
||||||
.scope(Message.Scope.SERVER)
|
.scope(Message.Scope.SERVER)
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class RequestsManager {
|
|||||||
sendLocalTeleportRequest(request, onlineUser);
|
sendLocalTeleportRequest(request, onlineUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getSettings().isCrossServer()) {
|
if (plugin.getSettings().doCrossServer()) {
|
||||||
Message.builder()
|
Message.builder()
|
||||||
.type(Message.Type.TELEPORT_REQUEST)
|
.type(Message.Type.TELEPORT_REQUEST)
|
||||||
.payload(Payload.withTeleportRequest(request))
|
.payload(Payload.withTeleportRequest(request))
|
||||||
@@ -151,7 +151,7 @@ public class RequestsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the player couldn't be found locally, send the request cross-server
|
// If the player couldn't be found locally, send the request cross-server
|
||||||
if (plugin.getSettings().isCrossServer()) {
|
if (plugin.getSettings().doCrossServer()) {
|
||||||
request.setRecipientName(targetUser);
|
request.setRecipientName(targetUser);
|
||||||
Message.builder()
|
Message.builder()
|
||||||
.type(Message.Type.TELEPORT_REQUEST)
|
.type(Message.Type.TELEPORT_REQUEST)
|
||||||
@@ -272,7 +272,7 @@ public class RequestsManager {
|
|||||||
final Optional<OnlineUser> localRequester = plugin.findOnlinePlayer(request.getRequesterName());
|
final Optional<OnlineUser> localRequester = plugin.findOnlinePlayer(request.getRequesterName());
|
||||||
if (localRequester.isPresent()) {
|
if (localRequester.isPresent()) {
|
||||||
handleLocalRequestResponse(localRequester.get(), request);
|
handleLocalRequestResponse(localRequester.get(), request);
|
||||||
} else if (plugin.getSettings().isCrossServer()) {
|
} else if (plugin.getSettings().doCrossServer()) {
|
||||||
Message.builder()
|
Message.builder()
|
||||||
.type(Message.Type.TELEPORT_REQUEST_RESPONSE)
|
.type(Message.Type.TELEPORT_REQUEST_RESPONSE)
|
||||||
.payload(Payload.withTeleportRequest(request))
|
.payload(Payload.withTeleportRequest(request))
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class WarpsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void propagateCacheUpdate(@NotNull UUID warpId) {
|
private void propagateCacheUpdate(@NotNull UUID warpId) {
|
||||||
if (plugin.getSettings().isCrossServer()) {
|
if (plugin.getSettings().doCrossServer()) {
|
||||||
plugin.getOnlineUsers().stream().findAny().ifPresent(user -> Message.builder()
|
plugin.getOnlineUsers().stream().findAny().ifPresent(user -> Message.builder()
|
||||||
.type(Message.Type.UPDATE_WARP)
|
.type(Message.Type.UPDATE_WARP)
|
||||||
.scope(Message.Scope.SERVER)
|
.scope(Message.Scope.SERVER)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class Teleport {
|
|||||||
// Teleport a user on another server
|
// Teleport a user on another server
|
||||||
if (localTeleporter.isEmpty()) {
|
if (localTeleporter.isEmpty()) {
|
||||||
final Username teleporter = (Username) this.teleporter;
|
final Username teleporter = (Username) this.teleporter;
|
||||||
if (!plugin.getSettings().isCrossServer()) {
|
if (!plugin.getSettings().doCrossServer()) {
|
||||||
throw new TeleportationException(TeleportationException.Type.TELEPORTER_NOT_FOUND);
|
throw new TeleportationException(TeleportationException.Type.TELEPORTER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ public class Teleport {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getSettings().isCrossServer()) {
|
if (plugin.getSettings().doCrossServer()) {
|
||||||
fireEvent((event) -> {
|
fireEvent((event) -> {
|
||||||
executeEconomyActions();
|
executeEconomyActions();
|
||||||
Message.builder()
|
Message.builder()
|
||||||
@@ -119,7 +119,7 @@ public class Teleport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Position target = (Position) this.target;
|
final Position target = (Position) this.target;
|
||||||
if (!plugin.getSettings().isCrossServer() || target.getServer().equals(plugin.getServerName())) {
|
if (!plugin.getSettings().doCrossServer() || target.getServer().equals(plugin.getServerName())) {
|
||||||
teleporter.teleportLocally(target, async);
|
teleporter.teleportLocally(target, async);
|
||||||
this.displayTeleportingComplete(teleporter);
|
this.displayTeleportingComplete(teleporter);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class Validator {
|
|||||||
* @return True if the name is valid as per the plugin settings, false otherwise
|
* @return True if the name is valid as per the plugin settings, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isValidName(@NotNull String name) {
|
public boolean isValidName(@NotNull String name) {
|
||||||
return (isAsciiOnly(name) || plugin.getSettings().isAllowUnicodeNames())
|
return (isAsciiOnly(name) || plugin.getSettings().doAllowUnicodeNames())
|
||||||
&& !containsWhitespace(name)
|
&& !containsWhitespace(name)
|
||||||
&& name.length() <= MAX_NAME_LENGTH && name.length() >= MIN_NAME_LENGTH;
|
&& name.length() <= MAX_NAME_LENGTH && name.length() >= MIN_NAME_LENGTH;
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ public class Validator {
|
|||||||
* @return Whether the meta is valid against the plugin settings
|
* @return Whether the meta is valid against the plugin settings
|
||||||
*/
|
*/
|
||||||
public boolean isValidDescription(@NotNull String description) {
|
public boolean isValidDescription(@NotNull String description) {
|
||||||
return (isAsciiOnly(description) || plugin.getSettings().isAllowUnicodeDescriptions())
|
return (isAsciiOnly(description) || plugin.getSettings().doAllowUnicodeDescriptions())
|
||||||
&& description.length() <= MAX_DESCRIPTION_LENGTH;
|
&& description.length() <= MAX_DESCRIPTION_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user