Merge branch 'main' into exposed

This commit is contained in:
2025-11-10 08:40:42 +01:00
24 changed files with 209 additions and 67 deletions
@@ -32,10 +32,14 @@ public class FlatteningWrapper21 extends FlatteningWrapper14 implements Flatteni
public ItemStack setSkullOwner(String player) {
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
head.editMeta(SkullMeta.class, skullMeta -> {
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player.startsWith(".") ? player.substring(1) : player);
PlayerProfile playerProfile = offlinePlayer.getPlayerProfile();
if (!playerProfile.isComplete()) playerProfile.complete();
skullMeta.setPlayerProfile(playerProfile);
try {
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player.startsWith(".") ? player.substring(1) : player);
PlayerProfile playerProfile = offlinePlayer.getPlayerProfile();
playerProfile.complete();
skullMeta.setPlayerProfile(playerProfile);
} catch (Exception e) {
// Ignore
}
});
return head;
}
@@ -24,18 +24,36 @@ import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.sql.UserConfig;
import lombok.AllArgsConstructor;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.data.type.Light;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.meta.BlockDataMeta;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.*;
public class WorldEditRendererCUIEditor implements Listener {
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
for (Type type : Type.values()) {
type.materialCache.remove(event.getPlayer());
type.widthCache.remove(event.getPlayer());
}
}
@EventHandler
public void onCRIUSleep(CRIUSleepEvent event) {
for (Type type : Type.values()) {
type.materialCache.clear();
type.widthCache.clear();
}
}
public class WorldEditRendererCUIEditor {
@AllArgsConstructor
public enum Type {
@@ -43,34 +61,43 @@ public class WorldEditRendererCUIEditor {
CLIPBOARD("cui_clipboard_material", "cui_clipboard_width", Material.LIME_CONCRETE, Width.SLIM),
;
private final Map<Player, Material> materialCache = new HashMap<>();
private final Map<Player, Width> widthCache = new HashMap<>();
private final String configMaterial;
private final String configWidth;
private final Material defaultMaterial;
private final Width defaultWidth;
public Material getMaterial(Player player) {
String material = UserConfig.getConfig(player.getUniqueId(), configMaterial);
if (material == null) {
return defaultMaterial;
} else {
return Material.valueOf(material);
}
return materialCache.computeIfAbsent(player, p -> {
String material = UserConfig.getConfig(p.getUniqueId(), configMaterial);
if (material == null) {
return defaultMaterial;
} else {
return Material.valueOf(material);
}
});
}
public void setMaterial(Player player, Material material) {
materialCache.put(player, material);
UserConfig.updatePlayerConfig(player.getUniqueId(), configMaterial, material.name());
}
public Width getWidth(Player player) {
String width = UserConfig.getConfig(player.getUniqueId(), configWidth);
if (width == null) {
return defaultWidth;
} else {
return Width.valueOf(width);
}
return widthCache.computeIfAbsent(player, p -> {
String width = UserConfig.getConfig(p.getUniqueId(), configWidth);
if (width == null) {
return defaultWidth;
} else {
return Width.valueOf(width);
}
});
}
public void setWidth(Player player, Width width) {
widthCache.put(player, width);
UserConfig.updatePlayerConfig(player.getUniqueId(), configWidth, width.name());
}
}
@@ -88,6 +115,7 @@ public class WorldEditRendererCUIEditor {
}
public WorldEditRendererCUIEditor() {
Bukkit.getPluginManager().registerEvents(this, Core.getInstance());
if (Core.getVersion() >= 20) {
new Command();
}
@@ -63,7 +63,9 @@ public class CLine extends CEntity {
if (Objects.equals(from, this.from) && Objects.equals(to, this.to)) return this;
this.from = from;
this.to = to;
hide(true);
tick();
hide(false);
return this;
}
@@ -82,7 +82,7 @@ public class CWireframe extends CEntity {
private void updateAndSpawnLines() {
List<CLine> lines = getEntitiesByType(CLine.class);
if (pos1 == null || pos2 == null) {
lines.forEach(line -> line.setFrom(null).setTo(null));
lines.forEach(line -> line.setFromAndTo(null, null));
return;
}