forked from SteamWar/SteamWar
Fixed build errors after merge
This commit is contained in:
@@ -1,20 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify it under the terms of the
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* of the License, or (at your option) any later version.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* Affero General Public License for more details.
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.bausystem;
|
package de.steamwar.bausystem;
|
||||||
@@ -71,6 +69,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
@Getter
|
@Getter
|
||||||
private static BauSystem instance;
|
private static BauSystem instance;
|
||||||
|
|
||||||
|
@Getter
|
||||||
private SpigotLinker linker;
|
private SpigotLinker linker;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -183,7 +182,8 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (TickManager.impl.isFrozen()) return;
|
if (TickManager.impl.isFrozen())
|
||||||
|
return;
|
||||||
if (counter >= delay) {
|
if (counter >= delay) {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
cancel();
|
cancel();
|
||||||
@@ -201,7 +201,8 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (TickManager.impl.isFrozen()) return;
|
if (TickManager.impl.isFrozen())
|
||||||
|
return;
|
||||||
if (counter >= (first ? delay : period)) {
|
if (counter >= (first ? delay : period)) {
|
||||||
first = false;
|
first = false;
|
||||||
runnable.run();
|
runnable.run();
|
||||||
@@ -217,4 +218,4 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
AtomicReference<BukkitTask> task = new AtomicReference<>();
|
AtomicReference<BukkitTask> task = new AtomicReference<>();
|
||||||
task.set(runTaskTimer(plugin, () -> consumer.accept(task.get()), delay, period));
|
task.set(runTaskTimer(plugin, () -> consumer.accept(task.get()), delay, period));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-23
@@ -19,13 +19,11 @@ package de.steamwar.bausystem.features.simulator;
|
|||||||
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
import de.steamwar.bausystem.features.simulator.display.ASimulatorCursor;
|
||||||
import de.steamwar.bausystem.features.simulator.display.EmptySimulatorCursor;
|
import de.steamwar.bausystem.features.simulator.display.EmptySimulatorCursor;
|
||||||
import de.steamwar.bausystem.features.simulator.display.SimulatorCursor;
|
import de.steamwar.bausystem.features.simulator.display.SimulatorCursor;
|
||||||
import de.steamwar.bausystem.features.simulator.display.SimulatorCursorMode;
|
import de.steamwar.bausystem.features.simulator.display.SimulatorCursorMode;
|
||||||
|
|
||||||
import de.steamwar.bausystem.utils.cursor.Cursor;
|
|
||||||
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.MinVersion;
|
import de.steamwar.linkage.MinVersion;
|
||||||
|
|
||||||
@@ -42,18 +40,13 @@ import java.util.*;
|
|||||||
@Linked
|
@Linked
|
||||||
@MinVersion(19)
|
@MinVersion(19)
|
||||||
public class SimulatorCursorManager implements Listener {
|
public class SimulatorCursorManager implements Listener {
|
||||||
|
public static final SimulatorCursorManager INSTANCE = new SimulatorCursorManager();
|
||||||
|
|
||||||
private final Map<Player, Map<Simulator, Cursor>> activeCursorsByPlayerBySimulator = new HashMap<>();
|
private final Map<Player, Map<Simulator, ASimulatorCursor>> openCursorsByPlayerBySimulator = new HashMap<>();
|
||||||
|
private final Map<Player, ASimulatorCursor> activeCursorByPlayer = new HashMap<>();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerItemEquip(PlayerItemHeldEvent event) {
|
public void onPlayerItemEquip(PlayerItemHeldEvent event) {
|
||||||
ItemStack oldItem = event.getPlayer().getInventory().getItem(event.getPreviousSlot());
|
|
||||||
|
|
||||||
if (SimulatorUtils.isSimulatorItem(oldItem)) {
|
|
||||||
Simulator simulator = SimulatorStorage.getSimulator(oldItem);
|
|
||||||
hideCursor(event.getPlayer(), simulator);
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack newItem = event.getPlayer().getInventory().getItem(event.getNewSlot());
|
ItemStack newItem = event.getPlayer().getInventory().getItem(event.getNewSlot());
|
||||||
if (SimulatorUtils.isSimulatorItem(newItem)) {
|
if (SimulatorUtils.isSimulatorItem(newItem)) {
|
||||||
Simulator simulator = SimulatorStorage.getSimulator(newItem);
|
Simulator simulator = SimulatorStorage.getSimulator(newItem);
|
||||||
@@ -66,15 +59,22 @@ public class SimulatorCursorManager implements Listener {
|
|||||||
* simulator is null.
|
* simulator is null.
|
||||||
*/
|
*/
|
||||||
public void showCursor(Player player, Simulator simulator) {
|
public void showCursor(Player player, Simulator simulator) {
|
||||||
var cursorsBySimulator = activeCursorsByPlayerBySimulator.computeIfAbsent(player, __ -> new HashMap<>());
|
var currentActiveCursor = activeCursorByPlayer.get(player);
|
||||||
|
if (currentActiveCursor != null) {
|
||||||
|
currentActiveCursor.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
var cursorMode = currentActiveCursor != null ? currentActiveCursor.getCursorMode() : SimulatorCursorMode.TNT;
|
||||||
|
|
||||||
|
var cursorsBySimulator = openCursorsByPlayerBySimulator.computeIfAbsent(player, __ -> new HashMap<>());
|
||||||
var cursor = cursorsBySimulator.get(simulator);
|
var cursor = cursorsBySimulator.get(simulator);
|
||||||
if (cursor == null) {
|
if (cursor == null) {
|
||||||
if (simulator == null) {
|
if (simulator == null) {
|
||||||
Cursor emptyCursor = new EmptySimulatorCursor(player);
|
ASimulatorCursor emptyCursor = new EmptySimulatorCursor(player, cursorMode);
|
||||||
cursorsBySimulator.put(simulator, emptyCursor);
|
cursorsBySimulator.put(simulator, emptyCursor);
|
||||||
cursor = emptyCursor;
|
cursor = emptyCursor;
|
||||||
} else {
|
} else {
|
||||||
Cursor newCursor = new SimulatorCursor(simulator, player, SimulatorCursorMode.TNT);
|
ASimulatorCursor newCursor = new SimulatorCursor(simulator, player, cursorMode);
|
||||||
cursorsBySimulator.put(simulator, newCursor);
|
cursorsBySimulator.put(simulator, newCursor);
|
||||||
cursor = newCursor;
|
cursor = newCursor;
|
||||||
}
|
}
|
||||||
@@ -83,16 +83,19 @@ public class SimulatorCursorManager implements Listener {
|
|||||||
cursor.show();
|
cursor.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideCursor(Player player, Simulator simulator) {
|
public Optional<SimulatorCursorMode> getActiveCursorMode(Player player) {
|
||||||
var cursorsBySimulator = activeCursorsByPlayerBySimulator.get(player);
|
var currentActiveCursor = activeCursorByPlayer.get(player);
|
||||||
if (cursorsBySimulator == null) {
|
if (currentActiveCursor != null) {
|
||||||
return;
|
return Optional.of(currentActiveCursor.getCursorMode());
|
||||||
}
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
var cursor = cursorsBySimulator.remove(simulator);
|
|
||||||
if (cursor != null) {
|
|
||||||
cursor.hide();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setActiveCursorMode(Player player, SimulatorCursorMode mode) {
|
||||||
|
var currentActiveCursor = activeCursorByPlayer.get(player);
|
||||||
|
if (currentActiveCursor != null) {
|
||||||
|
currentActiveCursor.setCursorMode(mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+54
@@ -0,0 +1,54 @@
|
|||||||
|
package de.steamwar.bausystem.features.simulator.display;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||||
|
import de.steamwar.bausystem.utils.cursor.Cursor;
|
||||||
|
import de.steamwar.entity.REntityServer;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
public abstract class ASimulatorCursor extends Cursor implements Listener {
|
||||||
|
protected final Player owner;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
protected SimulatorCursorMode cursorMode;
|
||||||
|
|
||||||
|
protected ASimulatorCursor(Player owner, REntityServer targetServer, SimulatorCursorMode cursorMode) {
|
||||||
|
super(targetServer, owner, Material.GLASS, Material.TNT, List.of(Cursor.CursorMode.FREE, Cursor.CursorMode.BLOCK_ALIGNED));
|
||||||
|
this.cursorMode = cursorMode;
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapCursorMode() {
|
||||||
|
cursorMode = cursorMode.switchType();
|
||||||
|
setCursorMaterial(cursorMode.getMaterial());
|
||||||
|
setAllowedCursorModes(cursorMode.getAllowedCursorModes());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCursorMode(SimulatorCursorMode mode) {
|
||||||
|
this.cursorMode = mode;
|
||||||
|
setCursorMaterial(cursorMode.getMaterial());
|
||||||
|
setAllowedCursorModes(cursorMode.getAllowedCursorModes());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hide() {
|
||||||
|
super.hide();
|
||||||
|
super.getTargetServer().removePlayer(owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show() {
|
||||||
|
super.show();
|
||||||
|
super.getTargetServer().addPlayer(owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerShift(PlayerToggleSneakEvent event) {
|
||||||
|
if (event.getPlayer() != owner) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
swapCursorMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-39
@@ -1,56 +1,20 @@
|
|||||||
package de.steamwar.bausystem.features.simulator.display;
|
package de.steamwar.bausystem.features.simulator.display;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
||||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||||
import de.steamwar.bausystem.utils.cursor.Cursor;
|
|
||||||
import de.steamwar.entity.REntityServer;
|
import de.steamwar.entity.REntityServer;
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
|
|
||||||
public class EmptySimulatorCursor extends Cursor implements Listener {
|
public class EmptySimulatorCursor extends ASimulatorCursor {
|
||||||
private final Player owner;
|
public EmptySimulatorCursor(Player owner, SimulatorCursorMode cursorMode) {
|
||||||
|
super(owner, new REntityServer(), cursorMode);
|
||||||
private SimulatorCursorMode cursorMode;
|
|
||||||
|
|
||||||
public EmptySimulatorCursor(Player owner) {
|
|
||||||
super(new REntityServer(), owner, Material.GLASS, Material.TNT, List.of(Cursor.CursorMode.FREE, Cursor.CursorMode.BLOCK_ALIGNED));
|
|
||||||
this.cursorMode = SimulatorCursorMode.TNT;
|
|
||||||
this.owner = owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void swapCursorMode() {
|
|
||||||
cursorMode = cursorMode.switchType();
|
|
||||||
setCursorMaterial(cursorMode.getMaterial());
|
|
||||||
setAllowedCursorModes(cursorMode.getAllowedCursorModes());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hide() {
|
|
||||||
super.hide();
|
|
||||||
super.getTargetServer().removePlayer(owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void show() {
|
|
||||||
super.show();
|
|
||||||
super.getTargetServer().addPlayer(owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerShift(PlayerToggleSneakEvent event) {
|
|
||||||
if (event.getPlayer() != owner) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
swapCursorMode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+2
-34
@@ -3,11 +3,8 @@ package de.steamwar.bausystem.features.simulator.display;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||||
@@ -16,45 +13,16 @@ import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor;
|
|||||||
import de.steamwar.bausystem.features.simulator.gui.SimulatorGroupGui;
|
import de.steamwar.bausystem.features.simulator.gui.SimulatorGroupGui;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.SimulatorGui;
|
import de.steamwar.bausystem.features.simulator.gui.SimulatorGui;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
import de.steamwar.bausystem.utils.cursor.Cursor;
|
|
||||||
|
|
||||||
public class SimulatorCursor extends Cursor {
|
public class SimulatorCursor extends ASimulatorCursor {
|
||||||
private final Simulator simulator;
|
private final Simulator simulator;
|
||||||
private final Player owner;
|
|
||||||
|
|
||||||
private SimulatorCursorMode cursorMode;
|
|
||||||
|
|
||||||
public SimulatorCursor(Simulator simulator, Player owner, SimulatorCursorMode cursorMode) {
|
public SimulatorCursor(Simulator simulator, Player owner, SimulatorCursorMode cursorMode) {
|
||||||
super(SimulatorRenderer.renderSimulator(simulator), owner, Material.LIME_STAINED_GLASS_PANE, Material.RED_STAINED_GLASS_PANE,
|
super(owner, SimulatorRenderer.renderSimulator(simulator), cursorMode);
|
||||||
cursorMode.getAllowedCursorModes());
|
|
||||||
|
|
||||||
this.simulator = simulator;
|
this.simulator = simulator;
|
||||||
this.owner = owner;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void swapCursorMode() {
|
|
||||||
SimulatorCursorMode newMode = cursorMode.switchType();
|
|
||||||
setCursorMaterial(newMode.getMaterial());
|
|
||||||
setAllowedCursorModes(newMode.getAllowedCursorModes());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hide() {
|
|
||||||
super.hide();
|
|
||||||
super.getTargetServer().removePlayer(owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void show() {
|
|
||||||
super.show();
|
|
||||||
super.getTargetServer().addPlayer(owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerShift(PlayerToggleSneakEvent event) {
|
|
||||||
if (event.getPlayer() != owner) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
swapCursorMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(Optional<Location> clickedLocation, boolean clickedOnEntity, Action clickAction) {
|
public void onClick(Optional<Location> clickedLocation, boolean clickedOnEntity, Action clickAction) {
|
||||||
|
|||||||
+9
-7
@@ -18,14 +18,16 @@ import lombok.Getter;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
public enum SimulatorCursorMode {
|
public enum SimulatorCursorMode {
|
||||||
TNT(Material.TNT, "TNT", vector -> new TNTElement(vector).add(new TNTPhase()), List.of(CursorMode.FREE, CursorMode.BLOCK_ALIGNED)), REDSTONE_BLOCK(
|
TNT(Material.TNT, Material.GUNPOWDER, "TNT", vector -> new TNTElement(vector).add(new TNTPhase()),
|
||||||
Material.REDSTONE_BLOCK, "Redstone Block", vector -> new RedstoneElement(vector).add(new RedstonePhase()), List.of(CursorMode.BLOCK_ALIGNED)), OBSERVER(
|
List.of(CursorMode.FREE, CursorMode.BLOCK_ALIGNED)), REDSTONE_BLOCK(Material.REDSTONE_BLOCK, Material.REDSTONE_WIRE, "Redstone Block",
|
||||||
Material.OBSERVER, "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase()), List.of(CursorMode.BLOCK_ALIGNED));
|
vector -> new RedstoneElement(vector).add(new RedstonePhase()), List.of(CursorMode.BLOCK_ALIGNED)), OBSERVER(Material.OBSERVER, Material.QUARTZ,
|
||||||
|
"Observer", vector -> new ObserverElement(vector).add(new ObserverPhase()), List.of(CursorMode.BLOCK_ALIGNED)),;
|
||||||
|
|
||||||
private Material material;
|
public final Material material;
|
||||||
private String name;
|
public final Material nonSelectedMaterial;
|
||||||
private Function<Vector, SimulatorElement<?>> elementFunction;
|
public final String name;
|
||||||
private List<CursorMode> allowedCursorModes;
|
public final Function<Vector, SimulatorElement<?>> elementFunction;
|
||||||
|
public final List<CursorMode> allowedCursorModes;
|
||||||
|
|
||||||
public SimulatorCursorMode switchType() {
|
public SimulatorCursorMode switchType() {
|
||||||
if (this == TNT) {
|
if (this == TNT) {
|
||||||
|
|||||||
+18
-19
@@ -1,26 +1,26 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify it under the terms of the
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* of the License, or (at your option) any later version.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* Affero General Public License for more details.
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.bausystem.features.simulator.gui;
|
package de.steamwar.bausystem.features.simulator.gui;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.simulator.SimulatorCursor;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.features.simulator.SimulatorCursorManager;
|
||||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
import de.steamwar.bausystem.features.simulator.display.SimulatorCursorMode;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
import de.steamwar.data.CMDs;
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
@@ -30,6 +30,7 @@ import org.bukkit.entity.Player;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
public class SimulatorCursorSwitcherGui extends SimulatorBaseGui {
|
public class SimulatorCursorSwitcherGui extends SimulatorBaseGui {
|
||||||
|
private final SimulatorCursorManager cursorManager = BauSystem.getInstance().getLinker().get(SimulatorCursorManager.class).orElseThrow();
|
||||||
|
|
||||||
private SimulatorBaseGui back;
|
private SimulatorBaseGui back;
|
||||||
|
|
||||||
@@ -50,14 +51,12 @@ public class SimulatorCursorSwitcherGui extends SimulatorBaseGui {
|
|||||||
}).setCustomModelData(CMDs.BACK));
|
}).setCustomModelData(CMDs.BACK));
|
||||||
|
|
||||||
int slot = 2;
|
int slot = 2;
|
||||||
SimulatorCursor.CursorType currentType = SimulatorCursor.getCursorType(player);
|
SimulatorCursorMode currentType = cursorManager.getActiveCursorMode(player).orElse(SimulatorCursorMode.TNT);
|
||||||
for (SimulatorCursor.CursorType type : SimulatorCursor.CursorType.values()) {
|
for (SimulatorCursorMode type : SimulatorCursorMode.values()) {
|
||||||
boolean selected = type == currentType;
|
boolean selected = type == currentType;
|
||||||
SWItem swItem = new SWItem(selected ? type.material : type.nonSelectedMaterial, "§e" + type.name)
|
SWItem swItem = new SWItem(selected ? type.material : type.nonSelectedMaterial, "§e" + type.name)
|
||||||
.setCustomModelData(selected ? 0 : CMDs.Simulator.NEW_PHASE)
|
.setCustomModelData(selected ? 0 : CMDs.Simulator.NEW_PHASE).setLore(Collections.singletonList("§eClick to select")).setCallback(click -> {
|
||||||
.setLore(Collections.singletonList("§eClick to select"))
|
cursorManager.setActiveCursorMode(player, type);
|
||||||
.setCallback(click -> {
|
|
||||||
SimulatorCursor.setCursorType(player, type);
|
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
});
|
});
|
||||||
inventory.setItem(slot, swItem);
|
inventory.setItem(slot, swItem);
|
||||||
|
|||||||
+7
-1
@@ -17,9 +17,13 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.simulator.gui;
|
package de.steamwar.bausystem.features.simulator.gui;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.features.simulator.SimulatorCursorManager;
|
||||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||||
|
import de.steamwar.bausystem.features.simulator.display.SimulatorCursor;
|
||||||
|
import de.steamwar.bausystem.features.simulator.display.SimulatorCursorMode;
|
||||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||||
import de.steamwar.data.CMDs;
|
import de.steamwar.data.CMDs;
|
||||||
@@ -29,6 +33,8 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
|
public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
|
||||||
|
|
||||||
|
private final SimulatorCursorManager cursorManager = BauSystem.getInstance().getLinker().get(SimulatorCursorManager.class).orElseThrow();
|
||||||
|
|
||||||
public SimulatorGui(Player player, Simulator simulator) {
|
public SimulatorGui(Player player, Simulator simulator) {
|
||||||
super(player, simulator, 6 * 9, simulator.getGroups());
|
super(player, simulator, 6 * 9, simulator.getGroups());
|
||||||
}
|
}
|
||||||
@@ -48,7 +54,7 @@ public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
|
|||||||
inventory.setItem(4, simulator.toItem(player, clickType -> {
|
inventory.setItem(4, simulator.toItem(player, clickType -> {
|
||||||
new SimulatorMaterialGui(player, simulator, simulator::getMaterial, simulator::setMaterial, this).open();
|
new SimulatorMaterialGui(player, simulator, simulator::getMaterial, simulator::setMaterial, this).open();
|
||||||
}));
|
}));
|
||||||
SimulatorCursor.CursorType cursorType = SimulatorCursor.getCursorType(player);
|
SimulatorCursorMode cursorType = cursorManager.getActiveCursorMode(player).orElse(SimulatorCursorMode.TNT);
|
||||||
inventory.setItem(48, new SWItem(cursorType.material, "§7Placing §8-§e " + cursorType.name, clickType -> {
|
inventory.setItem(48, new SWItem(cursorType.material, "§7Placing §8-§e " + cursorType.name, clickType -> {
|
||||||
new SimulatorCursorSwitcherGui(player, simulator, this).open();
|
new SimulatorCursorSwitcherGui(player, simulator, this).open();
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify it under the terms of the
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* of the License, or (at your option) any later version.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* Affero General Public License for more details.
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.linkage;
|
package de.steamwar.linkage;
|
||||||
@@ -32,6 +30,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public abstract class AbstractLinker<T> {
|
public abstract class AbstractLinker<T> {
|
||||||
@@ -52,16 +51,13 @@ public abstract class AbstractLinker<T> {
|
|||||||
List<Class<?>> classes;
|
List<Class<?>> classes;
|
||||||
try {
|
try {
|
||||||
classes = new BufferedReader(new InputStreamReader(plugin.getClass().getResourceAsStream("/META-INF/annotations/de.steamwar.linkage.Linked")))
|
classes = new BufferedReader(new InputStreamReader(plugin.getClass().getResourceAsStream("/META-INF/annotations/de.steamwar.linkage.Linked")))
|
||||||
.lines()
|
.lines().map(s -> {
|
||||||
.map(s -> {
|
|
||||||
try {
|
try {
|
||||||
return Class.forName(s, false, plugin.getClass().getClassLoader());
|
return Class.forName(s, false, plugin.getClass().getClassLoader());
|
||||||
} catch (ClassNotFoundException | NoClassDefFoundError e) {
|
} catch (ClassNotFoundException | NoClassDefFoundError e) {
|
||||||
throw new SecurityException(e.getMessage(), e);
|
throw new SecurityException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
})
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
Throwable cause = e.getCause();
|
Throwable cause = e.getCause();
|
||||||
throw new LinkException(cause.getMessage(), cause);
|
throw new LinkException(cause.getMessage(), cause);
|
||||||
@@ -71,12 +67,15 @@ public abstract class AbstractLinker<T> {
|
|||||||
classes.forEach(clazz -> {
|
classes.forEach(clazz -> {
|
||||||
MinVersion minVersion = clazz.getAnnotation(MinVersion.class);
|
MinVersion minVersion = clazz.getAnnotation(MinVersion.class);
|
||||||
MaxVersion maxVersion = clazz.getAnnotation(MaxVersion.class);
|
MaxVersion maxVersion = clazz.getAnnotation(MaxVersion.class);
|
||||||
if (!versionCheck(clazz, minVersion, maxVersion)) return;
|
if (!versionCheck(clazz, minVersion, maxVersion))
|
||||||
|
return;
|
||||||
EventMode eventMode = clazz.getAnnotation(EventMode.class);
|
EventMode eventMode = clazz.getAnnotation(EventMode.class);
|
||||||
if (!eventModeCheck(clazz, eventMode)) return;
|
if (!eventModeCheck(clazz, eventMode))
|
||||||
|
return;
|
||||||
PluginCheck[] pluginChecks = clazz.getAnnotationsByType(PluginCheck.class);
|
PluginCheck[] pluginChecks = clazz.getAnnotationsByType(PluginCheck.class);
|
||||||
for (PluginCheck pluginCheck : pluginChecks) {
|
for (PluginCheck pluginCheck : pluginChecks) {
|
||||||
if (!pluginCheck(clazz, pluginCheck)) return;
|
if (!pluginCheck(clazz, pluginCheck))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object any;
|
Object any;
|
||||||
@@ -157,12 +156,14 @@ public abstract class AbstractLinker<T> {
|
|||||||
/**
|
/**
|
||||||
* There is no need in calling {@link Enable#enable()} by this method.
|
* There is no need in calling {@link Enable#enable()} by this method.
|
||||||
*/
|
*/
|
||||||
protected void linkObject(Object any) {
|
protected void linkObject(Object any) {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There is no need in calling {@link Disable#disable()} ()} by this method.
|
* There is no need in calling {@link Disable#disable()} ()} by this method.
|
||||||
*/
|
*/
|
||||||
protected void unlinkObject(Object any) {
|
protected void unlinkObject(Object any) {}
|
||||||
|
|
||||||
|
public final <L> Optional<L> get(Class<L> clazz) {
|
||||||
|
return Optional.ofNullable((L) instances.get(clazz));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user