This commit is contained in:
parent
f9f538589f
commit
069eca1578
6 changed files with 74 additions and 1 deletions
|
@ -184,6 +184,7 @@ public class Region {
|
|||
perms.set_bool_perm("place", region.getBoolean("place", false));
|
||||
perms.set_bool_perm("break", region.getBoolean("break", false));
|
||||
perms.set_bool_perm("interact", region.getBoolean("interact", false));
|
||||
perms.set_bool_perm("laser", region.getBoolean("laser", false));
|
||||
|
||||
perms.set_bool_perm("explode", region.getBoolean("explode", false));
|
||||
perms.set_bool_perm("enter", region.getBoolean("enter", true));
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package net.pietru.cookie_utils.mixins;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import finalforeach.cosmicreach.GameSingletons;
|
||||
import finalforeach.cosmicreach.accounts.Account;
|
||||
import finalforeach.cosmicreach.blocks.BlockPosition;
|
||||
import finalforeach.cosmicreach.blocks.BlockState;
|
||||
import finalforeach.cosmicreach.entities.EntityLaserProjectile;
|
||||
import finalforeach.cosmicreach.entities.EntityUniqueId;
|
||||
import finalforeach.cosmicreach.entities.player.Player;
|
||||
import finalforeach.cosmicreach.networking.packets.MessagePacket;
|
||||
import finalforeach.cosmicreach.networking.server.ServerSingletons;
|
||||
import finalforeach.cosmicreach.util.Axis;
|
||||
import finalforeach.cosmicreach.world.Zone;
|
||||
import net.pietru.cookie_utils.permissions.Permissions;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
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.can_edit_block;
|
||||
import static net.pietru.cookie_utils.api.Region.is_not_reloading;
|
||||
|
||||
@Mixin(EntityLaserProjectile.class)
|
||||
public class EntityLaserProjectileMixin extends EntityMixin {
|
||||
@Shadow
|
||||
EntityUniqueId sourceEntityId;
|
||||
|
||||
@Inject(method = "onCollideWithBlock", at = @At("HEAD"), cancellable = true)
|
||||
private void event_collide_block(Axis axis, BlockState block, int bx, int by, int bz, CallbackInfo ci){
|
||||
BlockPosition blockPos = BlockPosition.ofGlobal(this.zone, bx, by, bz);
|
||||
Player plr = null;
|
||||
for (Player p : GameSingletons.world.players) {
|
||||
if (p.getEntity().uniqueId.equals(sourceEntityId)) {
|
||||
plr = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (plr!=null) {
|
||||
Account account = GameSingletons.getAccountFromPlayer(plr);
|
||||
if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_edit_block(blockPos, "laser", account.getUniqueId())) {
|
||||
ci.cancel();
|
||||
|
||||
MessagePacket packet = new MessagePacket("[Server] " + (is_not_reloading ? "Sorry, but this area is under protection." : "Sorry but you can't do this action right now. [Config Reload In Progress]"));
|
||||
packet.setupAndSend(ServerSingletons.getConnection(plr));
|
||||
}
|
||||
}else
|
||||
if (can_edit_block(blockPos, "laser"))
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package net.pietru.cookie_utils.mixins;
|
||||
|
||||
import finalforeach.cosmicreach.entities.Entity;
|
||||
import finalforeach.cosmicreach.world.Zone;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public class EntityMixin {
|
||||
@Shadow
|
||||
public Zone zone;
|
||||
}
|
|
@ -34,6 +34,7 @@ public class ObjectPermList {
|
|||
val.addChild("place", new JsonValue(false));
|
||||
val.addChild("break", new JsonValue(false));
|
||||
val.addChild("interact", new JsonValue(false));
|
||||
val.addChild("laser", new JsonValue(false));
|
||||
|
||||
val.addChild("explode", new JsonValue(false));
|
||||
val.addChild("enter", new JsonValue(true));
|
||||
|
@ -46,6 +47,7 @@ public class ObjectPermList {
|
|||
val.set_bool_perm("place", false);
|
||||
val.set_bool_perm("break", false);
|
||||
val.set_bool_perm("interact", false);
|
||||
val.set_bool_perm("laser", false);
|
||||
|
||||
val.set_bool_perm("explode", false);
|
||||
val.set_bool_perm("enter", true);
|
||||
|
|
|
@ -74,6 +74,7 @@ public class areaPermSetup extends Setup {
|
|||
plr_perm.perms.set_bool_perm("interact", target);
|
||||
plr_perm.perms.set_bool_perm("enter", target);
|
||||
plr_perm.perms.set_bool_perm("pvp", target);
|
||||
plr_perm.perms.set_bool_perm("laser", target);
|
||||
break;
|
||||
case "edit","e":
|
||||
plr_perm.perms.set_bool_perm("place", target);
|
||||
|
@ -88,6 +89,9 @@ public class areaPermSetup extends Setup {
|
|||
case "pvp","p":
|
||||
plr_perm.perms.set_bool_perm("pvp", target);
|
||||
break;
|
||||
case "laser","l":
|
||||
plr_perm.perms.set_bool_perm("laser", target);
|
||||
break;
|
||||
}
|
||||
|
||||
run_setup_finish();
|
||||
|
@ -95,7 +99,7 @@ public class areaPermSetup extends Setup {
|
|||
|
||||
step_hints.add("Interactive setup via chat, please type anything to continue...");
|
||||
step_hints.add("Please select mode - Grant/Revoke (G/R)");
|
||||
step_hints.add("Please select permission: edit(e),interact(i),enter(m),all(a).");
|
||||
step_hints.add("Please select permission: edit(e),interact(i),enter(m),pvp(p),laser(l),all(a).");
|
||||
step_hints.add("Please enter player id...");
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
"BlockBreakMixin",
|
||||
"BlockEntitySignMixin",
|
||||
"BlockPlaceMixin",
|
||||
"EntityLaserProjectileMixin",
|
||||
"EntityMixin",
|
||||
"InteractBlockMixin",
|
||||
"LoginPacketMixin",
|
||||
"MessagePacketMixin",
|
||||
|
|
Loading…
Reference in a new issue