From 76421fe12d379f073e67059254e16b0ccec0117b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=BB=E9=AD=82=E5=9C=A3=E4=BD=BF?= Date: Fri, 20 Dec 2024 10:43:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=95=E5=85=A5=E5=A2=93=E7=A2=91=E6=9C=BA?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../Commands/ZbCommand.java | 21 +- .../CoordinateRecorder.java | 20 ++ .../Listener/PlayerEventListener.java | 188 ++++++++++++ .../coordinateRecorder/data/Database.java | 98 ++++--- .../coordinateRecorder/data/PlayerData.java | 54 ++++ .../java/ling/database/DefaultSchema.java | 7 + src/main/java/ling/database/Indexes.java | 2 + src/main/java/ling/database/Keys.java | 3 + src/main/java/ling/database/Tables.java | 6 + .../ling/database/tables/TombstoneTB.java | 269 ++++++++++++++++++ .../database/tables/pojos/TombstoneBO.java | 264 +++++++++++++++++ .../database/tables/records/TombstonePO.java | 191 +++++++++++++ 13 files changed, 1081 insertions(+), 44 deletions(-) create mode 100644 src/main/java/ling/database/tables/TombstoneTB.java create mode 100644 src/main/java/ling/database/tables/pojos/TombstoneBO.java create mode 100644 src/main/java/ling/database/tables/records/TombstonePO.java diff --git a/pom.xml b/pom.xml index 2db37fd..a43abc9 100644 --- a/pom.xml +++ b/pom.xml @@ -72,7 +72,7 @@ org.jooq.meta.sqlite.SQLiteDatabase - Version|LocationNotepad|PlayerSettings + Version|LocationNotepad|PlayerSettings|Tombstone diff --git a/src/main/java/ling/coordinateRecorder/Commands/ZbCommand.java b/src/main/java/ling/coordinateRecorder/Commands/ZbCommand.java index a9d2ecd..4433baa 100644 --- a/src/main/java/ling/coordinateRecorder/Commands/ZbCommand.java +++ b/src/main/java/ling/coordinateRecorder/Commands/ZbCommand.java @@ -28,7 +28,7 @@ import static ling.database.tables.LocationnotepadTB.LOCATIONNOTEPAD; public class ZbCommand implements CommandExecutor, TabCompleter { protected final static List TAB_1 = Arrays.asList("add", "remove", "help", "reload", "list", "fixed", - "unfixed"); + "unfixed", "unlock"); public ZbCommand() { @@ -115,6 +115,20 @@ public class ZbCommand implements CommandExecutor, TabCompleter { player.sendMessage("当前第" + page + "页,共" + pageCount + "页"); } + @SuppressWarnings("DuplicatedCode") + protected void unlock(Player player, String[] strings) { + if (strings.length > 1) { + player.sendMessage(ChatColor.RED + "命令过长"); + return; + } + PlayerData data = PlayerMap.getCurrent().getPlayerData(player); + if (data == null) { + player.sendMessage(ChatColor.RED + "玩家未登录"); + return; + } + data.unlockTombstoneBlock(); + } + protected void remove(Player player, String[] strings) { if (strings.length > 2) { player.sendMessage(ChatColor.RED + "命令过长"); @@ -170,7 +184,7 @@ public class ZbCommand implements CommandExecutor, TabCompleter { "欢迎使用坐标管理器!你好," + player.getName() + "\n\n" + "本书将向你介绍如何使用指令记录曾探索过的地点,以避免迷路\n" + "如果需要再次查看帮助信息,请使用 /zb help\n", "/zb add <地点名称> <固定到侧边栏> \n" + "记录当前地点到数据库中,例如\n" + "/zb add Home\n" + "将会记录当前的位置,取名为 Home,并固定到屏幕右侧\n", "如果不想固定到屏幕右侧,可以像这样使用\n" + "/zb add Home false\n" + "然后,你可以使用/zb list来查看已经保存的位置\n" + "使用/zb fixed 来将地点固定到屏幕右侧\n" + "使用/zb unfixed 来取消固定。\n"); - bookMeta.addEnchant(Enchantment.VANISHING_CURSE,1,true); + bookMeta.addEnchant(Enchantment.VANISHING_CURSE, 1, true); return bookMeta; } @@ -280,6 +294,9 @@ public class ZbCommand implements CommandExecutor, TabCompleter { case "unfixed": unfixed(player, strings); break; + case "unlock": + unlock(player, strings); + break; } } catch (SQLException e) { player.sendMessage(ChatColor.RED + "服务器内部错误,请联系管理员"); diff --git a/src/main/java/ling/coordinateRecorder/CoordinateRecorder.java b/src/main/java/ling/coordinateRecorder/CoordinateRecorder.java index 739f10a..3938878 100644 --- a/src/main/java/ling/coordinateRecorder/CoordinateRecorder.java +++ b/src/main/java/ling/coordinateRecorder/CoordinateRecorder.java @@ -6,6 +6,7 @@ import ling.coordinateRecorder.Listener.PlayerEventListener; import ling.coordinateRecorder.Listener.PlayerLoginEventListener; import ling.coordinateRecorder.data.Database; import org.bukkit.Bukkit; +import org.bukkit.NamespacedKey; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; @@ -16,6 +17,10 @@ public final class CoordinateRecorder extends JavaPlugin { private static CoordinateRecorder current; private static Database database; private static Plugin authMePlugin; + private static NamespacedKey tombstoneOwner; + private static NamespacedKey tombstoneOwnerName; + //墓碑配套盔甲架的名称 + private static NamespacedKey tombstoneOwnerTitle; private static void start() throws SQLException { database.installPlugin(); @@ -36,6 +41,9 @@ public final class CoordinateRecorder extends JavaPlugin { public void onEnable() { // Plugin startup logic current = this; + tombstoneOwner = new NamespacedKey(this, "tombstoneOwner"); + tombstoneOwnerName = new NamespacedKey(this, "tombstoneOwnerName"); + tombstoneOwnerTitle = new NamespacedKey(this, "tombstoneOwnerTitle"); authMePlugin = Bukkit.getPluginManager().getPlugin("AuthMe"); try { database = new Database(this); @@ -52,6 +60,18 @@ public final class CoordinateRecorder extends JavaPlugin { } } + public static NamespacedKey getTombstoneOwner() { + return tombstoneOwner; + } + + public static NamespacedKey getTombstoneOwnerName() { + return tombstoneOwnerName; + } + + public static NamespacedKey getTombstoneOwnerTitle() { + return tombstoneOwnerTitle; + } + @Override public void onDisable() { // Plugin shutdown logic diff --git a/src/main/java/ling/coordinateRecorder/Listener/PlayerEventListener.java b/src/main/java/ling/coordinateRecorder/Listener/PlayerEventListener.java index d8aa3f4..745897a 100644 --- a/src/main/java/ling/coordinateRecorder/Listener/PlayerEventListener.java +++ b/src/main/java/ling/coordinateRecorder/Listener/PlayerEventListener.java @@ -1,9 +1,32 @@ package ling.coordinateRecorder.Listener; +import ling.coordinateRecorder.CoordinateRecorder; +import ling.coordinateRecorder.data.PlayerData; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.Chest; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataType; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; /// 玩家事件监听器 public class PlayerEventListener implements Listener { @@ -14,6 +37,171 @@ public class PlayerEventListener implements Listener { PlayerMap.getCurrent().playerQuit(event.getPlayer()); } + /** + * 获取适合生成墓碑的位置。 + * + * @param deathLocation 玩家死亡位置。 + * @return 适合生成墓碑的位置(默认为死亡位置上方或附近空位)。 + */ + public static Location getGraveLocation(Location deathLocation) { + // 检查当前位置是否为空气或可放置箱子的方块 + Block block = deathLocation.getBlock(); + if (isSuitableForGrave(block)) { + return deathLocation; + } + + // 尝试在死亡位置上方寻找 + Location aboveLocation = deathLocation.clone().add(0, 1, 0); + if (isSuitableForGrave(aboveLocation.getBlock())) { + return aboveLocation; + } + + // 尝试在死亡位置周围(水平范围)寻找 + for (int x = -2; x <= 2; x++) { + for (int z = -2; z <= 2; z++) { + Location nearbyLocation = deathLocation.clone().add(x, 0, z); + if (isSuitableForGrave(nearbyLocation.getBlock())) { + return nearbyLocation; + } + + // 检查周围位置的上方 + Location nearbyAboveLocation = nearbyLocation.clone().add(0, 1, 0); + if (isSuitableForGrave(nearbyAboveLocation.getBlock())) { + return nearbyAboveLocation; + } + } + } + + // 如果找不到合适的位置,默认返回原始死亡位置 + return deathLocation; + } + + /** + * 判断是否适合生成墓碑。 + * + * @param block 待检查的方块。 + * @return 如果适合放置墓碑,返回 true;否则返回 false。 + */ + private static boolean isSuitableForGrave(Block block) { + Material type = block.getType(); + return type == Material.AIR || block.isPassable(); + } + + public static String getTime() { + LocalDateTime now = LocalDateTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + return now.format(formatter); + } + + /// 保护墓碑 + protected void onTombstoneProtect(Cancellable event, Player player, Block block) { + if (block.getType() != Material.CHEST) { + return; + } + Chest chest = (Chest) block.getState(); + PersistentDataContainer persistent = chest.getPersistentDataContainer(); + if (!persistent.has(CoordinateRecorder.getTombstoneOwner())) { + //没有存储元数据的箱子一定不是墓碑 + return; + } + String uuid = persistent.get(CoordinateRecorder.getTombstoneOwner(), PersistentDataType.STRING); + String name = persistent.get(CoordinateRecorder.getTombstoneOwnerName(), PersistentDataType.STRING); + if (!player.getUniqueId().toString().equals(uuid)) { + player.sendMessage(ChatColor.RED + "这是 " + name + " 的墓碑,你无权访问!"); + event.setCancelled(true); + } else { + int count = 0; + for (ItemStack item : chest.getBlockInventory().getContents()) { + if (item != null && item.getType() != Material.AIR) { + count += item.getAmount(); + } + } + PlayerData data = PlayerMap.getCurrent().getPlayerData(player); + if (data == null) { + player.sendMessage(ChatColor.RED + "玩家没有注册"); + return; + } + data.setTombstoneBlock(block); + player.sendMessage("这是你的墓碑,请使用/zb unlock 命令解除锁定"); + player.sendMessage("墓碑内有" + count + "个物品"); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) { + Player player = event.getPlayer(); + Block block = event.getClickedBlock(); + if (block == null) return; + onTombstoneProtect(event, player, block); + } + + /// 保护墓碑不被其他玩家摧毁 + @EventHandler + public void onBlockBread(BlockBreakEvent event) { + Player player = event.getPlayer(); + Block block = event.getBlock(); + onTombstoneProtect(event, player, block); + } + + /// 阻止墓碑被火焰点燃 + @EventHandler + public void onBlockIgnite(BlockIgniteEvent event) { + Block block = event.getBlock(); + if (block.getType() != Material.CHEST) return; + Chest chest = (Chest) block.getState(); + PersistentDataContainer persistent = chest.getPersistentDataContainer(); + if (persistent.has(CoordinateRecorder.getTombstoneOwner())) { + //有元数据的箱子一定是墓碑 + System.out.println("阻止点燃"); + event.setCancelled(true); + } + } + + /// 在玩家死亡时,保管掉落物 + @EventHandler + public void playerDeath(PlayerDeathEvent event) { + Player player = event.getEntity(); + Location location = player.getLocation(); + + //寻找可以生成墓碑的位置 + Location save = getGraveLocation(location); + Block block = save.getBlock(); + + String text = ChatColor.YELLOW + "这里长眠着 " + player.getName(); + + //生成一个箱子 + block.setType(Material.CHEST); + Chest chest = (Chest) block.getState(); + //为墓碑附加元数据 + PersistentDataContainer persistent = chest.getPersistentDataContainer(); + persistent.set(CoordinateRecorder.getTombstoneOwner(), PersistentDataType.STRING, + player.getUniqueId().toString()); + persistent.set(CoordinateRecorder.getTombstoneOwnerName(), PersistentDataType.STRING, player.getName()); + persistent.set(CoordinateRecorder.getTombstoneOwnerTitle(), PersistentDataType.STRING, text); + chest.setCustomName(player.getName() + " 的墓碑"); + chest.update(); + + //将玩家掉落物存入箱子 + Inventory chestInventory = chest.getBlockInventory(); + for (ItemStack item : event.getDrops()) { + if (item != null) chestInventory.addItem(item); + } + event.getDrops().clear(); + + //在墓碑上方生成悬浮文字 + Location textLocation = location.clone().add(0, 1.5, 0); + World world = textLocation.getWorld(); + assert world != null; + ArmorStand armorStand = (ArmorStand) world.spawnEntity(textLocation, EntityType.ARMOR_STAND); + armorStand.setVisible(false); + armorStand.setGravity(false); + armorStand.setCustomName(text); + armorStand.setCustomNameVisible(true); + armorStand.setMarker(true); + + } + /// 玩家移动 @EventHandler public void playerMove(PlayerMoveEvent event) { diff --git a/src/main/java/ling/coordinateRecorder/data/Database.java b/src/main/java/ling/coordinateRecorder/data/Database.java index dfde5df..cdbd23f 100644 --- a/src/main/java/ling/coordinateRecorder/data/Database.java +++ b/src/main/java/ling/coordinateRecorder/data/Database.java @@ -50,12 +50,12 @@ public class Database { protected void createVersion() { if (ctx.meta().getTables("Version").isEmpty()) { ctx.createTable("Version") - .column("ID", SQLDataType.INTEGER.identity(true)) - .column("version", SQLDataType.INTEGER.nullable(false)) - .column("versionName", SQLDataType.VARCHAR(32).nullable(false)) - .column("createTime", SQLDataType.BIGINTUNSIGNED.nullable(false)) - .constraint(DSL.primaryKey("ID")) - .execute(); + .column("ID", SQLDataType.INTEGER.identity(true)) + .column("version", SQLDataType.INTEGER.nullable(false)) + .column("versionName", SQLDataType.VARCHAR(32).nullable(false)) + .column("createTime", SQLDataType.BIGINTUNSIGNED.nullable(false)) + .constraint(DSL.primaryKey("ID")) + .execute(); } } @@ -64,37 +64,53 @@ public class Database { //玩家记录坐标点 if (ctx.meta().getTables("LocationNotepad").isEmpty()) { ctx.createTable("LocationNotepad") - .column("ID", SQLDataType.INTEGER.identity(true)) - .column("UID", SQLDataType.VARCHAR(64).nullable(false)) - .column("world", SQLDataType.VARCHAR(32).nullable(false)) - .column("name", SQLDataType.VARCHAR(64).nullable(false)) - .column("x", SQLDataType.INTEGER.nullable(false)) - .column("y", SQLDataType.INTEGER.nullable(false)) - .column("z", SQLDataType.INTEGER.nullable(false)) - .column("time", SQLDataType.BIGINTUNSIGNED.nullable(false)) - .column("isFixed", SQLDataType.BOOLEAN.nullable(false).default_(false)) - .column("isDelete", SQLDataType.BOOLEAN.nullable(false).default_(false)) - .constraints(DSL.primaryKey("ID")) - .execute(); + .column("ID", SQLDataType.INTEGER.identity(true)) + .column("UID", SQLDataType.VARCHAR(64).nullable(false)) + .column("world", SQLDataType.VARCHAR(32).nullable(false)) + .column("name", SQLDataType.VARCHAR(64).nullable(false)) + .column("x", SQLDataType.INTEGER.nullable(false)) + .column("y", SQLDataType.INTEGER.nullable(false)) + .column("z", SQLDataType.INTEGER.nullable(false)) + .column("time", SQLDataType.BIGINTUNSIGNED.nullable(false)) + .column("isFixed", SQLDataType.BOOLEAN.nullable(false).default_(false)) + .column("isDelete", SQLDataType.BOOLEAN.nullable(false).default_(false)) + .constraints(DSL.primaryKey("ID")) + .execute(); ctx.createIndex(DSL.name("PlayerIndex")) - .on("LocationNotepad", "UID", "isFixed", "isDelete", "name") - .execute(); + .on("LocationNotepad", "UID", "isFixed", "isDelete", "name") + .execute(); } //玩家设置表 if (ctx.meta().getTables("PlayerSettings").isEmpty()) { ctx.createTable("PlayerSettings") - .column("UID", SQLDataType.VARCHAR(64).nullable(false)) - //控制是否在玩家屏幕右侧通过计分板显示插件信息 - .column("displaySwitch", SQLDataType.BOOLEAN.nullable(false).default_(true)) - //控制是否在计分板上显示当前时间刻对应的时间 - .column("showTime", SQLDataType.BOOLEAN.nullable(false).default_(true)) - //控制是否允许他人请求向自己传送 - .column("tpMe", SQLDataType.BOOLEAN.nullable(false).default_(true)) - //当他人的传送请求被设置自动拒绝时,展示给它的提示信息 - .column("settingsRejectTpMessage", - SQLDataType.CHAR.nullable(false).default_("对方的设置不允许任何人向他传送!")) - .constraint(DSL.primaryKey("UID")) - .execute(); + .column("UID", SQLDataType.VARCHAR(64).nullable(false)) + //控制是否在玩家屏幕右侧通过计分板显示插件信息 + .column("displaySwitch", SQLDataType.BOOLEAN.nullable(false).default_(true)) + //控制是否在计分板上显示当前时间刻对应的时间 + .column("showTime", SQLDataType.BOOLEAN.nullable(false).default_(true)) + //控制是否允许他人请求向自己传送 + .column("tpMe", SQLDataType.BOOLEAN.nullable(false).default_(true)) + //当他人的传送请求被设置自动拒绝时,展示给它的提示信息 + .column("settingsRejectTpMessage", + SQLDataType.CHAR.nullable(false).default_("对方的设置不允许任何人向他传送!")) + .constraint(DSL.primaryKey("UID")) + .execute(); + } + //墓碑记录 + if (ctx.meta().getTables("Tombstone").isEmpty()) { + ctx.createTable("Tombstone") + .column("ID", SQLDataType.INTEGER.identity(true)) + .column("UID", SQLDataType.VARCHAR(64).nullable(false)) + .column("world", SQLDataType.VARCHAR(32).nullable(false)) + .column("x", SQLDataType.INTEGER.nullable(false)) + .column("y", SQLDataType.INTEGER.nullable(false)) + .column("z", SQLDataType.INTEGER.nullable(false)) + .column("time", SQLDataType.BIGINTUNSIGNED.nullable(false)) + .column("isDelete", SQLDataType.BOOLEAN.nullable(false).default_(false)) + .execute(); + ctx.createIndex(DSL.name("TombstoneIndex")) + .on("Tombstone", "UID", "world", "x", "y", "z", "time", "isDelete") + .execute(); } } @@ -115,14 +131,14 @@ public class Database { return; } ctx.insertInto(VersionTB.VERSION) - .columns( - VersionTB.VERSION.VERSION_, - VersionTB.VERSION.VERSIONNAME, - VersionTB.VERSION.CREATETIME - ).values( - VERSION, - VERSION_NAME, - BigDecimal.valueOf(System.currentTimeMillis()) - ).execute(); + .columns( + VersionTB.VERSION.VERSION_, + VersionTB.VERSION.VERSIONNAME, + VersionTB.VERSION.CREATETIME + ).values( + VERSION, + VERSION_NAME, + BigDecimal.valueOf(System.currentTimeMillis()) + ).execute(); } } diff --git a/src/main/java/ling/coordinateRecorder/data/PlayerData.java b/src/main/java/ling/coordinateRecorder/data/PlayerData.java index fa40799..ab55e95 100644 --- a/src/main/java/ling/coordinateRecorder/data/PlayerData.java +++ b/src/main/java/ling/coordinateRecorder/data/PlayerData.java @@ -5,7 +5,15 @@ import ling.database.tables.records.LocationnotepadPO; import ling.database.tables.records.PlayersettingsPO; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.Chest; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataType; import org.jooq.Record; import org.jooq.Result; @@ -26,6 +34,8 @@ public class PlayerData { protected PlayersettingsPO settings; protected static final CoordinateRecorder plugin = CoordinateRecorder.getCurrent(); protected ScoreboardUI ui; + //正在交互的墓碑 + protected Block tombstoneBlock; public PlayerData(Player player) throws SQLException { @@ -36,6 +46,50 @@ public class PlayerData { locationListUpdate(); } + public void setTombstoneBlock(Block tombstone) { + this.tombstoneBlock = tombstone; + } + + /// 解锁墓碑 + public void unlockTombstoneBlock() { + if (tombstoneBlock == null) { + player.sendMessage(ChatColor.RED + "请先右键点击要解锁的墓碑"); + return; + } + if (tombstoneBlock.getType() != Material.CHEST) { + player.sendMessage(ChatColor.RED + "目标不是一个墓碑!"); + return; + } + if (player.getLocation().distance(tombstoneBlock.getLocation()) > 8) { + player.sendMessage(ChatColor.RED + "距离太远,无法解锁!"); + return; + } + Chest chest = (Chest) tombstoneBlock.getState(); + PersistentDataContainer persistent = chest.getPersistentDataContainer(); + if (!persistent.has(CoordinateRecorder.getTombstoneOwnerTitle())) { + player.sendMessage(ChatColor.RED + "目标不是一个墓碑!"); + return; + } + String name = persistent.get(CoordinateRecorder.getTombstoneOwnerTitle(), PersistentDataType.STRING); + assert name != null; + + Location location = tombstoneBlock.getLocation(); + World world = location.getWorld(); + assert world != null; + //先清理盔甲架 + for (Entity entity : world.getNearbyEntities(location, 3, 3, 3)) { + if (entity.getType() == EntityType.ARMOR_STAND && name.equals(entity.getCustomName())) { + entity.remove(); + } + } + //然后解除箱子的锁 + persistent.remove(CoordinateRecorder.getTombstoneOwnerTitle()); + persistent.remove(CoordinateRecorder.getTombstoneOwner()); + persistent.remove(CoordinateRecorder.getTombstoneOwnerName()); + chest.update(); + player.sendMessage("墓碑已解锁!"); + } + protected Record loadPlayerSettingsRecord() throws SQLException { return CoordinateRecorder.getDatabase().getDSL().select().from(PLAYERSETTINGS).where( diff --git a/src/main/java/ling/database/DefaultSchema.java b/src/main/java/ling/database/DefaultSchema.java index 1a39933..f1d6363 100644 --- a/src/main/java/ling/database/DefaultSchema.java +++ b/src/main/java/ling/database/DefaultSchema.java @@ -9,6 +9,7 @@ import java.util.List; import ling.database.tables.LocationnotepadTB; import ling.database.tables.PlayersettingsTB; +import ling.database.tables.TombstoneTB; import ling.database.tables.VersionTB; import org.jooq.Catalog; @@ -39,6 +40,11 @@ public class DefaultSchema extends SchemaImpl { */ public final PlayersettingsTB PLAYERSETTINGS = PlayersettingsTB.PLAYERSETTINGS; + /** + * The table Tombstone. + */ + public final TombstoneTB TOMBSTONE = TombstoneTB.TOMBSTONE; + /** * The table Version. */ @@ -62,6 +68,7 @@ public class DefaultSchema extends SchemaImpl { return Arrays.asList( LocationnotepadTB.LOCATIONNOTEPAD, PlayersettingsTB.PLAYERSETTINGS, + TombstoneTB.TOMBSTONE, VersionTB.VERSION ); } diff --git a/src/main/java/ling/database/Indexes.java b/src/main/java/ling/database/Indexes.java index f9c743f..0023bbb 100644 --- a/src/main/java/ling/database/Indexes.java +++ b/src/main/java/ling/database/Indexes.java @@ -5,6 +5,7 @@ package ling.database; import ling.database.tables.LocationnotepadTB; +import ling.database.tables.TombstoneTB; import org.jooq.Index; import org.jooq.OrderField; @@ -23,4 +24,5 @@ public class Indexes { // ------------------------------------------------------------------------- public static final Index PLAYERINDEX = Internal.createIndex(DSL.name("PlayerIndex"), LocationnotepadTB.LOCATIONNOTEPAD, new OrderField[] { LocationnotepadTB.LOCATIONNOTEPAD.UID, LocationnotepadTB.LOCATIONNOTEPAD.ISFIXED, LocationnotepadTB.LOCATIONNOTEPAD.ISDELETE, LocationnotepadTB.LOCATIONNOTEPAD.NAME }, false); + public static final Index TOMBSTONEINDEX = Internal.createIndex(DSL.name("TombstoneIndex"), TombstoneTB.TOMBSTONE, new OrderField[] { TombstoneTB.TOMBSTONE.UID, TombstoneTB.TOMBSTONE.WORLD, TombstoneTB.TOMBSTONE.X, TombstoneTB.TOMBSTONE.Y, TombstoneTB.TOMBSTONE.Z, TombstoneTB.TOMBSTONE.TIME, TombstoneTB.TOMBSTONE.ISDELETE }, false); } diff --git a/src/main/java/ling/database/Keys.java b/src/main/java/ling/database/Keys.java index 5f61f0f..cee6882 100644 --- a/src/main/java/ling/database/Keys.java +++ b/src/main/java/ling/database/Keys.java @@ -6,9 +6,11 @@ package ling.database; import ling.database.tables.LocationnotepadTB; import ling.database.tables.PlayersettingsTB; +import ling.database.tables.TombstoneTB; import ling.database.tables.VersionTB; import ling.database.tables.records.LocationnotepadPO; import ling.database.tables.records.PlayersettingsPO; +import ling.database.tables.records.TombstonePO; import ling.database.tables.records.VersionPO; import org.jooq.TableField; @@ -30,5 +32,6 @@ public class Keys { public static final UniqueKey LOCATIONNOTEPAD__PK_LOCATIONNOTEPAD = Internal.createUniqueKey(LocationnotepadTB.LOCATIONNOTEPAD, DSL.name("pk_LocationNotepad"), new TableField[] { LocationnotepadTB.LOCATIONNOTEPAD.ID }, true); public static final UniqueKey PLAYERSETTINGS__PK_PLAYERSETTINGS = Internal.createUniqueKey(PlayersettingsTB.PLAYERSETTINGS, DSL.name("pk_PlayerSettings"), new TableField[] { PlayersettingsTB.PLAYERSETTINGS.UID }, true); + public static final UniqueKey TOMBSTONE__PK_TOMBSTONE = Internal.createUniqueKey(TombstoneTB.TOMBSTONE, DSL.name("pk_Tombstone"), new TableField[] { TombstoneTB.TOMBSTONE.ID }, true); public static final UniqueKey VERSION__PK_VERSION = Internal.createUniqueKey(VersionTB.VERSION, DSL.name("pk_Version"), new TableField[] { VersionTB.VERSION.ID }, true); } diff --git a/src/main/java/ling/database/Tables.java b/src/main/java/ling/database/Tables.java index 67de98c..269b750 100644 --- a/src/main/java/ling/database/Tables.java +++ b/src/main/java/ling/database/Tables.java @@ -6,6 +6,7 @@ package ling.database; import ling.database.tables.LocationnotepadTB; import ling.database.tables.PlayersettingsTB; +import ling.database.tables.TombstoneTB; import ling.database.tables.VersionTB; @@ -25,6 +26,11 @@ public class Tables { */ public static final PlayersettingsTB PLAYERSETTINGS = PlayersettingsTB.PLAYERSETTINGS; + /** + * The table Tombstone. + */ + public static final TombstoneTB TOMBSTONE = TombstoneTB.TOMBSTONE; + /** * The table Version. */ diff --git a/src/main/java/ling/database/tables/TombstoneTB.java b/src/main/java/ling/database/tables/TombstoneTB.java new file mode 100644 index 0000000..fc0f548 --- /dev/null +++ b/src/main/java/ling/database/tables/TombstoneTB.java @@ -0,0 +1,269 @@ +/* + * This file is generated by jOOQ. + */ +package ling.database.tables; + + +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import ling.database.DefaultSchema; +import ling.database.Indexes; +import ling.database.Keys; +import ling.database.tables.records.TombstonePO; + +import org.jooq.Condition; +import org.jooq.Field; +import org.jooq.Identity; +import org.jooq.Index; +import org.jooq.Name; +import org.jooq.PlainSQL; +import org.jooq.QueryPart; +import org.jooq.SQL; +import org.jooq.Schema; +import org.jooq.Select; +import org.jooq.Stringly; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" }) +public class TombstoneTB extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of Tombstone + */ + public static final TombstoneTB TOMBSTONE = new TombstoneTB(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return TombstonePO.class; + } + + /** + * The column Tombstone.ID. + */ + public final TableField ID = createField(DSL.name("ID"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column Tombstone.UID. + */ + public final TableField UID = createField(DSL.name("UID"), SQLDataType.VARCHAR(64).nullable(false), this, ""); + + /** + * The column Tombstone.world. + */ + public final TableField WORLD = createField(DSL.name("world"), SQLDataType.VARCHAR(32).nullable(false), this, ""); + + /** + * The column Tombstone.x. + */ + public final TableField X = createField(DSL.name("x"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Tombstone.y. + */ + public final TableField Y = createField(DSL.name("y"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Tombstone.z. + */ + public final TableField Z = createField(DSL.name("z"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column Tombstone.time. + */ + public final TableField TIME = createField(DSL.name("time"), SQLDataType.NUMERIC.nullable(false), this, ""); + + /** + * The column Tombstone.isDelete. + */ + public final TableField ISDELETE = createField(DSL.name("isDelete"), SQLDataType.BOOLEAN.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BOOLEAN)), this, ""); + + private TombstoneTB(Name alias, Table aliased) { + this(alias, aliased, (Field[]) null, null); + } + + private TombstoneTB(Name alias, Table aliased, Field[] parameters, Condition where) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table(), where); + } + + /** + * Create an aliased Tombstone table reference + */ + public TombstoneTB(String alias) { + this(DSL.name(alias), TOMBSTONE); + } + + /** + * Create an aliased Tombstone table reference + */ + public TombstoneTB(Name alias) { + this(alias, TOMBSTONE); + } + + /** + * Create a Tombstone table reference + */ + public TombstoneTB() { + this(DSL.name("Tombstone"), null); + } + + @Override + public Schema getSchema() { + return aliased() ? null : DefaultSchema.DEFAULT_SCHEMA; + } + + @Override + public List getIndexes() { + return Arrays.asList(Indexes.TOMBSTONEINDEX); + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.TOMBSTONE__PK_TOMBSTONE; + } + + @Override + public TombstoneTB as(String alias) { + return new TombstoneTB(DSL.name(alias), this); + } + + @Override + public TombstoneTB as(Name alias) { + return new TombstoneTB(alias, this); + } + + @Override + public TombstoneTB as(Table alias) { + return new TombstoneTB(alias.getQualifiedName(), this); + } + + /** + * Rename this table + */ + @Override + public TombstoneTB rename(String name) { + return new TombstoneTB(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public TombstoneTB rename(Name name) { + return new TombstoneTB(name, null); + } + + /** + * Rename this table + */ + @Override + public TombstoneTB rename(Table name) { + return new TombstoneTB(name.getQualifiedName(), null); + } + + /** + * Create an inline derived table from this table + */ + @Override + public TombstoneTB where(Condition condition) { + return new TombstoneTB(getQualifiedName(), aliased() ? this : null, null, condition); + } + + /** + * Create an inline derived table from this table + */ + @Override + public TombstoneTB where(Collection conditions) { + return where(DSL.and(conditions)); + } + + /** + * Create an inline derived table from this table + */ + @Override + public TombstoneTB where(Condition... conditions) { + return where(DSL.and(conditions)); + } + + /** + * Create an inline derived table from this table + */ + @Override + public TombstoneTB where(Field condition) { + return where(DSL.condition(condition)); + } + + /** + * Create an inline derived table from this table + */ + @Override + @PlainSQL + public TombstoneTB where(SQL condition) { + return where(DSL.condition(condition)); + } + + /** + * Create an inline derived table from this table + */ + @Override + @PlainSQL + public TombstoneTB where(@Stringly.SQL String condition) { + return where(DSL.condition(condition)); + } + + /** + * Create an inline derived table from this table + */ + @Override + @PlainSQL + public TombstoneTB where(@Stringly.SQL String condition, Object... binds) { + return where(DSL.condition(condition, binds)); + } + + /** + * Create an inline derived table from this table + */ + @Override + @PlainSQL + public TombstoneTB where(@Stringly.SQL String condition, QueryPart... parts) { + return where(DSL.condition(condition, parts)); + } + + /** + * Create an inline derived table from this table + */ + @Override + public TombstoneTB whereExists(Select select) { + return where(DSL.exists(select)); + } + + /** + * Create an inline derived table from this table + */ + @Override + public TombstoneTB whereNotExists(Select select) { + return where(DSL.notExists(select)); + } +} diff --git a/src/main/java/ling/database/tables/pojos/TombstoneBO.java b/src/main/java/ling/database/tables/pojos/TombstoneBO.java new file mode 100644 index 0000000..ff61837 --- /dev/null +++ b/src/main/java/ling/database/tables/pojos/TombstoneBO.java @@ -0,0 +1,264 @@ +/* + * This file is generated by jOOQ. + */ +package ling.database.tables.pojos; + + +import java.io.Serializable; +import java.math.BigDecimal; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" }) +public class TombstoneBO implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private String uid; + private String world; + private Integer x; + private Integer y; + private Integer z; + private BigDecimal time; + private Boolean isdelete; + + public TombstoneBO() {} + + public TombstoneBO(TombstoneBO value) { + this.id = value.id; + this.uid = value.uid; + this.world = value.world; + this.x = value.x; + this.y = value.y; + this.z = value.z; + this.time = value.time; + this.isdelete = value.isdelete; + } + + public TombstoneBO( + Integer id, + String uid, + String world, + Integer x, + Integer y, + Integer z, + BigDecimal time, + Boolean isdelete + ) { + this.id = id; + this.uid = uid; + this.world = world; + this.x = x; + this.y = y; + this.z = z; + this.time = time; + this.isdelete = isdelete; + } + + /** + * Getter for Tombstone.ID. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for Tombstone.ID. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for Tombstone.UID. + */ + public String getUid() { + return this.uid; + } + + /** + * Setter for Tombstone.UID. + */ + public void setUid(String uid) { + this.uid = uid; + } + + /** + * Getter for Tombstone.world. + */ + public String getWorld() { + return this.world; + } + + /** + * Setter for Tombstone.world. + */ + public void setWorld(String world) { + this.world = world; + } + + /** + * Getter for Tombstone.x. + */ + public Integer getX() { + return this.x; + } + + /** + * Setter for Tombstone.x. + */ + public void setX(Integer x) { + this.x = x; + } + + /** + * Getter for Tombstone.y. + */ + public Integer getY() { + return this.y; + } + + /** + * Setter for Tombstone.y. + */ + public void setY(Integer y) { + this.y = y; + } + + /** + * Getter for Tombstone.z. + */ + public Integer getZ() { + return this.z; + } + + /** + * Setter for Tombstone.z. + */ + public void setZ(Integer z) { + this.z = z; + } + + /** + * Getter for Tombstone.time. + */ + public BigDecimal getTime() { + return this.time; + } + + /** + * Setter for Tombstone.time. + */ + public void setTime(BigDecimal time) { + this.time = time; + } + + /** + * Getter for Tombstone.isDelete. + */ + public Boolean getIsdelete() { + return this.isdelete; + } + + /** + * Setter for Tombstone.isDelete. + */ + public void setIsdelete(Boolean isdelete) { + this.isdelete = isdelete; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final TombstoneBO other = (TombstoneBO) obj; + if (this.id == null) { + if (other.id != null) + return false; + } + else if (!this.id.equals(other.id)) + return false; + if (this.uid == null) { + if (other.uid != null) + return false; + } + else if (!this.uid.equals(other.uid)) + return false; + if (this.world == null) { + if (other.world != null) + return false; + } + else if (!this.world.equals(other.world)) + return false; + if (this.x == null) { + if (other.x != null) + return false; + } + else if (!this.x.equals(other.x)) + return false; + if (this.y == null) { + if (other.y != null) + return false; + } + else if (!this.y.equals(other.y)) + return false; + if (this.z == null) { + if (other.z != null) + return false; + } + else if (!this.z.equals(other.z)) + return false; + if (this.time == null) { + if (other.time != null) + return false; + } + else if (!this.time.equals(other.time)) + return false; + if (this.isdelete == null) { + if (other.isdelete != null) + return false; + } + else if (!this.isdelete.equals(other.isdelete)) + return false; + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.id == null) ? 0 : this.id.hashCode()); + result = prime * result + ((this.uid == null) ? 0 : this.uid.hashCode()); + result = prime * result + ((this.world == null) ? 0 : this.world.hashCode()); + result = prime * result + ((this.x == null) ? 0 : this.x.hashCode()); + result = prime * result + ((this.y == null) ? 0 : this.y.hashCode()); + result = prime * result + ((this.z == null) ? 0 : this.z.hashCode()); + result = prime * result + ((this.time == null) ? 0 : this.time.hashCode()); + result = prime * result + ((this.isdelete == null) ? 0 : this.isdelete.hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TombstoneBO ("); + + sb.append(id); + sb.append(", ").append(uid); + sb.append(", ").append(world); + sb.append(", ").append(x); + sb.append(", ").append(y); + sb.append(", ").append(z); + sb.append(", ").append(time); + sb.append(", ").append(isdelete); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/src/main/java/ling/database/tables/records/TombstonePO.java b/src/main/java/ling/database/tables/records/TombstonePO.java new file mode 100644 index 0000000..46c9a4c --- /dev/null +++ b/src/main/java/ling/database/tables/records/TombstonePO.java @@ -0,0 +1,191 @@ +/* + * This file is generated by jOOQ. + */ +package ling.database.tables.records; + + +import java.math.BigDecimal; + +import ling.database.tables.TombstoneTB; +import ling.database.tables.pojos.TombstoneBO; + +import org.jooq.Record1; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" }) +public class TombstonePO extends UpdatableRecordImpl { + + private static final long serialVersionUID = 1L; + + /** + * Setter for Tombstone.ID. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for Tombstone.ID. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for Tombstone.UID. + */ + public void setUid(String value) { + set(1, value); + } + + /** + * Getter for Tombstone.UID. + */ + public String getUid() { + return (String) get(1); + } + + /** + * Setter for Tombstone.world. + */ + public void setWorld(String value) { + set(2, value); + } + + /** + * Getter for Tombstone.world. + */ + public String getWorld() { + return (String) get(2); + } + + /** + * Setter for Tombstone.x. + */ + public void setX(Integer value) { + set(3, value); + } + + /** + * Getter for Tombstone.x. + */ + public Integer getX() { + return (Integer) get(3); + } + + /** + * Setter for Tombstone.y. + */ + public void setY(Integer value) { + set(4, value); + } + + /** + * Getter for Tombstone.y. + */ + public Integer getY() { + return (Integer) get(4); + } + + /** + * Setter for Tombstone.z. + */ + public void setZ(Integer value) { + set(5, value); + } + + /** + * Getter for Tombstone.z. + */ + public Integer getZ() { + return (Integer) get(5); + } + + /** + * Setter for Tombstone.time. + */ + public void setTime(BigDecimal value) { + set(6, value); + } + + /** + * Getter for Tombstone.time. + */ + public BigDecimal getTime() { + return (BigDecimal) get(6); + } + + /** + * Setter for Tombstone.isDelete. + */ + public void setIsdelete(Boolean value) { + set(7, value); + } + + /** + * Getter for Tombstone.isDelete. + */ + public Boolean getIsdelete() { + return (Boolean) get(7); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached TombstonePO + */ + public TombstonePO() { + super(TombstoneTB.TOMBSTONE); + } + + /** + * Create a detached, initialised TombstonePO + */ + public TombstonePO(Integer id, String uid, String world, Integer x, Integer y, Integer z, BigDecimal time, Boolean isdelete) { + super(TombstoneTB.TOMBSTONE); + + setId(id); + setUid(uid); + setWorld(world); + setX(x); + setY(y); + setZ(z); + setTime(time); + setIsdelete(isdelete); + resetChangedOnNotNull(); + } + + /** + * Create a detached, initialised TombstonePO + */ + public TombstonePO(TombstoneBO value) { + super(TombstoneTB.TOMBSTONE); + + if (value != null) { + setId(value.getId()); + setUid(value.getUid()); + setWorld(value.getWorld()); + setX(value.getX()); + setY(value.getY()); + setZ(value.getZ()); + setTime(value.getTime()); + setIsdelete(value.getIsdelete()); + resetChangedOnNotNull(); + } + } +}