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
|
||||
* 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 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.
|
||||
* 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/>.
|
||||
* 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;
|
||||
@@ -71,6 +69,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
@Getter
|
||||
private static BauSystem instance;
|
||||
|
||||
@Getter
|
||||
private SpigotLinker linker;
|
||||
|
||||
@Override
|
||||
@@ -183,7 +182,8 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (TickManager.impl.isFrozen()) return;
|
||||
if (TickManager.impl.isFrozen())
|
||||
return;
|
||||
if (counter >= delay) {
|
||||
runnable.run();
|
||||
cancel();
|
||||
@@ -201,7 +201,8 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (TickManager.impl.isFrozen()) return;
|
||||
if (TickManager.impl.isFrozen())
|
||||
return;
|
||||
if (counter >= (first ? delay : period)) {
|
||||
first = false;
|
||||
runnable.run();
|
||||
@@ -217,4 +218,4 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
AtomicReference<BukkitTask> task = new AtomicReference<>();
|
||||
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.display.ASimulatorCursor;
|
||||
import de.steamwar.bausystem.features.simulator.display.EmptySimulatorCursor;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorCursor;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorCursorMode;
|
||||
|
||||
import de.steamwar.bausystem.utils.cursor.Cursor;
|
||||
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
|
||||
@@ -42,18 +40,13 @@ import java.util.*;
|
||||
@Linked
|
||||
@MinVersion(19)
|
||||
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
|
||||
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());
|
||||
if (SimulatorUtils.isSimulatorItem(newItem)) {
|
||||
Simulator simulator = SimulatorStorage.getSimulator(newItem);
|
||||
@@ -66,15 +59,22 @@ public class SimulatorCursorManager implements Listener {
|
||||
* simulator is null.
|
||||
*/
|
||||
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);
|
||||
if (cursor == null) {
|
||||
if (simulator == null) {
|
||||
Cursor emptyCursor = new EmptySimulatorCursor(player);
|
||||
ASimulatorCursor emptyCursor = new EmptySimulatorCursor(player, cursorMode);
|
||||
cursorsBySimulator.put(simulator, emptyCursor);
|
||||
cursor = emptyCursor;
|
||||
} else {
|
||||
Cursor newCursor = new SimulatorCursor(simulator, player, SimulatorCursorMode.TNT);
|
||||
ASimulatorCursor newCursor = new SimulatorCursor(simulator, player, cursorMode);
|
||||
cursorsBySimulator.put(simulator, newCursor);
|
||||
cursor = newCursor;
|
||||
}
|
||||
@@ -83,16 +83,19 @@ public class SimulatorCursorManager implements Listener {
|
||||
cursor.show();
|
||||
}
|
||||
|
||||
public void hideCursor(Player player, Simulator simulator) {
|
||||
var cursorsBySimulator = activeCursorsByPlayerBySimulator.get(player);
|
||||
if (cursorsBySimulator == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var cursor = cursorsBySimulator.remove(simulator);
|
||||
if (cursor != null) {
|
||||
cursor.hide();
|
||||
public Optional<SimulatorCursorMode> getActiveCursorMode(Player player) {
|
||||
var currentActiveCursor = activeCursorByPlayer.get(player);
|
||||
if (currentActiveCursor != null) {
|
||||
return Optional.of(currentActiveCursor.getCursorMode());
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
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.player.PlayerToggleSneakEvent;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.utils.cursor.Cursor;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
|
||||
public class EmptySimulatorCursor extends Cursor implements Listener {
|
||||
private final Player owner;
|
||||
|
||||
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();
|
||||
public class EmptySimulatorCursor extends ASimulatorCursor {
|
||||
public EmptySimulatorCursor(Player owner, SimulatorCursorMode cursorMode) {
|
||||
super(owner, new REntityServer(), cursorMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-34
@@ -3,11 +3,8 @@ package de.steamwar.bausystem.features.simulator.display;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
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.SimulatorGui;
|
||||
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 Player owner;
|
||||
|
||||
private 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,
|
||||
cursorMode.getAllowedCursorModes());
|
||||
super(owner, SimulatorRenderer.renderSimulator(simulator), cursorMode);
|
||||
|
||||
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
|
||||
public void onClick(Optional<Location> clickedLocation, boolean clickedOnEntity, Action clickAction) {
|
||||
|
||||
+9
-7
@@ -18,14 +18,16 @@ import lombok.Getter;
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum SimulatorCursorMode {
|
||||
TNT(Material.TNT, "TNT", vector -> new TNTElement(vector).add(new TNTPhase()), List.of(CursorMode.FREE, CursorMode.BLOCK_ALIGNED)), REDSTONE_BLOCK(
|
||||
Material.REDSTONE_BLOCK, "Redstone Block", vector -> new RedstoneElement(vector).add(new RedstonePhase()), List.of(CursorMode.BLOCK_ALIGNED)), OBSERVER(
|
||||
Material.OBSERVER, "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase()), List.of(CursorMode.BLOCK_ALIGNED));
|
||||
TNT(Material.TNT, Material.GUNPOWDER, "TNT", vector -> new TNTElement(vector).add(new TNTPhase()),
|
||||
List.of(CursorMode.FREE, CursorMode.BLOCK_ALIGNED)), REDSTONE_BLOCK(Material.REDSTONE_BLOCK, Material.REDSTONE_WIRE, "Redstone Block",
|
||||
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;
|
||||
private String name;
|
||||
private Function<Vector, SimulatorElement<?>> elementFunction;
|
||||
private List<CursorMode> allowedCursorModes;
|
||||
public final Material material;
|
||||
public final Material nonSelectedMaterial;
|
||||
public final String name;
|
||||
public final Function<Vector, SimulatorElement<?>> elementFunction;
|
||||
public final List<CursorMode> allowedCursorModes;
|
||||
|
||||
public SimulatorCursorMode switchType() {
|
||||
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
|
||||
* 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 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.
|
||||
* 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/>.
|
||||
* 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.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.display.SimulatorCursorMode;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@@ -30,6 +30,7 @@ import org.bukkit.entity.Player;
|
||||
import java.util.Collections;
|
||||
|
||||
public class SimulatorCursorSwitcherGui extends SimulatorBaseGui {
|
||||
private final SimulatorCursorManager cursorManager = BauSystem.getInstance().getLinker().get(SimulatorCursorManager.class).orElseThrow();
|
||||
|
||||
private SimulatorBaseGui back;
|
||||
|
||||
@@ -50,14 +51,12 @@ public class SimulatorCursorSwitcherGui extends SimulatorBaseGui {
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
int slot = 2;
|
||||
SimulatorCursor.CursorType currentType = SimulatorCursor.getCursorType(player);
|
||||
for (SimulatorCursor.CursorType type : SimulatorCursor.CursorType.values()) {
|
||||
SimulatorCursorMode currentType = cursorManager.getActiveCursorMode(player).orElse(SimulatorCursorMode.TNT);
|
||||
for (SimulatorCursorMode type : SimulatorCursorMode.values()) {
|
||||
boolean selected = type == currentType;
|
||||
SWItem swItem = new SWItem(selected ? type.material : type.nonSelectedMaterial, "§e" + type.name)
|
||||
.setCustomModelData(selected ? 0 : CMDs.Simulator.NEW_PHASE)
|
||||
.setLore(Collections.singletonList("§eClick to select"))
|
||||
.setCallback(click -> {
|
||||
SimulatorCursor.setCursorType(player, type);
|
||||
.setCustomModelData(selected ? 0 : CMDs.Simulator.NEW_PHASE).setLore(Collections.singletonList("§eClick to select")).setCallback(click -> {
|
||||
cursorManager.setActiveCursorMode(player, type);
|
||||
player.closeInventory();
|
||||
});
|
||||
inventory.setItem(slot, swItem);
|
||||
|
||||
+7
-1
@@ -17,9 +17,13 @@
|
||||
|
||||
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.SimulatorElement;
|
||||
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.gui.base.SimulatorPageGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
@@ -29,6 +33,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
|
||||
|
||||
private final SimulatorCursorManager cursorManager = BauSystem.getInstance().getLinker().get(SimulatorCursorManager.class).orElseThrow();
|
||||
|
||||
public SimulatorGui(Player player, Simulator simulator) {
|
||||
super(player, simulator, 6 * 9, simulator.getGroups());
|
||||
}
|
||||
@@ -48,7 +54,7 @@ public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
|
||||
inventory.setItem(4, simulator.toItem(player, clickType -> {
|
||||
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 -> {
|
||||
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
|
||||
* 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 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.
|
||||
* 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/>.
|
||||
* 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.linkage;
|
||||
@@ -32,6 +30,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class AbstractLinker<T> {
|
||||
@@ -52,16 +51,13 @@ public abstract class AbstractLinker<T> {
|
||||
List<Class<?>> classes;
|
||||
try {
|
||||
classes = new BufferedReader(new InputStreamReader(plugin.getClass().getResourceAsStream("/META-INF/annotations/de.steamwar.linkage.Linked")))
|
||||
.lines()
|
||||
.map(s -> {
|
||||
.lines().map(s -> {
|
||||
try {
|
||||
return Class.forName(s, false, plugin.getClass().getClassLoader());
|
||||
} catch (ClassNotFoundException | NoClassDefFoundError e) {
|
||||
throw new SecurityException(e.getMessage(), e);
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
} catch (SecurityException e) {
|
||||
Throwable cause = e.getCause();
|
||||
throw new LinkException(cause.getMessage(), cause);
|
||||
@@ -71,12 +67,15 @@ public abstract class AbstractLinker<T> {
|
||||
classes.forEach(clazz -> {
|
||||
MinVersion minVersion = clazz.getAnnotation(MinVersion.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);
|
||||
if (!eventModeCheck(clazz, eventMode)) return;
|
||||
if (!eventModeCheck(clazz, eventMode))
|
||||
return;
|
||||
PluginCheck[] pluginChecks = clazz.getAnnotationsByType(PluginCheck.class);
|
||||
for (PluginCheck pluginCheck : pluginChecks) {
|
||||
if (!pluginCheck(clazz, pluginCheck)) return;
|
||||
if (!pluginCheck(clazz, pluginCheck))
|
||||
return;
|
||||
}
|
||||
|
||||
Object any;
|
||||
@@ -157,12 +156,14 @@ public abstract class AbstractLinker<T> {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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