Add BauSystem module

Fix ci java version
Fix LinkageProcessor
This commit is contained in:
2024-08-05 13:28:50 +02:00
parent 41d31e6c9c
commit 3366a30b0c
526 changed files with 43550 additions and 149479 deletions
@@ -0,0 +1,5 @@
package de.steamwar.bausystem.shared;
public interface EnumDisplay {
String getChatValue();
}
@@ -0,0 +1,56 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.shared;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@Getter
@EqualsAndHashCode
public class Pair<K, V> {
private K key;
private V value;
public Pair(final K key, final V value) {
this.key = key;
this.value = value;
}
public K setKey(final K key) {
final K currentKey = this.key;
this.key = key;
return currentKey;
}
public V setValue(final V value) {
final V currentValue = this.value;
this.value = value;
return currentValue;
}
@Override
public String toString() {
return this.key + "=" + this.value;
}
}
@@ -0,0 +1,30 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.shared;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.util.Vector;
@Getter
@AllArgsConstructor
public class Position {
private final Vector location;
}
@@ -0,0 +1,36 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.shared;
import java.util.concurrent.atomic.AtomicInteger;
public final class ReferenceCounter {
private AtomicInteger references = new AtomicInteger(0);
public int increment() {
return references.getAndIncrement();
}
public int decrement() {
return references.decrementAndGet();
}
}
@@ -0,0 +1,83 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.shared;
import org.bukkit.util.Vector;
import java.util.Objects;
public class RoundedPosition {
private static final long factor = 10;
private long x;
private long y;
private long z;
public RoundedPosition(Position position) {
this(position.getLocation().getX(), position.getLocation().getY(), position.getLocation().getZ());
}
public RoundedPosition(Position position, int factor) {
this(position.getLocation().getX(), position.getLocation().getY(), position.getLocation().getZ(), factor);
}
public RoundedPosition(Vector vector) {
this(vector.getX(), vector.getY(), vector.getZ());
}
public RoundedPosition(Vector vector, int factor) {
this(vector.getX(), vector.getY(), vector.getZ(), factor);
}
public RoundedPosition(double x, double y, double z) {
this.x = (long) (x * factor);
this.y = (long) (y * factor);
this.z = (long) (z * factor);
}
public RoundedPosition(double x, double y, double z, long factor) {
if (factor == -1) {
this.x = Double.doubleToLongBits(x);
this.y = Double.doubleToLongBits(y);
this.z = Double.doubleToLongBits(z);
} else {
this.x = (long) (x * factor);
this.y = (long) (y * factor);
this.z = (long) (z * factor);
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof RoundedPosition)) return false;
RoundedPosition that = (RoundedPosition) o;
return x == that.x &&
y == that.y &&
z == that.z;
}
@Override
public int hashCode() {
return Objects.hash(x, y, z);
}
}
@@ -0,0 +1,26 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.shared;
public interface ShowMode<T extends Position> {
void show(T position);
void hide();
}
@@ -0,0 +1,143 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.shared;
@SuppressWarnings({"unused", "UnusedReturnValue"})
public class SizedStack<T> {
private int maxSize;
private T[] data;
private int size;
private int head;
public SizedStack(int size) {
this.maxSize = size;
//noinspection unchecked
this.data = (T[]) new Object[this.maxSize];
this.head = 0;
this.size = 0;
}
public T push(final T element) {
this.data[this.head] = element;
this.increaseHead();
this.increaseSize();
return element;
}
public T pop() {
this.decreaseHead();
this.decreaseSize();
final T result = this.data[this.head];
this.data[this.head] = null;
return result;
}
public T peek() {
return this.data[this.head];
}
public boolean empty() {
return this.size == 0;
}
protected boolean canEqual(final Object other) {
return other instanceof SizedStack;
}
private void increaseHead() {
this.head++;
while (this.head > this.maxSize - 1) {
this.head -= this.maxSize;
}
}
private void decreaseHead() {
this.head--;
while (this.head < 0) {
this.head += this.maxSize;
}
}
private void increaseSize() {
if (this.size < this.maxSize) {
this.size++;
}
}
private void decreaseSize() {
if (this.size > 0) {
this.size--;
}
}
@Override
public int hashCode() {
final int PRIME = 59;
int result = 1;
result = result * PRIME + this.maxSize;
result = result * PRIME + this.toString().hashCode();
result = result * PRIME + this.size;
return result;
}
@Override
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof SizedStack)) {
return false;
}
final SizedStack<?> other = (SizedStack<?>) o;
if (!other.canEqual(this)) {
return false;
}
if (this.maxSize != other.maxSize) {
return false;
}
if (this.size != other.size) {
return false;
}
if (!this.data.getClass().equals(other.data.getClass())) {
return false;
}
return this.toString().equals(other.toString());
}
public int getMaxSize() {
return maxSize;
}
public int getSize() {
return size;
}
@Override
public String toString() {
final StringBuilder result = new StringBuilder("[");
for (int i = 0; i < this.size - 1; i++) {
result.append(this.data[(this.head - i - 1 < 0) ? (this.head - i - 1 + this.maxSize) : (this.head - i - 1)]).append(",");
}
result.append(this.data[(this.head - this.size < 0) ? (this.head - this.size + this.maxSize) : (this.head - this.size)]);
result.append("]");
return result.toString();
}
}