add pvp protect for areas, bugfix blockPos in oninteract event?
Some checks failed
/ Auto-Build-App (push) Failing after 3m1s
Some checks failed
/ Auto-Build-App (push) Failing after 3m1s
This commit is contained in:
parent
5d75207b39
commit
8b377e21cb
6 changed files with 54 additions and 7 deletions
|
@ -173,6 +173,8 @@ public class Region {
|
||||||
perms.set_bool_perm("explode", region.getBoolean("explode", false));
|
perms.set_bool_perm("explode", region.getBoolean("explode", false));
|
||||||
perms.set_bool_perm("enter", region.getBoolean("enter", true));
|
perms.set_bool_perm("enter", region.getBoolean("enter", true));
|
||||||
perms.set_bool_perm("spawn_mob", region.getBoolean("spawn_mob", true));
|
perms.set_bool_perm("spawn_mob", region.getBoolean("spawn_mob", true));
|
||||||
|
|
||||||
|
perms.set_bool_perm("pvp", region.getBoolean("pvp", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class InteractBlockMixin {
|
||||||
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.getSide() != NetworkSide.CLIENT) {
|
||||||
Account account = ServerSingletons.getAccount(identity);
|
Account account = ServerSingletons.getAccount(identity);
|
||||||
|
if (blockPos!=null) {
|
||||||
BlockPosition temp = blockPos.copy();
|
BlockPosition temp = blockPos.copy();
|
||||||
temp.convertToLocal(identity.getZone());
|
temp.convertToLocal(identity.getZone());
|
||||||
if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_edit_block(temp, "interact", account.getUniqueId())) {
|
if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_edit_block(temp, "interact", account.getUniqueId())) {
|
||||||
|
@ -47,3 +48,4 @@ public class InteractBlockMixin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package net.pietru.cookie_utils.mixins;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.sugar.Local;
|
||||||
|
import finalforeach.cosmicreach.accounts.Account;
|
||||||
|
import finalforeach.cosmicreach.entities.Entity;
|
||||||
|
import finalforeach.cosmicreach.entities.player.PlayerEntity;
|
||||||
|
import finalforeach.cosmicreach.networking.packets.MessagePacket;
|
||||||
|
import finalforeach.cosmicreach.networking.server.ServerSingletons;
|
||||||
|
import net.pietru.cookie_utils.permissions.Permissions;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import static net.pietru.cookie_utils.api.Region.*;
|
||||||
|
|
||||||
|
@Mixin(PlayerEntity.class)
|
||||||
|
public class PlayerEntityMixin {
|
||||||
|
|
||||||
|
@Inject(method = "onAttackInteraction", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void event_player_attack(CallbackInfo ci, @Local Entity sourceEntity){
|
||||||
|
if (sourceEntity instanceof PlayerEntity){
|
||||||
|
Account account = ((PlayerEntity) sourceEntity).player.getAccount();
|
||||||
|
|
||||||
|
if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_enter_position(sourceEntity.getPosition(),"pvp",account.getUniqueId())) {
|
||||||
|
ci.cancel();
|
||||||
|
|
||||||
|
MessagePacket packet = new MessagePacket("[Server] " + (is_not_reloading ? "Sorry, but you can't attack people here." : "Sorry but you can't do this action right now. [Config Reload In Progress]"));
|
||||||
|
packet.setupAndSend(ServerSingletons.getConnection(((PlayerEntity) sourceEntity).player));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package net.pietru.cookie_utils.permissions;
|
package net.pietru.cookie_utils.permissions;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.JsonValue;
|
import com.badlogic.gdx.utils.JsonValue;
|
||||||
|
import finalforeach.cosmicreach.settings.ServerSettings;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -37,6 +38,8 @@ public class ObjectPermList {
|
||||||
val.addChild("explode", new JsonValue(false));
|
val.addChild("explode", new JsonValue(false));
|
||||||
val.addChild("enter", new JsonValue(true));
|
val.addChild("enter", new JsonValue(true));
|
||||||
val.addChild("spawn_mob", new JsonValue(false));
|
val.addChild("spawn_mob", new JsonValue(false));
|
||||||
|
|
||||||
|
val.addChild("pvp", new JsonValue(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void get_default_perms(ObjectPermList val){
|
public static void get_default_perms(ObjectPermList val){
|
||||||
|
@ -47,5 +50,7 @@ public class ObjectPermList {
|
||||||
val.set_bool_perm("explode", false);
|
val.set_bool_perm("explode", false);
|
||||||
val.set_bool_perm("enter", true);
|
val.set_bool_perm("enter", true);
|
||||||
val.set_bool_perm("spawn_mob", false);
|
val.set_bool_perm("spawn_mob", false);
|
||||||
|
|
||||||
|
val.set_bool_perm("pvp", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ public class areaPermSetup extends Setup {
|
||||||
plr_perm.perms.set_bool_perm("break", target);
|
plr_perm.perms.set_bool_perm("break", target);
|
||||||
plr_perm.perms.set_bool_perm("interact", target);
|
plr_perm.perms.set_bool_perm("interact", target);
|
||||||
plr_perm.perms.set_bool_perm("enter", target);
|
plr_perm.perms.set_bool_perm("enter", target);
|
||||||
|
plr_perm.perms.set_bool_perm("pvp", target);
|
||||||
break;
|
break;
|
||||||
case "edit","e":
|
case "edit","e":
|
||||||
plr_perm.perms.set_bool_perm("place", target);
|
plr_perm.perms.set_bool_perm("place", target);
|
||||||
|
@ -84,6 +85,9 @@ public class areaPermSetup extends Setup {
|
||||||
case "enter","m":
|
case "enter","m":
|
||||||
plr_perm.perms.set_bool_perm("enter", target);
|
plr_perm.perms.set_bool_perm("enter", target);
|
||||||
break;
|
break;
|
||||||
|
case "pvp","p":
|
||||||
|
plr_perm.perms.set_bool_perm("pvp", target);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
run_setup_finish();
|
run_setup_finish();
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
"PlayerPositionMixin",
|
"PlayerPositionMixin",
|
||||||
"NettyServerMixin",
|
"NettyServerMixin",
|
||||||
"ServerSingletonsMixin",
|
"ServerSingletonsMixin",
|
||||||
"BlockEntitySignMixin"
|
"BlockEntitySignMixin",
|
||||||
|
"PlayerEntityMixin"
|
||||||
],
|
],
|
||||||
"client": [],
|
"client": [],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
|
|
Loading…
Reference in a new issue