Compare commits
3 commits
dc014a4fe5
...
53db2009fc
Author | SHA1 | Date | |
---|---|---|---|
53db2009fc | |||
db75fd5626 | |||
07930bdd80 |
7 changed files with 84 additions and 33 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
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ public class BlockEntitySignMixin {
|
|||
|
||||
@Shadow
|
||||
private String[] texts = new String[]{"", "", "", "", ""};
|
||||
@Shadow
|
||||
public boolean textureDirty = true;
|
||||
|
||||
@Inject(method = "onInteract", at = @At("HEAD"), cancellable = true)
|
||||
private void event_onInteract(CallbackInfo ci, @Local Player player, @Local Zone zone){
|
||||
|
@ -67,6 +69,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;
|
||||
|
@ -85,6 +88,9 @@ public class BlockEntitySignMixin {
|
|||
|
||||
MessagePacket packet = new MessagePacket("[Server] Successfully claimed area of size "+size+" (size*2+1)");
|
||||
packet.setupAndSend(ServerSingletons.getConnection(player));
|
||||
|
||||
texts[2] = player.getAccount().getDisplayName();
|
||||
textureDirty = true;
|
||||
} else {
|
||||
MessagePacket packet = new MessagePacket("[Server] Area of size "+size+" intersects another protected area...");
|
||||
packet.setupAndSend(ServerSingletons.getConnection(player));
|
||||
|
|
|
@ -6,9 +6,7 @@ import finalforeach.cosmicreach.blocks.BlockPosition;
|
|||
import finalforeach.cosmicreach.blocks.BlockState;
|
||||
import finalforeach.cosmicreach.blocks.BlockStateMissing;
|
||||
import finalforeach.cosmicreach.entities.player.Player;
|
||||
import finalforeach.cosmicreach.items.ItemMergeStrategy;
|
||||
import finalforeach.cosmicreach.items.ItemSlot;
|
||||
import finalforeach.cosmicreach.items.ItemStack;
|
||||
import finalforeach.cosmicreach.networking.NetworkIdentity;
|
||||
import finalforeach.cosmicreach.networking.packets.MessagePacket;
|
||||
import finalforeach.cosmicreach.networking.packets.blocks.PlaceBlockPacket;
|
||||
|
|
|
@ -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())) {
|
||||
ci.cancel();
|
||||
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()));
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import finalforeach.cosmicreach.entities.player.Player;
|
|||
import finalforeach.cosmicreach.networking.packets.ParticleSystemPacket;
|
||||
import finalforeach.cosmicreach.networking.server.ServerSingletons;
|
||||
import finalforeach.cosmicreach.particles.GameParticleSystem;
|
||||
import finalforeach.cosmicreach.particles.IParticleComponent;
|
||||
import finalforeach.cosmicreach.particles.spawn.GameParticleSpawnSphere;
|
||||
import finalforeach.cosmicreach.particles.components.IParticleComponent;
|
||||
import finalforeach.cosmicreach.particles.components.spawn.GameParticleSpawnSphere;
|
||||
import finalforeach.cosmicreach.world.Zone;
|
||||
import net.pietru.cookie_utils.scripting.BaseScript;
|
||||
import net.pietru.cookie_utils.scripting.ExecutionContext;
|
||||
|
|
Loading…
Reference in a new issue