This commit is contained in:
parent
9f032739db
commit
23cc2c8582
5 changed files with 14 additions and 10 deletions
|
@ -21,6 +21,7 @@ public class Area {
|
|||
BoundingBox space = new BoundingBox();
|
||||
|
||||
public String name = "none";
|
||||
public String zoneId = "";
|
||||
public String parent = "";
|
||||
public boolean enabled = true;
|
||||
public boolean protect = false;
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.badlogic.gdx.math.Vector3;
|
|||
import com.badlogic.gdx.utils.*;
|
||||
import finalforeach.cosmicreach.blocks.BlockPosition;
|
||||
import finalforeach.cosmicreach.io.SaveLocation;
|
||||
import finalforeach.cosmicreach.networking.server.ServerSingletons;
|
||||
import finalforeach.cosmicreach.world.Zone;
|
||||
import net.pietru.cookie_utils.permissions.ObjectPermList;
|
||||
import net.pietru.cookie_utils.permissions.PlayerAreaPerm;
|
||||
|
@ -29,7 +30,7 @@ public class Region {
|
|||
|
||||
if (is_not_reloading)
|
||||
for (Area a : areas){
|
||||
if (a.enabled && a.does_intersect(g_position)){
|
||||
if (a.enabled && (z.zoneId.isEmpty() || z.zoneId.equals(a.zoneId)) && a.does_intersect(g_position)){
|
||||
can=a.get_action_bool(action,player_id);
|
||||
break;
|
||||
}
|
||||
|
@ -46,7 +47,7 @@ public class Region {
|
|||
if (is_not_reloading)
|
||||
for (int i = 0; i< areas.size; i++){
|
||||
Area a = areas.get(i);
|
||||
if (a.enabled && a.does_intersect(g_position)){
|
||||
if (a.enabled && (z.zoneId.isEmpty() || z.zoneId.equals(a.zoneId)) && a.does_intersect(g_position)){
|
||||
can=a.get_action_bool(action);
|
||||
break;
|
||||
}
|
||||
|
@ -57,11 +58,12 @@ public class Region {
|
|||
|
||||
public static boolean can_enter_position(Vector3 position,String action,String player_id){
|
||||
boolean can = is_not_reloading;
|
||||
Zone z = ServerSingletons.getAccountByUniqueId(player_id).getPlayer().getZone();
|
||||
|
||||
if (is_not_reloading)
|
||||
for (int i = 0; i< areas.size; i++){
|
||||
Area a = areas.get(i);
|
||||
if (a.enabled && a.does_intersect(position)){
|
||||
if (a.enabled && (z.zoneId.isEmpty() || z.zoneId.equals(a.zoneId)) && a.does_intersect(position)){
|
||||
can=a.get_action_bool(action,player_id);
|
||||
break;
|
||||
}
|
||||
|
@ -70,13 +72,13 @@ public class Region {
|
|||
return can;
|
||||
}
|
||||
|
||||
public static boolean can_enter_position(Vector3 position,String action){
|
||||
public static boolean can_enter_position(Vector3 position,String action, Zone z){
|
||||
boolean can = is_not_reloading;
|
||||
|
||||
if (is_not_reloading)
|
||||
for (int i = 0; i< areas.size; i++){
|
||||
Area a = areas.get(i);
|
||||
if (a.enabled && a.does_intersect(position)){
|
||||
if (a.enabled && (z.zoneId.isEmpty() || z.zoneId.equals(a.zoneId)) && a.does_intersect(position)){
|
||||
can=a.get_action_bool(action);
|
||||
break;
|
||||
}
|
||||
|
@ -100,11 +102,11 @@ public class Region {
|
|||
return can;
|
||||
}
|
||||
|
||||
public static Area get_area_at_pos(Vector3 position){
|
||||
public static Area get_area_at_pos(Vector3 position, Zone z){
|
||||
if (is_not_reloading)
|
||||
for (int i = 0; i< areas.size; i++){
|
||||
Area a = areas.get(i);
|
||||
if (a.enabled && a.does_intersect(position)){
|
||||
if (a.enabled && (z.zoneId.isEmpty() || z.zoneId.equals(a.zoneId)) && a.does_intersect(position)){
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
@ -149,6 +151,7 @@ public class Region {
|
|||
area.enabled=region.getBoolean("enabled",true);
|
||||
area.protect=region.getBoolean("protect",false);
|
||||
|
||||
area.zoneId = region.getString("zoneId","");
|
||||
area.parent = region.getString("parent","");
|
||||
if (area.parent.isEmpty()) {
|
||||
ObjectPermList perms = area.perms;
|
||||
|
|
|
@ -88,7 +88,7 @@ public class TextCommands {
|
|||
commands.put("my_area",(args, networkIdentity, channelHandlerContext) -> {
|
||||
Account account = ServerSingletons.getAccount(networkIdentity);
|
||||
Player plr = ServerSingletons.getPlayer(networkIdentity);
|
||||
Area area = get_area_at_pos(plr.getPosition());
|
||||
Area area = get_area_at_pos(plr.getPosition(), plr.getZone());
|
||||
|
||||
MessagePacket packet = new MessagePacket("You are in "+(area!=null?area.name : "no area atm..."));
|
||||
packet.playerUniqueId=account.getUniqueId();
|
||||
|
|
|
@ -22,7 +22,7 @@ public class MobSpawnerMixin {
|
|||
|
||||
@Inject(method = "spawnMob", at = @At("HEAD"), cancellable = true)
|
||||
private void event_spawnMob(CallbackInfo ci, @Local Zone zone){
|
||||
if (!can_enter_position(tmpSpawnPackLoc,"spawn_mob")) {
|
||||
if (!can_enter_position(tmpSpawnPackLoc,"spawn_mob", zone)) {
|
||||
++numberOfMobs;
|
||||
ci.cancel();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class areaPermSetup extends Setup {
|
|||
@Override
|
||||
public boolean can_start_setup(String playerId) {
|
||||
Player player = GameSingletons.getPlayerFromUniqueId(playerId);
|
||||
area=get_area_at_pos(player.getPosition());
|
||||
area=get_area_at_pos(player.getPosition(), player.getZone());
|
||||
return area!=null&&Region.is_area_user_type(player.getPosition(),playerId,"Owner");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue