Protect from fire, improve protections
This commit is contained in:
parent
07930bdd80
commit
db75fd5626
5 changed files with 77 additions and 29 deletions
|
@ -10,9 +10,9 @@ id=cookie_utils
|
|||
|
||||
# Dependency Versions
|
||||
cosmic_reach_rev=alpha
|
||||
cosmic_reach_version=0.4.8
|
||||
cosmic_reach_version=0.4.9
|
||||
# If unspecified, will use the version above
|
||||
cosmic_reach_server_version=0.4.8
|
||||
cosmic_reach_server_version=0.4.9
|
||||
cosmic_quilt_version=2.3.1
|
||||
#2.2.0
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ public class BlockEntitySignMixin {
|
|||
Area area = new Area();
|
||||
area.enabled = true;
|
||||
ObjectPermList.get_default_perms(area.perms);
|
||||
ObjectPermList.get_safe_perm_overrides(area.perms);
|
||||
area.setCorners(ca, cb);
|
||||
area.name = "claim_sign/self_claim_sign_"+c+"_" + ownerId.replace(":", "_") + ".json";
|
||||
area.zoneId = zone.zoneId;
|
||||
|
|
|
@ -1,10 +1,27 @@
|
|||
package net.pietru.cookie_utils.mixins;
|
||||
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import finalforeach.cosmicreach.accounts.Account;
|
||||
import finalforeach.cosmicreach.entities.Entity;
|
||||
import finalforeach.cosmicreach.entities.EntityFlameProjectile;
|
||||
import finalforeach.cosmicreach.entities.EntityLaserProjectile;
|
||||
import finalforeach.cosmicreach.entities.IDamageSource;
|
||||
import finalforeach.cosmicreach.entities.components.PlayerFallDamage;
|
||||
import finalforeach.cosmicreach.entities.player.Player;
|
||||
import finalforeach.cosmicreach.entities.player.PlayerEntity;
|
||||
import finalforeach.cosmicreach.networking.packets.MessagePacket;
|
||||
import finalforeach.cosmicreach.networking.server.ServerSingletons;
|
||||
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_enter_position;
|
||||
import static net.pietru.cookie_utils.api.Region.is_not_reloading;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public class EntityMixin {
|
||||
|
@ -12,4 +29,32 @@ public class EntityMixin {
|
|||
public Zone zone;
|
||||
@Shadow
|
||||
public Vector3 position;
|
||||
|
||||
@Inject(method = "hit", at = @At("HEAD"), cancellable = true)
|
||||
private void event_player_hit(CallbackInfo ci, @Local(argsOnly = true) IDamageSource damageSource, @Local(argsOnly = true) float amount){
|
||||
if (damageSource instanceof Entity) {
|
||||
if (damageSource instanceof PlayerEntity) {
|
||||
Account account = ((PlayerEntity) damageSource).getPlayer().getAccount();
|
||||
|
||||
if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_enter_position(((Entity) damageSource).getPosition(), "pve", account.getUniqueId())) {
|
||||
ci.cancel();
|
||||
|
||||
MessagePacket packet = new MessagePacket("[Server] " + (is_not_reloading ? "Sorry, but you can't things here." : "Sorry but you can't do this action right now. [Config Reload In Progress]"));
|
||||
packet.setupAndSend(ServerSingletons.getConnection(((PlayerEntity) damageSource).getPlayer()));
|
||||
}
|
||||
} else if (damageSource instanceof EntityLaserProjectile) {
|
||||
if (!can_enter_position(((Entity)damageSource).getPosition(), "laser_damage", this.zone)) {
|
||||
ci.cancel();
|
||||
}
|
||||
} else if (damageSource instanceof EntityFlameProjectile) {
|
||||
if (!can_enter_position(((Entity)damageSource).getPosition(), "fire_damage", this.zone)) {
|
||||
ci.cancel();
|
||||
}
|
||||
} else {
|
||||
if (!can_enter_position(((Entity)damageSource).getPosition(), "eve", this.zone)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ 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.EntityFlameProjectile;
|
||||
import finalforeach.cosmicreach.entities.EntityLaserProjectile;
|
||||
import finalforeach.cosmicreach.entities.IDamageSource;
|
||||
import finalforeach.cosmicreach.entities.components.PlayerFallDamage;
|
||||
|
@ -20,42 +21,27 @@ import static net.pietru.cookie_utils.api.Region.*;
|
|||
@Mixin(PlayerEntity.class)
|
||||
public class PlayerEntityMixin extends EntityMixin{
|
||||
|
||||
@Inject(method = "onAttackInteraction", at = @At("HEAD"), cancellable = true)
|
||||
private void event_player_attack(CallbackInfo ci, @Local(argsOnly = true) Entity sourceEntity){
|
||||
if (sourceEntity instanceof PlayerEntity){
|
||||
Account account = ((PlayerEntity) sourceEntity).getPlayer().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).getPlayer()));
|
||||
}
|
||||
} else if (sourceEntity instanceof EntityLaserProjectile) {
|
||||
if (!can_enter_position(sourceEntity.getPosition(),"laser_damage",this.zone)){
|
||||
ci.cancel();
|
||||
}
|
||||
} else {
|
||||
if (!can_enter_position(sourceEntity.getPosition(),"pve",this.zone)){
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "hit", at = @At("HEAD"), cancellable = true)
|
||||
private void event_player_hit(CallbackInfo ci, @Local(argsOnly = true) IDamageSource damageSource, @Local(argsOnly = true) float amount){
|
||||
if (damageSource instanceof Entity) {
|
||||
if (damageSource instanceof PlayerEntity) {
|
||||
Account account = ((PlayerEntity) damageSource).getPlayer().getAccount();
|
||||
Entity ob = ((Entity)(Object)this);
|
||||
|
||||
if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_enter_position(((Entity)damageSource).getPosition(), "pvp", account.getUniqueId())) {
|
||||
if (ob instanceof PlayerEntity) {
|
||||
if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_enter_position(((Entity) damageSource).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) damageSource).getPlayer()));
|
||||
}
|
||||
}
|
||||
} else if (damageSource instanceof EntityLaserProjectile) {
|
||||
if (!can_enter_position(((Entity)damageSource).getPosition(), "laser_damage", this.zone)) {
|
||||
if (!can_enter_position(((Entity)damageSource).getPosition(), "player_laser_damage", this.zone)) {
|
||||
ci.cancel();
|
||||
}
|
||||
} else if (damageSource instanceof EntityFlameProjectile) {
|
||||
if (!can_enter_position(((Entity)damageSource).getPosition(), "player_fire_damage", this.zone)) {
|
||||
ci.cancel();
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Map;
|
|||
|
||||
public class ObjectPermList {
|
||||
public static final Map<String,Boolean> default_bool_perms = new HashMap<>();
|
||||
public static final Map<String,Boolean> safety_overrides_bool_perms = new HashMap<>();
|
||||
static {
|
||||
default_bool_perms.put("place", false);
|
||||
default_bool_perms.put("break", false);
|
||||
|
@ -20,8 +21,17 @@ public class ObjectPermList {
|
|||
|
||||
default_bool_perms.put("pvp", false);
|
||||
default_bool_perms.put("pve", true);
|
||||
default_bool_perms.put("eve", true);
|
||||
default_bool_perms.put("player_laser_damage", true);
|
||||
default_bool_perms.put("laser_damage", true);
|
||||
default_bool_perms.put("player_fire_damage", true);
|
||||
default_bool_perms.put("fire_damage", true);
|
||||
default_bool_perms.put("fall_damage",true);
|
||||
|
||||
safety_overrides_bool_perms.put("pve", false);
|
||||
safety_overrides_bool_perms.put("player_laser_damage", false);
|
||||
safety_overrides_bool_perms.put("player_fire_damage", false);
|
||||
safety_overrides_bool_perms.put("fall_damage",false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,4 +69,10 @@ public class ObjectPermList {
|
|||
val.set_bool_perm(key,default_bool_perms.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
public static void get_safe_perm_overrides(ObjectPermList val){
|
||||
for (String key : safety_overrides_bool_perms.keySet()){
|
||||
val.set_bool_perm(key,default_bool_perms.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue