mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Fix permission issues and erroneous messages with homes and warps, close #252
This commit is contained in:
1 parent
9385b8aace
commit
88802db702
3 files changed
+23
-11
No files matched your search
@@ -57,7 +57,7 @@ public class HomeCommand extends CommandBase implements TabCompletable, ConsoleE
|
||||
}
|
||||
|
||||
private void teleportToNamedHome(@NotNull OnlineUser teleporter, @NotNull User owner, @NotNull String homeName) {
|
||||
final boolean otherHome = owner.uuid.equals(teleporter.uuid);
|
||||
final boolean otherHome = !owner.uuid.equals(teleporter.uuid);
|
||||
plugin.getDatabase()
|
||||
.getHome(owner, homeName)
|
||||
.thenAccept(homeResult -> homeResult.ifPresentOrElse(home -> {
|
||||
@@ -65,6 +65,7 @@ public class HomeCommand extends CommandBase implements TabCompletable, ConsoleE
|
||||
if (!teleporter.hasPermission(Permission.COMMAND_HOME_OTHER.node)) {
|
||||
plugin.getLocales().getLocale("error_no_permission")
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Teleport.builder(plugin, teleporter)
|
||||
@@ -73,10 +74,10 @@ public class HomeCommand extends CommandBase implements TabCompletable, ConsoleE
|
||||
.thenAccept(TimedTeleport::execute);
|
||||
}, () -> {
|
||||
if (otherHome) {
|
||||
plugin.getLocales().getLocale("error_home_invalid", homeName)
|
||||
plugin.getLocales().getLocale("error_home_invalid_other", owner.username, homeName)
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
} else {
|
||||
plugin.getLocales().getLocale("error_home_invalid_other", owner.username, homeName)
|
||||
plugin.getLocales().getLocale("error_home_invalid", homeName)
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -69,7 +69,7 @@ public class PublicHomeCommand extends CommandBase implements TabCompletable, Co
|
||||
}
|
||||
|
||||
private void teleportToNamedHome(@NotNull OnlineUser teleporter, @NotNull User owner, @NotNull String homeName) {
|
||||
final boolean otherHome = owner.uuid.equals(teleporter.uuid);
|
||||
final boolean otherHome = !owner.uuid.equals(teleporter.uuid);
|
||||
plugin.getDatabase()
|
||||
.getHome(owner, homeName)
|
||||
.thenAccept(homeResult -> homeResult.ifPresentOrElse(home -> {
|
||||
@@ -77,6 +77,7 @@ public class PublicHomeCommand extends CommandBase implements TabCompletable, Co
|
||||
if (!teleporter.hasPermission(Permission.COMMAND_HOME_OTHER.node)) {
|
||||
plugin.getLocales().getLocale("error_no_permission")
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Teleport.builder(plugin, teleporter)
|
||||
@@ -85,10 +86,10 @@ public class PublicHomeCommand extends CommandBase implements TabCompletable, Co
|
||||
.thenAccept(TimedTeleport::execute);
|
||||
}, () -> {
|
||||
if (otherHome) {
|
||||
plugin.getLocales().getLocale("error_home_invalid", homeName)
|
||||
plugin.getLocales().getLocale("error_home_invalid_other", owner.username, homeName)
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
} else {
|
||||
plugin.getLocales().getLocale("error_home_invalid_other", owner.username, homeName)
|
||||
plugin.getLocales().getLocale("error_home_invalid", homeName)
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.william278.huskhomes.position.Warp;
|
||||
import net.william278.huskhomes.teleport.Teleport;
|
||||
import net.william278.huskhomes.teleport.TimedTeleport;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.intellij.lang.annotations.Subst;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -36,11 +37,20 @@ public class WarpCommand extends CommandBase implements TabCompletable, ConsoleE
|
||||
final String warpName = args[0];
|
||||
plugin.getDatabase()
|
||||
.getWarp(warpName)
|
||||
.thenAccept(warpResult -> warpResult.ifPresentOrElse(warp ->
|
||||
Teleport.builder(plugin, onlineUser)
|
||||
.setTarget(warp)
|
||||
.toTimedTeleport()
|
||||
.thenAccept(TimedTeleport::execute),
|
||||
.thenAccept(warpResult -> warpResult.ifPresentOrElse(warp -> {
|
||||
if (plugin.getSettings().permissionRestrictWarps) {
|
||||
@Subst("huskhomes.command.warp") final String warpPermission = Permission.COMMAND_WARP + "." + warp.meta.name;
|
||||
if (!onlineUser.hasPermission(Permission.COMMAND_SET_WARP.node) && !onlineUser.hasPermission(warpPermission)) {
|
||||
plugin.getLocales().getLocale("error_no_permission")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Teleport.builder(plugin, onlineUser)
|
||||
.setTarget(warp)
|
||||
.toTimedTeleport()
|
||||
.thenAccept(TimedTeleport::execute);
|
||||
},
|
||||
() -> plugin.getLocales().getLocale("error_warp_invalid", warpName)
|
||||
.ifPresent(onlineUser::sendMessage)));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user