Add DynamicRegion

This commit is contained in:
2025-12-19 17:25:12 +01:00
parent 5958befced
commit 54f8dc9eb0
9 changed files with 160 additions and 66 deletions
@@ -0,0 +1,55 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.region.dynamic;
import de.steamwar.bausystem.region.DynamicRegionSystem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionData;
import lombok.Getter;
import lombok.NonNull;
import java.util.UUID;
public abstract class DynamicRegion implements Region {
@Getter
protected final UUID id;
protected final int minX;
protected final int minZ;
protected DynamicRegion(UUID id, int minX, int minZ) {
this.id = id;
this.minX = minX;
this.minZ = minZ;
DynamicRegionSystem.INSTANCE.add(this);
// TODO: Implement further
}
public void update(DynamicRegion updateFrom) {
}
public abstract void setRegionData(@NonNull RegionData regionData);
public void delete() {
if (getType().isCannotDelete()) return;
DynamicRegionSystem.INSTANCE.remove(this);
// TODO: Implement!
}
}
@@ -0,0 +1,38 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.region.dynamic;
import de.steamwar.bausystem.region.RegionData;
import org.atteo.classindex.IndexAnnotated;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@IndexAnnotated
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface RegionConstructorData {
int widthX();
int widthZ();
boolean placeable() default true;
Class<? extends RegionData> regionDataClass();
}
@@ -33,6 +33,10 @@ public class GlobalRegionData extends RegionData {
public GlobalRegionData() {
super(new YAPIONObject(), () -> {}); // TODO: Implement loading of data and saving!
}
@Override
protected void initialize() {
flagMap.put(Flag.TNT, TNTMode.DENY);
flagMap.put(Flag.COLOR, ColorMode.YELLOW);
flagMap.put(Flag.PROTECT, ProtectMode.INACTIVE);