mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
Rename some Settings getters
This commit is contained in:
1 parent
29cf3f9ffc
commit
34fdb88d5c
22 files changed
+44
-44
No files matched your search
@@ -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
|
||||
*/
|
||||
default Optional<Position> getSpawn() {
|
||||
return getSettings().isCrossServer() && getSettings().isGlobalSpawn()
|
||||
return getSettings().doCrossServer() && getSettings().isGlobalSpawn()
|
||||
? getDatabase().getWarp(getSettings().getGlobalSpawnName()).map(warp -> (Position) warp)
|
||||
: getLocalCachedSpawn().map(spawn -> spawn.getPosition(getServerName()));
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public abstract class BaseHuskHomesAPI {
|
||||
* @since 3.0
|
||||
*/
|
||||
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 plugin.supplyAsync(() -> plugin.getDatabase().getRespawnPosition(user));
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DelWarpCommand extends SavedPositionCommand<Warp> {
|
||||
|
||||
@Override
|
||||
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())) {
|
||||
plugin.getLocales().getLocale("error_no_permission")
|
||||
.ifPresent(executor::sendMessage);
|
||||
|
||||
@@ -233,7 +233,7 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
|
||||
if (!plugin.getSettings().isCrossServer()) {
|
||||
if (!plugin.getSettings().doCrossServer()) {
|
||||
plugin.getLocales().getLocale("edit_home_menu_world", home.getWorld().getName())
|
||||
.ifPresent(this::add);
|
||||
} else {
|
||||
|
||||
@@ -141,7 +141,7 @@ public class EditWarpCommand extends SavedPositionCommand<Warp> {
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
|
||||
if (!plugin.getSettings().isCrossServer()) {
|
||||
if (!plugin.getSettings().doCrossServer()) {
|
||||
plugin.getLocales().getLocale("edit_warp_menu_world", warp.getWorld().getName()).ifPresent(this::add);
|
||||
} else {
|
||||
plugin.getLocales().getLocale("edit_warp_menu_world_server", warp.getWorld().getName(), warp.getServer()).ifPresent(this::add);
|
||||
|
||||
@@ -95,7 +95,7 @@ public abstract class SavedPositionCommand<T extends SavedPosition> extends Comm
|
||||
|
||||
private Optional<Warp> resolveWarp(@NotNull CommandUser executor, @NotNull String 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)))) {
|
||||
plugin.getLocales().getLocale("error_warp_invalid", warpName)
|
||||
.ifPresent(executor::sendMessage);
|
||||
|
||||
@@ -19,7 +19,7 @@ public class SetSpawnCommand extends InGameCommand {
|
||||
public void execute(@NotNull OnlineUser executor, @NotNull String[] args) {
|
||||
final Position position = executor.getPosition();
|
||||
try {
|
||||
if (plugin.getSettings().isCrossServer() && plugin.getSettings().isGlobalSpawn()) {
|
||||
if (plugin.getSettings().doCrossServer() && plugin.getSettings().isGlobalSpawn()) {
|
||||
final String warpName = plugin.getSettings().getGlobalSpawnName();
|
||||
plugin.getManager().warps().createWarp(warpName, position, true);
|
||||
plugin.getLocales().getRawLocale("spawn_warp_default_description")
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TpAllCommand extends InGameCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getSettings().isCrossServer()) {
|
||||
if (plugin.getSettings().doCrossServer()) {
|
||||
Message.builder()
|
||||
.target(Message.TARGET_ALL)
|
||||
.type(Message.Type.TELEPORT_TO_POSITION)
|
||||
|
||||
@@ -27,7 +27,7 @@ public class WarpCommand extends SavedPositionCommand<Warp> {
|
||||
|
||||
@Override
|
||||
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())) {
|
||||
plugin.getLocales().getLocale("error_no_permission")
|
||||
.ifPresent(executor::sendMessage);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class WarpListCommand extends ListCommand {
|
||||
@NotNull
|
||||
private List<Warp> getItems(@NotNull CommandUser executor) {
|
||||
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()
|
||||
.filter(warp -> executor.hasPermission(getPermission(warp.getPermission())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -317,7 +317,7 @@ public class Settings {
|
||||
return stackPermissionLimits;
|
||||
}
|
||||
|
||||
public boolean isPermissionRestrictWarps() {
|
||||
public boolean doPermissionRestrictWarps() {
|
||||
return permissionRestrictWarps;
|
||||
}
|
||||
|
||||
@@ -341,19 +341,19 @@ public class Settings {
|
||||
return strictTpaHereRequests;
|
||||
}
|
||||
|
||||
public boolean isAllowUnicodeNames() {
|
||||
public boolean doAllowUnicodeNames() {
|
||||
return allowUnicodeNames;
|
||||
}
|
||||
|
||||
public boolean isAllowUnicodeDescriptions() {
|
||||
public boolean doAllowUnicodeDescriptions() {
|
||||
return allowUnicodeDescriptions;
|
||||
}
|
||||
|
||||
public boolean isBackCommandReturnByDeath() {
|
||||
public boolean doBackCommandReturnByDeath() {
|
||||
return backCommandReturnByDeath;
|
||||
}
|
||||
|
||||
public boolean isBackCommandSaveOnTeleportEvent() {
|
||||
public boolean doBackCommandSaveOnTeleportEvent() {
|
||||
return backCommandSaveOnTeleportEvent;
|
||||
}
|
||||
|
||||
@@ -365,18 +365,18 @@ public class Settings {
|
||||
return asynchronousTeleports;
|
||||
}
|
||||
|
||||
public boolean isPlaySoundEffects() {
|
||||
public boolean doPlaySoundEffects() {
|
||||
return playSoundEffects;
|
||||
}
|
||||
|
||||
public Optional<String> getSoundEffect(@NotNull SoundEffectAction action) {
|
||||
if (!isPlaySoundEffects()) {
|
||||
if (!doPlaySoundEffects()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.ofNullable(soundEffects.get(action.name().toLowerCase()));
|
||||
}
|
||||
|
||||
public boolean isCrossServer() {
|
||||
public boolean doCrossServer() {
|
||||
return crossServer;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public abstract class MapHook extends Hook {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !plugin.getSettings().isCrossServer() || position.getServer().equals(plugin.getServerName());
|
||||
return !plugin.getSettings().doCrossServer() || position.getServer().equals(plugin.getServerName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -46,7 +46,7 @@ public class PlanHook extends Hook {
|
||||
|
||||
private void registerDataExtension() {
|
||||
try {
|
||||
ExtensionService.getInstance().register(new PlanDataExtension(plugin.getDatabase(), plugin.getSettings().isCrossServer()));
|
||||
ExtensionService.getInstance().register(new PlanDataExtension(plugin.getDatabase(), plugin.getSettings().doCrossServer()));
|
||||
} catch (IllegalStateException planIsNotEnabled) {
|
||||
plugin.log(Level.SEVERE, "Plan extension hook failed to register. Plan is not enabled.", planIsNotEnabled);
|
||||
// Plan is not enabled, handle exception
|
||||
|
||||
@@ -40,7 +40,7 @@ public class EventListener {
|
||||
plugin.getDatabase().ensureUser(onlineUser);
|
||||
|
||||
// Handle cross server checks
|
||||
if (plugin.getSettings().isCrossServer()) {
|
||||
if (plugin.getSettings().doCrossServer()) {
|
||||
this.handleInboundTeleport(onlineUser);
|
||||
|
||||
// Synchronize the global player list
|
||||
@@ -82,7 +82,7 @@ public class EventListener {
|
||||
final Optional<Position> bedPosition = teleporter.getBedSpawnPosition();
|
||||
if (bedPosition.isEmpty()) {
|
||||
plugin.getSpawn().ifPresent(spawn -> {
|
||||
if (plugin.getSettings().isCrossServer() && !spawn.getServer().equals(plugin.getServerName())) {
|
||||
if (plugin.getSettings().doCrossServer() && !spawn.getServer().equals(plugin.getServerName())) {
|
||||
plugin.runLater(() -> {
|
||||
try {
|
||||
Teleport.builder(plugin)
|
||||
@@ -126,7 +126,7 @@ public class EventListener {
|
||||
plugin.getManager().homes().removeUserHomes(onlineUser);
|
||||
|
||||
// Update global lists
|
||||
if (plugin.getSettings().isCrossServer()) {
|
||||
if (plugin.getSettings().doCrossServer()) {
|
||||
final List<String> localPlayerList = plugin.getLocalPlayerList().stream()
|
||||
.filter(player -> !player.equals(onlineUser.getUsername()))
|
||||
.toList();
|
||||
@@ -170,7 +170,7 @@ public class EventListener {
|
||||
* @param onlineUser the {@link OnlineUser} who died
|
||||
*/
|
||||
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)) {
|
||||
plugin.getDatabase().setLastPosition(onlineUser, onlineUser.getPosition());
|
||||
}
|
||||
@@ -188,13 +188,13 @@ public class EventListener {
|
||||
.map(command -> onlineUser.hasPermission(command.getPermission())
|
||||
&& onlineUser.hasPermission(command.getPermission("death")))
|
||||
.orElse(false);
|
||||
if (plugin.getSettings().isBackCommandReturnByDeath() && canReturnByDeath) {
|
||||
if (plugin.getSettings().doBackCommandReturnByDeath() && canReturnByDeath) {
|
||||
plugin.getLocales().getLocale("return_by_death_notification")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
}
|
||||
|
||||
// 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 -> {
|
||||
if (!respawnPosition.getServer().equals(plugin.getServerName())) {
|
||||
Teleport.builder(plugin)
|
||||
@@ -216,7 +216,7 @@ public class EventListener {
|
||||
* @param sourcePosition the source {@link Position} they came from
|
||||
*/
|
||||
protected final void handlePlayerTeleport(@NotNull OnlineUser onlineUser, @NotNull Position sourcePosition) {
|
||||
if (!plugin.getSettings().isBackCommandSaveOnTeleportEvent()) {
|
||||
if (!plugin.getSettings().doBackCommandSaveOnTeleportEvent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ public class EventListener {
|
||||
* @param position the new spawn point
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class HomesManager {
|
||||
}
|
||||
|
||||
private void propagateCacheUpdate(@NotNull UUID homeId) {
|
||||
if (plugin.getSettings().isCrossServer()) {
|
||||
if (plugin.getSettings().doCrossServer()) {
|
||||
plugin.getOnlineUsers().stream().findAny().ifPresent(user -> Message.builder()
|
||||
.type(Message.Type.UPDATE_HOME)
|
||||
.scope(Message.Scope.SERVER)
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Manager {
|
||||
|
||||
// Update caches on all servers
|
||||
protected void propagateCacheUpdate() {
|
||||
if (plugin.getSettings().isCrossServer()) {
|
||||
if (plugin.getSettings().doCrossServer()) {
|
||||
plugin.getOnlineUsers().stream().findAny().ifPresent(user -> Message.builder()
|
||||
.type(Message.Type.UPDATE_CACHES)
|
||||
.scope(Message.Scope.SERVER)
|
||||
|
||||
@@ -121,7 +121,7 @@ public class RequestsManager {
|
||||
sendLocalTeleportRequest(request, onlineUser);
|
||||
}
|
||||
|
||||
if (plugin.getSettings().isCrossServer()) {
|
||||
if (plugin.getSettings().doCrossServer()) {
|
||||
Message.builder()
|
||||
.type(Message.Type.TELEPORT_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 (plugin.getSettings().isCrossServer()) {
|
||||
if (plugin.getSettings().doCrossServer()) {
|
||||
request.setRecipientName(targetUser);
|
||||
Message.builder()
|
||||
.type(Message.Type.TELEPORT_REQUEST)
|
||||
@@ -272,7 +272,7 @@ public class RequestsManager {
|
||||
final Optional<OnlineUser> localRequester = plugin.findOnlinePlayer(request.getRequesterName());
|
||||
if (localRequester.isPresent()) {
|
||||
handleLocalRequestResponse(localRequester.get(), request);
|
||||
} else if (plugin.getSettings().isCrossServer()) {
|
||||
} else if (plugin.getSettings().doCrossServer()) {
|
||||
Message.builder()
|
||||
.type(Message.Type.TELEPORT_REQUEST_RESPONSE)
|
||||
.payload(Payload.withTeleportRequest(request))
|
||||
|
||||
@@ -49,7 +49,7 @@ public class WarpsManager {
|
||||
}
|
||||
|
||||
private void propagateCacheUpdate(@NotNull UUID warpId) {
|
||||
if (plugin.getSettings().isCrossServer()) {
|
||||
if (plugin.getSettings().doCrossServer()) {
|
||||
plugin.getOnlineUsers().stream().findAny().ifPresent(user -> Message.builder()
|
||||
.type(Message.Type.UPDATE_WARP)
|
||||
.scope(Message.Scope.SERVER)
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Teleport {
|
||||
// Teleport a user on another server
|
||||
if (localTeleporter.isEmpty()) {
|
||||
final Username teleporter = (Username) this.teleporter;
|
||||
if (!plugin.getSettings().isCrossServer()) {
|
||||
if (!plugin.getSettings().doCrossServer()) {
|
||||
throw new TeleportationException(TeleportationException.Type.TELEPORTER_NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class Teleport {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getSettings().isCrossServer()) {
|
||||
if (plugin.getSettings().doCrossServer()) {
|
||||
fireEvent((event) -> {
|
||||
executeEconomyActions();
|
||||
Message.builder()
|
||||
@@ -119,7 +119,7 @@ public class Teleport {
|
||||
}
|
||||
|
||||
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);
|
||||
this.displayTeleportingComplete(teleporter);
|
||||
return;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Validator {
|
||||
* @return True if the name is valid as per the plugin settings, false otherwise
|
||||
*/
|
||||
public boolean isValidName(@NotNull String name) {
|
||||
return (isAsciiOnly(name) || plugin.getSettings().isAllowUnicodeNames())
|
||||
return (isAsciiOnly(name) || plugin.getSettings().doAllowUnicodeNames())
|
||||
&& !containsWhitespace(name)
|
||||
&& 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
|
||||
*/
|
||||
public boolean isValidDescription(@NotNull String description) {
|
||||
return (isAsciiOnly(description) || plugin.getSettings().isAllowUnicodeDescriptions())
|
||||
return (isAsciiOnly(description) || plugin.getSettings().doAllowUnicodeDescriptions())
|
||||
&& description.length() <= MAX_DESCRIPTION_LENGTH;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user