forked from SteamWar/SteamWar
Improve SimulatorCursor selection changing
This commit is contained in:
+25
-16
@@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.simulator;
|
package de.steamwar.bausystem.features.simulator;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
|
import de.steamwar.Reflection;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
@@ -40,10 +40,13 @@ import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
|||||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||||
import de.steamwar.bausystem.utils.ItemUtils;
|
import de.steamwar.bausystem.utils.ItemUtils;
|
||||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.entity.REntity;
|
import de.steamwar.entity.REntity;
|
||||||
import de.steamwar.entity.REntityServer;
|
import de.steamwar.entity.REntityServer;
|
||||||
import de.steamwar.entity.RFallingBlockEntity;
|
import de.steamwar.entity.RFallingBlockEntity;
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
|
import de.steamwar.inventory.SWInventory;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.MinVersion;
|
import de.steamwar.linkage.MinVersion;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -147,8 +150,23 @@ public class SimulatorCursor implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (LAST_SNEAKS.containsKey(player)) {
|
if (LAST_SNEAKS.containsKey(player)) {
|
||||||
cursorType.put(player, cursorType.getOrDefault(player, CursorType.TNT).switchType());
|
SWInventory swInventory = new SWInventory(player, 9, "Simulator Cursor");
|
||||||
calcCursor(player);
|
int slot = 2;
|
||||||
|
CursorType currentType = cursorType.getOrDefault(player, CursorType.TNT);
|
||||||
|
for (CursorType type : CursorType.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 -> {
|
||||||
|
cursorType.put(player, type);
|
||||||
|
calcCursor(player);
|
||||||
|
player.closeInventory();
|
||||||
|
});
|
||||||
|
swInventory.setItem(slot, swItem);
|
||||||
|
slot += 2;
|
||||||
|
}
|
||||||
|
swInventory.open();
|
||||||
} else {
|
} else {
|
||||||
LAST_SNEAKS.put(player, System.currentTimeMillis());
|
LAST_SNEAKS.put(player, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
@@ -331,25 +349,16 @@ public class SimulatorCursor implements Listener {
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum CursorType {
|
public enum CursorType {
|
||||||
TNT(Material.TNT, SimulatorCursor::getPosFree, "TNT", vector -> new TNTElement(vector).add(new TNTPhase())),
|
TNT(Material.TNT, Material.GUNPOWDER, SimulatorCursor::getPosFree, "TNT", vector -> new TNTElement(vector).add(new TNTPhase())),
|
||||||
REDSTONE_BLOCK(Material.REDSTONE_BLOCK, SimulatorCursor::getPosBlockAligned, "Redstone Block", vector -> new RedstoneElement(vector).add(new RedstonePhase())),
|
REDSTONE_BLOCK(Material.REDSTONE_BLOCK, Material.REDSTONE, SimulatorCursor::getPosBlockAligned, "Redstone Block", vector -> new RedstoneElement(vector).add(new RedstonePhase())),
|
||||||
OBSERVER(Material.OBSERVER, SimulatorCursor::getPosBlockAligned, "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase())),
|
OBSERVER(Material.OBSERVER, Material.QUARTZ, SimulatorCursor::getPosBlockAligned, "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase())),
|
||||||
;
|
;
|
||||||
|
|
||||||
private Material material;
|
private Material material;
|
||||||
|
private Material nonSelectedMaterial;
|
||||||
private BiFunction<Player, RayTraceUtils.RRayTraceResult, Vector> position;
|
private BiFunction<Player, RayTraceUtils.RRayTraceResult, Vector> position;
|
||||||
private String name;
|
private String name;
|
||||||
private Function<Vector, SimulatorElement<?>> elementFunction;
|
private Function<Vector, SimulatorElement<?>> elementFunction;
|
||||||
|
|
||||||
public CursorType switchType() {
|
|
||||||
if (this == TNT) {
|
|
||||||
return REDSTONE_BLOCK;
|
|
||||||
}
|
|
||||||
if (this == REDSTONE_BLOCK) {
|
|
||||||
return OBSERVER;
|
|
||||||
}
|
|
||||||
return TNT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|||||||
Reference in New Issue
Block a user