This commit is contained in:
parent
c12c02bda6
commit
3a97650a7a
7 changed files with 51 additions and 7 deletions
|
@ -5,7 +5,6 @@ import finalforeach.cosmicreach.accounts.Account;
|
|||
import finalforeach.cosmicreach.blocks.BlockPosition;
|
||||
import finalforeach.cosmicreach.blocks.BlockState;
|
||||
import finalforeach.cosmicreach.networking.NetworkIdentity;
|
||||
import finalforeach.cosmicreach.networking.NetworkSide;
|
||||
import finalforeach.cosmicreach.networking.packets.MessagePacket;
|
||||
import finalforeach.cosmicreach.networking.packets.blocks.BreakBlockPacket;
|
||||
import finalforeach.cosmicreach.networking.server.ServerSingletons;
|
||||
|
@ -13,6 +12,7 @@ import finalforeach.cosmicreach.world.Zone;
|
|||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.pietru.cookie_utils.permissions.Permissions;
|
||||
import net.pietru.cookie_utils.setups.Setup;
|
||||
import net.pietru.cookie_utils.utils.player_utils;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -35,6 +35,11 @@ public class BlockBreakMixin {
|
|||
private void event_block_break(CallbackInfo ci, @Local NetworkIdentity identity, @Local ChannelHandlerContext ctx){
|
||||
if (identity.isServer()) {
|
||||
Account account = ServerSingletons.getAccount(identity);
|
||||
|
||||
if (player_utils.preform_safety_checks(account)){
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_edit_block(blockPos,"break",account.getUniqueId())) {
|
||||
ci.cancel();
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.pietru.cookie_utils.api.Region;
|
|||
import net.pietru.cookie_utils.permissions.ObjectPermList;
|
||||
import net.pietru.cookie_utils.permissions.Permissions;
|
||||
import net.pietru.cookie_utils.permissions.PlayerAreaPerm;
|
||||
import net.pietru.cookie_utils.utils.player_utils;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -30,6 +31,12 @@ public class BlockEntitySignMixin {
|
|||
|
||||
@Inject(method = "onInteract", at = @At("HEAD"), cancellable = true)
|
||||
private void event_onInteract(CallbackInfo ci, @Local Player player, @Local Zone zone){
|
||||
|
||||
if (player_utils.preform_safety_checks(player)){
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (texts[0].equals("[CLAIM]") && texts[2].isEmpty() && !player.isProne) {
|
||||
BlockEntity be = (BlockEntity) (Object) this;
|
||||
int x = be.getGlobalX();
|
||||
|
|
|
@ -8,13 +8,12 @@ import finalforeach.cosmicreach.blocks.BlockStateMissing;
|
|||
import finalforeach.cosmicreach.items.ItemMergeStrategy;
|
||||
import finalforeach.cosmicreach.items.ItemStack;
|
||||
import finalforeach.cosmicreach.networking.NetworkIdentity;
|
||||
import finalforeach.cosmicreach.networking.NetworkSide;
|
||||
import finalforeach.cosmicreach.networking.packets.MessagePacket;
|
||||
import finalforeach.cosmicreach.networking.packets.blocks.PlaceBlockPacket;
|
||||
import finalforeach.cosmicreach.networking.server.ServerSingletons;
|
||||
import finalforeach.cosmicreach.world.Zone;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.pietru.cookie_utils.permissions.Permissions;
|
||||
import net.pietru.cookie_utils.utils.player_utils;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -41,6 +40,12 @@ public class BlockPlaceMixin {
|
|||
temp.convertToLocal(identity.getZone());
|
||||
if (identity.isServer() && !ci.isCancelled()) {
|
||||
Account account = ServerSingletons.getAccount(identity);
|
||||
|
||||
if (player_utils.preform_safety_checks(account)){
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_edit_block(temp,"place",account.getUniqueId())) {
|
||||
ci.cancel();
|
||||
if (!identity.getPlayer().gamemode.hasInfiniteItems())
|
||||
|
|
|
@ -5,13 +5,12 @@ import finalforeach.cosmicreach.accounts.Account;
|
|||
import finalforeach.cosmicreach.blocks.BlockPosition;
|
||||
import finalforeach.cosmicreach.blocks.BlockState;
|
||||
import finalforeach.cosmicreach.networking.NetworkIdentity;
|
||||
import finalforeach.cosmicreach.networking.NetworkSide;
|
||||
import finalforeach.cosmicreach.networking.packets.MessagePacket;
|
||||
import finalforeach.cosmicreach.networking.packets.blocks.InteractBlockPacket;
|
||||
import finalforeach.cosmicreach.networking.server.ServerSingletons;
|
||||
import finalforeach.cosmicreach.world.Zone;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.pietru.cookie_utils.permissions.Permissions;
|
||||
import net.pietru.cookie_utils.utils.player_utils;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -36,6 +35,12 @@ public class InteractBlockMixin {
|
|||
private void event_block_interact(CallbackInfo ci, @Local NetworkIdentity identity, @Local ChannelHandlerContext ctx){
|
||||
if (identity.isServer()) {
|
||||
Account account = ServerSingletons.getAccount(identity);
|
||||
|
||||
if (player_utils.preform_safety_checks(account)){
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockPos!=null) {
|
||||
BlockPosition temp = blockPos.copy();
|
||||
temp.convertToLocal(identity.getZone());
|
||||
|
|
|
@ -6,7 +6,6 @@ import finalforeach.cosmicreach.accounts.Account;
|
|||
import finalforeach.cosmicreach.entities.Entity;
|
||||
import finalforeach.cosmicreach.entities.player.Player;
|
||||
import finalforeach.cosmicreach.networking.NetworkIdentity;
|
||||
import finalforeach.cosmicreach.networking.NetworkSide;
|
||||
import finalforeach.cosmicreach.networking.packets.MessagePacket;
|
||||
import finalforeach.cosmicreach.networking.packets.entities.PlayerPositionPacket;
|
||||
import finalforeach.cosmicreach.networking.server.ServerSingletons;
|
||||
|
@ -46,6 +45,11 @@ public class PlayerPositionMixin {
|
|||
Account account = ServerSingletons.getAccount(identity);
|
||||
Player player = ServerSingletons.getPlayer(identity);
|
||||
|
||||
if (player_utils.preform_safety_checks(account)){
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_enter_position(position,"enter",playerUniqueId)) {
|
||||
ci.cancel();
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.pietru.cookie_utils.mixins;
|
|||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import finalforeach.cosmicreach.GameSingletons;
|
||||
import finalforeach.cosmicreach.accounts.Account;
|
||||
import finalforeach.cosmicreach.entities.player.Player;
|
||||
import finalforeach.cosmicreach.networking.NetworkIdentity;
|
||||
import finalforeach.cosmicreach.networking.packets.ZonePacket;
|
||||
import finalforeach.cosmicreach.networking.server.ServerSingletons;
|
||||
|
@ -17,8 +18,9 @@ public class ServerSingletonsMixin {
|
|||
|
||||
@Inject(method = "addAccount", at = @At("TAIL"))
|
||||
private static void event_player_data(CallbackInfo ci, @Local NetworkIdentity id, @Local Account account){
|
||||
Player p = account.getPlayer();
|
||||
for (Zone z : GameSingletons.world.getZones()){
|
||||
if (!account.getPlayer().getZone().zoneId.equals(z.zoneId)){
|
||||
if (!p.getZone().zoneId.equals(z.zoneId)){
|
||||
id.send(new ZonePacket(z, false));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,4 +82,20 @@ public class player_utils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean preform_safety_checks(Player player){
|
||||
if (player==null)
|
||||
return true;
|
||||
if (player.getAccount()==null)
|
||||
return true;
|
||||
return player.getAccount().getUniqueId()==null;
|
||||
}
|
||||
|
||||
public static boolean preform_safety_checks(Account account){
|
||||
if (account==null)
|
||||
return true;
|
||||
if (account.getPlayer()==null)
|
||||
return true;
|
||||
return account.getUniqueId()==null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue