forked from SteamWar/SteamWar
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09d2ed5384
|
||
|
|
b576c36c2d
|
||
|
|
a089d42d9a
|
||
|
|
0a7a753c48
|
||
|
|
86bfde90b8
|
||
|
|
7c5a927d0f
|
+1
-1
@@ -59,7 +59,7 @@ public class BackupCommand extends SWCommand {
|
|||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (region.getRegionData().get(Flag.CHANGED).isWithDefault(ChangedMode.NO_CHANGE)) {
|
if (region.getFlags().get(Flag.CHANGED).isWithDefault(ChangedMode.NO_CHANGE)) {
|
||||||
BauSystem.MESSAGE.send("BACKUP_CREATE_NO_CHANGE", p);
|
BauSystem.MESSAGE.send("BACKUP_CREATE_NO_CHANGE", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -56,8 +56,8 @@ public class BauInfoBauGuiItem extends BauGuiItem {
|
|||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
List<String> stringList = new ArrayList<>();
|
List<String> stringList = new ArrayList<>();
|
||||||
for (Flag flag : Flag.getFlags()) {
|
for (Flag flag : Flag.getFlags()) {
|
||||||
if (!region.getRegionData().has(flag).isApplicable()) continue;
|
if (!region.getFlags().has(flag).isApplicable()) continue;
|
||||||
FlagOptional<?> value = region.getRegionData().get(flag);
|
FlagOptional<?> value = region.getFlags().get(flag);
|
||||||
if (value.isPresent()) {
|
if (value.isPresent()) {
|
||||||
stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), player)));
|
stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), player)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ public class InfoCommand extends SWCommand {
|
|||||||
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_OWNER", p, SteamwarUser.byId(bauServer.getOwnerID()).getUserName());
|
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_OWNER", p, SteamwarUser.byId(bauServer.getOwnerID()).getUserName());
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
for (Flag flag : Flag.getFlags()) {
|
for (Flag flag : Flag.getFlags()) {
|
||||||
if (!region.getRegionData().has(flag).isApplicable()) continue;
|
if (!region.getFlags().has(flag).isApplicable()) continue;
|
||||||
FlagOptional<?> value = region.getRegionData().get(flag);
|
FlagOptional<?> value = region.getFlags().get(flag);
|
||||||
if (value.isPresent()) {
|
if (value.isPresent()) {
|
||||||
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_FLAG", p, BauSystem.MESSAGE.parse(flag.getChatValue(), p), BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), p));
|
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_FLAG", p, BauSystem.MESSAGE.parse(flag.getChatValue(), p), BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), p));
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -51,17 +51,17 @@ public class ColorCommand extends SWCommand {
|
|||||||
public void genericColorSet(@Validator Player p, ColorMode color, ColorizationType colorizationType) {
|
public void genericColorSet(@Validator Player p, ColorMode color, ColorizationType colorizationType) {
|
||||||
if (colorizationType == ColorizationType.GLOBAL) {
|
if (colorizationType == ColorizationType.GLOBAL) {
|
||||||
Region.getRegions().forEach(region -> {
|
Region.getRegions().forEach(region -> {
|
||||||
region.getRegionData().set(Flag.COLOR, color);
|
region.getFlags().set(Flag.COLOR, color);
|
||||||
});
|
});
|
||||||
BauSystem.MESSAGE.send("REGION_COLOR_GLOBAL", p, BauSystem.MESSAGE.parse(color.getChatValue(), p));
|
BauSystem.MESSAGE.send("REGION_COLOR_GLOBAL", p, BauSystem.MESSAGE.parse(color.getChatValue(), p));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (!region.getRegionData().has(Flag.COLOR).isWritable()) {
|
if (!region.getFlags().has(Flag.COLOR).isWritable()) {
|
||||||
BauSystem.MESSAGE.send("REGION_COLOR_NO_REGION", p);
|
BauSystem.MESSAGE.send("REGION_COLOR_NO_REGION", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
region.getRegionData().set(Flag.COLOR, color);
|
region.getFlags().set(Flag.COLOR, color);
|
||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
||||||
.ignoreAir(true)
|
.ignoreAir(true)
|
||||||
|
|||||||
@@ -53,11 +53,11 @@ public class FireCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean toggle(Region region) {
|
private boolean toggle(Region region) {
|
||||||
if (region.getRegionData().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
|
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
|
||||||
region.getRegionData().set(Flag.FIRE, FireMode.DENY);
|
region.getFlags().set(Flag.FIRE, FireMode.DENY);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
region.getRegionData().set(Flag.FIRE, FireMode.ALLOW);
|
region.getFlags().set(Flag.FIRE, FireMode.ALLOW);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -36,12 +36,12 @@ public class FireListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFireDamage(BlockBurnEvent e) {
|
public void onFireDamage(BlockBurnEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFireSpread(BlockSpreadEvent e) {
|
public void onFireSpread(BlockSpreadEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -56,7 +56,7 @@ public class FireListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.getRegionData().get(Flag.FIRE).isWithDefault(FireMode.DENY)) return null;
|
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.FIRE).getWithDefault().getChatValue(), p);
|
return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.FIRE).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -53,11 +53,11 @@ public class FreezeCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean toggle(Region region) {
|
private boolean toggle(Region region) {
|
||||||
if (region.getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
region.getRegionData().set(Flag.FREEZE, FreezeMode.INACTIVE);
|
region.getFlags().set(Flag.FREEZE, FreezeMode.INACTIVE);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
region.getRegionData().set(Flag.FREEZE, FreezeMode.ACTIVE);
|
region.getFlags().set(Flag.FREEZE, FreezeMode.ACTIVE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-21
@@ -48,7 +48,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntitySpawn(EntitySpawnEvent e) {
|
public void onEntitySpawn(EntitySpawnEvent e) {
|
||||||
if (Region.getRegion(e.getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
|
if (Region.getRegion(e.getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
|
if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
@@ -60,7 +60,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
||||||
if (!e.isBuildable()) return;
|
if (!e.isBuildable()) return;
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
|
||||||
if (e.getMaterial() == Material.TNT) {
|
if (e.getMaterial() == Material.TNT) {
|
||||||
e.setBuildable(false);
|
e.setBuildable(false);
|
||||||
e.getBlock().setType(Material.TNT, false);
|
e.getBlock().setType(Material.TNT, false);
|
||||||
@@ -69,14 +69,14 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPhysicsEvent(BlockPhysicsEvent e) {
|
public void onPhysicsEvent(BlockPhysicsEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
if (e.getSourceBlock().getType() == Material.NOTE_BLOCK) {
|
if (e.getSourceBlock().getType() == Material.NOTE_BLOCK) {
|
||||||
BlockState state = e.getSourceBlock().getState();
|
BlockState state = e.getSourceBlock().getState();
|
||||||
NoteBlock noteBlock = (NoteBlock) state.getBlockData();
|
NoteBlock noteBlock = (NoteBlock) state.getBlockData();
|
||||||
@@ -101,44 +101,44 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPistonExtend(BlockPistonExtendEvent e) {
|
public void onPistonExtend(BlockPistonExtendEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPistonRetract(BlockPistonRetractEvent e) {
|
public void onPistonRetract(BlockPistonRetractEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockGrow(BlockGrowEvent e) {
|
public void onBlockGrow(BlockGrowEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onRedstoneEvent(BlockRedstoneEvent e) {
|
public void onRedstoneEvent(BlockRedstoneEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setNewCurrent(e.getOldCurrent());
|
e.setNewCurrent(e.getOldCurrent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockDispense(BlockDispenseEvent e) {
|
public void onBlockDispense(BlockDispenseEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryMoveEvent(InventoryMoveItemEvent e) {
|
public void onInventoryMoveEvent(InventoryMoveItemEvent e) {
|
||||||
if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
} else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
} else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
public void onBlockBreak(BlockBreakEvent e) {
|
public void onBlockBreak(BlockBreakEvent e) {
|
||||||
if (Core.getVersion() < 19) return;
|
if (Core.getVersion() < 19) return;
|
||||||
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
|
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
e.getBlock().setType(Material.BARRIER, false);
|
e.getBlock().setType(Material.BARRIER, false);
|
||||||
e.getBlock().setType(Material.AIR, false);
|
e.getBlock().setType(Material.AIR, false);
|
||||||
@@ -170,35 +170,35 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFluidLevelChange(FluidLevelChangeEvent e) {
|
public void onFluidLevelChange(FluidLevelChangeEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockSpread(BlockSpreadEvent e) {
|
public void onBlockSpread(BlockSpreadEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockFromTo(BlockFromToEvent e) {
|
public void onBlockFromTo(BlockFromToEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onSpongeAbsorb(SpongeAbsorbEvent e) {
|
public void onSpongeAbsorb(SpongeAbsorbEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockForm(BlockFormEvent e) {
|
public void onBlockForm(BlockFormEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,7 +206,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent e) {
|
public void onPlayerInteract(PlayerInteractEvent e) {
|
||||||
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||||
if (Region.getRegion(e.getClickedBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getClickedBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
Block block = e.getClickedBlock();
|
Block block = e.getClickedBlock();
|
||||||
if (block.getType() == Material.LEVER) {
|
if (block.getType() == Material.LEVER) {
|
||||||
Switch data = ((Switch) block.getBlockData());
|
Switch data = ((Switch) block.getBlockData());
|
||||||
@@ -218,7 +218,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockFade(BlockFadeEvent e) {
|
public void onBlockFade(BlockFadeEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,7 +235,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return null;
|
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.FREEZE).getWithDefault().getChatValue(), p);
|
return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.FREEZE).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -55,11 +55,11 @@ public class ItemsCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean toggle(Region region) {
|
private boolean toggle(Region region) {
|
||||||
if (region.getRegionData().get(Flag.ITEMS).isWithDefault(ItemMode.ACTIVE)) {
|
if (region.getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.ACTIVE)) {
|
||||||
region.getRegionData().set(Flag.ITEMS, ItemMode.INACTIVE);
|
region.getFlags().set(Flag.ITEMS, ItemMode.INACTIVE);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
region.getRegionData().set(Flag.ITEMS, ItemMode.ACTIVE);
|
region.getFlags().set(Flag.ITEMS, ItemMode.ACTIVE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -37,7 +37,7 @@ public class ItemsListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onItemSpawn(ItemSpawnEvent event) {
|
public void onItemSpawn(ItemSpawnEvent event) {
|
||||||
if (Region.getRegion(event.getLocation()).getRegionData().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) {
|
if (Region.getRegion(event.getLocation()).getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ public class ItemsListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.getRegionData().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) return null;
|
if (region.getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.ITEMS).getWithDefault().getChatValue(), p);
|
return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.ITEMS).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -53,11 +53,11 @@ public class NoGravityCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean toggle(Region region) {
|
private boolean toggle(Region region) {
|
||||||
if (region.getRegionData().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) {
|
if (region.getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) {
|
||||||
region.getRegionData().set(Flag.NO_GRAVITY, NoGravityMode.INACTIVE);
|
region.getFlags().set(Flag.NO_GRAVITY, NoGravityMode.INACTIVE);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
region.getRegionData().set(Flag.NO_GRAVITY, NoGravityMode.ACTIVE);
|
region.getFlags().set(Flag.NO_GRAVITY, NoGravityMode.ACTIVE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -37,7 +37,7 @@ public class NoGravityListener implements Listener, ScoreboardElement {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
public void onEntitySpawn(EntitySpawnEvent event) {
|
||||||
if (event.getEntityType() == EntityType.PLAYER) return;
|
if (event.getEntityType() == EntityType.PLAYER) return;
|
||||||
if (Region.getRegion(event.getLocation()).getRegionData().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) {
|
if (Region.getRegion(event.getLocation()).getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) {
|
||||||
event.getEntity().setGravity(false);
|
event.getEntity().setGravity(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ public class NoGravityListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.getRegionData().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.INACTIVE)) return null;
|
if (region.getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.INACTIVE)) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.NO_GRAVITY).getWithDefault().getChatValue(), p);
|
return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.NO_GRAVITY).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -39,18 +39,18 @@ public class ProtectCommand extends SWCommand {
|
|||||||
public void genericProtectCommand(@Validator Player p) {
|
public void genericProtectCommand(@Validator Player p) {
|
||||||
Region region = regionCheck(p);
|
Region region = regionCheck(p);
|
||||||
if (region == null) return;
|
if (region == null) return;
|
||||||
if (region.getRegionData().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
|
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
|
||||||
region.getRegionData().set(Flag.PROTECT, ProtectMode.INACTIVE);
|
region.getFlags().set(Flag.PROTECT, ProtectMode.INACTIVE);
|
||||||
RegionUtils.actionBar(region, "REGION_PROTECT_DISABLE");
|
RegionUtils.actionBar(region, "REGION_PROTECT_DISABLE");
|
||||||
} else {
|
} else {
|
||||||
region.getRegionData().set(Flag.PROTECT, ProtectMode.ACTIVE);
|
region.getFlags().set(Flag.PROTECT, ProtectMode.ACTIVE);
|
||||||
RegionUtils.actionBar(region, "REGION_PROTECT_ENABLE");
|
RegionUtils.actionBar(region, "REGION_PROTECT_ENABLE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Region regionCheck(Player player) {
|
private Region regionCheck(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (!region.getRegionData().has(Flag.PROTECT).isApplicable()) {
|
if (!region.getFlags().has(Flag.PROTECT).isApplicable()) {
|
||||||
BauSystem.MESSAGE.send("REGION_PROTECT_FALSE_REGION", player);
|
BauSystem.MESSAGE.send("REGION_PROTECT_FALSE_REGION", player);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -41,7 +41,7 @@ public class ProtectListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
private void explode(List<Block> blockList, Location location) {
|
private void explode(List<Block> blockList, Location location) {
|
||||||
Region region = Region.getRegion(location);
|
Region region = Region.getRegion(location);
|
||||||
if (region.getRegionData().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return;
|
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return;
|
||||||
Point p1 = region.getBuildArea().getMinPoint(true);
|
Point p1 = region.getBuildArea().getMinPoint(true);
|
||||||
Point p2 = region.getTestblockArea().getMinPoint(true);
|
Point p2 = region.getTestblockArea().getMinPoint(true);
|
||||||
int floorLevel = Math.min(p1.getY(), p2.getY());
|
int floorLevel = Math.min(p1.getY(), p2.getY());
|
||||||
@@ -70,7 +70,7 @@ public class ProtectListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.getRegionData().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return null;
|
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.PROTECT).getWithDefault().getChatValue(), p);
|
return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.PROTECT).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -102,7 +102,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
||||||
.ignoreAir(true)
|
.ignoreAir(true)
|
||||||
.color(region.getRegionData().get(Flag.COLOR).getWithDefault());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.getArea().reset(pasteBuilder, false);
|
region.getArea().reset(pasteBuilder, false);
|
||||||
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
@@ -124,7 +124,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
||||||
.ignoreAir(true)
|
.ignoreAir(true)
|
||||||
.color(region.getRegionData().get(Flag.COLOR).getWithDefault());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.getArea().reset(pasteBuilder, false);
|
region.getArea().reset(pasteBuilder, false);
|
||||||
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
|
|||||||
+1
-1
@@ -182,6 +182,6 @@ public class RegionListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void tagChangedRegion(final Location location) {
|
private static void tagChangedRegion(final Location location) {
|
||||||
Region.getRegion(location).getRegionData().set(Flag.CHANGED, ChangedMode.HAS_CHANGE);
|
Region.getRegion(location).getFlags().set(Flag.CHANGED, ChangedMode.HAS_CHANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-2
@@ -53,8 +53,9 @@ public class ResetCommand extends SWCommand {
|
|||||||
if (region == null) return;
|
if (region == null) return;
|
||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
||||||
.color(region.getRegionData().get(Flag.COLOR).getWithDefault());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.getArea().reset(pasteBuilder, false);
|
region.getArea().reset(pasteBuilder, false);
|
||||||
|
region.getFlags().clear();
|
||||||
region.getRegionData().clear();
|
region.getRegionData().clear();
|
||||||
RegionUtils.message(region, "REGION_RESET_RESETED");
|
RegionUtils.message(region, "REGION_RESET_RESETED");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
@@ -83,7 +84,7 @@ public class ResetCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
||||||
.color(region.getRegionData().get(Flag.COLOR).getWithDefault());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.getArea().reset(pasteBuilder, true);
|
region.getArea().reset(pasteBuilder, true);
|
||||||
RegionUtils.message(region, "REGION_RESET_RESETED");
|
RegionUtils.message(region, "REGION_RESET_RESETED");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class TNTCommand extends SWCommand {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public List<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
Region region = Region.getRegion(((Player) sender).getLocation());
|
Region region = Region.getRegion(((Player) sender).getLocation());
|
||||||
if (region.getRegionData().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||||
return new ArrayList<>(tntModeMap.keySet());
|
return new ArrayList<>(tntModeMap.keySet());
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<>(tntModeMapReduced.keySet());
|
return new ArrayList<>(tntModeMapReduced.keySet());
|
||||||
@@ -102,7 +102,7 @@ public class TNTCommand extends SWCommand {
|
|||||||
@Override
|
@Override
|
||||||
public TNTMode map(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public TNTMode map(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
Region region = Region.getRegion(((Player) sender).getLocation());
|
Region region = Region.getRegion(((Player) sender).getLocation());
|
||||||
if (region.getRegionData().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||||
return tntModeMap.getOrDefault(s, null);
|
return tntModeMap.getOrDefault(s, null);
|
||||||
} else {
|
} else {
|
||||||
return tntModeMapReduced.getOrDefault(s, null);
|
return tntModeMapReduced.getOrDefault(s, null);
|
||||||
@@ -124,23 +124,23 @@ public class TNTCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
|
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
|
||||||
if (requestedMode != null && region.getRegionData().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
if (requestedMode != null && region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||||
region.getRegionData().set(Flag.TNT, requestedMode);
|
region.getFlags().set(Flag.TNT, requestedMode);
|
||||||
RegionUtils.actionBar(region, requestedMessage);
|
RegionUtils.actionBar(region, requestedMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (region.getRegionData().get(Flag.TNT).getWithDefault()) {
|
switch (region.getFlags().get(Flag.TNT).getWithDefault()) {
|
||||||
case ALLOW:
|
case ALLOW:
|
||||||
case ONLY_TB:
|
case ONLY_TB:
|
||||||
region.getRegionData().set(Flag.TNT, TNTMode.DENY);
|
region.getFlags().set(Flag.TNT, TNTMode.DENY);
|
||||||
RegionUtils.actionBar(region, getDisableMessage());
|
RegionUtils.actionBar(region, getDisableMessage());
|
||||||
break;
|
break;
|
||||||
case DENY:
|
case DENY:
|
||||||
if (region.getRegionData().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||||
region.getRegionData().set(Flag.TNT, TNTMode.ONLY_TB);
|
region.getFlags().set(Flag.TNT, TNTMode.ONLY_TB);
|
||||||
RegionUtils.actionBar(region, getTestblockEnableMessage());
|
RegionUtils.actionBar(region, getTestblockEnableMessage());
|
||||||
} else {
|
} else {
|
||||||
region.getRegionData().set(Flag.TNT, TNTMode.ALLOW);
|
region.getFlags().set(Flag.TNT, TNTMode.ALLOW);
|
||||||
RegionUtils.actionBar(region, getEnableMessage());
|
RegionUtils.actionBar(region, getEnableMessage());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class TNTListener implements Listener, ScoreboardElement {
|
|||||||
private void explode(List<Block> blockList, boolean destroy) {
|
private void explode(List<Block> blockList, boolean destroy) {
|
||||||
blockList.removeIf(block -> {
|
blockList.removeIf(block -> {
|
||||||
Region region = Region.getRegion(block.getLocation());
|
Region region = Region.getRegion(block.getLocation());
|
||||||
TNTMode value = region.getRegionData().get(Flag.TNT).getWithDefault();
|
TNTMode value = region.getFlags().get(Flag.TNT).getWithDefault();
|
||||||
if (value == TNTMode.ALLOW) {
|
if (value == TNTMode.ALLOW) {
|
||||||
if (destroy && block.getType() != Material.TNT) {
|
if (destroy && block.getType() != Material.TNT) {
|
||||||
block.setType(Material.AIR);
|
block.setType(Material.AIR);
|
||||||
@@ -86,7 +86,7 @@ public class TNTListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.getRegionData().get(Flag.TNT).isWithDefault(TNTMode.ALLOW)) return null;
|
if (region.getFlags().get(Flag.TNT).isWithDefault(TNTMode.ALLOW)) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.TNT).getWithDefault().getChatValue(), p);
|
return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.TNT).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -119,7 +119,7 @@ public class TestblockCommand extends SWCommand {
|
|||||||
.onlyColors(onlyColors)
|
.onlyColors(onlyColors)
|
||||||
.removeTNT(removeTNT)
|
.removeTNT(removeTNT)
|
||||||
.removeWater(removeWater)
|
.removeWater(removeWater)
|
||||||
.color(region.getRegionData().get(Flag.COLOR).getWithDefault());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.getTestblockArea().reset(pasteBuilder, regionExtensionType == RegionExtensionType.EXTENSION);
|
region.getTestblockArea().reset(pasteBuilder, regionExtensionType == RegionExtensionType.EXTENSION);
|
||||||
RegionUtils.message(region, "REGION_TB_DONE");
|
RegionUtils.message(region, "REGION_TB_DONE");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
|
|||||||
+2
-2
@@ -84,14 +84,14 @@ public class ColorBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
ColorMode mode = region.getRegionData().get(Flag.COLOR).orElse(ColorMode.PINK);
|
ColorMode mode = region.getFlags().get(Flag.COLOR).orElse(ColorMode.PINK);
|
||||||
return new SWItem(mapColor(mode), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack();
|
return new SWItem(mapColor(mode), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean click(ClickType click, Player p) {
|
public boolean click(ClickType click, Player p) {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
ColorMode current = Region.getRegion(p.getLocation()).getRegionData().get(Flag.COLOR).orElse(ColorMode.PINK);
|
ColorMode current = Region.getRegion(p.getLocation()).getFlags().get(Flag.COLOR).orElse(ColorMode.PINK);
|
||||||
List<SWListInv.SWListEntry<ColorMode>> items = new ArrayList<>();
|
List<SWListInv.SWListEntry<ColorMode>> items = new ArrayList<>();
|
||||||
for (ColorMode value : ColorMode.values()) {
|
for (ColorMode value : ColorMode.values()) {
|
||||||
items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> {
|
items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> {
|
||||||
|
|||||||
+2
-2
@@ -42,10 +42,10 @@ public class FireBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (!region.getRegionData().has(Flag.FIRE).isApplicable()) {
|
if (!region.getFlags().has(Flag.FIRE).isApplicable()) {
|
||||||
return new SWItem(Material.BARRIER, "").getItemStack();
|
return new SWItem(Material.BARRIER, "").getItemStack();
|
||||||
}
|
}
|
||||||
if (region.getRegionData().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
|
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
|
||||||
return new SWItem(Material.FIRE_CHARGE, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_ALLOW", player)).getItemStack();
|
return new SWItem(Material.FIRE_CHARGE, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_ALLOW", player)).getItemStack();
|
||||||
} else {
|
} else {
|
||||||
return new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_DISALLOW", player)).getItemStack();
|
return new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_DISALLOW", player)).getItemStack();
|
||||||
|
|||||||
+2
-2
@@ -42,10 +42,10 @@ public class FreezeBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (!region.getRegionData().has(Flag.FREEZE).isApplicable()) {
|
if (!region.getFlags().has(Flag.FREEZE).isApplicable()) {
|
||||||
return new SWItem(Material.BARRIER, "").getItemStack();
|
return new SWItem(Material.BARRIER, "").getItemStack();
|
||||||
}
|
}
|
||||||
if (region.getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
return new SWItem(Material.GUNPOWDER, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_ALLOW", player)).getItemStack();
|
return new SWItem(Material.GUNPOWDER, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_ALLOW", player)).getItemStack();
|
||||||
} else {
|
} else {
|
||||||
return new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_DISALLOW", player)).getItemStack();
|
return new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_DISALLOW", player)).getItemStack();
|
||||||
|
|||||||
+2
-2
@@ -43,10 +43,10 @@ public class ProtectBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (!region.getRegionData().has(Flag.PROTECT).isApplicable()) {
|
if (!region.getFlags().has(Flag.PROTECT).isApplicable()) {
|
||||||
return new SWItem(Material.BARRIER, "").getItemStack();
|
return new SWItem(Material.BARRIER, "").getItemStack();
|
||||||
}
|
}
|
||||||
if (region.getRegionData().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
|
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
|
||||||
return SWUtils.setCustomModelData(new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)), 1).getItemStack();
|
return SWUtils.setCustomModelData(new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)), 1).getItemStack();
|
||||||
} else {
|
} else {
|
||||||
return SWUtils.setCustomModelData(new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)), 1).getItemStack();
|
return SWUtils.setCustomModelData(new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)), 1).getItemStack();
|
||||||
|
|||||||
+2
-2
@@ -42,7 +42,7 @@ public class TntBauGuiItem extends BauGuiItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
switch (Region.getRegion(player.getLocation()).getRegionData().get(Flag.TNT).getWithDefault()) {
|
switch (Region.getRegion(player.getLocation()).getFlags().get(Flag.TNT).getWithDefault()) {
|
||||||
case DENY:
|
case DENY:
|
||||||
return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack();
|
return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack();
|
||||||
case ONLY_TB:
|
case ONLY_TB:
|
||||||
@@ -55,7 +55,7 @@ public class TntBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public boolean click(ClickType click, Player p) {
|
public boolean click(ClickType click, Player p) {
|
||||||
if (click == ClickType.LEFT) {
|
if (click == ClickType.LEFT) {
|
||||||
switch (Region.getRegion(p.getLocation()).getRegionData().get(Flag.TNT).getWithDefault()) {
|
switch (Region.getRegion(p.getLocation()).getFlags().get(Flag.TNT).getWithDefault()) {
|
||||||
case DENY:
|
case DENY:
|
||||||
updateTntMode(TNTMode.ALLOW, p);
|
updateTntMode(TNTMode.ALLOW, p);
|
||||||
break;
|
break;
|
||||||
|
|||||||
+6
-6
@@ -59,14 +59,14 @@ public class RegionLib implements LuaLib {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
LuaValue tntLib = LuaValue.tableOf();
|
LuaValue tntLib = LuaValue.tableOf();
|
||||||
tntLib.set("mode", getter(() -> region.get().getRegionData().get(Flag.TNT).nameWithDefault()));
|
tntLib.set("mode", getter(() -> region.get().getFlags().get(Flag.TNT).nameWithDefault()));
|
||||||
tntLib.set("enabled", getter(() -> region.get().getRegionData().get(Flag.TNT).orElse(null) != TNTMode.DENY));
|
tntLib.set("enabled", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) != TNTMode.DENY));
|
||||||
tntLib.set("onlyTb", getter(() -> region.get().getRegionData().get(Flag.TNT).orElse(null) == TNTMode.ONLY_TB));
|
tntLib.set("onlyTb", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) == TNTMode.ONLY_TB));
|
||||||
table.set("tnt", tntLib);
|
table.set("tnt", tntLib);
|
||||||
|
|
||||||
table.set("fire", getter(() -> region.get().getRegionData().get(Flag.FIRE).orElse(null) == FireMode.ALLOW));
|
table.set("fire", getter(() -> region.get().getFlags().get(Flag.FIRE).orElse(null) == FireMode.ALLOW));
|
||||||
table.set("freeze", getter(() -> region.get().getRegionData().get(Flag.FREEZE).orElse(null) == FreezeMode.ACTIVE));
|
table.set("freeze", getter(() -> region.get().getFlags().get(Flag.FREEZE).orElse(null) == FreezeMode.ACTIVE));
|
||||||
table.set("protect", getter(() -> region.get().getRegionData().get(Flag.PROTECT).orElse(null) == ProtectMode.ACTIVE));
|
table.set("protect", getter(() -> region.get().getFlags().get(Flag.PROTECT).orElse(null) == ProtectMode.ACTIVE));
|
||||||
|
|
||||||
//LuaValue traceLib = LuaValue.tableOf();
|
//LuaValue traceLib = LuaValue.tableOf();
|
||||||
//traceLib.set("active", getter(() -> !region.get().isGlobal() && Recorder.INSTANCE.get(region.get()) instanceof ActiveTracer));
|
//traceLib.set("active", getter(() -> !region.get().isGlobal() && Recorder.INSTANCE.get(region.get()) instanceof ActiveTracer));
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ public final class TNTPhase extends SimulatorPhase {
|
|||||||
@Override
|
@Override
|
||||||
public void accept(World world) {
|
public void accept(World world) {
|
||||||
Location location = position.toLocation(world);
|
Location location = position.toLocation(world);
|
||||||
if (Region.getRegion(location).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) return;
|
if (Region.getRegion(location).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) return;
|
||||||
TNTPrimed tnt = world.spawn(location, TNTPrimed.class);
|
TNTPrimed tnt = world.spawn(location, TNTPrimed.class);
|
||||||
if (!xJump) tnt.setVelocity(tnt.getVelocity().setX(0));
|
if (!xJump) tnt.setVelocity(tnt.getVelocity().setX(0));
|
||||||
if (!yJump) tnt.setVelocity(tnt.getVelocity().setY(0));
|
if (!yJump) tnt.setVelocity(tnt.getVelocity().setY(0));
|
||||||
|
|||||||
+2
-2
@@ -35,8 +35,8 @@ public class StabFinalizer extends StabStep {
|
|||||||
try {
|
try {
|
||||||
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
|
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider);
|
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider);
|
||||||
if (data.region.getRegionData().has(Flag.COLOR).isReadable()) {
|
if (data.region.getFlags().has(Flag.COLOR).isReadable()) {
|
||||||
pasteBuilder.color(data.region.getRegionData().get(Flag.COLOR).getWithDefault());
|
pasteBuilder.color(data.region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
}
|
}
|
||||||
data.region.getTestblockArea().reset(pasteBuilder, true);
|
data.region.getTestblockArea().reset(pasteBuilder, true);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
|
|||||||
+2
-2
@@ -73,8 +73,8 @@ public class StabGenerator extends StabStep implements Listener {
|
|||||||
try {
|
try {
|
||||||
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
|
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider);
|
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider);
|
||||||
if (data.region.getRegionData().has(Flag.COLOR).isReadable()) {
|
if (data.region.getFlags().has(Flag.COLOR).isReadable()) {
|
||||||
pasteBuilder.color(data.region.getRegionData().get(Flag.COLOR).getWithDefault());
|
pasteBuilder.color(data.region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
}
|
}
|
||||||
data.region.getTestblockArea().reset(pasteBuilder, true);
|
data.region.getTestblockArea().reset(pasteBuilder, true);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
|
|||||||
+2
-2
@@ -121,8 +121,8 @@ public class BauScoreboard implements Listener {
|
|||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.getType().isGlobal()) return "§eSteam§8War";
|
if (region.getType().isGlobal()) return "§eSteam§8War";
|
||||||
String colorCode = "§e";
|
String colorCode = "§e";
|
||||||
if (region.getRegionData().has(Flag.COLOR).isReadable()) {
|
if (region.getFlags().has(Flag.COLOR).isReadable()) {
|
||||||
colorCode = "§" + region.getRegionData().get(Flag.COLOR).orElse(ColorMode.PINK).getColorCode();
|
colorCode = "§" + region.getFlags().get(Flag.COLOR).orElse(ColorMode.PINK).getColorCode();
|
||||||
}
|
}
|
||||||
return colorCode + "■ §eSteam§8War " + colorCode + "■"; // ■
|
return colorCode + "■ §eSteam§8War " + colorCode + "■"; // ■
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ public class BackupScheduler implements Enable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Iterator<Region> regionsToBackup = RegionSystem.INSTANCE.getRegions()
|
Iterator<Region> regionsToBackup = RegionSystem.INSTANCE.getRegions()
|
||||||
.filter(region -> region.getRegionData().has(Flag.CHANGED).isReadable())
|
.filter(region -> region.getFlags().has(Flag.CHANGED).isReadable())
|
||||||
.filter(region -> region.getRegionData().get(Flag.CHANGED).isWithDefault(ChangedMode.HAS_CHANGE))
|
.filter(region -> region.getFlags().get(Flag.CHANGED).getWithDefault() == ChangedMode.HAS_CHANGE)
|
||||||
.iterator();
|
.iterator();
|
||||||
if (!regionsToBackup.hasNext()) return;
|
if (!regionsToBackup.hasNext()) return;
|
||||||
doBackup(regionsToBackup);
|
doBackup(regionsToBackup);
|
||||||
@@ -63,7 +63,7 @@ public class BackupScheduler implements Enable {
|
|||||||
Optional<RegionBackups.Backup> backup = region.getBackups()
|
Optional<RegionBackups.Backup> backup = region.getBackups()
|
||||||
.create(RegionBackups.BackupType.AUTOMATIC);
|
.create(RegionBackups.BackupType.AUTOMATIC);
|
||||||
if (backup.isPresent()) {
|
if (backup.isPresent()) {
|
||||||
region.getRegionData().set(Flag.CHANGED, ChangedMode.NO_CHANGE);
|
region.getFlags().set(Flag.CHANGED, ChangedMode.NO_CHANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(BauSystem.getInstance(), 0, 20 * 60);
|
}.runTaskTimer(BauSystem.getInstance(), 0, 20 * 60);
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* 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 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.region;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
|
import lombok.NonNull;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface FlagStorage {
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
<T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy has(@NonNull Flag<T> flag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the flag was changed and did not already contain the provided value
|
||||||
|
*/
|
||||||
|
<T extends Enum<T> & Flag.Value<T>> boolean set(@NonNull Flag<T> flag, @NonNull T value);
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
<T extends Enum<T> & Flag.Value<T>> FlagOptional<T> get(@NonNull Flag<T> flag);
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
Map<Flag<?>, Flag.Value<?>> getBackedMap();
|
||||||
|
}
|
||||||
@@ -23,6 +23,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|||||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
import de.steamwar.sql.GameModeConfig;
|
import de.steamwar.sql.GameModeConfig;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -54,7 +55,7 @@ public interface Region {
|
|||||||
RegionType getType();
|
RegionType getType();
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
RegionData getRegionData();
|
FlagStorage getFlags();
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
Area getArea();
|
Area getArea();
|
||||||
@@ -74,6 +75,9 @@ public interface Region {
|
|||||||
@NonNull
|
@NonNull
|
||||||
RegionBackups getBackups();
|
RegionBackups getBackups();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
RegionData getRegionData();
|
||||||
|
|
||||||
interface Area {
|
interface Area {
|
||||||
|
|
||||||
Area EMPTY = new Area() {
|
Area EMPTY = new Area() {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public interface RegionBackups {
|
|||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final RegionData data;
|
private final FlagStorage flags;
|
||||||
|
|
||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
public abstract boolean load();
|
public abstract boolean load();
|
||||||
|
|||||||
@@ -19,134 +19,75 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.region;
|
package de.steamwar.bausystem.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import lombok.NonNull;
|
|
||||||
import yapion.hierarchy.types.YAPIONObject;
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Objects;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public abstract class RegionData {
|
public interface RegionData {
|
||||||
|
|
||||||
private final List<Property<?, ?>> properties = new ArrayList<>();
|
void clear();
|
||||||
|
|
||||||
protected final YAPIONObject data;
|
SchematicNode getTestblockSchematic();
|
||||||
protected final YAPIONObject flagData;
|
|
||||||
protected final Runnable onChange;
|
|
||||||
protected final Map<Flag<?>, Flag.Value<?>> flagMap = new HashMap<>();
|
|
||||||
|
|
||||||
private final class Property<T, K> {
|
void setTestblockSchematic(SchematicNode schematic);
|
||||||
private final String field;
|
|
||||||
private final Function<K, T> loader;
|
|
||||||
private final Function<T, K> writer;
|
|
||||||
|
|
||||||
private T value;
|
RegionData EMPTY = new RegionData() {
|
||||||
|
|
||||||
public Property(String field, Function<K, T> loader, Function<T, K> writer) {
|
@Override
|
||||||
this.field = field;
|
public void clear() {
|
||||||
this.loader = loader;
|
|
||||||
this.writer = writer;
|
|
||||||
properties.add(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
@Override
|
||||||
if (flagData.containsKey(field)) {
|
public SchematicNode getTestblockSchematic() {
|
||||||
value = loader.apply(flagData.getPlainValue(field));
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTestblockSchematic(SchematicNode schematic) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class RegionDataImpl implements RegionData {
|
||||||
|
|
||||||
|
private final YAPIONObject yapionObject;
|
||||||
|
private final Runnable onChange;
|
||||||
|
|
||||||
|
public RegionDataImpl(YAPIONObject yapionObject, Runnable onChange) {
|
||||||
|
this.yapionObject = yapionObject;
|
||||||
|
this.onChange = onChange;
|
||||||
|
|
||||||
|
if (yapionObject.containsKey("testblockSchematic")) {
|
||||||
|
testblockSchematic = SchematicNode.getSchematicNode(yapionObject.getInt("testblockSchematic"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
testblockSchematic = null;
|
||||||
|
yapionObject.remove("testblockSchematic");
|
||||||
|
onChange.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private SchematicNode testblockSchematic = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SchematicNode getTestblockSchematic() {
|
||||||
|
return testblockSchematic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTestblockSchematic(SchematicNode schematic) {
|
||||||
|
if (Objects.equals(this.testblockSchematic, schematic)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.testblockSchematic = schematic;
|
||||||
|
if (schematic == null) {
|
||||||
|
yapionObject.remove("testblockSchematic");
|
||||||
} else {
|
} else {
|
||||||
value = null;
|
yapionObject.put("testblockSchematic", testblockSchematic.getId());
|
||||||
}
|
}
|
||||||
|
onChange.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public T get() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set(T value) {
|
|
||||||
this.value = value;
|
|
||||||
if (value == null) {
|
|
||||||
flagData.remove(field);
|
|
||||||
} else {
|
|
||||||
flagData.put(field, writer.apply(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Property<SchematicNode, Integer> testblockSchematic = new Property<>("testblockSchematic", SchematicNode::byId, SchematicNode::getId);
|
|
||||||
|
|
||||||
protected RegionData(YAPIONObject data, Runnable onChange) {
|
|
||||||
this.data = data;
|
|
||||||
this.flagData = data.getObjectOrSetDefault("flagStorage", new YAPIONObject());
|
|
||||||
this.onChange = onChange;
|
|
||||||
initialize();
|
|
||||||
for (final Flag flag : Flag.getFlags()) {
|
|
||||||
if (!has(flag).isWritable()) continue;
|
|
||||||
try {
|
|
||||||
String s = flagData.getPlainValue(flag.name());
|
|
||||||
flagMap.put(flag, flag.valueOfValue(s));
|
|
||||||
} catch (Exception e) {
|
|
||||||
flagMap.put(flag, (Flag.Value<?>) flag.getDefaultValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
properties.forEach(Property::load);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void initialize() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public abstract <T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy has(@NonNull Flag<T> flag);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the flag was changed and did not already contain the provided value
|
|
||||||
*/
|
|
||||||
public final <T extends Enum<T> & Flag.Value<T>> boolean set(@NonNull Flag<T> flag, @NonNull T value) {
|
|
||||||
if (has(flag).isWritable()) {
|
|
||||||
if (flagMap.put(flag, value) != value) {
|
|
||||||
flagData.put(flag.name(), value.name());
|
|
||||||
onChange.run();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public final <T extends Enum<T> & Flag.Value<T>> FlagOptional<T> get(@NonNull Flag<T> flag) {
|
|
||||||
return FlagOptional.of(flag, (T) flagMap.get(flag));
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void clear() {
|
|
||||||
for (Flag flag : Flag.getFlags()) {
|
|
||||||
if (has(flag).isWritable()) {
|
|
||||||
flagMap.remove(flag);
|
|
||||||
flagData.remove(flag.name());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
properties.forEach(property -> property.set(null));
|
|
||||||
onChange.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final Map<Flag<?>, Flag.Value<?>> getBackedMap() {
|
|
||||||
return flagMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SchematicNode getTestblockSchematic() {
|
|
||||||
return testblockSchematic.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTestblockSchematic(SchematicNode schematic) {
|
|
||||||
testblockSchematic.set(schematic);
|
|
||||||
onChange.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final String toString() {
|
|
||||||
return getClass().getSimpleName() + "{" +
|
|
||||||
"flagMap=" + flagMap +
|
|
||||||
'}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+106
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* 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 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.region.fixed;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.region.FlagOptional;
|
||||||
|
import de.steamwar.bausystem.region.FlagStorage;
|
||||||
|
import de.steamwar.bausystem.region.RegionFlagPolicy;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
|
import de.steamwar.bausystem.worlddata.WorldData;
|
||||||
|
import de.steamwar.core.Core;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class FixedFlagStorage implements FlagStorage {
|
||||||
|
|
||||||
|
private Map<Flag<?>, Flag.Value<?>> flagMap = new HashMap<>();
|
||||||
|
private YAPIONObject data;
|
||||||
|
|
||||||
|
public FixedFlagStorage(YAPIONObject data) {
|
||||||
|
this.data = data;
|
||||||
|
for (final Flag flag : Flag.getFlags()) {
|
||||||
|
if (!has(flag).isWritable()) continue;
|
||||||
|
try {
|
||||||
|
String s = data.getPlainValue(flag.name());
|
||||||
|
flagMap.put(flag, flag.valueOfValue(s));
|
||||||
|
} catch (Exception e) {
|
||||||
|
flagMap.put(flag, (Flag.Value<?>) flag.getDefaultValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull <T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy has(@NonNull Flag<T> flag) {
|
||||||
|
if (flag.oneOf(Flag.COLOR, Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.PROTECT, Flag.NO_GRAVITY, Flag.CHANGED)) {
|
||||||
|
return RegionFlagPolicy.WRITABLE;
|
||||||
|
}
|
||||||
|
if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) {
|
||||||
|
return RegionFlagPolicy.WRITABLE;
|
||||||
|
}
|
||||||
|
if (flag.oneOf(Flag.TESTBLOCK)) {
|
||||||
|
return RegionFlagPolicy.READ_ONLY;
|
||||||
|
}
|
||||||
|
return RegionFlagPolicy.NOT_APPLICABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends Enum<T> & Flag.Value<T>> boolean set(@NonNull Flag<T> flag, @NonNull T value) {
|
||||||
|
if (has(flag).isWritable()) {
|
||||||
|
boolean hasChanged = flagMap.put(flag, value) != value;
|
||||||
|
if (hasChanged) {
|
||||||
|
data.put(flag.name(), value.name());
|
||||||
|
WorldData.write();
|
||||||
|
}
|
||||||
|
return hasChanged;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull <T extends Enum<T> & Flag.Value<T>> FlagOptional<T> get(@NonNull Flag<T> flag) {
|
||||||
|
return FlagOptional.of(flag, (T) flagMap.get(flag));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
for (Flag flag : Flag.getFlags()) {
|
||||||
|
if (flag == Flag.TESTBLOCK) continue;
|
||||||
|
if (flag == Flag.COLOR) continue;
|
||||||
|
if (flag == Flag.CHANGED) continue;
|
||||||
|
flagMap.remove(flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Flag<?>, Flag.Value<?>> getBackedMap() {
|
||||||
|
return flagMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "FixedFlagStorage{" +
|
||||||
|
"flagMap=" + flagMap +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
+113
@@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* 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 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.region.fixed;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.region.FlagOptional;
|
||||||
|
import de.steamwar.bausystem.region.FlagStorage;
|
||||||
|
import de.steamwar.bausystem.region.RegionFlagPolicy;
|
||||||
|
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
|
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||||
|
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||||
|
import de.steamwar.bausystem.worlddata.WorldData;
|
||||||
|
import de.steamwar.core.Core;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class FixedGlobalFlagStorage implements FlagStorage {
|
||||||
|
|
||||||
|
private Map<Flag<?>, Flag.Value<?>> flagMap = new HashMap<>();
|
||||||
|
private YAPIONObject data;
|
||||||
|
|
||||||
|
public FixedGlobalFlagStorage(YAPIONObject data) {
|
||||||
|
flagMap.put(Flag.TNT, TNTMode.DENY);
|
||||||
|
this.data = data;
|
||||||
|
for (final Flag flag : Flag.getFlags()) {
|
||||||
|
if (!has(flag).isWritable()) continue;
|
||||||
|
try {
|
||||||
|
String s = data.getPlainValue(flag.name());
|
||||||
|
flagMap.put(flag, flag.valueOfValue(s));
|
||||||
|
} catch (Exception e) {
|
||||||
|
flagMap.put(flag, (Flag.Value<?>) flag.getDefaultValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull <T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy has(@NonNull Flag<T> flag) {
|
||||||
|
if (flag.oneOf(Flag.COLOR)) {
|
||||||
|
return RegionFlagPolicy.READ_ONLY;
|
||||||
|
}
|
||||||
|
if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) {
|
||||||
|
return RegionFlagPolicy.WRITABLE;
|
||||||
|
}
|
||||||
|
if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE)) {
|
||||||
|
return RegionFlagPolicy.WRITABLE;
|
||||||
|
}
|
||||||
|
return RegionFlagPolicy.NOT_APPLICABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends Enum<T> & Flag.Value<T>> boolean set(@NonNull Flag<T> flag, @NonNull T value) {
|
||||||
|
if (has(flag).isWritable()) {
|
||||||
|
data.put(flag.name(), value.name());
|
||||||
|
WorldData.write();
|
||||||
|
return flagMap.put(flag, value) != value;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull <T extends Enum<T> & Flag.Value<T>> FlagOptional<T> get(@NonNull Flag<T> flag) {
|
||||||
|
if (flag.oneOf(Flag.COLOR)) {
|
||||||
|
return FlagOptional.of((Flag) flag, ColorMode.YELLOW);
|
||||||
|
}
|
||||||
|
if (flag.oneOf(Flag.PROTECT)) {
|
||||||
|
return FlagOptional.of((Flag) flag, ProtectMode.INACTIVE);
|
||||||
|
}
|
||||||
|
return FlagOptional.of(flag, (T) flagMap.get(flag));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
for (Flag flag : Flag.getFlags()) {
|
||||||
|
if (flag == Flag.TESTBLOCK) continue;
|
||||||
|
if (flag == Flag.COLOR) continue;
|
||||||
|
if (flag == Flag.CHANGED) continue;
|
||||||
|
flagMap.remove(flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Flag<?>, Flag.Value<?>> getBackedMap() {
|
||||||
|
return flagMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "FixedGlobalFlagStorage{" +
|
||||||
|
"flagMap=" + flagMap +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-2
@@ -41,7 +41,7 @@ public final class FixedGlobalRegion implements Region {
|
|||||||
private static final Point MAX_POINT = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
private static final Point MAX_POINT = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private static RegionData FLAG_STORAGE;
|
private static FlagStorage FLAG_STORAGE;
|
||||||
|
|
||||||
private static final UUID GLOBAL_REGION_ID = new UUID(0, 0);
|
private static final UUID GLOBAL_REGION_ID = new UUID(0, 0);
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ public final class FixedGlobalRegion implements Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull RegionData getRegionData() {
|
public @NonNull FlagStorage getFlags() {
|
||||||
return FLAG_STORAGE;
|
return FLAG_STORAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,4 +139,9 @@ public final class FixedGlobalRegion implements Region {
|
|||||||
public @NonNull RegionBackups getBackups() {
|
public @NonNull RegionBackups getBackups() {
|
||||||
return RegionBackups.EMPTY;
|
return RegionBackups.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull RegionData getRegionData() {
|
||||||
|
return RegionData.EMPTY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-58
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* 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 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.region.fixed;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.region.RegionData;
|
|
||||||
import de.steamwar.bausystem.region.RegionFlagPolicy;
|
|
||||||
import de.steamwar.bausystem.region.flags.ColorMode;
|
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
|
||||||
import de.steamwar.bausystem.region.flags.ProtectMode;
|
|
||||||
import de.steamwar.bausystem.region.flags.TNTMode;
|
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import yapion.hierarchy.types.YAPIONObject;
|
|
||||||
|
|
||||||
public class FixedGlobalRegionData extends RegionData {
|
|
||||||
|
|
||||||
public FixedGlobalRegionData(YAPIONObject data, Runnable onChange) {
|
|
||||||
super(data, onChange);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initialize() {
|
|
||||||
flagMap.put(Flag.TNT, TNTMode.DENY);
|
|
||||||
flagMap.put(Flag.COLOR, ColorMode.YELLOW);
|
|
||||||
flagMap.put(Flag.PROTECT, ProtectMode.INACTIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NonNull <T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy has(@NonNull Flag<T> flag) {
|
|
||||||
if (flag.oneOf(Flag.COLOR, Flag.PROTECT)) {
|
|
||||||
return RegionFlagPolicy.READ_ONLY;
|
|
||||||
}
|
|
||||||
if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) {
|
|
||||||
return RegionFlagPolicy.WRITABLE;
|
|
||||||
}
|
|
||||||
if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE)) {
|
|
||||||
return RegionFlagPolicy.WRITABLE;
|
|
||||||
}
|
|
||||||
return RegionFlagPolicy.NOT_APPLICABLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+11
-3
@@ -26,6 +26,7 @@ import de.steamwar.bausystem.region.flags.Flag;
|
|||||||
import de.steamwar.bausystem.region.flags.TestblockMode;
|
import de.steamwar.bausystem.region.flags.TestblockMode;
|
||||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
|
import de.steamwar.bausystem.worlddata.WorldData;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.sql.GameModeConfig;
|
import de.steamwar.sql.GameModeConfig;
|
||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
@@ -49,7 +50,7 @@ public class FixedRegion implements Region {
|
|||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private final FixedRegionData flagStorage;
|
private final FixedFlagStorage flagStorage;
|
||||||
private final Prototype prototype;
|
private final Prototype prototype;
|
||||||
private final String skin;
|
private final String skin;
|
||||||
|
|
||||||
@@ -59,6 +60,7 @@ public class FixedRegion implements Region {
|
|||||||
private final int floorLevel;
|
private final int floorLevel;
|
||||||
private final int waterLevel;
|
private final int waterLevel;
|
||||||
private final GameModeConfig<Material, String> gameModeConfig;
|
private final GameModeConfig<Material, String> gameModeConfig;
|
||||||
|
private final RegionData regionData;
|
||||||
private final RegionHistory regionHistory = new RegionHistory.Impl(20);
|
private final RegionHistory regionHistory = new RegionHistory.Impl(20);
|
||||||
|
|
||||||
private final RegionBackups regionBackups = new RegionBackups() {
|
private final RegionBackups regionBackups = new RegionBackups() {
|
||||||
@@ -139,7 +141,7 @@ public class FixedRegion implements Region {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FixedRegion(String name, FixedRegionData flagStorage, Prototype prototype, YAPIONObject regionConfig, YAPIONObject regionData) {
|
public FixedRegion(String name, FixedFlagStorage flagStorage, Prototype prototype, YAPIONObject regionConfig, YAPIONObject regionData) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
uuid = UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8));
|
uuid = UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8));
|
||||||
this.flagStorage = flagStorage;
|
this.flagStorage = flagStorage;
|
||||||
@@ -341,6 +343,7 @@ public class FixedRegion implements Region {
|
|||||||
} else {
|
} else {
|
||||||
this.gameModeConfig = GameModeConfig.getByFileName(found);
|
this.gameModeConfig = GameModeConfig.getByFileName(found);
|
||||||
}
|
}
|
||||||
|
this.regionData = new RegionData.RegionDataImpl(regionData, WorldData::write);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -354,7 +357,7 @@ public class FixedRegion implements Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull RegionData getRegionData() {
|
public @NonNull FlagStorage getFlags() {
|
||||||
return flagStorage;
|
return flagStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,4 +390,9 @@ public class FixedRegion implements Region {
|
|||||||
public @NonNull RegionBackups getBackups() {
|
public @NonNull RegionBackups getBackups() {
|
||||||
return regionBackups;
|
return regionBackups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull RegionData getRegionData() {
|
||||||
|
return regionData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-48
@@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* 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 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.region.fixed;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.region.RegionData;
|
|
||||||
import de.steamwar.bausystem.region.RegionFlagPolicy;
|
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import yapion.hierarchy.types.YAPIONObject;
|
|
||||||
|
|
||||||
public class FixedRegionData extends RegionData {
|
|
||||||
|
|
||||||
public FixedRegionData(YAPIONObject data, Runnable onChange) {
|
|
||||||
super(data, onChange);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NonNull <T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy has(@NonNull Flag<T> flag) {
|
|
||||||
if (flag.oneOf(Flag.COLOR, Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.PROTECT, Flag.NO_GRAVITY, Flag.CHANGED)) {
|
|
||||||
return RegionFlagPolicy.WRITABLE;
|
|
||||||
}
|
|
||||||
if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) {
|
|
||||||
return RegionFlagPolicy.WRITABLE;
|
|
||||||
}
|
|
||||||
if (flag.oneOf(Flag.TESTBLOCK)) {
|
|
||||||
return RegionFlagPolicy.READ_ONLY;
|
|
||||||
}
|
|
||||||
return RegionFlagPolicy.NOT_APPLICABLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-2
@@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.bausystem.region.fixed;
|
package de.steamwar.bausystem.region.fixed;
|
||||||
|
|
||||||
import de.steamwar.bausystem.region.FixedRegionSystem;
|
import de.steamwar.bausystem.region.FixedRegionSystem;
|
||||||
import de.steamwar.bausystem.worlddata.WorldData;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import yapion.hierarchy.types.YAPIONObject;
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
@@ -217,7 +216,7 @@ public class Prototype {
|
|||||||
} else {
|
} else {
|
||||||
prototype = PROTOTYPE_MAP.get(regionConfig.getPlainValue("prototype"));
|
prototype = PROTOTYPE_MAP.get(regionConfig.getPlainValue("prototype"));
|
||||||
}
|
}
|
||||||
FixedRegionData flagStorage = new FixedRegionData(regionData, WorldData::write);
|
FixedFlagStorage flagStorage = new FixedFlagStorage(regionData.getObjectOrSetDefault("flagStorage", new YAPIONObject()));
|
||||||
FixedRegionSystem.addRegion(new FixedRegion(name, flagStorage, prototype, regionConfig, regionData));
|
FixedRegionSystem.addRegion(new FixedRegion(name, flagStorage, prototype, regionConfig, regionData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.region.fixed.loader;
|
package de.steamwar.bausystem.region.fixed.loader;
|
||||||
|
|
||||||
import de.steamwar.bausystem.region.fixed.FixedGlobalRegionData;
|
import de.steamwar.bausystem.region.fixed.FixedGlobalFlagStorage;
|
||||||
import de.steamwar.bausystem.region.fixed.FixedGlobalRegion;
|
import de.steamwar.bausystem.region.fixed.FixedGlobalRegion;
|
||||||
import de.steamwar.bausystem.region.fixed.Prototype;
|
import de.steamwar.bausystem.region.fixed.Prototype;
|
||||||
import de.steamwar.bausystem.worlddata.WorldData;
|
import de.steamwar.bausystem.worlddata.WorldData;
|
||||||
@@ -80,6 +80,6 @@ public class RegionLoader {
|
|||||||
globalOptions = new YAPIONObject();
|
globalOptions = new YAPIONObject();
|
||||||
optionsYapionObject.add("global", globalOptions);
|
optionsYapionObject.add("global", globalOptions);
|
||||||
}
|
}
|
||||||
FixedGlobalRegion.setFLAG_STORAGE(new FixedGlobalRegionData(globalOptions, WorldData::write));
|
FixedGlobalRegion.setFLAG_STORAGE(new FixedGlobalFlagStorage(globalOptions.getObjectOrSetDefault("flagStorage", new YAPIONObject())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,10 +44,6 @@ object LeaderboardTable : CompositeIdTable("Leaderboard") {
|
|||||||
val bestTime = bool("BestTime")
|
val bestTime = bool("BestTime")
|
||||||
|
|
||||||
override val primaryKey = PrimaryKey(userId, name)
|
override val primaryKey = PrimaryKey(userId, name)
|
||||||
|
|
||||||
init {
|
|
||||||
addIdColumn(userId)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Leaderboard(id: EntityID<CompositeID>) : CompositeEntity(id) {
|
class Leaderboard(id: EntityID<CompositeID>) : CompositeEntity(id) {
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* 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 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.sql
|
||||||
|
|
||||||
|
import de.steamwar.sql.internal.useDb
|
||||||
|
import org.jetbrains.exposed.v1.core.VarCharColumnType
|
||||||
|
import org.jetbrains.exposed.v1.core.and
|
||||||
|
import org.jetbrains.exposed.v1.core.dao.id.CompositeID
|
||||||
|
import org.jetbrains.exposed.v1.core.dao.id.CompositeIdTable
|
||||||
|
import org.jetbrains.exposed.v1.core.dao.id.EntityID
|
||||||
|
import org.jetbrains.exposed.v1.core.eq
|
||||||
|
import org.jetbrains.exposed.v1.dao.CompositeEntity
|
||||||
|
import org.jetbrains.exposed.v1.dao.CompositeEntityClass
|
||||||
|
|
||||||
|
object PollAnswerTable: CompositeIdTable("PollAnswer") {
|
||||||
|
val userId = reference("UserID", SteamwarUserTable)
|
||||||
|
val question = varchar("Question", 150)
|
||||||
|
val answer = integer("Answer")
|
||||||
|
}
|
||||||
|
|
||||||
|
class PollAnswer(id: EntityID<CompositeID>): CompositeEntity(id) {
|
||||||
|
var userId by PollAnswerTable.userId
|
||||||
|
private set
|
||||||
|
var question by PollAnswerTable.question
|
||||||
|
private set
|
||||||
|
private var answerId by PollAnswerTable.answer
|
||||||
|
var answer: Int
|
||||||
|
get() = answerId
|
||||||
|
set(value) = useDb {
|
||||||
|
answerId = value
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object: CompositeEntityClass<PollAnswer>(PollAnswerTable) {
|
||||||
|
@JvmStatic
|
||||||
|
var currentPoll: String? = null
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun get(userId: Int) = useDb {
|
||||||
|
find { (PollAnswerTable.userId eq userId) and (PollAnswerTable.question eq currentPoll!!) }.firstOrNull()
|
||||||
|
?: new {
|
||||||
|
this.userId = EntityID(userId, SteamwarUserTable)
|
||||||
|
this.question = currentPoll!!
|
||||||
|
this.answerId = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun getCurrentResults(): Map<Int, Int> = useDb {
|
||||||
|
exec("SELECT Count(UserID) AS Times, Answer FROM PollAnswer WHERE Question = ? GROUP BY Answer ORDER BY Times ASC",
|
||||||
|
args = listOf(VarCharColumnType() to currentPoll!!)) {
|
||||||
|
val result = mutableMapOf<Int, Int>()
|
||||||
|
while (it.next()) {
|
||||||
|
result[it.getInt("Answer")] = it.getInt("Times")
|
||||||
|
}
|
||||||
|
result
|
||||||
|
} ?: emptyMap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hasAnswered() = answerId != 0
|
||||||
|
}
|
||||||
@@ -179,14 +179,6 @@ class Punishment(id: EntityID<Int>) : IntEntity(id) {
|
|||||||
"UNNOTEAMSERVER",
|
"UNNOTEAMSERVER",
|
||||||
UserPerm.MODERATION
|
UserPerm.MODERATION
|
||||||
),
|
),
|
||||||
NoEvent(
|
|
||||||
"NOEVENT_TEAM",
|
|
||||||
"NOEVENT_PERMA",
|
|
||||||
"NOEVENT_UNTIL",
|
|
||||||
"NOEVENT_ERROR",
|
|
||||||
"UNNOEVENT",
|
|
||||||
UserPerm.MODERATION
|
|
||||||
),
|
|
||||||
Note("NOTE_TEAM", null, null, null, null, UserPerm.PUNISHMENTS, true);
|
Note("NOTE_TEAM", null, null, null, null, UserPerm.PUNISHMENTS, true);
|
||||||
|
|
||||||
fun isMulti() = multi
|
fun isMulti() = multi
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ object TeamTable : IntIdTable("Team", "TeamID") {
|
|||||||
val name = varchar("TeamName", 16)
|
val name = varchar("TeamName", 16)
|
||||||
val deleted = bool("TeamDeleted").default(false)
|
val deleted = bool("TeamDeleted").default(false)
|
||||||
val address = text("Address").nullable()
|
val address = text("Address").nullable()
|
||||||
val port = ushort("Port").default(25565u)
|
val port = ushort("Port")
|
||||||
}
|
}
|
||||||
|
|
||||||
class Team(id: EntityID<Int>) : IntEntity(id) {
|
class Team(id: EntityID<Int>) : IntEntity(id) {
|
||||||
|
|||||||
+4
-7
@@ -27,7 +27,9 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
|||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.*;
|
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
|
||||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
@@ -118,12 +120,7 @@ public class WorldeditWrapper14 implements WorldeditWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Clipboard loadChar(String charName) throws IOException {
|
public Clipboard loadChar(String charName) throws IOException {
|
||||||
File file = new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schem");
|
return new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schem"))))).read();
|
||||||
Clipboard clipboard;
|
|
||||||
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
|
|
||||||
clipboard = reader.read();
|
|
||||||
}
|
|
||||||
return clipboard;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -203,23 +203,13 @@ public class FightSchematic extends StateDependent {
|
|||||||
for(int i = 0; i < chars.length; i++){
|
for(int i = 0; i < chars.length; i++){
|
||||||
Clipboard character;
|
Clipboard character;
|
||||||
try {
|
try {
|
||||||
if (Character.isLowerCase(chars[i])) {
|
character = WorldeditWrapper.impl.loadChar(chars[i] == '/' ? "slash" : String.valueOf(chars[i]));
|
||||||
character = WorldeditWrapper.impl.loadChar("lower/" + chars[i]);
|
|
||||||
} else if (Character.isUpperCase(chars[i])) {
|
|
||||||
character = WorldeditWrapper.impl.loadChar("upper/" + chars[i]);
|
|
||||||
} else {
|
|
||||||
character = WorldeditWrapper.impl.loadChar(chars[i] == '/' ? "slash" : String.valueOf(chars[i]));
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Bukkit.getLogger().log(Level.WARNING, "Could not display character {} due to missing file!", chars[i]);
|
||||||
try {
|
try {
|
||||||
character = WorldeditWrapper.impl.loadChar(chars[i] == '/' ? "slash" : String.valueOf(chars[i]));
|
character = WorldeditWrapper.impl.loadChar("");
|
||||||
} catch (IOException ex) {
|
}catch (IOException ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Could not display character {} due to missing file!", chars[i]);
|
throw new SecurityException("Could not load text", ex);
|
||||||
try {
|
|
||||||
character = WorldeditWrapper.impl.loadChar("");
|
|
||||||
}catch (IOException exc) {
|
|
||||||
throw new SecurityException("Could not load text", exc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,18 +50,6 @@ tasks.register<FightServer>("WarGear20") {
|
|||||||
config = "WarGear20.yml"
|
config = "WarGear20.yml"
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register<FightServer>("HalloweenWS") {
|
|
||||||
group = "run"
|
|
||||||
description = "Run a Halloween 1.21 Fight Replay Server"
|
|
||||||
dependsOn(":SpigotCore:shadowJar")
|
|
||||||
dependsOn(":FightSystem:shadowJar")
|
|
||||||
template = "HalloweenWS"
|
|
||||||
worldName = "arenas/Lucifus"
|
|
||||||
config = "HalloweenWS.yml"
|
|
||||||
replay = 179786
|
|
||||||
jar = "/jars/paper-1.21.6.jar"
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register<FightServer>("WarGear21") {
|
tasks.register<FightServer>("WarGear21") {
|
||||||
group = "run"
|
group = "run"
|
||||||
description = "Run a WarGear 1.21 Fight Server"
|
description = "Run a WarGear 1.21 Fight Server"
|
||||||
|
|||||||
@@ -300,10 +300,10 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper
|
|||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static final Class<?> entityPose = Reflection.getClass("net.minecraft.world.entity.Pose");
|
private static final Class<?> entityPose = Reflection.getClass("net.minecraft.world.entity.Pose");
|
||||||
protected static final Object standing = entityPose.getEnumConstants()[0];
|
private static final Object standing = entityPose.getEnumConstants()[0];
|
||||||
protected static final Object swimming = entityPose.getEnumConstants()[3];
|
private static final Object swimming = entityPose.getEnumConstants()[3];
|
||||||
protected static final Object sneaking = entityPose.getEnumConstants()[5];
|
private static final Object sneaking = entityPose.getEnumConstants()[5];
|
||||||
@Override
|
@Override
|
||||||
public Object getPose(FlatteningWrapper.EntityPose pose) {
|
public Object getPose(FlatteningWrapper.EntityPose pose) {
|
||||||
switch (pose) {
|
switch (pose) {
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ dependencies {
|
|||||||
|
|
||||||
compileOnly(libs.paperapi21)
|
compileOnly(libs.paperapi21)
|
||||||
compileOnly(libs.nms21)
|
compileOnly(libs.nms21)
|
||||||
compileOnly(libs.authlib2)
|
|
||||||
compileOnly(libs.datafixer)
|
compileOnly(libs.datafixer)
|
||||||
compileOnly(libs.netty)
|
compileOnly(libs.netty)
|
||||||
compileOnly(libs.authlib)
|
compileOnly(libs.authlib)
|
||||||
|
|||||||
@@ -43,11 +43,4 @@ public class FlatteningWrapper21 extends FlatteningWrapper14 implements Flatteni
|
|||||||
});
|
});
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static final Object shooting = entityPose.getEnumConstants()[16];
|
|
||||||
@Override
|
|
||||||
public Object getPose(FlatteningWrapper.EntityPose pose) {
|
|
||||||
if (pose == FlatteningWrapper.EntityPose.SHOOTING) return shooting;
|
|
||||||
return super.getPose(pose);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,31 +21,46 @@ package de.steamwar.core;
|
|||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
import de.steamwar.Reflection;
|
||||||
|
import net.minecraft.Util;
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
|
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.GameType;
|
import net.minecraft.world.level.GameType;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.LongSupplier;
|
||||||
|
|
||||||
public class ProtocolWrapper21 implements ProtocolWrapper {
|
public class ProtocolWrapper21 implements ProtocolWrapper {
|
||||||
|
|
||||||
|
private static final Reflection.Field<List> equipmentStack = Reflection.getField(equipmentPacket, List.class, 0);
|
||||||
@Override
|
@Override
|
||||||
public void setEquipmentPacketStack(Object packet, Object slot, Object stack) {
|
public void setEquipmentPacketStack(Object packet, Object slot, Object stack) {
|
||||||
ClientboundSetEquipmentPacket setEquipmentPacket = (ClientboundSetEquipmentPacket) packet;
|
equipmentStack.set(packet, Collections.singletonList(new Pair<>(slot, stack)));
|
||||||
setEquipmentPacket.getSlots().add(Pair.of((EquipmentSlot) slot, (ItemStack) stack));
|
}
|
||||||
|
|
||||||
|
private static final Reflection.Constructor removePacketConstructor = Reflection.getConstructor(ClientboundPlayerInfoRemovePacket.class, List.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public Object playerInfoPacketConstructor(PlayerInfoAction action, GameProfile profile, GameMode mode) {
|
||||||
|
if(action == PlayerInfoAction.REMOVE)
|
||||||
|
return removePacketConstructor.invoke(Collections.singletonList(profile.getId()));
|
||||||
|
return switch (action) {
|
||||||
|
case ADD -> new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE), new ClientboundPlayerInfoUpdatePacket.Entry(
|
||||||
|
profile.getId(), profile, true, 0, GameType.byId(mode.getValue()), null, true, 0, null
|
||||||
|
));
|
||||||
|
case GAMEMODE -> new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE), new ClientboundPlayerInfoUpdatePacket.Entry(
|
||||||
|
profile.getId(), profile, true, 0, GameType.byId(mode.getValue()), null, true, 0, null
|
||||||
|
));
|
||||||
|
default -> null;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object playerInfoPacketConstructor(PlayerInfoAction action, GameProfile profile, GameMode mode) {
|
public void initTPSWarp(LongSupplier longSupplier) {
|
||||||
if(action == PlayerInfoAction.REMOVE)
|
Util.timeSource = () -> System.nanoTime() + longSupplier.getAsLong();
|
||||||
return new ClientboundPlayerInfoRemovePacket(Collections.singletonList(profile.getId()));
|
|
||||||
|
|
||||||
return new ClientboundPlayerInfoUpdatePacket(action == PlayerInfoAction.ADD ?
|
|
||||||
EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE) : EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE),
|
|
||||||
Collections.singletonList(new ClientboundPlayerInfoUpdatePacket.Entry(profile.getId(), profile, false, 0, GameType.byId(mode.getValue()), null, false, 0, null)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.core;
|
package de.steamwar.core;
|
||||||
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@@ -41,9 +40,4 @@ public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper {
|
|||||||
public Material getTurtleScute() {
|
public Material getTurtleScute() {
|
||||||
return Material.TURTLE_SCUTE;
|
return Material.TURTLE_SCUTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getValue(Property property) {
|
|
||||||
return property.value();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.core;
|
package de.steamwar.core;
|
||||||
|
|
||||||
|
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReaderV2;
|
||||||
import com.sk89q.jnbt.NBTInputStream;
|
import com.sk89q.jnbt.NBTInputStream;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
@@ -36,11 +37,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.enginehub.linbus.stream.LinBinaryIO;
|
import org.enginehub.linbus.stream.LinBinaryIO;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class WorldEditWrapper21 implements WorldEditWrapper {
|
public class WorldEditWrapper21 implements WorldEditWrapper {
|
||||||
|
|
||||||
@@ -71,58 +68,12 @@ public class WorldEditWrapper21 implements WorldEditWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
public Clipboard getClipboard(InputStream is, NodeData.SchematicFormat ignored) throws IOException {
|
public Clipboard getClipboard(InputStream is, NodeData.SchematicFormat schemFormat) throws IOException {
|
||||||
ResetableInputStream ris = new ResetableInputStream(is);
|
return switch (schemFormat) {
|
||||||
for (NodeData.SchematicFormat schemFormat : NodeData.SchematicFormat.values()) {
|
case MCEDIT -> new MCEditSchematicReader(new NBTInputStream(is)).read();
|
||||||
try {
|
case SPONGE_V2 -> new SpongeSchematicV2Reader(LinBinaryIO.read(new DataInputStream(is))).read();
|
||||||
Clipboard clipboard = switch (schemFormat) {
|
case SPONGE_V3 -> new SpongeSchematicV3Reader(LinBinaryIO.read(new DataInputStream(is))).read();
|
||||||
case MCEDIT -> new MCEditSchematicReader(new NBTInputStream(ris)).read();
|
};
|
||||||
case SPONGE_V2 -> new SpongeSchematicV2Reader(LinBinaryIO.read(new DataInputStream(ris))).read();
|
|
||||||
case SPONGE_V3 -> new SpongeSchematicV3Reader(LinBinaryIO.read(new DataInputStream(ris))).read();
|
|
||||||
};
|
|
||||||
ris.close();
|
|
||||||
return clipboard;
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
ris.reset();
|
|
||||||
}
|
|
||||||
throw new IOException("No clipboard found");
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ResetableInputStream extends InputStream {
|
|
||||||
|
|
||||||
private InputStream inputStream;
|
|
||||||
private int pointer = 0;
|
|
||||||
private List<Integer> list = new ArrayList<>();
|
|
||||||
|
|
||||||
public ResetableInputStream(InputStream in) {
|
|
||||||
this.inputStream = in;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int read() throws IOException {
|
|
||||||
if (pointer >= list.size()) {
|
|
||||||
int data = inputStream.read();
|
|
||||||
list.add(data);
|
|
||||||
pointer++;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
int data = list.get(pointer);
|
|
||||||
pointer++;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reset() throws IOException {
|
|
||||||
pointer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() throws IOException {
|
|
||||||
list.clear();
|
|
||||||
pointer = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
-73
@@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* 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 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.core.authlib;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.GameProfileRepository;
|
|
||||||
import com.mojang.authlib.ProfileLookupCallback;
|
|
||||||
import de.steamwar.Reflection;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.Services;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class SteamwarGameProfileRepository21 extends SteamwarGameProfileRepository {
|
|
||||||
private static final GameProfileRepository fallback;
|
|
||||||
private static final Reflection.Field<Services> field;
|
|
||||||
private static final Services current;
|
|
||||||
|
|
||||||
static {
|
|
||||||
Class<?> clazz = MinecraftServer.getServer().getClass();
|
|
||||||
field = Reflection.getField(clazz, Services.class, 0);
|
|
||||||
current = field.get(MinecraftServer.getServer());
|
|
||||||
fallback = current.profileRepository();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void findProfilesByNames(String[] strings, ProfileLookupCallback profileLookupCallback) {
|
|
||||||
List<String> unknownNames = new ArrayList<>();
|
|
||||||
for (String name:strings) {
|
|
||||||
SteamwarUser user = SteamwarUser.get(name);
|
|
||||||
if(user == null) {
|
|
||||||
unknownNames.add(name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
profileLookupCallback.onProfileLookupSucceeded(new GameProfile(user.getUUID(), user.getUserName()));
|
|
||||||
}
|
|
||||||
if(!unknownNames.isEmpty()) {
|
|
||||||
fallback.findProfilesByNames(unknownNames.toArray(new String[0]), profileLookupCallback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<GameProfile> findProfileByName(String s) {
|
|
||||||
return fallback.findProfileByName(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void inject() {
|
|
||||||
Services newServices = new Services(current.sessionService(), current.servicesKeySet(), this, current.profileCache(), current.paperConfigurations());
|
|
||||||
field.set(MinecraftServer.getServer(), newServices);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,9 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.entity;
|
package de.steamwar.entity;
|
||||||
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
|
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
|
||||||
import net.minecraft.world.entity.EntityType;
|
|
||||||
import net.minecraft.world.entity.PositionMoveRotation;
|
import net.minecraft.world.entity.PositionMoveRotation;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
@@ -33,21 +31,4 @@ public class PacketConstructor21 implements PacketConstructor{
|
|||||||
PositionMoveRotation rot = new PositionMoveRotation(new Vec3(x, y, z), Vec3.ZERO, pitch, yaw);
|
PositionMoveRotation rot = new PositionMoveRotation(new Vec3(x, y, z), Vec3.ZERO, pitch, yaw);
|
||||||
return new ClientboundTeleportEntityPacket(entityId, rot, Collections.emptySet(), false);
|
return new ClientboundTeleportEntityPacket(entityId, rot, Collections.emptySet(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object createRPlayerSpawn(RPlayer player) {
|
|
||||||
return new ClientboundAddEntityPacket(
|
|
||||||
player.entityId,
|
|
||||||
player.uuid,
|
|
||||||
player.x,
|
|
||||||
player.y,
|
|
||||||
player.z,
|
|
||||||
player.yaw,
|
|
||||||
player.pitch,
|
|
||||||
EntityType.PLAYER,
|
|
||||||
0,
|
|
||||||
Vec3.ZERO,
|
|
||||||
player.headYaw
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.core;
|
package de.steamwar.core;
|
||||||
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@@ -41,9 +40,4 @@ public class TrickyTrialsWrapper8 implements TrickyTrialsWrapper {
|
|||||||
public Material getTurtleScute() {
|
public Material getTurtleScute() {
|
||||||
return Material.STONE;
|
return Material.STONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getValue(Property property) {
|
|
||||||
return property.getValue();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-72
@@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* 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 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.core.authlib;
|
|
||||||
|
|
||||||
import com.mojang.authlib.Agent;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.GameProfileRepository;
|
|
||||||
import com.mojang.authlib.ProfileLookupCallback;
|
|
||||||
import de.steamwar.Reflection;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SteamwarGameProfileRepository8 extends SteamwarGameProfileRepository {
|
|
||||||
|
|
||||||
private static final GameProfileRepository fallback;
|
|
||||||
|
|
||||||
private static final Object minecraftServer;
|
|
||||||
private static final Reflection.Field<?> gameProfile;
|
|
||||||
|
|
||||||
static {
|
|
||||||
Class<?> minecraftServerClass = Reflection.getClass("net.minecraft.server.MinecraftServer");
|
|
||||||
Class<?> gpr = Reflection.getClass("com.mojang.authlib.GameProfileRepository");
|
|
||||||
gameProfile = Reflection.getField(minecraftServerClass, gpr, 0);
|
|
||||||
minecraftServer = Reflection.getTypedMethod(minecraftServerClass, "getServer", minecraftServerClass).invoke(null);
|
|
||||||
fallback = (GameProfileRepository) gameProfile.get(minecraftServer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void inject() {
|
|
||||||
gameProfile.set(minecraftServer, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void findProfilesByNames(String[] strings, Agent agent, ProfileLookupCallback profileLookupCallback) {
|
|
||||||
if(agent == Agent.SCROLLS) {
|
|
||||||
fallback.findProfilesByNames(strings, agent, profileLookupCallback);
|
|
||||||
} else {
|
|
||||||
List<String> unknownNames = new ArrayList<>();
|
|
||||||
for (String name:strings) {
|
|
||||||
SteamwarUser user = SteamwarUser.get(name);
|
|
||||||
if(user == null) {
|
|
||||||
unknownNames.add(name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
profileLookupCallback.onProfileLookupSucceeded(new GameProfile(user.getUUID(), user.getUserName()));
|
|
||||||
}
|
|
||||||
if(!unknownNames.isEmpty()) {
|
|
||||||
fallback.findProfilesByNames(unknownNames.toArray(new String[0]), agent, profileLookupCallback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -21,12 +21,6 @@ package de.steamwar.core;
|
|||||||
|
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.Reflection;
|
import de.steamwar.Reflection;
|
||||||
import de.steamwar.command.*;
|
|
||||||
import de.steamwar.core.authlib.SteamwarGameProfileRepository;
|
|
||||||
import de.steamwar.core.events.AntiNocom;
|
|
||||||
import de.steamwar.core.events.ChattingEvent;
|
|
||||||
import de.steamwar.core.events.PlayerJoinedEvent;
|
|
||||||
import de.steamwar.core.events.WorldLoadEvent;
|
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.SWTypeMapperCreator;
|
import de.steamwar.command.SWTypeMapperCreator;
|
||||||
import de.steamwar.command.TabCompletionCache;
|
import de.steamwar.command.TabCompletionCache;
|
||||||
@@ -116,9 +110,6 @@ public class Core extends JavaPlugin {
|
|||||||
getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new NetworkReceiver());
|
getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new NetworkReceiver());
|
||||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge");
|
getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge");
|
||||||
|
|
||||||
if (Core.getVersion() != 20)
|
|
||||||
SteamwarGameProfileRepository.impl.inject();
|
|
||||||
|
|
||||||
TinyProtocol.init();
|
TinyProtocol.init();
|
||||||
CheckpointUtils.signalHandler();
|
CheckpointUtils.signalHandler();
|
||||||
|
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ public class FlatteningWrapper {
|
|||||||
public enum EntityPose {
|
public enum EntityPose {
|
||||||
NORMAL,
|
NORMAL,
|
||||||
SNEAKING,
|
SNEAKING,
|
||||||
SWIMMING,
|
SWIMMING;
|
||||||
SHOOTING,
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.core;
|
package de.steamwar.core;
|
||||||
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryView;
|
||||||
|
|
||||||
public interface TrickyTrialsWrapper {
|
public interface TrickyTrialsWrapper {
|
||||||
TrickyTrialsWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
TrickyTrialsWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||||
@@ -32,6 +33,4 @@ public interface TrickyTrialsWrapper {
|
|||||||
Enchantment getUnbreakingEnchantment();
|
Enchantment getUnbreakingEnchantment();
|
||||||
|
|
||||||
Material getTurtleScute();
|
Material getTurtleScute();
|
||||||
|
|
||||||
String getValue(Property property);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* 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 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.core.authlib;
|
||||||
|
|
||||||
|
import de.steamwar.Reflection;
|
||||||
|
import com.mojang.authlib.GameProfileRepository;
|
||||||
|
import com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.linkage.MaxVersion;
|
||||||
|
import de.steamwar.linkage.api.Enable;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
@MaxVersion(18)
|
||||||
|
public class AuthlibInjector implements Enable {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
Class<?> minecraftServerClass = Reflection.getClass("net.minecraft.server.MinecraftServer");
|
||||||
|
Reflection.Field<GameProfileRepository> gameProfile = Reflection.getField(minecraftServerClass, GameProfileRepository.class, 0);
|
||||||
|
Object minecraftServer = Reflection.getTypedMethod(minecraftServerClass, "getServer", minecraftServerClass).invoke(null);
|
||||||
|
gameProfile.set(minecraftServer, new SteamwarGameProfileRepository((YggdrasilGameProfileRepository) gameProfile.get(minecraftServer)));
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
-5
@@ -19,12 +19,42 @@
|
|||||||
|
|
||||||
package de.steamwar.core.authlib;
|
package de.steamwar.core.authlib;
|
||||||
|
|
||||||
|
import com.mojang.authlib.Agent;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.GameProfileRepository;
|
import com.mojang.authlib.GameProfileRepository;
|
||||||
import de.steamwar.core.Core;
|
import com.mojang.authlib.ProfileLookupCallback;
|
||||||
import de.steamwar.core.VersionDependent;
|
import com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
|
||||||
public abstract class SteamwarGameProfileRepository implements GameProfileRepository {
|
import java.util.ArrayList;
|
||||||
public static final SteamwarGameProfileRepository impl = VersionDependent.getVersionImpl(Core.getInstance());
|
import java.util.List;
|
||||||
|
|
||||||
public abstract void inject();
|
public class SteamwarGameProfileRepository implements GameProfileRepository {
|
||||||
|
|
||||||
|
private final YggdrasilGameProfileRepository fallback;
|
||||||
|
|
||||||
|
public SteamwarGameProfileRepository(YggdrasilGameProfileRepository repository) {
|
||||||
|
fallback = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void findProfilesByNames(String[] strings, Agent agent, ProfileLookupCallback profileLookupCallback) {
|
||||||
|
if(agent == Agent.SCROLLS) {
|
||||||
|
fallback.findProfilesByNames(strings, agent, profileLookupCallback);
|
||||||
|
} else {
|
||||||
|
List<String> unknownNames = new ArrayList<>();
|
||||||
|
for (String name:strings) {
|
||||||
|
SteamwarUser user = SteamwarUser.get(name);
|
||||||
|
if(user == null) {
|
||||||
|
unknownNames.add(name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profileLookupCallback.onProfileLookupSucceeded(new GameProfile(user.getUUID(), user.getUserName()));
|
||||||
|
}
|
||||||
|
if(!unknownNames.isEmpty()) {
|
||||||
|
fallback.findProfilesByNames(unknownNames.toArray(new String[0]), agent, profileLookupCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ import de.steamwar.core.Core;
|
|||||||
import de.steamwar.core.VersionDependent;
|
import de.steamwar.core.VersionDependent;
|
||||||
|
|
||||||
public interface PacketConstructor {
|
public interface PacketConstructor {
|
||||||
PacketConstructor impl = VersionDependent.getVersionImpl(Core.getInstance());
|
public static final PacketConstructor impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||||
|
|
||||||
Object teleportPacket(int entityId, double x, double y, double z, float yaw, float pitch);
|
Object teleportPacket(int entityId, double x, double y, double z, float yaw, float pitch);
|
||||||
Object createRPlayerSpawn(RPlayer player);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class REntity {
|
|||||||
|
|
||||||
private static final Object entityStatusWatcher = BountifulWrapper.impl.getDataWatcherObject(0, Byte.class);
|
private static final Object entityStatusWatcher = BountifulWrapper.impl.getDataWatcherObject(0, Byte.class);
|
||||||
private static final Object sneakingDataWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() > 12 ? 6 : 0, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.NORMAL).getClass());
|
private static final Object sneakingDataWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() > 12 ? 6 : 0, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.NORMAL).getClass());
|
||||||
private static final Object bowDrawnWatcher = Core.getVersion() >= 21 ? BountifulWrapper.impl.getDataWatcherObject(6, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.NORMAL).getClass()) : BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() > 12 ? 7 : 6, Byte.class);
|
private static final Object bowDrawnWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() > 12 ? 7 : 6, Byte.class);
|
||||||
private static final Object nameWatcher = BountifulWrapper.impl.getDataWatcherObject(2, Core.getVersion() > 12 ? Optional.class : String.class); // Optional<IChatBaseComponent>
|
private static final Object nameWatcher = BountifulWrapper.impl.getDataWatcherObject(2, Core.getVersion() > 12 ? Optional.class : String.class); // Optional<IChatBaseComponent>
|
||||||
private static final Object nameVisibleWatcher = BountifulWrapper.impl.getDataWatcherObject(3, Boolean.class);
|
private static final Object nameVisibleWatcher = BountifulWrapper.impl.getDataWatcherObject(3, Boolean.class);
|
||||||
|
|
||||||
@@ -58,9 +58,9 @@ public class REntity {
|
|||||||
protected double y;
|
protected double y;
|
||||||
@Getter
|
@Getter
|
||||||
protected double z;
|
protected double z;
|
||||||
protected byte yaw;
|
private byte yaw;
|
||||||
protected byte pitch;
|
private byte pitch;
|
||||||
protected byte headYaw;
|
private byte headYaw;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private boolean hidden;
|
private boolean hidden;
|
||||||
@@ -219,9 +219,7 @@ public class REntity {
|
|||||||
|
|
||||||
public void setBowDrawn(boolean drawn, boolean offHand) {
|
public void setBowDrawn(boolean drawn, boolean offHand) {
|
||||||
bowDrawn = drawn;
|
bowDrawn = drawn;
|
||||||
if (Core.getVersion() >= 21) {
|
if(Core.getVersion() > 8){
|
||||||
server.updateEntity(this, getDataWatcherPacket(bowDrawnWatcher, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.SHOOTING)));
|
|
||||||
} else if(Core.getVersion() > 8){
|
|
||||||
server.updateEntity(this, getDataWatcherPacket(bowDrawnWatcher, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0))));
|
server.updateEntity(this, getDataWatcherPacket(bowDrawnWatcher, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0))));
|
||||||
}else{
|
}else{
|
||||||
server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, getEntityStatus()));
|
server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, getEntityStatus()));
|
||||||
@@ -445,14 +443,12 @@ public class REntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.Field<Integer> equipmentEntity = Reflection.getField(ProtocolWrapper.equipmentPacket, int.class, 0);
|
private static final Reflection.Field<Integer> equipmentEntity = Reflection.getField(ProtocolWrapper.equipmentPacket, int.class, 0);
|
||||||
private static final Reflection.Field<List> equipmentSlots = Reflection.getField(ProtocolWrapper.equipmentPacket, List.class, 0);
|
|
||||||
|
|
||||||
private static final Class<?> craftItemStack = Reflection.getClass("org.bukkit.craftbukkit.inventory.CraftItemStack");
|
private static final Class<?> craftItemStack = Reflection.getClass("org.bukkit.craftbukkit.inventory.CraftItemStack");
|
||||||
protected static final Reflection.Method asNMSCopy = Reflection.getTypedMethod(REntity.craftItemStack, "asNMSCopy", ProtocolWrapper.itemStack, ItemStack.class);
|
protected static final Reflection.Method asNMSCopy = Reflection.getTypedMethod(REntity.craftItemStack, "asNMSCopy", ProtocolWrapper.itemStack, ItemStack.class);
|
||||||
protected Object getEquipmentPacket(Object slot, ItemStack stack){
|
protected Object getEquipmentPacket(Object slot, ItemStack stack){
|
||||||
Object packet = Reflection.newInstance(ProtocolWrapper.equipmentPacket);
|
Object packet = Reflection.newInstance(ProtocolWrapper.equipmentPacket);
|
||||||
equipmentEntity.set(packet, entityId);
|
equipmentEntity.set(packet, entityId);
|
||||||
equipmentSlots.set(packet, new ArrayList<>());
|
|
||||||
ProtocolWrapper.impl.setEquipmentPacketStack(packet, slot, asNMSCopy.invoke(null, stack));
|
ProtocolWrapper.impl.setEquipmentPacketStack(packet, slot, asNMSCopy.invoke(null, stack));
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ package de.steamwar.entity;
|
|||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import de.steamwar.Reflection;
|
import de.steamwar.Reflection;
|
||||||
import de.steamwar.core.*;
|
import de.steamwar.core.BountifulWrapper;
|
||||||
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.core.FlatteningWrapper;
|
||||||
|
import de.steamwar.core.ProtocolWrapper;
|
||||||
import de.steamwar.network.CoreNetworkHandler;
|
import de.steamwar.network.CoreNetworkHandler;
|
||||||
import de.steamwar.network.NetworkSender;
|
import de.steamwar.network.NetworkSender;
|
||||||
import de.steamwar.network.packets.common.PlayerSkinRequestPacket;
|
import de.steamwar.network.packets.common.PlayerSkinRequestPacket;
|
||||||
@@ -79,7 +82,7 @@ public class RPlayer extends REntity {
|
|||||||
NetworkSender.sendOrQueue(new PlayerSkinRequestPacket(actualUUID));
|
NetworkSender.sendOrQueue(new PlayerSkinRequestPacket(actualUUID));
|
||||||
return new Property("textures", null, null);
|
return new Property("textures", null, null);
|
||||||
});
|
});
|
||||||
if (TrickyTrialsWrapper.impl.getValue(skinData) != null) {
|
if (skinData.getValue() != null) {
|
||||||
GameProfile gameProfile = new GameProfile(uuid, name);
|
GameProfile gameProfile = new GameProfile(uuid, name);
|
||||||
gameProfile.getProperties().put("textures", skinData);
|
gameProfile.getProperties().put("textures", skinData);
|
||||||
return gameProfile;
|
return gameProfile;
|
||||||
@@ -114,21 +117,10 @@ public class RPlayer extends REntity {
|
|||||||
packetSink.accept(ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, saved, GameMode.CREATIVE));
|
packetSink.accept(ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, saved, GameMode.CREATIVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Class<?> namedSpawnPacket = null;
|
private static final Class<?> namedSpawnPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundAddPlayerPacket");
|
||||||
private static Function<REntity, Object> namedSpawnPacketGenerator = null;
|
private static final Function<REntity, Object> namedSpawnPacketGenerator = spawnPacketGenerator(namedSpawnPacket, Core.getVersion() == 8 ? 1 : 0);
|
||||||
private static Reflection.Field<UUID> namedSpawnUUID = null;
|
private static final Reflection.Field<UUID> namedSpawnUUID = Reflection.getField(namedSpawnPacket, UUID.class, 0);
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
namedSpawnPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundAddPlayerPacket");
|
|
||||||
namedSpawnPacketGenerator = spawnPacketGenerator(namedSpawnPacket, Core.getVersion() == 8 ? 1 : 0);
|
|
||||||
namedSpawnUUID = Reflection.getField(namedSpawnPacket, UUID.class, 0);
|
|
||||||
} catch (IllegalArgumentException e) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object getNamedSpawnPacket() {
|
private Object getNamedSpawnPacket() {
|
||||||
if (Core.getVersion() >= 21) return PacketConstructor.impl.createRPlayerSpawn(this);
|
|
||||||
|
|
||||||
Object packet = namedSpawnPacketGenerator.apply(this);
|
Object packet = namedSpawnPacketGenerator.apply(this);
|
||||||
namedSpawnUUID.set(packet, uuid);
|
namedSpawnUUID.set(packet, uuid);
|
||||||
FlatteningWrapper.impl.setNamedSpawnPacketDataWatcher(packet);
|
FlatteningWrapper.impl.setNamedSpawnPacketDataWatcher(packet);
|
||||||
|
|||||||
@@ -208,14 +208,6 @@ NOTEAMSERVER_UNTIL=§7You are excluded from §e§lteam servers§7 §euntil {0}§
|
|||||||
UNNOTEAMSERVER_ERROR=§cThe player is not excluded from team servers.
|
UNNOTEAMSERVER_ERROR=§cThe player is not excluded from team servers.
|
||||||
UNNOTEAMSERVER=§e{0} §7may now set §e§lteam servers§7 again§8.
|
UNNOTEAMSERVER=§e{0} §7may now set §e§lteam servers§7 again§8.
|
||||||
|
|
||||||
NOEVENT_TEAM=§e{0} §7was excluded from §e{1} {2} §7from §e§levents§8: §f{3}
|
|
||||||
NOEVENT_PERMA=§7You are §epermanently§7 excluded from §e§levents§8: §e{0}
|
|
||||||
NOEVENT_UNTIL=§7You are excluded from §e§levents§7 §euntil {0}§8: §e{1}
|
|
||||||
NOEVENT_ERROR=§cThe player is not excluded from events.
|
|
||||||
UNNOEVENT=§e{0} §7may now participate in §e§levents§7 again§8.
|
|
||||||
NOEVENT_PLAYER_PUNISHED=§7A player in your Team is excluded from §e§levents§8.§7 Your team cannot participate§8.
|
|
||||||
NOEVENT_INVITED_PUNISHED=§cThe player you invited cannot attend §e§levents§8.§7 If they join your future Event participation will be restricted§8.
|
|
||||||
|
|
||||||
NOTE_TEAM=§e{0} §7received a §e§lnote§7 from §e{1} {2}: §f{3}
|
NOTE_TEAM=§e{0} §7received a §e§lnote§7 from §e{1} {2}: §f{3}
|
||||||
|
|
||||||
#BugCommand
|
#BugCommand
|
||||||
@@ -226,6 +218,11 @@ IGNORE_YOURSELF=§cHow are you going to ignore yourself?
|
|||||||
IGNORE_ALREADY=§cYou are already ignoring this player.
|
IGNORE_ALREADY=§cYou are already ignoring this player.
|
||||||
IGNORE_MESSAGE=§7You are now ignoring §e{0}§8.
|
IGNORE_MESSAGE=§7You are now ignoring §e{0}§8.
|
||||||
|
|
||||||
|
#PollresultCommand
|
||||||
|
POLLRESULT_NOPOLL=§cThere is currently no ongoing poll.
|
||||||
|
POLLRESULT_HEADER=§e{0} players have voted on the question: §7{1}
|
||||||
|
POLLRESULT_LIST=§e{0}§8: §7{1}
|
||||||
|
|
||||||
#BauCommand
|
#BauCommand
|
||||||
BAU_ADDMEMBER_USAGE=§8/§7build addmember §8[§eplayer§8]
|
BAU_ADDMEMBER_USAGE=§8/§7build addmember §8[§eplayer§8]
|
||||||
BAU_ADDMEMBER_SELFADD=§cYou don't have to add yourself!
|
BAU_ADDMEMBER_SELFADD=§cYou don't have to add yourself!
|
||||||
@@ -370,6 +367,12 @@ MSG_IGNORED=§cThis player has blocked you!
|
|||||||
#PingCommand
|
#PingCommand
|
||||||
PING_RESPONSE=§7Your ping is §c{0}§7 ms!
|
PING_RESPONSE=§7Your ping is §c{0}§7 ms!
|
||||||
|
|
||||||
|
#PollCommand
|
||||||
|
POLL_NO_POLL=§cThere is no ongoing poll.
|
||||||
|
POLL_NO_ANSWER=§cThis is not an option
|
||||||
|
POLL_ANSWER_REFRESH=§aYour answer was updated.
|
||||||
|
POLL_ANSWER_NEW=§aYour answer was registered.
|
||||||
|
|
||||||
#RCommand
|
#RCommand
|
||||||
R_USAGE=§8/§7r §8[§eanswer§8]
|
R_USAGE=§8/§7r §8[§eanswer§8]
|
||||||
|
|
||||||
@@ -594,6 +597,13 @@ JOIN_STREAMING=§5Streaming Mode§7 is still active§8.§7 Keep in mind that you
|
|||||||
#EventModeListener
|
#EventModeListener
|
||||||
EVENTMODE_KICK=§cYou are not an event participant.
|
EVENTMODE_KICK=§cYou are not an event participant.
|
||||||
|
|
||||||
|
#PollSystem
|
||||||
|
POLL_HEADER=§e§lPoll
|
||||||
|
POLL_HEADER2=§7Click the answer you like!
|
||||||
|
POLL_QUESTION=§e{0}
|
||||||
|
POLL_ANSWER=§7{0}
|
||||||
|
POLL_ANSWER_HOVER=§eChoose {0}
|
||||||
|
|
||||||
#TablistManager
|
#TablistManager
|
||||||
TABLIST_PHASE_WEBSITE=§8Website: https://§eSteam§8War.de
|
TABLIST_PHASE_WEBSITE=§8Website: https://§eSteam§8War.de
|
||||||
TABLIST_PHASE_DISCORD=§8Discord: https://§eSteam§8War.de/discord
|
TABLIST_PHASE_DISCORD=§8Discord: https://§eSteam§8War.de/discord
|
||||||
|
|||||||
@@ -190,14 +190,6 @@ NOTEAMSERVER_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lTeamserver§7 setzen a
|
|||||||
UNNOTEAMSERVER_ERROR=§cDer Spieler ist nicht vom Teamserver setzten ausgeschlossen.
|
UNNOTEAMSERVER_ERROR=§cDer Spieler ist nicht vom Teamserver setzten ausgeschlossen.
|
||||||
UNNOTEAMSERVER=§e{0} §7darf nun wieder §e§lTeamserver§7 setzen§8.
|
UNNOTEAMSERVER=§e{0} §7darf nun wieder §e§lTeamserver§7 setzen§8.
|
||||||
|
|
||||||
NOEVENT_TEAM=§e{0} §7wurde von §e{1} {2} §7aus §e§lEvents§8 ausgeschlossen: §f{3}
|
|
||||||
NOEVENT_PERMA=§7Du bist §epermanent§7 von §e§lEvents§8 ausgeschlossen: §e{0}
|
|
||||||
NOEVENT_UNTIL=§7Du bist §ebis zum {0}§7 von §e§lEvents§7 ausgeschlossen§8: §e{1}
|
|
||||||
NOEVENT_ERROR=§cDer Spieler ist nicht von Events ausgeschlossen.
|
|
||||||
UNNOEVENT=§e{0} §7kann nun wieder an §e§lEvents§7 teilnehmen§8.
|
|
||||||
NOEVENT_PLAYER_PUNISHED=§7Ein Spieler deines Teams ist von §e§lEvents§7 ausgeschlossen§8.§7 Dein Team kann nicht teilnehmen§8.
|
|
||||||
NOEVENT_INVITED_PUNISHED=§cDer von dir eingeladene Spieler kann nicht an §e§lEvents§7 teilnehmen§8.§7 Wenn er beitritt, wird deine zukünftige Teilnahme an Events eingeschränkt§8.
|
|
||||||
|
|
||||||
NOTE_TEAM=§e{0} §7erhielt von §e{1} {2} §7die §e§lNotiz§7§8: §f{3}
|
NOTE_TEAM=§e{0} §7erhielt von §e{1} {2} §7die §e§lNotiz§7§8: §f{3}
|
||||||
|
|
||||||
#BugCommand
|
#BugCommand
|
||||||
@@ -208,6 +200,10 @@ IGNORE_YOURSELF=§cWie willst du dich selber ignorieren?
|
|||||||
IGNORE_ALREADY=§cDu ignorierst diesen Spieler bereits.
|
IGNORE_ALREADY=§cDu ignorierst diesen Spieler bereits.
|
||||||
IGNORE_MESSAGE=§7Du ignorierst nun §e{0}§8.
|
IGNORE_MESSAGE=§7Du ignorierst nun §e{0}§8.
|
||||||
|
|
||||||
|
#PollresultCommand
|
||||||
|
POLLRESULT_NOPOLL=§cDerzeit läuft keine Umfrage.
|
||||||
|
POLLRESULT_HEADER=§eEs haben {0} abgestimmt auf die Frage: §7{1}
|
||||||
|
|
||||||
#BauCommand
|
#BauCommand
|
||||||
BAU_ADDMEMBER_USAGE=§8/§7bau addmember §8[§eSpieler§8]
|
BAU_ADDMEMBER_USAGE=§8/§7bau addmember §8[§eSpieler§8]
|
||||||
BAU_ADDMEMBER_SELFADD=§cDu brauchst dich nicht selbst hinzufügen!
|
BAU_ADDMEMBER_SELFADD=§cDu brauchst dich nicht selbst hinzufügen!
|
||||||
@@ -349,6 +345,12 @@ MSG_IGNORED=§cDieser Spieler hat dich geblockt!
|
|||||||
#PingCommand
|
#PingCommand
|
||||||
PING_RESPONSE=§7Dein Ping beträgt §c{0}§7 ms!
|
PING_RESPONSE=§7Dein Ping beträgt §c{0}§7 ms!
|
||||||
|
|
||||||
|
#PollCommand
|
||||||
|
POLL_NO_POLL=§cDerzeit läuft keine Umfrage.
|
||||||
|
POLL_NO_ANSWER=§cDas ist keine Antwortmöglichkeit!
|
||||||
|
POLL_ANSWER_REFRESH=§aDeine Antwort wurde aktualisiert.
|
||||||
|
POLL_ANSWER_NEW=§aDeine Antwort wurde registriert.
|
||||||
|
|
||||||
#RCommand
|
#RCommand
|
||||||
R_USAGE=§8/§7r §8[§eAntwort§8]
|
R_USAGE=§8/§7r §8[§eAntwort§8]
|
||||||
|
|
||||||
@@ -567,6 +569,13 @@ JOIN_STREAMING=§5Streaming-Modus§7 ist weiterhin aktiv§8.§7 Beachten Sie, da
|
|||||||
#EventModeListener
|
#EventModeListener
|
||||||
EVENTMODE_KICK=§cDu bist kein Eventteilnehmer.
|
EVENTMODE_KICK=§cDu bist kein Eventteilnehmer.
|
||||||
|
|
||||||
|
#PollSystem
|
||||||
|
POLL_HEADER=§e§lUmfrage
|
||||||
|
POLL_HEADER2=§7Klicke die Antwort an, die dir gefällt!
|
||||||
|
POLL_QUESTION=§e{0}
|
||||||
|
POLL_ANSWER=§7{0}
|
||||||
|
POLL_ANSWER_HOVER=§e{0} §ewählen
|
||||||
|
|
||||||
#TablistManager
|
#TablistManager
|
||||||
TABLIST_FOOTER=§e{0} {1}§8ms §eSpieler§8: §7{2}
|
TABLIST_FOOTER=§e{0} {1}§8ms §eSpieler§8: §7{2}
|
||||||
TABLIST_BAU=§7§lBau
|
TABLIST_BAU=§7§lBau
|
||||||
|
|||||||
@@ -68,11 +68,18 @@ public class Config {
|
|||||||
private boolean eventmode = false;
|
private boolean eventmode = false;
|
||||||
private Map<String, Server> servers = Collections.emptyMap();
|
private Map<String, Server> servers = Collections.emptyMap();
|
||||||
private List<String> broadcasts = Collections.emptyList();
|
private List<String> broadcasts = Collections.emptyList();
|
||||||
|
private Poll poll = null;
|
||||||
|
|
||||||
public RegisteredServer lobbyserver() {
|
public RegisteredServer lobbyserver() {
|
||||||
return VelocityCore.getProxy().getServer(lobbyserver).orElseThrow();
|
return VelocityCore.getProxy().getServer(lobbyserver).orElseThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static class Poll {
|
||||||
|
private String question;
|
||||||
|
private List<String> answers;
|
||||||
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public static class Server {
|
public static class Server {
|
||||||
private int spectatePort = 0;
|
private int spectatePort = 0;
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import de.steamwar.velocitycore.commands.TeamCommand;
|
|||||||
import de.steamwar.velocitycore.discord.DiscordBot;
|
import de.steamwar.velocitycore.discord.DiscordBot;
|
||||||
import de.steamwar.velocitycore.discord.DiscordConfig;
|
import de.steamwar.velocitycore.discord.DiscordConfig;
|
||||||
import de.steamwar.velocitycore.listeners.BasicListener;
|
import de.steamwar.velocitycore.listeners.BasicListener;
|
||||||
|
import de.steamwar.velocitycore.listeners.PollSystem;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
@@ -134,6 +135,7 @@ public class VelocityCore implements ReloadablePlugin {
|
|||||||
schedule(TabCompletionCache::invalidateOldEntries).repeat(1, TimeUnit.SECONDS).schedule();
|
schedule(TabCompletionCache::invalidateOldEntries).repeat(1, TimeUnit.SECONDS).schedule();
|
||||||
|
|
||||||
initStaticServers();
|
initStaticServers();
|
||||||
|
PollSystem.init();
|
||||||
|
|
||||||
local = new Node.LocalNode();
|
local = new Node.LocalNode();
|
||||||
if(MAIN_SERVER) {
|
if(MAIN_SERVER) {
|
||||||
@@ -149,7 +151,6 @@ public class VelocityCore implements ReloadablePlugin {
|
|||||||
new PunishmentCommand("nodev", Punishment.PunishmentType.NoDevServer);
|
new PunishmentCommand("nodev", Punishment.PunishmentType.NoDevServer);
|
||||||
new PunishmentCommand("nofight", Punishment.PunishmentType.NoFightServer);
|
new PunishmentCommand("nofight", Punishment.PunishmentType.NoFightServer);
|
||||||
new PunishmentCommand("noteamserver", Punishment.PunishmentType.NoTeamServer);
|
new PunishmentCommand("noteamserver", Punishment.PunishmentType.NoTeamServer);
|
||||||
new PunishmentCommand("noevent", Punishment.PunishmentType.NoEvent);
|
|
||||||
new PunishmentCommand("note", Punishment.PunishmentType.Note);
|
new PunishmentCommand("note", Punishment.PunishmentType.Note);
|
||||||
|
|
||||||
linker = new AbstractLinker<>(this) {
|
linker = new AbstractLinker<>(this) {
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* 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 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.velocitycore.commands;
|
||||||
|
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.velocitycore.listeners.PollSystem;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeValidator;
|
||||||
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.sql.PollAnswer;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
public class PollCommand extends SWCommand {
|
||||||
|
|
||||||
|
public PollCommand() {
|
||||||
|
super("poll");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void genericCommand(@Validator Chatter sender) {
|
||||||
|
PollSystem.sendPoll(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register(noTabComplete = true)
|
||||||
|
public void answerPoll(@Validator Chatter sender, String answerString) {
|
||||||
|
int answer;
|
||||||
|
try {
|
||||||
|
answer = Integer.parseUnsignedInt(answerString);
|
||||||
|
if(answer < 1 || answer > PollSystem.answers())
|
||||||
|
throw new NumberFormatException();
|
||||||
|
}catch(NumberFormatException e){
|
||||||
|
sender.system("POLL_NO_ANSWER");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PollAnswer pollAnswer = PollAnswer.get(sender.user().getId());
|
||||||
|
if(pollAnswer.hasAnswered())
|
||||||
|
sender.system("POLL_ANSWER_REFRESH");
|
||||||
|
else
|
||||||
|
sender.system("POLL_ANSWER_NEW");
|
||||||
|
|
||||||
|
pollAnswer.setAnswer(answer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ClassValidator(value = Chatter.class, local = true)
|
||||||
|
public TypeValidator<Chatter> noPoll() {
|
||||||
|
return PollSystem.noPoll();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* 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 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.velocitycore.commands;
|
||||||
|
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.velocitycore.listeners.PollSystem;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeValidator;
|
||||||
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.sql.PollAnswer;
|
||||||
|
import de.steamwar.sql.UserPerm;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
public class PollresultCommand extends SWCommand {
|
||||||
|
|
||||||
|
public PollresultCommand() {
|
||||||
|
super("pollresult", UserPerm.MODERATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void genericCommand(@Validator Chatter sender) {
|
||||||
|
Map<Integer, Integer> voted = PollAnswer.getCurrentResults();
|
||||||
|
sender.system("POLLRESULT_HEADER", voted.values().stream().reduce(Integer::sum).orElse(0), PollAnswer.getCurrentPoll());
|
||||||
|
for (Map.Entry<Integer, Integer> e: voted.entrySet()) {
|
||||||
|
sender.prefixless("POLLRESULT_LIST", PollSystem.getAnswer(e.getKey()), e.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ClassValidator(value = Chatter.class, local = true)
|
||||||
|
public TypeValidator<Chatter> noPoll() {
|
||||||
|
return PollSystem.noPoll();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,7 +26,10 @@ import de.steamwar.command.SWCommand;
|
|||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.messages.Message;
|
import de.steamwar.messages.Message;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.sql.BannedUserIPs;
|
||||||
|
import de.steamwar.sql.Punishment;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import de.steamwar.sql.UserPerm;
|
||||||
import de.steamwar.velocitycore.VelocityCore;
|
import de.steamwar.velocitycore.VelocityCore;
|
||||||
import de.steamwar.velocitycore.listeners.IPSanitizer;
|
import de.steamwar.velocitycore.listeners.IPSanitizer;
|
||||||
|
|
||||||
@@ -210,11 +213,6 @@ public class PunishmentCommand {
|
|||||||
if(punishmentType == Punishment.PunishmentType.Ban)
|
if(punishmentType == Punishment.PunishmentType.Ban)
|
||||||
ban(target, banTime, msg, punisher, isPerma);
|
ban(target, banTime, msg, punisher, isPerma);
|
||||||
Chatter.serverteam().system(punishmentType.getTeamMessage(), target, sender, new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg);
|
Chatter.serverteam().system(punishmentType.getTeamMessage(), target, sender, new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg);
|
||||||
if (punishmentType == Punishment.PunishmentType.NoEvent) {
|
|
||||||
int teamId = target.getTeam();
|
|
||||||
if (teamId == 0) return;
|
|
||||||
TeamTeilnahme.deleteFuture(teamId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
|
|||||||
@@ -141,9 +141,6 @@ public class TeamCommand extends SWCommand {
|
|||||||
user.setTeam(t);
|
user.setTeam(t);
|
||||||
teamInvitations.remove(user.getId());
|
teamInvitations.remove(user.getId());
|
||||||
sender.system("TEAM_JOIN_JOINED", Team.byId(t).getTeamName());
|
sender.system("TEAM_JOIN_JOINED", Team.byId(t).getTeamName());
|
||||||
if (user.isPunished(Punishment.PunishmentType.NoEvent)) {
|
|
||||||
TeamTeilnahme.deleteFuture(t);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("stepback")
|
@Register("stepback")
|
||||||
@@ -204,9 +201,6 @@ public class TeamCommand extends SWCommand {
|
|||||||
|
|
||||||
invitations.add(team.getTeamId());
|
invitations.add(team.getTeamId());
|
||||||
sender.system("TEAM_INVITE_INVITED", target.getUserName());
|
sender.system("TEAM_INVITE_INVITED", target.getUserName());
|
||||||
if (target.isPunished(Punishment.PunishmentType.NoEvent)) {
|
|
||||||
sender.system("NOEVENT_INVITED_PUNISHED");
|
|
||||||
}
|
|
||||||
Chatter.of(target).system("TEAM_INVITE_INVITED_TARGET", team.getTeamColor(), team.getTeamName());
|
Chatter.of(target).system("TEAM_INVITE_INVITED_TARGET", team.getTeamColor(), team.getTeamName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,12 +422,6 @@ public class TeamCommand extends SWCommand {
|
|||||||
TeamTeilnahme.notTeilnehmen(team.getTeamId(), event.getEventID());
|
TeamTeilnahme.notTeilnehmen(team.getTeamId(), event.getEventID());
|
||||||
sender.system("TEAM_EVENT_LEFT");
|
sender.system("TEAM_EVENT_LEFT");
|
||||||
}else{
|
}else{
|
||||||
if (team.getMembers().stream().anyMatch(integer -> {
|
|
||||||
return SteamwarUser.get(integer).isPunished(Punishment.PunishmentType.NoEvent);
|
|
||||||
})) {
|
|
||||||
sender.system("NOEVENT_PLAYER_PUNISHED");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
TeamTeilnahme.teilnehmen(team.getTeamId(), event.getEventID());
|
TeamTeilnahme.teilnehmen(team.getTeamId(), event.getEventID());
|
||||||
sender.system("TEAM_EVENT_JOINED", event.getEventName());
|
sender.system("TEAM_EVENT_JOINED", event.getEventName());
|
||||||
sender.prefixless("TEAM_EVENT_HOW_TO_LEAVE");
|
sender.prefixless("TEAM_EVENT_HOW_TO_LEAVE");
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ import de.steamwar.sql.Team;
|
|||||||
import de.steamwar.sql.TeamTeilnahme;
|
import de.steamwar.sql.TeamTeilnahme;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
|
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||||
|
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||||
|
import net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu;
|
||||||
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -51,6 +54,12 @@ public class EventChannel {
|
|||||||
.setTitle("Zukünftige Events")
|
.setTitle("Zukünftige Events")
|
||||||
.setAuthor("SteamWar", "https://www.steamwar.de");
|
.setAuthor("SteamWar", "https://www.steamwar.de");
|
||||||
|
|
||||||
|
|
||||||
|
StringSelectMenu.Builder menuBuilder = StringSelectMenu.create("eventName")
|
||||||
|
.setPlaceholder("Wähle ein Event aus!")
|
||||||
|
.setMinValues(1)
|
||||||
|
.setMaxValues(1);
|
||||||
|
|
||||||
Timestamp now = Timestamp.from(Instant.now());
|
Timestamp now = Timestamp.from(Instant.now());
|
||||||
List<Event> events = Event.getComing();
|
List<Event> events = Event.getComing();
|
||||||
events.forEach(event -> {
|
events.forEach(event -> {
|
||||||
@@ -64,10 +73,18 @@ public class EventChannel {
|
|||||||
st.append("\nAngemeldete Teams: ").append(teilname);
|
st.append("\nAngemeldete Teams: ").append(teilname);
|
||||||
}
|
}
|
||||||
embedBuilder.addField(event.getEventName(), st.toString(), false);
|
embedBuilder.addField(event.getEventName(), st.toString(), false);
|
||||||
|
if(event.getDeadline().after(Timestamp.from(Instant.now()))) {
|
||||||
|
menuBuilder.addOption(event.getEventName(), event.getEventID() + "", "An " + event.getEventName() + " teilnehmen", Emoji.fromUnicode("U+1F4DD"));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return new MessageCreateBuilder()
|
MessageCreateBuilder messageBuilder = new MessageCreateBuilder()
|
||||||
.setEmbeds(embedBuilder.build());
|
.setEmbeds(embedBuilder.build());
|
||||||
|
|
||||||
|
if(events.stream().anyMatch(event -> event.getDeadline().after(Timestamp.from(Instant.now())))) {
|
||||||
|
messageBuilder.setComponents(ActionRow.of(menuBuilder.build()));
|
||||||
|
}
|
||||||
|
return messageBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MessageCreateBuilder updateCurrent() {
|
private MessageCreateBuilder updateCurrent() {
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* 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 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.velocitycore.listeners;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.connection.PostLoginEvent;
|
||||||
|
import de.steamwar.velocitycore.Config;
|
||||||
|
import de.steamwar.velocitycore.VelocityCore;
|
||||||
|
import de.steamwar.command.TypeValidator;
|
||||||
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.messages.Message;
|
||||||
|
import de.steamwar.sql.PollAnswer;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
|
||||||
|
public class PollSystem extends BasicListener {
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
poll = VelocityCore.get().getConfig().getPoll();
|
||||||
|
if(poll == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(noCurrentPoll())
|
||||||
|
return;
|
||||||
|
|
||||||
|
PollAnswer.setCurrentPoll(poll.getQuestion());
|
||||||
|
new PollSystem();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Config.Poll poll = null;
|
||||||
|
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onPostLogin(PostLoginEvent event){
|
||||||
|
Chatter player = Chatter.of(event.getPlayer());
|
||||||
|
|
||||||
|
PollAnswer answer = PollAnswer.get(player.user().getId());
|
||||||
|
if(answer.hasAnswered())
|
||||||
|
return;
|
||||||
|
|
||||||
|
sendPoll(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendPoll(Chatter player) {
|
||||||
|
player.system("POLL_HEADER");
|
||||||
|
player.prefixless("POLL_HEADER2");
|
||||||
|
player.prefixless("POLL_QUESTION", poll.getQuestion());
|
||||||
|
|
||||||
|
for(int i = 1; i <= poll.getAnswers().size(); i++) {
|
||||||
|
player.prefixless("POLL_ANSWER", new Message("POLL_ANSWER_HOVER", poll.getAnswers().get(i-1)), ClickEvent.runCommand("/poll " + i), poll.getAnswers().get(i-1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean noCurrentPoll(){
|
||||||
|
return poll == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TypeValidator<Chatter> noPoll() {
|
||||||
|
return (sender, value, messageSender) -> {
|
||||||
|
if (PollSystem.noCurrentPoll()) {
|
||||||
|
messageSender.send("POLL_NO_POLL");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int answers(){
|
||||||
|
return poll.getAnswers().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getAnswer(int i) {
|
||||||
|
return poll.getAnswers().get(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,12 +20,9 @@
|
|||||||
package de.steamwar
|
package de.steamwar
|
||||||
|
|
||||||
import de.steamwar.plugins.configurePlugins
|
import de.steamwar.plugins.configurePlugins
|
||||||
import de.steamwar.routes.ResponseUser
|
|
||||||
import de.steamwar.routes.SchematicCode
|
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
import io.ktor.server.engine.*
|
import io.ktor.server.engine.*
|
||||||
import de.steamwar.routes.configureRoutes
|
import de.steamwar.routes.configureRoutes
|
||||||
import de.steamwar.sql.SchematicType
|
|
||||||
import de.steamwar.sql.SteamwarUser
|
import de.steamwar.sql.SteamwarUser
|
||||||
import io.ktor.server.netty.*
|
import io.ktor.server.netty.*
|
||||||
import kotlinx.serialization.ExperimentalSerializationApi
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
@@ -47,7 +44,6 @@ fun main() {
|
|||||||
Thread {
|
Thread {
|
||||||
while (true) {
|
while (true) {
|
||||||
Thread.sleep(1000 * 10)
|
Thread.sleep(1000 * 10)
|
||||||
ResponseUser.clearCache()
|
|
||||||
SteamwarUser.clear()
|
SteamwarUser.clear()
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
|
|||||||
@@ -0,0 +1,215 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* 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 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.routes
|
||||||
|
|
||||||
|
import de.steamwar.plugins.SWPermissionCheck
|
||||||
|
import de.steamwar.sql.AuditLog
|
||||||
|
import de.steamwar.sql.AuditLogTable
|
||||||
|
import de.steamwar.sql.SteamwarUserTable
|
||||||
|
import de.steamwar.sql.UserPerm
|
||||||
|
import de.steamwar.sql.internal.useDb
|
||||||
|
import io.ktor.server.application.call
|
||||||
|
import io.ktor.server.application.install
|
||||||
|
import io.ktor.server.response.respond
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
import io.ktor.server.routing.get
|
||||||
|
import io.ktor.server.routing.route
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import org.jetbrains.exposed.v1.core.Alias
|
||||||
|
import org.jetbrains.exposed.v1.core.JoinType
|
||||||
|
import org.jetbrains.exposed.v1.core.SortOrder
|
||||||
|
import org.jetbrains.exposed.v1.core.alias
|
||||||
|
import org.jetbrains.exposed.v1.core.greater
|
||||||
|
import org.jetbrains.exposed.v1.core.inList
|
||||||
|
import org.jetbrains.exposed.v1.core.isNull
|
||||||
|
import org.jetbrains.exposed.v1.core.less
|
||||||
|
import org.jetbrains.exposed.v1.core.like
|
||||||
|
import org.jetbrains.exposed.v1.core.or
|
||||||
|
import org.jetbrains.exposed.v1.jdbc.Query
|
||||||
|
import org.jetbrains.exposed.v1.jdbc.andWhere
|
||||||
|
import org.jetbrains.exposed.v1.jdbc.select
|
||||||
|
import org.jetbrains.exposed.v1.jdbc.selectAll
|
||||||
|
import java.time.Instant
|
||||||
|
|
||||||
|
fun Route.configureAuditLog() {
|
||||||
|
route("/auditlog") {
|
||||||
|
install(SWPermissionCheck) {
|
||||||
|
mustAuth = true
|
||||||
|
permission = UserPerm.MODERATION
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
val text = call.request.queryParameters["fullText"]
|
||||||
|
val actionText = call.request.queryParameters["actionText"]
|
||||||
|
val serverText = call.request.queryParameters["server"]
|
||||||
|
val actor = call.request.queryParameters.getAll("actor")?.map { it.toInt() }?.toSet()
|
||||||
|
val actionType =
|
||||||
|
call.request.queryParameters.getAll("actionType")?.map { AuditLog.Type.valueOf(it) }?.toSet()
|
||||||
|
val timeGreater = call.request.queryParameters["timeGreater"]?.let { Instant.ofEpochMilli(it.toLong()) }
|
||||||
|
val timeLess = call.request.queryParameters["timeLess"]?.let { Instant.ofEpochMilli(it.toLong()) }
|
||||||
|
|
||||||
|
val serverOwner = call.request.queryParameters.getAll("serverOwner")?.map { it.toInt() }?.toSet()
|
||||||
|
val velocity = call.request.queryParameters["velocity"]?.toBoolean()
|
||||||
|
|
||||||
|
val page = call.request.queryParameters["page"]?.toIntOrNull() ?: 0
|
||||||
|
val limit = call.request.queryParameters["limit"]?.toIntOrNull() ?: 100
|
||||||
|
val sorting = call.request.queryParameters["sorting"] ?: "DESC"
|
||||||
|
|
||||||
|
call.respond(
|
||||||
|
PagedAuditLog.filter(
|
||||||
|
actionText,
|
||||||
|
serverText,
|
||||||
|
text,
|
||||||
|
actor,
|
||||||
|
actionType,
|
||||||
|
timeGreater,
|
||||||
|
timeLess,
|
||||||
|
serverOwner,
|
||||||
|
velocity,
|
||||||
|
page,
|
||||||
|
limit,
|
||||||
|
sorting
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class PagedAuditLog(val rows: Long, val entries: List<AuditLogEntry>) {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun filter(
|
||||||
|
actionText: String? = null,
|
||||||
|
serverText: String? = null,
|
||||||
|
fullText: String? = null,
|
||||||
|
actor: Set<Int>? = null,
|
||||||
|
actionType: Set<AuditLog.Type>? = null,
|
||||||
|
timeGreater: Instant? = null,
|
||||||
|
timeLess: Instant? = null,
|
||||||
|
serverOwner: Set<Int>? = null,
|
||||||
|
velocity: Boolean? = null,
|
||||||
|
page: Int = 0,
|
||||||
|
limit: Int = 100,
|
||||||
|
sorting: String = "DESC"
|
||||||
|
) = useDb {
|
||||||
|
val actorTable = SteamwarUserTable.alias("actor")
|
||||||
|
val serverOwnerTable = SteamwarUserTable.alias("serverOwner")
|
||||||
|
|
||||||
|
val query = AuditLogTable.join(
|
||||||
|
actorTable,
|
||||||
|
JoinType.INNER,
|
||||||
|
onColumn = actorTable[SteamwarUserTable.id],
|
||||||
|
otherColumn = AuditLogTable.actor
|
||||||
|
)
|
||||||
|
.join(
|
||||||
|
serverOwnerTable,
|
||||||
|
JoinType.LEFT,
|
||||||
|
onColumn = serverOwnerTable[SteamwarUserTable.id],
|
||||||
|
otherColumn = AuditLogTable.serverOwner
|
||||||
|
)
|
||||||
|
.select(
|
||||||
|
actorTable[SteamwarUserTable.username], serverOwnerTable[SteamwarUserTable.username],
|
||||||
|
*AuditLogTable.columns.toTypedArray()
|
||||||
|
)
|
||||||
|
|
||||||
|
PagedAuditLog(
|
||||||
|
AuditLogTable.selectAll().addAuditLogFilters(
|
||||||
|
actionText,
|
||||||
|
serverText,
|
||||||
|
fullText,
|
||||||
|
actor,
|
||||||
|
actionType,
|
||||||
|
timeGreater,
|
||||||
|
timeLess,
|
||||||
|
serverOwner,
|
||||||
|
velocity
|
||||||
|
).count(),
|
||||||
|
query
|
||||||
|
.addAuditLogFilters(
|
||||||
|
actionText,
|
||||||
|
serverText,
|
||||||
|
fullText,
|
||||||
|
actor,
|
||||||
|
actionType,
|
||||||
|
timeGreater,
|
||||||
|
timeLess,
|
||||||
|
serverOwner,
|
||||||
|
velocity
|
||||||
|
)
|
||||||
|
.limit(limit)
|
||||||
|
.offset((page * limit).toLong())
|
||||||
|
.orderBy(AuditLogTable.time, SortOrder.valueOf(sorting.uppercase()))
|
||||||
|
.map {
|
||||||
|
AuditLogEntry(
|
||||||
|
it[AuditLogTable.id].value,
|
||||||
|
it[AuditLogTable.time].toEpochMilli(),
|
||||||
|
it[AuditLogTable.server],
|
||||||
|
it[serverOwnerTable[SteamwarUserTable.username]],
|
||||||
|
it[actorTable[SteamwarUserTable.username]],
|
||||||
|
it[AuditLogTable.action],
|
||||||
|
it[AuditLogTable.actionText]
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Query.addAuditLogFilters(
|
||||||
|
actionText: String? = null,
|
||||||
|
serverText: String? = null,
|
||||||
|
fullText: String? = null,
|
||||||
|
actor: Set<Int>? = null,
|
||||||
|
actionType: Set<AuditLog.Type>? = null,
|
||||||
|
timeGreater: Instant? = null,
|
||||||
|
timeLess: Instant? = null,
|
||||||
|
serverOwner: Set<Int>? = null,
|
||||||
|
velocity: Boolean? = null,
|
||||||
|
): Query {
|
||||||
|
actionText?.let {
|
||||||
|
andWhere { (AuditLogTable.actionText like "%$it%") }
|
||||||
|
}
|
||||||
|
serverText?.let {
|
||||||
|
andWhere { (AuditLogTable.server like "%$it%") }
|
||||||
|
}
|
||||||
|
fullText?.let {
|
||||||
|
andWhere { (AuditLogTable.actionText like "%$it%") or (AuditLogTable.server like "%$it%") }
|
||||||
|
}
|
||||||
|
actor?.let { andWhere { AuditLogTable.actor inList actor } }
|
||||||
|
actionType?.let { andWhere { AuditLogTable.action inList actionType } }
|
||||||
|
timeGreater?.let { andWhere { AuditLogTable.time greater timeGreater } }
|
||||||
|
timeLess?.let { andWhere { AuditLogTable.time less timeLess } }
|
||||||
|
serverOwner?.let { andWhere { AuditLogTable.serverOwner inList serverOwner } }
|
||||||
|
if (velocity == true) andWhere { AuditLogTable.serverOwner.isNull() }
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class AuditLogEntry(
|
||||||
|
val id: Int,
|
||||||
|
val time: Long,
|
||||||
|
val server: String,
|
||||||
|
val serverOwner: String?,
|
||||||
|
val actor: String,
|
||||||
|
val actionType: AuditLog.Type,
|
||||||
|
val actionText: String
|
||||||
|
)
|
||||||
@@ -66,7 +66,7 @@ fun Route.configureAuth() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
call.sessions.set(SWUserSession(user.getId()))
|
call.sessions.set(SWUserSession(user.getId()))
|
||||||
call.respond(ResponseUser.get(user))
|
call.respond(ResponseUser(user))
|
||||||
}
|
}
|
||||||
|
|
||||||
delete {
|
delete {
|
||||||
@@ -100,7 +100,7 @@ fun Route.configureAuth() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
call.sessions.set(SWUserSession(user.getId()))
|
call.sessions.set(SWUserSession(user.getId()))
|
||||||
call.respond(ResponseUser.get(user))
|
call.respond(ResponseUser(user))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import de.steamwar.plugins.SWAuthPrincipal
|
|||||||
import de.steamwar.plugins.SWPermissionCheck
|
import de.steamwar.plugins.SWPermissionCheck
|
||||||
import de.steamwar.sql.SchematicType
|
import de.steamwar.sql.SchematicType
|
||||||
import de.steamwar.sql.SteamwarUser
|
import de.steamwar.sql.SteamwarUser
|
||||||
|
import de.steamwar.sql.SteamwarUserTable
|
||||||
import de.steamwar.sql.Team
|
import de.steamwar.sql.Team
|
||||||
import de.steamwar.sql.UserPerm
|
import de.steamwar.sql.UserPerm
|
||||||
import de.steamwar.sql.internal.useDb
|
import de.steamwar.sql.internal.useDb
|
||||||
@@ -36,6 +37,13 @@ import io.ktor.server.response.*
|
|||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import org.bspfsystems.yamlconfiguration.file.YamlConfiguration
|
import org.bspfsystems.yamlconfiguration.file.YamlConfiguration
|
||||||
|
import org.jetbrains.exposed.v1.core.ResultRow
|
||||||
|
import org.jetbrains.exposed.v1.core.eq
|
||||||
|
import org.jetbrains.exposed.v1.core.inList
|
||||||
|
import org.jetbrains.exposed.v1.core.like
|
||||||
|
import org.jetbrains.exposed.v1.jdbc.Query
|
||||||
|
import org.jetbrains.exposed.v1.jdbc.andWhere
|
||||||
|
import org.jetbrains.exposed.v1.jdbc.selectAll
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.InetSocketAddress
|
import java.net.InetSocketAddress
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -44,28 +52,39 @@ import java.util.*
|
|||||||
data class ResponseSchematicType(val name: String, val db: String)
|
data class ResponseSchematicType(val name: String, val db: String)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ResponseUser(val name: String, val uuid: String, val prefix: String, val perms: List<String>) {
|
data class ResponseUser(
|
||||||
private constructor(user: SteamwarUser) : this(user.userName, user.uuid.toString(), user.prefix().chatPrefix, user.perms().filter { !it.name.startsWith("PREFIX_") }.map { it.name })
|
val name: String, val uuid: String, val id: Int?, val perms: List<String>?, val prefix: String?
|
||||||
|
) {
|
||||||
|
constructor(user: SteamwarUser, includeId: Boolean = false, includePerms: Boolean = false) : this(
|
||||||
|
user.userName,
|
||||||
|
user.uuid.toString(),
|
||||||
|
if (includeId) user.getId() else null,
|
||||||
|
if (includePerms) user.perms().map { it.name } else null,
|
||||||
|
if (includePerms) user.prefix().chatPrefix else null,
|
||||||
|
)
|
||||||
|
|
||||||
companion object {
|
constructor(row: ResultRow, includeId: Boolean = false, includePerms: Boolean = false, prefixes: MutableSet<UserPerm> = mutableSetOf()) : this(
|
||||||
private val cache = mutableMapOf<Int, ResponseUser>()
|
row[SteamwarUserTable.username],
|
||||||
|
row[SteamwarUserTable.uuid],
|
||||||
|
if (includeId) row[SteamwarUserTable.id].value else null,
|
||||||
|
if (includePerms) UserPerm.getPerms(row[SteamwarUserTable.id].value).also { prefixes.addAll(it) }.map { it.name } else null,
|
||||||
|
if (includePerms) prefixes.firstOrNull { UserPerm.prefixes.containsKey(it) }?.let { UserPerm.prefixes[it]!!.chatPrefix } else null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun get(id: Int): ResponseUser {
|
@Serializable
|
||||||
synchronized(cache) {
|
data class ResponseUserList(val entries: List<ResponseUser>, val rows: Long)
|
||||||
return cache[id] ?: ResponseUser(SteamwarUser.byId(id)!!).also { cache[id] = it }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun get(user: SteamwarUser): ResponseUser = synchronized(cache) {
|
private fun Query.addUserFilter(
|
||||||
return cache[user.getId()] ?: ResponseUser(user).also { cache[user.getId()] = it }
|
name: String? = null,
|
||||||
}
|
uuid: UUID? = null,
|
||||||
|
team: Set<Int>? = null,
|
||||||
|
): Query {
|
||||||
|
name?.let { andWhere { (SteamwarUserTable.username like "%$it%") } }
|
||||||
|
uuid?.let { andWhere { (SteamwarUserTable.uuid eq it.toString()) } }
|
||||||
|
team?.let { andWhere { (SteamwarUserTable.team inList team) } }
|
||||||
|
|
||||||
fun clearCache() {
|
return this
|
||||||
synchronized(cache) {
|
|
||||||
cache.clear()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Route.configureDataRoutes() {
|
fun Route.configureDataRoutes() {
|
||||||
@@ -76,13 +95,33 @@ fun Route.configureDataRoutes() {
|
|||||||
permission = UserPerm.MODERATION
|
permission = UserPerm.MODERATION
|
||||||
}
|
}
|
||||||
get("/users") {
|
get("/users") {
|
||||||
call.respond(useDb { SteamwarUser.all().map { ResponseUser.get(it) } })
|
val name = call.request.queryParameters["name"]
|
||||||
|
val uuid = call.request.queryParameters["uuid"]?.let { catchException { UUID.fromString(it) } }
|
||||||
|
val team = call.request.queryParameters.getAll("team")?.map { it.toInt() }?.toSet()
|
||||||
|
|
||||||
|
val limit = call.request.queryParameters["limit"]?.toIntOrNull() ?: 100
|
||||||
|
val page = call.request.queryParameters["page"]?.toIntOrNull() ?: 0
|
||||||
|
|
||||||
|
val includePerms = call.request.queryParameters["includePerms"]?.toBoolean() ?: false
|
||||||
|
val includeId = call.request.queryParameters["includeId"]?.toBoolean() ?: false
|
||||||
|
|
||||||
|
call.respond(
|
||||||
|
useDb {
|
||||||
|
ResponseUserList(
|
||||||
|
SteamwarUserTable.selectAll().addUserFilter(name, uuid, team).limit(limit)
|
||||||
|
.offset((page * limit).toLong())
|
||||||
|
.map { ResponseUser(it, includeId, includePerms) },
|
||||||
|
SteamwarUserTable.selectAll().addUserFilter(name, uuid, team).count()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
get("/teams") {
|
get("/teams") {
|
||||||
call.respond(Team.getAll().map { ResponseTeam(it) })
|
call.respond(Team.getAll().map { ResponseTeam(it) })
|
||||||
}
|
}
|
||||||
get("/schematicTypes") {
|
get("/schematicTypes") {
|
||||||
call.respond(SchematicType.values().filter { !it.check() }.map { ResponseSchematicType(it.name(), it.toDB()) })
|
call.respond(SchematicType.values().filter { !it.check() }
|
||||||
|
.map { ResponseSchematicType(it.name(), it.toDB()) })
|
||||||
}
|
}
|
||||||
get("/gamemodes") {
|
get("/gamemodes") {
|
||||||
call.respond(
|
call.respond(
|
||||||
@@ -116,11 +155,14 @@ fun Route.configureDataRoutes() {
|
|||||||
}
|
}
|
||||||
get("/team") {
|
get("/team") {
|
||||||
call.respond(
|
call.respond(
|
||||||
listOf(UserPerm.PREFIX_ADMIN, UserPerm.PREFIX_DEVELOPER, UserPerm.PREFIX_MODERATOR, UserPerm.PREFIX_SUPPORTER, UserPerm.PREFIX_BUILDER)
|
listOf(
|
||||||
.associateWith { SteamwarUser.getUsersWithPerm(it) }
|
UserPerm.PREFIX_ADMIN,
|
||||||
.mapKeys { UserPerm.prefixes[it.key]!!.chatPrefix }
|
UserPerm.PREFIX_DEVELOPER,
|
||||||
.mapValues { it.value.map { ResponseUser.get(it) } }
|
UserPerm.PREFIX_MODERATOR,
|
||||||
)
|
UserPerm.PREFIX_SUPPORTER,
|
||||||
|
UserPerm.PREFIX_BUILDER
|
||||||
|
).associateWith { SteamwarUser.getUsersWithPerm(it) }.mapKeys { UserPerm.prefixes[it.key]!!.chatPrefix }
|
||||||
|
.mapValues { it.value.map { ResponseUser(it) } })
|
||||||
}
|
}
|
||||||
get("/skin/{uuid}") {
|
get("/skin/{uuid}") {
|
||||||
val uuid = call.parameters["uuid"]
|
val uuid = call.parameters["uuid"]
|
||||||
@@ -138,7 +180,7 @@ fun Route.configureDataRoutes() {
|
|||||||
route("/me") {
|
route("/me") {
|
||||||
install(SWPermissionCheck)
|
install(SWPermissionCheck)
|
||||||
get {
|
get {
|
||||||
call.respond(ResponseUser.get(call.principal<SWAuthPrincipal>()!!.user))
|
call.respond(ResponseUser(call.principal<SWAuthPrincipal>()!!.user, includePerms = true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ fun Route.configureEventRefereesRouting() {
|
|||||||
route("/referees") {
|
route("/referees") {
|
||||||
get {
|
get {
|
||||||
val event = call.receiveEvent() ?: return@get
|
val event = call.receiveEvent() ?: return@get
|
||||||
call.respond(Referee.get(event.eventID).map { ResponseUser.get(SteamwarUser.byId(it)!!) })
|
call.respond(Referee.get(event.eventID).map { ResponseUser(SteamwarUser.byId(it)!!) })
|
||||||
}
|
}
|
||||||
put {
|
put {
|
||||||
val event = call.receiveEvent() ?: return@put
|
val event = call.receiveEvent() ?: return@put
|
||||||
@@ -39,7 +39,7 @@ fun Route.configureEventRefereesRouting() {
|
|||||||
referees.forEach {
|
referees.forEach {
|
||||||
Referee.add(event.eventID, SteamwarUser.get(UUID.fromString(it))!!.getId())
|
Referee.add(event.eventID, SteamwarUser.get(UUID.fromString(it))!!.getId())
|
||||||
}
|
}
|
||||||
call.respond(Referee.get(event.eventID).map { ResponseUser.get(SteamwarUser.byId(it)!!) })
|
call.respond(Referee.get(event.eventID).map { ResponseUser(SteamwarUser.byId(it)!!) })
|
||||||
}
|
}
|
||||||
delete {
|
delete {
|
||||||
val event = call.receiveEvent() ?: return@delete
|
val event = call.receiveEvent() ?: return@delete
|
||||||
@@ -47,7 +47,7 @@ fun Route.configureEventRefereesRouting() {
|
|||||||
referees.forEach {
|
referees.forEach {
|
||||||
Referee.remove(event.eventID, SteamwarUser.get(UUID.fromString(it))!!.getId())
|
Referee.remove(event.eventID, SteamwarUser.get(UUID.fromString(it))!!.getId())
|
||||||
}
|
}
|
||||||
call.respond(Referee.get(event.eventID).map { ResponseUser.get(SteamwarUser.byId(it)!!) })
|
call.respond(Referee.get(event.eventID).map { ResponseUser(SteamwarUser.byId(it)!!) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ data class ExtendedResponseEvent(
|
|||||||
TeamTeilnahme.getTeams(event.eventID).map { ResponseTeam(it) },
|
TeamTeilnahme.getTeams(event.eventID).map { ResponseTeam(it) },
|
||||||
EventGroup.get(event).map { ResponseGroups(it) },
|
EventGroup.get(event).map { ResponseGroups(it) },
|
||||||
EventFight.getEvent(event.eventID).map { ResponseEventFight(it) },
|
EventFight.getEvent(event.eventID).map { ResponseEventFight(it) },
|
||||||
Referee.get(event.eventID).map { ResponseUser.get(SteamwarUser.byId(it)!!) },
|
Referee.get(event.eventID).map { ResponseUser(SteamwarUser.byId(it)!!) },
|
||||||
EventRelation.get(event).map { ResponseRelation(it) }
|
EventRelation.get(event).map { ResponseRelation(it) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ fun Application.configureRoutes() {
|
|||||||
configurePage()
|
configurePage()
|
||||||
configureSchematic()
|
configureSchematic()
|
||||||
configureAuth()
|
configureAuth()
|
||||||
|
configureAuditLog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,9 +34,7 @@ import io.ktor.server.response.*
|
|||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import java.io.BufferedInputStream
|
import java.io.BufferedInputStream
|
||||||
import java.io.ByteArrayInputStream
|
|
||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
import java.io.InputStream
|
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
@@ -49,16 +47,6 @@ data class ResponseSchematic(val name: String, val id: Int, val type: String?, v
|
|||||||
constructor(node: SchematicNode) : this(node.name, node.getId(), node.schemtype?.name(), node.owner, node.item, node.lastUpdate.time, node.rank, node.replaceColor(), node.allowReplay())
|
constructor(node: SchematicNode) : this(node.name, node.getId(), node.schemtype?.name(), node.owner, node.item, node.lastUpdate.time, node.rank, node.replaceColor(), node.allowReplay())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class ResponseSchematicLong(val members: List<ResponseUser>, val path: String, val schem: ResponseSchematic) {
|
|
||||||
constructor(node: SchematicNode, path: String): this(NodeMember.getNodeMembers(node.getId()).map { ResponseUser.get(it.member) }, path, ResponseSchematic(node))
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class ResponseSchematicList(val breadcrumbs: List<ResponseBreadcrumb>, val schematics: List<ResponseSchematic>, val players: Map<String, ResponseUser>) {
|
|
||||||
constructor(schematics: List<ResponseSchematic>, breadcrumbs: List<ResponseBreadcrumb>) : this(breadcrumbs, schematics, schematics.map { it.owner }.distinct().map { ResponseUser.get(it) }.associateBy { it.uuid })
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ResponseBreadcrumb(val name: String, val id: Int)
|
data class ResponseBreadcrumb(val name: String, val id: Int)
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,17 @@ import de.steamwar.plugins.SWPermissionCheck
|
|||||||
import de.steamwar.plugins.getUser
|
import de.steamwar.plugins.getUser
|
||||||
import de.steamwar.sql.SteamwarUser
|
import de.steamwar.sql.SteamwarUser
|
||||||
import de.steamwar.sql.UserPerm
|
import de.steamwar.sql.UserPerm
|
||||||
import io.ktor.http.*
|
import io.ktor.http.HttpStatusCode
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.ApplicationCall
|
||||||
import io.ktor.server.response.*
|
import io.ktor.server.application.call
|
||||||
import io.ktor.server.routing.*
|
import io.ktor.server.application.install
|
||||||
import kotlinx.serialization.Serializable
|
import io.ktor.server.response.respond
|
||||||
|
import io.ktor.server.routing.Route
|
||||||
|
import io.ktor.server.routing.delete
|
||||||
|
import io.ktor.server.routing.get
|
||||||
|
import io.ktor.server.routing.put
|
||||||
|
import io.ktor.server.routing.route
|
||||||
|
import kotlinx.serialization.Serializable;
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RespondPrefix(val name: String, val colorCode: String, val chatPrefix: String)
|
data class RespondPrefix(val name: String, val colorCode: String, val chatPrefix: String)
|
||||||
@@ -76,7 +82,12 @@ fun Route.configureUserPerms() {
|
|||||||
|
|
||||||
val prefixs = UserPerm.prefixes[prefix]!!
|
val prefixs = UserPerm.prefixes[prefix]!!
|
||||||
|
|
||||||
call.respond(RespondUserPermsPrefix(RespondPrefix(prefix.name, prefixs.colorCode, prefixs.chatPrefix), perms))
|
call.respond(
|
||||||
|
RespondUserPermsPrefix(
|
||||||
|
RespondPrefix(prefix.name, prefixs.colorCode, prefixs.chatPrefix),
|
||||||
|
perms
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
put("/prefix/{prefix}") {
|
put("/prefix/{prefix}") {
|
||||||
val (user, prefix) = call.receivePermission("prefix", isPrefix = true) ?: return@put
|
val (user, prefix) = call.receivePermission("prefix", isPrefix = true) ?: return@put
|
||||||
@@ -112,7 +123,10 @@ fun Route.configureUserPerms() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun ApplicationCall.receivePermission(fieldName: String = "perm", isPrefix: Boolean = false): Pair<SteamwarUser, UserPerm>? {
|
suspend fun ApplicationCall.receivePermission(
|
||||||
|
fieldName: String = "perm",
|
||||||
|
isPrefix: Boolean = false
|
||||||
|
): Pair<SteamwarUser, UserPerm>? {
|
||||||
val user = request.getUser()
|
val user = request.getUser()
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
respond(HttpStatusCode.BadRequest)
|
respond(HttpStatusCode.BadRequest)
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ dependencyResolutionManagement {
|
|||||||
library("paperapi", "io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT")
|
library("paperapi", "io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT")
|
||||||
library("paperapi21", "io.papermc.paper:paper-api:1.21.6-R0.1-SNAPSHOT")
|
library("paperapi21", "io.papermc.paper:paper-api:1.21.6-R0.1-SNAPSHOT")
|
||||||
library("authlib", "com.mojang:authlib:1.5.25")
|
library("authlib", "com.mojang:authlib:1.5.25")
|
||||||
library("authlib2", "com.mojang:authlib:6.0.58")
|
|
||||||
library("datafixer", "com.mojang:datafixerupper:4.0.26")
|
library("datafixer", "com.mojang:datafixerupper:4.0.26")
|
||||||
library("brigadier", "com.mojang:brigadier:1.0.18")
|
library("brigadier", "com.mojang:brigadier:1.0.18")
|
||||||
library("anvilgui", "net.wesjd:anvilgui:1.10.6-SNAPSHOT")
|
library("anvilgui", "net.wesjd:anvilgui:1.10.6-SNAPSHOT")
|
||||||
|
|||||||
Reference in New Issue
Block a user