forked from SteamWar/SteamWar
Update some part of Region
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
steamwar.java
|
||||
}
|
||||
|
||||
tasks.compileJava {
|
||||
options.isWarnings = false
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":BauSystem:BauSystem_Main"))
|
||||
compileOnly(project(":SpigotCore"))
|
||||
|
||||
compileOnly(libs.spigotapi)
|
||||
compileOnly(libs.axiom)
|
||||
compileOnly(libs.authlib)
|
||||
compileOnly(libs.viaapi)
|
||||
|
||||
compileOnly(libs.nms20)
|
||||
compileOnly(libs.fawe18)
|
||||
|
||||
implementation(libs.luaj)
|
||||
implementation(files("$projectDir/../libs/YAPION-SNAPSHOT.jar"))
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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.regionnew;
|
||||
|
||||
import de.steamwar.bausystem.regionnew.flags.Flag;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class FixedFlagStorage implements FlagStorage {
|
||||
|
||||
private Map<Flag<?>, Flag.Value<?>> flagMap = new HashMap<>();
|
||||
|
||||
public static FlagStorage createFromRegion(Region region) {
|
||||
FlagStorage flagStorage = new FixedFlagStorage();
|
||||
Flag.getFlags().forEach(flag -> {
|
||||
if (region.hasFlag(flag).isReadable()) {
|
||||
flagStorage.set(flag, flag.getDefaultValue());
|
||||
}
|
||||
});
|
||||
return flagStorage;
|
||||
}
|
||||
|
||||
public static FlagStorage createFromFile(File file) {
|
||||
throw new IllegalStateException("Not implemented yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Enum<T> & Flag.Value<T>> boolean set(Flag<T> flag, Flag.Value<T> value) {
|
||||
return flagMap.put(flag, value) != value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Enum<T> & Flag.Value<T>> Flag.Value<T> get(Flag<T> flag) {
|
||||
return (Flag.Value<T>) flagMap.get(flag);
|
||||
}
|
||||
}
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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.regionnew;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.steamwar.bausystem.regionnew.flags.Flag;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.Optional;
|
||||
|
||||
public final class FixedGlobalRegion implements Region {
|
||||
|
||||
public static final FixedGlobalRegion INSTANCE = new FixedGlobalRegion();
|
||||
|
||||
private static final Point MIN_POINT = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
private static final Point MAX_POINT = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
private final FlagStorage FLAG_STORAGE = FixedFlagStorage.createFromRegion(this); // TODO: Update to either File or Region creation!
|
||||
|
||||
private FixedGlobalRegion() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionType getType() {
|
||||
return RegionType.GLOBAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy hasFlag(@NonNull Flag<T> flag) {
|
||||
if (flag.oneOff(Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.ITEMS)) {
|
||||
return RegionFlagPolicy.WRITABLE;
|
||||
}
|
||||
return RegionFlagPolicy.NOT_APPLICABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Enum<T> & Flag.Value<T>> boolean setFlag(@NonNull Flag<T> flag, Flag.Value<T> value) {
|
||||
return hasFlag(flag).isWritable() && FLAG_STORAGE.set(flag, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Enum<T> & Flag.Value<T>> Optional<Flag.Value<T>> getFlag(@NonNull Flag<T> flag) {
|
||||
if (hasFlag(flag).isReadable()) {
|
||||
return Optional.of(FLAG_STORAGE.get(flag));
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getMinPoint() {
|
||||
return MIN_POINT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getMaxPoint() {
|
||||
return MAX_POINT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inRegion(Location location) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getBuildMinPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getBuildMaxPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBuildRegion(boolean extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getTestblockMinPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getTestblockMaxPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inTestblockRegion(boolean extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<File> getGameModeConfig() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EditSession> copy() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EditSession> copyBuild() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EditSession> copyTestblock() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetBuild(@Nullable SchematicNode schematicNode, boolean extension) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTestblock(@Nullable SchematicNode schematicNode, boolean extension) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remember(EditSession editSession) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean undo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean redo() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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.regionnew;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.steamwar.bausystem.regionnew.flags.Flag;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.Optional;
|
||||
|
||||
public class FixedRegion implements Region { // TODO: Implement!
|
||||
|
||||
@Override
|
||||
public RegionType getType() {
|
||||
return RegionType.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy hasFlag(@NonNull Flag<T> flag) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Enum<T> & Flag.Value<T>> boolean setFlag(@NonNull Flag<T> flag, Flag.Value<T> value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Enum<T> & Flag.Value<T>> Optional<Flag.Value<T>> getFlag(@NonNull Flag<T> flag) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getMinPoint() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getMaxPoint() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inRegion(Location location) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getBuildMinPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getBuildMaxPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBuildRegion(boolean extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getTestblockMinPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getTestblockMaxPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inTestblockRegion(boolean extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<File> getGameModeConfig() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EditSession> copy() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EditSession> copyBuild() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EditSession> copyTestblock() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetBuild(@Nullable SchematicNode schematicNode, boolean extension) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTestblock(@Nullable SchematicNode schematicNode, boolean extension) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remember(EditSession editSession) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean undo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean redo() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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.regionnew;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class FixedRegionSystem implements RegionSystem {
|
||||
|
||||
private static final Map<String, Region> REGION_MAP = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region getGlobalRegion() {
|
||||
return FixedGlobalRegion.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region get(Location location) {
|
||||
return REGION_MAP.values().stream()
|
||||
.filter(region -> region.inRegion(location))
|
||||
.findFirst()
|
||||
.orElse(FixedGlobalRegion.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Region> getRegion(String name) {
|
||||
return Optional.ofNullable(REGION_MAP.get(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Region> getRegions() {
|
||||
return REGION_MAP.values().stream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModular() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user