From a78e6482e84ce2cd579d0d5b22fcdad5a4c378bd Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Sun, 28 Apr 2019 18:06:42 +0800 Subject: [PATCH] feat: optimize framework Signed-off-by: MiaoWoo --- src/main/resources/core/patch/Array.js | 2 +- src/main/resources/core/patch/Date.js | 5 +- src/main/resources/core/patch/Object.js | 27 +- src/main/resources/core/require.js | 2 +- src/main/resources/node_modules/fs.js | 9 +- .../internal/bukkit/item-id-material.json | 2270 +++++++++++++++++ .../node_modules/internal/bukkit/item.js | 8 + 7 files changed, 2288 insertions(+), 35 deletions(-) create mode 100644 src/main/resources/node_modules/internal/bukkit/item-id-material.json diff --git a/src/main/resources/core/patch/Array.js b/src/main/resources/core/patch/Array.js index 7bb899a..45bd1d1 100644 --- a/src/main/resources/core/patch/Array.js +++ b/src/main/resources/core/patch/Array.js @@ -17,4 +17,4 @@ } }); } -})(); \ No newline at end of file +})(); diff --git a/src/main/resources/core/patch/Date.js b/src/main/resources/core/patch/Date.js index 3b3e997..0f39538 100644 --- a/src/main/resources/core/patch/Date.js +++ b/src/main/resources/core/patch/Date.js @@ -1,15 +1,14 @@ /** * 补丁和方法扩展 */ - -(function () { +(function() { /** * 日期格式化 * 例: new Date().format('yyyy-MM-dd hh:mm:ss.s') => "2017-08-24 16:15:40.693" * @param fmt 格式化字符串 * @returns {*} */ - Date.prototype.format = function (fmt) { + Date.prototype.format = function(fmt) { var o = { "M+": this.getMonth() + 1, //月份 "d+": this.getDate(), //日 diff --git a/src/main/resources/core/patch/Object.js b/src/main/resources/core/patch/Object.js index 02642e3..65c4e62 100644 --- a/src/main/resources/core/patch/Object.js +++ b/src/main/resources/core/patch/Object.js @@ -2,14 +2,12 @@ * 补丁和方法扩展 */ -(function () { +(function() { // Object.assign Polyfill if (!Object.assign) { Object.defineProperty(Object, "assign", { enumerable: false, - configurable: true, - writable: true, - value: function (target) { + value: function(target) { "use strict"; if (target === undefined || target === null) throw new TypeError("Cannot convert first argument to object"); @@ -28,13 +26,11 @@ } }); } - + // Object.values Polyfill if (!Object.values) { Object.defineProperty(Object, "values", { enumerable: false, - configurable: true, - writable: true, - value: function (target) { + value: function(target) { "use strict"; var values = []; for (var key in target) { @@ -50,22 +46,9 @@ if (!Object.toJson) { Object.defineProperty(Object.prototype, "toJson", { enumerable: false, - configurable: true, - writable: true, - value: function () { + value: function() { return JSON.stringify(this); } }); } - - - // Object.prototype.toJson = function () { - // return JSON.stringify(this); - // }; - - // // YAML快速生成 - // var yaml = require('modules/yaml'); - // Object.prototype.toYaml = function () { - // return yaml.safeDump(this); - // }; })(); diff --git a/src/main/resources/core/require.js b/src/main/resources/core/require.js index c907092..b39a6c9 100644 --- a/src/main/resources/core/require.js +++ b/src/main/resources/core/require.js @@ -31,7 +31,7 @@ var File = Java.type("java.io.File"); var separatorChar = File.separatorChar; var cacheDir = parent + separatorChar + "runtime"; - var paths = [parent, parent + separatorChar + 'node_modules']; + var paths = [parent + separatorChar + 'node_modules', parent]; try { base.delete(cacheDir); diff --git a/src/main/resources/node_modules/fs.js b/src/main/resources/node_modules/fs.js index a17284d..ebee878 100644 --- a/src/main/resources/node_modules/fs.js +++ b/src/main/resources/node_modules/fs.js @@ -3,13 +3,8 @@ /*global Java, base, module, exports, require, __FILE__*/ var File = Java.type("java.io.File"); var Files = Java.type("java.nio.file.Files"); -// noinspection JSUnresolvedVariable var separatorChar = File.separatorChar; var StandardCopyOption = Java.type("java.nio.file.StandardCopyOption"); -// noinspection JSUnusedLocalSymbols -var _toString = function(obj) { - return Object.prototype.toString.call(obj); -}; /** * 用文件分割符合并路径 @@ -145,9 +140,7 @@ function del(file) { if (!file.exists()) { return; } - // noinspection JSValidateTypes if (file.isDirectory()) { - // noinspection JSUnresolvedVariable Files.list(file.toPath()).collect(java.util.stream.Collector.toList()).forEach(function(f) { del(f); }) @@ -155,7 +148,6 @@ function del(file) { Files.delete(file.toPath()); } -// noinspection JSUnusedLocalSymbols function exists(file) { return fs.file(file).exists() } @@ -173,6 +165,7 @@ Object.assign(fs, { concat: concat, create: create, mkdirs: mkdirs, + exists: exists, file: file, copy: copy, read: read diff --git a/src/main/resources/node_modules/internal/bukkit/item-id-material.json b/src/main/resources/node_modules/internal/bukkit/item-id-material.json new file mode 100644 index 0000000..5327463 --- /dev/null +++ b/src/main/resources/node_modules/internal/bukkit/item-id-material.json @@ -0,0 +1,2270 @@ +[ + "AIR", + "STONE", + "GRASS", + "DIRT", + "COBBLESTONE", + "WOOD", + "SAPLING", + "BEDROCK", + "WATER", + "STATIONARY_WATER", + "LAVA", + "STATIONARY_LAVA", + "SAND", + "GRAVEL", + "GOLD_ORE", + "IRON_ORE", + "COAL_ORE", + "LOG", + "LEAVES", + "SPONGE", + "GLASS", + "LAPIS_ORE", + "LAPIS_BLOCK", + "DISPENSER", + "SANDSTONE", + "NOTE_BLOCK", + "BED_BLOCK", + "POWERED_RAIL", + "DETECTOR_RAIL", + "PISTON_STICKY_BASE", + "WEB", + "LONG_GRASS", + "DEAD_BUSH", + "PISTON_BASE", + "PISTON_EXTENSION", + "WOOL", + "PISTON_MOVING_PIECE", + "YELLOW_FLOWER", + "RED_ROSE", + "BROWN_MUSHROOM", + "RED_MUSHROOM", + "GOLD_BLOCK", + "IRON_BLOCK", + "DOUBLE_STEP", + "STEP", + "BRICK", + "TNT", + "BOOKSHELF", + "MOSSY_COBBLESTONE", + "OBSIDIAN", + "TORCH", + "FIRE", + "MOB_SPAWNER", + "WOOD_STAIRS", + "CHEST", + "REDSTONE_WIRE", + "DIAMOND_ORE", + "DIAMOND_BLOCK", + "WORKBENCH", + "CROPS", + "SOIL", + "FURNACE", + "BURNING_FURNACE", + "SIGN_POST", + "WOODEN_DOOR", + "LADDER", + "RAILS", + "COBBLESTONE_STAIRS", + "WALL_SIGN", + "LEVER", + "STONE_PLATE", + "IRON_DOOR_BLOCK", + "WOOD_PLATE", + "REDSTONE_ORE", + "GLOWING_REDSTONE_ORE", + "REDSTONE_TORCH_OFF", + "REDSTONE_TORCH_ON", + "STONE_BUTTON", + "SNOW", + "ICE", + "SNOW_BLOCK", + "CACTUS", + "CLAY", + "SUGAR_CANE_BLOCK", + "JUKEBOX", + "FENCE", + "PUMPKIN", + "NETHERRACK", + "SOUL_SAND", + "GLOWSTONE", + "PORTAL", + "JACK_O_LANTERN", + "CAKE_BLOCK", + "DIODE_BLOCK_OFF", + "DIODE_BLOCK_ON", + "STAINED_GLASS", + "TRAP_DOOR", + "MONSTER_EGGS", + "SMOOTH_BRICK", + "HUGE_MUSHROOM_1", + "HUGE_MUSHROOM_2", + "IRON_FENCE", + "THIN_GLASS", + "MELON_BLOCK", + "PUMPKIN_STEM", + "MELON_STEM", + "VINE", + "FENCE_GATE", + "BRICK_STAIRS", + "SMOOTH_STAIRS", + "MYCEL", + "WATER_LILY", + "NETHER_BRICK", + "NETHER_FENCE", + "NETHER_BRICK_STAIRS", + "NETHER_WARTS", + "ENCHANTMENT_TABLE", + "BREWING_STAND", + "CAULDRON", + "ENDER_PORTAL", + "ENDER_PORTAL_FRAME", + "ENDER_STONE", + "DRAGON_EGG", + "REDSTONE_LAMP_OFF", + "REDSTONE_LAMP_ON", + "WOOD_DOUBLE_STEP", + "WOOD_STEP", + "COCOA", + "SANDSTONE_STAIRS", + "EMERALD_ORE", + "ENDER_CHEST", + "TRIPWIRE_HOOK", + "TRIPWIRE", + "EMERALD_BLOCK", + "SPRUCE_WOOD_STAIRS", + "BIRCH_WOOD_STAIRS", + "JUNGLE_WOOD_STAIRS", + "COMMAND", + "BEACON", + "COBBLE_WALL", + "FLOWER_POT", + "CARROT", + "POTATO", + "WOOD_BUTTON", + "SKULL", + "ANVIL", + "TRAPPED_CHEST", + "GOLD_PLATE", + "IRON_PLATE", + "REDSTONE_COMPARATOR_OFF", + "REDSTONE_COMPARATOR_ON", + "DAYLIGHT_DETECTOR", + "REDSTONE_BLOCK", + "QUARTZ_ORE", + "HOPPER", + "QUARTZ_BLOCK", + "QUARTZ_STAIRS", + "ACTIVATOR_RAIL", + "DROPPER", + "STAINED_CLAY", + "STAINED_GLASS_PANE", + "LEAVES_2", + "LOG_2", + "ACACIA_STAIRS", + "DARK_OAK_STAIRS", + "SLIME_BLOCK", + "BARRIER", + "IRON_TRAPDOOR", + "PRISMARINE", + "SEA_LANTERN", + "HAY_BLOCK", + "CARPET", + "HARD_CLAY", + "COAL_BLOCK", + "PACKED_ICE", + "DOUBLE_PLANT", + "STANDING_BANNER", + "WALL_BANNER", + "DAYLIGHT_DETECTOR_INVERTED", + "RED_SANDSTONE", + "RED_SANDSTONE_STAIRS", + "DOUBLE_STONE_SLAB2", + "STONE_SLAB2", + "SPRUCE_FENCE_GATE", + "BIRCH_FENCE_GATE", + "JUNGLE_FENCE_GATE", + "DARK_OAK_FENCE_GATE", + "ACACIA_FENCE_GATE", + "SPRUCE_FENCE", + "BIRCH_FENCE", + "JUNGLE_FENCE", + "DARK_OAK_FENCE", + "ACACIA_FENCE", + "SPRUCE_DOOR", + "BIRCH_DOOR", + "JUNGLE_DOOR", + "ACACIA_DOOR", + "DARK_OAK_DOOR", + "END_ROD", + "CHORUS_PLANT", + "CHORUS_FLOWER", + "PURPUR_BLOCK", + "PURPUR_PILLAR", + "PURPUR_STAIRS", + "PURPUR_DOUBLE_SLAB", + "PURPUR_SLAB", + "END_BRICKS", + "BEETROOT_BLOCK", + "GRASS_PATH", + "END_GATEWAY", + "COMMAND_REPEATING", + "COMMAND_CHAIN", + "FROSTED_ICE", + "MAGMA", + "NETHER_WART_BLOCK", + "RED_NETHER_BRICK", + "BONE_BLOCK", + "STRUCTURE_VOID", + "OBSERVER", + "WHITE_SHULKER_BOX", + "ORANGE_SHULKER_BOX", + "MAGENTA_SHULKER_BOX", + "LIGHT_BLUE_SHULKER_BOX", + "YELLOW_SHULKER_BOX", + "LIME_SHULKER_BOX", + "PINK_SHULKER_BOX", + "GRAY_SHULKER_BOX", + "SILVER_SHULKER_BOX", + "CYAN_SHULKER_BOX", + "PURPLE_SHULKER_BOX", + "BLUE_SHULKER_BOX", + "BROWN_SHULKER_BOX", + "GREEN_SHULKER_BOX", + "RED_SHULKER_BOX", + "BLACK_SHULKER_BOX", + "WHITE_GLAZED_TERRACOTTA", + "ORANGE_GLAZED_TERRACOTTA", + "MAGENTA_GLAZED_TERRACOTTA", + "LIGHT_BLUE_GLAZED_TERRACOTTA", + "YELLOW_GLAZED_TERRACOTTA", + "LIME_GLAZED_TERRACOTTA", + "PINK_GLAZED_TERRACOTTA", + "GRAY_GLAZED_TERRACOTTA", + "SILVER_GLAZED_TERRACOTTA", + "CYAN_GLAZED_TERRACOTTA", + "PURPLE_GLAZED_TERRACOTTA", + "BLUE_GLAZED_TERRACOTTA", + "BROWN_GLAZED_TERRACOTTA", + "GREEN_GLAZED_TERRACOTTA", + "RED_GLAZED_TERRACOTTA", + "BLACK_GLAZED_TERRACOTTA", + "CONCRETE", + "CONCRETE_POWDER", + null, + null, + "STRUCTURE_BLOCK", + "IRON_SPADE", + "IRON_PICKAXE", + "IRON_AXE", + "FLINT_AND_STEEL", + "APPLE", + "BOW", + "ARROW", + "COAL", + "DIAMOND", + "IRON_INGOT", + "GOLD_INGOT", + "IRON_SWORD", + "WOOD_SWORD", + "WOOD_SPADE", + "WOOD_PICKAXE", + "WOOD_AXE", + "STONE_SWORD", + "STONE_SPADE", + "STONE_PICKAXE", + "STONE_AXE", + "DIAMOND_SWORD", + "DIAMOND_SPADE", + "DIAMOND_PICKAXE", + "DIAMOND_AXE", + "STICK", + "BOWL", + "MUSHROOM_SOUP", + "GOLD_SWORD", + "GOLD_SPADE", + "GOLD_PICKAXE", + "GOLD_AXE", + "STRING", + "FEATHER", + "SULPHUR", + "WOOD_HOE", + "STONE_HOE", + "IRON_HOE", + "DIAMOND_HOE", + "GOLD_HOE", + "SEEDS", + "WHEAT", + "BREAD", + "LEATHER_HELMET", + "LEATHER_CHESTPLATE", + "LEATHER_LEGGINGS", + "LEATHER_BOOTS", + "CHAINMAIL_HELMET", + "CHAINMAIL_CHESTPLATE", + "CHAINMAIL_LEGGINGS", + "CHAINMAIL_BOOTS", + "IRON_HELMET", + "IRON_CHESTPLATE", + "IRON_LEGGINGS", + "IRON_BOOTS", + "DIAMOND_HELMET", + "DIAMOND_CHESTPLATE", + "DIAMOND_LEGGINGS", + "DIAMOND_BOOTS", + "GOLD_HELMET", + "GOLD_CHESTPLATE", + "GOLD_LEGGINGS", + "GOLD_BOOTS", + "FLINT", + "PORK", + "GRILLED_PORK", + "PAINTING", + "GOLDEN_APPLE", + "SIGN", + "WOOD_DOOR", + "BUCKET", + "WATER_BUCKET", + "LAVA_BUCKET", + "MINECART", + "SADDLE", + "IRON_DOOR", + "REDSTONE", + "SNOW_BALL", + "BOAT", + "LEATHER", + "MILK_BUCKET", + "CLAY_BRICK", + "CLAY_BALL", + "SUGAR_CANE", + "PAPER", + "BOOK", + "SLIME_BALL", + "STORAGE_MINECART", + "POWERED_MINECART", + "EGG", + "COMPASS", + "FISHING_ROD", + "WATCH", + "GLOWSTONE_DUST", + "RAW_FISH", + "COOKED_FISH", + "INK_SACK", + "BONE", + "SUGAR", + "CAKE", + "BED", + "DIODE", + "COOKIE", + "MAP", + "SHEARS", + "MELON", + "PUMPKIN_SEEDS", + "MELON_SEEDS", + "RAW_BEEF", + "COOKED_BEEF", + "RAW_CHICKEN", + "COOKED_CHICKEN", + "ROTTEN_FLESH", + "ENDER_PEARL", + "BLAZE_ROD", + "GHAST_TEAR", + "GOLD_NUGGET", + "NETHER_STALK", + "POTION", + "GLASS_BOTTLE", + "SPIDER_EYE", + "FERMENTED_SPIDER_EYE", + "BLAZE_POWDER", + "MAGMA_CREAM", + "BREWING_STAND_ITEM", + "CAULDRON_ITEM", + "EYE_OF_ENDER", + "SPECKLED_MELON", + "MONSTER_EGG", + "EXP_BOTTLE", + "FIREBALL", + "BOOK_AND_QUILL", + "WRITTEN_BOOK", + "EMERALD", + "ITEM_FRAME", + "FLOWER_POT_ITEM", + "CARROT_ITEM", + "POTATO_ITEM", + "BAKED_POTATO", + "POISONOUS_POTATO", + "EMPTY_MAP", + "GOLDEN_CARROT", + "SKULL_ITEM", + "CARROT_STICK", + "NETHER_STAR", + "PUMPKIN_PIE", + "FIREWORK", + "FIREWORK_CHARGE", + "ENCHANTED_BOOK", + "REDSTONE_COMPARATOR", + "NETHER_BRICK_ITEM", + "QUARTZ", + "EXPLOSIVE_MINECART", + "HOPPER_MINECART", + "PRISMARINE_SHARD", + "PRISMARINE_CRYSTALS", + "RABBIT", + "COOKED_RABBIT", + "RABBIT_STEW", + "RABBIT_FOOT", + "RABBIT_HIDE", + "ARMOR_STAND", + "IRON_BARDING", + "GOLD_BARDING", + "DIAMOND_BARDING", + "LEASH", + "NAME_TAG", + "COMMAND_MINECART", + "MUTTON", + "COOKED_MUTTON", + "BANNER", + "END_CRYSTAL", + "SPRUCE_DOOR_ITEM", + "BIRCH_DOOR_ITEM", + "JUNGLE_DOOR_ITEM", + "ACACIA_DOOR_ITEM", + "DARK_OAK_DOOR_ITEM", + "CHORUS_FRUIT", + "CHORUS_FRUIT_POPPED", + "BEETROOT", + "BEETROOT_SEEDS", + "BEETROOT_SOUP", + "DRAGONS_BREATH", + "SPLASH_POTION", + "SPECTRAL_ARROW", + "TIPPED_ARROW", + "LINGERING_POTION", + "SHIELD", + "ELYTRA", + "BOAT_SPRUCE", + "BOAT_BIRCH", + "BOAT_JUNGLE", + "BOAT_ACACIA", + "BOAT_DARK_OAK", + "TOTEM", + "SHULKER_SHELL", + null, + "IRON_NUGGET", + "KNOWLEDGE_BOOK", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + "GOLD_RECORD", + "GREEN_RECORD", + "RECORD_3", + "RECORD_4", + "RECORD_5", + "RECORD_6", + "RECORD_7", + "RECORD_8", + "RECORD_9", + "RECORD_10", + "RECORD_11", + "RECORD_12" +] \ No newline at end of file diff --git a/src/main/resources/node_modules/internal/bukkit/item.js b/src/main/resources/node_modules/internal/bukkit/item.js index fc7247a..1fefbc4 100644 --- a/src/main/resources/node_modules/internal/bukkit/item.js +++ b/src/main/resources/node_modules/internal/bukkit/item.js @@ -8,6 +8,8 @@ var Bukkit = MServer; var item = {}; var ItemStack = Java.type("org.bukkit.inventory.ItemStack"); var Material = Java.type('org.bukkit.Material'); +var ItemIDMaterial = require('./item-id-material.json') +var ItemIDRegex = /^[0-9]*$/ /** * 创建一个物品 @@ -20,8 +22,14 @@ item.create = function() { var argType = toString.call(idOrType) switch (argType) { case "[object Number]": + if (Material['LEGACY_PREFIX']) { + idOrType = Material[Material['LEGACY_PREFIX'] + ItemIDMaterial[idOrType]]; + } break; case "[object String]": + if (ItemIDRegex.test(idOrType)) { + idOrType = ItemIDMaterial[idOrType]; + } // 尝试获取老版本枚举 idOrType = Material[idOrType] || Material[Material['LEGACY_PREFIX'] + idOrType]; break;