adapt area_perms to work better with sub-folders + some improvements
All checks were successful
/ Auto-Build-App (push) Successful in 1m17s

This commit is contained in:
pietru 2025-02-24 10:19:37 +01:00
parent 066bae3d90
commit 56930a839d
6 changed files with 13 additions and 8 deletions

View file

@ -166,7 +166,10 @@ public class Region {
area.setCorners(a, b); area.setCorners(a, b);
area.name=f.getName(); area.name = f.getPath().replace(regions_folder.getPath(), "").replace("\\", "/");
if (area.name.startsWith("/"))
area.name = area.name.substring(1);
area.enabled=region.getBoolean("enabled",true); area.enabled=region.getBoolean("enabled",true);
area.protect=region.getBoolean("protect",false); area.protect=region.getBoolean("protect",false);
@ -263,7 +266,9 @@ public class Region {
if (perm.player_id.isEmpty()) if (perm.player_id.isEmpty())
continue; continue;
perm.filename=f.getName(); perm.filename = f.getPath().replace(perms_folder.getPath(), "").replace("\\", "/");
if (area.name.startsWith("/"))
area.name = area.name.substring(1);
perm.type=perm_json.getString("type", ""); perm.type=perm_json.getString("type", "");
perm.enabled=perm_json.getBoolean("enabled", false); perm.enabled=perm_json.getBoolean("enabled", false);

View file

@ -33,7 +33,7 @@ public class BlockBreakMixin {
@Inject(method = "handle", at = @At("HEAD"), cancellable = true) @Inject(method = "handle", at = @At("HEAD"), cancellable = true)
private void event_block_break(CallbackInfo ci, @Local NetworkIdentity identity, @Local ChannelHandlerContext ctx){ private void event_block_break(CallbackInfo ci, @Local NetworkIdentity identity, @Local ChannelHandlerContext ctx){
if (identity.getSide() != NetworkSide.CLIENT) { if (identity.isServer()) {
Account account = ServerSingletons.getAccount(identity); Account account = ServerSingletons.getAccount(identity);
if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_edit_block(blockPos,"break",account.getUniqueId())) { if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_edit_block(blockPos,"break",account.getUniqueId())) {

View file

@ -35,11 +35,11 @@ public class BlockPlaceMixin {
@Inject(method = "handle", at = @At("HEAD"), cancellable = true) @Inject(method = "handle", at = @At("HEAD"), cancellable = true)
private void event_block_place(CallbackInfo ci, @Local NetworkIdentity identity, @Local ChannelHandlerContext ctx){ private void event_block_place(CallbackInfo ci, @Local NetworkIdentity identity, @Local ChannelHandlerContext ctx){
if (identity.getSide() != NetworkSide.CLIENT) { if (identity.isServer()) {
if (targetBlockState instanceof BlockStateMissing) if (targetBlockState instanceof BlockStateMissing)
ci.cancel(); ci.cancel();
} }
if (identity.getSide() != NetworkSide.CLIENT && !ci.isCancelled()) { if (identity.isServer() && !ci.isCancelled()) {
Account account = ServerSingletons.getAccount(identity); Account account = ServerSingletons.getAccount(identity);
if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_edit_block(blockPos,"place",account.getUniqueId())) { if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_edit_block(blockPos,"place",account.getUniqueId())) {
ci.cancel(); ci.cancel();

View file

@ -34,7 +34,7 @@ public class InteractBlockMixin {
@Inject(method = "handle", at = @At("HEAD"), cancellable = true) @Inject(method = "handle", at = @At("HEAD"), cancellable = true)
private void event_block_interact(CallbackInfo ci, @Local NetworkIdentity identity, @Local ChannelHandlerContext ctx){ private void event_block_interact(CallbackInfo ci, @Local NetworkIdentity identity, @Local ChannelHandlerContext ctx){
if (identity.getSide() != NetworkSide.CLIENT) { if (identity.isServer()) {
Account account = ServerSingletons.getAccount(identity); Account account = ServerSingletons.getAccount(identity);
if (blockPos!=null) { if (blockPos!=null) {
BlockPosition temp = blockPos.copy(); BlockPosition temp = blockPos.copy();

View file

@ -49,7 +49,7 @@ public class MessagePacketMixin {
ply_msgs.put(playerUniqueId,new MessageInfo()); ply_msgs.put(playerUniqueId,new MessageInfo());
} }
if (identity.getSide() != NetworkSide.CLIENT && !ci.isCancelled()) { if (identity.isServer() && !ci.isCancelled()) {
Account account = ServerSingletons.getAccount(identity); Account account = ServerSingletons.getAccount(identity);
if (message.startsWith(":")) { if (message.startsWith(":")) {
String cmd = message.replaceFirst(":",""); String cmd = message.replaceFirst(":","");

View file

@ -42,7 +42,7 @@ public class PlayerPositionMixin {
@Inject(method = "handle", at = @At("HEAD"), cancellable = true) @Inject(method = "handle", at = @At("HEAD"), cancellable = true)
private void event_player_move(CallbackInfo ci, @Local NetworkIdentity identity, @Local ChannelHandlerContext ctx){ private void event_player_move(CallbackInfo ci, @Local NetworkIdentity identity, @Local ChannelHandlerContext ctx){
if (identity.getSide() != NetworkSide.CLIENT) { if (identity.isServer()) {
Account account = ServerSingletons.getAccount(identity); Account account = ServerSingletons.getAccount(identity);
Player player = ServerSingletons.getPlayer(identity); Player player = ServerSingletons.getPlayer(identity);