SteamWar/BauSystem2.0
Archiviert
12
0

Initial stuff
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-06-09 10:54:27 +02:00
Ursprung d7dc2515c0
Commit db48cde912
5 geänderte Dateien mit 295 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,82 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.features.simulatorn;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.linkage.Disable;
import de.steamwar.bausystem.linkage.Enable;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.utils.ItemUtils;
import de.steamwar.inventory.SWItem;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@Linked(LinkageType.ENABLE_LINK)
@Linked(LinkageType.DISABLE_LINK)
public class SimulatorStorage implements Enable, Disable {
private static NamespacedKey simulatorSelection = SWUtils.getNamespaceKey("simulator_selection");
private static Map<String, TNTSimulator> tntSimulators = new HashMap<>();
public static Set<String> getSimulatorNames() {
return tntSimulators.keySet();
}
public static TNTSimulator getSimulator(String name) {
return tntSimulators.get(name);
}
public static TNTSimulator getSimulator(ItemStack itemStack) {
if (!ItemUtils.isItem(itemStack, "simulator")) {
return null;
}
String selection = ItemUtils.getTag(itemStack, simulatorSelection);
if (selection == null) {
return null;
}
return tntSimulators.get(selection);
}
public static ItemStack getWand(Player p) {
ItemStack itemStack = new SWItem(Material.BLAZE_ROD, BauSystem.MESSAGE.parse("SIMULATOR_WAND_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_1", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_2", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_3", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_4", p)), false, null).getItemStack();
ItemUtils.setItem(itemStack, "simulator");
return itemStack;
}
@Override
public void enable() {
}
@Override
public void disable() {
}
}

Datei anzeigen

@ -0,0 +1,27 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.features.simulatorn;
import org.bukkit.Material;
public class TNTSimulator {
private Material material;
}

Datei anzeigen

@ -0,0 +1,37 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.features.simulatorn.tnt;
import de.steamwar.bausystem.shared.Pair;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.Map;
public interface SimulatorElement {
void show(Player player);
void hide(Player player);
ItemStack menu();
void locations(Map<Integer, Map<Integer, Pair<Runnable, Integer>>> result, Vector origin, int tickOffset, World world); // Ticks to subtick order to spawning runnable to count of activations
}

Datei anzeigen

@ -0,0 +1,80 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.features.simulatorn.tnt;
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
import de.steamwar.bausystem.shared.Pair;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.HashMap;
import java.util.Map;
public class TNTElement implements SimulatorElement {
private final AbstractSimulatorEntity entity;
private final Vector position;
private int fuseTicks = 80;
private int count = 1;
private int tickOffset = 0;
private boolean xVelocity = false;
private boolean yVelocity = false;
private boolean zVelocity = false;
private int order = 0;
private Material material = Material.TNT;
public TNTElement(Vector position, AbstractSimulatorEntity entity) {
this.position = position;
this.entity = entity;
}
@Override
public void show(Player player) {
entity.sendEntity(player);
}
@Override
public void hide(Player player) {
entity.hide(player, true);
}
@Override
public ItemStack menu() {
return null;
}
@Override
public void locations(Map<Integer, Map<Integer, Pair<Runnable, Integer>>> result, Vector origin, int tickOffset, World world) {
result.computeIfAbsent(this.tickOffset + tickOffset, ignore -> new HashMap<>())
.computeIfAbsent(order, ignore -> new Pair<>(() -> {
world.spawn(position.clone().add(origin).toLocation(world), TNTPrimed.class, tntPrimed -> {
tntPrimed.setFuseTicks(fuseTicks);
if (!xVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0));
if (!yVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0));
if (!zVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setZ(0));
});
}, count));
}
}

Datei anzeigen

@ -0,0 +1,69 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.features.simulatorn.tnt;
import de.steamwar.bausystem.shared.Pair;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class TNTGroup implements SimulatorElement {
private final Vector position;
private int tickOffset = 0;
private Material material = Material.BARREL;
private List<TNTElement> elements = new ArrayList<>();
public TNTGroup(Vector position) {
this.position = position;
}
@Override
public void show(Player player) {
elements.forEach(tntElement -> {
tntElement.show(player);
});
}
@Override
public void hide(Player player) {
elements.forEach(tntElement -> {
tntElement.hide(player);
});
}
@Override
public ItemStack menu() {
return null;
}
@Override
public void locations(Map<Integer, Map<Integer, Pair<Runnable, Integer>>> result, Vector origin, int tickOffset, World world) {
elements.forEach(tntElement -> {
tntElement.locations(result, origin.clone().add(position), this.tickOffset + tickOffset, world);
});
}
}