From 584761945831fa84b6a23a62432d63d2184ca4d7 Mon Sep 17 00:00:00 2001 From: Zrips Date: Wed, 30 Mar 2016 16:42:36 +0300 Subject: [PATCH] 3.0 update --- .classpath | 11 + .externalToolBuilders/Create jar file.launch | 19 + .project | 27 + ItemList.yml | 702 ------ com/gamingmesh/jobs/Gui/.gitignore | 1 + .../Gui/{GuiTools.java => GuiManager.java} | 62 +- com/gamingmesh/jobs/HookEconomyTask.java | 4 +- com/gamingmesh/jobs/Jobs.java | 586 +++-- com/gamingmesh/jobs/JobsPlugin.java | 71 +- com/gamingmesh/jobs/NMS.java | 4 + com/gamingmesh/jobs/PlayerManager.java | 364 +++- com/gamingmesh/jobs/Signs/SignInfo.java | 56 +- com/gamingmesh/jobs/Signs/SignUtil.java | 129 +- .../jobs/actions/EntityActionInfo.java | 4 +- .../jobs/actions/MaterialActionInfo.java | 2 +- com/gamingmesh/jobs/api/JobsPaymentEvent.java | 88 +- com/gamingmesh/jobs/commands/.gitignore | 5 + com/gamingmesh/jobs/commands/Cmd.java | 9 + com/gamingmesh/jobs/commands/JobCommand.java | 2 +- .../jobs/commands/JobsCommands.java | 1905 +++-------------- com/gamingmesh/jobs/commands/list/.gitignore | 45 + .../jobs/commands/list/archive.java | 55 + com/gamingmesh/jobs/commands/list/bonus.java | 109 + com/gamingmesh/jobs/commands/list/browse.java | 72 + .../jobs/commands/list/convert.java | 78 + com/gamingmesh/jobs/commands/list/demote.java | 55 + .../jobs/commands/list/editpoints.java | 69 + com/gamingmesh/jobs/commands/list/employ.java | 54 + .../jobs/commands/list/expboost.java | 79 + com/gamingmesh/jobs/commands/list/fire.java | 53 + .../jobs/commands/list/fireall.java | 50 + com/gamingmesh/jobs/commands/list/give.java | 55 + com/gamingmesh/jobs/commands/list/glog.java | 101 + .../jobs/commands/list/grantxp.java | 62 + com/gamingmesh/jobs/commands/list/gtop.java | 105 + com/gamingmesh/jobs/commands/list/info.java | 53 + com/gamingmesh/jobs/commands/list/join.java | 83 + com/gamingmesh/jobs/commands/list/leave.java | 43 + .../jobs/commands/list/leaveall.java | 37 + com/gamingmesh/jobs/commands/list/limit.java | 173 ++ com/gamingmesh/jobs/commands/list/log.java | 100 + .../jobs/commands/list/moneyboost.java | 80 + .../jobs/commands/list/playerinfo.java | 42 + .../jobs/commands/list/pointboost.java | 80 + com/gamingmesh/jobs/commands/list/points.java | 53 + .../jobs/commands/list/promote.java | 54 + com/gamingmesh/jobs/commands/list/reload.java | 28 + .../jobs/commands/list/removexp.java | 61 + com/gamingmesh/jobs/commands/list/shop.java | 41 + .../jobs/commands/list/signupdate.java | 34 + com/gamingmesh/jobs/commands/list/stats.java | 52 + com/gamingmesh/jobs/commands/list/toggle.java | 72 + com/gamingmesh/jobs/commands/list/top.java | 114 + .../jobs/commands/list/transfer.java | 59 + com/gamingmesh/jobs/config/.gitignore | 26 + .../jobs/config/BossBarManager.java | 130 ++ com/gamingmesh/jobs/config/ConfigManager.java | 589 ++++- .../ExploreManager.java} | 6 +- .../jobs/config/GeneralConfigManager.java | 833 +++++++ com/gamingmesh/jobs/config/JobConfig.java | 561 ----- .../jobs/config/JobsConfiguration.java | 1586 -------------- .../jobs/config/LanguageManager.java | 436 ++++ .../jobs/config/NameTranslatorManager.java | 1627 ++++++++++++++ .../jobs/config/RestrictedAreaManager.java | 112 + .../jobs/config/RestrictedBlockManager.java | 126 ++ .../ScboardManager.java} | 13 +- .../jobs/config/ScheduleManager.java | 230 ++ com/gamingmesh/jobs/config/ShopManager.java | 384 ++++ com/gamingmesh/jobs/config/TitleManager.java | 187 ++ com/gamingmesh/jobs/container/.gitignore | 6 + .../jobs/container/BoostMultiplier.java | 25 + .../jobs/container/BossBarInfo.java | 39 + com/gamingmesh/jobs/container/Convert.java | 90 +- com/gamingmesh/jobs/container/Job.java | 62 +- com/gamingmesh/jobs/container/JobInfo.java | 26 +- com/gamingmesh/jobs/container/JobItems.java | 93 +- .../jobs/container/JobProgression.java | 298 +-- com/gamingmesh/jobs/container/JobsPlayer.java | 137 +- .../jobs/container/LocaleReader.java | 75 + com/gamingmesh/jobs/container/PlayerInfo.java | 20 + .../jobs/container/PlayerPoints.java | 53 + com/gamingmesh/jobs/container/ShopItem.java | 117 + com/gamingmesh/jobs/container/TopList.java | 36 +- com/gamingmesh/jobs/dao/JobsConnection.java | 64 +- com/gamingmesh/jobs/dao/JobsDAO.java | 385 ++-- com/gamingmesh/jobs/dao/JobsDAOMySQL.java | 181 +- com/gamingmesh/jobs/dao/JobsDAOSQLite.java | 256 ++- com/gamingmesh/jobs/economy/.gitignore | 1 + .../jobs/economy/BufferedEconomy.java | 100 +- .../jobs/economy/BufferedPayment.java | 38 +- com/gamingmesh/jobs/economy/PaymentData.java | 379 ++-- com/gamingmesh/jobs/economy/PointsData.java | 43 + com/gamingmesh/jobs/i18n/Language.java | 36 +- .../jobs/listeners/JobsListener.java | 135 +- .../jobs/listeners/JobsPaymentListener.java | 365 ++-- .../jobs/listeners/McMMOlistener.java | 33 +- .../jobs/listeners/MythicMobsListener.java | 59 +- .../listeners/PistonProtectionListener.java | 27 +- com/gamingmesh/jobs/nmsUtil/v1_7.java | 8 + com/gamingmesh/jobs/nmsUtil/v1_8.java | 8 +- com/gamingmesh/jobs/nmsUtil/v1_9.class | Bin 1335 -> 1721 bytes com/gamingmesh/jobs/nmsUtil/v1_9.java | 7 + com/gamingmesh/jobs/stuff/.gitignore | 2 + com/gamingmesh/jobs/stuff/ActionBar.java | 100 +- com/gamingmesh/jobs/stuff/ChatColor.java | 17 +- com/gamingmesh/jobs/stuff/FileDownloader.java | 35 - com/gamingmesh/jobs/stuff/Loging.java | 6 +- .../jobs/stuff/OfflinePlayerList.java | 54 - .../jobs/stuff/PerformCommands.java | 66 +- com/gamingmesh/jobs/stuff/Perm.java | 50 +- com/gamingmesh/jobs/stuff/ScheduleUtil.java | 149 -- com/gamingmesh/jobs/stuff/TabComplete.java | 199 +- com/gamingmesh/jobs/stuff/TranslateName.java | 90 - .../jobs/tasks/BufferedPaymentTask.java | 26 +- .../jobs/tasks/BufferedPaymentThread.java | 6 +- .../jobs/tasks/DatabaseSaveThread.java | 6 +- jobConfig.yml | 1266 +++++++++-- plugin.yml | 8 +- shopItems.yml | 109 + 119 files changed, 11764 insertions(+), 6825 deletions(-) create mode 100644 .classpath create mode 100644 .externalToolBuilders/Create jar file.launch create mode 100644 .project delete mode 100644 ItemList.yml rename com/gamingmesh/jobs/Gui/{GuiTools.java => GuiManager.java} (73%) create mode 100644 com/gamingmesh/jobs/commands/Cmd.java create mode 100644 com/gamingmesh/jobs/commands/list/.gitignore create mode 100644 com/gamingmesh/jobs/commands/list/archive.java create mode 100644 com/gamingmesh/jobs/commands/list/bonus.java create mode 100644 com/gamingmesh/jobs/commands/list/browse.java create mode 100644 com/gamingmesh/jobs/commands/list/convert.java create mode 100644 com/gamingmesh/jobs/commands/list/demote.java create mode 100644 com/gamingmesh/jobs/commands/list/editpoints.java create mode 100644 com/gamingmesh/jobs/commands/list/employ.java create mode 100644 com/gamingmesh/jobs/commands/list/expboost.java create mode 100644 com/gamingmesh/jobs/commands/list/fire.java create mode 100644 com/gamingmesh/jobs/commands/list/fireall.java create mode 100644 com/gamingmesh/jobs/commands/list/give.java create mode 100644 com/gamingmesh/jobs/commands/list/glog.java create mode 100644 com/gamingmesh/jobs/commands/list/grantxp.java create mode 100644 com/gamingmesh/jobs/commands/list/gtop.java create mode 100644 com/gamingmesh/jobs/commands/list/info.java create mode 100644 com/gamingmesh/jobs/commands/list/join.java create mode 100644 com/gamingmesh/jobs/commands/list/leave.java create mode 100644 com/gamingmesh/jobs/commands/list/leaveall.java create mode 100644 com/gamingmesh/jobs/commands/list/limit.java create mode 100644 com/gamingmesh/jobs/commands/list/log.java create mode 100644 com/gamingmesh/jobs/commands/list/moneyboost.java create mode 100644 com/gamingmesh/jobs/commands/list/playerinfo.java create mode 100644 com/gamingmesh/jobs/commands/list/pointboost.java create mode 100644 com/gamingmesh/jobs/commands/list/points.java create mode 100644 com/gamingmesh/jobs/commands/list/promote.java create mode 100644 com/gamingmesh/jobs/commands/list/reload.java create mode 100644 com/gamingmesh/jobs/commands/list/removexp.java create mode 100644 com/gamingmesh/jobs/commands/list/shop.java create mode 100644 com/gamingmesh/jobs/commands/list/signupdate.java create mode 100644 com/gamingmesh/jobs/commands/list/stats.java create mode 100644 com/gamingmesh/jobs/commands/list/toggle.java create mode 100644 com/gamingmesh/jobs/commands/list/top.java create mode 100644 com/gamingmesh/jobs/commands/list/transfer.java create mode 100644 com/gamingmesh/jobs/config/BossBarManager.java rename com/gamingmesh/jobs/{stuff/Explore.java => config/ExploreManager.java} (95%) create mode 100644 com/gamingmesh/jobs/config/GeneralConfigManager.java delete mode 100644 com/gamingmesh/jobs/config/JobConfig.java delete mode 100644 com/gamingmesh/jobs/config/JobsConfiguration.java create mode 100644 com/gamingmesh/jobs/config/LanguageManager.java create mode 100644 com/gamingmesh/jobs/config/NameTranslatorManager.java create mode 100644 com/gamingmesh/jobs/config/RestrictedAreaManager.java create mode 100644 com/gamingmesh/jobs/config/RestrictedBlockManager.java rename com/gamingmesh/jobs/{stuff/Scboard.java => config/ScboardManager.java} (78%) create mode 100644 com/gamingmesh/jobs/config/ScheduleManager.java create mode 100644 com/gamingmesh/jobs/config/ShopManager.java create mode 100644 com/gamingmesh/jobs/config/TitleManager.java create mode 100644 com/gamingmesh/jobs/container/BoostMultiplier.java create mode 100644 com/gamingmesh/jobs/container/BossBarInfo.java create mode 100644 com/gamingmesh/jobs/container/LocaleReader.java create mode 100644 com/gamingmesh/jobs/container/PlayerInfo.java create mode 100644 com/gamingmesh/jobs/container/PlayerPoints.java create mode 100644 com/gamingmesh/jobs/container/ShopItem.java create mode 100644 com/gamingmesh/jobs/economy/PointsData.java delete mode 100644 com/gamingmesh/jobs/stuff/FileDownloader.java delete mode 100644 com/gamingmesh/jobs/stuff/OfflinePlayerList.java delete mode 100644 com/gamingmesh/jobs/stuff/ScheduleUtil.java delete mode 100644 com/gamingmesh/jobs/stuff/TranslateName.java create mode 100644 shopItems.yml diff --git a/.classpath b/.classpath new file mode 100644 index 00000000..e92c2d02 --- /dev/null +++ b/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/.externalToolBuilders/Create jar file.launch b/.externalToolBuilders/Create jar file.launch new file mode 100644 index 00000000..e88582ef --- /dev/null +++ b/.externalToolBuilders/Create jar file.launch @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 00000000..cf8ba2bf --- /dev/null +++ b/.project @@ -0,0 +1,27 @@ + + + Jobs + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/Create jar file.launch + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/ItemList.yml b/ItemList.yml deleted file mode 100644 index 2dcfa314..00000000 --- a/ItemList.yml +++ /dev/null @@ -1,702 +0,0 @@ -# You can edit text between - and =, keep spaces! -# if you not sure how to edit it, dont do it at all :) -# You can use any color you want and translate to any text you want -# first 2 numbers are id with meta data, keep it as it is for block/item/mob -# Text after = are minecraft'ish name, like Stone/Granite/Diorite and so on, all of them are stone -# Ex: '5:3 - Jungle Wood Plank = planks' can be changed to '5:3 - &3Jungle &4Woody &3Planky = planks' -ItemList: - - '0 - Air = air' - - '1 - All Stone = stone' - - '1:0 - Stone = stone' - - '1:1 - Granite = stone' - - '1:2 - Polished Granite = stone' - - '1:3 - Diorite = stone' - - '1:4 - Polished Diorite = stone' - - '1:5 - Andesite = stone' - - '1:6 - Polished Andesite = stone' - - '2 - Grass = grass' - - '3 - All Dirt = dirt' - - '3:0 - Dirt = dirt' - - '3:1 - Coarse Dirt = dirt' - - '3:2 - Podzol = dirt' - - '4 - Cobblestone = cobblestone' - - '5 - All Wood Plank = planks' - - '5:0 - Oak Wood Plank = planks' - - '5:1 - Spruce Wood Plank = planks' - - '5:2 - Birch Wood Plank = planks' - - '5:3 - Jungle Wood Plank = planks' - - '5:4 - Acacia Wood Plank = planks' - - '5:5 - Dark Oak Wood Plank = planks' - - '6 - All Saplings = sapling' - - '6:0 - Oak Sapling = sapling' - - '6:1 - Spruce Sapling = sapling' - - '6:2 - Birch Sapling = sapling' - - '6:3 - Jungle Sapling = sapling' - - '6:4 - Acacia Sapling = sapling' - - '6:5 - Dark Oak Sapling = sapling' - - '7 - Bedrock = bedrock' - - '8 - Flowing Water = flowing_water' - - '9 - Still Water = water' - - '10 - Flowing Lava = flowing_lava' - - '11 - Still Lava = lava' - - '12 - All Sand = sand' - - '12:0 - Sand = sand' - - '12:1 - Red Sand = sand' - - '13 - Gravel = gravel' - - '14 - Gold Ore = gold_ore' - - '15 - Iron Ore = iron_ore' - - '16 - Coal Ore = coal_ore' - - '17 - All Wood = log' - - '17:0 - Oak Wood = log' - - '17:1 - Spruce Wood = log' - - '17:2 - Birch Wood = log' - - '17:3 - Jungle Wood = log' - - '18 - All Leaves = leaves' - - '18:0 - Oak Leaves = leaves' - - '18:1 - Spruce Leaves = leaves' - - '18:2 - Birch Leaves = leaves' - - '18:3 - Jungle Leaves = leaves' - - '19 - Sponge = sponge' - - '19:1 - Wet Sponge = sponge' - - '20 - Glass = glass' - - '21 - Lapis Lazuli Ore = lapis_ore' - - '22 - Lapis Lazuli Block = lapis_block' - - '23 - Dispenser = dispenser' - - '24 - Sandstone = sandstone' - - '24:1 - Chiseled Sandstone = sandstone' - - '24:2 - Smooth Sandstone = sandstone' - - '25 - Note Block = noteblock' - - '26 - Bed = bed' - - '27 - Powered Rail = golden_rail' - - '28 - Detector Rail = detector_rail' - - '29 - Sticky Piston = sticky_piston' - - '30 - Cobweb = web' - - '31 - Dead Shrub = tallgrass' - - '31:1 - Grass = tallgrass' - - '31:2 - Fern = tallgrass' - - '32 - Dead Shrub = deadbush' - - '33 - Piston = piston' - - '34 - Piston Head = piston_head' - - '35 - All Wool = wool' - - '35:0 - White Wool = wool' - - '35:1 - Orange Wool = wool' - - '35:2 - Magenta Wool = wool' - - '35:3 - Light Blue Wool = wool' - - '35:4 - Yellow Wool = wool' - - '35:5 - Lime Wool = wool' - - '35:6 - Pink Wool = wool' - - '35:7 - Gray Wool = wool' - - '35:8 - Light Gray Wool = wool' - - '35:9 - Cyan Wool = wool' - - '35:10 - Purple Wool = wool' - - '35:11 - Blue Wool = wool' - - '35:12 - Brown Wool = wool' - - '35:13 - Green Wool = wool' - - '35:14 - Red Wool = wool' - - '35:15 - Black Wool = wool' - - '37 - Dandelion = yellow_flower' - - '38 - All Flowers = red_flower' - - '38:0 - Poppy = red_flower' - - '38:1 - Blue Orchid = red_flower' - - '38:2 - Allium = red_flower' - - '38:3 - Azure Bluet = red_flower' - - '38:4 - Red Tulip = red_flower' - - '38:5 - Orange Tulip = red_flower' - - '38:6 - White Tulip = red_flower' - - '38:7 - Pink Tulip = red_flower' - - '38:8 - Oxeye Daisy = red_flower' - - '39 - Brown Mushroom = brown_mushroom' - - '40 - Red Mushroom = red_mushroom' - - '41 - Gold Block = gold_block' - - '42 - Iron Block = iron_block' - - '43 - All Double Slabs = double_stone_slab' - - '43:0 - Double Stone Slab = double_stone_slab' - - '43:1 - Double Sandstone Slab = double_stone_slab' - - '43:2 - Double Wooden Slab = double_stone_slab' - - '43:3 - Double Cobblestone Slab = double_stone_slab' - - '43:4 - Double Brick Slab = double_stone_slab' - - '43:5 - Double Stone Brick Slab = double_stone_slab' - - '43:6 - Double Nether Brick Slab = double_stone_slab' - - '43:7 - Double Quartz Slab = double_stone_slab' - - '44 - All Slabs = stone_slab' - - '44:0 - Stone Slab = stone_slab' - - '44:1 - Sandstone Slab = stone_slab' - - '44:2 - Wooden Slab = stone_slab' - - '44:3 - Cobblestone Slab = stone_slab' - - '44:4 - Brick Slab = stone_slab' - - '44:5 - Stone Brick Slab = stone_slab' - - '44:6 - Nether Brick Slab = stone_slab' - - '44:7 - Quartz Slab = stone_slab' - - '45 - Bricks = brick_block' - - '46 - TNT = tnt' - - '47 - Bookshelf = bookshelf' - - '48 - Moss Stone = mossy_cobblestone' - - '49 - Obsidian = obsidian' - - '50 - Torch = torch' - - '51 - Fire = fire' - - '52 - Monster Spawner = mob_spawner' - - '53 - Oak Wood Stairs = oak_stairs' - - '54 - Chest = chest' - - '55 - Redstone Wire = redstone_wire' - - '56 - Diamond Ore = diamond_ore' - - '57 - Diamond Block = diamond_block' - - '58 - Crafting Table = crafting_table' - - '59 - Wheat Crops = wheat' - - '60 - Farmland = farmland' - - '61 - Furnace = furnace' - - '62 - Burning Furnace = lit_furnace' - - '63 - Standing Sign Block = standing_sign' - - '64 - Wooden Door Block = wooden_door' - - '65 - Ladder = ladder' - - '66 - Rail = rail' - - '67 - Cobblestone Stairs = stone_stairs' - - '68 - Wall-mounted Sign Block = wall_sign' - - '69 - Lever = lever' - - '70 - Stone Pressure Plate = stone_pressure_plate' - - '71 - Iron Door Block = iron_door' - - '72 - Wooden Pressure Plate = wooden_pressure_plate' - - '73 - Redstone Ore = redstone_ore' - - '74 - Glowing Redstone Ore = lit_redstone_ore' - - '75 - Redstone Torch (off) = unlit_redstone_torch' - - '76 - Redstone Torch (on) = redstone_torch' - - '77 - Stone Button = stone_button' - - '78 - Snow = snow_layer' - - '79 - Ice = ice' - - '80 - Snow Block = snow' - - '81 - Cactus = cactus' - - '82 - Clay = clay' - - '83 - Sugar Canes = reeds' - - '84 - Jukebox = jukebox' - - '85 - Oak Fence = fence' - - '86 - Pumpkin = pumpkin' - - '87 - Netherrack = netherrack' - - '88 - Soul Sand = soul_sand' - - '89 - Glowstone = glowstone' - - '90 - Nether Portal = portal' - - '91 - Jack o''Lantern = lit_pumpkin' - - '92 - Cake Block = cake' - - '93 - Redstone Repeater Block (off) = unpowered_repeater' - - '94 - Redstone Repeater Block (on) = powered_repeater' - - '95 - All Stained Glass = stained_glass' - - '95:0 - White Stained Glass = stained_glass' - - '95:1 - Orange Stained Glass = stained_glass' - - '95:2 - Magenta Stained Glass = stained_glass' - - '95:3 - Light Blue Stained Glass = stained_glass' - - '95:4 - Yellow Stained Glass = stained_glass' - - '95:5 - Lime Stained Glass = stained_glass' - - '95:6 - Pink Stained Glass = stained_glass' - - '95:7 - Gray Stained Glass = stained_glass' - - '95:8 - Light Gray Stained Glass = stained_glass' - - '95:9 - Cyan Stained Glass = stained_glass' - - '95:10 - Purple Stained Glass = stained_glass' - - '95:11 - Blue Stained Glass = stained_glass' - - '95:12 - Brown Stained Glass = stained_glass' - - '95:13 - Green Stained Glass = stained_glass' - - '95:14 - Red Stained Glass = stained_glass' - - '95:15 - Black Stained Glass = stained_glass' - - '96 - Wooden Trapdoor = trapdoor' - - '97 - Stone Monster Egg = monster_egg' - - '97:1 - Cobblestone Monster Egg = monster_egg' - - '97:2 - Stone Brick Monster Egg = monster_egg' - - '97:3 - Mossy Stone Brick Monster Egg = monster_egg' - - '97:4 - Cracked Stone Brick Monster Egg = monster_egg' - - '97:5 - Chiseled Stone Brick Monster Egg = monster_egg' - - '98 - Stone Bricks = stonebrick' - - '98:1 - Mossy Stone Bricks = stonebrick' - - '98:2 - Cracked Stone Bricks = stonebrick' - - '98:3 - Chiseled Stone Bricks = stonebrick' - - '99 - Red Mushroom Cap = stonebrick' - - '100 - Brown Mushroom Cap = stonebrick' - - '101 - Iron Bars = iron_bars' - - '102 - Glass Pane = glass_pane' - - '103 - Melon Block = melon_block' - - '104 - Pumpkin Stem = pumpkin_stem' - - '105 - Melon Stem = melon_stem' - - '106 - Vines = vine' - - '107 - Oak Fence Gate = fence_gate' - - '108 - Brick Stairs = brick_stairs' - - '109 - Stone Brick Stairs = stone_brick_stairs' - - '110 - Mycelium = mycelium' - - '111 - Lily Pad = waterlily' - - '112 - Nether Brick = nether_brick' - - '113 - Nether Brick Fence = nether_brick_fence' - - '114 - Nether Brick Stairs = nether_brick_stairs' - - '115 - Nether Wart = nether_wart' - - '116 - Enchantment Table = enchanting_table' - - '117 - Brewing Stand = brewing_stand' - - '118 - Cauldron = cauldron' - - '119 - End Portal = end_portal' - - '120 - End Portal Frame = end_portal_frame' - - '121 - End Stone = end_stone' - - '122 - Dragon Egg = dragon_egg' - - '123 - Redstone Lamp (inactive) = redstone_lamp' - - '124 - Redstone Lamp (active) = lit_redstone_lamp' - - '125 - All Double Wood Slab = double_wooden_slab' - - '125:0 - Double Oak Wood Slab = double_wooden_slab' - - '125:1 - Double Spruce Wood Slab = double_wooden_slab' - - '125:2 - Double Birch Wood Slab = double_wooden_slab' - - '125:3 - Double Jungle Wood Slab = double_wooden_slab' - - '125:4 - Double Acacia Wood Slab = double_wooden_slab' - - '125:5 - Double Dark Oak Wood Slab = double_wooden_slab' - - '126 - All Wood Slab = wooden_slab' - - '126:0 - Oak Wood Slab = wooden_slab' - - '126:1 - Spruce Wood Slab = wooden_slab' - - '126:2 - Birch Wood Slab = wooden_slab' - - '126:3 - Jungle Wood Slab = wooden_slab' - - '126:4 - Acacia Wood Slab = wooden_slab' - - '126:5 - Dark Oak Wood Slab = wooden_slab' - - '127 - Cocoa = cocoa' - - '128 - Sandstone Stairs = sandstone_stairs' - - '129 - Emerald Ore = emerald_ore' - - '130 - Ender Chest = ender_chest' - - '131 - Tripwire Hook = tripwire_hook' - - '132 - Tripwire = tripwire_hook' - - '133 - Emerald Block = emerald_block' - - '134 - Spruce Wood Stairs = spruce_stairs' - - '135 - Birch Wood Stairs = birch_stairs' - - '136 - Jungle Wood Stairs = jungle_stairs' - - '137 - Command Block = command_block' - - '138 - Beacon = beacon' - - '139 - Cobblestone Wall = cobblestone_wall' - - '139:1 - Mossy Cobblestone Wall = cobblestone_wall' - - '140 - Flower Pot = flower_pot' - - '141 - Carrots = carrots' - - '142 - Potatoes = potatoes' - - '143 - Wooden Button = wooden_button' - - '144 - Mob Head = skull' - - '145 - Anvil = anvil' - - '146 - Trapped Chest = trapped_chest' - - '147 - Weighted Pressure Plate (light) = light_weighted_pressure_plate' - - '148 - Weighted Pressure Plate (heavy) = heavy_weighted_pressure_plate' - - '149 - Redstone Comparator (inactive) = unpowered_comparator' - - '150 - Redstone Comparator (active) = powered_comparator' - - '151 - Daylight Sensor = daylight_detector' - - '152 - Redstone Block = redstone_block' - - '153 - Nether Quartz Ore = quartz_ore' - - '154 - Hopper = hopper' - - '155 - Quartz Block = quartz_block' - - '155:1 - Chiseled Quartz Block = quartz_block' - - '155:2 - Pillar Quartz Block = quartz_block' - - '156 - Quartz Stairs = quartz_stairs' - - '157 - Activator Rail = activator_rail' - - '158 - Dropper = dropper' - - '159 - All Stained Clays = stained_hardened_clay' - - '159:0 - White Stained Clay = stained_hardened_clay' - - '159:1 - Orange Stained Clay = stained_hardened_clay' - - '159:2 - Magenta Stained Clay = stained_hardened_clay' - - '159:3 - Light Blue Stained Clay = stained_hardened_clay' - - '159:4 - Yellow Stained Clay = stained_hardened_clay' - - '159:5 - Lime Stained Clay = stained_hardened_clay' - - '159:6 - Pink Stained Clay = stained_hardened_clay' - - '159:7 - Gray Stained Clay = stained_hardened_clay' - - '159:8 - Light Gray Stained Clay = stained_hardened_clay' - - '159:9 - Cyan Stained Clay = stained_hardened_clay' - - '159:10 - Purple Stained Clay = stained_hardened_clay' - - '159:11 - Blue Stained Clay = stained_hardened_clay' - - '159:12 - Brown Stained Clay = stained_hardened_clay' - - '159:13 - Green Stained Clay = stained_hardened_clay' - - '159:14 - Red Stained Clay = stained_hardened_clay' - - '159:15 - Black Stained Clay = stained_hardened_clay' - - '160 - All Stained Glass Panes = stained_glass_pane' - - '160:0 - White Stained Glass Pane = stained_glass_pane' - - '160:1 - Orange Stained Glass Pane = stained_glass_pane' - - '160:2 - Magenta Stained Glass Pane = stained_glass_pane' - - '160:3 - Light Blue Stained Glass Pane = stained_glass_pane' - - '160:4 - Yellow Stained Glass Pane = stained_glass_pane' - - '160:5 - Lime Stained Glass Pane = stained_glass_pane' - - '160:6 - Pink Stained Glass Pane = stained_glass_pane' - - '160:7 - Gray Stained Glass Pane = stained_glass_pane' - - '160:8 - Light Gray Stained Glass Pane = stained_glass_pane' - - '160:9 - Cyan Stained Glass Pane = stained_glass_pane' - - '160:10 - Purple Stained Glass Pane = stained_glass_pane' - - '160:11 - Blue Stained Glass Pane = stained_glass_pane' - - '160:12 - Brown Stained Glass Pane = stained_glass_pane' - - '160:13 - Green Stained Glass Pane = stained_glass_pane' - - '160:14 - Red Stained Glass Pane = stained_glass_pane' - - '160:15 - Black Stained Glass Pane = stained_glass_pane' - - '161 - Acacia Or Dark Oak Leaves = leaves2' - - '161:0 - Acacia Leaves = leaves2' - - '161:1 - Dark Oak Leaves = leaves2' - - '162 - Acacia Or Dark Oak Wood = logs2' - - '162:0 - Acacia Wood = logs2' - - '162:1 - Dark Oak Wood = logs2' - - '163 - Acacia Wood Stairs = acacia_stairs' - - '164 - Dark Oak Wood Stairs = dark_oak_stairs' - - '165 - Slime Block = slime' - - '166 - Barrier = barrier' - - '167 - Iron Trapdoor = iron_trapdoor' - - '168 - All Prismarine = prismarine' - - '168:0 - Prismarine = prismarine' - - '168:1 - Prismarine Bricks = prismarine' - - '168:2 - Dark Prismarine = prismarine' - - '169 - Sea Lantern = sea_lantern' - - '170 - Hay Bale = hay_block' - - '171 - All Carpet = carpet' - - '171:0 - White Carpet = carpet' - - '171:1 - Orange Carpet = carpet' - - '171:2 - Magenta Carpet = carpet' - - '171:3 - Light Blue Carpet = carpet' - - '171:4 - Yellow Carpet = carpet' - - '171:5 - Lime Carpet = carpet' - - '171:6 - Pink Carpet = carpet' - - '171:7 - Gray Carpet = carpet' - - '171:8 - Light Gray Carpet = carpet' - - '171:9 - Cyan Carpet = carpet' - - '171:10 - Purple Carpet = carpet' - - '171:11 - Blue Carpet = carpet' - - '171:12 - Brown Carpet = carpet' - - '171:13 - Green Carpet = carpet' - - '171:14 - Red Carpet = carpet' - - '171:15 - Black Carpet = carpet' - - '172 - Hardened Clay = hardened_clay' - - '173 - Block of Coal = coal_block' - - '174 - Packed Ice = packed_ice' - - '175 - All Big Flowers = double_plant' - - '175:0 - Sunflower = double_plant' - - '175:1 - Lilac = double_plant' - - '175:2 - Double Tallgrass = double_plant' - - '175:3 - Large Fern = double_plant' - - '175:4 - Rose Bush = double_plant' - - '175:5 - Peony = double_plant' - - '176 - Free-standing Banner = standing_banner' - - '177 - Wall-mounted Banner = wall_banner' - - '178 - Inverted Daylight Sensor = daylight_detector_inverted' - - '179 - Red Sandstone = red_sandstone' - - '179:1 - Smooth Red Sandstone = red_sandstone' - - '179:2 - Chiseled Red Sandstone = red_sandstone' - - '180 - Red Sandstone Stairs = red_sandstone_stairs' - - '181 - Double Red Sandstone Slab = stone_slab2' - - '182 - Red Sandstone Slab = double_stone_slab2' - - '183 - Spruce Fence Gate = spruce_fence_gate' - - '184 - Birch Fence Gate = birch_fence_gate' - - '185 - Jungle Fence Gate = jungle_fence_gate' - - '186 - Dark Oak Fence Gate = dark_oak_fence_gate' - - '187 - Acacia Fence Gate = acacia_fence_gate' - - '188 - Spruce Fence = spruce_fence' - - '189 - Birch Fence = birch_fence' - - '190 - Jungle Fence = jungle_fence' - - '191 - Dark Oak Fence = dark_oak_fence' - - '192 - Acacia Fence = acacia_fence' - - '193 - Spure Door Block = spruce_door' - - '194 - Birch Door Block = birch_door' - - '195 - Jungle Door Block = jungle_door' - - '196 - Acacia Door Block = acacia_door' - - '197 - Dark Oak Door Block = dark_oak_door' - - '256 - Iron Shovel = iron_shovel' - - '257 - Iron Pickaxe = iron_pickaxe' - - '258 - Iron Axe = iron_axe' - - '259 - Flint and Steel = flint_and_steel' - - '260 - Apple = apple' - - '261 - Bow = bow' - - '262 - Arrow = arrow' - - '263 - Coal = coal' - - '263:1 - Charcoal = coal' - - '264 - Diamond = diamond' - - '265 - Iron Ingot = iron_ingot' - - '266 - Gold Ingot = gold_ingot' - - '267 - Iron Sword = iron_sword' - - '268 - Wooden Sword = wooden_sword' - - '269 - Wooden Shovel = wooden_shovel' - - '270 - Wooden Pickaxe = wooden_pickaxe' - - '271 - Wooden Axe = wooden_axe' - - '272 - Stone Sword = stone_sword' - - '273 - Stone Shovel = stone_shovel' - - '274 - Stone Pickaxe = stone_pickaxe' - - '275 - Stone Axe = stone_axe' - - '276 - Diamond Sword = diamond_sword' - - '277 - Diamond Shovel = diamond_shovel' - - '278 - Diamond Pickaxe = diamond_pickaxe' - - '279 - Diamond Axe = diamond_axe' - - '280 - Stick = stick' - - '281 - Bowl = bowl' - - '282 - Mushroom Stew = mushroom_stew' - - '283 - Golden Sword = golden_sword' - - '284 - Golden Shovel = golden_shovel' - - '285 - Golden Pickaxe = golden_pickaxe' - - '286 - Golden Axe = golden_axe' - - '287 - String = string' - - '288 - Feather = feather' - - '289 - Gunpowder = gunpowder' - - '290 - Wooden Hoe = wooden_hoe' - - '291 - Stone Hoe = stone_hoe' - - '292 - Iron Hoe = iron_hoe' - - '293 - Diamond Hoe = diamond_hoe' - - '294 - Golden Hoe = golden_hoe' - - '295 - Wheat Seeds = wheat_seeds' - - '296 - Wheat = wheat' - - '297 - Bread = bread' - - '298 - Leather Helmet = leather_helmet' - - '299 - Leather Tunic = leather_chestplate' - - '300 - Leather Pants = leather_leggings' - - '301 - Leather Boots = leather_boots' - - '302 - Chainmail Helmet = chainmail_helmet' - - '303 - Chainmail Chestplate = chainmail_chestplate' - - '304 - Chainmail Leggings = chainmail_leggings' - - '305 - Chainmail Boots = chainmail_boots' - - '306 - Iron Helmet = iron_helmet' - - '307 - Iron Chestplate = iron_chestplate' - - '308 - Iron Leggings = iron_leggings' - - '309 - Iron Boots = iron_boots' - - '310 - Diamond Helmet = diamond_helmet' - - '311 - Diamond Chestplate = diamond_chestplate' - - '312 - Diamond Leggings = diamond_leggings' - - '313 - Diamond Boots = diamond_boots' - - '314 - Golden Helmet = golden_helmet' - - '315 - Golden Chestplate = golden_chestplate' - - '316 - Golden Leggings = golden_leggings' - - '317 - Golden Boots = golden_boots' - - '318 - Flint = flint' - - '319 - Raw Porkchop = porkchop' - - '320 - Cooked Porkchop = cooked_porkchop' - - '321 - Painting = painting' - - '322 - Golden Apple = golden_apple' - - '322:1 - Enchanted Golden Apple = golden_apple' - - '323 - Sign = sign' - - '324 - Wooden Door = wooden_door' - - '325 - Bucket = bucket' - - '326 - Water Bucket = water_bucket' - - '327 - Lava Bucket = lava_bucket' - - '328 - Minecart = minecart' - - '329 - Saddle = saddle' - - '330 - Iron Door = iron_door' - - '331 - Redstone = redstone' - - '332 - Snowball = snowball' - - '333 - Boat = boat' - - '334 - Leather = leather' - - '335 - Milk Bucket = milk_bucket' - - '336 - Brick = brick' - - '337 - Clay Ball = clay_ball' - - '338 - Sugar Canes = reeds' - - '339 - Paper = paper' - - '340 - Book = book' - - '341 - Slimeball = slime_ball' - - '342 - Minecart with Chest = chest_minecart' - - '343 - Minecart with Furnace = furnace_minecart' - - '344 - Egg = egg' - - '345 - Compass = compass' - - '346 - Fishing Rod = fishing_rod' - - '347 - Clock = clock' - - '348 - Glowstone Dust = glowstone_dust' - - '349 - Raw Fish = fish' - - '349:1 - Raw Salmon = fish' - - '349:2 - Clownfish = fish' - - '349:3 - Pufferfish = fish' - - '350 - Cooked Fish = cooked_fish' - - '350:1 - Cooked Salmon = cooked_fish' - - '351 - All Dyes = dye' - - '351:0 - Ink Sack = dye' - - '351:1 - Rose Red = dye' - - '351:2 - Cactus Green = dye' - - '351:3 - Coco Beans = dye' - - '351:4 - Lapis Lazuli = dye' - - '351:5 - Purple Dye = dye' - - '351:6 - Cyan Dye = dye' - - '351:7 - Light Gray Dye = dye' - - '351:8 - Gray Dye = dye' - - '351:9 - Pink Dye = dye' - - '351:10 - Lime Dye = dye' - - '351:11 - Dandelion Yellow = dye' - - '351:12 - Light Blue Dye = dye' - - '351:13 - Magenta Dye = dye' - - '351:14 - Orange Dye = dye' - - '351:15 - Bone Meal = dye' - - '352 - Bone = bone' - - '353 - Sugar = sugar' - - '354 - Cake = cake' - - '355 - Bed = bed' - - '356 - Redstone Repeater = repeater' - - '357 - Cookie = cookie' - - '358 - Map = filled_map' - - '359 - Shears = shears' - - '360 - Melon = melon' - - '361 - Pumpkin Seeds = pumpkin_seeds' - - '362 - Melon Seeds = melon_seeds' - - '363 - Raw Beef = beef' - - '364 - Steak = cooked_beef' - - '365 - Raw Chicken = chicken' - - '366 - Cooked Chicken = cooked_chicken' - - '367 - Rotten Flesh = rotten_flesh' - - '368 - Ender Pearl = ender_pearl' - - '369 - Blaze Rod = blaze_rod' - - '370 - Ghast Tear = ghast_tear' - - '371 - Gold Nugget = gold_nugget' - - '372 - Nether Wart = nether_wart' - - '373 - Potion = potion' - - '374 - Glass Bottle = glass_bottle' - - '375 - Spider Eye = spider_eye' - - '376 - Fermented Spider Eye = fermented_spider_eye' - - '377 - Blaze Powder = blaze_powder' - - '378 - Magma Cream = magma_cream' - - '379 - Brewing Stand = brewing_stand' - - '380 - Cauldron = cauldron' - - '381 - Eye of Ender = ender_eye' - - '382 - Glistering Melon = speckled_melon' - - '383:50 - Spawn Creeper = spawn_egg' - - '383:51 - Spawn Skeleton = spawn_egg' - - '383:52 - Spawn Spider = spawn_egg' - - '383:54 - Spawn Zombie = spawn_egg' - - '383:55 - Spawn Slime = spawn_egg' - - '383:56 - Spawn Ghast = spawn_egg' - - '383:57 - Spawn Pigman = spawn_egg' - - '383:58 - Spawn Enderman = spawn_egg' - - '383:59 - Spawn Cave Spider = spawn_egg' - - '383:60 - Spawn Silverfish = spawn_egg' - - '383:61 - Spawn Blaze = spawn_egg' - - '383:62 - Spawn Magma Cube = spawn_egg' - - '383:65 - Spawn Bat = spawn_egg' - - '383:66 - Spawn Witch = spawn_egg' - - '383:67 - Spawn Endermite = spawn_egg' - - '383:68 - Spawn Guardian = spawn_egg' - - '383:90 - Spawn Pig = spawn_egg' - - '383:91 - Spawn Sheep = spawn_egg' - - '383:92 - Spawn Cow = spawn_egg' - - '383:93 - Spawn Chicken = spawn_egg' - - '383:94 - Spawn Squid = spawn_egg' - - '383:95 - Spawn Wolf = spawn_egg' - - '383:96 - Spawn Mooshroom = spawn_egg' - - '383:98 - Spawn Ocelot = spawn_egg' - - '383:100 - Spawn Horse = spawn_egg' - - '383:101 - Spawn Rabbit = spawn_egg' - - '383:120 - Spawn Villager = spawn_egg' - - '384 - Bottle o'' Enchanting = experience_bottle' - - '385 - Fire Charge = fire_charge' - - '386 - Book and Quill = writable_book' - - '387 - Written Book = written_book' - - '388 - Emerald = emerald' - - '389 - Item Frame = item_frame' - - '390 - Flower Pot = flower_pot' - - '391 - Carrot = carrot' - - '392 - Potato = potato' - - '393 - Baked Potato = baked_potato' - - '394 - Poisonous Potato = poisonous_potato' - - '395 - Empty Map = map' - - '396 - Golden Carrot = golden_carrot' - - '397 - Mob Head (Skeleton) = skull' - - '397:1 - Mob Head (Wither Skeleton) = skull' - - '397:2 - Mob Head (Zombie) = skull' - - '397:3 - Mob Head (Human) = skull' - - '397:4 - Mob Head (Creeper) = skull' - - '398 - Carrot on a Stick = carrot_on_a_stick' - - '399 - Nether Star = nether_star' - - '400 - Pumpkin Pie = pumpkin_pie' - - '401 - Firework Rocket = fireworks' - - '402 - Firework Star = firework_charge' - - '403 - Enchanted Book = enchanted_book' - - '404 - Redstone Comparator = comparator' - - '405 - Nether Brick = netherbrick' - - '406 - Nether Quartz = quartz' - - '407 - Minecart with TNT = tnt_minecart' - - '408 - Minecart with Hopper = hopper_minecart' - - '409 - Prismarine Shard = prismarine_shard' - - '410 - Prismarine Crystals = prismarine_crystals' - - '411 - Raw Rabbit = rabbit' - - '412 - Cooked Rabbit = cooked_rabbit' - - '413 - Rabbit Stew = rabbit_stew' - - '414 - Rabbit''s Foot = rabbit_foot' - - '415 - Rabbit Hide = rabbit_hide' - - '416 - Armor Stand = armor_stand' - - '417 - Iron Horse Armor = iron_horse_armor' - - '418 - Golden Horse Armor = golden_horse_armor' - - '419 - Diamond Horse Armor = diamond_horse_armor' - - '420 - Lead = lead' - - '421 - Name Tag = name_tag' - - '422 - Minecart with Command Block = command_block_minecart' - - '423 - Raw Mutton = mutton' - - '424 - Cooked Mutton = cooked_mutton' - - '425 - Banner = banner' - - '427 - Spruce Door = spruce_door' - - '428 - Birch Door = birch_door' - - '429 - Jungle Door = jungle_door' - - '430 - Acacia Door = acacia_door' - - '431 - Dark Oak Door = dark_oak_door' - - '2256 - 13 Disc = record_13' - - '2257 - Cat Disc = record_cat' - - '2258 - Blocks Disc = record_blocks' - - '2259 - Chirp Disc = record_chirp' - - '2260 - Far Disc = record_far' - - '2261 - Mall Disc = record_mall' - - '2262 - Mellohi Disc = record_mellohi' - - '2263 - Stal Disc = record_stal' - - '2264 - Strad Disc = record_strad' - - '2265 - Ward Disc = record_ward' - - '2266 - 11 Disc = record_11' - - '2267 - Wait Disc = record_wait' -EntityList: - - '50 - Creeper = Creeper' - - '51 - Skeleton = Skeleton' - - '51:1 - WitherSkeleton = Skeleton' - - '52 - Spider = Spider' - - '53 - Giant = Giant' - - '54 - Zombie = Zombie' - - '54:1 - Zombie Villager = Zombie' - - '55 - Slime = Slime' - - '56 - Ghast = Ghast' - - '57 - Zombie Pigman = PigZombie' - - '58 - Enderman = Enderman' - - '59 - Cave Spider = CaveSpider' - - '60 - Silverfish = Silverfish' - - '61 - Blaze = Blaze' - - '62 - LavaSlime = LavaSlime' - - '63 - EnderDragon = EnderDragon' - - '64 - Wither = WitherBoss' - - '65 - Bat = Bat' - - '66 - Witch = Witch' - - '67 - Endermite = Endermite' - - '68 - Guardian = Guardian' - - '68:1 - Elder Guardian = Guardian' - - '90 - Pig = Pig' - - '91 - Sheep = Sheep' - - '92 - Cow = Cow' - - '93 - Chicken = Chicken' - - '94 - Squid = Squid' - - '95 - Wolf = Wolf' - - '96 - MushroomCow = MushroomCow' - - '97 - Snow Golem = SnowMan' - - '98 - Ocelot = Ozelot' - - '99 - Iron Golem = VillagerGolem' - - '100 - Horse = EntityHorse' - - '101 - Rabbit = Rabbit' - - '120 - Villager = Villager' -EnchantList: - - '0 - Protection = PROTECTION_ENVIRONMENTAL' - - '1 - Fire Protection = PROTECTION_FIRE' - - '2 - Feather Falling = PROTECTION_FALL' - - '3 - Blast Protection = PROTECTION_EXPLOSIONS' - - '4 - Projectile Protection = ROTECTION_PROJECTILE' - - '5 - Respiration = OXYGEN' - - '6 - Aqua Affinity = DIG_SPEED' - - '7 - Thorns = THORNS' - - '8 - Depth Strider = DEPTH_STRIDER' - - '16 - Sharpness = DAMAGE_ALL' - - '17 - Smite = DAMAGE_UNDEAD' - - '18 - Bane of Arthropods = DAMAGE_ARTHROPODS' - - '19 - Knockback = KNOCKBACK' - - '20 - Fire Aspect = FIRE_ASPECT' - - '21 - Looting = LOOT_BONUS_MOBS' - - '32 - Efficiency = DIG_SPEED' - - '33 - Silk Touch = SILK_TOUCH' - - '34 - Unbreaking = DURABILITY' - - '35 - Fortune = LOOT_BONUS_BLOCKS' - - '48 - Power = ARROW_DAMAGE' - - '49 - Punch = ARROW_KNOCKBACK' - - '50 - Flame = ARROW_FIRE' - - '51 - Infinity = ARROW_INFINITE' - - '61 - Luck of the Sea = LUCK' - - '62 - Lure = LURE' -ColorList: - - '0 - &fWhite = white' - - '1 - &6Orange = orange' - - '2 - &dMagenta = magenta' - - '3 - %9Light blue = lightBlue' - - '4 - &eYellow = yellow' - - '5 - &aLime = lime' - - '6 - &dPink = pink' - - '7 - &8Gray = gray' - - '8 - &7Light gray = silver' - - '9 - &3Cyan = cyan' - - '10 - &5Purple = purple' - - '11 - &1Blue = blue' - - '12 - &4Brown = brown' - - '13 - &2Green = green' - - '14 - &cRed = red' - - '15 - &0Black = black' \ No newline at end of file diff --git a/com/gamingmesh/jobs/Gui/.gitignore b/com/gamingmesh/jobs/Gui/.gitignore index 68eca3f2..7912feea 100644 --- a/com/gamingmesh/jobs/Gui/.gitignore +++ b/com/gamingmesh/jobs/Gui/.gitignore @@ -1,3 +1,4 @@ /Gui.class /GuiInfoList.class /GuiTools.class +/GuiManager.class diff --git a/com/gamingmesh/jobs/Gui/GuiTools.java b/com/gamingmesh/jobs/Gui/GuiManager.java similarity index 73% rename from com/gamingmesh/jobs/Gui/GuiTools.java rename to com/gamingmesh/jobs/Gui/GuiManager.java index 7d3e8156..34406beb 100644 --- a/com/gamingmesh/jobs/Gui/GuiTools.java +++ b/com/gamingmesh/jobs/Gui/GuiManager.java @@ -14,21 +14,17 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.commands.JobsCommands; -import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobInfo; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; -import com.gamingmesh.jobs.i18n.Language; -import com.gamingmesh.jobs.stuff.TranslateName; -public class GuiTools { +public class GuiManager { - public static HashMap GuiList = new HashMap(); + public HashMap GuiList = new HashMap(); - public static void CloseInventories() { + public void CloseInventories() { for (Entry one : GuiList.entrySet()) { Player player = Bukkit.getPlayer(one.getKey()); if (player != null) { @@ -37,18 +33,23 @@ public class GuiTools { } } - public static Inventory CreateJobsGUI(Player player) { + public Inventory CreateJobsGUI(Player player) { ArrayList JobsList = new ArrayList(); for (Job job : Jobs.getJobs()) { - if (ConfigManager.getJobsConfiguration().getHideJobsWithoutPermission()) - if (!JobsCommands.hasJobPermission(player, job)) + if (Jobs.getGCManager().getHideJobsWithoutPermission()) + if (!Jobs.getCommandManager().hasJobPermission(player, job)) continue; JobsList.add(job); } GuiInfoList guiInfo = new GuiInfoList(player.getName()); guiInfo.setJobList(JobsList); + + Inventory topinv = player.getOpenInventory().getTopInventory(); + if (topinv != null) + player.closeInventory(); + GuiList.put(player.getName(), guiInfo); int GuiSize = 9; @@ -72,7 +73,7 @@ public class GuiTools { List pJobs = JPlayer.getJobProgression(); - String title = Language.getMessage("command.info.gui.pickjob"); + String title = Jobs.getLanguage().getMessage("command.info.gui.pickjob"); if (title.length() > 32) title = title.substring(0, 30) + ".."; @@ -86,7 +87,7 @@ public class GuiTools { for (JobProgression onePJob : pJobs) { if (onePJob.getJob().getName().equalsIgnoreCase(job.getName())) - Lore.add(Language.getMessage("command.info.gui.working")); + Lore.add(Jobs.getLanguage().getMessage("command.info.gui.working")); } int maxlevel = 0; @@ -96,35 +97,36 @@ public class GuiTools { maxlevel = job.getMaxLevel(); if (maxlevel > 0) - Lore.add(Language.getMessage("command.info.gui.max") + maxlevel); + Lore.add(Jobs.getLanguage().getMessage("command.info.gui.max") + maxlevel); - if (ConfigManager.getJobsConfiguration().ShowTotalWorkers) - Lore.add(Language.getMessage("command.browse.output.totalWorkers").replace("[amount]", String.valueOf(job.getTotalPlayers()))); + if (Jobs.getGCManager().ShowTotalWorkers) + Lore.add(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers())); - if (ConfigManager.getJobsConfiguration().useDynamicPayment && ConfigManager.getJobsConfiguration().ShowPenaltyBonus) + if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) if (job.getBonus() < 0) - Lore.add(Language.getMessage("command.browse.output.penalty").replace("[amount]", String.valueOf((int) (job.getBonus() * 100) / 100.0 * -1))); + Lore.add(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) / 100.0 * -1)); else - Lore.add(Language.getMessage("command.browse.output.bonus").replace("[amount]", String.valueOf((int) (job.getBonus() * 100) / 100.0))); + Lore.add(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100) / 100.0)); Lore.addAll(Arrays.asList(job.getDescription().split("/n"))); if (job.getMaxSlots() != null) - Lore.add(Language.getMessage("command.info.gui.leftSlots") + ((job.getMaxSlots() - Jobs.getUsedSlots(job)) > 0 ? (job.getMaxSlots() - Jobs.getUsedSlots( - job)) : 0)); + Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftSlots") + ((job.getMaxSlots() - Jobs.getUsedSlots(job)) > 0 ? (job.getMaxSlots() - Jobs + .getUsedSlots( + job)) : 0)); - Lore.add(Language.getMessage("command.info.gui.actions")); + Lore.add(Jobs.getLanguage().getMessage("command.info.gui.actions")); for (ActionType actionType : ActionType.values()) { List info = job.getJobInfo(actionType); if (info != null && !info.isEmpty()) { - Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Language.getMessage("command.info.output." + actionType.getName().toLowerCase() + Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"))); } } Lore.add(""); - Lore.add(Language.getMessage("command.info.gui.leftClick")); - Lore.add(Language.getMessage("command.info.gui.rightClick")); + Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftClick")); + Lore.add(Jobs.getLanguage().getMessage("command.info.gui.rightClick")); ItemStack GuiItem = job.getGuiItem(); @@ -138,7 +140,7 @@ public class GuiTools { return GuiInv; } - public static Inventory CreateJobsSubGUI(Player player, Job job) { + public Inventory CreateJobsSubGUI(Player player, Job job) { Inventory tempInv = Bukkit.createInventory(null, 54, ""); @@ -166,11 +168,11 @@ public class GuiTools { continue; ArrayList Lore = new ArrayList(); - Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Language.getMessage("command.info.output." + actionType.getName().toLowerCase() + Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"))); int y = 1; for (int z = 0; z < info.size(); z++) { - String itemName = TranslateName.Translate(info.get(z).getName(), info.get(z)); + String itemName = Jobs.getNameTranslatorManager().Translate(info.get(z).getName(), info.get(z)); double income = info.get(z).getIncome(level, numjobs); income = income + ((income * MoneyBoost) - income) + ((income * job.getMoneyBoost()) - income); @@ -198,7 +200,7 @@ public class GuiTools { GuiItem = job.getGuiItem(); Lore = new ArrayList(); - Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Language.getMessage("command.info.output." + actionType.getName().toLowerCase() + Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"))); i++; } @@ -246,7 +248,7 @@ public class GuiTools { // backButton = 53; // } - String title = Language.getMessage("command.info.gui.jobinfo").replace("[jobname]", job.getName()); + String title = Jobs.getLanguage().getMessage("command.info.gui.jobinfo", "[jobname]", job.getName()); if (title.length() > 32) title = title.substring(0, 30) + ".."; Inventory GuiInv = Bukkit.createInventory(null, GuiSize, title); @@ -258,7 +260,7 @@ public class GuiTools { ItemStack skull = new ItemStack(Material.JACK_O_LANTERN, 1, (byte) 0); ItemMeta skullMeta = skull.getItemMeta(); - skullMeta.setDisplayName(Language.getMessage("command.info.gui.back")); + skullMeta.setDisplayName(Jobs.getLanguage().getMessage("command.info.gui.back")); skull.setItemMeta(skullMeta); diff --git a/com/gamingmesh/jobs/HookEconomyTask.java b/com/gamingmesh/jobs/HookEconomyTask.java index 08ba82fd..273265b7 100644 --- a/com/gamingmesh/jobs/HookEconomyTask.java +++ b/com/gamingmesh/jobs/HookEconomyTask.java @@ -44,7 +44,7 @@ public class HookEconomyTask implements Runnable { Economy economy = provider.getProvider(); if (economy != null) { Jobs.setEconomy(plugin, new VaultEconomy(economy)); - String message = ChatColor.translateAlternateColorCodes('&', "&2[" + plugin.getDescription().getName() + "] Successfully linked with Vault."); + String message = ChatColor.translateAlternateColorCodes('&', "&e[" + plugin.getDescription().getName() + "] Successfully linked with Vault."); ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); console.sendMessage(message); return; @@ -58,7 +58,7 @@ public class HookEconomyTask implements Runnable { Bukkit.getServer().getLogger().severe("Vault is required by this plugin for economy support!"); Bukkit.getServer().getLogger().severe("Please install Vault first!"); Bukkit.getServer().getLogger().severe("You can find the latest version here:"); - Bukkit.getServer().getLogger().severe("http://dev.bukkit.org/server-mods/vault/"); + Bukkit.getServer().getLogger().severe("http://dev.bukkit.org/bukkit-plugins/vault/"); Bukkit.getServer().getLogger().severe("=============================================="); } diff --git a/com/gamingmesh/jobs/Jobs.java b/com/gamingmesh/jobs/Jobs.java index d48ad034..9a72b77e 100644 --- a/com/gamingmesh/jobs/Jobs.java +++ b/com/gamingmesh/jobs/Jobs.java @@ -20,28 +20,35 @@ package com.gamingmesh.jobs; import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.WeakHashMap; -import java.util.Map.Entry; import java.util.logging.Logger; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - +import com.gamingmesh.jobs.Gui.GuiManager; import com.gamingmesh.jobs.Signs.SignUtil; +import com.gamingmesh.jobs.commands.JobsCommands; +import com.gamingmesh.jobs.config.BossBarManager; import com.gamingmesh.jobs.config.ConfigManager; +import com.gamingmesh.jobs.config.ExploreManager; +import com.gamingmesh.jobs.config.GeneralConfigManager; +import com.gamingmesh.jobs.config.LanguageManager; +import com.gamingmesh.jobs.config.NameTranslatorManager; +import com.gamingmesh.jobs.config.RestrictedAreaManager; +import com.gamingmesh.jobs.config.RestrictedBlockManager; +import com.gamingmesh.jobs.config.ScboardManager; +import com.gamingmesh.jobs.config.ScheduleManager; +import com.gamingmesh.jobs.config.ShopManager; +import com.gamingmesh.jobs.config.TitleManager; import com.gamingmesh.jobs.container.ActionInfo; +import com.gamingmesh.jobs.container.BoostMultiplier; import com.gamingmesh.jobs.container.Job; -import com.gamingmesh.jobs.container.JobItems; +import com.gamingmesh.jobs.container.JobInfo; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.dao.JobsDAO; @@ -49,25 +56,38 @@ import com.gamingmesh.jobs.economy.BufferedEconomy; import com.gamingmesh.jobs.economy.Economy; import com.gamingmesh.jobs.economy.PaymentData; import com.gamingmesh.jobs.i18n.Language; +import com.gamingmesh.jobs.listeners.MythicMobsListener; import com.gamingmesh.jobs.stuff.ActionBar; -import com.gamingmesh.jobs.stuff.Debug; -import com.gamingmesh.jobs.stuff.Explore; import com.gamingmesh.jobs.stuff.JobsClassLoader; import com.gamingmesh.jobs.stuff.Loging; -import com.gamingmesh.jobs.stuff.Scboard; -import com.gamingmesh.jobs.stuff.ScheduleUtil; import com.gamingmesh.jobs.tasks.BufferedPaymentThread; import com.gamingmesh.jobs.tasks.DatabaseSaveThread; +import net.coreprotect.CoreProtectAPI; + public class Jobs { public static Jobs instance = new Jobs(); // public static JobsPlugin plugin = new JobsPlugin(); private static PlayerManager pManager = new PlayerManager(); - private static Language lManager = new Language(); - private static SignUtil signManager = new SignUtil(); - private static Scboard scboardManager = new Scboard(); - private static ScheduleUtil scheduleManager = new ScheduleUtil(); - private static Explore exploreManager = new Explore(); + private static JobsCommands cManager = null; + private static Language lManager = null; + private static LanguageManager lmManager = null; + private static SignUtil signManager = null; + private static ScboardManager scboardManager = null; + private static ScheduleManager scheduleManager = null; + private static NameTranslatorManager NameTranslatorManager = null; + private static GuiManager GUIManager = null; + private static ExploreManager exploreManager = null; + private static TitleManager titleManager = null; + private static RestrictedBlockManager RBManager = null; + private static RestrictedAreaManager RAManager = null; + private static BossBarManager BBManager; + private static ShopManager shopManager; + + private static MythicMobsListener MythicManager; + + private static ConfigManager configManager; + private static GeneralConfigManager GconfigManager; private static Logger pLogger; private static File dataFolder; @@ -77,6 +97,7 @@ public class Jobs { private static Job noneJob = null; private static WeakHashMap usedSlots = new WeakHashMap(); public static WeakHashMap actionbartoggle = new WeakHashMap(); + public static WeakHashMap BossBartoggle = new WeakHashMap(); // public static WeakHashMap GlobalBoost = new WeakHashMap(); private static BufferedEconomy economy; private static PermissionHandler permissionHandler; @@ -86,8 +107,68 @@ public class Jobs { public final static HashMap paymentLimit = new HashMap(); public final static HashMap ExpLimit = new HashMap(); + public final static HashMap PointLimit = new HashMap(); - private Jobs() { + private static NMS nms; + + private static ActionBar actionbar; + + private static CoreProtectAPI CPAPI = null; + + public static CoreProtectAPI getCoreProtectApi() { + return CPAPI; + } + + public static void setCoreProtectApi(CoreProtectAPI capi) { + CPAPI = capi; + } + + public static void setMythicManager(JobsPlugin plugin) { + MythicManager = new MythicMobsListener(plugin); + } + + public static MythicMobsListener getMythicManager() { + return MythicManager; + } + + public static void setShopManager(JobsPlugin plugin) { + shopManager = new ShopManager(plugin); + } + + public static ShopManager getShopManager() { + return shopManager; + } + + public static void setConfigManager(JobsPlugin plugin) { + configManager = new ConfigManager(plugin); + } + + public static ConfigManager getConfigManager() { + return configManager; + } + + public static void setGCManager(JobsPlugin plugin) { + GconfigManager = new GeneralConfigManager(plugin); + } + + public static GeneralConfigManager getGCManager() { + return GconfigManager; + } + + public static void setActionBar(ActionBar bar) { + actionbar = bar; + } + + public static ActionBar getActionBar() { + return actionbar; + } + + public static void setNms(NMS newNms) { + nms = newNms; + } + + public static NMS getNms() { + return nms; } /** @@ -98,36 +179,100 @@ public class Jobs { return pManager; } + public static void setRestrictedBlockManager(JobsPlugin plugin) { + RBManager = new RestrictedBlockManager(plugin); + } + + public static RestrictedBlockManager getRestrictedBlockManager() { + return RBManager; + } + + public static void setRestrictedAreaManager(JobsPlugin plugin) { + RAManager = new RestrictedAreaManager(plugin); + } + + public static RestrictedAreaManager getRestrictedAreaManager() { + return RAManager; + } + + public static void setTitleManager(JobsPlugin plugin) { + titleManager = new TitleManager(plugin); + } + + public static TitleManager gettitleManager() { + return titleManager; + } + + public static void setBBManager(JobsPlugin plugin) { + BBManager = new BossBarManager(plugin); + } + + public static BossBarManager getBBManager() { + return BBManager; + } + + public static WeakHashMap getActionbarToggleList() { + return actionbartoggle; + } + + public static WeakHashMap getBossBarToggleList() { + return BossBartoggle; + } + /** * Returns schedule manager * @return the schedule manager */ - public static ScheduleUtil getSchedule() { + public static ScheduleManager getScheduleManager() { return scheduleManager; } - public static void setSchedule(JobsPlugin plugin) { - scheduleManager = new ScheduleUtil(plugin); + public static void setScheduleManager(JobsPlugin plugin) { + scheduleManager = new ScheduleManager(plugin); } - public static Explore getExplore() { + public static NameTranslatorManager getNameTranslatorManager() { + return NameTranslatorManager; + } + + public static void setNameTranslatorManager(JobsPlugin plugin) { + NameTranslatorManager = new NameTranslatorManager(plugin); + } + + public static GuiManager getGUIManager() { + return GUIManager; + } + + public static void setGUIManager(JobsPlugin plugin) { + GUIManager = new GuiManager(); + } + + public static JobsCommands getCommandManager() { + return cManager; + } + + public static void setCommandManager(JobsPlugin plugin) { + cManager = new JobsCommands(plugin); + } + + public static ExploreManager getExplore() { return exploreManager; } public static void setExplore() { - exploreManager = new Explore(); + exploreManager = new ExploreManager(); } /** * Returns scoreboard manager * @return the scoreboard manager */ - public static Scboard getScboard() { + public static ScboardManager getScboard() { return scboardManager; } public static void setScboard(JobsPlugin plugin) { - scboardManager = new Scboard(plugin); + scboardManager = new ScboardManager(plugin); } /** @@ -154,6 +299,14 @@ public class Jobs { lManager = new Language(plugin); } + public static LanguageManager getLanguageManager() { + return lmManager; + } + + public static void setLanguageManager(JobsPlugin plugin) { + lmManager = new LanguageManager(plugin); + } + /** * Sets the plugin logger */ @@ -277,9 +430,9 @@ public class Jobs { dao.closeConnections(); } - ConfigManager.getJobsConfiguration().reload(); - Jobs.getLanguage().reload(ConfigManager.getJobsConfiguration().getLocale()); - ConfigManager.getJobConfig().reload(); + Jobs.getGCManager().reload(); + Jobs.getLanguage().reload(Jobs.getGCManager().getLocale()); + Jobs.getConfigManager().reload(); usedSlots.clear(); for (Job job : jobs) { usedSlots.put(job, getJobsDAO().getSlotsTaken(job)); @@ -288,16 +441,16 @@ public class Jobs { permissionHandler.registerPermissions(); // set the system to auto save - if (ConfigManager.getJobsConfiguration().getSavePeriod() > 0) { - saveTask = new DatabaseSaveThread(ConfigManager.getJobsConfiguration().getSavePeriod()); + if (Jobs.getGCManager().getSavePeriod() > 0) { + saveTask = new DatabaseSaveThread(Jobs.getGCManager().getSavePeriod()); saveTask.start(); } // schedule payouts to buffered payments - paymentThread = new BufferedPaymentThread(ConfigManager.getJobsConfiguration().getEconomyBatchDelay()); + paymentThread = new BufferedPaymentThread(Jobs.getGCManager().getEconomyBatchDelay()); paymentThread.start(); - ConfigManager.getJobsConfiguration().loadScheduler(); + Jobs.getJobsDAO().loadPlayerData(); } /** @@ -324,10 +477,10 @@ public class Jobs { if (dao != null) { dao.closeConnections(); } - if (ConfigManager.getJobsConfiguration().storageMethod.equals("mysql")) - ConfigManager.getJobsConfiguration().startSqlite(); + if (Jobs.getGCManager().storageMethod.equals("mysql")) + Jobs.getGCManager().startSqlite(); else - ConfigManager.getJobsConfiguration().startMysql(); + Jobs.getGCManager().startMysql(); pManager.reload(); } @@ -401,30 +554,33 @@ public class Jobs { if (player == null) return true; + if (amount == 0) + return true; + String playername = player.getName(); - if (!ConfigManager.getJobsConfiguration().EconomyLimitUse) + if (!Jobs.getGCManager().MoneyLimitUse) return true; if (!paymentLimit.containsKey(playername)) { - PaymentData data = new PaymentData(System.currentTimeMillis(), amount, 0.0, 0L, false); + PaymentData data = new PaymentData(System.currentTimeMillis(), amount, 0.0, 0.0, 0L, false); //data.AddNewAmount(amount); paymentLimit.put(playername, data); } else { PaymentData data = paymentLimit.get(playername); JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(player); - if (data.IsReachedMoneyLimit(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit, JPlayer.getMoneyLimit())) { + if (data.IsReachedMoneyLimit(Jobs.getGCManager().MoneyTimeLimit, JPlayer.getMoneyLimit())) { if (player.isOnline() && !data.Informed && !data.isReseted()) { - ((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedlimit")); - ((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedlimit2")); + ((Player) player).sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reachedlimit")); + ((Player) player).sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reachedlimit2")); data.Setinformed(); } - if (data.IsAnnounceTime(ConfigManager.getJobsConfiguration().EconomyLimitAnnouncmentDelay) && player.isOnline()) { - String message = Language.getMessage("command.limit.output.lefttime").replace("%hour%", String.valueOf(data.GetLeftHour(ConfigManager - .getJobsConfiguration().EconomyLimitTimeLimit))); - message = message.replace("%min%", String.valueOf(data.GetLeftMin(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit))); - message = message.replace("%sec%", String.valueOf(data.GetLeftsec(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit))); - ActionBar.send(((Player) player), ChatColor.RED + message); + if (data.IsAnnounceTime(Jobs.getGCManager().MoneyAnnouncmentDelay) && player.isOnline()) { + String message = Jobs.getLanguage().getMessage("command.limit.output.lefttime", "%hour%", data.GetLeftHour(Jobs + .getGCManager().MoneyTimeLimit)); + message = message.replace("%min%", String.valueOf(data.GetLeftMin(Jobs.getGCManager().MoneyTimeLimit))); + message = message.replace("%sec%", String.valueOf(data.GetLeftsec(Jobs.getGCManager().MoneyTimeLimit))); + Jobs.getActionBar().send(((Player) player), ChatColor.RED + message); } if (data.isReseted()) data.setReseted(false); @@ -442,28 +598,27 @@ public class Jobs { String playername = player.getName(); - if (!ConfigManager.getJobsConfiguration().EconomyExpLimitUse) + if (!Jobs.getGCManager().ExpLimitUse) return true; if (!ExpLimit.containsKey(playername)) { - PaymentData data = new PaymentData(System.currentTimeMillis(), 0.0, amount, 0L, false); + PaymentData data = new PaymentData(System.currentTimeMillis(), 0.0, 0.0, amount, 0L, false); //data.AddNewAmount(amount); ExpLimit.put(playername, data); } else { PaymentData data = ExpLimit.get(playername); JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(player); - if (data.IsReachedExpLimit(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit, JPlayer.getExpLimit())) { + if (data.IsReachedExpLimit(Jobs.getGCManager().ExpTimeLimit, JPlayer.getExpLimit())) { if (player.isOnline() && !data.Informed && !data.isReseted()) { - ((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedExplimit")); - ((Player) player).sendMessage(Language.getMessage("command.limit.output.reachedExplimit2")); + ((Player) player).sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reachedExplimit")); + ((Player) player).sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reachedExplimit2")); data.Setinformed(); } - if (data.IsAnnounceTime(ConfigManager.getJobsConfiguration().EconomyLimitAnnouncmentExpDelay) && player.isOnline()) { - String message = Language.getMessage("command.limit.output.lefttime").replace("%hour%", String.valueOf(data.GetLeftHour(ConfigManager - .getJobsConfiguration().EconomyExpTimeLimit))); - message = message.replace("%min%", String.valueOf(data.GetLeftMin(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit))); - message = message.replace("%sec%", String.valueOf(data.GetLeftsec(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit))); - ActionBar.send(((Player) player), ChatColor.RED + message); + if (data.IsAnnounceTime(Jobs.getGCManager().ExpAnnouncmentDelay) && player.isOnline()) { + String message = Jobs.getLanguage().getMessage("command.limit.output.lefttime", "%hour%", data.GetLeftHour(Jobs.getGCManager().ExpTimeLimit)); + message = message.replace("%min%", String.valueOf(data.GetLeftMin(Jobs.getGCManager().ExpTimeLimit))); + message = message.replace("%sec%", String.valueOf(data.GetLeftsec(Jobs.getGCManager().ExpTimeLimit))); + Jobs.getActionBar().send(((Player) player), ChatColor.RED + message); } if (data.isReseted()) data.setReseted(false); @@ -475,6 +630,47 @@ public class Jobs { return true; } + public static boolean isUnderPointLimit(final OfflinePlayer player, Double amount) { + if (player == null) + return false; + + if (amount == 0) + return true; + + String playername = player.getName(); + + if (!Jobs.getGCManager().PointLimitUse) + return true; + + if (!PointLimit.containsKey(playername)) { + PaymentData data = new PaymentData(System.currentTimeMillis(), 0.0, amount, 0.0, 0L, false); + //data.AddNewAmount(amount); + PointLimit.put(playername, data); + } else { + PaymentData data = PointLimit.get(playername); + JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(player); + if (data.IsReachedPointLimit(Jobs.getGCManager().PointTimeLimit, JPlayer.getPointLimit())) { + if (player.isOnline() && !data.Informed && !data.isReseted()) { + ((Player) player).sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reachedPointlimit")); + ((Player) player).sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reachedPointlimit2")); + data.Setinformed(); + } + if (data.IsAnnounceTime(Jobs.getGCManager().PointAnnouncmentDelay) && player.isOnline()) { + String message = Jobs.getLanguage().getMessage("command.limit.output.lefttime", "%hour%", data.GetLeftHour(Jobs.getGCManager().PointTimeLimit)); + message = message.replace("%min%", String.valueOf(data.GetLeftMin(Jobs.getGCManager().PointTimeLimit))); + message = message.replace("%sec%", String.valueOf(data.GetLeftsec(Jobs.getGCManager().PointTimeLimit))); + Jobs.getActionBar().send(((Player) player), ChatColor.RED + message); + } + if (data.isReseted()) + data.setReseted(false); + return false; + } else + data.AddPoints(amount); + PointLimit.put(playername, data); + } + return true; + } + /** * Performed an action * @@ -483,8 +679,7 @@ public class Jobs { * @param action - the action * @param multiplier - the payment/xp multiplier */ - @SuppressWarnings("deprecation") - public static void action(JobsPlayer jPlayer, ActionInfo info, double multiplier, ItemStack item, ItemStack[] armor) { + public static void action(JobsPlayer jPlayer, ActionInfo info, double multiplier) { if (jPlayer == null) return; @@ -498,22 +693,38 @@ public class Jobs { Player dude = Bukkit.getServer().getPlayer(jPlayer.getPlayerUUID()); if (jobNone != null) { - Double income = jobNone.getIncome(info, 1, numjobs); - if (income != null) { + JobInfo jobinfo = jobNone.getJobInfo(info, 1); - Double amount = income + ((income * multiplier) - income) + ((income * 1.0) - income) + ((income * Jobs.getNoneJob().getMoneyBoost()) - income); + if (jobinfo == null) + return; - if (ConfigManager.getJobsConfiguration().useDynamicPayment) { + Double income = jobinfo.getIncome(1, numjobs); + Double points = jobinfo.getPoints(1, numjobs); + + if (income != 0D || points != 0D) { + + Double amount = 0D; + if (income != 0D) + amount = income + ((income * multiplier) - income) + ((income * 1.0) - income) + ((income * Jobs.getNoneJob().getMoneyBoost()) - income); + + Double pointAmount = 0D; + if (points != 0D) + pointAmount = points + ((points * multiplier) - points) + ((points * 1.0) - points) + ((points * Jobs.getNoneJob().getPointBoost()) - points); + + if (Jobs.getGCManager().useDynamicPayment) { double moneyBonus = (income * (jobNone.getBonus() / 100)); amount += moneyBonus; + + double pointBonus = (points * (jobNone.getBonus() / 100)); + pointAmount += pointBonus; } if (!isUnderMoneyLimit(dude, amount)) return; - Jobs.getEconomy().pay(jPlayer, amount, 0.0); + Jobs.getEconomy().pay(jPlayer, amount, pointAmount, 0.0); - if (ConfigManager.getJobsConfiguration().LoggingUse) + if (Jobs.getGCManager().LoggingUse) Loging.recordToLog(jPlayer, info, amount, 0); } } @@ -522,171 +733,126 @@ public class Jobs { for (JobProgression prog : progression) { int level = prog.getLevel(); - Double income = prog.getJob().getIncome(info, level, numjobs); + JobInfo jobinfo = prog.getJob().getJobInfo(info, level); - if (income != null) { - Double exp = prog.getJob().getExperience(info, level, numjobs); + if (jobinfo == null) + continue; - if (ConfigManager.getJobsConfiguration().addXpPlayer()) { - Player player = Bukkit.getServer().getPlayer(jPlayer.getPlayerUUID()); - if (player != null) { - /* - * Minecraft experience is calculated in whole numbers only. - * Calculate the fraction of an experience point and perform a dice roll. - * That way jobs that give fractions of experience points will slowly give - * experience in the aggregate - */ - int expInt = exp.intValue(); - double remainder = exp.doubleValue() - expInt; - if (Math.abs(remainder) > Math.random()) { - if (exp.doubleValue() < 0) { - expInt--; - } else { - expInt++; - } + Double income = jobinfo.getIncome(level, numjobs); + Double points = jobinfo.getPoints(level, numjobs); + + if (income == 0D && points == 0D) + continue; + + Double exp = jobinfo.getExperience(level, numjobs); + + if (Jobs.getGCManager().addXpPlayer()) { + Player player = Bukkit.getServer().getPlayer(jPlayer.getPlayerUUID()); + if (player != null) { + /* + * Minecraft experience is calculated in whole numbers only. + * Calculate the fraction of an experience point and perform a dice roll. + * That way jobs that give fractions of experience points will slowly give + * experience in the aggregate + */ + int expInt = exp.intValue(); + double remainder = exp.doubleValue() - expInt; + if (Math.abs(remainder) > Math.random()) { + if (exp.doubleValue() < 0) { + expInt--; + } else { + expInt++; } - player.giveExp(expInt); } + player.giveExp(expInt); } + } - // Item boost check - Double itemMoneyBoost = 0.0; - Double itemExpBoost = 0.0; - if (item != null) { + BoostMultiplier FinalBoost = Jobs.getPlayerManager().getFinalBonus(Bukkit.getServer().getPlayer(jPlayer.getPlayerUUID()), prog.getJob()); - ItemMeta meta = item.getItemMeta(); - String name = null; - List lore = new ArrayList(); + if (multiplier != 0.0) + FinalBoost = new BoostMultiplier(FinalBoost.getMoney() + ((multiplier * 100) - 100), FinalBoost.getPoints() + ((multiplier * 100) - 100), FinalBoost + .getExp() + ((multiplier * 100) - 100)); - if (item.hasItemMeta()) { - if (meta.hasDisplayName()) - name = meta.getDisplayName(); - if (meta.hasLore()) - lore = meta.getLore(); - } + OfflinePlayer dude = jPlayer.getPlayer(); - Map enchants = item.getEnchantments(); + // Calculate income - main: for (JobItems oneItem : prog.getJob().getItems()) { - if (oneItem.getId() != item.getTypeId()) - continue; - - if (oneItem.getName() != null && name != null) - if (!org.bukkit.ChatColor.translateAlternateColorCodes('&', oneItem.getName()).equalsIgnoreCase(name)) - continue; - - for (String onelore : oneItem.getLore()) { - if (lore.size() == 0 || !lore.contains(onelore)) - continue main; - } - - for (Entry oneE : enchants.entrySet()) { - if (oneItem.getenchants().containsKey(oneE.getKey())) { - if (oneItem.getenchants().get(oneE.getKey()) < oneE.getValue()) { - continue main; - } - } else - continue main; - } - - itemMoneyBoost = ((income * oneItem.getMoneyBoost()) - income); - itemExpBoost = ((exp * oneItem.getExpBoost()) - exp); - - Debug.D("boost"); - - break; - } - - } - - // Armor boost check - Double armorMoneyBoost = 0.0; - Double armorExpBoost = 0.0; - if (armor != null) - for (ItemStack OneArmor : armor) { - if (OneArmor == null) - continue; - if (!OneArmor.hasItemMeta()) - continue; - ItemMeta meta = OneArmor.getItemMeta(); - if (!meta.hasDisplayName() || !meta.hasLore()) - continue; - for (JobItems oneItem : prog.getJob().getItems()) { - if (oneItem.getId() != OneArmor.getTypeId()) - continue; - if (!ChatColor.translateAlternateColorCodes('&', oneItem.getName()).equalsIgnoreCase(meta.getDisplayName())) - continue; - if (!oneItem.getLore().equals(meta.getLore())) - continue; - armorMoneyBoost += ((income * oneItem.getMoneyBoost()) - income); - armorExpBoost += ((exp * oneItem.getExpBoost()) - exp); - break; - - } - - } - - OfflinePlayer dude = jPlayer.getPlayer(); - - // Calculate income - - Double amount = income + ((income * multiplier) - income) + ((income * prog.getJob().getMoneyBoost()) - income) + ((income * prog.getMoneyBoost()) - - income) + itemMoneyBoost + armorMoneyBoost; - - if (ConfigManager.getJobsConfiguration().useDynamicPayment) { - double moneyBonus = (income * (prog.getJob().getBonus() / 100)); - amount += moneyBonus; - } - - if (ConfigManager.getJobsConfiguration().useMinimumOveralPayment && income > 0) { - double maxLimit = income * ConfigManager.getJobsConfiguration().MinimumOveralPaymentLimit; + Double amount = 0D; + if (income != 0D) { + amount = income + (income * FinalBoost.getMoney() / 100); + if (Jobs.getGCManager().useMinimumOveralPayment && income > 0) { + double maxLimit = income * Jobs.getGCManager().MinimumOveralPaymentLimit; if (amount < maxLimit) { amount = maxLimit; } } + } - // Calculate exp - double expAmount = exp + ((exp * multiplier) - exp) + ((exp * prog.getJob().getExpBoost()) - exp) + ((exp * prog.getExpBoost()) - exp) + itemExpBoost - + armorExpBoost; + // Calculate points - if (ConfigManager.getJobsConfiguration().useDynamicPayment) { - double expBonus = (exp * (prog.getJob().getBonus() / 100)); - expAmount += expBonus; - } - - if (ConfigManager.getJobsConfiguration().useMinimumOveralPayment && exp > 0) { - double maxLimit = exp * ConfigManager.getJobsConfiguration().MinimumOveralPaymentLimit; - if (exp < maxLimit) { - exp = maxLimit; + Double pointAmount = 0D; + if (points != 0D) { + pointAmount = points + (points * FinalBoost.getPoints() / 100); + if (Jobs.getGCManager().useMinimumOveralPoints && points > 0) { + double maxLimit = points * Jobs.getGCManager().MinimumOveralPaymentLimit; + if (pointAmount < maxLimit) { + pointAmount = maxLimit; } } - - if (!isUnderMoneyLimit(dude, amount)) { - amount = 0.0000000001; - if (ConfigManager.getJobsConfiguration().EconomyExpStop) - expAmount = 0.0; - } - - if (!isUnderExpLimit(dude, expAmount)) { - expAmount = 0.0; - if (ConfigManager.getJobsConfiguration().EconomyMoneyStop) - expAmount = 0.0000000001; - } - - if (amount == 0.0000000001 && expAmount == 0.0) - continue; - - Jobs.getEconomy().pay(jPlayer, amount, expAmount); - int oldLevel = prog.getLevel(); - - if (ConfigManager.getJobsConfiguration().LoggingUse) - Loging.recordToLog(jPlayer, info, amount, expAmount); - - if (prog.addExperience(expAmount)) - Jobs.getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel); } + + // Calculate exp + double expAmount = exp + (exp * FinalBoost.getExp() / 100); + + if (Jobs.getGCManager().useMinimumOveralPayment && exp > 0) { + double maxLimit = exp * Jobs.getGCManager().MinimumOveralPaymentLimit; + if (exp < maxLimit) { + exp = maxLimit; + } + } + + if (!isUnderMoneyLimit(dude, amount)) { + amount = 0D; + if (Jobs.getGCManager().MoneyStopExp) + expAmount = 0D; + if (Jobs.getGCManager().MoneyStopPoint) + pointAmount = 0D; + } + + if (!isUnderExpLimit(dude, expAmount)) { + expAmount = 0D; + if (Jobs.getGCManager().ExpStopMoney) + amount = 0D; + if (Jobs.getGCManager().ExpStopPoint) + pointAmount = 0D; + } + + if (!isUnderPointLimit(dude, pointAmount)) { + pointAmount = 0D; + if (Jobs.getGCManager().PointStopMoney) + amount = 0D; + if (Jobs.getGCManager().PointStopExp) + expAmount = 0D; + } + + if ((amount == 0D || pointAmount == 0D) && expAmount == 0D) + continue; + + if (Jobs.getGCManager().BossBarEnabled && Jobs.getGCManager().BossBarShowOnEachAction) + Jobs.getBBManager().ShowJobProgression(jPlayer, prog); + else if (Jobs.getGCManager().BossBarEnabled && !Jobs.getGCManager().BossBarShowOnEachAction) + jPlayer.getUpdateBossBarFor().add(prog.getJob().getName()); + + Jobs.getEconomy().pay(jPlayer, amount, pointAmount, expAmount); + int oldLevel = prog.getLevel(); + + if (Jobs.getGCManager().LoggingUse) + Loging.recordToLog(jPlayer, info, amount, expAmount); + + if (prog.addExperience(expAmount)) + Jobs.getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel); } } } - } diff --git a/com/gamingmesh/jobs/JobsPlugin.java b/com/gamingmesh/jobs/JobsPlugin.java index dffe66f1..d09ffbd5 100644 --- a/com/gamingmesh/jobs/JobsPlugin.java +++ b/com/gamingmesh/jobs/JobsPlugin.java @@ -21,38 +21,21 @@ package com.gamingmesh.jobs; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import net.coreprotect.CoreProtect; -import net.coreprotect.CoreProtectAPI; -import net.elseland.xikage.MythicMobs.MythicMobs; -import net.elseland.xikage.MythicMobs.API.MythicMobsAPI; - import org.bukkit.Bukkit; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.ChatColor; -import com.gamingmesh.jobs.Gui.GuiTools; -import com.gamingmesh.jobs.commands.JobsCommands; -import com.gamingmesh.jobs.config.ConfigManager; -import com.gamingmesh.jobs.config.JobConfig; -import com.gamingmesh.jobs.config.JobsConfiguration; import com.gamingmesh.jobs.listeners.JobsListener; import com.gamingmesh.jobs.listeners.JobsPaymentListener; import com.gamingmesh.jobs.listeners.McMMOlistener; import com.gamingmesh.jobs.listeners.MythicMobsListener; import com.gamingmesh.jobs.listeners.PistonProtectionListener; -import com.gamingmesh.jobs.stuff.OfflinePlayerList; +import com.gamingmesh.jobs.stuff.ActionBar; import com.gamingmesh.jobs.stuff.TabComplete; import com.gamingmesh.jobs.config.YmlMaker; public class JobsPlugin extends JavaPlugin { - public static CoreProtectAPI CPAPI; - public static MythicMobsAPI MMAPI; - public static boolean CPPresent = false; - private static NMS nms; - - public static NMS getNms() { - return nms; - } @Override public void onEnable() { @@ -65,7 +48,7 @@ public class JobsPlugin extends JavaPlugin { Class nmsClass; nmsClass = Class.forName("com.gamingmesh.jobs.nmsUtil." + version); if (NMS.class.isAssignableFrom(nmsClass)) { - nms = (NMS) nmsClass.getConstructor().newInstance(); + Jobs.setNms((NMS) nmsClass.getConstructor().newInstance()); } else { System.out.println("Something went wrong, please note down version and contact author v:" + version); this.setEnabled(false); @@ -94,7 +77,9 @@ public class JobsPlugin extends JavaPlugin { this.setEnabled(false); } - OfflinePlayerList.fillList(); + Jobs.setActionBar(new ActionBar()); + +// OfflinePlayerList.fillList(); YmlMaker jobConfig = new YmlMaker(this, "jobConfig.yml"); jobConfig.saveDefaultConfig(); @@ -103,23 +88,29 @@ public class JobsPlugin extends JavaPlugin { YmlMaker jobSchedule = new YmlMaker(this, "schedule.yml"); jobSchedule.saveDefaultConfig(); + + YmlMaker jobShopItems = new YmlMaker(this, "shopItems.yml"); + jobShopItems.saveDefaultConfig(); Jobs.setPermissionHandler(new PermissionHandler(this)); - Jobs.setSignUtil(this); Jobs.setScboard(this); - Jobs.setSchedule(this); Jobs.setLanguage(this); + Jobs.setGUIManager(this); Jobs.setExplore(); + Jobs.setBBManager(this); + Jobs.setPluginLogger(getLogger()); Jobs.setDataFolder(getDataFolder()); - ConfigManager.registerJobsConfiguration(new JobsConfiguration(this)); - ConfigManager.registerJobConfig(new JobConfig(this)); + Jobs.setGCManager(this); + Jobs.setConfigManager(this); - getCommand("jobs").setExecutor(new JobsCommands(this)); + Jobs.setCommandManager(this); + + getCommand("jobs").setExecutor(Jobs.getCommandManager()); this.getCommand("jobs").setTabCompleter(new TabComplete()); @@ -136,41 +127,41 @@ public class JobsPlugin extends JavaPlugin { if (McMMOlistener.CheckmcMMO()) getServer().getPluginManager().registerEvents(new McMMOlistener(this), this); - if (MythicMobsListener.Check() && ConfigManager.getJobsConfiguration().MythicMobsEnabled) + Jobs.setMythicManager(this); + if (Jobs.getMythicManager().Check() && Jobs.getGCManager().MythicMobsEnabled) { getServer().getPluginManager().registerEvents(new MythicMobsListener(this), this); + } - if (ConfigManager.getJobsConfiguration().useBlockProtection) + if (Jobs.getGCManager().useBlockProtection) getServer().getPluginManager().registerEvents(new PistonProtectionListener(this), this); // register economy Bukkit.getScheduler().runTask(this, new HookEconomyTask(this)); - if (getServer().getPluginManager().getPlugin("MythicMobs") != null) { - MMAPI = ((MythicMobs) getServer().getPluginManager().getPlugin("MythicMobs")).getAPI(); - } - if (getServer().getPluginManager().getPlugin("CoreProtect") != null) { - CPPresent = true; - CPAPI = ((CoreProtect) getServer().getPluginManager().getPlugin("CoreProtect")).getAPI(); + Jobs.setCoreProtectApi(((CoreProtect) getServer().getPluginManager().getPlugin("CoreProtect")).getAPI()); } // all loaded properly. - if (ConfigManager.getJobsConfiguration().useGlobalBoostScheduler) - Jobs.getSchedule().scheduler(); - Jobs.getSchedule().DateUpdater(); + if (Jobs.getGCManager().useGlobalBoostScheduler) + Jobs.getScheduleManager().scheduler(); + Jobs.getScheduleManager().DateUpdater(); - String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6Plugin has been enabled succesfully."); + String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Plugin has been enabled succesfully."); ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); console.sendMessage(message); - Jobs.getLanguage().reload(ConfigManager.getJobsConfiguration().getLocale()); - + Jobs.getLanguage().reload(Jobs.getGCManager().getLocale()); + Jobs.getJobsDAO().loadExplore(); + + Jobs.getCommandManager().fillCommands(); } @Override public void onDisable() { - GuiTools.CloseInventories(); + Jobs.getGUIManager().CloseInventories(); + Jobs.getShopManager().CloseInventories(); Jobs.getJobsDAO().saveExplore(); Jobs.shutdown(); String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &2Plugin has been disabled succesfully."); diff --git a/com/gamingmesh/jobs/NMS.java b/com/gamingmesh/jobs/NMS.java index 10e73cc0..8c14e73a 100644 --- a/com/gamingmesh/jobs/NMS.java +++ b/com/gamingmesh/jobs/NMS.java @@ -3,11 +3,15 @@ package com.gamingmesh.jobs; import java.util.List; import org.bukkit.block.Block; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.event.block.BlockPistonRetractEvent; +import org.bukkit.inventory.ItemStack; public interface NMS { public List getPistonRetractBlocks(BlockPistonRetractEvent event); public boolean isElderGuardian(Entity entity); + + public ItemStack getItemInMainHand(Player player); } diff --git a/com/gamingmesh/jobs/PlayerManager.java b/com/gamingmesh/jobs/PlayerManager.java index 18454073..0ca46523 100644 --- a/com/gamingmesh/jobs/PlayerManager.java +++ b/com/gamingmesh/jobs/PlayerManager.java @@ -19,49 +19,106 @@ package com.gamingmesh.jobs; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.Sound; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + import com.gamingmesh.jobs.api.JobsJoinEvent; import com.gamingmesh.jobs.api.JobsLeaveEvent; import com.gamingmesh.jobs.api.JobsLevelUpEvent; -import com.gamingmesh.jobs.config.ConfigManager; +import com.gamingmesh.jobs.container.BoostMultiplier; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobCommands; import com.gamingmesh.jobs.container.JobConditions; +import com.gamingmesh.jobs.container.JobItems; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.container.PlayerInfo; import com.gamingmesh.jobs.dao.JobsDAO; -import com.gamingmesh.jobs.i18n.Language; -import com.gamingmesh.jobs.stuff.ActionBar; +import com.gamingmesh.jobs.dao.JobsDAOData; +import com.gamingmesh.jobs.economy.PointsData; import com.gamingmesh.jobs.stuff.ChatColor; +import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.PerformCommands; public class PlayerManager { // private Map players = Collections.synchronizedMap(new HashMap()); private ConcurrentHashMap players = new ConcurrentHashMap(); + private PointsData PointsDatabase = new PointsData(); + + private HashMap PlayerMap = new HashMap(); + + public PointsData getPointsData() { + return PointsDatabase; + } + + public HashMap getPlayerMap() { + return PlayerMap; + } + + public int getPlayerIdByName(String name) { + for (Entry one : PlayerMap.entrySet()) { + if (one.getValue().getName() == null) + continue; + if (one.getValue().getName().equalsIgnoreCase(name)) + return one.getValue().getID(); + } + return -1; + } + + public Entry getPlayerInfoByName(String name) { + for (Entry one : PlayerMap.entrySet()) { + if (one.getValue().getName() == null) + continue; + if (one.getValue().getName().equalsIgnoreCase(name)) + return one; + } + return null; + } + + public Entry getPlayerInfoById(int id) { + for (Entry one : PlayerMap.entrySet()) { + if (one.getValue().getName() == null) + continue; + if (one.getValue().getID() == id) + return one; + } + return null; + } /** * Handles join of new player * @param playername */ public void playerJoin(Player player) { -// synchronized (players) { + long time = System.nanoTime(); JobsPlayer jPlayer = players.get(player.getName().toLowerCase()); if (jPlayer == null) { jPlayer = JobsPlayer.loadFromDao(Jobs.getJobsDAO(), player); + Debug.D("1. " + (System.nanoTime() - time)); JobsPlayer.loadLogFromDao(jPlayer); + Debug.D("2. " + (System.nanoTime() - time)); players.put(player.getName().toLowerCase(), jPlayer); } jPlayer.onConnect(); + Debug.D("3. " + (System.nanoTime() - time)); jPlayer.reloadHonorific(); + Debug.D("4. " + (System.nanoTime() - time)); Jobs.getPermissionHandler().recalculatePermissions(jPlayer); + Debug.D("5. " + (System.nanoTime() - time)); return; -// } } /** @@ -69,20 +126,20 @@ public class PlayerManager { * @param playername */ public void playerQuit(Player player) { -// synchronized (players) { - if (ConfigManager.getJobsConfiguration().saveOnDisconnect()) { + if (Jobs.getGCManager().saveOnDisconnect()) { + Debug.D("save on disc"); JobsPlayer jPlayer = players.remove(player.getName().toLowerCase()); if (jPlayer != null) { jPlayer.save(Jobs.getJobsDAO()); jPlayer.onDisconnect(); } } else { + Debug.D("dont save"); JobsPlayer jPlayer = players.get(player.getName().toLowerCase()); if (jPlayer != null) { jPlayer.onDisconnect(); } } -// } } /** @@ -99,25 +156,19 @@ public class PlayerManager { * 3) Garbage collect the real list to remove any offline players with saved data */ ArrayList list = null; -// synchronized (players) { list = new ArrayList(players.values()); -// } for (JobsPlayer jPlayer : list) { jPlayer.save(dao); } -// synchronized (players) { Iterator iter = players.values().iterator(); while (iter.hasNext()) { JobsPlayer jPlayer = iter.next(); -// synchronized (jPlayer.saveLock) { if (!jPlayer.isOnline() && jPlayer.isSaved()) { iter.remove(); } -// } } -// } } /** @@ -126,9 +177,7 @@ public class PlayerManager { * @return the player job info of the player */ public JobsPlayer getJobsPlayer(Player player) { -// synchronized (players) { return players.get(player.getName().toLowerCase()); -// } } /** @@ -137,9 +186,11 @@ public class PlayerManager { * @return the player job info of the player */ public JobsPlayer getJobsPlayer(String playerName) { -// synchronized (players) { return players.get(playerName.toLowerCase()); -// } + } + + public JobsPlayer getJobsPlayerOffline(OfflinePlayer player) { + return getJobsPlayerOffline(player.getName()); } /** @@ -147,14 +198,43 @@ public class PlayerManager { * @param player - the player who's job you're getting * @return the player job info of the player */ - public JobsPlayer getJobsPlayerOffline(OfflinePlayer offlinePlayer) { - JobsPlayer jPlayer = players.get(offlinePlayer.getName().toLowerCase()); + public JobsPlayer getJobsPlayerOffline(String playerName) { + Debug.D("Getting offline player data"); + JobsPlayer jPlayer = players.get(playerName.toLowerCase()); if (jPlayer != null) return jPlayer; - JobsPlayer player = JobsPlayer.loadFromDao(Jobs.getJobsDAO(), offlinePlayer); - JobsPlayer.loadLogFromDao(player); - return player; + Entry info = getPlayerInfoByName(playerName); + + if (info == null) + return null; + + if (info.getValue().getName() == null) + return null; + + jPlayer = new JobsPlayer(info.getValue().getName(), null); + jPlayer.setPlayerUUID(UUID.fromString(info.getKey())); + jPlayer.setUserId(info.getValue().getID()); + + List list = Jobs.getJobsDAO().getAllJobs(info.getValue().getName(), UUID.fromString(info.getKey())); + for (JobsDAOData jobdata : list) { + if (Jobs.getJob(jobdata.getJobName()) == null) + continue; + Job job = Jobs.getJob(jobdata.getJobName()); + if (job == null) + continue; + JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience(), -1, -1, -1); + jPlayer.progression.add(jobProgression); + jPlayer.reloadMaxExperience(); + jPlayer.reloadLimits(); + } + + Debug.D("Offline player UID " + jPlayer.getUserId()); + + Jobs.getJobsDAO().loadPoints(jPlayer); + + JobsPlayer.loadLogFromDao(jPlayer); + return jPlayer; } /** @@ -350,17 +430,16 @@ public class PlayerManager { return; // LevelUp event - JobsLevelUpEvent levelUpEvent = new JobsLevelUpEvent(jPlayer, job.getName(), prog.getLevel(), ConfigManager.getJobsConfiguration().getTitleForLevel(oldLevel, job - .getName()), ConfigManager.getJobsConfiguration().getTitleForLevel(prog.getLevel(), job.getName()), ConfigManager.getJobsConfiguration().SoundLevelupSound - .toUpperCase(), ConfigManager.getJobsConfiguration().SoundLevelupVolume, ConfigManager.getJobsConfiguration().SoundLevelupPitch, ConfigManager - .getJobsConfiguration().SoundTitleChangeSound.toUpperCase(), ConfigManager.getJobsConfiguration().SoundTitleChangeVolume, ConfigManager - .getJobsConfiguration().SoundTitleChangePitch); + JobsLevelUpEvent levelUpEvent = new JobsLevelUpEvent(jPlayer, job.getName(), prog.getLevel(), Jobs.gettitleManager().getTitleForLevel(oldLevel, job + .getName()), Jobs.gettitleManager().getTitleForLevel(prog.getLevel(), job.getName()), Jobs.getGCManager().SoundLevelupSound + .toUpperCase(), Jobs.getGCManager().SoundLevelupVolume, Jobs.getGCManager().SoundLevelupPitch, Jobs.getGCManager().SoundTitleChangeSound.toUpperCase(), + Jobs.getGCManager().SoundTitleChangeVolume, Jobs.getGCManager().SoundTitleChangePitch); Bukkit.getServer().getPluginManager().callEvent(levelUpEvent); // If event is canceled, dont do anything if (levelUpEvent.isCancelled()) return; - if (ConfigManager.getJobsConfiguration().SoundLevelupUse) { + if (Jobs.getGCManager().SoundLevelupUse) { Sound sound = getSound(levelUpEvent.getSoundName()); if (sound != null) player.getWorld().playSound(player.getLocation(), sound, levelUpEvent.getSoundVolume(), levelUpEvent.getSoundPitch()); @@ -369,10 +448,10 @@ public class PlayerManager { } String message; - if (ConfigManager.getJobsConfiguration().isBroadcastingLevelups()) { - message = Language.getMessage("message.levelup.broadcast"); + if (Jobs.getGCManager().isBroadcastingLevelups()) { + message = Jobs.getLanguage().getMessage("message.levelup.broadcast"); } else { - message = Language.getMessage("message.levelup.nobroadcast"); + message = Jobs.getLanguage().getMessage("message.levelup.nobroadcast"); } message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); @@ -387,21 +466,20 @@ public class PlayerManager { } message = message.replace("%joblevel%", "" + prog.getLevel()); for (String line : message.split("\n")) { - if (ConfigManager.getJobsConfiguration().isBroadcastingLevelups()) { - if (ConfigManager.getJobsConfiguration().BroadcastingLevelUpLevels.contains(oldLevel + 1) || ConfigManager - .getJobsConfiguration().BroadcastingLevelUpLevels.contains(0)) + if (Jobs.getGCManager().isBroadcastingLevelups()) { + if (Jobs.getGCManager().BroadcastingLevelUpLevels.contains(oldLevel + 1) || Jobs.getGCManager().BroadcastingLevelUpLevels.contains(0)) Bukkit.getServer().broadcastMessage(line); } else if (player != null) { - if (ConfigManager.getJobsConfiguration().LevelChangeActionBar) - ActionBar.send(player, line); - if (ConfigManager.getJobsConfiguration().LevelChangeChat) + if (Jobs.getGCManager().LevelChangeActionBar) + Jobs.getActionBar().send(player, line); + if (Jobs.getGCManager().LevelChangeChat) player.sendMessage(line); } } if (levelUpEvent.getNewTitle() != null && !levelUpEvent.getNewTitle().equals(levelUpEvent.getOldTitle())) { - if (ConfigManager.getJobsConfiguration().SoundTitleChangeUse) { + if (Jobs.getGCManager().SoundTitleChangeUse) { Sound sound = getSound(levelUpEvent.getTitleChangeSoundName()); if (sound != null) player.getWorld().playSound(player.getLocation(), sound, levelUpEvent.getTitleChangeVolume(), @@ -410,10 +488,10 @@ public class PlayerManager { Bukkit.getConsoleSender().sendMessage("[Jobs] Cant find sound by name: " + levelUpEvent.getTitleChangeSoundName() + ". Please update it"); } // user would skill up - if (ConfigManager.getJobsConfiguration().isBroadcastingSkillups()) { - message = Language.getMessage("message.skillup.broadcast"); + if (Jobs.getGCManager().isBroadcastingSkillups()) { + message = Jobs.getLanguage().getMessage("message.skillup.broadcast"); } else { - message = Language.getMessage("message.skillup.nobroadcast"); + message = Jobs.getLanguage().getMessage("message.skillup.nobroadcast"); } if (player != null) { message = message.replace("%playername%", player.getDisplayName()); @@ -423,12 +501,12 @@ public class PlayerManager { message = message.replace("%titlename%", levelUpEvent.getNewTitleColor() + levelUpEvent.getNewTitleName() + ChatColor.WHITE); message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); for (String line : message.split("\n")) { - if (ConfigManager.getJobsConfiguration().isBroadcastingLevelups()) { + if (Jobs.getGCManager().isBroadcastingLevelups()) { Bukkit.getServer().broadcastMessage(line); } else if (player != null) { - if (ConfigManager.getJobsConfiguration().TitleChangeActionBar) - ActionBar.send(player, line); - if (ConfigManager.getJobsConfiguration().TitleChangeChat) + if (Jobs.getGCManager().TitleChangeActionBar) + Jobs.getActionBar().send(player, line); + if (Jobs.getGCManager().TitleChangeChat) player.sendMessage(line); } } @@ -514,24 +592,6 @@ public class PlayerManager { } } - /** - * Get job exp boost - * @param player - * @param job - * @return double of boost - */ - public Double GetExpBoost(Player dude, Job job) { - Double ExpBoost = 1.0; - if (dude == null || job.getName() == null) - return 1.0; - if (Perm(dude, "jobs.boost." + job.getName() + ".exp") || Perm(dude, "jobs.boost." + job.getName() + ".both") || Perm(dude, "jobs.boost.all.both") || Perm(dude, - "jobs.boost.all.exp")) { - ExpBoost = ConfigManager.getJobsConfiguration().BoostExp; - } - - return ExpBoost; - } - /** * Get max jobs * @param player @@ -544,7 +604,7 @@ public class PlayerManager { int totalJobs = Jobs.getJobs().size() + 5; - short count = (short) ConfigManager.getJobsConfiguration().getMaxJobs(); + short count = (short) Jobs.getGCManager().getMaxJobs(); for (short ctr = 0; ctr < totalJobs; ctr++) { if (Perm(player, "jobs.max." + ctr)) count = ctr; @@ -565,21 +625,70 @@ public class PlayerManager { * @return double of boost */ public Double GetMoneyBoost(Player dude, Job job) { - Double MoneyBoost = 1.0; + Double Boost = 1.0; if (dude != null && job.getName() != null) { - if (Perm(dude, "jobs.boost." + job.getName() + ".money") || Perm(dude, "jobs.boost." + job.getName() + ".both") || Perm(dude, "jobs.boost.all.both") || Perm( + if (Perm(dude, "jobs.boost." + job.getName() + ".money") || Perm(dude, "jobs.boost." + job.getName() + ".all") || Perm(dude, "jobs.boost.all.all") || Perm( dude, "jobs.boost.all.money")) { - MoneyBoost = ConfigManager.getJobsConfiguration().BoostMoney; + Boost = Jobs.getGCManager().BoostMoney; } } - return MoneyBoost; + return Boost; + } + + public double GetMoneyBoostInPerc(Player dude, Job job) { + double Boost = GetMoneyBoost(dude, job) * 100.0 - 100.0; + return Boost; + } + + /** + * Get job point boost + * @param player + * @param job + * @return double of boost + */ + public Double GetPointBoost(Player dude, Job job) { + Double Boost = 1.0; + if (dude != null && job.getName() != null) { + if (Perm(dude, "jobs.boost." + job.getName() + ".points") || Perm(dude, "jobs.boost." + job.getName() + ".all") || Perm(dude, "jobs.boost.all.all") || Perm( + dude, "jobs.boost.all.points")) { + Boost = Jobs.getGCManager().BoostPoints; + } + } + return Boost; + } + + public double GetPointBoostInPerc(Player dude, Job job) { + double Boost = GetPointBoost(dude, job) * 100.0 - 100.0; + return Boost; + } + + /** + * Get job exp boost + * @param player + * @param job + * @return double of boost + */ + public Double GetExpBoost(Player dude, Job job) { + Double Boost = 1.0; + if (dude == null || job.getName() == null) + return 1.0; + if (Perm(dude, "jobs.boost." + job.getName() + ".exp") || Perm(dude, "jobs.boost." + job.getName() + ".all") || Perm(dude, "jobs.boost.all.all") || Perm(dude, + "jobs.boost.all.exp")) { + Boost = Jobs.getGCManager().BoostExp; + } + + return Boost; + } + + public double GetExpBoostInPerc(Player dude, Job job) { + double Boost = GetExpBoost(dude, job) * 100.0 - 100.0; + return Boost; } /** * Perform reload */ public void reload() { -// synchronized (players) { for (JobsPlayer jPlayer : players.values()) { for (JobProgression progression : jPlayer.getJobProgression()) { String jobName = progression.getJob().getName(); @@ -590,11 +699,120 @@ public class PlayerManager { } if (jPlayer.isOnline()) { jPlayer.reloadHonorific(); - jPlayer.reloadMoneyLimit(); - jPlayer.reloadExpLimit(); + jPlayer.reloadLimits(); Jobs.getPermissionHandler().recalculatePermissions(jPlayer); } } -// } + } + + public BoostMultiplier getItemBoost(Player player, Job prog) { + BoostMultiplier data = new BoostMultiplier(1D, 1D, 1D); + if (player == null) + return data; + + ItemStack iih = Jobs.getNms().getItemInMainHand(player); + + BoostMultiplier itemboost = Jobs.getPlayerManager().getItemBoost(prog, iih); + + data = new BoostMultiplier(data.getMoney() + itemboost.getMoney(), + data.getPoints() + itemboost.getPoints(), + data.getExp() + itemboost.getExp()); + + for (ItemStack OneArmor : player.getInventory().getArmorContents()) { + BoostMultiplier armorboost = Jobs.getPlayerManager().getItemBoost(prog, OneArmor); + data = new BoostMultiplier(data.getMoney() + armorboost.getMoney(), + data.getPoints() + armorboost.getPoints(), + data.getExp() + armorboost.getExp()); + } + + return data; + } + + @SuppressWarnings("deprecation") + public BoostMultiplier getItemBoost(Job prog, ItemStack item) { + if (item == null) + return new BoostMultiplier(0D, 0D, 0D); + + ItemMeta meta = item.getItemMeta(); + String name = null; + List lore = new ArrayList(); + + if (item.hasItemMeta()) { + if (meta.hasDisplayName()) + name = meta.getDisplayName(); + if (meta.hasLore()) + lore = meta.getLore(); + } + + Map enchants = item.getEnchantments(); + + main: for (JobItems oneItem : prog.getItems()) { + if (oneItem.getId() != item.getTypeId()) + continue; + + if (oneItem.getName() != null && name != null) + if (!org.bukkit.ChatColor.translateAlternateColorCodes('&', oneItem.getName()).equalsIgnoreCase(name)) + continue; + + for (String onelore : oneItem.getLore()) { + if (lore.size() == 0 || !lore.contains(onelore)) + continue main; + } + + for (Entry oneE : enchants.entrySet()) { + if (oneItem.getenchants().containsKey(oneE.getKey())) { + if (oneItem.getenchants().get(oneE.getKey()) < oneE.getValue()) { + continue main; + } + } else + continue main; + } + + return new BoostMultiplier(oneItem.getMoneyBoost() - 1D, oneItem.getPointBoost() - 1D, oneItem.getExpBoost() - 1D); + } + + return new BoostMultiplier(0D, 0D, 0D); + } + + public BoostMultiplier getFinalBonus(Player player, Job prog) { + BoostMultiplier multiplier = new BoostMultiplier(0D, 0D, 0D); + if (player == null || prog == null) + return multiplier; + + double PMoneyBoost = Jobs.getPlayerManager().GetMoneyBoostInPerc(player, prog); + PMoneyBoost = (int) (PMoneyBoost * 100D) / 100D; + double PPointBoost = Jobs.getPlayerManager().GetPointBoostInPerc(player, prog); + PPointBoost = (int) (PPointBoost * 100D) / 100D; + double PExpBoost = Jobs.getPlayerManager().GetExpBoostInPerc(player, prog); + PExpBoost = (int) (PExpBoost * 100D) / 100D; + + double GMoneyBoost = prog.getMoneyBoost() * 100.0 - 100.0; + GMoneyBoost = (int) (GMoneyBoost * 100D) / 100D; + double GPointBoost = prog.getPointBoost() * 100.0 - 100.0; + GPointBoost = (int) (GPointBoost * 100D) / 100D; + double GExpBoost = prog.getExpBoost() * 100.0 - 100.0; + GExpBoost = (int) (GExpBoost * 100D) / 100D; + + double DBoost = (int) (prog.getBonus() * 100D) / 100D; + if (!Jobs.getGCManager().useDynamicPayment) + DBoost = 0.0; + + BoostMultiplier itemboost = Jobs.getPlayerManager().getItemBoost(player, prog); + + double IMoneyBoost = itemboost.getMoney() * 100.0 - 100.0; + IMoneyBoost = (int) (IMoneyBoost * 100D) / 100D; + double IPointBoost = itemboost.getPoints() * 100.0 - 100.0; + IPointBoost = (int) (IPointBoost * 100D) / 100D; + double IExpBoost = itemboost.getExp() * 100.0 - 100.0; + IExpBoost = (int) (IExpBoost * 100D) / 100D; + + double RBoost = Jobs.getRestrictedAreaManager().getRestrictedMultiplier(player) * 100.0 - 100.0; + RBoost = (int) (RBoost * 100D) / 100D; + + double Fmoney = (int) ((IMoneyBoost + DBoost + GMoneyBoost + PMoneyBoost + RBoost) * 100) / 100D; + double Fpoints = (int) ((IPointBoost + DBoost + GPointBoost + PPointBoost + RBoost) * 100) / 100D; + double Fexp = (int) ((IExpBoost + DBoost + GExpBoost + PExpBoost + RBoost) * 100) / 100D; + + return new BoostMultiplier(Fmoney, Fpoints, Fexp); } } diff --git a/com/gamingmesh/jobs/Signs/SignInfo.java b/com/gamingmesh/jobs/Signs/SignInfo.java index c52001c5..55afb299 100644 --- a/com/gamingmesh/jobs/Signs/SignInfo.java +++ b/com/gamingmesh/jobs/Signs/SignInfo.java @@ -1,28 +1,28 @@ -package com.gamingmesh.jobs.Signs; - -import java.util.ArrayList; -import java.util.List; - -public class SignInfo { - - List AllSigns = new ArrayList(); - - public SignInfo() { - } - - public void setAllSigns(List AllSigns) { - this.AllSigns = AllSigns; - } - - public List GetAllSigns() { - return this.AllSigns; - } - - public void removeSign(Sign sign) { - this.AllSigns.remove(sign); - } - - public void addSign(Sign sign) { - this.AllSigns.add(sign); - } -} +package com.gamingmesh.jobs.Signs; + +import java.util.ArrayList; +import java.util.List; + +public class SignInfo { + + List AllSigns = new ArrayList(); + + public SignInfo() { + } + + public void setAllSigns(List AllSigns) { + this.AllSigns = AllSigns; + } + + public List GetAllSigns() { + return this.AllSigns; + } + + public void removeSign(Sign sign) { + this.AllSigns.remove(sign); + } + + public void addSign(Sign sign) { + this.AllSigns.add(sign); + } +} diff --git a/com/gamingmesh/jobs/Signs/SignUtil.java b/com/gamingmesh/jobs/Signs/SignUtil.java index d99c2edb..a5119336 100644 --- a/com/gamingmesh/jobs/Signs/SignUtil.java +++ b/com/gamingmesh/jobs/Signs/SignUtil.java @@ -16,98 +16,81 @@ import org.bukkit.configuration.file.YamlConfiguration; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.config.CommentedYamlConfiguration; -import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.container.TopList; -import com.gamingmesh.jobs.i18n.Language; public class SignUtil { - - public SignUtil() { - } - + public SignInfo Signs = new SignInfo(); private JobsPlugin plugin; public SignUtil(JobsPlugin plugin) { this.plugin = plugin; } - - public SignInfo getSigns(){ + + public SignInfo getSigns() { return Signs; } // Sign file public void LoadSigns() { - Thread threadd = new Thread() { - public void run() { + Signs.GetAllSigns().clear(); + File file = new File(plugin.getDataFolder(), "Signs.yml"); + YamlConfiguration f = YamlConfiguration.loadConfiguration(file); - Signs.GetAllSigns().clear(); - File file = new File(plugin.getDataFolder(), "Signs.yml"); - YamlConfiguration f = YamlConfiguration.loadConfiguration(file); + if (!f.isConfigurationSection("Signs")) + return; - if (!f.isConfigurationSection("Signs")) - return; - - ConfigurationSection ConfCategory = f.getConfigurationSection("Signs"); - ArrayList categoriesList = new ArrayList(ConfCategory.getKeys(false)); - if (categoriesList.size() == 0) - return; - for (String category : categoriesList) { - ConfigurationSection NameSection = ConfCategory.getConfigurationSection(category); - com.gamingmesh.jobs.Signs.Sign newTemp = new com.gamingmesh.jobs.Signs.Sign(); - newTemp.setCategory(Integer.valueOf(category)); - newTemp.setWorld(NameSection.getString("World")); - newTemp.setX(NameSection.getDouble("X")); - newTemp.setY(NameSection.getDouble("Y")); - newTemp.setZ(NameSection.getDouble("Z")); - newTemp.setNumber(NameSection.getInt("Number")); - newTemp.setJobName(NameSection.getString("JobName")); - newTemp.setSpecial(NameSection.getBoolean("Special")); - Signs.addSign(newTemp); - } - return; - } - }; - threadd.start(); + ConfigurationSection ConfCategory = f.getConfigurationSection("Signs"); + ArrayList categoriesList = new ArrayList(ConfCategory.getKeys(false)); + if (categoriesList.size() == 0) + return; + for (String category : categoriesList) { + ConfigurationSection NameSection = ConfCategory.getConfigurationSection(category); + com.gamingmesh.jobs.Signs.Sign newTemp = new com.gamingmesh.jobs.Signs.Sign(); + newTemp.setCategory(Integer.valueOf(category)); + newTemp.setWorld(NameSection.getString("World")); + newTemp.setX(NameSection.getDouble("X")); + newTemp.setY(NameSection.getDouble("Y")); + newTemp.setZ(NameSection.getDouble("Z")); + newTemp.setNumber(NameSection.getInt("Number")); + newTemp.setJobName(NameSection.getString("JobName")); + newTemp.setSpecial(NameSection.getBoolean("Special")); + Signs.addSign(newTemp); + } + return; } // Signs save file public void saveSigns() { - - Thread threadd = new Thread() { - public void run() { - File f = new File(plugin.getDataFolder(), "Signs.yml"); - YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); + File f = new File(plugin.getDataFolder(), "Signs.yml"); + YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); - CommentedYamlConfiguration writer = new CommentedYamlConfiguration(); - conf.options().copyDefaults(true); + CommentedYamlConfiguration writer = new CommentedYamlConfiguration(); + conf.options().copyDefaults(true); - writer.addComment("Signs", "DO NOT EDIT THIS FILE BY HAND!"); + writer.addComment("Signs", "DO NOT EDIT THIS FILE BY HAND!"); - if (!conf.isConfigurationSection("Signs")) - conf.createSection("Signs"); + if (!conf.isConfigurationSection("Signs")) + conf.createSection("Signs"); - for (com.gamingmesh.jobs.Signs.Sign one : Signs.GetAllSigns()) { - String path = "Signs." + String.valueOf(one.GetCategory()); - writer.set(path + ".World", one.GetWorld()); - writer.set(path + ".X", one.GetX()); - writer.set(path + ".Y", one.GetY()); - writer.set(path + ".Z", one.GetZ()); - writer.set(path + ".Number", one.GetNumber()); - writer.set(path + ".JobName", one.GetJobName()); - writer.set(path + ".Special", one.isSpecial()); - } + for (com.gamingmesh.jobs.Signs.Sign one : Signs.GetAllSigns()) { + String path = "Signs." + String.valueOf(one.GetCategory()); + writer.set(path + ".World", one.GetWorld()); + writer.set(path + ".X", one.GetX()); + writer.set(path + ".Y", one.GetY()); + writer.set(path + ".Z", one.GetZ()); + writer.set(path + ".Number", one.GetNumber()); + writer.set(path + ".JobName", one.GetJobName()); + writer.set(path + ".Special", one.isSpecial()); + } - try { - writer.save(f); - } catch (IOException e) { - e.printStackTrace(); - ; - } - return; - } - }; - threadd.start(); + try { + writer.save(f); + } catch (IOException e) { + e.printStackTrace(); + ; + } + return; } public boolean SignUpdate(String JobName) { @@ -157,7 +140,7 @@ public class SignUtil { if (PlayerName == null) PlayerName = "Unknown"; - String line = Language.getMessage("signs.List"); + String line = Jobs.getLanguage().getMessage("signs.List"); line = line.replace("[number]", String.valueOf(i + number + 1)); line = line.replace("[player]", PlayerName); line = line.replace("[level]", String.valueOf(((TopList) PlayerList.get(i)).getLevel())); @@ -172,28 +155,28 @@ public class SignUtil { String PlayerNameStrip = PlayerName.split("(?<=\\G.{7})")[0]; PlayerName = PlayerNameStrip + "~"; } - String line1 = Language.getMessage("signs.SpecialList." + one.GetNumber() + ".1"); + String line1 = Jobs.getLanguage().getMessage("signs.SpecialList." + one.GetNumber() + ".1"); line1 = line1.replace("[number]", String.valueOf(one.GetNumber() + number + 1)); line1 = line1.replace("[player]", PlayerName); line1 = line1.replace("[level]", String.valueOf(((TopList) PlayerList.get(0)).getLevel())); sign.setLine(0, line1); - line1 = Language.getMessage("signs.SpecialList." + one.GetNumber() + ".2"); + line1 = Jobs.getLanguage().getMessage("signs.SpecialList." + one.GetNumber() + ".2"); line1 = line1.replace("[number]", String.valueOf(one.GetNumber() + number + 1)); line1 = line1.replace("[player]", PlayerName); line1 = line1.replace("[level]", String.valueOf(((TopList) PlayerList.get(0)).getLevel())); sign.setLine(1, line1); - line1 = Language.getMessage("signs.SpecialList." + one.GetNumber() + ".3"); + line1 = Jobs.getLanguage().getMessage("signs.SpecialList." + one.GetNumber() + ".3"); line1 = line1.replace("[number]", String.valueOf(one.GetNumber() + number + 1)); line1 = line1.replace("[player]", PlayerName); line1 = line1.replace("[level]", String.valueOf(((TopList) PlayerList.get(0)).getLevel())); sign.setLine(2, line1); - line1 = Language.getMessage("signs.SpecialList." + one.GetNumber() + ".4"); + line1 = Jobs.getLanguage().getMessage("signs.SpecialList." + one.GetNumber() + ".4"); line1 = line1.replace("[number]", String.valueOf(one.GetNumber() + number + 1)); line1 = line1.replace("[player]", PlayerName); line1 = line1.replace("[level]", String.valueOf(((TopList) PlayerList.get(0)).getLevel())); @@ -238,6 +221,6 @@ public class SignUtil { skull.update(); return; } - }, timelapse * ConfigManager.getJobsConfiguration().InfoUpdateInterval * 20L); + }, timelapse * Jobs.getGCManager().InfoUpdateInterval * 20L); } } diff --git a/com/gamingmesh/jobs/actions/EntityActionInfo.java b/com/gamingmesh/jobs/actions/EntityActionInfo.java index 0cda24d1..a49ed68b 100644 --- a/com/gamingmesh/jobs/actions/EntityActionInfo.java +++ b/com/gamingmesh/jobs/actions/EntityActionInfo.java @@ -23,7 +23,7 @@ import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.entity.Zombie; -import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.container.ActionInfo; import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.BaseActionInfo; @@ -50,7 +50,7 @@ public class EntityActionInfo extends BaseActionInfo implements ActionInfo { return "ZombieVillager"; } - if (JobsPlugin.getNms().isElderGuardian(this.entity)) + if (Jobs.getNms().isElderGuardian(this.entity)) return "ElderGuardian"; return entity.getType().toString(); diff --git a/com/gamingmesh/jobs/actions/MaterialActionInfo.java b/com/gamingmesh/jobs/actions/MaterialActionInfo.java index a688a206..f092f35e 100644 --- a/com/gamingmesh/jobs/actions/MaterialActionInfo.java +++ b/com/gamingmesh/jobs/actions/MaterialActionInfo.java @@ -40,7 +40,7 @@ public abstract class MaterialActionInfo extends BaseActionInfo implements Actio @Override public String getNameWithSub() { - return getName()+":"+data; + return getName() + ":" + data; } } diff --git a/com/gamingmesh/jobs/api/JobsPaymentEvent.java b/com/gamingmesh/jobs/api/JobsPaymentEvent.java index 7ea39503..a2d24db8 100644 --- a/com/gamingmesh/jobs/api/JobsPaymentEvent.java +++ b/com/gamingmesh/jobs/api/JobsPaymentEvent.java @@ -1,42 +1,48 @@ -package com.gamingmesh.jobs.api; - -import org.bukkit.OfflinePlayer; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -public final class JobsPaymentEvent extends Event implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private OfflinePlayer offlinePlayer; - private double money; - private boolean cancelled; - - public JobsPaymentEvent(OfflinePlayer offlinePlayer, double money) { - this.offlinePlayer = offlinePlayer; - this.money = money; - } - - public OfflinePlayer getPlayer() { - return this.offlinePlayer; - } - - public double getAmount() { - return this.money; - } - - public boolean isCancelled() { - return cancelled; - } - - public void setCancelled(boolean cancel) { - cancelled = cancel; - } - - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } +package com.gamingmesh.jobs.api; + +import org.bukkit.OfflinePlayer; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public final class JobsPaymentEvent extends Event implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private OfflinePlayer offlinePlayer; + private double money; + private double points; + private boolean cancelled; + + public JobsPaymentEvent(OfflinePlayer offlinePlayer, double money, double points) { + this.offlinePlayer = offlinePlayer; + this.money = money; + this.points = points; + } + + public OfflinePlayer getPlayer() { + return this.offlinePlayer; + } + + public double getAmount() { + return this.money; + } + + public double getPoints() { + return this.points; + } + + public boolean isCancelled() { + return cancelled; + } + + public void setCancelled(boolean cancel) { + cancelled = cancel; + } + + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } } \ No newline at end of file diff --git a/com/gamingmesh/jobs/commands/.gitignore b/com/gamingmesh/jobs/commands/.gitignore index 611c61f6..ede0ef99 100644 --- a/com/gamingmesh/jobs/commands/.gitignore +++ b/com/gamingmesh/jobs/commands/.gitignore @@ -1,3 +1,8 @@ /JobCommand.class /JobsCommands.class /JobsCommands$1.class +/Cmd.class +/CMICommands.class +/CMICommands$1.class +/oldcommands.class +/oldcommands$1.class diff --git a/com/gamingmesh/jobs/commands/Cmd.java b/com/gamingmesh/jobs/commands/Cmd.java new file mode 100644 index 00000000..07dbf1e4 --- /dev/null +++ b/com/gamingmesh/jobs/commands/Cmd.java @@ -0,0 +1,9 @@ +package com.gamingmesh.jobs.commands; + +import org.bukkit.command.CommandSender; + +import com.gamingmesh.jobs.JobsPlugin; + +public interface Cmd { + public boolean perform(JobsPlugin plugin, CommandSender sender, String[] args); +} diff --git a/com/gamingmesh/jobs/commands/JobCommand.java b/com/gamingmesh/jobs/commands/JobCommand.java index 700eba25..e1b9b0ec 100644 --- a/com/gamingmesh/jobs/commands/JobCommand.java +++ b/com/gamingmesh/jobs/commands/JobCommand.java @@ -26,5 +26,5 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD}) public @interface JobCommand { - + int value(); } diff --git a/com/gamingmesh/jobs/commands/JobsCommands.java b/com/gamingmesh/jobs/commands/JobsCommands.java index 321137e4..7f23a7fe 100644 --- a/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/com/gamingmesh/jobs/commands/JobsCommands.java @@ -1,113 +1,108 @@ -/** - * Jobs Plugin for Bukkit - * Copyright (C) 2011 Zak Ford - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - package com.gamingmesh.jobs.commands; -import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.sql.SQLException; +import java.net.URL; +import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.Enumeration; import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; - +import java.util.jar.JarEntry; +import java.util.jar.JarFile; import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; +import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Score; -import org.bukkit.scoreboard.Scoreboard; -import org.bukkit.scoreboard.ScoreboardManager; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.JobsPlugin; -import com.gamingmesh.jobs.Gui.GuiTools; -import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.container.ActionType; -import com.gamingmesh.jobs.container.Convert; +import com.gamingmesh.jobs.container.BoostMultiplier; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobInfo; -import com.gamingmesh.jobs.container.JobItems; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; -import com.gamingmesh.jobs.container.Log; -import com.gamingmesh.jobs.container.LogAmounts; -import com.gamingmesh.jobs.container.TopList; -import com.gamingmesh.jobs.economy.PaymentData; -import com.gamingmesh.jobs.i18n.Language; -import com.gamingmesh.jobs.stuff.ChatColor; -import com.gamingmesh.jobs.stuff.GiveItem; -import com.gamingmesh.jobs.stuff.OfflinePlayerList; -import com.gamingmesh.jobs.stuff.Perm; -import com.gamingmesh.jobs.stuff.Sorting; -import com.gamingmesh.jobs.stuff.TimeManage; -import com.gamingmesh.jobs.stuff.TranslateName; public class JobsCommands implements CommandExecutor { private static final String label = "jobs"; - private JobsPlugin plugin; + private static final String packagePath = "com.gamingmesh.jobs.commands.list"; + private static final List hidenCommands = Arrays.asList(); + Map CommandList = new HashMap(); + final String baseCmd = "jobs"; + + protected JobsPlugin plugin; public JobsCommands(JobsPlugin plugin) { this.plugin = plugin; } + public Map getCommands() { + return CommandList; + } + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (args.length == 0) - return help(sender); - String cmd = args[0].toLowerCase(); - try { - Method m = getClass().getMethod(cmd, CommandSender.class, String[].class); - if (m.isAnnotationPresent(JobCommand.class)) { - if (!hasCommandPermission(sender, cmd)) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.permission")); - return true; - } - String[] myArgs = reduceArgs(args); - if (myArgs.length > 0) { - if (myArgs[myArgs.length - 1].equals("?")) { - sendUsage(sender, cmd); - return true; - } - } - - return (Boolean) m.invoke(this, sender, myArgs); + if (sender instanceof Player) { + if (!Jobs.getGCManager().canPerformActionInWorld(((Player) sender).getWorld()) && !sender.hasPermission("jobs.disabledworld.commands")) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.worldisdisabled")); + return true; } - } catch (SecurityException e) { - e.printStackTrace(); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { } - return help(sender); + if (args.length == 0) + return help(sender, 1); + + if ((args.length == 1 || args.length == 2) && (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help"))) { + int page = 1; + if (args.length == 2) + try { + page = Integer.parseInt(args[1]); + } catch (NumberFormatException e) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.notNumber")); + return true; + } + if (page < 1) + page = 1; + return help(sender, page); + } + + String cmd = args[0].toLowerCase(); + + if (!hasCommandPermission(sender, cmd)) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.permission")); + return true; + } + String[] myArgs = reduceArgs(args); + if (myArgs.length > 0) { + if (myArgs[myArgs.length - 1].equals("?")) { + sendUsage(sender, cmd); + return true; + } + } + + Cmd cmdClass = getCmdClass(cmd); + if (cmdClass == null) { + return help(sender, 1); + } + boolean back = cmdClass.perform(plugin, sender, myArgs); + if (back) + return true; + + if (!(sender instanceof Player)) + return help(sender, 1); + + return help(sender, 1); } private static String[] reduceArgs(String[] args) { @@ -117,29 +112,229 @@ public class JobsCommands implements CommandExecutor { return Arrays.copyOfRange(args, 1, args.length); } - public static boolean hasCommandPermission(CommandSender sender, String cmd) { + private static boolean hasCommandPermission(CommandSender sender, String cmd) { return sender.hasPermission("jobs.command." + cmd); } - private String getUsage(String cmd) { + private static String getUsage(String cmd) { StringBuilder builder = new StringBuilder(); builder.append(ChatColor.GREEN.toString()); builder.append('/').append(label).append(' '); builder.append(cmd); builder.append(ChatColor.YELLOW); String key = "command." + cmd + ".help.args"; - if (Language.containsKey(key)) { + if (Jobs.getLanguage().containsKey(key)) { builder.append(' '); - builder.append(Language.getMessage(key)); + builder.append(Jobs.getLanguage().getMessage(key)); + } + return builder.toString(); + } + + public static String getUsageNoCmd(String cmd) { + StringBuilder builder = new StringBuilder(); + builder.append(ChatColor.GREEN.toString()); + builder.append('/').append(label).append(' '); + builder.append(ChatColor.YELLOW); + String key = "command." + cmd + ".help.args"; + if (Jobs.getLanguage().containsKey(key)) { + builder.append(' '); + builder.append(Jobs.getLanguage().getMessage(key)); } return builder.toString(); } public void sendUsage(CommandSender sender, String cmd) { - String message = ChatColor.YELLOW + Language.getMessage("command.help.output.usage"); + String message = ChatColor.YELLOW + Jobs.getLanguage().getMessage("command.help.output.usage"); message = message.replace("%usage%", getUsage(cmd)); sender.sendMessage(message); - sender.sendMessage(ChatColor.YELLOW + "* " + Language.getMessage("command." + cmd + ".help.info")); + sender.sendMessage(ChatColor.YELLOW + "* " + Jobs.getLanguage().getMessage("command." + cmd + ".help.info")); + } + + protected boolean help(CommandSender sender, int page) { + + Map commands = GetCommands(sender); + + if (commands.size() == 0) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.permission")); + return true; + } + commands = sort(commands); + int amountToShow = 7; + int start = page * amountToShow - amountToShow; + int end = page * amountToShow; + int TotalPages = (int) commands.size() / amountToShow; + if (((commands.size() * 1.0) / (amountToShow * 1.0)) - TotalPages > 0) + TotalPages++; + if (start >= commands.size()) { + page = TotalPages; + start = page * amountToShow; + end = start + amountToShow; + } + + sender.sendMessage(Jobs.getLanguage().getMessage("command.help.output.title")); + sender.sendMessage(Jobs.getLanguage().getMessage("command.help.output.page", "[1]", page, "[2]", TotalPages)); + + int i = -1; + for (Entry one : commands.entrySet()) { + i++; + if (i < start) + continue; + if (i >= end) + break; + sender.sendMessage(getUsage(one.getKey()) + " - " + Jobs.getLanguage().getMessage("command." + one.getKey() + ".help.info")); + } + + String prevCmd = "/" + baseCmd + " ? " + (page - 1); + String prev = "[\"\",{\"text\":\"" + Jobs.getLanguage().getMessage("command.help.output.prev") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"" + + prevCmd + + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + "<<<" + "\"}]}}}"; + String nextCmd = "/" + baseCmd + " ? " + (page + 1); + String next = " {\"text\":\"" + Jobs.getLanguage().getMessage("command.help.output.next") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"" + nextCmd + + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + ">>>" + "\"}]}}}]"; + + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName() + " " + prev + "," + next); + + return true; + } + + public static List getClassesFromPackage(String pckgname) throws ClassNotFoundException { + List result = new ArrayList(); + try { + for (URL jarURL : ((URLClassLoader) JobsPlugin.class.getClassLoader()).getURLs()) { + result.addAll(getClassesInSamePackageFromJar(pckgname, jarURL.getPath())); + } + } catch (NullPointerException x) { + throw new ClassNotFoundException(pckgname + " does not appear to be a valid package (Null pointer exception)"); + } + + return result; + } + + private static List getClassesInSamePackageFromJar(String packageName, String jarPath) { + JarFile jarFile = null; + List listOfCommands = new ArrayList(); + try { + jarFile = new JarFile(jarPath); + Enumeration en = jarFile.entries(); + while (en.hasMoreElements()) { + JarEntry entry = en.nextElement(); + String entryName = entry.getName(); + packageName = packageName.replace(".", "/"); + if (entryName != null && entryName.endsWith(".class") && entryName.startsWith(packageName)) { + String name = entryName.replace(packageName, "").replace(".class", "").replace("/", ""); + if (name.contains("$")) + name = name.split("\\$")[0]; + listOfCommands.add(name); + } + } + } catch (Exception e) { + } finally { + try { + if (jarFile != null) { + jarFile.close(); + } + } catch (Exception e) { + } + } + return listOfCommands; + } + + public Map GetCommands(CommandSender sender) { + Map temp = new HashMap(); + for (Entry cmd : CommandList.entrySet()) { + if (!hasCommandPermission(sender, cmd.getKey())) + continue; + temp.put(cmd.getKey(), cmd.getValue()); + } + return temp; + } + + public void fillCommands() { + List lm = new ArrayList(); + HashMap> classes = new HashMap>(); + try { + lm = getClassesFromPackage(packagePath); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + + for (String one : lm) { + Class newclass = getClass(one); + if (newclass != null) + classes.put(one, newclass); + } + + for (Entry> OneClass : classes.entrySet()) { + for (Method met : OneClass.getValue().getMethods()) { + if (!met.isAnnotationPresent(JobCommand.class)) + continue; + String cmd = OneClass.getKey(); + if (hidenCommands.contains(met.getName().toLowerCase())) + continue; + CommandList.put(cmd, met.getAnnotation(JobCommand.class).value()); + break; + } + } + } + + private Class getClass(String cmd) { + Class nmsClass = null; + try { + nmsClass = Class.forName(packagePath + "." + cmd.toLowerCase()); + } catch (ClassNotFoundException e) { + } catch (IllegalArgumentException e) { + } catch (SecurityException e) { + } + return nmsClass; + } + + private Cmd getCmdClass(String cmd) { + Cmd cmdClass = null; + try { + Class nmsClass; + nmsClass = Class.forName(packagePath + "." + cmd.toLowerCase()); + if (Cmd.class.isAssignableFrom(nmsClass)) { + cmdClass = (Cmd) nmsClass.getConstructor().newInstance(); + } + } catch (ClassNotFoundException e) { + } catch (InstantiationException e) { + } catch (IllegalAccessException e) { + } catch (IllegalArgumentException e) { + } catch (InvocationTargetException e) { + } catch (NoSuchMethodException e) { + } catch (SecurityException e) { + } + return cmdClass; + } + + private static Map sort(Map unsortMap) { + List> list = new LinkedList>(unsortMap.entrySet()); + Collections.sort(list, new Comparator>() { + public int compare(Map.Entry o1, Map.Entry o2) { + return (o1.getValue()).compareTo(o2.getValue()); + } + }); + Map sortedMap = new LinkedHashMap(); + for (Iterator> it = list.iterator(); it.hasNext();) { + Map.Entry entry = it.next(); + sortedMap.put(entry.getKey(), entry.getValue()); + } + return sortedMap; + } + + /** + * Check Job joining permission + */ + public boolean hasJobPermission(Player sender, Job job) { + return hasJobPermission((CommandSender) sender, job); + } + + public boolean hasJobPermission(CommandSender sender, Job job) { + if (!sender.hasPermission("jobs.use")) { + return false; + } else { + return sender.hasPermission("jobs.join." + job.getName().toLowerCase()); + } } public void sendValidActions(CommandSender sender) { @@ -152,1418 +347,7 @@ public class JobsCommands implements CommandExecutor { first = false; } - sender.sendMessage(Language.getMessage("command.info.help.actions").replace("%actions%", builder.toString())); - } - - protected boolean help(CommandSender sender) { - sender.sendMessage(Language.getMessage("command.info.help.title")); - for (Method m : getClass().getMethods()) { - if (m.isAnnotationPresent(JobCommand.class)) { - String cmd = m.getName(); - if (!hasCommandPermission(sender, cmd)) - continue; - sender.sendMessage(getUsage(cmd)); - } - } - sender.sendMessage(ChatColor.YELLOW + Language.getMessage("command.help.output.info")); - return true; - } - - @JobCommand - public boolean fixnames(CommandSender sender, String[] args) throws IOException { - - if (args.length > 0) { - sendUsage(sender, "fixnames"); - return true; - } - - sender.sendMessage(ChatColor.GOLD + "[Jobs] Starting name fix proccess, this can take up to minute depending on your data base size."); - Jobs.getJobsDAO().fixName(sender); - - return true; - } - -// @JobCommand -// public boolean fixuuid(CommandSender sender, String[] args) throws IOException { -// -// if (args.length > 0) { -// sendUsage(sender, "fixuuid"); -// return true; -// } -// -// sender.sendMessage(ChatColor.GOLD + "[Jobs] Starting uuid fix proccess, this can take up to minute depending on your data base size."); -// Jobs.getJobsDAO().fixUuid(sender); -// -// return true; -// } - - @JobCommand - public boolean convert(CommandSender sender, String[] args) throws IOException { - - if (!(sender instanceof Player)) - return false; - - if (args.length > 0) { - sendUsage(sender, "convert"); - return true; - } - - Player pSender = (Player) sender; - - List list = null; - List archivelist = null; - - try { - list = Jobs.getJobsDAO().convertDatabase(pSender, "jobs"); - archivelist = Jobs.getJobsDAO().convertDatabase(pSender, "archive"); - } catch (SQLException e) { - e.printStackTrace(); - sender.sendMessage(ChatColor.RED + "Can't read data from data base, please send error log to dev's."); - return false; - } - Jobs.ChangeDatabase(); - - if (list == null & archivelist == null) - return false; - try { - Jobs.getJobsDAO().continueConvertions(list, "jobs"); - Jobs.getJobsDAO().continueConvertions(archivelist, "archive"); - } catch (SQLException e) { - e.printStackTrace(); - sender.sendMessage(ChatColor.RED + "Can't write data to data base, please send error log to dev's."); - return false; - } - - Jobs.reload(); - - String from = "MysSQL"; - String to = "SqLite"; - - if (ConfigManager.getJobsConfiguration().storageMethod.equalsIgnoreCase("sqlite")) { - from = "SqLite"; - to = "MySQL"; - } - - sender.sendMessage(ChatColor.GOLD + "Data base was converted from " + ChatColor.GREEN + from + ChatColor.GOLD + " to " + ChatColor.GREEN + to + ChatColor.GOLD - + "! Now you can stop the server, change storage-method to " + ChatColor.GREEN + to + ChatColor.GOLD - + " in general config file and start server again on your new database system."); - - return true; - } - - @JobCommand - public boolean join(CommandSender sender, String[] args) { - if (!(sender instanceof Player)) - return false; - - if (args.length != 1 && args.length != 0) { - sendUsage(sender, "join"); - return true; - } - - if (args.length == 0) { - if (sender instanceof Player && ConfigManager.getJobsConfiguration().JobsGUIOpenOnJoin) - ((Player) sender).openInventory(GuiTools.CreateJobsGUI((Player) sender)); - else - return false; - return true; - } - - Player pSender = (Player) sender; - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); - - String jobName = args[0]; - Job job = Jobs.getJob(jobName); - if (job == null) { - // job does not exist - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job")); - return true; - } - - if (!hasJobPermission(pSender, job)) { - // you do not have permission to join the job - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.permission")); - return true; - } - - if (jPlayer.isInJob(job)) { - // already in job message - String message = ChatColor.RED + Language.getMessage("command.join.error.alreadyin"); - message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.RED); - sender.sendMessage(message); - return true; - } - - if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) { - String message = ChatColor.RED + Language.getMessage("command.join.error.fullslots"); - message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.RED); - sender.sendMessage(message); - return true; - } - - int confMaxJobs = ConfigManager.getJobsConfiguration().getMaxJobs(); - short PlayerMaxJobs = (short) jPlayer.getJobProgression().size(); - if (confMaxJobs > 0 && PlayerMaxJobs >= confMaxJobs && !Jobs.getPlayerManager().getJobsLimit(pSender, PlayerMaxJobs)) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.join.error.maxjobs")); - return true; - } - - Jobs.getPlayerManager().joinJob(jPlayer, job); - - String message = Language.getMessage("command.join.success"); - message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); - sender.sendMessage(message); - return true; - } - - @JobCommand - public boolean test(CommandSender sender, String[] args) { - if (!(sender instanceof Player)) - return false; - - Player pSender = (Player) sender; - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); - - Jobs.getJobsDAO().saveLog(jPlayer); - return true; - } - - @JobCommand - public boolean leave(CommandSender sender, String[] args) { - if (!(sender instanceof Player)) - return false; - - if (args.length < 1) { - sendUsage(sender, "leave"); - return true; - } - - Player pSender = (Player) sender; - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); - - String jobName = args[0]; - Job job = Jobs.getJob(jobName); - if (job == null) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job")); - return true; - } - - Jobs.getPlayerManager().leaveJob(jPlayer, job); - String message = Language.getMessage("command.leave.success"); - message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); - sender.sendMessage(message); - return true; - } - - @JobCommand - public boolean leaveall(CommandSender sender, String[] args) { - if (!(sender instanceof Player)) - return false; - - Player pSender = (Player) sender; - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); - - List jobs = jPlayer.getJobProgression(); - if (jobs.size() == 0) { - sender.sendMessage(Language.getMessage("command.leaveall.error.nojobs")); - return true; - } - - Jobs.getPlayerManager().leaveAllJobs(jPlayer); - sender.sendMessage(Language.getMessage("command.leaveall.success")); - return true; - } - - @JobCommand - public boolean info(CommandSender sender, String[] args) { - if (!(sender instanceof Player)) - return false; - - if (args.length < 1) { - sendUsage(sender, "info"); - sendValidActions(sender); - return true; - } - - Player pSender = (Player) sender; - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); - - String jobName = args[0]; - Job job = Jobs.getJob(jobName); - if (job == null) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job")); - return true; - } - - if (ConfigManager.getJobsConfiguration().hideJobsInfoWithoutPermission) - if (!hasJobPermission(pSender, job)) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.permission")); - return true; - } - - String type = ""; - if (args.length >= 2) { - type = args[1]; - } - sender.sendMessage(jobInfoMessage(jPlayer, job, type).split("\n")); - return true; - } - - @JobCommand - public boolean stats(CommandSender sender, String[] args) { - JobsPlayer jPlayer = null; - if (args.length >= 1) { - if (!sender.hasPermission("jobs.command.admin.stats")) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.permission")); - return true; - } -// @SuppressWarnings("deprecation") -// OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); - - OfflinePlayer offlinePlayer = OfflinePlayerList.getPlayer(args[0]); - if (offlinePlayer != null) - jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); - } else if (sender instanceof Player) { - jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); - } - - if (jPlayer == null) { - sendUsage(sender, "stats"); - return true; - } - - if (jPlayer.getJobProgression().size() == 0) { - sender.sendMessage(Language.getMessage("command.stats.error.nojob")); - return true; - } - - for (JobProgression jobProg : jPlayer.getJobProgression()) { - sender.sendMessage(jobStatsMessage(jobProg).split("\n")); - } - return true; - } - - @JobCommand - public boolean toggle(CommandSender sender, String[] args) { - - if (!ConfigManager.getJobsConfiguration().ToggleActionBar) { - sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.toggle.output.turnedoff")); - return true; - } - - if (!(sender instanceof Player)) - return false; - if (args.length > 0) { - sendUsage(sender, "toggle"); - return true; - } - - String PlayerName = sender.getName(); - - if (PlayerName == null) { - sendUsage(sender, "toggle"); - return true; - } - - if (Jobs.actionbartoggle.containsKey(PlayerName)) - if (Jobs.actionbartoggle.get(PlayerName)) { - Jobs.actionbartoggle.put(PlayerName, false); - sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.toggle.output.off")); - } else { - Jobs.actionbartoggle.put(PlayerName, true); - sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.toggle.output.on")); - } - else { - Jobs.actionbartoggle.put(PlayerName, true); - sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.toggle.output.on")); - } - - return true; - } - - @JobCommand - public boolean expboost(CommandSender sender, String[] args) { - //if (!(sender instanceof Player)) - // return false; - - if (args.length > 2 || args.length <= 1) { - sendUsage(sender, "expboost"); - return true; - } - - double rate = 1.0; - if (!args[1].equalsIgnoreCase("all") && !args[0].equalsIgnoreCase("reset")) - try { - rate = Double.parseDouble(args[1]); - } catch (NumberFormatException e) { - sendUsage(sender, "expboost"); - return true; - } - - String PlayerName = sender.getName(); - String jobName = args[0]; - Job job = Jobs.getJob(jobName); - - if (PlayerName == null) { - sendUsage(sender, "expboost"); - return true; - } - - if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) { - for (Job one : Jobs.getJobs()) { - one.setExpBoost(1.0); - } - sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.expboost.output.allreset")); - return true; - } else if (args[0].equalsIgnoreCase("reset")) { - boolean found = false; - for (Job one : Jobs.getJobs()) { - if (one.getName().equalsIgnoreCase(args[1])) { - one.setExpBoost(1.0); - found = true; - break; - } - } - - if (found) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.expboost.output.jobsboostreset").replace("%jobname%", job.getName())); - return true; - } - } - - if (args[0].equalsIgnoreCase("all")) { - - for (Job one : Jobs.getJobs()) { - one.setExpBoost(rate); - } - - sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.expboost.output.boostalladded").replace("%boost%", String.valueOf(rate))); - return true; - } else { - if (job == null) { - sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.error.job")); - return true; - } - job.setExpBoost(rate); - sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.expboost.output.boostadded").replace("%boost%", String.valueOf(rate)).replace("%jobname%", - job.getName())); - return true; - } - } - - @JobCommand - public boolean moneyboost(CommandSender sender, String[] args) { - //if (!(sender instanceof Player)) - // return false; - - if (args.length > 2 || args.length <= 1) { - sendUsage(sender, "moneyboost"); - return true; - } - - double rate = 1.0; - if (!args[1].equalsIgnoreCase("all") && !args[0].equalsIgnoreCase("reset")) - try { - rate = Double.parseDouble(args[1]); - } catch (NumberFormatException e) { - sendUsage(sender, "moneyboost"); - return true; - } - - String PlayerName = sender.getName(); - String jobName = args[0]; - Job job = Jobs.getJob(jobName); - - if (PlayerName == null) { - sendUsage(sender, "moneyboost"); - return true; - } - - if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) { - for (Job one : Jobs.getJobs()) { - one.setMoneyBoost(1.0); - } - sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.moneyboost.output.allreset")); - return true; - } else if (args[0].equalsIgnoreCase("reset")) { - boolean found = false; - for (Job one : Jobs.getJobs()) { - if (one.getName().equalsIgnoreCase(args[1])) { - one.setMoneyBoost(1.0); - found = true; - break; - } - } - - if (found) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.moneyboost.output.jobsboostreset").replace("%jobname%", job.getName())); - return true; - } - } - - if (args[0].equalsIgnoreCase("all")) { - - for (Job one : Jobs.getJobs()) { - one.setMoneyBoost(rate); - } - - sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.moneyboost.output.boostalladded").replace("%boost%", String.valueOf(rate))); - return true; - } else { - if (job == null) { - sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.error.job")); - return true; - } - job.setMoneyBoost(rate); - sender.sendMessage(ChatColor.GREEN + Language.getMessage("command.moneyboost.output.boostadded").replace("%boost%", String.valueOf(rate)).replace("%jobname%", - job.getName())); - return true; - } - } - - @SuppressWarnings("deprecation") - @JobCommand - public boolean archive(CommandSender sender, String[] args) { - JobsPlayer jPlayer = null; - if (args.length >= 1) { - if (!sender.hasPermission("jobs.command.admin.archive")) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.permission")); - return true; - } - OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); - jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); - - } else if (sender instanceof Player) { - jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); - } - - if (jPlayer == null) { - sendUsage(sender, "archive"); - return true; - } - - List AllJobs = Jobs.getJobsDAO().getJobsFromArchive(jPlayer); - - if (AllJobs.size() == 0) { - sender.sendMessage(Language.getMessage("command.archive.error.nojob")); - return true; - } - - for (String jobInfo : AllJobs) { - sender.sendMessage(jobStatsMessage(jobInfo)); - } - return true; - } - - @JobCommand - public boolean browse(CommandSender sender, String[] args) { - ArrayList lines = new ArrayList(); - for (Job job : Jobs.getJobs()) { - if (ConfigManager.getJobsConfiguration().getHideJobsWithoutPermission()) { - if (!hasJobPermission(sender, job)) - continue; - } - StringBuilder builder = new StringBuilder(); - builder.append(" "); - builder.append(job.getChatColor().toString()); - builder.append(job.getName()); - if (job.getMaxLevel() > 0) { - builder.append(ChatColor.WHITE.toString()); - builder.append(Language.getMessage("command.info.help.max")); - if (Perm.hasPermission(sender, "jobs." + job.getName() + ".vipmaxlevel") && job.getVipMaxLevel() != 0) - builder.append(job.getVipMaxLevel()); - else - builder.append(job.getMaxLevel()); - } - - if (ConfigManager.getJobsConfiguration().ShowTotalWorkers) - builder.append(Language.getMessage("command.browse.output.totalWorkers").replace("[amount]", String.valueOf(job.getTotalPlayers()))); - - if (ConfigManager.getJobsConfiguration().useDynamicPayment && ConfigManager.getJobsConfiguration().ShowPenaltyBonus) - if (job.getBonus() < 0) - builder.append(Language.getMessage("command.browse.output.penalty").replace("[amount]", String.valueOf((int) (job.getBonus() * 100) / 100.0 * -1))); - else - builder.append(Language.getMessage("command.browse.output.bonus").replace("[amount]", String.valueOf((int) (job.getBonus() * 100) / 100.0))); - - lines.add(builder.toString()); - if (!job.getDescription().isEmpty()) { - lines.add(" - " + job.getDescription().replace("/n", "")); - } - } - - if (lines.size() == 0) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.browse.error.nojobs")); - return true; - } - - if (sender instanceof Player && ConfigManager.getJobsConfiguration().JobsGUIOpenOnBrowse) { - ((Player) sender).openInventory(GuiTools.CreateJobsGUI((Player) sender)); - } - - if (ConfigManager.getJobsConfiguration().JobsGUIShowChatBrowse) { - sender.sendMessage(Language.getMessage("command.browse.output.header")); - for (String line : lines) { - sender.sendMessage(line); - } - sender.sendMessage(Language.getMessage("command.browse.output.footer")); - } - return true; - } - - @JobCommand - public boolean playerinfo(CommandSender sender, String[] args) { - if (args.length < 2) { - sendUsage(sender, "playerinfo"); - sendValidActions(sender); - return true; - } - - @SuppressWarnings("deprecation") - OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); - - String jobName = args[1]; - Job job = Jobs.getJob(jobName); - if (job == null) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job")); - return true; - } - String type = ""; - if (args.length >= 3) { - type = args[2]; - } - sender.sendMessage(jobInfoMessage(jPlayer, job, type).split("\n")); - return true; - } - - @JobCommand - public boolean reload(CommandSender sender, String[] args) { - try { - Jobs.reload(); - sender.sendMessage(Language.getMessage("command.admin.success")); - } catch (Exception e) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error")); - - String message = org.bukkit.ChatColor.translateAlternateColorCodes('&', "&4There was an error when performing a reload: "); - ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); - console.sendMessage(message); - - //Jobs.getPluginLogger().severe("There was an error when performing a reload: "); - e.printStackTrace(); - } - return true; - } - - @JobCommand - public boolean fire(CommandSender sender, String[] args) { - if (args.length < 2) { - sendUsage(sender, "fire"); - return true; - } - - @SuppressWarnings("deprecation") - OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); - - Job job = Jobs.getJob(args[1]); - if (job == null) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job")); - return true; - } - if (!jPlayer.isInJob(job)) { - String message = ChatColor.RED + Language.getMessage("command.fire.error.nojob"); - message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.RED); - sender.sendMessage(message); - return true; - } - try { - Jobs.getPlayerManager().leaveJob(jPlayer, job); - Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); - if (player != null) { - String message = Language.getMessage("command.fire.output.target"); - message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); - player.sendMessage(message); - } - - sender.sendMessage(Language.getMessage("command.admin.success")); - } catch (Exception e) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error")); - } - return true; - } - - @JobCommand - public boolean fireall(CommandSender sender, String[] args) { - if (args.length < 1) { - sendUsage(sender, "fireall"); - return true; - } - - @SuppressWarnings("deprecation") - OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); - - List jobs = jPlayer.getJobProgression(); - if (jobs.size() == 0) { - sender.sendMessage(Language.getMessage("command.fireall.error.nojobs")); - return true; - } - - try { - Jobs.getPlayerManager().leaveAllJobs(jPlayer); - Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); - if (player != null) { - player.sendMessage(Language.getMessage("command.fireall.output.target")); - } - - sender.sendMessage(Language.getMessage("command.admin.success")); - } catch (Exception e) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error")); - } - return true; - } - - @JobCommand - public boolean employ(CommandSender sender, String[] args) { - if (args.length < 2) { - sendUsage(sender, "employ"); - return true; - } - - @SuppressWarnings("deprecation") - OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); - - Job job = Jobs.getJob(args[1]); - if (job == null) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job")); - return true; - } - if (jPlayer.isInJob(job)) { - // already in job message - String message = ChatColor.RED + Language.getMessage("command.employ.error.alreadyin"); - message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.RED); - sender.sendMessage(message); - return true; - } - try { - // check if player already has the job - Jobs.getPlayerManager().joinJob(jPlayer, job); - Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); - if (player != null) { - String message = Language.getMessage("command.employ.output.target"); - message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); - player.sendMessage(message); - } - - sender.sendMessage(Language.getMessage("command.admin.success")); - } catch (Exception e) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error")); - } - return true; - } - - @JobCommand - public boolean promote(CommandSender sender, String[] args) { - if (args.length < 3) { - sendUsage(sender, "promote"); - return true; - } - - @SuppressWarnings("deprecation") - OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); - - Job job = Jobs.getJob(args[1]); - if (job == null) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job")); - return true; - } - try { - // check if player already has the job - if (jPlayer.isInJob(job)) { - Integer levelsGained = Integer.parseInt(args[2]); - Jobs.getPlayerManager().promoteJob(jPlayer, job, levelsGained); - - Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); - if (player != null) { - String message = Language.getMessage("command.promote.output.target"); - message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); - message = message.replace("%levelsgained%", Integer.valueOf(levelsGained).toString()); - player.sendMessage(message); - } - - sender.sendMessage(Language.getMessage("command.admin.success")); - } - } catch (Exception e) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error")); - } - return true; - } - - @JobCommand - public boolean demote(CommandSender sender, String[] args) { - if (args.length < 3) { - sendUsage(sender, "demote"); - return true; - } - - @SuppressWarnings("deprecation") - OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); - - Job job = Jobs.getJob(args[1]); - if (job == null) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job")); - return true; - } - try { - // check if player already has the job - if (jPlayer.isInJob(job)) { - Integer levelsLost = Integer.parseInt(args[2]); - Jobs.getPlayerManager().demoteJob(jPlayer, job, levelsLost); - - Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); - if (player != null) { - String message = Language.getMessage("command.demote.output.target"); - message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); - message = message.replace("%levelslost%", Integer.valueOf(levelsLost).toString()); - player.sendMessage(message); - } - - sender.sendMessage(Language.getMessage("command.admin.success")); - } - } catch (Exception e) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error")); - } - return true; - } - - @JobCommand - public boolean grantxp(CommandSender sender, String[] args) { - if (args.length < 3) { - sendUsage(sender, "grantxp"); - return true; - } - - @SuppressWarnings("deprecation") - OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); - - Job job = Jobs.getJob(args[1]); - if (job == null) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job")); - return true; - } - double xpGained; - try { - xpGained = Double.parseDouble(args[2]); - } catch (Exception e) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error")); - return true; - } - if (xpGained <= 0) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error")); - return true; - } - // check if player already has the job - if (jPlayer.isInJob(job)) { - Jobs.getPlayerManager().addExperience(jPlayer, job, xpGained); - - Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); - if (player != null) { - String message = Language.getMessage("command.grantxp.output.target"); - message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); - message = message.replace("%xpgained%", Double.valueOf(xpGained).toString()); - player.sendMessage(message); - } - - sender.sendMessage(Language.getMessage("command.admin.success")); - } - return true; - } - - @JobCommand - public boolean removexp(CommandSender sender, String[] args) { - if (args.length < 3) { - sendUsage(sender, "removexp"); - return true; - } - - @SuppressWarnings("deprecation") - OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); - - Job job = Jobs.getJob(args[1]); - if (job == null) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job")); - return true; - } - double xpLost; - try { - xpLost = Double.parseDouble(args[2]); - } catch (Exception e) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error")); - return true; - } - if (xpLost <= 0) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error")); - return true; - } - // check if player already has the job - if (jPlayer.isInJob(job)) { - Jobs.getPlayerManager().removeExperience(jPlayer, job, xpLost); - - Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); - if (player != null) { - String message = Language.getMessage("command.removexp.output.target"); - message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); - message = message.replace("%xplost%", Double.valueOf(xpLost).toString()); - player.sendMessage(message); - } - - sender.sendMessage(Language.getMessage("command.admin.success")); - } - return true; - } - - @JobCommand - public boolean transfer(CommandSender sender, String[] args) { - if (args.length < 3) { - sendUsage(sender, "transfer"); - return true; - } - - @SuppressWarnings("deprecation") - OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); - - Job oldjob = Jobs.getJob(args[1]); - Job newjob = Jobs.getJob(args[2]); - if (oldjob == null) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job")); - return true; - } - if (newjob == null) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job")); - return true; - } - try { - if (jPlayer.isInJob(oldjob) && !jPlayer.isInJob(newjob)) { - Jobs.getPlayerManager().transferJob(jPlayer, oldjob, newjob); - - Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); - if (player != null) { - String message = Language.getMessage("command.transfer.output.target"); - message = message.replace("%oldjobname%", oldjob.getChatColor() + oldjob.getName() + ChatColor.WHITE); - message = message.replace("%newjobname%", newjob.getChatColor() + newjob.getName() + ChatColor.WHITE); - player.sendMessage(message); - } - - sender.sendMessage(Language.getMessage("command.admin.success")); - } - } catch (Exception e) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error")); - } - return true; - } - - @JobCommand - public boolean signupdate(CommandSender sender, String[] args) { - if (args.length != 1) { - sendUsage(sender, "signupdate"); - return true; - } - - Job oldjob = Jobs.getJob(args[0]); - - if (oldjob == null && !args[0].equalsIgnoreCase("gtoplist")) { - sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job")); - return true; - } - if (!args[0].equalsIgnoreCase("gtoplist")) - Jobs.getSignUtil().SignUpdate(oldjob.getName()); - else - Jobs.getSignUtil().SignUpdate("gtoplist"); - - return true; - } - - @JobCommand - public boolean gtop(CommandSender sender, String[] args) { - - if (args.length != 1 && args.length != 0) { - sendUsage(sender, "gtop"); - return true; - } - - if (!(sender instanceof Player)) - return false; - Player player = (Player) sender; - - if (args.length > 0 && args[0].equalsIgnoreCase("clear")) { - player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); - return true; - } - - int start = 0; - if (args.length == 1) - try { - start = Integer.parseInt(args[0]); - } catch (NumberFormatException e) { - return true; - } - if (start < 0) - start = 0; - - List FullList = Jobs.getJobsDAO().getGlobalTopList(start); - if (FullList.size() <= 0) { - player.sendMessage(ChatColor.RED + Language.getMessage("command.gtop.error.nojob")); - return false; - } - - if (!ConfigManager.getJobsConfiguration().ShowToplistInScoreboard) { - player.sendMessage(Language.getMessage("command.gtop.output.topline")); - int i = start; - for (TopList One : FullList) { - i++; - String PlayerName = One.getPlayerName() != null ? One.getPlayerName() : "Unknown"; - player.sendMessage(Language.getMessage("command.gtop.output.list").replace("%number%", String.valueOf(i)).replace("%playername%", PlayerName).replace( - "%level%", String.valueOf(One.getLevel())).replace("%exp%", String.valueOf(One.getExp()))); - } - } else { - - player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); - - ScoreboardManager manager = Bukkit.getScoreboardManager(); - Scoreboard board = manager.getNewScoreboard(); - Objective objective = board.registerNewObjective("JobsTopPlayers", "dummy"); - objective.setDisplaySlot(DisplaySlot.SIDEBAR); - objective.setDisplayName(Language.getMessage("scoreboard.gtopline")); - int i = start; - for (TopList One : FullList) { - i++; - String playername = One.getPlayerName() != null ? One.getPlayerName() : "Unknown"; - - Score score = objective.getScore(Language.getMessage("scoreboard.lines").replace("%number%", String.valueOf(i)).replace("%playername%", playername)); - score.setScore(One.getLevel()); - - } - player.setScoreboard(board); - - Jobs.getScboard().addNew(player); - - //player.sendMessage(ChatColor.GOLD + Language.getMessage("scoreboard.clear")); - - int from = start; - if (start >= 15) - from = start - 15; - int until = start + 15; - - String prev = "[\"\",{\"text\":\"" + Language.getMessage("command.gtop.output.prev") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs gtop " - + from + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Language.getMessage("command.gtop.output.show") - .replace("[from]", String.valueOf(from)).replace("[until]", String.valueOf((from + 15))) + "\"}]}}}"; - String next = " {\"text\":\"" + Language.getMessage("command.gtop.output.next") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs gtop " - + until + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Language.getMessage( - "command.gtop.output.show").replace("[from]", String.valueOf(until + 1)).replace("[until]", String.valueOf((until + 15))) + "\"}]}}}]"; - - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + prev + "," + next); - } - return true; - } - - @JobCommand - public boolean top(CommandSender sender, String[] args) { - - if (args.length != 1 && args.length != 2) { - sendUsage(sender, "top"); - return true; - } - - if (!(sender instanceof Player)) - return false; - Player player = (Player) sender; - - if (args[0].equalsIgnoreCase("clear")) { - player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); - return true; - } - - int start = 0; - if (args.length == 2) - try { - start = Integer.parseInt(args[1]); - } catch (NumberFormatException e) { - return true; - } - if (start < 0) - start = 0; - - List FullList = Jobs.getJobsDAO().toplist(args[0], start); - if (FullList.size() <= 0) { - player.sendMessage(ChatColor.RED + Language.getMessage("command.top.error.nojob")); - return false; - } - - Job job = Jobs.getJob(args[0]); - String jobName = args[0]; - if (job != null) - jobName = job.getName(); - - if (!ConfigManager.getJobsConfiguration().ShowToplistInScoreboard) { - player.sendMessage(Language.getMessage("command.top.output.topline").replace("%jobname%", jobName)); - int i = start; - for (TopList One : FullList) { - i++; - String PlayerName = One.getPlayerName() != null ? One.getPlayerName() : "Unknown"; - player.sendMessage(Language.getMessage("command.top.output.list").replace("%number%", String.valueOf(i)).replace("%playername%", PlayerName).replace( - "%level%", String.valueOf(One.getLevel())).replace("%exp%", String.valueOf(One.getExp()))); - } - } else { - - player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); - - ScoreboardManager manager = Bukkit.getScoreboardManager(); - Scoreboard board = manager.getNewScoreboard(); - Objective objective = board.registerNewObjective("JobsTopPlayers", "dummy"); - objective.setDisplaySlot(DisplaySlot.SIDEBAR); - objective.setDisplayName(Language.getMessage("scoreboard.topline").replace("%jobname%", jobName)); - int i = start; - for (TopList One : FullList) { - i++; - String playername = One.getPlayerName() != null ? One.getPlayerName() : "Unknown"; - - Score score = objective.getScore(Language.getMessage("scoreboard.lines").replace("%number%", String.valueOf(i)).replace("%playername%", playername)); - score.setScore(One.getLevel()); - - } - player.setScoreboard(board); - //player.sendMessage(ChatColor.GOLD + Language.getMessage("scoreboard.clear")); - - Jobs.getScboard().addNew(player); - - int from = start; - if (start >= 15) - from = start - 15; - int until = start + 15; - - String prev = "[\"\",{\"text\":\"" + Language.getMessage("command.top.output.prev") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs top " - + jobName + " " + from + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Language.getMessage( - "command.top.output.show").replace("[from]", String.valueOf(from)).replace("[until]", String.valueOf((from + 15))) + "\"}]}}}"; - String next = " {\"text\":\"" + Language.getMessage("command.top.output.next") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs top " - + jobName + " " + until + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Language.getMessage( - "command.top.output.show").replace("[from]", String.valueOf(until + 1)).replace("[until]", String.valueOf((until + 15))) + "\"}]}}}]"; - - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + prev + "," + next); - } - return true; - } - - @JobCommand - public boolean give(CommandSender sender, String[] args) { - - if (args.length < 1 || Jobs.getJob(args[0]) == null && Jobs.getJob(args[1]) == null) { - sendUsage(sender, "give"); - return true; - } - - if (args.length == 2 && sender instanceof Player) { - Job job = Jobs.getJob(args[0]); - for (JobItems item : job.getItems()) { - if (item.getNode().equalsIgnoreCase(args[1])) { - GiveItem.GiveItemForPlayer((Player) sender, item.getId(), 0, 1, item.getName(), item.getLore(), item.getenchants()); - return true; - } - } - sender.sendMessage(Language.getMessage("command.give.output.noitem")); - return true; - } else if (args.length == 3) { - Job job = Jobs.getJob(args[1]); - Player player = Bukkit.getPlayer(args[0]); - if (player == null) { - sender.sendMessage(Language.getMessage("command.give.output.notonline").replace("%playername%", args[0])); - return true; - } - for (JobItems item : job.getItems()) { - if (item.getNode().equalsIgnoreCase(args[2])) { - GiveItem.GiveItemForPlayer(player, item.getId(), 0, 1, item.getName(), item.getLore(), item.getenchants()); - return true; - } - } - sender.sendMessage(Language.getMessage("command.give.output.noitem")); - return true; - } else { - sendUsage(sender, "give"); - return true; - } - } - - @JobCommand - public boolean limit(CommandSender sender, String[] args) { - if (args.length > 0) { - sendUsage(sender, "limit"); - return true; - } - - if (!(sender instanceof Player)) - return false; - - Player player = (Player) sender; - - if (!ConfigManager.getJobsConfiguration().EconomyLimitUse && !ConfigManager.getJobsConfiguration().EconomyExpLimitUse) { - player.sendMessage(Language.getMessage("command.limit.output.notenabled")); - return true; - } - JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player); - - String playername = player.getName(); - - if (ConfigManager.getJobsConfiguration().EconomyLimitUse) - if (Jobs.paymentLimit.containsKey(playername) && Jobs.paymentLimit.get(playername).GetLeftTime(ConfigManager - .getJobsConfiguration().EconomyLimitTimeLimit) > 0) { - PaymentData data = Jobs.paymentLimit.get(playername); - - String lefttimemessage = Language.getMessage("command.limit.output.lefttime").replace("%hour%", String.valueOf(data.GetLeftHour(ConfigManager - .getJobsConfiguration().EconomyLimitTimeLimit))); - lefttimemessage = lefttimemessage.replace("%min%", String.valueOf(data.GetLeftMin(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit))); - lefttimemessage = lefttimemessage.replace("%sec%", String.valueOf(data.GetLeftsec(ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit))); - player.sendMessage(lefttimemessage); - - String message = Language.getMessage("command.limit.output.moneylimit"); - message = message.replace("%money%", String.valueOf(data.GetAmountBylimit(JPlayer.getMoneyLimit()))); - message = message.replace("%totalmoney%", String.valueOf(JPlayer.getMoneyLimit())); - player.sendMessage(message); - - } else { - - int lefttime1 = ConfigManager.getJobsConfiguration().EconomyLimitTimeLimit; - - int hour = 0; - int min = 0; - int sec = 0; - - if (lefttime1 >= 3600) { - hour = lefttime1 / 3600; - lefttime1 = lefttime1 - (hour * 3600); - if (lefttime1 > 60 && lefttime1 < 3600) { - min = lefttime1 / 60; - sec = lefttime1 - (min * 60); - } else if (lefttime1 < 60) - sec = lefttime1; - } else if (lefttime1 > 60 && lefttime1 < 3600) { - min = lefttime1 / 60; - lefttime1 = lefttime1 - (min * 60); - } else - sec = lefttime1; - - String message = Language.getMessage("command.limit.output.lefttime").replace("%hour%", String.valueOf(hour)); - message = message.replace("%min%", String.valueOf(min)); - message = message.replace("%sec%", String.valueOf(sec)); - player.sendMessage(message); - - message = Language.getMessage("command.limit.output.moneylimit").replace("%money%", "0.0"); - message = message.replace("%totalmoney%", String.valueOf(JPlayer.getMoneyLimit())); - player.sendMessage(message); - } - - if (ConfigManager.getJobsConfiguration().EconomyExpLimitUse) - if (Jobs.ExpLimit.containsKey(playername) && Jobs.ExpLimit.get(playername).GetLeftTime(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit) > 0) { - PaymentData data = Jobs.ExpLimit.get(playername); - - String lefttimemessage = Language.getMessage("command.limit.output.leftexptime").replace("%hour%", String.valueOf(data.GetLeftHour(ConfigManager - .getJobsConfiguration().EconomyExpTimeLimit))); - lefttimemessage = lefttimemessage.replace("%min%", String.valueOf(data.GetLeftMin(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit))); - lefttimemessage = lefttimemessage.replace("%sec%", String.valueOf(data.GetLeftsec(ConfigManager.getJobsConfiguration().EconomyExpTimeLimit))); - player.sendMessage(lefttimemessage); - - String message = Language.getMessage("command.limit.output.explimit"); - message = message.replace("%exp%", String.valueOf(data.GetExpBylimit(JPlayer.getExpLimit()))); - message = message.replace("%totalexp%", String.valueOf(JPlayer.getExpLimit())); - player.sendMessage(message); - - } else { - - int lefttime1 = ConfigManager.getJobsConfiguration().EconomyExpTimeLimit; - - int hour = 0; - int min = 0; - int sec = 0; - - if (lefttime1 >= 3600) { - hour = lefttime1 / 3600; - lefttime1 = lefttime1 - (hour * 3600); - if (lefttime1 > 60 && lefttime1 < 3600) { - min = lefttime1 / 60; - sec = lefttime1 - (min * 60); - } else if (lefttime1 < 60) - sec = lefttime1; - } else if (lefttime1 > 60 && lefttime1 < 3600) { - min = lefttime1 / 60; - lefttime1 = lefttime1 - (min * 60); - } else - sec = lefttime1; - - String message = Language.getMessage("command.limit.output.leftexptime").replace("%hour%", String.valueOf(hour)); - message = message.replace("%min%", String.valueOf(min)); - message = message.replace("%sec%", String.valueOf(sec)); - player.sendMessage(message); - - message = Language.getMessage("command.limit.output.explimit").replace("%exp%", "0.0"); - message = message.replace("%totalexp%", String.valueOf(JPlayer.getExpLimit())); - player.sendMessage(message); - } - - return true; - } - - @JobCommand - public boolean log(CommandSender sender, String[] args) { - - if (!(sender instanceof Player) && args.length != 1) - return false; - - if (args.length != 1 && args.length != 0) { - sendUsage(sender, "log"); - return true; - } - JobsPlayer JPlayer = null; - if (args.length == 0) - JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); - else if (args.length == 1) { - if (!sender.hasPermission("jobs.commands.log.others")) { - sender.sendMessage(Language.getMessage("command.error.permission")); - return true; - } - JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); - if (JPlayer == null) - JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(OfflinePlayerList.getPlayer(args[0])); - } - - if (JPlayer == null) { - sendUsage(sender, "log"); - return true; - } - - List logList = JPlayer.getLog(); - - if (logList.size() == 0) { - sender.sendMessage(Language.getMessage("command.log.output.bottomline")); - sender.sendMessage(Language.getMessage("command.log.output.nodata")); - sender.sendMessage(Language.getMessage("command.log.output.bottomline")); - return true; - } - - Map unsortMap = new HashMap(); - - for (Log one : logList) { - HashMap AmountList = one.getAmountList(); - for (Entry oneMap : AmountList.entrySet()) { - unsortMap.put(oneMap.getKey(), oneMap.getValue().getMoney()); - } - } - - unsortMap = Sorting.sortDoubleDESC(unsortMap); - int count = 0; - int max = 10; - sender.sendMessage(Language.getMessage("command.log.output.topline").replace("%playername%", JPlayer.getUserName())); - for (Log one : logList) { - HashMap AmountList = one.getAmountList(); - for (Entry oneSorted : unsortMap.entrySet()) { - for (Entry oneMap : AmountList.entrySet()) { - if (oneMap.getKey().equalsIgnoreCase(oneSorted.getKey())) { - count++; - String msg = Language.getMessage("command.log.output.list") - .replace("%number%", String.valueOf(count)) - .replace("%action%", one.getActionType()) - .replace("%item%", oneMap.getValue().getItemName().replace(":0", "").replace("_", " ").toLowerCase()) - .replace("%qty%", String.valueOf(oneMap.getValue().getCount())) - .replace("%money%", String.valueOf(oneMap.getValue().getMoney())) - .replace("%exp%", String.valueOf(oneMap.getValue().getExp())); - msg = org.bukkit.ChatColor.translateAlternateColorCodes('&', msg); - sender.sendMessage(msg); - break; - } - } - if (count > max) - break; - } - if (count > max) - break; - } - sender.sendMessage(Language.getMessage("command.log.output.bottomline")); - - return true; - } - - @JobCommand - public boolean glog(final CommandSender sender, String[] args) { - if (args.length != 0) { - sendUsage(sender, "glog"); - return true; - } - Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { - @Override - public void run() { - Map unsortMap = new HashMap(); - - int time = TimeManage.timeInInt(); - - for (String OneP : Jobs.getJobsDAO().getLognameList(time, time)) { - JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(OneP); - if (JPlayer == null) { - OfflinePlayer offp = OfflinePlayerList.getPlayer(OneP); - if (offp != null) - JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(OfflinePlayerList.getPlayer(OneP)); - } - if (JPlayer == null) - continue; - List logList = JPlayer.getLog(); - if (logList.size() == 0) - continue; - - for (Log one : logList) { - HashMap AmountList = one.getAmountList(); - for (Entry oneMap : AmountList.entrySet()) { - oneMap.getValue().setUsername(OneP); - oneMap.getValue().setAction(one.getActionType()); - unsortMap.put(oneMap.getValue(), oneMap.getValue().getMoney()); - } - } - } - - unsortMap = Sorting.sortDoubleDESCByLog(unsortMap); - - int count = 1; - int max = 10; - - sender.sendMessage(Language.getMessage("command.glog.output.topline")); - for (Entry one : unsortMap.entrySet()) { - LogAmounts info = one.getKey(); - - String msg = Language.getMessage("command.glog.output.list") - .replace("%username%", one.getKey().getUsername()) - .replace("%number%", String.valueOf(count)) - .replace("%action%", info.getAction()) - .replace("%item%", one.getKey().getItemName().replace(":0", "").replace("_", " ").toLowerCase()) - .replace("%qty%", String.valueOf(one.getKey().getCount())) - .replace("%money%", String.valueOf(one.getKey().getMoney())) - .replace("%exp%", String.valueOf(one.getKey().getExp())); - msg = org.bukkit.ChatColor.translateAlternateColorCodes('&', msg); - sender.sendMessage(msg); - count++; - - if (count > max) - break; - } - if (unsortMap.size() == 0) { - sender.sendMessage(Language.getMessage("command.glog.output.nodata")); - } - sender.sendMessage(Language.getMessage("command.glog.output.bottomline")); - - return; - } - }); - return true; + sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.actions", "%actions%", builder.toString())); } /** @@ -1573,10 +357,10 @@ public class JobsCommands implements CommandExecutor { * @param type - type of info * @return the message */ - private String jobInfoMessage(JobsPlayer player, Job job, String type) { + public String jobInfoMessage(JobsPlayer player, Job job, String type) { if (job == null) { // job doesn't exist - return ChatColor.RED + Language.getMessage("command.error.job"); + return ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job"); } if (type == null) { @@ -1596,18 +380,20 @@ public class JobsCommands implements CommandExecutor { } if (job.getExpBoost() != 1.0) - message.append(ChatColor.GOLD + Language.getMessage("command.expboost.output.infostats").replace("%boost%", String.valueOf(job.getExpBoost())) + "\n"); + message.append(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.expboost.output.infostats", "%boost%", job.getExpBoost()) + "\n"); if (job.getMoneyBoost() != 1.0) - message.append(ChatColor.GOLD + Language.getMessage("command.moneyboost.output.infostats").replace("%boost%", String.valueOf(job.getMoneyBoost())) + "\n"); + message.append(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.moneyboost.output.infostats", "%boost%", job.getMoneyBoost()) + "\n"); - if (ConfigManager.getJobsConfiguration().useDynamicPayment) + if (job.getPointBoost() != 1.0) + message.append(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.pointboost.output.infostats", "%boost%", job.getPointBoost()) + "\n"); + + if (Jobs.getGCManager().useDynamicPayment) if (job.getBonus() < 0) - message.append(ChatColor.GOLD + Language.getMessage("command.info.help.penalty").replace("[penalty]", String.valueOf((int) (job.getBonus() * 100) / 100.0 - * -1)) + "\n"); - else - message.append(ChatColor.GOLD + Language.getMessage("command.info.help.bonus").replace("[bonus]", String.valueOf((int) (job.getBonus() * 100) / 100.0)) + message.append(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.info.help.penalty", "[penalty]", (int) (job.getBonus() * 100) / 100.0 * -1) + "\n"); + else + message.append(ChatColor.GOLD + Jobs.getLanguage().getMessage("command.info.help.bonus", "[bonus]", (int) (job.getBonus() * 100) / 100.0) + "\n"); for (ActionType actionType : ActionType.values()) { if (showAllTypes == 1 || type.startsWith(actionType.getName().toLowerCase())) { @@ -1615,7 +401,7 @@ public class JobsCommands implements CommandExecutor { if (info != null && !info.isEmpty()) { message.append(jobInfoMessage(player, job, actionType)); } else if (showAllTypes == 0) { - String myMessage = Language.getMessage("command.info.output." + actionType.getName().toLowerCase() + ".none"); + String myMessage = Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".none"); myMessage = myMessage.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); message.append(myMessage); } @@ -1635,17 +421,12 @@ public class JobsCommands implements CommandExecutor { // money exp boost Player dude = Bukkit.getServer().getPlayer(player.getPlayerUUID()); - Double MoneyBoost = Jobs.getPlayerManager().GetMoneyBoost(dude, job); - Double ExpBoost = Jobs.getPlayerManager().GetExpBoost(dude, job); - // Global boost - Double JobGlobalBoost = job.getExpBoost(); - - Double DynamicBonus = job.getBonus(); + BoostMultiplier finalBoost = Jobs.getPlayerManager().getFinalBonus(dude, job); StringBuilder message = new StringBuilder(); - message.append(Language.getMessage("command.info.output." + type.getName().toLowerCase() + ".info")); + message.append(Jobs.getLanguage().getMessage("command.info.output." + type.getName().toLowerCase() + ".info")); message.append(":\n"); int level = 1; @@ -1656,59 +437,60 @@ public class JobsCommands implements CommandExecutor { int numjobs = player.getJobProgression().size(); List jobInfo = job.getJobInfo(type); for (JobInfo info : jobInfo) { + String materialName = info.getName().toLowerCase().replace('_', ' '); materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1); - - materialName = TranslateName.Translate(materialName, info); - + materialName = Jobs.getNameTranslatorManager().Translate(materialName, info); materialName = org.bukkit.ChatColor.translateAlternateColorCodes('&', materialName); double income = info.getIncome(level, numjobs); - if (ConfigManager.getJobsConfiguration().useDynamicPayment) { - double moneyBonus = (income * (DynamicBonus / 100)); - income += moneyBonus; - } - - income = income + ((income * MoneyBoost) - income) + ((income * JobGlobalBoost) - income); +// Jobs.getPlayerManager().getFinalBonus(player, prog) + income = income + (income * finalBoost.getMoney() / 100); ChatColor incomeColor = income >= 0 ? ChatColor.GREEN : ChatColor.DARK_RED; double xp = info.getExperience(level, numjobs); - - if (ConfigManager.getJobsConfiguration().useDynamicPayment) { - double expBonus = (xp * (DynamicBonus / 100)); - xp += expBonus; - } - - xp = xp + ((xp * ExpBoost) - xp) + ((xp * JobGlobalBoost) - xp); + xp = xp + (xp * finalBoost.getExp() / 100); ChatColor xpColor = xp >= 0 ? ChatColor.YELLOW : ChatColor.GRAY; String xpString = String.format("%.2f xp", xp); + double points = info.getPoints(level, numjobs); + points = points + (points * finalBoost.getPoints() / 100); + ChatColor pointsColor = xp >= 0 ? ChatColor.GOLD : ChatColor.GRAY; + String pointsString = String.format("%.2f points ", points); + message.append(" "); - message.append(Language.getMessage("command.info.help.material").replace("%material%", materialName)); - if (prog!= null && !info.isInLevelRange(prog.getLevel())) + message.append(Jobs.getLanguage().getMessage("command.info.help.material", "%material%", materialName)); + if (prog != null && !info.isInLevelRange(prog.getLevel())) message.append(org.bukkit.ChatColor.RED + " -> "); else message.append(" -> "); + if (income != 0.0) { + message.append(incomeColor.toString()); + message.append(Jobs.getEconomy().format(income)); + message.append(" "); + } + + if (points != 0.0) { + message.append(pointsColor.toString()); + message.append(pointsString); + } + message.append(xpColor.toString()); message.append(xpString); - message.append(' '); - - message.append(incomeColor.toString()); - message.append(Jobs.getEconomy().format(income)); + message.append(" "); if (info.getFromLevel() > 1 && info.getUntilLevel() != -1) - message.append(Language.getMessage("command.info.help.levelRange").replace("%levelFrom%", "" + info.getFromLevel()).replace("%levelUntil%", "" + info - .getUntilLevel())); + message.append(Jobs.getLanguage().getMessage("command.info.help.levelRange", "%levelFrom%", info.getFromLevel(), "%levelUntil%", info.getUntilLevel())); if (info.getFromLevel() > 1 && info.getUntilLevel() == -1) - message.append(Language.getMessage("command.info.help.levelFrom").replace("%levelFrom%", "" + info.getFromLevel())); + message.append(Jobs.getLanguage().getMessage("command.info.help.levelFrom", "%levelFrom%", info.getFromLevel())); if (info.getFromLevel() == 1 && info.getUntilLevel() != -1) - message.append(Language.getMessage("command.info.help.levelUntil").replace("%levelUntil%", "" + info.getUntilLevel())); + message.append(Jobs.getLanguage().getMessage("command.info.help.levelUntil", "%levelUntil%", info.getUntilLevel())); message.append('\n'); } @@ -1720,12 +502,26 @@ public class JobsCommands implements CommandExecutor { * @param jobProg - the job progress of the players job * @return the message */ - private String jobStatsMessage(JobProgression jobProg) { - String message = Language.getMessage("command.stats.output"); - message = message.replace("%joblevel%", Integer.valueOf(jobProg.getLevel()).toString()); - message = message.replace("%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName() + ChatColor.WHITE); - message = message.replace("%jobxp%", Double.toString(Math.round((Double) jobProg.getExperience() * 100.0) / 100.0)); - message = message.replace("%jobmaxxp%", Integer.toString(jobProg.getMaxExperience())); + public String jobStatsMessage(JobProgression jobProg) { + String message = Jobs.getLanguage().getMessage("command.stats.output", + "%joblevel%", Integer.valueOf(jobProg.getLevel()).toString(), + "%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName() + ChatColor.WHITE, + "%jobxp%", Double.toString(Math.round((Double) jobProg.getExperience() * 100.0) / 100.0), + "%jobmaxxp%", Integer.toString(jobProg.getMaxExperience())); + return " " + jobProgressMessage(jobProg.getMaxExperience(), jobProg.getExperience()) + " " + message; + } + + public String jobProgressMessage(double max, double current) { + String message = ""; + String pos = ChatColor.DARK_GREEN + "\u258F"; + String pros = ChatColor.YELLOW + "\u258F"; + int percentage = (int) ((current * 50.0) / max); + for (int i = 0; i < percentage; i++) { + message += pos; + } + for (int i = 0; i < 50 - percentage; i++) { + message += pros; + } return message; } @@ -1734,30 +530,15 @@ public class JobsCommands implements CommandExecutor { * @param jobInfo - jobinfo string line * @return the message */ - private String jobStatsMessage(String jobInfo) { + public String jobStatsMessage(String jobInfo) { String[] splited = jobInfo.split(":"); if (Jobs.getJob(splited[0]) == null) return ""; - String message = Language.getMessage("command.archive.output"); - message = message.replace("%joblevel%", Integer.valueOf(splited[1]).toString()); - message = message.replace("%getbackjoblevel%", Integer.valueOf(splited[2]).toString()); - message = message.replace("%jobname%", Jobs.getJob(splited[0]).getChatColor() + splited[0] + ChatColor.WHITE); - message = message.replace("%jobxp%", Double.toString(Math.round((Double) Double.valueOf(splited[3]) * 100.0) / 100.0)); + String message = Jobs.getLanguage().getMessage("command.archive.output", + "%joblevel%", Integer.valueOf(splited[1]).toString(), + "%getbackjoblevel%", Integer.valueOf(splited[2]).toString(), + "%jobname%", Jobs.getJob(splited[0]).getChatColor() + splited[0] + ChatColor.WHITE, + "%jobxp%", Double.toString(Math.round((Double) Double.valueOf(splited[3]) * 100.0) / 100.0)); return message; } - - /** - * Check Job joining permission - */ - public static boolean hasJobPermission(Player sender, Job job) { - return hasJobPermission((CommandSender) sender, job); - } - - private static boolean hasJobPermission(CommandSender sender, Job job) { - if (!sender.hasPermission("jobs.use")) { - return false; - } else { - return sender.hasPermission("jobs.join." + job.getName().toLowerCase()); - } - } } diff --git a/com/gamingmesh/jobs/commands/list/.gitignore b/com/gamingmesh/jobs/commands/list/.gitignore new file mode 100644 index 00000000..d494fd62 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/.gitignore @@ -0,0 +1,45 @@ +/fixnames.class +/aaa.class +/aaa2.class +/aaa3.class +/aaa4.class +/aaa5.class +/aaa6.class +/convert.class +/join.class +/leave.class +/leaveall.class +/info.class +/aaa7.class +/stats.class +/toggle.class +/aaa8.class +/aaa10.class +/aaa9.class +/expboost.class +/moneyboost.class +/archive.class +/playerinfo.class +/reload.class +/browse.class +/fire.class +/fireall.class +/employ.class +/promote.class +/demote.class +/grantxp.class +/removexp.class +/transfer.class +/signupdate.class +/gtop.class +/top.class +/give.class +/limit.class +/log.class +/glog.class +/glog$1.class +/pointboost.class +/points.class +/shop.class +/bonus.class +/editpoints.class diff --git a/com/gamingmesh/jobs/commands/list/archive.java b/com/gamingmesh/jobs/commands/list/archive.java new file mode 100644 index 00000000..e61d2858 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/archive.java @@ -0,0 +1,55 @@ +package com.gamingmesh.jobs.commands.list; + +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class archive implements Cmd { + + @JobCommand(1400) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + JobsPlayer jPlayer = null; + if (args.length >= 1) { + if (!sender.hasPermission("jobs.command.admin.archive")) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.permission")); + return true; + } + @SuppressWarnings("deprecation") + OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); + jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); + + } else if (sender instanceof Player) { + jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); + } + + if (jPlayer == null) { + if (args.length >= 1) + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); + return true; + } + + List AllJobs = Jobs.getJobsDAO().getJobsFromArchive(jPlayer); + + if (AllJobs.isEmpty()) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.archive.error.nojob")); + return true; + } + + sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getUserName())); + for (String jobInfo : AllJobs) { + sender.sendMessage(Jobs.getCommandManager().jobStatsMessage(jobInfo)); + } + sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/bonus.java b/com/gamingmesh/jobs/commands/list/bonus.java new file mode 100644 index 00000000..b08ae612 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/bonus.java @@ -0,0 +1,109 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.BoostMultiplier; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class bonus implements Cmd { + + @JobCommand(300) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (!(sender instanceof Player)) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); + return false; + } + + if (args.length != 1) { + Jobs.getCommandManager().sendUsage(sender, "bonus"); + return true; + } + + Player player = (Player) sender; + + Job job = Jobs.getJob(args[0]); + + if (job == null) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + +// sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", job.getChatColor() + job.getName())); + double PMoneyBoost = Jobs.getPlayerManager().GetMoneyBoostInPerc(player, job); + PMoneyBoost = (int) (PMoneyBoost * 100D) / 100D; + double PPointBoost = Jobs.getPlayerManager().GetPointBoostInPerc(player, job); + PPointBoost = (int) (PPointBoost * 100D) / 100D; + double PExpBoost = Jobs.getPlayerManager().GetExpBoostInPerc(player, job); + PExpBoost = (int) (PExpBoost * 100D) / 100D; + + double GMoneyBoost = job.getMoneyBoost() * 100.0 - 100.0; + GMoneyBoost = (int) (GMoneyBoost * 100D) / 100D; + double GPointBoost = job.getPointBoost() * 100.0 - 100.0; + GPointBoost = (int) (GPointBoost * 100D) / 100D; + double GExpBoost = job.getExpBoost() * 100.0 - 100.0; + GExpBoost = (int) (GExpBoost * 100D) / 100D; + + double DBoost = (int) (job.getBonus() * 100D) / 100D; + + BoostMultiplier itemboost = Jobs.getPlayerManager().getItemBoost(player, job); + + double IMoneyBoost = itemboost.getMoney() * 100.0 - 100.0; + IMoneyBoost = (int) (IMoneyBoost * 100D) / 100D; + double IPointBoost = itemboost.getPoints() * 100.0 - 100.0; + IPointBoost = (int) (IPointBoost * 100D) / 100D; + double IExpBoost = itemboost.getExp() * 100.0 - 100.0; + IExpBoost = (int) (IExpBoost * 100D) / 100D; + + double RBoost = Jobs.getRestrictedAreaManager().getRestrictedMultiplier(player) * 100.0 - 100.0; + RBoost = (int) (RBoost * 100D) / 100D; + + sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.topline")); + + sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.permission", + "%money%", ChatColor.DARK_GREEN.toString() + formatText(PMoneyBoost), + "%points%", ChatColor.GOLD.toString() + formatText(PPointBoost), + "%exp%", ChatColor.YELLOW.toString() + formatText(PExpBoost))); + + sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.item", + "%money%", ChatColor.DARK_GREEN.toString() + formatText(IMoneyBoost), + "%points%", ChatColor.GOLD.toString() + formatText(IPointBoost), + "%exp%", ChatColor.YELLOW.toString() + formatText(IExpBoost))); + + sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.global", + "%money%", ChatColor.DARK_GREEN.toString() + formatText(GMoneyBoost), + "%points%", ChatColor.GOLD.toString() + formatText(GPointBoost), + "%exp%", ChatColor.YELLOW.toString() + formatText(GExpBoost))); + + sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.dynamic", + "%money%", ChatColor.DARK_GREEN.toString() + formatText(DBoost), + "%points%", ChatColor.GOLD.toString() + formatText(DBoost), + "%exp%", ChatColor.YELLOW.toString() + formatText(DBoost))); + + sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.area", + "%money%", ChatColor.DARK_GREEN.toString() + formatText(RBoost), + "%points%", ChatColor.GOLD.toString() + formatText(RBoost), + "%exp%", ChatColor.YELLOW.toString() + formatText(RBoost))); + + double Fmoney = Math.rint((IMoneyBoost + DBoost + GMoneyBoost + PMoneyBoost + RBoost) * 100) / 100; + double Fpoints = Math.rint((IPointBoost + DBoost + GPointBoost + PPointBoost + RBoost) * 100) / 100; + double Fexp = Math.rint((IExpBoost + DBoost + GExpBoost + PExpBoost + RBoost) * 100) / 100; + + sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); + sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.final", + "%money%", ChatColor.DARK_GREEN.toString() + formatText(Fmoney), + "%points%", ChatColor.GOLD.toString() + formatText(Fpoints), + "%exp%", ChatColor.YELLOW.toString() + formatText(Fexp))); + + return true; + } + + private String formatText(double amount) { + return ((amount > 0 ? "+" : "") + amount + "%"); + } + +} diff --git a/com/gamingmesh/jobs/commands/list/browse.java b/com/gamingmesh/jobs/commands/list/browse.java new file mode 100644 index 00000000..7f9176f4 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/browse.java @@ -0,0 +1,72 @@ +package com.gamingmesh.jobs.commands.list; + +import java.util.ArrayList; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.stuff.ChatColor; +import com.gamingmesh.jobs.stuff.Perm; + +public class browse implements Cmd { + + @JobCommand(200) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + ArrayList lines = new ArrayList(); + for (Job job : Jobs.getJobs()) { + if (Jobs.getGCManager().getHideJobsWithoutPermission()) { + if (!Jobs.getCommandManager().hasJobPermission(sender, job)) + continue; + } + StringBuilder builder = new StringBuilder(); + builder.append(" "); + builder.append(job.getChatColor().toString()); + builder.append(job.getName()); + if (job.getMaxLevel() > 0) { + builder.append(ChatColor.WHITE.toString()); + builder.append(Jobs.getLanguage().getMessage("command.info.help.max")); + if (Perm.hasPermission(sender, "jobs." + job.getName() + ".vipmaxlevel") && job.getVipMaxLevel() != 0) + builder.append(job.getVipMaxLevel()); + else + builder.append(job.getMaxLevel()); + } + + if (Jobs.getGCManager().ShowTotalWorkers) + builder.append(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers())); + + if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) + if (job.getBonus() < 0) + builder.append(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) / 100.0 * -1)); + else + builder.append(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100) / 100.0)); + + lines.add(builder.toString()); + if (!job.getDescription().isEmpty()) { + lines.add(" - " + job.getDescription().replace("/n", "")); + } + } + + if (lines.size() == 0) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.browse.error.nojobs")); + return true; + } + + if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnBrowse) { + ((Player) sender).openInventory(Jobs.getGUIManager().CreateJobsGUI((Player) sender)); + } + + if (Jobs.getGCManager().JobsGUIShowChatBrowse) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.header")); + for (String line : lines) { + sender.sendMessage(line); + } + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.footer")); + } + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/convert.java b/com/gamingmesh/jobs/commands/list/convert.java new file mode 100644 index 00000000..b0687426 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/convert.java @@ -0,0 +1,78 @@ +package com.gamingmesh.jobs.commands.list; + +import java.io.IOException; +import java.sql.SQLException; +import java.util.List; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Convert; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class convert implements Cmd { + + @JobCommand(2600) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + + if (!(sender instanceof Player)) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.fromconsole")); + return false; + } + + if (args.length > 0) { + Jobs.getCommandManager().sendUsage(sender, "convert"); + return true; + } + + Player pSender = (Player) sender; + + List list = null; + List archivelist = null; + + try { + list = Jobs.getJobsDAO().convertDatabase(pSender, "jobs"); + archivelist = Jobs.getJobsDAO().convertDatabase(pSender, "archive"); + } catch (SQLException e) { + e.printStackTrace(); + sender.sendMessage(ChatColor.RED + "Can't read data from data base, please send error log to dev's."); + return false; + } + Jobs.ChangeDatabase(); + + if (list == null & archivelist == null) + return false; + try { + Jobs.getJobsDAO().continueConvertions(list, "jobs"); + Jobs.getJobsDAO().continueConvertions(archivelist, "archive"); + } catch (SQLException e) { + e.printStackTrace(); + sender.sendMessage(ChatColor.RED + "Can't write data to data base, please send error log to dev's."); + return false; + } + + try { + Jobs.reload(); + } catch (IOException e) { + e.printStackTrace(); + } + + String from = "MysSQL"; + String to = "SqLite"; + + if (Jobs.getGCManager().storageMethod.equalsIgnoreCase("sqlite")) { + from = "SqLite"; + to = "MySQL"; + } + + sender.sendMessage(ChatColor.GOLD + "Data base was converted from " + ChatColor.GREEN + from + ChatColor.GOLD + " to " + ChatColor.GREEN + to + ChatColor.GOLD + + "! Now you can stop the server, change storage-method to " + ChatColor.GREEN + to + ChatColor.GOLD + + " in general config file and start server again on your new database system."); + + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/demote.java b/com/gamingmesh/jobs/commands/list/demote.java new file mode 100644 index 00000000..e60d9de7 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/demote.java @@ -0,0 +1,55 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class demote implements Cmd { + + @JobCommand(1700) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (args.length < 3) { + Jobs.getCommandManager().sendUsage(sender, "demote"); + return true; + } + + @SuppressWarnings("deprecation") + OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); + + Job job = Jobs.getJob(args[1]); + if (job == null) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + try { + // check if player already has the job + if (jPlayer.isInJob(job)) { + Integer levelsLost = Integer.parseInt(args[2]); + Jobs.getPlayerManager().demoteJob(jPlayer, job, levelsLost); + + Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); + if (player != null) { + String message = Jobs.getLanguage().getMessage("command.demote.output.target", + "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE, + "%levelslost%", levelsLost); + player.sendMessage(message); + } + + sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); + } + } catch (Exception e) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error")); + } + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/editpoints.java b/com/gamingmesh/jobs/commands/list/editpoints.java new file mode 100644 index 00000000..93d27470 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/editpoints.java @@ -0,0 +1,69 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.container.PlayerPoints; + +public class editpoints implements Cmd { + + @JobCommand(475) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + + if (args.length != 3) { + Jobs.getCommandManager().sendUsage(sender, "editpoints"); + return true; + } + + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[1]); + if (jPlayer == null) + jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(args[1]); + + if (jPlayer == null) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[1])); + return true; + } + + double amount = 0; + try { + amount = Double.parseDouble(args[2]); + } catch (NumberFormatException e) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.notNumber")); + return true; + } + + PlayerPoints pointInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(jPlayer.getPlayerUUID()); + + if (pointInfo == null) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", jPlayer.getUserName())); + return true; + } + + switch (args[0].toLowerCase()) { + case "take": + pointInfo.takePoints(amount); + sender.sendMessage(Jobs.getLanguage().getMessage("command.editpoints.output.take", + "%playername%", jPlayer.getUserName(), + "%amount%", amount, + "%total%", (int) (pointInfo.getCurrentPoints() * 100) / 100D)); + break; + case "add": + pointInfo.addPoints(amount); + sender.sendMessage(Jobs.getLanguage().getMessage("command.editpoints.output.add", + "%playername%", jPlayer.getUserName(), + "%amount%", amount, + "%total%", (int) (pointInfo.getCurrentPoints() * 100) / 100D)); + break; + case "set": + pointInfo.setPoints(amount); + sender.sendMessage(Jobs.getLanguage().getMessage("command.editpoints.output.set", + "%playername%", jPlayer.getUserName(), + "%amount%", amount)); + break; + } + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/employ.java b/com/gamingmesh/jobs/commands/list/employ.java new file mode 100644 index 00000000..e34a1359 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/employ.java @@ -0,0 +1,54 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class employ implements Cmd { + + @JobCommand(1800) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (args.length < 2) { + Jobs.getCommandManager().sendUsage(sender, "employ"); + return true; + } + + @SuppressWarnings("deprecation") + OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); + + Job job = Jobs.getJob(args[1]); + if (job == null) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + if (jPlayer.isInJob(job)) { + // already in job message + String message = ChatColor.RED + Jobs.getLanguage().getMessage("command.employ.error.alreadyin", "%jobname%", job.getChatColor() + job.getName() + + ChatColor.RED); + sender.sendMessage(message); + return true; + } + try { + // check if player already has the job + Jobs.getPlayerManager().joinJob(jPlayer, job); + Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); + if (player != null) + player.sendMessage(Jobs.getLanguage().getMessage("command.employ.output.target", "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE)); + + sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); + } catch (Exception e) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error")); + } + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/expboost.java b/com/gamingmesh/jobs/commands/list/expboost.java new file mode 100644 index 00000000..ab2d8607 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/expboost.java @@ -0,0 +1,79 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class expboost implements Cmd { + + @JobCommand(2300) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (args.length > 2 || args.length <= 1) { + Jobs.getCommandManager().sendUsage(sender, "expboost"); + return true; + } + + double rate = 1.0; + if (!args[1].equalsIgnoreCase("all") && !args[0].equalsIgnoreCase("reset")) + try { + rate = Double.parseDouble(args[1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "expboost"); + return true; + } + + String PlayerName = sender.getName(); + String jobName = args[0]; + Job job = Jobs.getJob(jobName); + + if (PlayerName == null) { + Jobs.getCommandManager().sendUsage(sender, "expboost"); + return true; + } + + if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) { + for (Job one : Jobs.getJobs()) { + one.setExpBoost(1.0); + } + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.expboost.output.allreset")); + return true; + } else if (args[0].equalsIgnoreCase("reset")) { + boolean found = false; + for (Job one : Jobs.getJobs()) { + if (one.getName().equalsIgnoreCase(args[1])) { + one.setExpBoost(1.0); + found = true; + break; + } + } + + if (found) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.expboost.output.jobsboostreset", "%jobname%", job.getName())); + return true; + } + } + + if (args[0].equalsIgnoreCase("all")) { + + for (Job one : Jobs.getJobs()) { + one.setExpBoost(rate); + } + + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate)); + return true; + } else { + if (job == null) { + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + job.setExpBoost(rate); + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName())); + return true; + } + } +} diff --git a/com/gamingmesh/jobs/commands/list/fire.java b/com/gamingmesh/jobs/commands/list/fire.java new file mode 100644 index 00000000..f9728725 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/fire.java @@ -0,0 +1,53 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class fire implements Cmd { + + @JobCommand(1900) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (args.length < 2) { + Jobs.getCommandManager().sendUsage(sender, "fire"); + return true; + } + + @SuppressWarnings("deprecation") + OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); + + Job job = Jobs.getJob(args[1]); + if (job == null) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + if (!jPlayer.isInJob(job)) { + String message = ChatColor.RED + Jobs.getLanguage().getMessage("command.fire.error.nojob", "%jobname%", job.getChatColor() + job.getName() + ChatColor.RED); + sender.sendMessage(message); + return true; + } + try { + Jobs.getPlayerManager().leaveJob(jPlayer, job); + Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); + if (player != null) { + String message = Jobs.getLanguage().getMessage("command.fire.output.target", "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); + player.sendMessage(message); + } + + sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); + } catch (Exception e) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error")); + } + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/fireall.java b/com/gamingmesh/jobs/commands/list/fireall.java new file mode 100644 index 00000000..4b19619c --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/fireall.java @@ -0,0 +1,50 @@ +package com.gamingmesh.jobs.commands.list; + +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.JobProgression; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class fireall implements Cmd { + + @JobCommand(2000) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (args.length < 1) { + Jobs.getCommandManager().sendUsage(sender, "fireall"); + return true; + } + + @SuppressWarnings("deprecation") + OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); + + List jobs = jPlayer.getJobProgression(); + if (jobs.size() == 0) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.fireall.error.nojobs")); + return true; + } + + try { + Jobs.getPlayerManager().leaveAllJobs(jPlayer); + Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); + if (player != null) { + player.sendMessage(Jobs.getLanguage().getMessage("command.fireall.output.target")); + } + + sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); + } catch (Exception e) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error")); + } + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/give.java b/com/gamingmesh/jobs/commands/list/give.java new file mode 100644 index 00000000..ddeac236 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/give.java @@ -0,0 +1,55 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobItems; +import com.gamingmesh.jobs.stuff.GiveItem; + +public class give implements Cmd { + + @JobCommand(2500) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + + if (args.length < 1 || Jobs.getJob(args[0]) == null && Jobs.getJob(args[1]) == null) { + Jobs.getCommandManager().sendUsage(sender, "give"); + return true; + } + + if (args.length == 2 && sender instanceof Player) { + Job job = Jobs.getJob(args[0]); + for (JobItems item : job.getItems()) { + if (item.getNode().equalsIgnoreCase(args[1])) { + GiveItem.GiveItemForPlayer((Player) sender, item.getId(), 0, 1, item.getName(), item.getLore(), item.getenchants()); + return true; + } + } + sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem")); + return true; + } else if (args.length == 3) { + Job job = Jobs.getJob(args[1]); + Player player = Bukkit.getPlayer(args[0]); + if (player == null) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.notonline", "%playername%", args[0])); + return true; + } + for (JobItems item : job.getItems()) { + if (item.getNode().equalsIgnoreCase(args[2])) { + GiveItem.GiveItemForPlayer(player, item.getId(), 0, 1, item.getName(), item.getLore(), item.getenchants()); + return true; + } + } + sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem")); + return true; + } else { + Jobs.getCommandManager().sendUsage(sender, "give"); + return true; + } + } +} diff --git a/com/gamingmesh/jobs/commands/list/glog.java b/com/gamingmesh/jobs/commands/list/glog.java new file mode 100644 index 00000000..0856bf2b --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/glog.java @@ -0,0 +1,101 @@ +package com.gamingmesh.jobs.commands.list; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.container.Log; +import com.gamingmesh.jobs.container.LogAmounts; +import com.gamingmesh.jobs.container.PlayerInfo; +import com.gamingmesh.jobs.stuff.Sorting; +import com.gamingmesh.jobs.stuff.TimeManage; + +public class glog implements Cmd { + + @JobCommand(1200) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (args.length != 0) { + Jobs.getCommandManager().sendUsage(sender, "glog"); + return true; + } + Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { + @Override + public void run() { + Map unsortMap = new HashMap(); + + int time = TimeManage.timeInInt(); + + for (Integer OneP : Jobs.getJobsDAO().getLognameList(time, time)) { + + Entry info = Jobs.getPlayerManager().getPlayerInfoById(OneP); + + if (info == null) + continue; + + String name = info.getValue().getName(); + + if (name == null) + continue; + + JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(name); + if (JPlayer == null) { + JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(name); + } + + if (JPlayer == null) + continue; + List logList = JPlayer.getLog(); + if (logList.size() == 0) + continue; + + for (Log one : logList) { + HashMap AmountList = one.getAmountList(); + for (Entry oneMap : AmountList.entrySet()) { + oneMap.getValue().setUsername(name); + oneMap.getValue().setAction(one.getActionType()); + unsortMap.put(oneMap.getValue(), oneMap.getValue().getMoney()); + } + } + } + + unsortMap = Sorting.sortDoubleDESCByLog(unsortMap); + + int count = 1; + int max = 10; + + sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.topline")); + for (Entry one : unsortMap.entrySet()) { + LogAmounts info = one.getKey(); + sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.list", + "%username%", one.getKey().getUsername(), + "%number%", count, + "%action%", info.getAction(), + "%item%", one.getKey().getItemName().replace(":0", "").replace("_", " ").toLowerCase(), + "%qty%", one.getKey().getCount(), + "%money%", one.getKey().getMoney(), + "%exp%", one.getKey().getExp())); + count++; + + if (count > max) + break; + } + if (unsortMap.size() == 0) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.nodata")); + } + sender.sendMessage(Jobs.getLanguage().getMessage("command.glog.output.bottomline")); + + return; + } + }); + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/grantxp.java b/com/gamingmesh/jobs/commands/list/grantxp.java new file mode 100644 index 00000000..0619e5c8 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/grantxp.java @@ -0,0 +1,62 @@ + +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class grantxp implements Cmd { + + @JobCommand(2100) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (args.length < 3) { + Jobs.getCommandManager().sendUsage(sender, "grantxp"); + return true; + } + + @SuppressWarnings("deprecation") + OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); + + Job job = Jobs.getJob(args[1]); + if (job == null) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + double xpGained; + try { + xpGained = Double.parseDouble(args[2]); + } catch (Exception e) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error")); + return true; + } + if (xpGained <= 0) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error")); + return true; + } + // check if player already has the job + if (jPlayer.isInJob(job)) { + Jobs.getPlayerManager().addExperience(jPlayer, job, xpGained); + + Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); + if (player != null) { + String message = Jobs.getLanguage().getMessage("command.grantxp.output.target", + "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE, + "%xpgained%", xpGained); + player.sendMessage(message); + } + + sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); + } + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/gtop.java b/com/gamingmesh/jobs/commands/list/gtop.java new file mode 100644 index 00000000..394f8c9e --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/gtop.java @@ -0,0 +1,105 @@ +package com.gamingmesh.jobs.commands.list; + +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Score; +import org.bukkit.scoreboard.Scoreboard; +import org.bukkit.scoreboard.ScoreboardManager; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.TopList; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class gtop implements Cmd { + + @JobCommand(600) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + + if (args.length != 1 && args.length != 0) { + Jobs.getCommandManager().sendUsage(sender, "gtop"); + return true; + } + + if (!(sender instanceof Player)) + return false; + Player player = (Player) sender; + + if (args.length > 0 && args[0].equalsIgnoreCase("clear")) { + player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); + return true; + } + + int start = 0; + if (args.length == 1) + try { + start = Integer.parseInt(args[0]); + } catch (NumberFormatException e) { + return true; + } + if (start < 0) + start = 0; + + List FullList = Jobs.getJobsDAO().getGlobalTopList(start); + if (FullList.size() <= 0) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.gtop.error.nojob")); + return false; + } + + if (!Jobs.getGCManager().ShowToplistInScoreboard) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.topline")); + int i = start; + for (TopList One : FullList) { + i++; + String PlayerName = One.getPlayerName() != null ? One.getPlayerName() : "Unknown"; + sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.list", "%number%", i, "%playername%", PlayerName, "%level%", One.getLevel(), + "%exp%", One.getExp())); + } + } else { + + player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); + + ScoreboardManager manager = Bukkit.getScoreboardManager(); + Scoreboard board = manager.getNewScoreboard(); + Objective objective = board.registerNewObjective("JobsTopPlayers", "dummy"); + objective.setDisplaySlot(DisplaySlot.SIDEBAR); + objective.setDisplayName(Jobs.getLanguage().getMessage("scoreboard.gtopline")); + int i = start; + for (TopList One : FullList) { + i++; + String playername = One.getPlayerName() != null ? One.getPlayerName() : "Unknown"; + + Score score = objective.getScore(Jobs.getLanguage().getMessage("scoreboard.lines", "%number%", i, "%playername%", playername)); + score.setScore(One.getLevel()); + + } + player.setScoreboard(board); + + Jobs.getScboard().addNew(player); + + int from = start; + if (start >= 15) + from = start - 15; + int until = start + 15; + + String prev = "[\"\",{\"text\":\"" + Jobs.getLanguage().getMessage("command.gtop.output.prev") + + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs gtop " + + from + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Jobs.getLanguage().getMessage( + "command.gtop.output.show", "[from]", from, "[until]", (from + 15)) + "\"}]}}}"; + String next = " {\"text\":\"" + Jobs.getLanguage().getMessage("command.gtop.output.next") + + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs gtop " + + until + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Jobs.getLanguage().getMessage( + "command.gtop.output.show", "[from]", (until + 1), "[until]", (until + 15)) + "\"}]}}}]"; + + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + prev + "," + next); + } + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/info.java b/com/gamingmesh/jobs/commands/list/info.java new file mode 100644 index 00000000..62b89ec0 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/info.java @@ -0,0 +1,53 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class info implements Cmd { + + @JobCommand(300) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (!(sender instanceof Player)) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); + return false; + } + + if (args.length < 1) { + Jobs.getCommandManager().sendUsage(sender, "info"); + Jobs.getCommandManager().sendValidActions(sender); + return true; + } + + Player pSender = (Player) sender; + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); + + String jobName = args[0]; + Job job = Jobs.getJob(jobName); + if (job == null) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + + if (Jobs.getGCManager().hideJobsInfoWithoutPermission) + if (!Jobs.getCommandManager().hasJobPermission(pSender, job)) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.permission")); + return true; + } + + String type = ""; + if (args.length >= 2) { + type = args[1]; + } + sender.sendMessage(Jobs.getCommandManager().jobInfoMessage(jPlayer, job, type).split("\n")); + return true; + } + +} diff --git a/com/gamingmesh/jobs/commands/list/join.java b/com/gamingmesh/jobs/commands/list/join.java new file mode 100644 index 00000000..a1d373fd --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/join.java @@ -0,0 +1,83 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + + +public class join implements Cmd { + + @JobCommand(100) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (!(sender instanceof Player)){ + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); + return false; + } + + if (args.length != 1 && args.length != 0) { + Jobs.getCommandManager().sendUsage(sender, "join"); + return true; + } + + if (args.length == 0) { + if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnJoin) + ((Player) sender).openInventory(Jobs.getGUIManager().CreateJobsGUI((Player) sender)); + else + return false; + return true; + } + + Player pSender = (Player) sender; + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); + + String jobName = args[0]; + Job job = Jobs.getJob(jobName); + if (job == null) { + // job does not exist + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + + if (!Jobs.getCommandManager().hasJobPermission(pSender, job)) { + // you do not have permission to join the job + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.permission")); + return true; + } + + if (jPlayer.isInJob(job)) { + // already in job message + String message = ChatColor.RED + Jobs.getLanguage().getMessage("command.join.error.alreadyin"); + message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.RED); + sender.sendMessage(message); + return true; + } + + if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) { + String message = ChatColor.RED + Jobs.getLanguage().getMessage("command.join.error.fullslots"); + message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.RED); + sender.sendMessage(message); + return true; + } + + int confMaxJobs = Jobs.getGCManager().getMaxJobs(); + short PlayerMaxJobs = (short) jPlayer.getJobProgression().size(); + if (confMaxJobs > 0 && PlayerMaxJobs >= confMaxJobs && !Jobs.getPlayerManager().getJobsLimit(pSender, PlayerMaxJobs)) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.join.error.maxjobs")); + return true; + } + + Jobs.getPlayerManager().joinJob(jPlayer, job); + + String message = Jobs.getLanguage().getMessage("command.join.success"); + message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); + sender.sendMessage(message); + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/leave.java b/com/gamingmesh/jobs/commands/list/leave.java new file mode 100644 index 00000000..623ef829 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/leave.java @@ -0,0 +1,43 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + + +public class leave implements Cmd { + + @JobCommand(800) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (!(sender instanceof Player)) + return false; + + if (args.length < 1) { + Jobs.getCommandManager().sendUsage(sender, "leave"); + return true; + } + + Player pSender = (Player) sender; + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); + + String jobName = args[0]; + Job job = Jobs.getJob(jobName); + if (job == null) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + + Jobs.getPlayerManager().leaveJob(jPlayer, job); + String message = Jobs.getLanguage().getMessage("command.leave.success"); + message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); + sender.sendMessage(message); + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/leaveall.java b/com/gamingmesh/jobs/commands/list/leaveall.java new file mode 100644 index 00000000..1c6b8e10 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/leaveall.java @@ -0,0 +1,37 @@ +package com.gamingmesh.jobs.commands.list; + +import java.util.List; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.JobProgression; +import com.gamingmesh.jobs.container.JobsPlayer; + +public class leaveall implements Cmd { + + @JobCommand(900) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (!(sender instanceof Player)) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); + return false; + } + + Player pSender = (Player) sender; + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); + + List jobs = jPlayer.getJobProgression(); + if (jobs.size() == 0) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.error.nojobs")); + return true; + } + + Jobs.getPlayerManager().leaveAllJobs(jPlayer); + sender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.success")); + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/limit.java b/com/gamingmesh/jobs/commands/list/limit.java new file mode 100644 index 00000000..4e0b0fc8 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/limit.java @@ -0,0 +1,173 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.economy.PaymentData; + +public class limit implements Cmd { + + @JobCommand(700) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (args.length > 0) { + Jobs.getCommandManager().sendUsage(sender, "limit"); + return true; + } + + if (!(sender instanceof Player)) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); + return false; + } + + Player player = (Player) sender; + + if (!Jobs.getGCManager().MoneyLimitUse && !Jobs.getGCManager().ExpLimitUse && !Jobs.getGCManager().PointLimitUse) { + player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.notenabled")); + return true; + } + JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player); + + String playername = player.getName(); + + if (Jobs.getGCManager().MoneyLimitUse) + if (Jobs.paymentLimit.containsKey(playername) && Jobs.paymentLimit.get(playername).GetLeftTime(Jobs.getGCManager().MoneyTimeLimit) > 0) { + PaymentData data = Jobs.paymentLimit.get(playername); + + player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.lefttime", + "%hour%", data.GetLeftHour(Jobs.getGCManager().MoneyTimeLimit), + "%min%", data.GetLeftMin(Jobs.getGCManager().MoneyTimeLimit), + "%sec%", data.GetLeftsec(Jobs.getGCManager().MoneyTimeLimit))); + + player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.moneylimit", + "%money%", data.GetAmountBylimit(JPlayer.getMoneyLimit()), + "%totalmoney%", JPlayer.getMoneyLimit())); + + } else { + + int lefttime1 = Jobs.getGCManager().MoneyTimeLimit; + + int hour = 0; + int min = 0; + int sec = 0; + + if (lefttime1 >= 3600) { + hour = lefttime1 / 3600; + lefttime1 = lefttime1 - (hour * 3600); + if (lefttime1 > 60 && lefttime1 < 3600) { + min = lefttime1 / 60; + sec = lefttime1 - (min * 60); + } else if (lefttime1 < 60) + sec = lefttime1; + } else if (lefttime1 > 60 && lefttime1 < 3600) { + min = lefttime1 / 60; + lefttime1 = lefttime1 - (min * 60); + } else + sec = lefttime1; + + player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.lefttime", "%hour%", hour, + "%min%", min, + "%sec%", sec)); + + player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.moneylimit", + "%money%", "0.0", + "%totalmoney%", JPlayer.getMoneyLimit())); + } + + if (Jobs.getGCManager().ExpLimitUse) + if (Jobs.ExpLimit.containsKey(playername) && Jobs.ExpLimit.get(playername).GetLeftTime(Jobs.getGCManager().ExpTimeLimit) > 0) { + PaymentData data = Jobs.ExpLimit.get(playername); + + player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.leftexptime", + "%hour%", data.GetLeftHour(Jobs.getGCManager().ExpTimeLimit), + "%min%", data.GetLeftMin(Jobs.getGCManager().ExpTimeLimit), + "%sec%", data.GetLeftsec(Jobs.getGCManager().ExpTimeLimit))); + + player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.explimit", + "%exp%", data.GetExpBylimit(JPlayer.getExpLimit()), + "%totalexp%", JPlayer.getExpLimit())); + + } else { + + int lefttime1 = Jobs.getGCManager().ExpTimeLimit; + + int hour = 0; + int min = 0; + int sec = 0; + + if (lefttime1 >= 3600) { + hour = lefttime1 / 3600; + lefttime1 = lefttime1 - (hour * 3600); + if (lefttime1 > 60 && lefttime1 < 3600) { + min = lefttime1 / 60; + sec = lefttime1 - (min * 60); + } else if (lefttime1 < 60) + sec = lefttime1; + } else if (lefttime1 > 60 && lefttime1 < 3600) { + min = lefttime1 / 60; + lefttime1 = lefttime1 - (min * 60); + } else + sec = lefttime1; + + player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.leftexptime", + "%hour%", hour, + "%min%", min, + "%sec%", sec)); + + player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.explimit", + "%exp%", "0.0", + "%totalexp%", JPlayer.getExpLimit())); + } + + if (Jobs.getGCManager().PointLimitUse) + if (Jobs.PointLimit.containsKey(playername) && Jobs.PointLimit.get(playername).GetLeftTime(Jobs.getGCManager().PointTimeLimit) > 0) { + PaymentData data = Jobs.PointLimit.get(playername); + + player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.leftpointtime", + "%hour%", data.GetLeftHour(Jobs.getGCManager().PointTimeLimit), + "%min%", data.GetLeftMin(Jobs.getGCManager().PointTimeLimit), + "%sec%", data.GetLeftsec(Jobs.getGCManager().PointTimeLimit))); + + player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.pointlimit", + "%current%", data.GetPointsBylimit(JPlayer.getPointLimit()), + "%total%", JPlayer.getPointLimit())); + + } else { + + int lefttime1 = Jobs.getGCManager().PointTimeLimit; + + int hour = 0; + int min = 0; + int sec = 0; + + if (lefttime1 >= 3600) { + hour = lefttime1 / 3600; + lefttime1 = lefttime1 - (hour * 3600); + if (lefttime1 > 60 && lefttime1 < 3600) { + min = lefttime1 / 60; + sec = lefttime1 - (min * 60); + } else if (lefttime1 < 60) + sec = lefttime1; + } else if (lefttime1 > 60 && lefttime1 < 3600) { + min = lefttime1 / 60; + lefttime1 = lefttime1 - (min * 60); + } else + sec = lefttime1; + + player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.leftpointtime", + "%hour%", hour, + "%min%", min, + "%sec%", sec)); + + player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.pointlimit", + "%current%", "0.0", + "%total%", JPlayer.getPointLimit())); + } + + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/log.java b/com/gamingmesh/jobs/commands/list/log.java new file mode 100644 index 00000000..8f02f665 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/log.java @@ -0,0 +1,100 @@ +package com.gamingmesh.jobs.commands.list; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.container.Log; +import com.gamingmesh.jobs.container.LogAmounts; +import com.gamingmesh.jobs.stuff.Sorting; + +public class log implements Cmd { + + @JobCommand(1100) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + + if (!(sender instanceof Player) && args.length != 1) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); + return false; + } + + if (args.length != 1 && args.length != 0) { + Jobs.getCommandManager().sendUsage(sender, "log"); + return true; + } + JobsPlayer JPlayer = null; + if (args.length == 0) + JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); + else if (args.length == 1) { + if (!sender.hasPermission("jobs.commands.log.others")) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.permission")); + return true; + } + JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); + if (JPlayer == null) + JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(args[0]); + } + + if (JPlayer == null) { + Jobs.getCommandManager().sendUsage(sender, "log"); + return true; + } + + List logList = JPlayer.getLog(); + + if (logList.size() == 0) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.bottomline")); + sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.nodata")); + sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.bottomline")); + return true; + } + + Map unsortMap = new HashMap(); + + for (Log one : logList) { + HashMap AmountList = one.getAmountList(); + for (Entry oneMap : AmountList.entrySet()) { + unsortMap.put(oneMap.getKey(), oneMap.getValue().getMoney()); + } + } + + unsortMap = Sorting.sortDoubleDESC(unsortMap); + int count = 0; + int max = 10; + sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.topline", "%playername%", JPlayer.getUserName())); + for (Log one : logList) { + HashMap AmountList = one.getAmountList(); + for (Entry oneSorted : unsortMap.entrySet()) { + for (Entry oneMap : AmountList.entrySet()) { + if (oneMap.getKey().equalsIgnoreCase(oneSorted.getKey())) { + count++; + sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.list", + "%number%", count, + "%action%", one.getActionType(), + "%item%", oneMap.getValue().getItemName().replace(":0", "").replace("_", " ").toLowerCase(), + "%qty%", oneMap.getValue().getCount(), + "%money%", oneMap.getValue().getMoney(), + "%exp%", oneMap.getValue().getExp())); + break; + } + } + if (count > max) + break; + } + if (count > max) + break; + } + sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.bottomline")); + + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/moneyboost.java b/com/gamingmesh/jobs/commands/list/moneyboost.java new file mode 100644 index 00000000..4d161d40 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/moneyboost.java @@ -0,0 +1,80 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class moneyboost implements Cmd { + + @JobCommand(2400) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + + if (args.length > 2 || args.length <= 1) { + Jobs.getCommandManager().sendUsage(sender, "moneyboost"); + return true; + } + + double rate = 1.0; + if (!args[1].equalsIgnoreCase("all") && !args[0].equalsIgnoreCase("reset")) + try { + rate = Double.parseDouble(args[1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "moneyboost"); + return true; + } + + String PlayerName = sender.getName(); + String jobName = args[0]; + Job job = Jobs.getJob(jobName); + + if (PlayerName == null) { + Jobs.getCommandManager().sendUsage(sender, "moneyboost"); + return true; + } + + if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) { + for (Job one : Jobs.getJobs()) { + one.setMoneyBoost(1.0); + } + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.moneyboost.output.allreset")); + return true; + } else if (args[0].equalsIgnoreCase("reset")) { + boolean found = false; + for (Job one : Jobs.getJobs()) { + if (one.getName().equalsIgnoreCase(args[1])) { + one.setMoneyBoost(1.0); + found = true; + break; + } + } + + if (found) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset", "%jobname%", job.getName())); + return true; + } + } + + if (args[0].equalsIgnoreCase("all")) { + + for (Job one : Jobs.getJobs()) { + one.setMoneyBoost(rate); + } + + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate)); + return true; + } else { + if (job == null) { + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + job.setMoneyBoost(rate); + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName())); + return true; + } + } +} diff --git a/com/gamingmesh/jobs/commands/list/playerinfo.java b/com/gamingmesh/jobs/commands/list/playerinfo.java new file mode 100644 index 00000000..fd71d20c --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/playerinfo.java @@ -0,0 +1,42 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class playerinfo implements Cmd { + + @JobCommand(1300) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (args.length < 2) { + Jobs.getCommandManager().sendUsage(sender, "playerinfo"); + Jobs.getCommandManager().sendValidActions(sender); + return true; + } + + @SuppressWarnings("deprecation") + OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); + + String jobName = args[1]; + Job job = Jobs.getJob(jobName); + if (job == null) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + String type = ""; + if (args.length >= 3) { + type = args[2]; + } + sender.sendMessage(Jobs.getCommandManager().jobInfoMessage(jPlayer, job, type).split("\n")); + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/pointboost.java b/com/gamingmesh/jobs/commands/list/pointboost.java new file mode 100644 index 00000000..1da32e56 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/pointboost.java @@ -0,0 +1,80 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class pointboost implements Cmd { + + @JobCommand(2400) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + + if (args.length > 2 || args.length <= 1) { + Jobs.getCommandManager().sendUsage(sender, "pointboost"); + return true; + } + + double rate = 1.0; + if (!args[1].equalsIgnoreCase("all") && !args[0].equalsIgnoreCase("reset")) + try { + rate = Double.parseDouble(args[1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "pointboost"); + return true; + } + + String PlayerName = sender.getName(); + String jobName = args[0]; + Job job = Jobs.getJob(jobName); + + if (PlayerName == null) { + Jobs.getCommandManager().sendUsage(sender, "pointboost"); + return true; + } + + if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) { + for (Job one : Jobs.getJobs()) { + one.setPointBoost(1.0); + } + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.pointboost.output.allreset")); + return true; + } else if (args[0].equalsIgnoreCase("reset")) { + boolean found = false; + for (Job one : Jobs.getJobs()) { + if (one.getName().equalsIgnoreCase(args[1])) { + one.setPointBoost(1.0); + found = true; + break; + } + } + + if (found) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.pointboost.output.jobsboostreset", "%jobname%", job.getName())); + return true; + } + } + + if (args[0].equalsIgnoreCase("all")) { + + for (Job one : Jobs.getJobs()) { + one.setPointBoost(rate); + } + + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate)); + return true; + } else { + if (job == null) { + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + job.setPointBoost(rate); + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.pointboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName())); + return true; + } + } +} diff --git a/com/gamingmesh/jobs/commands/list/points.java b/com/gamingmesh/jobs/commands/list/points.java new file mode 100644 index 00000000..a128ccdf --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/points.java @@ -0,0 +1,53 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.container.PlayerPoints; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class points implements Cmd { + + @JobCommand(450) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + + if (args.length != 0 && args.length != 1) { + Jobs.getCommandManager().sendUsage(sender, "points"); + return true; + } + + JobsPlayer jPlayer = null; + if (args.length >= 1) { + if (!sender.hasPermission("jobs.command.admin.points")) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.permission")); + return true; + } + jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); + if (jPlayer == null) + jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(args[0]); + } else if (sender instanceof Player) { + jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); + } + + if (jPlayer == null) { + if (args.length >= 1) + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfo")); + else + Jobs.getCommandManager().sendUsage(sender, "points"); + return true; + } + + PlayerPoints pointInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(jPlayer.getPlayerUUID()); + + sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getUserName())); + sender.sendMessage(Jobs.getLanguage().getMessage("command.points.currentpoints", "%currentpoints%", (int) (pointInfo.getCurrentPoints() * 100) / 100D)); + sender.sendMessage(Jobs.getLanguage().getMessage("command.points.totalpoints", "%totalpoints%", (int) (pointInfo.getTotalPoints() * 100) / 100D)); + sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/promote.java b/com/gamingmesh/jobs/commands/list/promote.java new file mode 100644 index 00000000..9ece93e6 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/promote.java @@ -0,0 +1,54 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class promote implements Cmd { + + @JobCommand(1600) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (args.length < 3) { + Jobs.getCommandManager().sendUsage(sender, "promote"); + return true; + } + + @SuppressWarnings("deprecation") + OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); + + Job job = Jobs.getJob(args[1]); + if (job == null) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + try { + // check if player already has the job + if (jPlayer.isInJob(job)) { + Integer levelsGained = Integer.parseInt(args[2]); + Jobs.getPlayerManager().promoteJob(jPlayer, job, levelsGained); + + Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); + if (player != null) { + player.sendMessage(Jobs.getLanguage().getMessage("command.promote.output.target", + "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE, + "%levelsgained%", levelsGained)); + } + + sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); + } + } catch (Exception e) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error")); + } + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/reload.java b/com/gamingmesh/jobs/commands/list/reload.java new file mode 100644 index 00000000..2bf6b607 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/reload.java @@ -0,0 +1,28 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class reload implements Cmd { + @JobCommand(2900) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + try { + Jobs.reload(); + sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); + } catch (Exception e) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error")); + String message = org.bukkit.ChatColor.translateAlternateColorCodes('&', "&4There was an error when performing a reload: "); + ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); + console.sendMessage(message); + e.printStackTrace(); + } + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/removexp.java b/com/gamingmesh/jobs/commands/list/removexp.java new file mode 100644 index 00000000..35169ded --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/removexp.java @@ -0,0 +1,61 @@ + +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class removexp implements Cmd { + + @JobCommand(2200) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (args.length < 3) { + Jobs.getCommandManager().sendUsage(sender, "removexp"); + return true; + } + + @SuppressWarnings("deprecation") + OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); + + Job job = Jobs.getJob(args[1]); + if (job == null) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + double xpLost; + try { + xpLost = Double.parseDouble(args[2]); + } catch (Exception e) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error")); + return true; + } + if (xpLost <= 0) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error")); + return true; + } + // check if player already has the job + if (jPlayer.isInJob(job)) { + Jobs.getPlayerManager().removeExperience(jPlayer, job, xpLost); + + Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); + if (player != null) { + player.sendMessage(Jobs.getLanguage().getMessage("command.removexp.output.target", + "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE, + "%xplost%", xpLost)); + } + + sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); + } + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/shop.java b/com/gamingmesh/jobs/commands/list/shop.java new file mode 100644 index 00000000..f40803f0 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/shop.java @@ -0,0 +1,41 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; + +public class shop implements Cmd { + + @JobCommand(750) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + + if (!(sender instanceof Player)) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); + return true; + } + + if (args.length != 0) { + Jobs.getCommandManager().sendUsage(sender, "shop"); + return true; + } + + Player player = (Player) sender; + + Inventory inv = Jobs.getShopManager().CreateJobsGUI(player); + + Inventory topinv = player.getOpenInventory().getTopInventory(); + if (topinv != null) + player.closeInventory(); + + Jobs.getShopManager().GuiList.add(player.getName()); + + player.openInventory(inv); + + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/signupdate.java b/com/gamingmesh/jobs/commands/list/signupdate.java new file mode 100644 index 00000000..581cb059 --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/signupdate.java @@ -0,0 +1,34 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class signupdate implements Cmd { + + @JobCommand(2700) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (args.length != 1) { + Jobs.getCommandManager().sendUsage(sender, "signupdate"); + return true; + } + + Job oldjob = Jobs.getJob(args[0]); + + if (oldjob == null && !args[0].equalsIgnoreCase("gtoplist")) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + if (!args[0].equalsIgnoreCase("gtoplist")) + Jobs.getSignUtil().SignUpdate(oldjob.getName()); + else + Jobs.getSignUtil().SignUpdate("gtoplist"); + + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/stats.java b/com/gamingmesh/jobs/commands/list/stats.java new file mode 100644 index 00000000..ae70f82f --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/stats.java @@ -0,0 +1,52 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.JobProgression; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class stats implements Cmd { + + @JobCommand(400) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + JobsPlayer jPlayer = null; + if (args.length >= 1) { + if (!sender.hasPermission("jobs.command.admin.stats")) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.permission")); + return true; + } + jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); + if (jPlayer == null) + jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(args[0]); + } else if (sender instanceof Player) { + jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); + } + + if (jPlayer == null) { + if (args.length >= 1) + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfo")); + else + Jobs.getCommandManager().sendUsage(sender, "stats"); + return true; + } + + if (jPlayer.getJobProgression().size() == 0) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.stats.error.nojob")); + return true; + } + + sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getUserName())); + for (JobProgression jobProg : jPlayer.getJobProgression()) { + String[] msg = Jobs.getCommandManager().jobStatsMessage(jobProg).split("\n"); + sender.sendMessage(msg); + } + sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/toggle.java b/com/gamingmesh/jobs/commands/list/toggle.java new file mode 100644 index 00000000..2f3364bb --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/toggle.java @@ -0,0 +1,72 @@ + +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class toggle implements Cmd { + + @JobCommand(1000) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + + if (!(sender instanceof Player)) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); + return false; + } + + if (args.length != 1) { + Jobs.getCommandManager().sendUsage(sender, "toggle"); + return true; + } + + String PlayerName = sender.getName(); + + if (PlayerName == null || !args[0].equalsIgnoreCase("bossbar") && !args[0].equalsIgnoreCase("actionbar")) { + Jobs.getCommandManager().sendUsage(sender, "toggle"); + return true; + } + + if (args[0].equalsIgnoreCase("actionbar")) + if (Jobs.getActionbarToggleList().containsKey(PlayerName)) + if (Jobs.getActionbarToggleList().get(PlayerName)) { + Jobs.getActionbarToggleList().put(PlayerName, false); + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.toggle.output.off")); + } else { + Jobs.getActionbarToggleList().put(PlayerName, true); + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.toggle.output.on")); + } + else { + Jobs.getActionbarToggleList().put(PlayerName, true); + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.toggle.output.on")); + } + + if (args[0].equalsIgnoreCase("bossbar")) + if (Jobs.getBossBarToggleList().containsKey(PlayerName)) + if (Jobs.getBossBarToggleList().get(PlayerName)) { + Jobs.getBossBarToggleList().put(PlayerName, false); + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.toggle.output.off")); + + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(PlayerName); + + if (jPlayer != null) + jPlayer.hideBossBars(); + + } else { + Jobs.getBossBarToggleList().put(PlayerName, true); + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.toggle.output.on")); + } + else { + Jobs.getBossBarToggleList().put(PlayerName, true); + sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.toggle.output.on")); + } + + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/top.java b/com/gamingmesh/jobs/commands/list/top.java new file mode 100644 index 00000000..c0be182f --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/top.java @@ -0,0 +1,114 @@ +package com.gamingmesh.jobs.commands.list; + +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Score; +import org.bukkit.scoreboard.Scoreboard; +import org.bukkit.scoreboard.ScoreboardManager; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.TopList; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class top implements Cmd { + + @JobCommand(500) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + + if (args.length != 1 && args.length != 2) { + Jobs.getCommandManager().sendUsage(sender, "top"); + return true; + } + + if (!(sender instanceof Player)) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); + return false; + } + + Player player = (Player) sender; + + if (args[0].equalsIgnoreCase("clear")) { + player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); + return true; + } + + int start = 0; + if (args.length == 2) + try { + start = Integer.parseInt(args[1]); + } catch (NumberFormatException e) { + return true; + } + if (start < 0) + start = 0; + + List FullList = Jobs.getJobsDAO().toplist(args[0], start); + if (FullList.size() <= 0) { + player.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.top.error.nojob")); + return false; + } + + Job job = Jobs.getJob(args[0]); + String jobName = args[0]; + if (job != null) + jobName = job.getName(); + + if (!Jobs.getGCManager().ShowToplistInScoreboard) { + player.sendMessage(Jobs.getLanguage().getMessage("command.top.output.topline", "%jobname%", jobName)); + int i = start; + for (TopList One : FullList) { + i++; + String PlayerName = One.getPlayerName() != null ? One.getPlayerName() : "Unknown"; + player.sendMessage(Jobs.getLanguage().getMessage("command.top.output.list", "%number%", i, "%playername%", PlayerName, "%level%", One.getLevel(), "%exp%", + One.getExp())); + } + } else { + + player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); + + ScoreboardManager manager = Bukkit.getScoreboardManager(); + Scoreboard board = manager.getNewScoreboard(); + Objective objective = board.registerNewObjective("JobsTopPlayers", "dummy"); + objective.setDisplaySlot(DisplaySlot.SIDEBAR); + objective.setDisplayName(Jobs.getLanguage().getMessage("scoreboard.topline", "%jobname%", jobName)); + int i = start; + for (TopList One : FullList) { + i++; + String playername = One.getPlayerName() != null ? One.getPlayerName() : "Unknown"; + + Score score = objective.getScore(Jobs.getLanguage().getMessage("scoreboard.lines", "%number%", i, "%playername%", playername)); + score.setScore(One.getLevel()); + + } + player.setScoreboard(board); + + Jobs.getScboard().addNew(player); + + int from = start; + if (start >= 15) + from = start - 15; + int until = start + 15; + + String prev = "[\"\",{\"text\":\"" + Jobs.getLanguage().getMessage("command.top.output.prev") + + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs top " + + jobName + " " + from + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Jobs.getLanguage().getMessage( + "command.top.output.show", "[from]", from, "[until]", (from + 15)) + "\"}]}}}"; + String next = " {\"text\":\"" + Jobs.getLanguage().getMessage("command.top.output.next") + + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/jobs top " + + jobName + " " + until + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + Jobs.getLanguage().getMessage( + "command.top.output.show", "[from]", (until + 1), "[until]", (until + 15)) + "\"}]}}}]"; + + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + prev + "," + next); + } + return true; + } +} diff --git a/com/gamingmesh/jobs/commands/list/transfer.java b/com/gamingmesh/jobs/commands/list/transfer.java new file mode 100644 index 00000000..aa1a304f --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/transfer.java @@ -0,0 +1,59 @@ + +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class transfer implements Cmd { + + @JobCommand(1500) + public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + if (args.length < 3) { + Jobs.getCommandManager().sendUsage(sender, "transfer"); + return true; + } + + @SuppressWarnings("deprecation") + OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); + + Job oldjob = Jobs.getJob(args[1]); + Job newjob = Jobs.getJob(args[2]); + if (oldjob == null) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + if (newjob == null) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + try { + if (jPlayer.isInJob(oldjob) && !jPlayer.isInJob(newjob)) { + Jobs.getPlayerManager().transferJob(jPlayer, oldjob, newjob); + + Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); + if (player != null) { + String message = Jobs.getLanguage().getMessage("command.transfer.output.target", + "%oldjobname%", oldjob.getChatColor() + oldjob.getName() + ChatColor.WHITE, + "%newjobname%", newjob.getChatColor() + newjob.getName() + ChatColor.WHITE); + player.sendMessage(message); + } + + sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); + } + } catch (Exception e) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error")); + } + return true; + } +} diff --git a/com/gamingmesh/jobs/config/.gitignore b/com/gamingmesh/jobs/config/.gitignore index faac9c58..9a8a48f6 100644 --- a/com/gamingmesh/jobs/config/.gitignore +++ b/com/gamingmesh/jobs/config/.gitignore @@ -3,3 +3,29 @@ /JobConfig.class /JobsConfiguration.class /YmlMaker.class +/TitleSettings.class +/TitleManager.class +/RestrictedManager.class +/RestrictedBlockManager.class +/LanguageManager.class +/ScheduleUtil$1.class +/ScheduleUtil$2.class +/ScheduleUtil.class +/ScheduleManager$1.class +/ScheduleManager$2.class +/ScheduleManager.class +/TranslateName.class +/NameTranslatorManager.class +/RestrictedAreaManager.class +/JobsGeneralConfig.class +/JobsConfig.class +/GeneralConfigManager.class +/ShopManager.class +/Scboard$1.class +/Scboard.class +/ScboardManager$1.class +/ScboardManager.class +/Explore.class +/ExploreManager.class +/BossBarManager$1.class +/BossBarManager.class diff --git a/com/gamingmesh/jobs/config/BossBarManager.java b/com/gamingmesh/jobs/config/BossBarManager.java new file mode 100644 index 00000000..a1caadd6 --- /dev/null +++ b/com/gamingmesh/jobs/config/BossBarManager.java @@ -0,0 +1,130 @@ + +package com.gamingmesh.jobs.config; + +import java.text.DecimalFormat; +import java.text.NumberFormat; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.boss.BarColor; +import org.bukkit.boss.BarStyle; +import org.bukkit.boss.BossBar; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.container.BossBarInfo; +import com.gamingmesh.jobs.container.JobProgression; +import com.gamingmesh.jobs.container.JobsPlayer; + +public class BossBarManager { + + JobsPlugin plugin; + + public BossBarManager(JobsPlugin plugin) { + this.plugin = plugin; + } + + public synchronized void ShowJobProgression(final JobsPlayer player) { + if (player == null) + return; + for (String one : player.getUpdateBossBarFor()) { + for (JobProgression oneJob : player.getJobProgression()) { + if (one.equalsIgnoreCase(oneJob.getJob().getName())) + ShowJobProgression(player, oneJob); + } + } + player.getUpdateBossBarFor().clear(); + } + + public synchronized void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg) { + + String playername = player.getUserName(); + if (!Jobs.getBossBarToggleList().containsKey(playername) && Jobs.getGCManager().BossBarsMessageByDefault) + Jobs.getBossBarToggleList().put(playername, true); + + if (!Jobs.getBossBarToggleList().containsKey(playername)) + return; + + Boolean show = Jobs.getBossBarToggleList().get(playername); + + if (!show) + return; + + BossBar bar = null; + BossBarInfo OldOne = null; + for (BossBarInfo one : player.getBossBarInfo()) { + if (!one.getJobName().equalsIgnoreCase(jobProg.getJob().getName())) + continue; + + one.cancel(); + bar = one.getBar(); + OldOne = one; + break; + } + NumberFormat formatter = new DecimalFormat("#0.00"); + + String message = Jobs.getLanguage().getMessage("command.stats.output", + "%joblevel%", Integer.valueOf(jobProg.getLevel()).toString(), + "%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName() + ChatColor.WHITE, + "%jobxp%", formatter.format(Math.round((Double) jobProg.getExperience() * 100.0) / 100.0), + "%jobmaxxp%", (int) jobProg.getMaxExperience()); + + if (bar == null) { + BarColor color = BarColor.BLUE; + switch (player.getBossBarInfo().size()) { + case 1: + color = BarColor.GREEN; + break; + case 2: + color = BarColor.RED; + break; + case 3: + color = BarColor.WHITE; + break; + case 4: + color = BarColor.YELLOW; + break; + case 5: + color = BarColor.PINK; + break; + case 6: + color = BarColor.PURPLE; + break; + } + bar = Bukkit.createBossBar(message, color, BarStyle.SEGMENTED_20); + } else + bar.setTitle(message); + + double percentage = jobProg.getExperience() / jobProg.getMaxExperience(); + bar.setProgress(percentage); + if (OldOne == null) { + Player target = Bukkit.getPlayer(player.getPlayer().getUniqueId()); + if (target == null) + return; + bar.addPlayer(target); + OldOne = new BossBarInfo(player.getUserName(), jobProg.getJob().getName(), bar); + player.getBossBarInfo().add(OldOne); + } + bar.setVisible(true); + + OldOne.setId(Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + public void run() { + + for (BossBarInfo one : player.getBossBarInfo()) { + if (!one.getPlayerName().equalsIgnoreCase(player.getUserName())) + continue; + + if (!one.getJobName().equalsIgnoreCase(jobProg.getJob().getName())) + continue; + + BossBar tempBar = one.getBar(); + tempBar.setVisible(false); + break; + } + return; + } + }, Jobs.getGCManager().BossBarTimer * 20L)); + + } +} diff --git a/com/gamingmesh/jobs/config/ConfigManager.java b/com/gamingmesh/jobs/config/ConfigManager.java index 7f2a33e3..8192d238 100644 --- a/com/gamingmesh/jobs/config/ConfigManager.java +++ b/com/gamingmesh/jobs/config/ConfigManager.java @@ -18,23 +18,582 @@ package com.gamingmesh.jobs.config; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.apache.commons.lang.StringEscapeUtils; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.container.ActionType; +import com.gamingmesh.jobs.container.DisplayMethod; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobCommands; +import com.gamingmesh.jobs.container.JobConditions; +import com.gamingmesh.jobs.container.JobInfo; +import com.gamingmesh.jobs.container.JobItems; +import com.gamingmesh.jobs.container.JobLimitedItems; +import com.gamingmesh.jobs.container.JobPermission; +import com.gamingmesh.jobs.resources.jfep.Parser; +import com.gamingmesh.jobs.stuff.ChatColor; + public class ConfigManager { - private static JobsConfiguration config; - private static JobConfig jobConfig; - - public static JobsConfiguration getJobsConfiguration() { - return config; + private JobsPlugin plugin; + + public ConfigManager(JobsPlugin plugin) { + this.plugin = plugin; } - - public static void registerJobsConfiguration(JobsConfiguration c) { - config = c; + + public void reload() throws IOException { + // job settings + loadJobSettings(); } - - public static JobConfig getJobConfig() { - return jobConfig; - } - - public static void registerJobConfig(JobConfig c) { - jobConfig = c; + + /** + * Method to load the jobs configuration + * + * loads from Jobs/jobConfig.yml + * @throws IOException + */ + @SuppressWarnings("deprecation") + private void loadJobSettings() throws IOException { + File f = new File(plugin.getDataFolder(), "jobConfig.yml"); + InputStreamReader s = new InputStreamReader(new FileInputStream(f), "UTF-8"); + + ArrayList jobs = new ArrayList(); + Jobs.setJobs(jobs); + Jobs.setNoneJob(null); + if (!f.exists()) { + try { + f.createNewFile(); + } catch (IOException e) { + Jobs.getPluginLogger().severe("Unable to create jobConfig.yml! No jobs were loaded!"); + s.close(); + return; + } + } + YamlConfiguration conf = new YamlConfiguration(); + conf.options().pathSeparator('/'); + try { + conf.load(s); + s.close(); + } catch (Exception e) { + Bukkit.getServer().getLogger().severe("==================== Jobs ===================="); + Bukkit.getServer().getLogger().severe("Unable to load jobConfig.yml!"); + Bukkit.getServer().getLogger().severe("Check your config for formatting issues!"); + Bukkit.getServer().getLogger().severe("No jobs were loaded!"); + Bukkit.getServer().getLogger().severe("Error: " + e.getMessage()); + Bukkit.getServer().getLogger().severe("=============================================="); + return; + } + //conf.options().header(new StringBuilder().append("Jobs configuration.").append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("Stores information about each job.").append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("For example configurations, visit http://dev.bukkit.org/bukkit-plugins/jobs-reborn/.").append(System.getProperty("line.separator")).toString()); + + ConfigurationSection jobsSection = conf.getConfigurationSection("Jobs"); + //if (jobsSection == null) { + // jobsSection = conf.createSection("Jobs"); + //} + for (String jobKey : jobsSection.getKeys(false)) { + + // Ignoring example job + if (jobKey.equalsIgnoreCase("exampleJob")) + continue; + + ConfigurationSection jobSection = jobsSection.getConfigurationSection(jobKey); + String jobName = jobSection.getString("fullname"); + + // Translating unicode + jobName = StringEscapeUtils.unescapeJava(jobName); + + if (jobName == null) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid fullname property. Skipping job!"); + continue; + } + + int maxLevel = jobSection.getInt("max-level", 0); + if (maxLevel < 0) + maxLevel = 0; + + int vipmaxLevel = jobSection.getInt("vip-max-level", 0); + if (vipmaxLevel < 0) + vipmaxLevel = 0; + + Integer maxSlots = jobSection.getInt("slots", 0); + if (maxSlots.intValue() <= 0) { + maxSlots = null; + } + + String jobShortName = jobSection.getString("shortname"); + if (jobShortName == null) { + Jobs.getPluginLogger().warning("Job " + jobKey + " is missing the shortname property. Skipping job!"); + continue; + } + + String description = org.bukkit.ChatColor.translateAlternateColorCodes('&', jobSection.getString("description", "")); + + ChatColor color = ChatColor.WHITE; + if (jobSection.contains("ChatColour")) { + color = ChatColor.matchColor(jobSection.getString("ChatColour", "")); + if (color == null) { + color = ChatColor.WHITE; + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid ChatColour property. Defaulting to WHITE!"); + } + } + DisplayMethod displayMethod = DisplayMethod.matchMethod(jobSection.getString("chat-display", "")); + if (displayMethod == null) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid chat-display property. Defaulting to None!"); + displayMethod = DisplayMethod.NONE; + } + + Parser maxExpEquation; + String maxExpEquationInput = jobSection.getString("leveling-progression-equation"); + try { + maxExpEquation = new Parser(maxExpEquationInput); + // test equation + maxExpEquation.setVariable("numjobs", 1); + maxExpEquation.setVariable("joblevel", 1); + maxExpEquation.getValue(); + } catch (Exception e) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid leveling-progression-equation property. Skipping job!"); + continue; + } + + Parser incomeEquation = new Parser("0"); + if (jobSection.isString("income-progression-equation")) { + String incomeEquationInput = jobSection.getString("income-progression-equation"); + try { + incomeEquation = new Parser(incomeEquationInput); + // test equation + incomeEquation.setVariable("numjobs", 1); + incomeEquation.setVariable("joblevel", 1); + incomeEquation.setVariable("baseincome", 1); + incomeEquation.getValue(); + } catch (Exception e) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid income-progression-equation property. Skipping job!"); + continue; + } + } + + Parser expEquation; + String expEquationInput = jobSection.getString("experience-progression-equation"); + try { + expEquation = new Parser(expEquationInput); + // test equation + expEquation.setVariable("numjobs", 1); + expEquation.setVariable("joblevel", 1); + expEquation.setVariable("baseexperience", 1); + expEquation.getValue(); + } catch (Exception e) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid experience-progression-equation property. Skipping job!"); + continue; + } + + Parser pointsEquation = new Parser("0"); + if (jobSection.isString("points-progression-equation")) { + String pointsEquationInput = jobSection.getString("points-progression-equation"); + try { + pointsEquation = new Parser(pointsEquationInput); + // test equation + pointsEquation.setVariable("numjobs", 1); + pointsEquation.setVariable("joblevel", 1); + pointsEquation.setVariable("basepoints", 1); + pointsEquation.getValue(); + } catch (Exception e) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid points-progression-equation property. Skipping job!"); + continue; + } + } + + // Gui item + ItemStack GUIitem = new ItemStack(Material.getMaterial(35), 1, (byte) 13); + if (jobSection.contains("Gui")) { + ConfigurationSection guiSection = jobSection.getConfigurationSection("Gui"); + if (guiSection.contains("Id") && guiSection.contains("Data") && guiSection.isInt("Id") && guiSection.isInt("Data")) { + GUIitem = new ItemStack(Material.getMaterial(guiSection.getInt("Id")), 1, (byte) guiSection.getInt("Data")); + } else + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid Gui property. Please fix this if you want to use it!"); + } + + // Permissions + ArrayList jobPermissions = new ArrayList(); + ConfigurationSection permissionsSection = jobSection.getConfigurationSection("permissions"); + if (permissionsSection != null) { + for (String permissionKey : permissionsSection.getKeys(false)) { + ConfigurationSection permissionSection = permissionsSection.getConfigurationSection(permissionKey); + + String node = permissionKey.toLowerCase(); + if (permissionSection == null) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid permission key" + permissionKey + "!"); + continue; + } + boolean value = permissionSection.getBoolean("value", true); + int levelRequirement = permissionSection.getInt("level", 0); + jobPermissions.add(new JobPermission(node, value, levelRequirement)); + } + } + + // Conditions + ArrayList jobConditions = new ArrayList(); + ConfigurationSection conditionsSection = jobSection.getConfigurationSection("conditions"); + if (conditionsSection != null) { + for (String ConditionKey : conditionsSection.getKeys(false)) { + ConfigurationSection permissionSection = conditionsSection.getConfigurationSection(ConditionKey); + + String node = ConditionKey.toLowerCase(); + if (permissionSection == null) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid condition key " + ConditionKey + "!"); + continue; + } + if (!permissionSection.contains("requires") || !permissionSection.contains("perform")) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid condition requirement " + ConditionKey + "!"); + continue; + } + List requires = permissionSection.getStringList("requires"); + List perform = permissionSection.getStringList("perform"); + + jobConditions.add(new JobConditions(node, requires, perform)); + } + } + + // Command on leave + List JobsCommandOnLeave = new ArrayList(); + if (jobSection.isList("cmd-on-leave")) { + JobsCommandOnLeave = jobSection.getStringList("cmd-on-leave"); + } + + // Command on join + List JobsCommandOnJoin = new ArrayList(); + if (jobSection.isList("cmd-on-join")) { + JobsCommandOnJoin = jobSection.getStringList("cmd-on-join"); + } + + // Commands + ArrayList jobCommand = new ArrayList(); + ConfigurationSection commandsSection = jobSection.getConfigurationSection("commands"); + if (commandsSection != null) { + for (String commandKey : commandsSection.getKeys(false)) { + ConfigurationSection commandSection = commandsSection.getConfigurationSection(commandKey); + + String node = commandKey.toLowerCase(); + if (commandSection == null) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid command key" + commandKey + "!"); + continue; + } + String command = commandSection.getString("command"); + int levelFrom = commandSection.getInt("levelFrom"); + int levelUntil = commandSection.getInt("levelUntil"); + jobCommand.add(new JobCommands(node, command, levelFrom, levelUntil)); + } + } + + // Items + ArrayList jobItems = new ArrayList(); + ConfigurationSection itemsSection = jobSection.getConfigurationSection("items"); + if (itemsSection != null) { + for (String itemKey : itemsSection.getKeys(false)) { + ConfigurationSection itemSection = itemsSection.getConfigurationSection(itemKey); + + String node = itemKey.toLowerCase(); + if (itemSection == null) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid item key " + itemKey + "!"); + continue; + } + int id = itemSection.getInt("id"); + + String name = null; + if (itemSection.isString("name")) + name = itemSection.getString("name"); + + List lore = new ArrayList(); + if (itemSection.getStringList("lore") != null) + for (String eachLine : itemSection.getStringList("lore")) { + lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine)); + } + + HashMap enchants = new HashMap(); + if (itemSection.getStringList("enchants") != null) + for (String eachLine : itemSection.getStringList("enchants")) { + + if (!eachLine.contains("=")) + continue; + + Enchantment ench = Enchantment.getByName(eachLine.split("=")[0]); + Integer level = -1; + try { + level = Integer.parseInt(eachLine.split("=")[1]); + } catch (NumberFormatException e) { + continue; + } + + if (ench != null && level != -1) + enchants.put(ench, level); + } + + Double moneyBoost = 1D; + if (itemSection.isDouble("moneyBoost")) + moneyBoost = itemSection.getDouble("moneyBoost"); + + Double pointBoost = 1D; + if (itemSection.isDouble("pointBoost")) + pointBoost = itemSection.getDouble("pointBoost"); + + Double expBoost = 1D; + if (itemSection.isDouble("expBoost")) + expBoost = itemSection.getDouble("expBoost"); + + jobItems.add(new JobItems(node, id, 0, 1, name, lore, enchants, moneyBoost, pointBoost, expBoost)); + } + } + + // Limited Items + ArrayList jobLimitedItems = new ArrayList(); + ConfigurationSection LimitedItemsSection = jobSection.getConfigurationSection("limitedItems"); + if (LimitedItemsSection != null) { + for (String itemKey : LimitedItemsSection.getKeys(false)) { + ConfigurationSection itemSection = LimitedItemsSection.getConfigurationSection(itemKey); + + String node = itemKey.toLowerCase(); + if (itemSection == null) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid item key " + itemKey + "!"); + continue; + } + int id = itemSection.getInt("id"); + + String name = null; + if (itemSection.isString("name")) + name = itemSection.getString("name"); + + List lore = new ArrayList(); + if (itemSection.getStringList("lore") != null) + for (String eachLine : itemSection.getStringList("lore")) { + lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine)); + } + + HashMap enchants = new HashMap(); + if (itemSection.getStringList("enchants") != null) + for (String eachLine : itemSection.getStringList("enchants")) { + + if (!eachLine.contains("=")) + continue; + + Enchantment ench = Enchantment.getByName(eachLine.split("=")[0]); + Integer level = -1; + try { + level = Integer.parseInt(eachLine.split("=")[1]); + } catch (NumberFormatException e) { + continue; + } + + if (ench != null && level != -1) + enchants.put(ench, level); + } + + int level = itemSection.getInt("level"); + + jobLimitedItems.add(new JobLimitedItems(node, id, name, lore, enchants, level)); + } + } + + Job job = new Job(jobName, jobShortName, description, color, maxExpEquation, displayMethod, maxLevel, vipmaxLevel, maxSlots, jobPermissions, jobCommand, + jobConditions, jobItems, jobLimitedItems, JobsCommandOnJoin, JobsCommandOnLeave, GUIitem); + + for (ActionType actionType : ActionType.values()) { + ConfigurationSection typeSection = jobSection.getConfigurationSection(actionType.getName()); + ArrayList jobInfo = new ArrayList(); + if (typeSection != null) { + for (String key : typeSection.getKeys(false)) { + ConfigurationSection section = typeSection.getConfigurationSection(key); + String myKey = key; + String type = null; + String subType = ""; + String meta = ""; + int id = 0; + + if (myKey.contains("-")) { + // uses subType + subType = ":" + myKey.split("-")[1]; + meta = myKey.split("-")[1]; + myKey = myKey.split("-")[0]; + } + + Material material = Material.matchMaterial(myKey); + + if (material == null) + material = Material.getMaterial(myKey.replace(" ", "_").toUpperCase()); + + if (material == null) { + // try integer method + Integer matId = null; + try { + matId = Integer.valueOf(myKey); + } catch (NumberFormatException e) { + } + if (matId != null) { + material = Material.getMaterial(matId); + if (material != null) { + Jobs.getPluginLogger().warning("Job " + jobKey + " " + actionType.getName() + " is using ID: " + key + "!"); + Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!"); + } + } + } + + if (actionType == ActionType.EXPLORE) + material = null; + + if (material != null) { + // Break and Place actions MUST be blocks + if (actionType == ActionType.BREAK || actionType == ActionType.PLACE) { + if (!material.isBlock()) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key + + "! Material must be a block!"); + continue; + } + } + // START HACK + /* + * Historically, GLOWING_REDSTONE_ORE would ONLY work as REDSTONE_ORE, and putting + * GLOWING_REDSTONE_ORE in the configuration would not work. Unfortunately, this is + * completely backwards and wrong. + * + * To maintain backwards compatibility, all instances of REDSTONE_ORE should normalize + * to GLOWING_REDSTONE_ORE, and warn the user to change their configuration. In the + * future this hack may be removed and anybody using REDSTONE_ORE will have their + * configurations broken. + */ + if (material == Material.REDSTONE_ORE && actionType == ActionType.BREAK) { + Jobs.getPluginLogger().warning("Job " + jobKey + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE."); + Jobs.getPluginLogger().warning("Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration."); + Jobs.getPluginLogger().warning("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with."); + Jobs.getPluginLogger().warning("In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly."); + material = Material.GLOWING_REDSTONE_ORE; + } + // END HACK + + type = material.toString(); + id = material.getId(); + } else if (actionType == ActionType.KILL || actionType == ActionType.TAME || actionType == ActionType.BREED || actionType == ActionType.MILK) { + // check entities + EntityType entity = EntityType.fromName(key); + if (entity == null) { + try { + entity = EntityType.valueOf(key.toUpperCase()); + } catch (IllegalArgumentException e) { + } + } + + if (entity != null && entity.isAlive()) { + type = entity.toString(); + id = entity.getTypeId(); + + // using breeder finder + if (actionType == ActionType.BREED) + Jobs.getGCManager().setBreederFinder(true); + } + + // Just to recognize wither skeleton + if (key.equalsIgnoreCase("WitherSkeleton")) { + type = "WitherSkeleton"; + id = 51; + meta = "1"; + } + + // Just to recognize Zombie Villager + if (key.equalsIgnoreCase("ZombieVillager")) { + type = "ZombieVillager"; + id = 54; + meta = "1"; + } + + // Just to recognize Elder Guardian + if (key.equalsIgnoreCase("ElderGuardian")) { + type = "ElderGuardian"; + id = 68; + meta = "1"; + } + + } else if (actionType == ActionType.ENCHANT && material == null) { + Enchantment enchant = Enchantment.getByName(myKey); + if (enchant != null) + id = enchant.getId(); + type = myKey; + } else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL) { + type = myKey; + } else if (actionType == ActionType.EXPLORE) { + type = myKey; + int amount = 10; + try { + amount = Integer.valueOf(myKey); + } catch (NumberFormatException e) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key + "!"); + continue; + } + Jobs.getExplore().setExploreEnabled(); + Jobs.getExplore().setPlayerAmount(amount + 1); + } + + if (type == null) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key + "!"); + continue; + } + + if (actionType == ActionType.TNTBREAK) + Jobs.getGCManager().setTntFinder(true); + + double income = section.getDouble("income", 0.0); + if (income == 0) + incomeEquation = new Parser("0"); + + double points = section.getDouble("points", 0.0); + if (points == 0) + pointsEquation = new Parser("0"); + + double experience = section.getDouble("experience", 0.0); + + int fromlevel = 1; + + if (section.isInt("from-level")) + fromlevel = section.getInt("from-level"); + + int untilLevel = -1; + if (section.isInt("until-level")) { + untilLevel = section.getInt("until-level"); + if (untilLevel < fromlevel) { + Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid until-level in " + actionType.getName() + " for type property: " + key + + "! It will be not set."); + untilLevel = -1; + } + } + + jobInfo.add(new JobInfo(actionType, id, meta, type + subType, income, incomeEquation, experience, expEquation, pointsEquation, points, fromlevel, + untilLevel)); + } + } + job.setJobInfo(actionType, jobInfo); + } + + if (jobKey.equalsIgnoreCase("none")) { + Jobs.setNoneJob(job); + } else { + jobs.add(job); + } + } + + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + Jobs.getJobs().size() + " jobs!"); + //try { + // conf.save(f); + //} catch (IOException e) { + // e.printStackTrace(); + //} } } diff --git a/com/gamingmesh/jobs/stuff/Explore.java b/com/gamingmesh/jobs/config/ExploreManager.java similarity index 95% rename from com/gamingmesh/jobs/stuff/Explore.java rename to com/gamingmesh/jobs/config/ExploreManager.java index 8c3ad5ff..67ee0aba 100644 --- a/com/gamingmesh/jobs/stuff/Explore.java +++ b/com/gamingmesh/jobs/config/ExploreManager.java @@ -1,4 +1,4 @@ -package com.gamingmesh.jobs.stuff; +package com.gamingmesh.jobs.config; import java.util.HashMap; import org.bukkit.Chunk; @@ -9,13 +9,13 @@ import com.gamingmesh.jobs.container.ExploreChunk; import com.gamingmesh.jobs.container.ExploreRegion; import com.gamingmesh.jobs.container.ExploreRespond; -public class Explore { +public class ExploreManager { private HashMap worlds = new HashMap(); private boolean exploreEnabled = false; private int playerAmount = 1; - public Explore() { + public ExploreManager() { } public int getPlayerAmount() { diff --git a/com/gamingmesh/jobs/config/GeneralConfigManager.java b/com/gamingmesh/jobs/config/GeneralConfigManager.java new file mode 100644 index 00000000..2c7e5723 --- /dev/null +++ b/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -0,0 +1,833 @@ +/** + * Jobs Plugin for Bukkit + * Copyright (C) 2011 Zak Ford + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.gamingmesh.jobs.config; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.resources.jfep.Parser; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.container.LocaleReader; +import com.gamingmesh.jobs.container.Schedule; +import com.gamingmesh.jobs.dao.JobsDAOMySQL; +import com.gamingmesh.jobs.dao.JobsDAOSQLite; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class GeneralConfigManager { + private JobsPlugin plugin; + public List BroadcastingLevelUpLevels = new ArrayList(); + protected Locale locale; + protected int savePeriod; + protected boolean economyAsync; + protected boolean isBroadcastingSkillups; + protected boolean isBroadcastingLevelups; + protected boolean payInCreative; + protected boolean payExploringWhenFlying; + protected boolean addXpPlayer; + protected boolean hideJobsWithoutPermission; + protected int maxJobs; + protected boolean payNearSpawner; + protected boolean modifyChat; + public String modifyChatPrefix; + public String modifyChatSuffix; + public String modifyChatSeparator; + protected int economyBatchDelay; + protected boolean saveOnDisconnect; + public boolean LocalOfflinePlayersData; + public boolean MythicMobsEnabled; + public boolean LoggingUse; + + // Money limit + public boolean MoneyLimitUse; + public boolean MoneyStopPoint; + public boolean MoneyStopExp; + public int MoneyTimeLimit; + public int MoneyAnnouncmentDelay; + + // Point limit + public boolean PointLimitUse; + public boolean PointStopExp; + public boolean PointStopMoney; + public int PointTimeLimit; + public int PointAnnouncmentDelay; + + // Exp limit + public boolean ExpLimitUse; + public boolean ExpStopPoint; + public boolean ExpStopMoney; + public int ExpTimeLimit; + public int ExpAnnouncmentDelay; + + public boolean PayForRenaming, PayForEachCraft, SignsEnabled, + SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse, + EnableAnounceMessage, useBlockPiston, useSilkTouchProtection, UseCustomNames, + UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit, WaterBlockBreake; + public int globalblocktimer, CowMilkingTimer, + CoreProtectInterval, BlockPlaceInterval, InfoUpdateInterval; + public Double payNearSpawnerMultiplier, VIPpayNearSpawnerMultiplier, TreeFellerMultiplier, gigaDrillMultiplier, superBreakerMultiplier, PetPay, VipPetPay; + public String localeString = "EN"; + public boolean useBlockProtection; + public boolean useBlockTimer; + public boolean useMinimumOveralPayment; + public boolean useMinimumOveralPoints; + public boolean useBreederFinder = false; + private boolean useTnTFinder = false; + public boolean CancelCowMilking; + public boolean fixAtMaxLevel, ToggleActionBar, TitleChangeChat, TitleChangeActionBar, LevelChangeChat, + LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAcountChat, + EmptyServerAcountActionBar, ActionBarsMessageByDefault, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment, + useGlobalBoostScheduler, JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, JobsGUIOpenOnJoin; + public Integer levelLossPercentage, SoundLevelupVolume, SoundLevelupPitch, SoundTitleChangeVolume, + SoundTitleChangePitch, ToplistInScoreboardInterval; + public double BoostExp; + public double MinimumOveralPaymentLimit; + public double MinimumOveralPointsLimit; + public double BoostMoney; + public double BoostPoints; + public double DynamicPaymentMaxPenalty; + public double DynamicPaymentMaxBonus; + public double TaxesAmount; + public String SoundLevelupSound, SoundTitleChangeSound, ServerAcountName, ServertaxesAcountName; + public ArrayList keys; + public String storageMethod; + public boolean hideJobsInfoWithoutPermission; + public boolean UseTaxes; + public boolean TransferToServerAccount; + public boolean TakeFromPlayersPayment; + + //BossBar + public boolean BossBarEnabled; + public boolean BossBarShowOnEachAction; + public int BossBarTimer; + public boolean BossBarsMessageByDefault; + + public Parser DynamicPaymentEquation; + public Parser maxMoneyEquation; + public Parser maxExpEquation; + public Parser maxPointEquation; + + public boolean DisabledWorldsUse; + public List DisabledWorldsList = new ArrayList(); + + public List BoostSchedule = new ArrayList(); + + public HashMap> commandArgs = new HashMap>(); + + public HashMap> getCommandArgs() { + return commandArgs; + } + + public GeneralConfigManager(JobsPlugin plugin) { + this.plugin = plugin; + } + + public void setBreederFinder(boolean state) { + this.useBreederFinder = state; + } + + public boolean isUseBreederFinder() { + return this.useBreederFinder; + } + + public void setTntFinder(boolean state) { + this.useTnTFinder = state; + } + + public boolean isUseTntFinder() { + return this.useTnTFinder; + } + + /** + * Get how often in minutes to save job information + * @return how often in minutes to save job information + */ + public synchronized int getSavePeriod() { + return savePeriod; + } + + /** + * Should we use asynchronous economy calls + * @return true - use async + * @return false - use sync + */ + public synchronized boolean isEconomyAsync() { + return economyAsync; + } + + /** + * Function that tells if the system is set to broadcast on skill up + * @return true - broadcast on skill up + * @return false - do not broadcast on skill up + */ + public synchronized boolean isBroadcastingSkillups() { + return isBroadcastingSkillups; + } + + /** + * Function that tells if the system is set to broadcast on level up + * @return true - broadcast on level up + * @return false - do not broadcast on level up + */ + public synchronized boolean isBroadcastingLevelups() { + return isBroadcastingLevelups; + } + + /** + * Function that tells if the player should be paid while in creative + * @return true - pay in creative + * @return false - do not pay in creative + */ + public synchronized boolean payInCreative() { + return payInCreative; + } + + /** + * Function that tells if the player should be paid while exploring and flying + * @return true - pay + * @return false - do not + */ + public synchronized boolean payExploringWhenFlying() { + return payExploringWhenFlying; + } + + public synchronized boolean addXpPlayer() { + return addXpPlayer; + } + + /** + * Function to check if jobs should be hidden to players that lack permission to join the job + * @return + */ + public synchronized boolean getHideJobsWithoutPermission() { + return hideJobsWithoutPermission; + } + + /** + * Function to return the maximum number of jobs a player can join + * @return + */ + public synchronized int getMaxJobs() { + return maxJobs; + } + + /** + * Function to check if you get paid near a spawner is enabled + * @return true - you get paid + * @return false - you don't get paid + */ + public synchronized boolean payNearSpawner() { + return payNearSpawner; + } + + public synchronized boolean getModifyChat() { + return modifyChat; + } + + public String getModifyChatPrefix() { + return modifyChatPrefix; + } + + public String getModifyChatSuffix() { + return modifyChatSuffix; + } + + public String getModifyChatSeparator() { + return modifyChatSeparator; + } + + public synchronized int getEconomyBatchDelay() { + return economyBatchDelay; + } + + public synchronized boolean saveOnDisconnect() { + return saveOnDisconnect; + } + + public synchronized Locale getLocale() { + return locale; + } + + public boolean canPerformActionInWorld(Player player) { + if (player == null) + return true; + return canPerformActionInWorld(player.getWorld()); + } + + public boolean canPerformActionInWorld(World world) { + if (world == null) + return true; + if (!this.DisabledWorldsUse) + return true; + return canPerformActionInWorld(world.getName()); + } + + public boolean canPerformActionInWorld(String world) { + if (world == null) + return true; + if (!this.DisabledWorldsUse) + return true; + if (this.DisabledWorldsList.isEmpty()) + return true; + if (this.DisabledWorldsList.contains(world)) + return false; + return true; + } + + public synchronized void reload() { + // general settings + loadGeneralSettings(); + // Load locale + Jobs.setLanguageManager(plugin); + Jobs.getLanguageManager().load(); + // title settings + Jobs.setTitleManager(plugin); + Jobs.gettitleManager().load(); + // restricted areas + Jobs.setRestrictedAreaManager(plugin); + Jobs.getRestrictedAreaManager().load(); + // restricted blocks + Jobs.setRestrictedBlockManager(plugin); + Jobs.getRestrictedBlockManager().load(); + // Item/Block/mobs name list + Jobs.setNameTranslatorManager(plugin); + Jobs.getNameTranslatorManager().load(); + // signs information + Jobs.setSignUtil(plugin); + Jobs.getSignUtil().LoadSigns(); + // Schedule + Jobs.setScheduleManager(plugin); + Jobs.getScheduleManager().load(); + // Shop + Jobs.setShopManager(plugin); + Jobs.getShopManager().load(); + } + + /** + * Method to load the general configuration + * + * loads from Jobs/generalConfig.yml + */ + private synchronized void loadGeneralSettings() { + File f = new File(plugin.getDataFolder(), "generalConfig.yml"); + YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); + CommentedYamlConfiguration write = new CommentedYamlConfiguration(); + LocaleReader c = new LocaleReader(conf, write); + + StringBuilder header = new StringBuilder(); + header.append("General configuration."); + header.append(System.getProperty("line.separator")); + header.append(" The general configuration for the jobs plugin mostly includes how often the plugin"); + header.append(System.getProperty("line.separator")); + header.append("saves user data (when the user is in the game), the storage method, whether"); + header.append(System.getProperty("line.separator")); + header.append("to broadcast a message to the server when a user goes up a skill level."); + header.append(System.getProperty("line.separator")); + header.append(" It also allows admins to set the maximum number of jobs a player can have at"); + header.append(System.getProperty("line.separator")); + header.append("any one time."); + header.append(System.getProperty("line.separator")); + + c.getC().options().copyDefaults(true); + + c.getW().options().header(header.toString()); + + c.getW().addComment("locale-language", "Default language.", "Example: en, ru", "File in locale folder with same name should exist. Example: messages_ru.yml"); + localeString = c.get("locale-language", "en"); + try { + int i = localeString.indexOf('_'); + if (i == -1) { + locale = new Locale(localeString); + } else { + locale = new Locale(localeString.substring(0, i), localeString.substring(i + 1)); + } + } catch (IllegalArgumentException e) { + locale = Locale.getDefault(); + Jobs.getPluginLogger().warning("Invalid locale \"" + localeString + "\" defaulting to " + locale.getLanguage()); + } + + c.getW().addComment("storage-method", "storage method, can be MySQL, sqlite"); + storageMethod = c.get("storage-method", "sqlite"); + if (storageMethod.equalsIgnoreCase("mysql")) { + startMysql(); + } else if (storageMethod.equalsIgnoreCase("sqlite")) { + startSqlite(); + } else { + Jobs.getPluginLogger().warning("Invalid storage method! Changing method to sqlite!"); + c.getC().set("storage-method", "sqlite"); + Jobs.setDAO(JobsDAOSQLite.initialize()); + } + + c.getW().addComment("mysql-username", "Requires Mysql."); + c.get("mysql-username", "root"); + c.get("mysql-password", ""); + c.get("mysql-hostname", "localhost:3306"); + c.get("mysql-database", "minecraft"); + c.get("mysql-table-prefix", "jobs_"); + + c.getW().addComment("save-period", "How often in minutes you want it to save. This must be a non-zero number"); + c.get("save-period", 10); + if (c.getC().getInt("save-period") <= 0) { + Jobs.getPluginLogger().severe("Save period must be greater than 0! Defaulting to 10 minutes!"); + c.getC().set("save-period", 10); + } + savePeriod = c.getC().getInt("save-period"); + + c.getW().addComment("save-on-disconnect", "Should player data be saved on disconnect?", + "Player data is always periodically auto-saved and autosaved during a clean shutdown.", + "Only enable this if you have a multi-server setup, or have a really good reason for enabling this.", "Turning this on will decrease database performance."); + saveOnDisconnect = c.get("save-on-disconnect", false); + + c.getW().addComment("Optimizations.UseLocalOfflinePlayersData", "With this set to true, offline player data will be taken from local player data files", + "This will eliminate small lag spikes when request is being send to mojangs servers for offline players data", + "Theroticali this should work without issues, but if you havving some, just disable", + "But then you can feal some small (100-200ms) lag spikes while performings some jobs commands"); + LocalOfflinePlayersData = c.get("Optimizations.UseLocalOfflinePlayersData", true); + + c.getW().addComment("Optimizations.DisabledWorlds.Use", "By setting this to true, Jobs plugin will be disabled in given worlds", + "Only commands can be performed from disabled worlds with jobs.disabledworld.commands permission node"); + DisabledWorldsUse = c.get("Optimizations.DisabledWorlds.Use", false); + DisabledWorldsList = c.getStringList("Optimizations.DisabledWorlds.List", Arrays.asList(Bukkit.getWorlds().get(0).getName())); + + c.getW().addComment("Logging.Use", "With this set to true all players jobs actions will be logged to database for easy to see statistics", + "This is still in development and in feature it will expand"); + LoggingUse = c.get("Logging.Use", false); + + c.getW().addComment("broadcast.on-skill-up.use", "Do all players get a message when somone goes up a skill level?"); + isBroadcastingSkillups = c.get("broadcast.on-skill-up.use", false); + + c.getW().addComment("broadcast.on-level-up.use", "Do all players get a message when somone goes up a level?"); + isBroadcastingLevelups = c.get("broadcast.on-level-up.use", false); + c.getW().addComment("broadcast.on-level-up.levels", "For what levels you want to broadcast message? Keep it at 0 if you want for all of them"); + BroadcastingLevelUpLevels = c.getIntList("broadcast.on-level-up.levels", Arrays.asList(0)); + + c.getW().addComment("max-jobs", "Maximum number of jobs a player can join.", "Use 0 for no maximum"); + maxJobs = c.get("max-jobs", 3); + + c.getW().addComment("hide-jobs-without-permission", "Hide jobs from player if they lack the permission to join the job"); + hideJobsWithoutPermission = c.get("hide-jobs-without-permission", false); + + c.getW().addComment("hide-jobsinfo-without-permission", "Hide jobs info from player if they lack the permission to join the job"); + hideJobsInfoWithoutPermission = c.get("hide-jobsinfo-without-permission", false); + + c.getW().addComment("enable-pay-near-spawner", "Option to allow payment to be made when killing mobs from a spawner"); + payNearSpawner = c.get("enable-pay-near-spawner", false); + + c.getW().addComment("pay-near-spawner-multiplier", "enable-pay-near-spawner should be enabled for this to work", + "0.5 means that players will get only 50% exp/money from monsters spawned from spawner"); + payNearSpawnerMultiplier = c.get("pay-near-spawner-multiplier", 1.0); + + c.getW().addComment("VIP-pay-near-spawner-multiplier", "VIP multiplier to pay for monsters from spawners, this will ignore global multiplier", + "Use jobs.vipspawner permission node for this to be enabled"); + VIPpayNearSpawnerMultiplier = c.get("VIP-pay-near-spawner-multiplier", 1.0); + + c.getW().addComment("enable-pay-creative", "Option to allow payment to be made in creative mode"); + payInCreative = c.get("enable-pay-creative", false); + + c.getW().addComment("enable-pay-for-exploring-when-flying", "Option to allow payment to be made for exploring when player flyies"); + payExploringWhenFlying = c.get("enable-pay-for-exploring-when-flying", false); + + c.getW().addComment("add-xp-player", "Adds the Jobs xp recieved to the player's Minecraft XP bar"); + addXpPlayer = c.get("add-xp-player", false); + + c.getW().addComment("modify-chat", + "Modifys chat to add chat titles. If you're using a chat manager, you may add the tag {jobs} to your chat format and disable this."); + modifyChat = c.get("modify-chat", true); + + modifyChatPrefix = c.get("modify-chat-prefix", "&c[", true); + modifyChatSuffix = c.get("modify-chat-suffix", "&c]", true); + modifyChatSeparator = c.get("modify-chat-separator", " ", true); + + c.getW().addComment("UseCustomNames", "Do you want to use custom item/block/mob/enchant/color names", + "With this set to true names like Stone:1 will be translated to Granite", "Name list is in TranslatableWords.yml file"); + UseCustomNames = c.get("UseCustomNames", true); + + c.getW().addComment("economy-batch-delay", "Changes how often, in seconds, players are paid out. Default is 5 seconds.", + "Setting this too low may cause tick lag. Increase this to improve economy performance (at the cost of delays in payment)"); + economyBatchDelay = c.get("economy-batch-delay", 5); + + c.getW().addComment("economy-async", "Enable async economy calls.", "Disable this if you have issues with payments or your plugin is not thread safe."); + economyAsync = c.get("economy-async", true); + + c.getW().addComment("Economy.MinimumOveralPayment.use", + "Determines minimum payment. In example if player uses McMMO treefeller and earns only 20%, but at same time he gets 25% penalty from dynamic payment. He can 'get' negative amount of money", + "This will limit it to particular percentage", "Works only when original payment is above 0"); + useMinimumOveralPayment = c.get("Economy.MinimumOveralPayment.use", true); + MinimumOveralPaymentLimit = c.get("Economy.MinimumOveralPayment.limit", 0.1); + c.getW().addComment("Economy.MinimumOveralPoints.use", + "Determines minimum payment. In example if player uses McMMO treefeller and earns only 20%, but at same time he gets 25% penalty from dynamic payment. He can 'get' negative amount of money", + "This will limit it to particular percentage", "Works only when original payment is above 0"); + useMinimumOveralPoints = c.get("Economy.MinimumOveralPoints.use", true); + MinimumOveralPointsLimit = c.get("Economy.MinimumOveralPoints.limit", 0.1); + + c.getW().addComment("Economy.DynamicPayment.use", "Do you want to use dinamic payment dependent on how many players already working for jobs", + "This can help automaticaly lift up payments for not so popular jobs and lower for most popular ones"); + useDynamicPayment = c.get("Economy.DynamicPayment.use", false); + + String maxExpEquationInput = c.get("Economy.DynamicPayment.equation", "((totalworkers / totaljobs) - jobstotalplayers)/10.0"); + try { + DynamicPaymentEquation = new Parser(maxExpEquationInput); + // test equation + DynamicPaymentEquation.setVariable("totalworkers", 100); + DynamicPaymentEquation.setVariable("totaljobs", 10); + DynamicPaymentEquation.setVariable("jobstotalplayers", 10); + DynamicPaymentEquation.getValue(); + } catch (Exception e) { + Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Dynamic payment equation has an invalid property. Disabling feature!"); + useDynamicPayment = false; + } + + DynamicPaymentMaxPenalty = c.get("Economy.DynamicPayment.MaxPenalty", 25.0); + DynamicPaymentMaxBonus = c.get("Economy.DynamicPayment.MaxBonus", 100.0); + + c.getW().addComment("Economy.UseServerAcount", "Server economy acount", "With this enabled, players will get money from defined user (server account)", + "If this acount dont have enough money to pay for players for, player will get message"); + UseServerAccount = c.get("Economy.UseServerAcount", false); + c.getW().addComment("Economy.AcountName", "Username should be with Correct capitalization"); + ServerAcountName = c.get("Economy.AcountName", "Server"); + c.getW().addComment("Economy.Taxes.use", "Do you want to use taxes feature for jobs payment"); + UseTaxes = c.get("Economy.Taxes.use", false); + c.getW().addComment("Economy.Taxes.AccountName", "Username should be with Correct capitalization, it can be same as settup in server account before"); + ServertaxesAcountName = c.get("Economy.Taxes.AccountName", "Server"); + c.getW().addComment("Economy.Taxes.Amount", "Amount in percentage"); + TaxesAmount = c.get("Economy.Taxes.Amount", 15.0); + c.getW().addComment("Economy.Taxes.TransferToServerAccount", "Do you want to transfer taxes to server account"); + TransferToServerAccount = c.get("Economy.Taxes.TransferToServerAccount", true); + c.getW().addComment("Economy.Taxes.TakeFromPlayersPayment", + "With this true, taxes will be taken from players payment and he will get less money than its shown in jobs info", + "When its false player will get full payment and server account will get taxes amount to hes account"); + TakeFromPlayersPayment = c.get("Economy.Taxes.TakeFromPlayersPayment", false); + + // Money limit + c.getW().addComment("Economy.Limit.Money", "Money gain limit", "With this enabled, players will be limited how much they can make in defined time", + "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours"); + MoneyLimitUse = c.get("Economy.Limit.Money.Use", false); + c.getW().addComment("Economy.Limit.Money.StopWithExp", "Do you want to stop money gain when exp limit reached?"); + MoneyStopExp = c.get("Economy.Limit.Money.StopWithExp", false); + c.getW().addComment("Economy.Limit.Money.StopWithPoint", "Do you want to stop money gain when point limit reached?"); + MoneyStopPoint = c.get("Economy.Limit.Money.StopWithPoint", false); + + c.getW().addComment("Economy.Limit.Money.MoneyLimit", + "Equation to calculate max limit. Option to use totallevel to include players total amount levels of current jobs", + "You can always use simple number to set money limit", + "Default equation is: 500+500*(totallevel/100), this will add 1% from 500 for each level player have", + "So player with 2 jobs with level 15 and 22 will have 685 limit"); + String MoneyLimit = c.get("Economy.Limit.Money.MoneyLimit", "500+500*(totallevel/100)"); + try { + maxMoneyEquation = new Parser(MoneyLimit); + maxMoneyEquation.setVariable("totallevel", 1); + maxMoneyEquation.getValue(); + } catch (Exception e) { + Jobs.getPluginLogger().warning("MoneyLimit has an invalid value. Disabling money limit!"); + MoneyLimitUse = false; + } + + c.getW().addComment("Economy.Limit.Money.TimeLimit", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours"); + MoneyTimeLimit = c.get("Economy.Limit.Money.TimeLimit", 3600); + c.getW().addComment("Economy.Limit.Money.AnnouncmentDelay", "Delay between announcements about reached money limit", + "Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying"); + MoneyAnnouncmentDelay = c.get("Economy.Limit.Money.AnnouncmentDelay", 30); + + // Point limit + c.getW().addComment("Economy.Limit.Point", "Point gain limit", "With this enabled, players will be limited how much they can make in defined time"); + PointLimitUse = c.get("Economy.Limit.Point.Use", false); + c.getW().addComment("Economy.Limit.Point.StopWithExp", "Do you want to stop Point gain when exp limit reached?"); + PointStopExp = c.get("Economy.Limit.Point.StopWithExp", false); + c.getW().addComment("Economy.Limit.Point.StopWithMoney", "Do you want to stop Point gain when money limit reached?"); + PointStopMoney = c.get("Economy.Limit.Point.StopWithMoney", false); + + c.getW().addComment("Economy.Limit.Point.Limit", + "Equation to calculate max limit. Option to use totallevel to include players total amount levels of current jobs", + "You can always use simple number to set limit", + "Default equation is: 500+500*(totallevel/100), this will add 1% from 500 for each level player have", + "So player with 2 jobs with level 15 and 22 will have 685 limit"); + String PointLimit = c.get("Economy.Limit.Point.Limit", "500+500*(totallevel/100)"); + try { + maxPointEquation = new Parser(PointLimit); + maxPointEquation.setVariable("totallevel", 1); + maxPointEquation.getValue(); + } catch (Exception e) { + Jobs.getPluginLogger().warning("PointLimit has an invalid value. Disabling money limit!"); + PointLimitUse = false; + } + + c.getW().addComment("Economy.Limit.Point.TimeLimit", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours"); + PointTimeLimit = c.get("Economy.Limit.Point.TimeLimit", 3600); + c.getW().addComment("Economy.Limit.Point.AnnouncmentDelay", "Delay between announcements about reached limit", + "Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying"); + PointAnnouncmentDelay = c.get("Economy.Limit.Point.AnnouncmentDelay", 30); + + // Exp limit + c.getW().addComment("Economy.Limit.Exp", "Exp gain limit", "With this enabled, players will be limited how much they can get in defined time", + "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours"); + ExpLimitUse = c.get("Economy.Limit.Exp.Use", false); + c.getW().addComment("Economy.Limit.Exp.StopWithMoney", "Do you want to stop exp gain when money limit reached?"); + ExpStopMoney = c.get("Economy.Limit.Exp.StopWithMoney", false); + c.getW().addComment("Economy.Limit.Exp.StopWithPoint", "Do you want to stop exp gain when point limit reached?"); + ExpStopPoint = c.get("Economy.Limit.Exp.StopWithPoint", false); + + c.getW().addComment("Economy.Limit.Exp.Limit", "Equation to calculate max money limit. Option to use totallevel to include players total amount of current jobs", + "You can always use simple number to set exp limit", + "Default equation is: 5000+5000*(totallevel/100), this will add 1% from 5000 for each level player have", + "So player with 2 jobs with level 15 and 22 will have 6850 limit"); + String expLimit = c.get("Economy.Limit.Exp.Limit", "5000+5000*(totallevel/100)"); + try { + maxExpEquation = new Parser(expLimit); + maxExpEquation.setVariable("totallevel", 1); + maxExpEquation.getValue(); + } catch (Exception e) { + Jobs.getPluginLogger().warning("ExpLimit has an invalid value. Disabling money limit!"); + ExpLimitUse = false; + } + + c.getW().addComment("Economy.Limit.Exp.TimeLimit", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours"); + ExpTimeLimit = c.get("Economy.Limit.Exp.TimeLimit", 3600); + c.getW().addComment("Economy.Limit.Exp.AnnouncmentDelay", "Delay between announcements about reached Exp limit", + "Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying"); + ExpAnnouncmentDelay = c.get("Economy.Limit.Exp.AnnouncmentDelay", 30); + + c.getW().addComment("Economy.Repair.PayForRenaming", "Do you want to give money for only renaming items in anvil", + "Players will get full pay as they would for remairing two items when they only renaming one", + "This is not big issue, but if you want to disable it, you can"); + PayForRenaming = c.get("Economy.Repair.PayForRenaming", true); + + c.getW().addComment("Economy.Crafting.PayForEachCraft", + "With this true, player will get money for all crafted items instead of each crafting action (like with old payment mechanic)", + "By default its false, as you can make ALOT of money if prices kept from old payment mechanics"); + PayForEachCraft = c.get("Economy.Crafting.PayForEachCraft", false); + + c.getW().addComment("Economy.MilkingCow.CancelMilking", "With this true, when timer is still going, cow milking event will be canceled", + "With this false, player will get bucket of milk, but still no payment"); + CancelCowMilking = c.get("Economy.MilkingCow.CancelMilking", false); + c.getW().addComment("Economy.MilkingCow.Timer", + "How ofter player can milk cows in seconds. Keep in mind that by default player can milk cow indefinetly and as often as he wants", + "Set to 0 if you want to disable timer"); + CowMilkingTimer = c.get("Economy.MilkingCow.Timer", 30) * 1000; + + c.getW().addComment("ExploitProtections.Coreprotect.Use", + "Requires to have CoreProtect plugin and there should be block place/break logging enabled in core protect config file.", + "This will prevent players from abusing by placing and breaking blocks again and again", "This will work even after server restart"); + useCoreProtect = c.get("ExploitProtections.Coreprotect.Use", false); + c.getW().addComment("ExploitProtections.Coreprotect.TimeLimit", "Time limit in minutes to protect blocks from repeating place/breake action.", + "10080 equals to 7 days, keep it in reasonable time range"); + CoreProtectInterval = c.get("ExploitProtections.Coreprotect.TimeLimit", 604800); + + c.getW().addComment("ExploitProtections.Coreprotect.BlockPlace.Use", "Do you want to use block place interval protection"); + BlockPlaceUse = c.get("ExploitProtections.Coreprotect.BlockPlace.Use", true); + EnableAnounceMessage = c.get("ExploitProtections.Coreprotect.BlockPlace.EnableAnounceMessage", true); + c.getW().addComment("ExploitProtections.Coreprotect.BlockPlace.Interval", "Time interval in seconds in how fast you can place block in same place.", + "Keep it on low interval, 3-5 sec will be enough to prevent fast block place in same place and dont annoy peps", + "Edit block list in restrictedBlocks.yml under PlacedBlockTimer"); + BlockPlaceInterval = c.get("ExploitProtections.Coreprotect.BlockPlace.Interval", 2); + + c.getW().addComment("ExploitProtections.General.PlaceAndBreakProtection", + "Enable blocks protection, like ore, from exploiting by placing and destroying same block again and again.", "This works only until server restart", + "Modify restrictedBlocks.yml for blocks you want to protect"); + useBlockProtection = c.get("ExploitProtections.General.PlaceAndBreakProtection", true); + + c.getW().addComment("ExploitProtections.General.SilkTouchProtection", "Enable silk touch protection.", + "With this enabled players wont get paid for breaked blocks from restrictedblocks list with silk touch tool."); + useSilkTouchProtection = c.get("ExploitProtections.General.SilkTouchProtection", false); + + c.getW().addComment("ExploitProtections.General.StopPistonBlockMove", "Enable piston moving blocks from restrictedblocks list.", + "If piston moves block then it will be like new block and BlockPlaceAndBreakProtection wont work properly", + "If you using core protect and its being logging piston block moving, then you can disable this"); + useBlockPiston = c.get("ExploitProtections.General.StopPistonBlockMove", true); + + c.getW().addComment("ExploitProtections.General.BlocksTimer", "Enable blocks timer protection.", + "Only enable if you want to protect block from beying broken to fast, useful for vegetables.", "Modify restrictedBlocks.yml for blocks you want to protect"); + useBlockTimer = c.get("ExploitProtections.General.BlocksTimer", true); + + c.getW().addComment("ExploitProtections.General.GlobalBlockTimer", "All blocks will be protected X sec after player places it on ground."); + useGlobalTimer = c.get("ExploitProtections.General.GlobalBlockTimer.use", false); + globalblocktimer = c.get("ExploitProtections.General.GlobalBlockTimer.timer", 30); + + c.getW().addComment("ExploitProtections.General.PetPay", "Do you want to pay when players pet kills monster/player", "Can be exploited with mob farms", + "0.2 means 20% of original reward", "Optionaly you can give jobs.petpay permission node for specific players/ranks to get paid by VipPetPay multiplier"); + PetPay = c.get("ExploitProtections.General.PetPay", 0.1); + VipPetPay = c.get("ExploitProtections.General.VipPetPay", 1.0); + + c.getW().addComment("ExploitProtections.McMMO", "McMMO abilities"); + c.getW().addComment("ExploitProtections.McMMO.TreeFellerMultiplier", "Players will get part of money from cutting trees with treefeller ability enabled.", + "0.2 means 20% of original price"); + TreeFellerMultiplier = c.get("ExploitProtections.McMMO.TreeFellerMultiplier", 0.2); + c.getW().addComment("ExploitProtections.McMMO.gigaDrillMultiplier", "Players will get part of money from braking blocks with gigaDrill ability enabled.", + "0.2 means 20% of original price"); + gigaDrillMultiplier = c.get("ExploitProtections.McMMO.gigaDrillMultiplier", 0.2); + c.getW().addComment("ExploitProtections.McMMO.superBreakerMultiplier", "Players will get part of money from braking blocks with super breaker ability enabled.", + "0.2 means 20% of original price"); + superBreakerMultiplier = c.get("ExploitProtections.McMMO.superBreakerMultiplier", 0.2); + + c.getW().addComment("ExploitProtections.MythicMobs", "MythicMobs plugin support", "Disable if you having issues with it or using old version"); + MythicMobsEnabled = c.get("ExploitProtections.MythicMobs.enabled", true); + + c.getW().addComment("ExploitProtections.Spawner.PreventSlimeSplit", "Prevent slime spliting when they are from spawner", + "Protects agains exploiting as new splited slimes is treated as naturaly spawned and not from spawner"); + PreventSlimeSplit = c.get("ExploitProtections.Spawner.PreventSlimeSplit", true); + c.getW().addComment("ExploitProtections.Spawner.PreventMagmaCubeSplit", "Prevent magmacube spliting when they are from spawner"); + PreventMagmaCubeSplit = c.get("ExploitProtections.Spawner.PreventMagmaCubeSplit", true); + + c.getW().addComment("ExploitProtections.WaterBlockBreake", + "Prevent water braking placed blocks. Protection resets with server restart or after plants grows to next stage with bone powder or naturally", + "For strange reason works only 5 of 10 times, but this is completely enough to prevent exploiting"); + WaterBlockBreake = c.get("ExploitProtections.WaterBlockBreake", true); + + c.getW().addComment("use-breeder-finder", "Breeder finder.", + "If you are not using breeding payment, you can disable this to save little resources. Really little."); + useBreederFinder = c.get("use-breeder-finder", true); + + c.getW().addComment("boost", "Money exp boost with special permision.", + "You will need to add special permision for groups or players to have money/exp/points boost.", + "Use: jobs.boost.[jobname].money or jobs.boost.[jobname].exp or jobs.boost.[jobname].points or jobs.boost.[jobname].all for all of them with specific jobs name.", + "Use: jobs.boost.all.money or jobs.boost.all.exp or jobs.boost.all.points or jobs.boost.all.all to get boost for all jobs", + "1.25 means that player will get 25% more than others, you can set less than 1 to get less from anothers"); + BoostExp = c.get("boost.exp", 1.00); + BoostMoney = c.get("boost.money", 1.00); + BoostPoints = c.get("boost.points", 1.00); + + c.getW().addComment("old-job", "Old job save", "Players can leave job and return later with some level loss during that", + "You can fix players level if hes job level is at max level"); + levelLossPercentage = c.get("old-job.level-loss-percentage", 30); + fixAtMaxLevel = c.get("old-job.fix-at-max-level", true); + + c.getW().addComment("ActionBars.Messages.EnabledByDefault", "When this set to true player will see action bar messages by default"); + ActionBarsMessageByDefault = c.get("ActionBars.Messages.EnabledByDefault", true); + + c.getW().addComment("BossBar.Enabled", "Enables BossBar feature", "Works only from 1.9 mc version"); + BossBarEnabled = c.get("BossBar.Enabled", true); + + if (Jobs.getActionBar().getVersion() < 1900) { + BossBarEnabled = false; + Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Jobs] Your server version don't support BossBar. This feature will be disabled"); + } + + c.getW().addComment("BossBar.Messages.EnabledByDefault", "When this set to true player will see Bossbar messages by default"); + BossBarsMessageByDefault = c.get("BossBar.Messages.EnabledByDefault", true); + + c.getW().addComment("BossBar.ShowOnEachAction", "If enabled boss bar will update after each action", + "If disabled, BossBar will update only on each payment. This can save some server resources"); + BossBarShowOnEachAction = c.get("BossBar.ShowOnEachAction", false); + c.getW().addComment("BossBar.Timer", "How long in sec to show BossBar for player", + "If you have disabled ShowOnEachAction, then keep this number higher than payment interval for better experience"); + BossBarTimer = c.get("BossBar.Timer", economyBatchDelay + 1); + + c.getW().addComment("ShowActionBars", "You can enable/disable message shown for players in action bar"); + TitleChangeActionBar = c.get("ShowActionBars.OnTitleChange", true); + LevelChangeActionBar = c.get("ShowActionBars.OnLevelChange", true); + EmptyServerAcountActionBar = c.get("ShowActionBars.OnEmptyServerAcount", true); + + c.getW().addComment("ShowChatMessage", "Chat messages", "You can enable/disable message shown for players in chat"); + TitleChangeChat = c.get("ShowChatMessage.OnTitleChange", true); + LevelChangeChat = c.get("ShowChatMessage.OnLevelChange", true); + EmptyServerAcountChat = c.get("ShowChatMessage.OnEmptyServerAcount", true); + + c.getW().addComment("Sounds", "Sounds", "Extra sounds on some events", + "All sounds can be found in https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html"); + SoundLevelupUse = c.get("Sounds.LevelUp.use", true); + SoundLevelupSound = c.get("Sounds.LevelUp.sound", "ENTITY_PLAYER_LEVELUP"); + SoundLevelupVolume = c.get("Sounds.LevelUp.volume", 1); + SoundLevelupPitch = c.get("Sounds.LevelUp.pitch", 3); + SoundTitleChangeUse = c.get("Sounds.TitleChange.use", true); + SoundTitleChangeSound = c.get("Sounds.TitleChange.sound", "ENTITY_PLAYER_LEVELUP"); + SoundTitleChangeVolume = c.get("Sounds.TitleChange.volume", 1); + SoundTitleChangePitch = c.get("Sounds.TitleChange.pitch", 3); + + c.getW().addComment("Signs", "You can disable this to save SMALL amount of server resources"); + SignsEnabled = c.get("Signs.Enable", true); + SignsColorizeJobName = c.get("Signs.Colors.ColorizeJobName", true); + c.getW().addComment("Signs.InfoUpdateInterval", + "This is interval in sec in which signs will be updated. This is not continues update, signs are updated only on levelup, job leave, job join or similar action."); + c.getW().addComment("Signs.InfoUpdateInterval", + "This is update for same job signs, to avoid huge lag if you have bunch of same type signs. Keep it from 1 to as many sec you want"); + InfoUpdateInterval = c.get("Signs.InfoUpdateInterval", 5); + + c.getW().addComment("Scoreboard.ShowToplist", "This will enables to show top list in scoreboard instead of chat"); + ShowToplistInScoreboard = c.get("Scoreboard.ShowToplist", true); + c.getW().addComment("Scoreboard.interval", "For how long to show scoreboard"); + ToplistInScoreboardInterval = c.get("Scoreboard.interval", 10); + + c.getW().addComment("JobsBrowse.ShowTotalWorkers", "Do you want to show total amount of workers for job in jobs browse window"); + ShowTotalWorkers = c.get("JobsBrowse.ShowTotalWorkers", true); + c.getW().addComment("JobsBrowse.ShowPenaltyBonus", "Do you want to show penalty and bonus in jobs browse window. Only works if this feature is enabled"); + ShowPenaltyBonus = c.get("JobsBrowse.ShowPenaltyBonus", true); + + c.getW().addComment("JobsGUI.OpenOnBrowse", "Do you want to show GUI when performing /jobs browse command"); + JobsGUIOpenOnBrowse = c.get("JobsGUI.OpenOnBrowse", true); + c.getW().addComment("JobsGUI.ShowChatBrowse", "Do you want to show chat information when performing /jobs browse command"); + JobsGUIShowChatBrowse = c.get("JobsGUI.ShowChatBrowse", true); + c.getW().addComment("JobsGUI.SwitcheButtons", "With true left mouse button will join job and right will show more info", + "With false left mouse button will show more info, rigth will join job", "Dont forget to adjust locale file"); + JobsGUISwitcheButtons = c.get("JobsGUI.SwitcheButtons", false); + c.getW().addComment("JobsBrowse.ShowPenaltyBonus", "Do you want to show GUI when performing /jobs join command"); + JobsGUIOpenOnJoin = c.get("JobsGUI.OpenOnJoin", true); + + c.getW().addComment("Schedule.Boost.Enable", "Do you want to enable scheduler for global boost"); + useGlobalBoostScheduler = c.get("Schedule.Boost.Enable", false); + + // writer.addComment("Gui.UseJobsBrowse", "Do you want to use jobs browse gui instead of chat text"); + // UseJobsBrowse = c.get("Gui.UseJobsBrowse", true); + + // Write back config + try { + c.getW().save(f); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public synchronized void startMysql() { + File f = new File(plugin.getDataFolder(), "generalConfig.yml"); + YamlConfiguration config = YamlConfiguration.loadConfiguration(f); + String legacyUrl = config.getString("mysql-url"); + if (legacyUrl != null) { + String jdbcString = "jdbc:mysql://"; + if (legacyUrl.toLowerCase().startsWith(jdbcString)) { + legacyUrl = legacyUrl.substring(jdbcString.length()); + String[] parts = legacyUrl.split("/"); + if (parts.length >= 2) { + config.set("mysql-hostname", parts[0]); + config.set("mysql-database", parts[1]); + } + } + } + String username = config.getString("mysql-username"); + if (username == null) { + Jobs.getPluginLogger().severe("mysql-username property invalid or missing"); + } + String password = config.getString("mysql-password"); + String hostname = config.getString("mysql-hostname"); + String database = config.getString("mysql-database"); + String prefix = config.getString("mysql-table-prefix"); + if (plugin.isEnabled()) + Jobs.setDAO(JobsDAOMySQL.initialize(hostname, database, username, password, prefix)); + } + + public synchronized void startSqlite() { + Jobs.setDAO(JobsDAOSQLite.initialize()); + } +} diff --git a/com/gamingmesh/jobs/config/JobConfig.java b/com/gamingmesh/jobs/config/JobConfig.java deleted file mode 100644 index 1cb4d55a..00000000 --- a/com/gamingmesh/jobs/config/JobConfig.java +++ /dev/null @@ -1,561 +0,0 @@ -/** - * Jobs Plugin for Bukkit - * Copyright (C) 2011 Zak Ford - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.gamingmesh.jobs.config; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import org.apache.commons.lang.StringEscapeUtils; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.EntityType; -import org.bukkit.inventory.ItemStack; - -import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; -import com.gamingmesh.jobs.container.ActionType; -import com.gamingmesh.jobs.container.DisplayMethod; -import com.gamingmesh.jobs.container.Job; -import com.gamingmesh.jobs.container.JobCommands; -import com.gamingmesh.jobs.container.JobConditions; -import com.gamingmesh.jobs.container.JobInfo; -import com.gamingmesh.jobs.container.JobItems; -import com.gamingmesh.jobs.container.JobLimitedItems; -import com.gamingmesh.jobs.container.JobPermission; -import com.gamingmesh.jobs.resources.jfep.Parser; -import com.gamingmesh.jobs.stuff.ChatColor; - -public class JobConfig { - private JobsPlugin plugin; - - public JobConfig(JobsPlugin plugin) { - this.plugin = plugin; - } - - public void reload() throws IOException { - // job settings - loadJobSettings(); - } - - /** - * Method to load the jobs configuration - * - * loads from Jobs/jobConfig.yml - * @throws IOException - */ - @SuppressWarnings("deprecation") - private void loadJobSettings() throws IOException { - File f = new File(plugin.getDataFolder(), "jobConfig.yml"); - InputStreamReader s = new InputStreamReader(new FileInputStream(f), "UTF-8"); - - ArrayList jobs = new ArrayList(); - Jobs.setJobs(jobs); - Jobs.setNoneJob(null); - if (!f.exists()) { - try { - f.createNewFile(); - } catch (IOException e) { - Jobs.getPluginLogger().severe("Unable to create jobConfig.yml! No jobs were loaded!"); - s.close(); - return; - } - } - YamlConfiguration conf = new YamlConfiguration(); - conf.options().pathSeparator('/'); - try { - conf.load(s); - s.close(); - } catch (Exception e) { - Bukkit.getServer().getLogger().severe("==================== Jobs ===================="); - Bukkit.getServer().getLogger().severe("Unable to load jobConfig.yml!"); - Bukkit.getServer().getLogger().severe("Check your config for formatting issues!"); - Bukkit.getServer().getLogger().severe("No jobs were loaded!"); - Bukkit.getServer().getLogger().severe("Error: " + e.getMessage()); - Bukkit.getServer().getLogger().severe("=============================================="); - return; - } - //conf.options().header(new StringBuilder().append("Jobs configuration.").append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("Stores information about each job.").append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("For example configurations, visit http://dev.bukkit.org/bukkit-plugins/jobs-reborn/.").append(System.getProperty("line.separator")).toString()); - - ConfigurationSection jobsSection = conf.getConfigurationSection("Jobs"); - //if (jobsSection == null) { - // jobsSection = conf.createSection("Jobs"); - //} - for (String jobKey : jobsSection.getKeys(false)) { - - // Ignoring example job - if (jobKey.equalsIgnoreCase("exampleJob")) - continue; - - ConfigurationSection jobSection = jobsSection.getConfigurationSection(jobKey); - String jobName = jobSection.getString("fullname"); - - // Translating unicode - jobName = StringEscapeUtils.unescapeJava(jobName); - - if (jobName == null) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid fullname property. Skipping job!"); - continue; - } - - int maxLevel = jobSection.getInt("max-level", 0); - if (maxLevel < 0) - maxLevel = 0; - - int vipmaxLevel = jobSection.getInt("vip-max-level", 0); - if (vipmaxLevel < 0) - vipmaxLevel = 0; - - Integer maxSlots = jobSection.getInt("slots", 0); - if (maxSlots.intValue() <= 0) { - maxSlots = null; - } - - String jobShortName = jobSection.getString("shortname"); - if (jobShortName == null) { - Jobs.getPluginLogger().warning("Job " + jobKey + " is missing the shortname property. Skipping job!"); - continue; - } - - String description = org.bukkit.ChatColor.translateAlternateColorCodes('&', jobSection.getString("description", "")); - - ChatColor color = ChatColor.WHITE; - if (jobSection.contains("ChatColour")) { - color = ChatColor.matchColor(jobSection.getString("ChatColour", "")); - if (color == null) { - color = ChatColor.WHITE; - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid ChatColour property. Defaulting to WHITE!"); - } - } - DisplayMethod displayMethod = DisplayMethod.matchMethod(jobSection.getString("chat-display", "")); - if (displayMethod == null) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid chat-display property. Defaulting to None!"); - displayMethod = DisplayMethod.NONE; - } - - Parser maxExpEquation; - String maxExpEquationInput = jobSection.getString("leveling-progression-equation"); - try { - maxExpEquation = new Parser(maxExpEquationInput); - // test equation - maxExpEquation.setVariable("numjobs", 1); - maxExpEquation.setVariable("joblevel", 1); - maxExpEquation.getValue(); - } catch (Exception e) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid leveling-progression-equation property. Skipping job!"); - continue; - } - - Parser incomeEquation; - String incomeEquationInput = jobSection.getString("income-progression-equation"); - try { - incomeEquation = new Parser(incomeEquationInput); - // test equation - incomeEquation.setVariable("numjobs", 1); - incomeEquation.setVariable("joblevel", 1); - incomeEquation.setVariable("baseincome", 1); - incomeEquation.getValue(); - } catch (Exception e) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid income-progression-equation property. Skipping job!"); - continue; - } - - Parser expEquation; - String expEquationInput = jobSection.getString("experience-progression-equation"); - try { - expEquation = new Parser(expEquationInput); - // test equation - expEquation.setVariable("numjobs", 1); - expEquation.setVariable("joblevel", 1); - expEquation.setVariable("baseexperience", 1); - expEquation.getValue(); - } catch (Exception e) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid experience-progression-equation property. Skipping job!"); - continue; - } - - // Gui item - ItemStack GUIitem = new ItemStack(Material.getMaterial(35), 1, (byte) 13); - if (jobSection.contains("Gui")) { - ConfigurationSection guiSection = jobSection.getConfigurationSection("Gui"); - if (guiSection.contains("Id") && guiSection.contains("Data") && guiSection.isInt("Id") && guiSection.isInt("Data")) { - GUIitem = new ItemStack(Material.getMaterial(guiSection.getInt("Id")), 1, (byte) guiSection.getInt("Data")); - } else - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid Gui property. Please fix this if you want to use it!"); - } - - // Permissions - ArrayList jobPermissions = new ArrayList(); - ConfigurationSection permissionsSection = jobSection.getConfigurationSection("permissions"); - if (permissionsSection != null) { - for (String permissionKey : permissionsSection.getKeys(false)) { - ConfigurationSection permissionSection = permissionsSection.getConfigurationSection(permissionKey); - - String node = permissionKey.toLowerCase(); - if (permissionSection == null) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid permission key" + permissionKey + "!"); - continue; - } - boolean value = permissionSection.getBoolean("value", true); - int levelRequirement = permissionSection.getInt("level", 0); - jobPermissions.add(new JobPermission(node, value, levelRequirement)); - } - } - - // Conditions - ArrayList jobConditions = new ArrayList(); - ConfigurationSection conditionsSection = jobSection.getConfigurationSection("conditions"); - if (conditionsSection != null) { - for (String ConditionKey : conditionsSection.getKeys(false)) { - ConfigurationSection permissionSection = conditionsSection.getConfigurationSection(ConditionKey); - - String node = ConditionKey.toLowerCase(); - if (permissionSection == null) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid condition key " + ConditionKey + "!"); - continue; - } - if (!permissionSection.contains("requires") || !permissionSection.contains("perform")) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid condition requirement " + ConditionKey + "!"); - continue; - } - List requires = permissionSection.getStringList("requires"); - List perform = permissionSection.getStringList("perform"); - - jobConditions.add(new JobConditions(node, requires, perform)); - } - } - - // Command on leave - List JobsCommandOnLeave = new ArrayList(); - if (jobSection.isList("cmd-on-leave")) { - JobsCommandOnLeave = jobSection.getStringList("cmd-on-leave"); - } - - // Command on join - List JobsCommandOnJoin = new ArrayList(); - if (jobSection.isList("cmd-on-join")) { - JobsCommandOnJoin = jobSection.getStringList("cmd-on-join"); - } - - // Commands - ArrayList jobCommand = new ArrayList(); - ConfigurationSection commandsSection = jobSection.getConfigurationSection("commands"); - if (commandsSection != null) { - for (String commandKey : commandsSection.getKeys(false)) { - ConfigurationSection commandSection = commandsSection.getConfigurationSection(commandKey); - - String node = commandKey.toLowerCase(); - if (commandSection == null) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid command key" + commandKey + "!"); - continue; - } - String command = commandSection.getString("command"); - int levelFrom = commandSection.getInt("levelFrom"); - int levelUntil = commandSection.getInt("levelUntil"); - jobCommand.add(new JobCommands(node, command, levelFrom, levelUntil)); - } - } - - // Items - ArrayList jobItems = new ArrayList(); - ConfigurationSection itemsSection = jobSection.getConfigurationSection("items"); - if (itemsSection != null) { - for (String itemKey : itemsSection.getKeys(false)) { - ConfigurationSection itemSection = itemsSection.getConfigurationSection(itemKey); - - String node = itemKey.toLowerCase(); - if (itemSection == null) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid item key " + itemKey + "!"); - continue; - } - int id = itemSection.getInt("id"); - - String name = null; - if (itemSection.isString("name")) - name = itemSection.getString("name"); - - List lore = new ArrayList(); - if (itemSection.getStringList("lore") != null) - for (String eachLine : itemSection.getStringList("lore")) { - lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine)); - } - - HashMap enchants = new HashMap(); - if (itemSection.getStringList("enchants") != null) - for (String eachLine : itemSection.getStringList("enchants")) { - - if (!eachLine.contains("=")) - continue; - - Enchantment ench = Enchantment.getByName(eachLine.split("=")[0]); - Integer level = -1; - try { - level = Integer.parseInt(eachLine.split("=")[1]); - } catch (NumberFormatException e) { - continue; - } - - if (ench != null && level != -1) - enchants.put(ench, level); - } - - Double moneyBoost = itemSection.getDouble("moneyBoost"); - Double expBoost = itemSection.getDouble("expBoost"); - jobItems.add(new JobItems(node, id, name, lore, enchants, moneyBoost, expBoost)); - } - } - - // Limited Items - ArrayList jobLimitedItems = new ArrayList(); - ConfigurationSection LimitedItemsSection = jobSection.getConfigurationSection("limitedItems"); - if (LimitedItemsSection != null) { - for (String itemKey : LimitedItemsSection.getKeys(false)) { - ConfigurationSection itemSection = LimitedItemsSection.getConfigurationSection(itemKey); - - String node = itemKey.toLowerCase(); - if (itemSection == null) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid item key " + itemKey + "!"); - continue; - } - int id = itemSection.getInt("id"); - - String name = null; - if (itemSection.isString("name")) - name = itemSection.getString("name"); - - List lore = new ArrayList(); - if (itemSection.getStringList("lore") != null) - for (String eachLine : itemSection.getStringList("lore")) { - lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine)); - } - - HashMap enchants = new HashMap(); - if (itemSection.getStringList("enchants") != null) - for (String eachLine : itemSection.getStringList("enchants")) { - - if (!eachLine.contains("=")) - continue; - - Enchantment ench = Enchantment.getByName(eachLine.split("=")[0]); - Integer level = -1; - try { - level = Integer.parseInt(eachLine.split("=")[1]); - } catch (NumberFormatException e) { - continue; - } - - if (ench != null && level != -1) - enchants.put(ench, level); - } - - int level = itemSection.getInt("level"); - - jobLimitedItems.add(new JobLimitedItems(node, id, name, lore, enchants, level)); - } - } - - Job job = new Job(jobName, jobShortName, description, color, maxExpEquation, displayMethod, maxLevel, vipmaxLevel, maxSlots, jobPermissions, jobCommand, - jobConditions, jobItems, jobLimitedItems, JobsCommandOnJoin, JobsCommandOnLeave, GUIitem); - - for (ActionType actionType : ActionType.values()) { - ConfigurationSection typeSection = jobSection.getConfigurationSection(actionType.getName()); - ArrayList jobInfo = new ArrayList(); - if (typeSection != null) { - for (String key : typeSection.getKeys(false)) { - ConfigurationSection section = typeSection.getConfigurationSection(key); - String myKey = key; - String type = null; - String subType = ""; - String meta = ""; - int id = 0; - - if (myKey.contains("-")) { - // uses subType - subType = ":" + myKey.split("-")[1]; - meta = myKey.split("-")[1]; - myKey = myKey.split("-")[0]; - } - - Material material = Material.matchMaterial(myKey); - - if (material == null) - material = Material.getMaterial(myKey.replace(" ", "_").toUpperCase()); - - if (material == null) { - // try integer method - Integer matId = null; - try { - matId = Integer.valueOf(myKey); - } catch (NumberFormatException e) { - } - if (matId != null) { - material = Material.getMaterial(matId); - if (material != null) { - Jobs.getPluginLogger().warning("Job " + jobKey + " " + actionType.getName() + " is using ID: " + key + "!"); - Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!"); - } - } - } - - if (actionType == ActionType.EXPLORE) - material = null; - - if (material != null) { - // Break and Place actions MUST be blocks - if (actionType == ActionType.BREAK || actionType == ActionType.PLACE) { - if (!material.isBlock()) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key - + "! Material must be a block!"); - continue; - } - } - // START HACK - /* - * Historically, GLOWING_REDSTONE_ORE would ONLY work as REDSTONE_ORE, and putting - * GLOWING_REDSTONE_ORE in the configuration would not work. Unfortunately, this is - * completely backwards and wrong. - * - * To maintain backwards compatibility, all instances of REDSTONE_ORE should normalize - * to GLOWING_REDSTONE_ORE, and warn the user to change their configuration. In the - * future this hack may be removed and anybody using REDSTONE_ORE will have their - * configurations broken. - */ - if (material == Material.REDSTONE_ORE && actionType == ActionType.BREAK) { - Jobs.getPluginLogger().warning("Job " + jobKey + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE."); - Jobs.getPluginLogger().warning("Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration."); - Jobs.getPluginLogger().warning("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with."); - Jobs.getPluginLogger().warning("In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly."); - material = Material.GLOWING_REDSTONE_ORE; - } - // END HACK - - type = material.toString(); - id = material.getId(); - } else if (actionType == ActionType.KILL || actionType == ActionType.TAME || actionType == ActionType.BREED || actionType == ActionType.MILK) { - // check entities - EntityType entity = EntityType.fromName(key); - if (entity == null) { - try { - entity = EntityType.valueOf(key.toUpperCase()); - } catch (IllegalArgumentException e) { - } - } - - if (entity != null && entity.isAlive()) { - type = entity.toString(); - id = entity.getTypeId(); - - // using breeder finder - if (actionType == ActionType.BREED) - ConfigManager.getJobsConfiguration().setBreederFinder(true); - } - - // Just to recognize wither skeleton - if (key.equalsIgnoreCase("WitherSkeleton")) { - type = "WitherSkeleton"; - id = 51; - meta = "1"; - } - - // Just to recognize Zombie Villager - if (key.equalsIgnoreCase("ZombieVillager")) { - type = "ZombieVillager"; - id = 54; - meta = "1"; - } - - // Just to recognize Elder Guardian - if (key.equalsIgnoreCase("ElderGuardian")) { - type = "ElderGuardian"; - id = 68; - meta = "1"; - } - - } else if (actionType == ActionType.ENCHANT && material == null) { - Enchantment enchant = Enchantment.getByName(myKey); - if (enchant != null) - id = enchant.getId(); - type = myKey; - } else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL) { - type = myKey; - } else if (actionType == ActionType.EXPLORE) { - type = myKey; - int amount = 10; - try { - amount = Integer.valueOf(myKey); - } catch (NumberFormatException e) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key + "!"); - continue; - } - Jobs.getExplore().setExploreEnabled(); - Jobs.getExplore().setPlayerAmount(amount + 1); - } - - if (type == null) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid " + actionType.getName() + " type property: " + key + "!"); - continue; - } - - if (actionType == ActionType.TNTBREAK) - ConfigManager.getJobsConfiguration().setTntFinder(true); - - double income = section.getDouble("income", 0.0); - double experience = section.getDouble("experience", 0.0); - - int fromlevel = 1; - - if (section.isInt("from-level")) - fromlevel = section.getInt("from-level"); - - int untilLevel = -1; - if (section.isInt("until-level")) { - untilLevel = section.getInt("until-level"); - if (untilLevel < fromlevel) { - Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid until-level in " + actionType.getName() + " for type property: " + key - + "! It will be not set."); - untilLevel = -1; - } - } - - jobInfo.add(new JobInfo(actionType, id, meta, type + subType, income, incomeEquation, experience, expEquation, fromlevel, untilLevel)); - } - } - job.setJobInfo(actionType, jobInfo); - } - - if (jobKey.equalsIgnoreCase("none")) { - Jobs.setNoneJob(job); - } else { - jobs.add(job); - } - } - //try { - // conf.save(f); - //} catch (IOException e) { - // e.printStackTrace(); - //} - } -} diff --git a/com/gamingmesh/jobs/config/JobsConfiguration.java b/com/gamingmesh/jobs/config/JobsConfiguration.java deleted file mode 100644 index 97108ef5..00000000 --- a/com/gamingmesh/jobs/config/JobsConfiguration.java +++ /dev/null @@ -1,1586 +0,0 @@ -/** - * Jobs Plugin for Bukkit - * Copyright (C) 2011 Zak Ford - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.gamingmesh.jobs.config; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.configuration.Configuration; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.resources.jfep.Parser; -import com.gamingmesh.jobs.JobsPlugin; -import com.gamingmesh.jobs.container.NameList; -import com.gamingmesh.jobs.container.RestrictedArea; -import com.gamingmesh.jobs.container.Schedule; -import com.gamingmesh.jobs.container.Title; -import com.gamingmesh.jobs.dao.JobsDAOMySQL; -import com.gamingmesh.jobs.dao.JobsDAOSQLite; -import com.gamingmesh.jobs.stuff.ChatColor; - -public class JobsConfiguration { - private JobsPlugin plugin; - protected List titles = new ArrayList<Title>(); - protected ArrayList<RestrictedArea> restrictedAreas = new ArrayList<RestrictedArea>(); - public ArrayList<String> restrictedBlocks = new ArrayList<String>(); - public ArrayList<String> restrictedBlocksTimer = new ArrayList<String>(); - public ArrayList<Integer> restrictedPlaceBlocksTimer = new ArrayList<Integer>(); - public ArrayList<NameList> ListOfNames = new ArrayList<NameList>(); - public ArrayList<NameList> ListOfEntities = new ArrayList<NameList>(); - public ArrayList<NameList> ListOfEnchants = new ArrayList<NameList>(); - public ArrayList<NameList> ListOfColors = new ArrayList<NameList>(); - public List<Integer> BroadcastingLevelUpLevels = new ArrayList<Integer>(); - protected Locale locale; - protected int savePeriod; - protected boolean economyAsync; - protected boolean isBroadcastingSkillups; - protected boolean isBroadcastingLevelups; - protected boolean payInCreative; - protected boolean payExploringWhenFlying; - protected boolean addXpPlayer; - protected boolean hideJobsWithoutPermission; - protected int maxJobs; - protected boolean payNearSpawner; - protected boolean modifyChat; - public String modifyChatPrefix; - public String modifyChatSuffix; - public String modifyChatSeparator; - protected int economyBatchDelay; - protected boolean saveOnDisconnect; - public boolean LocalOfflinePlayersData; - public boolean MythicMobsEnabled; - public boolean LoggingUse; - public boolean EconomyLimitUse, EconomyExpLimitUse, PayForRenaming, PayForEachCraft, SignsEnabled, - SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse, - EnableAnounceMessage, useBlockPiston, useSilkTouchProtection, UseCustomNames, EconomyMoneyStop, - EconomyExpStop, UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit, WaterBlockBreake; - public int EconomyLimitTimeLimit, EconomyExpTimeLimit; - public int EconomyLimitAnnouncmentDelay, EconomyLimitAnnouncmentExpDelay, globalblocktimer, CowMilkingTimer, - CoreProtectInterval, BlockPlaceInterval, InfoUpdateInterval; - public Double payNearSpawnerMultiplier, VIPpayNearSpawnerMultiplier, TreeFellerMultiplier, gigaDrillMultiplier, superBreakerMultiplier, PetPay, VipPetPay; - public String localeString; - public boolean useBlockProtection; - public boolean useBlockTimer; - public boolean useMinimumOveralPayment; - public boolean useBreederFinder = false; - private boolean useTnTFinder = false; - public boolean CancelCowMilking; - public boolean fixAtMaxLevel, ToggleActionBar, TitleChangeChat, TitleChangeActionBar, LevelChangeChat, - LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAcountChat, - EmptyServerAcountActionBar, JobsToggleEnabled, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment, - useGlobalBoostScheduler, JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, JobsGUIOpenOnJoin; - public Integer levelLossPercentage, SoundLevelupVolume, SoundLevelupPitch, SoundTitleChangeVolume, - SoundTitleChangePitch, ToplistInScoreboardInterval; - public double BoostExp; - public double MinimumOveralPaymentLimit; - public double BoostMoney; - public double DynamicPaymentMaxPenalty; - public double DynamicPaymentMaxBonus; - public double TaxesAmount; - public String SoundLevelupSound, SoundTitleChangeSound, ServerAcountName, ServertaxesAcountName; - public ArrayList<String> keys; - public String storageMethod; - public boolean hideJobsInfoWithoutPermission; - public boolean UseTaxes; - public boolean TransferToServerAccount; - public boolean TakeFromPlayersPayment; - - public Parser DynamicPaymentEquation; - public Parser maxMoneyEquation; - public Parser maxExpEquation; - - public List<Schedule> BoostSchedule = new ArrayList<Schedule>(); - - public JobsConfiguration(JobsPlugin plugin) { - super(); - this.plugin = plugin; - } - - public String Colors(String text) { - return org.bukkit.ChatColor.translateAlternateColorCodes('&', text); - } - - public String GetConfigString(String path, String text, CommentedYamlConfiguration writer, YamlConfiguration conf, Boolean colorize) { - conf.addDefault(path, text); - text = conf.getString(path); - if (colorize) - text = Colors(text); - copySetting(conf, writer, path); - return text; - } - - public void setBreederFinder(boolean state) { - this.useBreederFinder = state; - } - - public boolean isUseBreederFinder() { - return this.useBreederFinder; - } - - public void setTntFinder(boolean state) { - this.useTnTFinder = state; - } - - public boolean isUseTntFinder() { - return this.useTnTFinder; - } - - /** - * Get how often in minutes to save job information - * @return how often in minutes to save job information - */ - public synchronized int getSavePeriod() { - return savePeriod; - } - - /** - * Should we use asynchronous economy calls - * @return true - use async - * @return false - use sync - */ - public synchronized boolean isEconomyAsync() { - return economyAsync; - } - - /** - * Function that tells if the system is set to broadcast on skill up - * @return true - broadcast on skill up - * @return false - do not broadcast on skill up - */ - public synchronized boolean isBroadcastingSkillups() { - return isBroadcastingSkillups; - } - - /** - * Function that tells if the system is set to broadcast on level up - * @return true - broadcast on level up - * @return false - do not broadcast on level up - */ - public synchronized boolean isBroadcastingLevelups() { - return isBroadcastingLevelups; - } - - /** - * Function that tells if the player should be paid while in creative - * @return true - pay in creative - * @return false - do not pay in creative - */ - public synchronized boolean payInCreative() { - return payInCreative; - } - - /** - * Function that tells if the player should be paid while exploring and flying - * @return true - pay - * @return false - do not - */ - public synchronized boolean payExploringWhenFlying() { - return payExploringWhenFlying; - } - - /** - * Function to return the title for a given level - * @return the correct title - * @return null if no title matches - */ - public Title getTitleForLevel(int level, String jobName) { - Title title = null; - for (Title t : titles) { - if (title == null) { - if (t.getLevelReq() <= level) { - title = t; - } - } else { - if (t.getLevelReq() <= level && t.getLevelReq() > title.getLevelReq()) { - title = t; - } - } - } - return title; - } - - public synchronized boolean addXpPlayer() { - return addXpPlayer; - } - - /** - * Function to check if jobs should be hidden to players that lack permission to join the job - * @return - */ - public synchronized boolean getHideJobsWithoutPermission() { - return hideJobsWithoutPermission; - } - - /** - * Function to return the maximum number of jobs a player can join - * @return - */ - public synchronized int getMaxJobs() { - return maxJobs; - } - - /** - * Function to check if you get paid near a spawner is enabled - * @return true - you get paid - * @return false - you don't get paid - */ - public synchronized boolean payNearSpawner() { - return payNearSpawner; - } - - /** - * Gets the area multiplier for the player - * @param player - * @return - the multiplier - */ - public synchronized double getRestrictedMultiplier(Player player) { - for (RestrictedArea area : restrictedAreas) { - if (area.inRestrictedArea(player)) - return area.getMultiplier(); - } - return 1.0; - } - - public synchronized boolean getModifyChat() { - return modifyChat; - } - - public String getModifyChatPrefix() { - return modifyChatPrefix; - } - - public String getModifyChatSuffix() { - return modifyChatSuffix; - } - - public String getModifyChatSeparator() { - return modifyChatSeparator; - } - - public synchronized int getEconomyBatchDelay() { - return economyBatchDelay; - } - - public synchronized boolean saveOnDisconnect() { - return saveOnDisconnect; - } - - public synchronized Locale getLocale() { - return locale; - } - - public synchronized void reload() { - // general settings - loadGeneralSettings(); - // Load locale - loadLanguage(); - // title settings - loadTitleSettings(); - // restricted areas - loadRestrictedAreaSettings(); - // restricted blocks - loadRestrictedBlocks(); - // Item/Block/mobs name list - loadItemList(); - // signs information - Jobs.getSignUtil().LoadSigns(); - -// loadScheduler(); - } - - /** - * Method to load the general configuration - * - * loads from Jobs/generalConfig.yml - */ - private synchronized void loadGeneralSettings() { - File f = new File(plugin.getDataFolder(), "generalConfig.yml"); - YamlConfiguration config = YamlConfiguration.loadConfiguration(f); - - CommentedYamlConfiguration writer = new CommentedYamlConfiguration(); - StringBuilder header = new StringBuilder(); - header.append("General configuration."); - header.append(System.getProperty("line.separator")); - header.append(" The general configuration for the jobs plugin mostly includes how often the plugin"); - header.append(System.getProperty("line.separator")); - header.append("saves user data (when the user is in the game), the storage method, whether"); - header.append(System.getProperty("line.separator")); - header.append("to broadcast a message to the server when a user goes up a skill level."); - header.append(System.getProperty("line.separator")); - header.append(" It also allows admins to set the maximum number of jobs a player can have at"); - header.append(System.getProperty("line.separator")); - header.append("any one time."); - header.append(System.getProperty("line.separator")); - - config.options().copyDefaults(true); - - writer.options().header(header.toString()); - - writer.addComment("locale-language", "Default language.", "Example: en, ru", "File in locale folder with same name should exist. Example: messages_ru.yml"); - localeString = getString("locale-language", "en", config, writer); - try { - int i = localeString.indexOf('_'); - if (i == -1) { - locale = new Locale(localeString); - } else { - locale = new Locale(localeString.substring(0, i), localeString.substring(i + 1)); - } - } catch (IllegalArgumentException e) { - locale = Locale.getDefault(); - Jobs.getPluginLogger().warning("Invalid locale \"" + localeString + "\" defaulting to " + locale.getLanguage()); - } - - writer.addComment("storage-method", "storage method, can be MySQL, sqlite"); - storageMethod = getString("storage-method", "sqlite", config, writer); - if (storageMethod.equalsIgnoreCase("mysql")) { - startMysql(); - // } else if (storageMethod.equalsIgnoreCase("h2")) { - // File h2jar = new File(plugin.getDataFolder(), "h2.jar"); - // Jobs.getPluginLogger().warning("H2 database no longer supported! Converting to SQLite."); - // if (!h2jar.exists()) { - // Jobs.getPluginLogger().info("H2 library not found, downloading..."); - // try { - // FileDownloader.downloadFile(new URL("http://dev.bukkit.org/media/files/692/88/h2-1.3.171.jar"), h2jar); - // } catch (MalformedURLException e) { - // e.printStackTrace(); - // } catch (IOException e) { - // Jobs.getPluginLogger().severe("Could not download database library!"); - // } - // } - // if (plugin.isEnabled()) { - // try { - // Jobs.getJobsClassloader().addFile(h2jar); - // } catch (IOException e) { - // Jobs.getPluginLogger().severe("Could not load database library!"); - // } - // if (plugin.isEnabled()) { - // try { - // JobsDAOH2.convertToSQLite(); - // Jobs.setDAO(JobsDAOSQLite.initialize()); - // config.set("storage-method", "sqlite"); - // } catch (SQLException e) { - // Jobs.getPluginLogger().severe("Error when converting from H2 to SQLite!"); - // e.printStackTrace(); - // } - // } - // } - } else if (storageMethod.equalsIgnoreCase("sqlite")) { - startSqlite(); - } else { - Jobs.getPluginLogger().warning("Invalid storage method! Changing method to sqlite!"); - config.set("storage-method", "sqlite"); - Jobs.setDAO(JobsDAOSQLite.initialize()); - } - - writer.addComment("mysql-username", "Requires Mysql."); - getString("mysql-username", "root", config, writer); - getString("mysql-password", "", config, writer); - getString("mysql-hostname", "localhost:3306", config, writer); - getString("mysql-database", "minecraft", config, writer); - getString("mysql-table-prefix", "jobs_", config, writer); - - writer.addComment("save-period", "How often in minutes you want it to save. This must be a non-zero number"); - getInt("save-period", 10, config, writer); - if (config.getInt("save-period") <= 0) { - Jobs.getPluginLogger().severe("Save period must be greater than 0! Defaulting to 10 minutes!"); - config.set("save-period", 10); - } - savePeriod = config.getInt("save-period"); - - writer.addComment("save-on-disconnect", "Should player data be saved on disconnect?", - "Player data is always periodically auto-saved and autosaved during a clean shutdown.", - "Only enable this if you have a multi-server setup, or have a really good reason for enabling this.", "Turning this on will decrease database performance."); - saveOnDisconnect = getBoolean("save-on-disconnect", false, config, writer); - - writer.addComment("Optimizations.UseLocalOfflinePlayersData", "With this set to true, offline player data will be taken from local player data files", - "This will eliminate small lag spikes when request is being send to mojangs servers for offline players data", - "Theroticali this should work without issues, but if you havving some, just disable", - "But then you can feal some small (100-200ms) lag spikes while performings some jobs commands"); - LocalOfflinePlayersData = getBoolean("Optimizations.UseLocalOfflinePlayersData", true, config, writer); - - writer.addComment("Logging.Use", "With this set to true all players jobs actions will be logged to database for easy to see statistics", - "This is still in development and in feature it will expand"); - LoggingUse = getBoolean("Logging.Use", false, config, writer); - - writer.addComment("broadcast.on-skill-up.use", "Do all players get a message when somone goes up a skill level?"); - isBroadcastingSkillups = getBoolean("broadcast.on-skill-up.use", false, config, writer); - - writer.addComment("broadcast.on-level-up.use", "Do all players get a message when somone goes up a level?"); - isBroadcastingLevelups = getBoolean("broadcast.on-level-up.use", false, config, writer); - writer.addComment("broadcast.on-level-up.levels", "For what levels you want to broadcast message? Keep it at 0 if you want for all of them"); - BroadcastingLevelUpLevels = getIntArray("broadcast.on-level-up.levels", Arrays.asList(0), config, writer); - - writer.addComment("max-jobs", "Maximum number of jobs a player can join.", "Use 0 for no maximum"); - maxJobs = getInt("max-jobs", 3, config, writer); - - writer.addComment("hide-jobs-without-permission", "Hide jobs from player if they lack the permission to join the job"); - hideJobsWithoutPermission = getBoolean("hide-jobs-without-permission", false, config, writer); - - writer.addComment("hide-jobsinfo-without-permission", "Hide jobs info from player if they lack the permission to join the job"); - hideJobsInfoWithoutPermission = getBoolean("hide-jobsinfo-without-permission", false, config, writer); - - writer.addComment("enable-pay-near-spawner", "Option to allow payment to be made when killing mobs from a spawner"); - payNearSpawner = getBoolean("enable-pay-near-spawner", false, config, writer); - - writer.addComment("pay-near-spawner-multiplier", "enable-pay-near-spawner should be enabled for this to work", - "0.5 means that players will get only 50% exp/money from monsters spawned from spawner"); - payNearSpawnerMultiplier = getDouble("pay-near-spawner-multiplier", 1.0, config, writer); - - writer.addComment("VIP-pay-near-spawner-multiplier", "VIP multiplier to pay for monsters from spawners, this will ignore global multiplier", - "Use jobs.vipspawner permission node for this to be enabled"); - VIPpayNearSpawnerMultiplier = getDouble("VIP-pay-near-spawner-multiplier", 1.0, config, writer); - - writer.addComment("enable-pay-creative", "Option to allow payment to be made in creative mode"); - payInCreative = getBoolean("enable-pay-creative", false, config, writer); - - writer.addComment("enable-pay-for-exploring-when-flying", "Option to allow payment to be made for exploring when player flyies"); - payExploringWhenFlying = getBoolean("enable-pay-for-exploring-when-flying", false, config, writer); - - writer.addComment("add-xp-player", "Adds the Jobs xp recieved to the player's Minecraft XP bar"); - addXpPlayer = getBoolean("add-xp-player", false, config, writer); - - writer.addComment("modify-chat", - "Modifys chat to add chat titles. If you're using a chat manager, you may add the tag {jobs} to your chat format and disable this."); - modifyChat = getBoolean("modify-chat", true, config, writer); - - modifyChatPrefix = getString("modify-chat-prefix", "&c[", config, writer, true); - modifyChatSuffix = getString("modify-chat-suffix", "&c]", config, writer, true); - modifyChatSeparator = getString("modify-chat-separator", " ", config, writer, true); - - writer.addComment("UseCustomNames", "Do you want to use custom item/block/mob/enchant/color names", - "With this set to true names like Stone:1 will be translated to Granite", "Name list is in ItemList.yml file"); - UseCustomNames = getBoolean("UseCustomNames", true, config, writer); - - writer.addComment("economy-batch-delay", "Changes how often, in seconds, players are paid out. Default is 5 seconds.", - "Setting this too low may cause tick lag. Increase this to improve economy performance (at the cost of delays in payment)"); - economyBatchDelay = getInt("economy-batch-delay", 5, config, writer); - - writer.addComment("economy-async", "Enable async economy calls.", "Disable this if you have issues with payments or your plugin is not thread safe."); - economyAsync = getBoolean("economy-async", true, config, writer); - - writer.addComment("Economy.MinimumOveralPayment.use", - "Determines minimum payment. In example if player uses McMMO treefeller and earns only 20%, but at same time he gets 25% penalty from dynamic payment. He can 'get' negative amount of money", - "This will limit it to particular percentage", "Works only when original payment is above 0"); - useMinimumOveralPayment = getBoolean("Economy.MinimumOveralPayment.use", true, config, writer); - MinimumOveralPaymentLimit = getDouble("Economy.MinimumOveralPayment.limit", 0.1, config, writer); - - writer.addComment("Economy.DynamicPayment.use", "Do you want to use dinamic payment dependent on how many players already working for jobs", - "This can help automaticaly lift up payments for not so popular jobs and lower for most popular ones"); - useDynamicPayment = getBoolean("Economy.DynamicPayment.use", false, config, writer); - - String maxExpEquationInput = getString("Economy.DynamicPayment.equation", "((totalworkers / totaljobs) - jobstotalplayers)/10.0", config, writer); - try { - DynamicPaymentEquation = new Parser(maxExpEquationInput); - // test equation - DynamicPaymentEquation.setVariable("totalworkers", 100); - DynamicPaymentEquation.setVariable("totaljobs", 10); - DynamicPaymentEquation.setVariable("jobstotalplayers", 10); - DynamicPaymentEquation.getValue(); - } catch (Exception e) { - Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Dynamic payment equation has an invalid property. Disabling feature!"); - useDynamicPayment = false; - } - - DynamicPaymentMaxPenalty = getDouble("Economy.DynamicPayment.MaxPenalty", 25.0, config, writer); - DynamicPaymentMaxBonus = getDouble("Economy.DynamicPayment.MaxBonus", 100.0, config, writer); - - writer.addComment("Economy.EnabledJobsToglle", "Do you want to enable jobs toggle by default"); - JobsToggleEnabled = getBoolean("Economy.EnabledJobsToglle", true, config, writer); - - writer.addComment("Economy.UseServerAcount", "Server economy acount", "With this enabled, players will get money from defined user (server account)", - "If this acount dont have enough money to pay for players for, player will get message"); - UseServerAccount = getBoolean("Economy.UseServerAcount", false, config, writer); - writer.addComment("Economy.AcountName", "Username should be with Correct capitalization"); - ServerAcountName = getString("Economy.AcountName", "Server", config, writer); - writer.addComment("Economy.Taxes.use", "Do you want to use taxes feature for jobs payment"); - UseTaxes = getBoolean("Economy.Taxes.use", false, config, writer); - writer.addComment("Economy.Taxes.AccountName", "Username should be with Correct capitalization, it can be same as settup in server account before"); - ServertaxesAcountName = getString("Economy.Taxes.AccountName", "Server", config, writer); - writer.addComment("Economy.Taxes.Amount", "Amount in percentage"); - TaxesAmount = getDouble("Economy.Taxes.Amount", 15.0, config, writer); - writer.addComment("Economy.Taxes.TransferToServerAccount", "Do you want to transfer taxes to server account"); - TransferToServerAccount = getBoolean("Economy.Taxes.TransferToServerAccount", true, config, writer); - writer.addComment("Economy.Taxes.TakeFromPlayersPayment", - "With this true, taxes will be taken from players payment and he will get less money than its shown in jobs info", - "When its false player will get full payment and server account will get taxes amount to hes account"); - TakeFromPlayersPayment = getBoolean("Economy.Taxes.TakeFromPlayersPayment", false, config, writer); - - writer.addComment("Economy.Limit.Money", "Money gain limit", "With this enabled, players will be limited how much they can make in defined time", - "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours"); - EconomyLimitUse = getBoolean("Economy.Limit.Money.Use", false, config, writer); - writer.addComment("Economy.Limit.Money.StopWithExp", "Do you want to stop money gain when exp limit reached?"); - EconomyMoneyStop = getBoolean("Economy.Limit.Money.StopWithExp", false, config, writer); - - writer.addComment("Economy.Limit.Money.MoneyLimit", - "Equation to calculate max money limit. Option to use totallevel to include players total amount levels of current jobs", - "You can always use simple number to set money limit", - "Default equation is: 500+500*(totallevel/100), this will add 1% from 500 for each level player have", - "So player with 2 jobs with level 15 and 22 will have 685 limit"); - String MoneyLimit = getString("Economy.Limit.Money.MoneyLimit", "500+500*(totallevel/100)", config, writer); - try { - maxMoneyEquation = new Parser(MoneyLimit); - maxMoneyEquation.setVariable("totallevel", 1); - maxMoneyEquation.getValue(); - } catch (Exception e) { - Jobs.getPluginLogger().warning("MoneyLimit has an invalid value. Disabling money limit!"); - EconomyLimitUse = false; - } - - writer.addComment("Economy.Limit.Money.TimeLimit", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours"); - EconomyLimitTimeLimit = getInt("Economy.Limit.Money.TimeLimit", 3600, config, writer); - writer.addComment("Economy.Limit.Money.AnnouncmentDelay", "Delay between announcements about reached money limit", - "Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying"); - EconomyLimitAnnouncmentDelay = getInt("Economy.Limit.Money.AnnouncmentDelay", 30, config, writer); - - writer.addComment("Economy.Limit.Exp", "Exp gain limit", "With this enabled, players will be limited how much they can get in defined time", - "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours"); - EconomyExpLimitUse = getBoolean("Economy.Limit.Exp.Use", false, config, writer); - writer.addComment("Economy.Limit.Exp.StopWithMoney", "Do you want to stop exp gain when money limit reached?"); - EconomyExpStop = getBoolean("Economy.Limit.Exp.StopWithMoney", false, config, writer); - - writer.addComment("Economy.Limit.Exp.Limit", "Equation to calculate max money limit. Option to use totallevel to include players total amount of current jobs", - "You can always use simple number to set exp limit", - "Default equation is: 5000+5000*(totallevel/100), this will add 1% from 5000 for each level player have", - "So player with 2 jobs with level 15 and 22 will have 6850 limit"); - String expLimit = getString("Economy.Limit.Exp.Limit", "5000+5000*(totallevel/100)", config, writer); - try { - maxExpEquation = new Parser(expLimit); - maxExpEquation.setVariable("totallevel", 1); - maxExpEquation.getValue(); - } catch (Exception e) { - Jobs.getPluginLogger().warning("ExpLimit has an invalid value. Disabling money limit!"); - EconomyExpLimitUse = false; - } - - writer.addComment("Economy.Limit.Exp.TimeLimit", "Time in seconds: 60 = 1min, 3600 = 1 hour, 86400 = 24 hours"); - EconomyExpTimeLimit = getInt("Economy.Limit.Exp.TimeLimit", 3600, config, writer); - writer.addComment("Economy.Limit.Exp.AnnouncmentDelay", "Delay between announcements about reached Exp limit", - "Keep this from 30 to 5 min (300), as players can get annoyed of constant message displaying"); - EconomyLimitAnnouncmentExpDelay = getInt("Economy.Limit.Exp.AnnouncmentDelay", 30, config, writer); - - writer.addComment("Economy.Repair.PayForRenaming", "Do you want to give money for only renaming items in anvil", - "Players will get full pay as they would for remairing two items when they only renaming one", - "This is not big issue, but if you want to disable it, you can"); - PayForRenaming = getBoolean("Economy.Repair.PayForRenaming", true, config, writer); - - writer.addComment("Economy.Crafting.PayForEachCraft", - "With this true, player will get money for all crafted items instead of each crafting action (like with old payment mechanic)", - "By default its false, as you can make ALOT of money if prices kept from old payment mechanics"); - PayForEachCraft = getBoolean("Economy.Crafting.PayForEachCraft", false, config, writer); - - writer.addComment("Economy.MilkingCow.CancelMilking", "With this true, when timer is still going, cow milking event will be canceled", - "With this false, player will get bucket of milk, but still no payment"); - CancelCowMilking = getBoolean("Economy.MilkingCow.CancelMilking", false, config, writer); - writer.addComment("Economy.MilkingCow.Timer", - "How ofter player can milk cows in seconds. Keep in mind that by default player can milk cow indefinetly and as often as he wants", - "Set to 0 if you want to disable timer"); - CowMilkingTimer = getInt("Economy.MilkingCow.Timer", 30, config, writer) * 1000; - - writer.addComment("ExploitProtections.Coreprotect.Use", - "Requires to have CoreProtect plugin and there should be block place/break logging enabled in core protect config file.", - "This will prevent players from abusing by placing and breaking blocks again and again", "This will work even after server restart"); - useCoreProtect = getBoolean("ExploitProtections.Coreprotect.Use", false, config, writer); - writer.addComment("ExploitProtections.Coreprotect.TimeLimit", "Time limit in minutes to protect blocks from repeating place/breake action.", - "10080 equals to 7 days, keep it in reasonable time range"); - CoreProtectInterval = getInt("ExploitProtections.Coreprotect.TimeLimit", 604800, config, writer); - - writer.addComment("ExploitProtections.Coreprotect.BlockPlace.Use", "Do you want to use block place interval protection"); - BlockPlaceUse = getBoolean("ExploitProtections.Coreprotect.BlockPlace.Use", true, config, writer); - EnableAnounceMessage = getBoolean("ExploitProtections.Coreprotect.BlockPlace.EnableAnounceMessage", true, config, writer); - writer.addComment("ExploitProtections.Coreprotect.BlockPlace.Interval", "Time interval in seconds in how fast you can place block in same place.", - "Keep it on low interval, 3-5 sec will be enough to prevent fast block place in same place and dont annoy peps", - "Edit block list in restrictedBlocks.yml under PlacedBlockTimer"); - BlockPlaceInterval = getInt("ExploitProtections.Coreprotect.BlockPlace.Interval", 2, config, writer); - - writer.addComment("ExploitProtections.General.PlaceAndBreakProtection", - "Enable blocks protection, like ore, from exploiting by placing and destroying same block again and again.", "This works only until server restart", - "Modify restrictedBlocks.yml for blocks you want to protect"); - useBlockProtection = getBoolean("ExploitProtections.General.PlaceAndBreakProtection", true, config, writer); - - writer.addComment("ExploitProtections.General.SilkTouchProtection", "Enable silk touch protection.", - "With this enabled players wont get paid for breaked blocks from restrictedblocks list with silk touch tool."); - useSilkTouchProtection = getBoolean("ExploitProtections.General.SilkTouchProtection", false, config, writer); - - writer.addComment("ExploitProtections.General.StopPistonBlockMove", "Enable piston moving blocks from restrictedblocks list.", - "If piston moves block then it will be like new block and BlockPlaceAndBreakProtection wont work properly", - "If you using core protect and its being logging piston block moving, then you can disable this"); - useBlockPiston = getBoolean("ExploitProtections.General.StopPistonBlockMove", true, config, writer); - - writer.addComment("ExploitProtections.General.BlocksTimer", "Enable blocks timer protection.", - "Only enable if you want to protect block from beying broken to fast, useful for vegetables.", "Modify restrictedBlocks.yml for blocks you want to protect"); - useBlockTimer = getBoolean("ExploitProtections.General.BlocksTimer", true, config, writer); - - writer.addComment("ExploitProtections.General.GlobalBlockTimer", "All blocks will be protected X sec after player places it on ground."); - useGlobalTimer = getBoolean("ExploitProtections.General.GlobalBlockTimer.use", false, config, writer); - globalblocktimer = getInt("ExploitProtections.General.GlobalBlockTimer.timer", 30, config, writer); - - writer.addComment("ExploitProtections.General.PetPay", "Do you want to pay when players pet kills monster/player", "Can be exploited with mob farms", - "0.2 means 20% of original reward", "Optionaly you can give jobs.petpay permission node for specific players/ranks to get paid by VipPetPay multiplier"); - PetPay = getDouble("ExploitProtections.General.PetPay", 0.1, config, writer); - VipPetPay = getDouble("ExploitProtections.General.VipPetPay", 1.0, config, writer); - - writer.addComment("ExploitProtections.McMMO", "McMMO abilities"); - writer.addComment("ExploitProtections.McMMO.TreeFellerMultiplier", "Players will get part of money from cutting trees with treefeller ability enabled.", - "0.2 means 20% of original price"); - TreeFellerMultiplier = getDouble("ExploitProtections.McMMO.TreeFellerMultiplier", 0.2, config, writer); - writer.addComment("ExploitProtections.McMMO.gigaDrillMultiplier", "Players will get part of money from braking blocks with gigaDrill ability enabled.", - "0.2 means 20% of original price"); - gigaDrillMultiplier = getDouble("ExploitProtections.McMMO.gigaDrillMultiplier", 0.2, config, writer); - writer.addComment("ExploitProtections.McMMO.superBreakerMultiplier", "Players will get part of money from braking blocks with super breaker ability enabled.", - "0.2 means 20% of original price"); - superBreakerMultiplier = getDouble("ExploitProtections.McMMO.superBreakerMultiplier", 0.2, config, writer); - - writer.addComment("ExploitProtections.MythicMobs", "MythicMobs plugin support", "Disable if you having issues with it or using old version"); - MythicMobsEnabled = getBoolean("ExploitProtections.MythicMobs.enabled", true, config, writer); - - writer.addComment("ExploitProtections.Spawner.PreventSlimeSplit", "Prevent slime spliting when they are from spawner", - "Protects agains exploiting as new splited slimes is treated as naturaly spawned and not from spawner"); - PreventSlimeSplit = getBoolean("ExploitProtections.Spawner.PreventSlimeSplit", true, config, writer); - writer.addComment("ExploitProtections.Spawner.PreventMagmaCubeSplit", "Prevent magmacube spliting when they are from spawner"); - PreventMagmaCubeSplit = getBoolean("ExploitProtections.Spawner.PreventMagmaCubeSplit", true, config, writer); - - writer.addComment("ExploitProtections.WaterBlockBreake", - "Prevent water braking placed blocks. Protection resets with server restart or after plants grows to next stage with bone powder or naturally", - "For strange reason works only 5 of 10 times, but this is completely enough to prevent exploiting"); - WaterBlockBreake = getBoolean("ExploitProtections.WaterBlockBreake", true, config, writer); - - writer.addComment("use-breeder-finder", "Breeder finder.", - "If you are not using breeding payment, you can disable this to save little resources. Really little."); - useBreederFinder = getBoolean("use-breeder-finder", true, config, writer); - - writer.addComment("boost", "Money exp boost with special permision.", "You will need to add special permision for groups or players to have money/exp boost.", - "Use: jobs.boost.[jobname].money or jobs.boost.[jobname].exp or jobs.boost.[jobname].both for both of them with specific jobs name.", - "Use: jobs.boost.all.money or jobs.boost.all.exp or jobs.boost.all.both to get boost for all jobs", - "1.25 means that player will get 25% more than others, you can set less than 1 to get less from anothers"); - BoostExp = getDouble("boost.exp", 1.25, config, writer); - BoostMoney = getDouble("boost.money", 1.25, config, writer); - - writer.addComment("old-job", "Old job save", "Players can leave job and return later with some level loss during that", - "You can fix players level if hes job level is at max level"); - levelLossPercentage = getInt("old-job.level-loss-percentage", 30, config, writer); - fixAtMaxLevel = getBoolean("old-job.fix-at-max-level", true, config, writer); - - writer.addComment("ActionBars", "Action bars", "You can enable/disable togglebale message by player with /jobs toggle"); - ToggleActionBar = getBoolean("ActionBars.Toggle", true, config, writer); - - writer.addComment("ShowActionBars", "You can enable/disable message shown for players in action bar"); - TitleChangeActionBar = getBoolean("ShowActionBars.OnTitleChange", true, config, writer); - LevelChangeActionBar = getBoolean("ShowActionBars.OnLevelChange", true, config, writer); - EmptyServerAcountActionBar = getBoolean("ShowActionBars.OnEmptyServerAcount", true, config, writer); - - writer.addComment("ShowChatMessage", "Chat messages", "You can enable/disable message shown for players in chat"); - TitleChangeChat = getBoolean("ShowChatMessage.OnTitleChange", true, config, writer); - LevelChangeChat = getBoolean("ShowChatMessage.OnLevelChange", true, config, writer); - EmptyServerAcountChat = getBoolean("ShowChatMessage.OnEmptyServerAcount", true, config, writer); - - writer.addComment("Sounds", "Sounds", "Extra sounds on some events", "All sounds can be found in https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html"); - SoundLevelupUse = getBoolean("Sounds.LevelUp.use", true, config, writer); - SoundLevelupSound = getString("Sounds.LevelUp.sound", "LEVEL_UP", config, writer); - SoundLevelupVolume = getInt("Sounds.LevelUp.volume", 1, config, writer); - SoundLevelupPitch = getInt("Sounds.LevelUp.pitch", 3, config, writer); - SoundTitleChangeUse = getBoolean("Sounds.TitleChange.use", true, config, writer); - SoundTitleChangeSound = getString("Sounds.TitleChange.sound", "LEVEL_UP", config, writer); - SoundTitleChangeVolume = getInt("Sounds.TitleChange.volume", 1, config, writer); - SoundTitleChangePitch = getInt("Sounds.TitleChange.pitch", 3, config, writer); - - writer.addComment("Signs", "You can disable this to save SMALL amount of server resources"); - SignsEnabled = getBoolean("Signs.Enable", true, config, writer); - SignsColorizeJobName = getBoolean("Signs.Colors.ColorizeJobName", true, config, writer); - writer.addComment("Signs.InfoUpdateInterval", - "This is interval in sec in which signs will be updated. This is not continues update, signs are updated only on levelup, job leave, job join or similar action."); - writer.addComment("Signs.InfoUpdateInterval", - "This is update for same job signs, to avoid huge lag if you have bunch of same type signs. Keep it from 1 to as many sec you want"); - InfoUpdateInterval = getInt("Signs.InfoUpdateInterval", 5, config, writer); - - writer.addComment("Scoreboard.ShowToplist", "This will enables to show top list in scoreboard instead of chat"); - ShowToplistInScoreboard = getBoolean("Scoreboard.ShowToplist", true, config, writer); - writer.addComment("Scoreboard.interval", "For how long to show scoreboard"); - ToplistInScoreboardInterval = getInt("Scoreboard.interval", 10, config, writer); - - writer.addComment("JobsBrowse.ShowTotalWorkers", "Do you want to show total amount of workers for job in jobs browse window"); - ShowTotalWorkers = getBoolean("JobsBrowse.ShowTotalWorkers", true, config, writer); - writer.addComment("JobsBrowse.ShowPenaltyBonus", "Do you want to show penalty and bonus in jobs browse window. Only works if this feature is enabled"); - ShowPenaltyBonus = getBoolean("JobsBrowse.ShowPenaltyBonus", true, config, writer); - - writer.addComment("JobsGUI.OpenOnBrowse", "Do you want to show GUI when performing /jobs browse command"); - JobsGUIOpenOnBrowse = getBoolean("JobsGUI.OpenOnBrowse", true, config, writer); - writer.addComment("JobsGUI.ShowChatBrowse", "Do you want to show chat information when performing /jobs browse command"); - JobsGUIShowChatBrowse = getBoolean("JobsGUI.ShowChatBrowse", true, config, writer); - writer.addComment("JobsGUI.SwitcheButtons", "With true left mouse button will join job and right will show more info", - "With false left mouse button will show more info, rigth will join job", "Dont forget to adjust locale file"); - JobsGUISwitcheButtons = getBoolean("JobsGUI.SwitcheButtons", false, config, writer); - writer.addComment("JobsBrowse.ShowPenaltyBonus", "Do you want to show GUI when performing /jobs join command"); - JobsGUIOpenOnJoin = getBoolean("JobsGUI.OpenOnJoin", true, config, writer); - - writer.addComment("Schedule.Boost.Enable", "Do you want to enable scheduler for global boost"); - useGlobalBoostScheduler = getBoolean("Schedule.Boost.Enable", false, config, writer); - - // writer.addComment("Gui.UseJobsBrowse", "Do you want to use jobs browse gui instead of chat text"); - // UseJobsBrowse = getBoolean("Gui.UseJobsBrowse", true, config, writer); - - // Write back config - try { - writer.save(f); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public synchronized void startMysql() { - File f = new File(plugin.getDataFolder(), "generalConfig.yml"); - YamlConfiguration config = YamlConfiguration.loadConfiguration(f); - String legacyUrl = config.getString("mysql-url"); - if (legacyUrl != null) { - String jdbcString = "jdbc:mysql://"; - if (legacyUrl.toLowerCase().startsWith(jdbcString)) { - legacyUrl = legacyUrl.substring(jdbcString.length()); - String[] parts = legacyUrl.split("/"); - if (parts.length >= 2) { - config.set("mysql-hostname", parts[0]); - config.set("mysql-database", parts[1]); - } - } - } - String username = config.getString("mysql-username"); - if (username == null) { - Jobs.getPluginLogger().severe("mysql-username property invalid or missing"); - } - String password = config.getString("mysql-password"); - String hostname = config.getString("mysql-hostname"); - String database = config.getString("mysql-database"); - String prefix = config.getString("mysql-table-prefix"); - if (plugin.isEnabled()) - Jobs.setDAO(JobsDAOMySQL.initialize(hostname, database, username, password, prefix)); - } - - public synchronized void startSqlite() { - Jobs.setDAO(JobsDAOSQLite.initialize()); - } - - public synchronized void copySetting(Configuration reader, Configuration writer, String path) { - writer.set(path, reader.get(path)); - } - - /** - * Method to load the title configuration - * - * loads from Jobs/titleConfig.yml - */ - private synchronized void loadTitleSettings() { - this.titles.clear(); - File f = new File(plugin.getDataFolder(), "titleConfig.yml"); - YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); - StringBuilder header = new StringBuilder().append("Title configuration").append(System.getProperty("line.separator")).append(System.getProperty("line.separator")) - .append("Stores the titles people gain at certain levels.").append(System.getProperty("line.separator")).append( - "Each title requres to have a name, short name (used when the player has more than").append(System.getProperty("line.separator")).append( - "1 job) the colour of the title and the level requrirement to attain the title.").append(System.getProperty("line.separator")).append(System - .getProperty("line.separator")).append("It is recommended but not required to have a title at level 0.").append(System.getProperty( - "line.separator")).append(System.getProperty("line.separator")).append("Titles are completely optional.").append(System.getProperty( - "line.separator")).append("Posible variable are {level} to add current jobs level.").append(System.getProperty("line.separator")).append( - System.getProperty("line.separator")).append("Titles:").append(System.getProperty("line.separator")).append(" Apprentice:").append( - System.getProperty("line.separator")).append(" Name: Apprentice").append(System.getProperty("line.separator")).append( - " ShortName: A").append(System.getProperty("line.separator")).append(" ChatColour: WHITE").append(System.getProperty( - "line.separator")).append(" levelReq: 0").append(System.getProperty("line.separator")).append(" Novice:").append( - System.getProperty("line.separator")).append(" Name: Novice").append(System.getProperty("line.separator")).append( - " ShortName: N").append(System.getProperty("line.separator")).append(" ChatColour: GRAY").append(System - .getProperty("line.separator")).append(" levelReq: 30").append(System.getProperty("line.separator")) - .append(" Journeyman:").append(System.getProperty("line.separator")).append(" Name: Journeyman").append(System.getProperty("line.separator")).append( - " ShortName: J").append(System.getProperty("line.separator")).append(" ChatColour: GOLD").append(System.getProperty("line.separator")).append( - " levelReq: 60").append(System.getProperty("line.separator")).append(" Master:").append(System.getProperty("line.separator")).append( - " Name: Master").append(System.getProperty("line.separator")).append(" ShortName: '{level} M'").append(System.getProperty("line.separator")) - .append(" ChatColour: BLACK").append(System.getProperty("line.separator")).append(" levelReq: 90").append(System.getProperty("line.separator")).append( - System.getProperty("line.separator")); - conf.options().header(header.toString()); - conf.options().copyDefaults(true); - conf.options().indent(2); - - ConfigurationSection titleSection = conf.getConfigurationSection("Titles"); - if (titleSection == null) { - titleSection = conf.createSection("Titles"); - } - for (String titleKey : titleSection.getKeys(false)) { - String jobName = null; - String titleName = titleSection.getString(titleKey + ".Name"); - String titleShortName = titleSection.getString(titleKey + ".ShortName"); - ChatColor titleColor = ChatColor.matchColor(titleSection.getString(titleKey + ".ChatColour", "")); - int levelReq = titleSection.getInt(titleKey + ".levelReq", -1); - - if (titleSection.isString(titleKey + ".JobName")) { - jobName = titleSection.getString(titleKey + ".JobName"); - } - - if (titleName == null) { - Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid Name property. Skipping!"); - continue; - } - - if (titleShortName == null) { - Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid ShortName property. Skipping!"); - continue; - } - if (titleColor == null) { - Jobs.getPluginLogger().severe("Title " + titleKey + "has an invalid ChatColour property. Skipping!"); - continue; - } - if (levelReq <= -1) { - Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid levelReq property. Skipping!"); - continue; - } - - this.titles.add(new Title(titleName, titleShortName, titleColor, levelReq, jobName)); - } - - try { - conf.save(f); - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Method to load the restricted areas configuration - * - * loads from Jobs/restrictedAreas.yml - */ - private synchronized void loadRestrictedAreaSettings() { - this.restrictedAreas.clear(); - File f = new File(plugin.getDataFolder(), "restrictedAreas.yml"); - YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); - conf.options().indent(2); - conf.options().copyDefaults(true); - StringBuilder header = new StringBuilder(); - - header.append("Restricted area configuration"); - header.append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append( - "Configures restricted areas where you cannot get experience or money").append(System.getProperty("line.separator")).append("when performing a job.").append( - System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("The multiplier changes the experience/money gains in an area.") - .append(System.getProperty("line.separator")).append("A multiplier of 0.0 means no money or xp, while 0.5 means you will get half the normal money/exp") - .append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("restrictedareas:").append(System.getProperty( - "line.separator")).append(" area1:").append(System.getProperty("line.separator")).append(" world: 'world'").append(System.getProperty( - "line.separator")).append(" multiplier: 0.0").append(System.getProperty("line.separator")).append(" point1:").append(System.getProperty( - "line.separator")).append(" x: 125").append(System.getProperty("line.separator")).append(" y: 0").append(System.getProperty( - "line.separator")).append(" z: 125").append(System.getProperty("line.separator")).append(" point2:").append(System.getProperty( - "line.separator")).append(" x: 150").append(System.getProperty("line.separator")).append(" y: 100").append(System.getProperty( - "line.separator")).append(" z: 150").append(System.getProperty("line.separator")).append(" area2:").append(System.getProperty( - "line.separator")).append(" world: 'world_nether'").append(System.getProperty("line.separator")).append(" multiplier: 0.0") - .append(System.getProperty("line.separator")).append(" point1:").append(System.getProperty("line.separator")).append(" x: -100").append(System - .getProperty("line.separator")).append(" y: 0").append(System.getProperty("line.separator")).append(" z: -100").append(System.getProperty( - "line.separator")).append(" point2:").append(System.getProperty("line.separator")).append(" x: -150").append(System.getProperty( - "line.separator")).append(" y: 100").append(System.getProperty("line.separator")).append(" z: -150"); - conf.options().header(header.toString()); - ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas"); - if (areaSection != null) { - for (String areaKey : areaSection.getKeys(false)) { - String worldName = conf.getString("restrictedareas." + areaKey + ".world"); - double multiplier = conf.getDouble("restrictedareas." + areaKey + ".multiplier", 0.0); - World world = Bukkit.getServer().getWorld(worldName); - if (world == null) - continue; - Location point1 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point1.x", 0.0), conf.getDouble("restrictedareas." + areaKey - + ".point1.y", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point1.z", 0.0)); - - Location point2 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point2.x", 0.0), conf.getDouble("restrictedareas." + areaKey - + ".point2.y", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point2.z", 0.0)); - this.restrictedAreas.add(new RestrictedArea(point1, point2, multiplier)); - } - } - try { - conf.save(f); - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Method to load the restricted areas configuration - * - * loads from Jobs/restrictedAreas.yml - */ - private synchronized void loadRestrictedBlocks() { - File f = new File(plugin.getDataFolder(), "restrictedBlocks.yml"); - YamlConfiguration config = YamlConfiguration.loadConfiguration(f); - - CommentedYamlConfiguration writer = new CommentedYamlConfiguration(); - - config.options().copyDefaults(true); - - writer.addComment("restrictedblocks", "All block to be protected from place/break exploit.", "This will prevent piston moving all blocks in list", - "Dont count in vegetables or any single click break blocks"); - restrictedBlocks.add("14"); - restrictedBlocks.add("15"); - restrictedBlocks.add("16"); - restrictedBlocks.add("21"); - restrictedBlocks.add("48"); - restrictedBlocks.add("56"); - restrictedBlocks.add("73"); - restrictedBlocks.add("74"); - restrictedBlocks.add("129"); - restrictedBlocks.add("153"); - config.addDefault("restrictedblocks", restrictedBlocks); - restrictedBlocks = (ArrayList<String>) config.getStringList("restrictedblocks"); - copySetting(config, writer, "restrictedblocks"); - - writer.addComment("blockstimer", "Block protected by timer in sec", - "141-60 means that carrot can be harvested after 60 sec (remember to use id's from placed objects, not from your inventory)"); - restrictedBlocksTimer.add("2-60"); - restrictedBlocksTimer.add("3-60"); - restrictedBlocksTimer.add("6-60"); - restrictedBlocksTimer.add("12-60"); - restrictedBlocksTimer.add("18-60"); - restrictedBlocksTimer.add("31-60"); - restrictedBlocksTimer.add("32-60"); - restrictedBlocksTimer.add("37-60"); - restrictedBlocksTimer.add("38-60"); - restrictedBlocksTimer.add("39-60"); - restrictedBlocksTimer.add("40-60"); - restrictedBlocksTimer.add("55-60"); - restrictedBlocksTimer.add("59-60"); - restrictedBlocksTimer.add("80-60"); - restrictedBlocksTimer.add("81-60"); - restrictedBlocksTimer.add("83-60"); - restrictedBlocksTimer.add("103-60"); - restrictedBlocksTimer.add("106-60"); - restrictedBlocksTimer.add("111-60"); - restrictedBlocksTimer.add("141-60"); - restrictedBlocksTimer.add("142-60"); - restrictedBlocksTimer.add("161-60"); - restrictedBlocksTimer.add("171-60"); - restrictedBlocksTimer.add("175-60"); - config.addDefault("blockstimer", restrictedBlocksTimer); - restrictedBlocksTimer = (ArrayList<String>) config.getStringList("blockstimer"); - copySetting(config, writer, "blockstimer"); - - writer.addComment("PlacedBlockTimer", "Block place protected by timer in sec", "For this to work CoreProtect plugin should be installed"); - restrictedPlaceBlocksTimer.add(2); - restrictedPlaceBlocksTimer.add(3); - restrictedPlaceBlocksTimer.add(6); - restrictedPlaceBlocksTimer.add(12); - restrictedPlaceBlocksTimer.add(18); - restrictedPlaceBlocksTimer.add(31); - restrictedPlaceBlocksTimer.add(32); - restrictedPlaceBlocksTimer.add(37); - restrictedPlaceBlocksTimer.add(38); - restrictedPlaceBlocksTimer.add(39); - restrictedPlaceBlocksTimer.add(40); - restrictedPlaceBlocksTimer.add(55); - restrictedPlaceBlocksTimer.add(59); - restrictedPlaceBlocksTimer.add(80); - restrictedPlaceBlocksTimer.add(81); - restrictedPlaceBlocksTimer.add(83); - restrictedPlaceBlocksTimer.add(103); - restrictedPlaceBlocksTimer.add(106); - restrictedPlaceBlocksTimer.add(111); - restrictedPlaceBlocksTimer.add(141); - restrictedPlaceBlocksTimer.add(142); - restrictedPlaceBlocksTimer.add(161); - restrictedPlaceBlocksTimer.add(171); - restrictedPlaceBlocksTimer.add(175); - config.addDefault("PlacedBlockTimer", restrictedPlaceBlocksTimer); - restrictedPlaceBlocksTimer = (ArrayList<Integer>) config.getIntegerList("PlacedBlockTimer"); - copySetting(config, writer, "PlacedBlockTimer"); - - writer.addComment("PlacedBlockTimer", "Block place protected by timer in sec", "For this to work CoreProtect plugin should be installed"); - restrictedPlaceBlocksTimer.add(2); - restrictedPlaceBlocksTimer.add(3); - restrictedPlaceBlocksTimer.add(6); - restrictedPlaceBlocksTimer.add(12); - restrictedPlaceBlocksTimer.add(18); - restrictedPlaceBlocksTimer.add(31); - restrictedPlaceBlocksTimer.add(32); - restrictedPlaceBlocksTimer.add(37); - restrictedPlaceBlocksTimer.add(38); - restrictedPlaceBlocksTimer.add(39); - restrictedPlaceBlocksTimer.add(40); - restrictedPlaceBlocksTimer.add(55); - restrictedPlaceBlocksTimer.add(59); - restrictedPlaceBlocksTimer.add(80); - restrictedPlaceBlocksTimer.add(81); - restrictedPlaceBlocksTimer.add(83); - restrictedPlaceBlocksTimer.add(103); - restrictedPlaceBlocksTimer.add(106); - restrictedPlaceBlocksTimer.add(111); - restrictedPlaceBlocksTimer.add(141); - restrictedPlaceBlocksTimer.add(142); - restrictedPlaceBlocksTimer.add(161); - restrictedPlaceBlocksTimer.add(171); - restrictedPlaceBlocksTimer.add(175); - config.addDefault("PlacedBlockTimer", restrictedPlaceBlocksTimer); - restrictedPlaceBlocksTimer = (ArrayList<Integer>) config.getIntegerList("PlacedBlockTimer"); - copySetting(config, writer, "PlacedBlockTimer"); - - try { - writer.save(f); - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Method to load the scheduler configuration - * - * loads from Jobs/schedule.yml - */ - public void loadScheduler() { - File f = new File(plugin.getDataFolder(), "schedule.yml"); - YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); - - conf.options().copyDefaults(true); - - if (!conf.contains("Boost")) - return; - - ArrayList<String> sections = new ArrayList<String>(conf.getConfigurationSection("Boost").getKeys(false)); - - for (String OneSection : sections) { - ConfigurationSection path = conf.getConfigurationSection("Boost." + OneSection); - - if (!path.contains("Enabled")) - continue; - - if (!conf.getConfigurationSection("Boost." + OneSection).getBoolean("Enabled")) - continue; - - Schedule sched = new Schedule(); - sched.setName(OneSection); - - if (!path.contains("From") || !path.getString("From").contains(":")) - continue; - - if (!path.contains("Until") || !path.getString("Until").contains(":")) - continue; - - if (!path.contains("Days") || !path.isList("Days")) - continue; - - if (!path.contains("Jobs") || !path.isList("Jobs")) - continue; - - if (!path.contains("Exp") || !path.isDouble("Exp")) - continue; - - if (!path.contains("Money") || !path.isDouble("Money")) - continue; - - sched.setDays(path.getStringList("Days")); - sched.setJobs(path.getStringList("Jobs")); - sched.setFrom(Integer.valueOf(path.getString("From").replace(":", ""))); - sched.setUntil(Integer.valueOf(path.getString("Until").replace(":", ""))); - - if (path.contains("MessageOnStart") && path.isList("MessageOnStart")) - sched.setMessageOnStart(path.getStringList("MessageOnStart"), path.getString("From"), path.getString("Until")); - - if (path.contains("BroadcastOnStart")) - sched.setBroadcastOnStart(path.getBoolean("BroadcastOnStart")); - - if (path.contains("MessageOnStop") && path.isList("MessageOnStop")) - sched.setMessageOnStop(path.getStringList("MessageOnStop"), path.getString("From"), path.getString("Until")); - - if (path.contains("BroadcastOnStop")) - sched.setBroadcastOnStop(path.getBoolean("BroadcastOnStop")); - - if (path.contains("BroadcastInterval")) - sched.setBroadcastInterval(path.getInt("BroadcastInterval")); - - if (path.contains("BroadcastMessage") && path.isList("BroadcastMessage")) - sched.setMessageToBroadcast(path.getStringList("BroadcastMessage"), path.getString("From"), path.getString("Until")); - - sched.setExpBoost(path.getDouble("Exp")); - sched.setMoneyBoost(path.getDouble("Money")); - - BoostSchedule.add(sched); - } - -// try { -// conf.save(f); -// } catch (IOException e) { -// e.printStackTrace(); -// } - } - - private Boolean getBoolean(String path, Boolean boo, YamlConfiguration config, CommentedYamlConfiguration writer) { - config.addDefault(path, boo); - copySetting(config, writer, path); - return config.getBoolean(path); - } - - private int getInt(String path, int boo, YamlConfiguration config, CommentedYamlConfiguration writer) { - config.addDefault(path, boo); - copySetting(config, writer, path); - return config.getInt(path); - } - - private List<Integer> getIntArray(String path, List<Integer> boo, YamlConfiguration config, CommentedYamlConfiguration writer) { - config.addDefault(path, boo); - copySetting(config, writer, path); - return config.getIntegerList(path); - } - - private String getString(String path, String boo, YamlConfiguration config, CommentedYamlConfiguration writer) { - config.addDefault(path, boo); - copySetting(config, writer, path); - return config.getString(path); - } - - private String getString(String path, String boo, YamlConfiguration config, CommentedYamlConfiguration writer, boolean colorize) { - config.addDefault(path, boo); - copySetting(config, writer, path); - return org.bukkit.ChatColor.translateAlternateColorCodes('&', config.getString(path)); - } - - private Double getDouble(String path, Double boo, YamlConfiguration config, CommentedYamlConfiguration writer) { - config.addDefault(path, boo); - copySetting(config, writer, path); - return config.getDouble(path); - } - - private synchronized void loadItemList() { - YmlMaker ItemFile = new YmlMaker((JavaPlugin) plugin, "ItemList.yml"); - ItemFile.saveDefaultConfig(); - List<String> section = ItemFile.getConfig().getStringList("ItemList"); - ListOfNames.clear(); - for (String one : section) { - if (!one.contains(" - ")) - continue; - - if (!one.contains(" = ")) - continue; - - String meta = ""; - String id = one.split(" - ")[0]; - String part2 = one.split(" - ")[1]; - String part3 = ""; - - part3 = part2.split(" = ")[1]; - part2 = part2.split(" = ")[0]; - - if (id.contains(":")) { - meta = id.split(":")[1]; - id = id.split(":")[0]; - } - - ListOfNames.add(new NameList(id, meta, part2, part3)); - } - - section = ItemFile.getConfig().getStringList("EntityList"); - ListOfEntities.clear(); - for (String one : section) { - if (!one.contains(" - ")) - continue; - - if (!one.contains(" = ")) - continue; - - String meta = ""; - String id = one.split(" - ")[0]; - String part2 = one.split(" - ")[1]; - String part3 = ""; - - part3 = part2.split(" = ")[1]; - part2 = part2.split(" = ")[0]; - - if (id.contains(":")) { - meta = id.split(":")[1]; - id = id.split(":")[0]; - } - - ListOfEntities.add(new NameList(id, meta, part2, part3)); - } - - section = ItemFile.getConfig().getStringList("EnchantList"); - ListOfEnchants.clear(); - for (String one : section) { - if (!one.contains(" - ")) - continue; - - if (!one.contains(" = ")) - continue; - - String id = one.split(" - ")[0]; - String part2 = one.split(" - ")[1]; - String part3 = ""; - - part3 = part2.split(" = ")[1]; - part2 = part2.split(" = ")[0]; - - ListOfEnchants.add(new NameList(id, "", part2, part3)); - } - - section = ItemFile.getConfig().getStringList("ColorList"); - ListOfColors.clear(); - for (String one : section) { - if (!one.contains(" - ")) - continue; - - if (!one.contains(" = ")) - continue; - - String id = one.split(" - ")[0]; - String part2 = one.split(" - ")[1]; - String part3 = ""; - - part3 = part2.split(" = ")[1]; - part2 = part2.split(" = ")[0]; - - ListOfColors.add(new NameList(id, "", part2, part3)); - } - - } - - /** - * Method to load the language file configuration - * - * loads from Jobs/locale/messages_en.yml - */ - private synchronized void loadLanguage() { - - // Just copying default language files, except en, that one will be generated - List<String> languages = new ArrayList<String>(); - languages.add("lt"); - languages.add("de"); - languages.add("cs"); - languages.add("fr"); - languages.add("ru"); - languages.add("cz"); - - for (String lang : languages) { - YmlMaker langFile = new YmlMaker((JavaPlugin) plugin, "locale" + File.separator + "messages_" + lang + ".yml"); - if (langFile != null) - langFile.saveDefaultConfig(); - } - - languages.add("en"); - - File customLocaleFile = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + localeString + ".yml"); - if (!customLocaleFile.exists() && !localeString.equalsIgnoreCase("en")) - languages.add(localeString); - - for (String lang : languages) { - - File f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + lang + ".yml"); - YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); - - CommentedYamlConfiguration writer = new CommentedYamlConfiguration(); - - conf.options().copyDefaults(true); - - GetConfigString("economy.error.nomoney", "Sorry, no money left in national bank!", writer, conf, true); - GetConfigString("limitedItem.error.levelup", "&cYou need to levelup in [jobname] to use this item!", writer, conf, true); - - GetConfigString("command.moneyboost.help.info", "Boosts Money gain for all players", writer, conf, true); - GetConfigString("command.moneyboost.help.args", "[jobname] [rate]", writer, conf, true); - GetConfigString("command.moneyboost.output.allreset", "All money boost turned off", writer, conf, true); - GetConfigString("command.moneyboost.output.jobsboostreset", "Money boost for %jobname% was turned off", writer, conf, true); - GetConfigString("command.moneyboost.output.nothingtoreset", "Nothing to reset", writer, conf, true); - GetConfigString("command.moneyboost.output.boostalladded", "Money boost of %boost% added for all jobs!", writer, conf, true); - GetConfigString("command.moneyboost.output.boostadded", "Money boost of &e%boost% &aadded for &e%jobname%!", writer, conf, true); - GetConfigString("command.moneyboost.output.infostats", "&c-----> &aMoney rate x%boost% enabled&c <-------", writer, conf, true); - - GetConfigString("command.expboost.help.info", "Boosts Exp gain for all players", writer, conf, true); - GetConfigString("command.expboost.help.args", "[jobname] [rate]", writer, conf, true); - GetConfigString("command.expboost.output.allreset", "All exp boost turned off", writer, conf, true); - GetConfigString("command.expboost.output.jobsboostreset", "Exp boost for %jobname% was turned off", writer, conf, true); - GetConfigString("command.expboost.output.nothingtoreset", "Nothing to reset", writer, conf, true); - GetConfigString("command.expboost.output.boostalladded", "Exp boost of %boost% added for all jobs!", writer, conf, true); - GetConfigString("command.expboost.output.boostadded", "Exp boost of &e%boost% &aadded for &e%jobname%!", writer, conf, true); - GetConfigString("command.expboost.output.infostats", "&c-----> &aExp rate x%boost% enabled&c <-------", writer, conf, true); - - GetConfigString("command.convert.help.info", - "Converts data base system from one system to another. if you currently running sqlite, this will convert to Mysql and vise versa.", writer, conf, true); - GetConfigString("command.convert.help.args", "", writer, conf, true); - - GetConfigString("command.limit.help.info", "Shows payment limits for jobs", writer, conf, true); - GetConfigString("command.limit.help.args", "", writer, conf, true); - - GetConfigString("command.limit.output.lefttime", "&eTime left until money limit resets: &2%hour% &ehour &2%min% &emin &2%sec% &esec", writer, conf, true); - GetConfigString("command.limit.output.moneylimit", "&eMoney limit: &2%money%&e/&2%totalmoney%", writer, conf, true); - GetConfigString("command.limit.output.leftexptime", "&eTime left until Exp limit resets: &2%hour% &ehour &2%min% &emin &2%sec% &esec", writer, conf, true); - GetConfigString("command.limit.output.explimit", "&eExp limit: &2%exp%&e/&2%totalexp%", writer, conf, true); - - GetConfigString("command.limit.output.reachedlimit", "&4You have reached money limit in given time!", writer, conf, true); - GetConfigString("command.limit.output.reachedlimit2", "&eYou can check your limit with &2/jobs limit &ecommand", writer, conf, true); - GetConfigString("command.limit.output.reachedExplimit", "&4You have reached exp limit in given time!", writer, conf, true); - GetConfigString("command.limit.output.reachedExplimit2", "&eYou can check your limit with &2/jobs limit &ecommand", writer, conf, true); - - GetConfigString("command.limit.output.notenabled", "&eMoney limit is not enabled", writer, conf, true); - - GetConfigString("command.admin.error", "There was an error in the command.", writer, conf, true); - GetConfigString("command.admin.success", "Your command has been performed.", writer, conf, true); - - GetConfigString("command.error.notNumber", "&ePlease use numbers!", writer, conf, true); - GetConfigString("command.error.job", "The job you have selected does not exist!", writer, conf, true); - GetConfigString("command.error.permission", "You do not have permission to do that!", writer, conf, true); - - GetConfigString("command.help.output.info", "Type /jobs [cmd] ? for more information about a command.", writer, conf, true); - GetConfigString("command.help.output.usage", "Usage: %usage%", writer, conf, true); - - GetConfigString("command.stats.help.info", "Show the level you are in each job you are part of.", writer, conf, true); - GetConfigString("command.stats.help.args", "[playername]", writer, conf, true); - GetConfigString("command.stats.error.nojob", "Please join a job first.", writer, conf, true); - GetConfigString("command.stats.output", "lvl%joblevel% %jobname% : %jobxp%/%jobmaxxp% xp", writer, conf, true); - - GetConfigString("command.archive.help.info", "Shows all jobs saved in archive by user.", writer, conf, true); - GetConfigString("command.archive.help.args", "[playername]", writer, conf, true); - GetConfigString("command.archive.error.nojob", "There is no jobs saved.", writer, conf, true); - GetConfigString("command.archive.output", "lvl %joblevel% (%getbackjoblevel%) %jobname%", writer, conf, true); - - GetConfigString("command.give.help.info", "Gives item by jobs name and item category name. Player name is optional", writer, conf, true); - GetConfigString("command.give.help.args", "[playername] [jobname] [itemname]", writer, conf, true); - GetConfigString("command.give.output.notonline", "&4Player [%playername%] is not online!", writer, conf, true); - GetConfigString("command.give.output.noitem", "&4Cant find any item by given name!", writer, conf, true); - - GetConfigString("command.info.help.title", "&2*** &eJobs&2 ***", writer, conf, true); - GetConfigString("command.info.help.info", "Show how much each job is getting paid and for what.", writer, conf, true); - GetConfigString("command.info.help.penalty", "&eThis job have &c[penalty]% &epenalty because of too many players working in it.", writer, conf, true); - GetConfigString("command.info.help.bonus", "&eThis job have &2[bonus]% &ebonus because not enough players working in it.", writer, conf, true); - GetConfigString("command.info.help.args", "[jobname] [action]", writer, conf, true); - GetConfigString("command.info.help.actions", "&eValid actions are: &f%actions%", writer, conf, true); - GetConfigString("command.info.help.max", " - &emax level:&f ", writer, conf, true); - GetConfigString("command.info.help.material", "&7%material%", writer, conf, true); - - GetConfigString("command.info.help.levelRange", " &a(&e%levelFrom% &a- &e%levelUntil% &alevels)", writer, conf, true); - GetConfigString("command.info.help.levelFrom", " &a(from &e%levelFrom% &alevel)", writer, conf, true); - GetConfigString("command.info.help.levelUntil", " &a(until &e%levelUntil% &alevel)", writer, conf, true); - - GetConfigString("command.info.gui.pickjob", "&ePick your job!", writer, conf, true); - GetConfigString("command.info.gui.jobinfo", "&e[jobname] info!", writer, conf, true); - GetConfigString("command.info.gui.actions", "&eValid actions are:", writer, conf, true); - GetConfigString("command.info.gui.leftClick", "&eLeft Click for more info", writer, conf, true); - GetConfigString("command.info.gui.rightClick", "&eRight click to join job", writer, conf, true); - GetConfigString("command.info.gui.leftSlots", "&eLeft slots:&f ", writer, conf, true); - GetConfigString("command.info.gui.working", "&2&nAlready working", writer, conf, true); - GetConfigString("command.info.gui.max", "&eMax level:&f ", writer, conf, true); - GetConfigString("command.info.gui.back", "&e<<< Back", writer, conf, true); - - GetConfigString("command.info.output.break.info", "Break", writer, conf, true); - GetConfigString("command.info.output.break.none", "%jobname% does not get money for breaking blocks.", writer, conf, true); - GetConfigString("command.info.output.tntbreak.info", "TNTBreak", writer, conf, true); - GetConfigString("command.info.output.tntbreak.none", "%jobname% does not get money for breaking blocks with tnt.", writer, conf, true); - GetConfigString("command.info.output.place.info", "Place", writer, conf, true); - GetConfigString("command.info.output.place.none", "%jobname% does not get money for placing blocks.", writer, conf, true); - GetConfigString("command.info.output.kill.info", "Kill", writer, conf, true); - GetConfigString("command.info.output.kill.none", "%jobname% does not get money for killing monsters.", writer, conf, true); - GetConfigString("command.info.output.mmkill.info", "MMKill", writer, conf, true); - GetConfigString("command.info.output.mmkill.none", "%jobname% does not get money for killing Mythic monsters.", writer, conf, true); - GetConfigString("command.info.output.fish.info", "Fish", writer, conf, true); - GetConfigString("command.info.output.fish.none", "%jobname% does not get money from fishing.", writer, conf, true); - GetConfigString("command.info.output.craft.info", "Craft", writer, conf, true); - GetConfigString("command.info.output.craft.none", "%jobname% does not get money from crafting.", writer, conf, true); - GetConfigString("command.info.output.smelt.info", "Smelt", writer, conf, true); - GetConfigString("command.info.output.smelt.none", "%jobname% does not get money from smelting.", writer, conf, true); - GetConfigString("command.info.output.brew.info", "Brew", writer, conf, true); - GetConfigString("command.info.output.brew.none", "%jobname% does not get money from brewing.", writer, conf, true); - GetConfigString("command.info.output.eat.info", "Eat", writer, conf, true); - GetConfigString("command.info.output.eat.none", "%jobname% does not get money from eating food.", writer, conf, true); - GetConfigString("command.info.output.dye.info", "Dye", writer, conf, true); - GetConfigString("command.info.output.dye.none", "%jobname% does not get money from dyeing.", writer, conf, true); - GetConfigString("command.info.output.enchant.info", "Enchant", writer, conf, true); - GetConfigString("command.info.output.enchant.none", "%jobname% does not get money from enchanting.", writer, conf, true); - GetConfigString("command.info.output.repair.info", "Repair", writer, conf, true); - GetConfigString("command.info.output.repair.none", "%jobname% does not get money from repairing.", writer, conf, true); - GetConfigString("command.info.output.breed.info", "Breed", writer, conf, true); - GetConfigString("command.info.output.breed.none", "%jobname% does not get money from breeding.", writer, conf, true); - GetConfigString("command.info.output.tame.info", "Tame", writer, conf, true); - GetConfigString("command.info.output.tame.none", "%jobname% does not get money from taming.", writer, conf, true); - GetConfigString("command.info.output.milk.info", "Milk", writer, conf, true); - GetConfigString("command.info.output.milk.none", "%jobname% does not get money from milking cows.", writer, conf, true); - GetConfigString("command.info.output.shear.info", "Shear", writer, conf, true); - GetConfigString("command.info.output.shear.none", "%jobname% does not get money from shearing sheeps.", writer, conf, true); - GetConfigString("command.info.output.explore.info", "Explore", writer, conf, true); - GetConfigString("command.info.output.explore.none", "%jobname% does not get money from exploring.", writer, conf, true); - GetConfigString("command.info.output.custom-kill.info", "Custom kill", writer, conf, true); - GetConfigString("command.info.output.custom-kill.none", "%jobname% does not get money from custom player kills.", writer, conf, true); - - GetConfigString("command.playerinfo.help.info", "Show how much each job is getting paid and for what on another player.", writer, conf, true); - GetConfigString("command.playerinfo.help.args", "[playername] [jobname] [action]", writer, conf, true); - - GetConfigString("command.join.help.info", "Join the selected job.", writer, conf, true); - GetConfigString("command.join.help.args", "[jobname]", writer, conf, true); - GetConfigString("command.join.error.alreadyin", "You are already in the job %jobname%.", writer, conf, true); - GetConfigString("command.join.error.fullslots", "You cannot join the job %jobname%, there are no slots available.", writer, conf, true); - GetConfigString("command.join.error.maxjobs", "You have already joined too many jobs.", writer, conf, true); - GetConfigString("command.join.success", "You have joined the job %jobname%.", writer, conf, true); - - GetConfigString("command.leave.help.info", "Leave the selected job.", writer, conf, true); - GetConfigString("command.leave.help.args", "[jobname]", writer, conf, true); - GetConfigString("command.leave.success", "You have left the job %jobname%.", writer, conf, true); - - GetConfigString("command.fixnames.help.info", "Tries to fix NULL player names in data base.", writer, conf, true); - GetConfigString("command.fixnames.help.args", "", writer, conf, true); - - GetConfigString("command.leaveall.help.info", "Leave all your jobs.", writer, conf, true); - GetConfigString("command.leaveall.error.nojobs", "You do not have any jobs to leave!", writer, conf, true); - GetConfigString("command.leaveall.success", "You have left all your jobs.", writer, conf, true); - - GetConfigString("command.browse.help.info", "List the jobs available to you.", writer, conf, true); - GetConfigString("command.browse.error.nojobs", "There are no jobs you can join.", writer, conf, true); - GetConfigString("command.browse.output.header", "You are allowed to join the following jobs:", writer, conf, true); - GetConfigString("command.browse.output.footer", "For more information type in /jobs info [JobName]", writer, conf, true); - GetConfigString("command.browse.output.totalWorkers", " &7Workers: &e[amount]", writer, conf, true); - GetConfigString("command.browse.output.penalty", " &4Penalty: &c[amount]%", writer, conf, true); - GetConfigString("command.browse.output.bonus", " &2Bonus: &a[amount]%", writer, conf, true); - - GetConfigString("command.fire.help.info", "Fire the player from the job.", writer, conf, true); - GetConfigString("command.fire.help.args", "[playername] [jobname]", writer, conf, true); - GetConfigString("command.fire.error.nojob", "Player does not have the job %jobname%.", writer, conf, true); - GetConfigString("command.fire.output.target", "You have been fired from %jobname%.", writer, conf, true); - - GetConfigString("command.fireall.help.info", "Fire player from all their jobs.", writer, conf, true); - GetConfigString("command.fireall.help.args", "[playername]", writer, conf, true); - GetConfigString("command.fireall.error.nojobs", "Player does not have any jobs to be fired from!", writer, conf, true); - GetConfigString("command.fireall.output.target", "You have been fired from all your jobs.", writer, conf, true); - - GetConfigString("command.employ.help.info", "Employ the player to the job.", writer, conf, true); - GetConfigString("command.employ.help.args", "[playername] [jobname]", writer, conf, true); - GetConfigString("command.employ.error.alreadyin", "Player is already in the job %jobname%.", writer, conf, true); - GetConfigString("command.employ.output.target", "You have been employed as a %jobname%.", writer, conf, true); - - GetConfigString("command.top.help.info", "Shows top 15 players by jobs name.", writer, conf, true); - GetConfigString("command.top.help.args", "[jobname]", writer, conf, true); - GetConfigString("command.top.error.nojob", "Cant find any job with this name.", writer, conf, true); - GetConfigString("command.top.output.topline", "&aTop&e 15 &aplayers by &e%jobname% &ajob", writer, conf, true); - GetConfigString("command.top.output.list", "&e%number%&a. &e%playername% &alvl &e%level% &awith&e %exp% &aexp", writer, conf, true); - GetConfigString("command.top.output.prev", "&e<<<<< Prev page &2|", writer, conf, true); - GetConfigString("command.top.output.next", "&2|&e Next Page >>>>", writer, conf, true); - GetConfigString("command.top.output.show", "&2Show from &e[from] &2until &e[until] &2top list", writer, conf, true); - - GetConfigString("command.gtop.help.info", "Shows top 15 players by global jobs level.", writer, conf, true); - GetConfigString("command.gtop.help.args", "", writer, conf, true); - GetConfigString("command.gtop.error.nojob", "Cant find any information.", writer, conf, true); - GetConfigString("command.gtop.output.topline", "&aTop&e 15 &aplayers by global job level", writer, conf, true); - GetConfigString("command.gtop.output.list", "&e%number%&a. &e%playername% &alvl &e%level% &awith&e %exp% &aexp", writer, conf, true); - GetConfigString("command.gtop.output.prev", "&e<<<<< Prev page &2|", writer, conf, true); - GetConfigString("command.gtop.output.next", "&2|&e Next Page >>>>", writer, conf, true); - GetConfigString("command.gtop.output.show", "&2Show from &e[from] &2until &e[until] &2global top list", writer, conf, true); - - GetConfigString("command.log.help.info", "Shows statistics.", writer, conf, true); - GetConfigString("command.log.help.args", "[playername]", writer, conf, true); - GetConfigString("command.log.output.topline", "&7************************* &6%playername% &7*************************", writer, conf, true); - GetConfigString("command.log.output.list", "&7* &6%number%. &3%action%: &6%item% &eqty: %qty% &6money: %money% &eexp: %exp%", writer, conf, true); - GetConfigString("command.log.output.bottomline", "&7***********************************************************", writer, conf, true); - GetConfigString("command.log.output.prev", "&e<<<<< Prev page &2|", writer, conf, true); - GetConfigString("command.log.output.next", "&2|&e Next Page >>>>", writer, conf, true); - GetConfigString("command.log.output.nodata", "&cData not found", writer, conf, true); - - GetConfigString("command.glog.help.info", "Shows global statistics.", writer, conf, true); - GetConfigString("command.glog.help.args", "", writer, conf, true); - GetConfigString("command.glog.output.topline", "&7*********************** &6Global statistics &7***********************", writer, conf, true); - GetConfigString("command.glog.output.list", "&7* &6%number%. &3%username% &e%action%: &6%item% &eqty: %qty% &6money: %money% &eexp: %exp%", writer, conf, - true); - GetConfigString("command.glog.output.bottomline", "&7**************************************************************", writer, conf, true); - GetConfigString("command.glog.output.nodata", "&cData not found", writer, conf, true); - - GetConfigString("command.transfer.help.info", "Transfer a player's job from an old job to a new job.", writer, conf, true); - GetConfigString("command.transfer.help.args", "[playername] [oldjob] [newjob]", writer, conf, true); - GetConfigString("command.transfer.output.target", "You have been transferred from %oldjobname% to %newjobname%.", writer, conf, true); - - GetConfigString("command.promote.help.info", "Promote the player X levels in a job.", writer, conf, true); - GetConfigString("command.promote.help.args", "[playername] [jobname] [levels]", writer, conf, true); - GetConfigString("command.promote.output.target", "You have been promoted %levelsgained% levels in %jobname%.", writer, conf, true); - - GetConfigString("command.demote.help.info", "Demote the player X levels in a job.", writer, conf, true); - GetConfigString("command.demote.help.args", "[playername] [jobname] [levels]", writer, conf, true); - GetConfigString("command.demote.output.target", "You have been demoted %levelslost% levels in %jobname%.", writer, conf, true); - - GetConfigString("command.grantxp.help.info", "Grant the player X experience in a job.", writer, conf, true); - GetConfigString("command.grantxp.help.args", "[playername] [jobname] [xp]", writer, conf, true); - GetConfigString("command.grantxp.output.target", "You have been granted %xpgained% experience in %jobname%.", writer, conf, true); - - GetConfigString("command.removexp.help.info", "Remove X experience from the player in a job.", writer, conf, true); - GetConfigString("command.removexp.help.args", "[playername] [jobname] [xp]", writer, conf, true); - GetConfigString("command.removexp.output.target", "You have lost %xplost% experience in %jobname%.", writer, conf, true); - - GetConfigString("command.signupdate.help.info", "Manualy updates sign by its name", writer, conf, true); - GetConfigString("command.signupdate.help.args", "[jobname]", writer, conf, true); - - GetConfigString("command.reload.help.info", "Reload configurations.", writer, conf, true); - - GetConfigString("message.skillup.broadcast", "%playername% has been promoted to a %titlename% %jobname%.", writer, conf, true); - GetConfigString("message.skillup.nobroadcast", "Congratulations, you have been promoted to a %titlename% %jobname%.", writer, conf, true); - - GetConfigString("message.levelup.broadcast", "%playername% is now a level %joblevel% %jobname%.", writer, conf, true); - GetConfigString("message.levelup.nobroadcast", "You are now a level %joblevel% %jobname%.", writer, conf, true); - - GetConfigString("message.cowtimer", "&eYou still need to wait &6%time% &esec to get paid for this job.", writer, conf, true); - GetConfigString("message.blocktimer", "&eYou need to wait: &3[time] &esec more to get paid for this!", writer, conf, true); - GetConfigString("message.placeblocktimer", "&eYou cant place block faster than &6[time] &esec interval in same place!", writer, conf, true); - GetConfigString("message.taxes", "&3[amount] &eserver taxes where transfered to this account", writer, conf, true); - - GetConfigString("message.boostStarted", "&eJobs boost time have been started!", writer, conf, true); - GetConfigString("message.boostStoped", "&eJobs boost time have been ended!", writer, conf, true); - - GetConfigString("command.toggle.help.info", "Toggles payment output on action bar.", writer, conf, true); - GetConfigString("command.toggle.output.turnedoff", "&4This feature are turned off!", writer, conf, true); - GetConfigString("command.toggle.output.paid", "&aYou got paid for &2[amount]&a and got &2[exp] &aexp", writer, conf, true); - GetConfigString("command.toggle.output.on", "&aToggled: &aON", writer, conf, true); - GetConfigString("command.toggle.output.off", "&aToggled: &4OFF", writer, conf, true); - - GetConfigString("message.crafting.fullinventory", "Your inventory is full!", writer, conf, true); - - GetConfigString("signs.List", "&0[number].&8[player]&7:&4[level]", writer, conf, true); - GetConfigString("signs.SpecialList.1.1", "&b** &8First &b**", writer, conf, true); - GetConfigString("signs.SpecialList.1.2", "&9[player]", writer, conf, true); - GetConfigString("signs.SpecialList.1.3", "&8[level] level", writer, conf, true); - GetConfigString("signs.SpecialList.1.4", "&b************", writer, conf, true); - GetConfigString("signs.SpecialList.2.1", "&b** &8Second &b**", writer, conf, true); - GetConfigString("signs.SpecialList.2.2", "&9[player]", writer, conf, true); - GetConfigString("signs.SpecialList.2.3", "&8[level] level", writer, conf, true); - GetConfigString("signs.SpecialList.2.4", "&b************", writer, conf, true); - GetConfigString("signs.SpecialList.3.1", "&b** &8Third &b**", writer, conf, true); - GetConfigString("signs.SpecialList.3.2", "&9[player]", writer, conf, true); - GetConfigString("signs.SpecialList.3.3", "&8[level] level", writer, conf, true); - GetConfigString("signs.SpecialList.3.4", "&b************", writer, conf, true); - GetConfigString("signs.cantcreate", "&4You can't create this sign!", writer, conf, true); - GetConfigString("signs.cantdestroy", "&4You can't destroy this sign!", writer, conf, true); - GetConfigString("signs.topline", "&2[Jobs]", writer, conf, true); - GetConfigString("signs.secondline.join", "&2Join", writer, conf, true); - GetConfigString("signs.secondline.leave", "&4Leave", writer, conf, true); - GetConfigString("signs.secondline.toggle", "&2Toggle", writer, conf, true); - GetConfigString("signs.secondline.top", "&2Top", writer, conf, true); - GetConfigString("signs.secondline.browse", "&2Browse", writer, conf, true); - GetConfigString("signs.secondline.stats", "&2Stats", writer, conf, true); - GetConfigString("signs.secondline.limit", "&2Limit", writer, conf, true); - GetConfigString("signs.secondline.info", "&2Info", writer, conf, true); - GetConfigString("signs.secondline.archive", "&2Archive", writer, conf, true); - - //GetConfigString("scoreboard.clear", "&eIf you want to remove scoreboard, type &2/jobs top clear", writer, conf, true); - GetConfigString("scoreboard.topline", "&2Top &e%jobname%", writer, conf, true); - GetConfigString("scoreboard.gtopline", "&2Global top list", writer, conf, true); - GetConfigString("scoreboard.lines", "&2%number%. &e%playername%", writer, conf, true); - - keys = new ArrayList<String>(conf.getConfigurationSection("signs.secondline").getKeys(false)); - - // Write back config - try { - writer.save(f); - } catch (IOException e) { - e.printStackTrace(); - } - } - } -} diff --git a/com/gamingmesh/jobs/config/LanguageManager.java b/com/gamingmesh/jobs/config/LanguageManager.java new file mode 100644 index 00000000..36d04268 --- /dev/null +++ b/com/gamingmesh/jobs/config/LanguageManager.java @@ -0,0 +1,436 @@ +package com.gamingmesh.jobs.config; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.java.JavaPlugin; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.container.LocaleReader; + +public class LanguageManager { + private JobsPlugin plugin; + + public LanguageManager(JobsPlugin plugin) { + this.plugin = plugin; + } + + /** + * Method to load the language file configuration + * + * loads from Jobs/locale/messages_en.yml + */ + synchronized void load() { + + // Just copying default language files, except en, that one will be generated + List<String> languages = new ArrayList<String>(); + languages.add("lt"); + languages.add("de"); + languages.add("cs"); + languages.add("fr"); + languages.add("ru"); + languages.add("cz"); + + for (String lang : languages) { + YmlMaker langFile = new YmlMaker((JavaPlugin) plugin, "locale" + File.separator + "messages_" + lang + ".yml"); + if (langFile != null) + langFile.saveDefaultConfig(); + } + + languages.add("en"); + + File customLocaleFile = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + Jobs.getGCManager().localeString + ".yml"); + if (!customLocaleFile.exists() && !Jobs.getGCManager().localeString.equalsIgnoreCase("en")) + languages.add(Jobs.getGCManager().localeString); + + for (String lang : languages) { + + File f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + lang + ".yml"); + YamlConfiguration config = YamlConfiguration.loadConfiguration(f); + CommentedYamlConfiguration writer = new CommentedYamlConfiguration(); + + LocaleReader c = new LocaleReader(config, writer); + + c.getC().options().copyDefaults(true); + Jobs.getGCManager().commandArgs.clear(); + + c.get("economy.error.nomoney", "&cSorry, no money left in national bank!"); + c.get("limitedItem.error.levelup", "&cYou need to levelup in [jobname] to use this item!"); + c.get("general.info.toplineseparator", "&7*********************** &6%playername% &7***********************"); + c.get("general.info.separator", "&7*******************************************************"); + c.get("general.admin.error", "&cThere was an error in the command."); + c.get("general.admin.success", "&eYour command has been performed."); + c.get("general.error.notNumber", "&ePlease use numbers!"); + c.get("general.error.job", "&cThe job you have selected does not exist!"); + c.get("general.error.permission", "&cYou do not have permission to do that!"); + c.get("general.error.noinfo", "&cNo information found!"); + c.get("general.error.noinfoByPlayer", "&cNo information found by [%playername%] player name!"); + c.get("general.error.ingame", "&cYou can use this command only in game!"); + c.get("general.error.fromconsole", "&cYou can use this command only from console!"); + c.get("general.error.worldisdisabled", "&cYou cant use command in this world!"); + + c.get("command.moneyboost.help.info", "Boosts Money gain for all players"); + c.get("command.moneyboost.help.args", "[jobname] [rate]"); + Jobs.getGCManager().commandArgs.put("moneyboost", Arrays.asList("[jobname]", "[rate]")); + c.get("command.moneyboost.output.allreset", "All money boost turned off"); + c.get("command.moneyboost.output.jobsboostreset", "Money boost for %jobname% was turned off"); + c.get("command.moneyboost.output.nothingtoreset", "Nothing to reset"); + c.get("command.moneyboost.output.boostalladded", "Money boost of %boost% added for all jobs!"); + c.get("command.moneyboost.output.boostadded", "Money boost of &e%boost% &aadded for &e%jobname%!"); + c.get("command.moneyboost.output.infostats", "&c-----> &aMoney rate x%boost% enabled&c <-------"); + + c.get("command.pointboost.help.info", "Boosts points gain for all players"); + c.get("command.pointboost.help.args", "[jobname] [rate]"); + Jobs.getGCManager().commandArgs.put("pointboost", Arrays.asList("[jobname]", "[rate]")); + c.get("command.pointboost.output.allreset", "All points boost turned off"); + c.get("command.pointboost.output.jobsboostreset", "Points boost for %jobname% was turned off"); + c.get("command.pointboost.output.nothingtoreset", "Nothing to reset"); + c.get("command.pointboost.output.boostalladded", "Points boost of %boost% added for all jobs!"); + c.get("command.pointboost.output.boostadded", "Points boost of &e%boost% &aadded for &e%jobname%!"); + c.get("command.pointboost.output.infostats", "&c-----> &aPoints rate x%boost% enabled&c <-------"); + + c.get("command.expboost.help.info", "Boosts Exp gain for all players"); + c.get("command.expboost.help.args", "[jobname] [rate]"); + Jobs.getGCManager().commandArgs.put("expboost", Arrays.asList("[jobname]", "[rate]")); + c.get("command.expboost.output.allreset", "All exp boost turned off"); + c.get("command.expboost.output.jobsboostreset", "Exp boost for %jobname% was turned off"); + c.get("command.expboost.output.nothingtoreset", "Nothing to reset"); + c.get("command.expboost.output.boostalladded", "Exp boost of %boost% added for all jobs!"); + c.get("command.expboost.output.boostadded", "Exp boost of &e%boost% &aadded for &e%jobname%!"); + c.get("command.expboost.output.infostats", "&c-----> &aExp rate x%boost% enabled&c <-------"); + + c.get("command.bonus.help.info", "Show job bonuses"); + c.get("command.bonus.help.args", "[jobname]"); + Jobs.getGCManager().commandArgs.put("bonus", Arrays.asList("[jobname]")); + c.get("command.bonus.output.topline", "&7**************** &2[money] &6[points] &e[exp] &7****************"); + c.get("command.bonus.output.permission", " &ePermission bonus: %money% %points% %exp%"); + c.get("command.bonus.output.item", " &eItem bonus: %money% %points% %exp%"); + c.get("command.bonus.output.global", " &eGlobal bonus: %money% %points% %exp%"); + c.get("command.bonus.output.dynamic", " &eDynamic payment bonus: %money% %points% %exp%"); + c.get("command.bonus.output.area", " &eArea bonus: %money% %points% %exp%"); + c.get("command.bonus.output.final", " &eFinal bonus: %money% %points% %exp%"); + + c.get("command.convert.help.info", + "Converts data base system from one system to another. if you currently running sqlite, this will convert to Mysql and vise versa."); + c.get("command.convert.help.args", ""); + + c.get("command.limit.help.info", "Shows payment limits for jobs"); + c.get("command.limit.help.args", ""); + c.get("command.limit.output.lefttime", "&eTime left until money limit resets: &2%hour% &ehour &2%min% &emin &2%sec% &esec"); + c.get("command.limit.output.moneylimit", "&eMoney limit: &2%money%&e/&2%totalmoney%"); + c.get("command.limit.output.leftexptime", "&eTime left until Exp limit resets: &2%hour% &ehour &2%min% &emin &2%sec% &esec"); + c.get("command.limit.output.explimit", "&eExp limit: &2%exp%&e/&2%totalexp%"); + c.get("command.limit.output.leftpointtime", "&eTime left until Point limit resets: &2%hour% &ehour &2%min% &emin &2%sec% &esec"); + c.get("command.limit.output.pointlimit", "&ePoint limit: &2%current%&e/&2%total%"); + c.get("command.limit.output.reachedlimit", "&4You have reached money limit in given time!"); + c.get("command.limit.output.reachedlimit2", "&eYou can check your limit with &2/jobs limit &ecommand"); + c.get("command.limit.output.reachedExplimit", "&4You have reached exp limit in given time!"); + c.get("command.limit.output.reachedExplimit2", "&eYou can check your limit with &2/jobs limit &ecommand"); + c.get("command.limit.output.reachedPointlimit", "&4You have reached exp limit in given time!"); + c.get("command.limit.output.reachedPointlimit2", "&eYou can check your limit with &2/jobs limit &ecommand"); + c.get("command.limit.output.notenabled", "&eMoney limit is not enabled"); + + c.get("command.help.output.info", "Type /jobs [cmd] ? for more information about a command."); + c.get("command.help.output.usage", "Usage: %usage%"); + c.get("command.help.output.title", "&e-------&e ======= &6Jobs &e======= &e-------"); + c.get("command.help.output.page", "&e-----&e ====== Page &6[1] &eof &6[2] &e====== &e-----"); + c.get("command.help.output.prev", "&e--- <<<<< &6Prev page &e|"); + c.get("command.help.output.next", "&e|&6 Next Page &e>>>> ---"); + + c.get("command.points.help.info", "Shows how much points player have."); + c.get("command.points.help.args", "[playername]"); + Jobs.getGCManager().commandArgs.put("points", Arrays.asList("[playername]")); + c.get("command.points.currentpoints", " &eCurrent point amount: &6%currentpoints%"); + c.get("command.points.totalpoints", " &eTotal amount of collected points until now: &6%totalpoints%"); + + c.get("command.editpoints.help.info", "Edit players points."); + c.get("command.editpoints.help.args", "[set/add/take] [playername] [amount]"); + Jobs.getGCManager().commandArgs.put("editpoints", Arrays.asList("set%%add%%take", "[playername]")); + c.get("command.editpoints.output.set", "&ePlayers (&6%playername%&e) points was set to &6%amount%"); + c.get("command.editpoints.output.add", "&ePlayer (&6%playername%&e) got aditinal &6%amount% &epoints. Now he has &6%total%"); + c.get("command.editpoints.output.take", "&ePlayer (&6%playername%&e) lost &6%amount% &epoints. Now he has &6%total%"); + + c.get("command.stats.help.info", "Show the level you are in each job you are part of."); + c.get("command.stats.help.args", "[playername]"); + Jobs.getGCManager().commandArgs.put("stats", Arrays.asList("[playername]")); + c.get("command.stats.error.nojob", "Please join a job first."); + c.get("command.stats.output", " lvl%joblevel% %jobname% : %jobxp%/%jobmaxxp% xp"); + + c.get("command.shop.help.info", "Opens special jobs shop."); + c.get("command.shop.help.args", ""); + c.get("command.shop.info.title", "&e------- &8Jobs shop &e-------"); + c.get("command.shop.info.currentPoints", "&eYou have: &6%currentpoints%"); + c.get("command.shop.info.price", "&ePrice: &6%price%"); + c.get("command.shop.info.reqJobs", "&eRequired jobs:"); + c.get("command.shop.info.reqJobsList", " &6%jobsname%&e: &e%level% lvl"); + + c.get("command.shop.info.NoPermForItem", "&cYou don't have required permissions for this item!"); + c.get("command.shop.info.NoPermToBuy", "&cNo permissions to buy this item"); + c.get("command.shop.info.NoJobReqForitem", "&cYou don't have required job (&6%jobname%&e) with required (&6%joblevel%&e) level"); + c.get("command.shop.info.NoPoints", "&cYou don't have enough points"); + c.get("command.shop.info.Paid", "&eYou have paid &6%amount% &efor this item"); + c.get("command.shop.info.reqJobsList", " &6%jobsname%&e: &e%level% lvl"); + + c.get("command.archive.help.info", "Shows all jobs saved in archive by user."); + c.get("command.archive.help.args", "[playername]"); + Jobs.getGCManager().commandArgs.put("archive", Arrays.asList("[playername]")); + c.get("command.archive.error.nojob", "There is no jobs saved."); + c.get("command.archive.output", "lvl %joblevel% (%getbackjoblevel%) %jobname%"); + + c.get("command.give.help.info", "Gives item by jobs name and item category name. Player name is optional"); + c.get("command.give.help.args", "[playername] [jobname] [itemname]"); + Jobs.getGCManager().commandArgs.put("give", Arrays.asList("[playername]", "[jobname]", "[jobitemname]")); + c.get("command.give.output.notonline", "&4Player [%playername%] is not online!"); + c.get("command.give.output.noitem", "&4Cant find any item by given name!"); + + c.get("command.info.help.title", "&2*** &eJobs&2 ***"); + c.get("command.info.help.info", "Show how much each job is getting paid and for what."); + c.get("command.info.help.penalty", "&eThis job have &c[penalty]% &epenalty because of too many players working in it."); + c.get("command.info.help.bonus", "&eThis job have &2[bonus]% &ebonus because not enough players working in it."); + c.get("command.info.help.args", "[jobname] [action]"); + Jobs.getGCManager().commandArgs.put("info", Arrays.asList("[jobname]", "[action]")); + c.get("command.info.help.actions", "&eValid actions are: &f%actions%"); + c.get("command.info.help.max", " - &emax level:&f "); + c.get("command.info.help.material", "&7%material%"); + + c.get("command.info.help.levelRange", " &a(&e%levelFrom% &a- &e%levelUntil% &alevels)"); + c.get("command.info.help.levelFrom", " &a(from &e%levelFrom% &alevel)"); + c.get("command.info.help.levelUntil", " &a(until &e%levelUntil% &alevel)"); + + c.get("command.info.gui.pickjob", "&ePick your job!"); + c.get("command.info.gui.jobinfo", "&e[jobname] info!"); + c.get("command.info.gui.actions", "&eValid actions are:"); + c.get("command.info.gui.leftClick", "&eLeft Click for more info"); + c.get("command.info.gui.rightClick", "&eRight click to join job"); + c.get("command.info.gui.leftSlots", "&eLeft slots:&f "); + c.get("command.info.gui.working", "&2&nAlready working"); + c.get("command.info.gui.max", "&eMax level:&f "); + c.get("command.info.gui.back", "&e<<< Back"); + + c.get("command.info.output.break.info", "Break"); + c.get("command.info.output.break.none", "%jobname% does not get money for breaking blocks."); + c.get("command.info.output.tntbreak.info", "TNTBreak"); + c.get("command.info.output.tntbreak.none", "%jobname% does not get money for breaking blocks with tnt."); + c.get("command.info.output.place.info", "Place"); + c.get("command.info.output.place.none", "%jobname% does not get money for placing blocks."); + c.get("command.info.output.kill.info", "Kill"); + c.get("command.info.output.kill.none", "%jobname% does not get money for killing monsters."); + c.get("command.info.output.mmkill.info", "MMKill"); + c.get("command.info.output.mmkill.none", "%jobname% does not get money for killing Mythic monsters."); + c.get("command.info.output.fish.info", "Fish"); + c.get("command.info.output.fish.none", "%jobname% does not get money from fishing."); + c.get("command.info.output.craft.info", "Craft"); + c.get("command.info.output.craft.none", "%jobname% does not get money from crafting."); + c.get("command.info.output.smelt.info", "Smelt"); + c.get("command.info.output.smelt.none", "%jobname% does not get money from smelting."); + c.get("command.info.output.brew.info", "Brew"); + c.get("command.info.output.brew.none", "%jobname% does not get money from brewing."); + c.get("command.info.output.eat.info", "Eat"); + c.get("command.info.output.eat.none", "%jobname% does not get money from eating food."); + c.get("command.info.output.dye.info", "Dye"); + c.get("command.info.output.dye.none", "%jobname% does not get money from dyeing."); + c.get("command.info.output.enchant.info", "Enchant"); + c.get("command.info.output.enchant.none", "%jobname% does not get money from enchanting."); + c.get("command.info.output.repair.info", "Repair"); + c.get("command.info.output.repair.none", "%jobname% does not get money from repairing."); + c.get("command.info.output.breed.info", "Breed"); + c.get("command.info.output.breed.none", "%jobname% does not get money from breeding."); + c.get("command.info.output.tame.info", "Tame"); + c.get("command.info.output.tame.none", "%jobname% does not get money from taming."); + c.get("command.info.output.milk.info", "Milk"); + c.get("command.info.output.milk.none", "%jobname% does not get money from milking cows."); + c.get("command.info.output.shear.info", "Shear"); + c.get("command.info.output.shear.none", "%jobname% does not get money from shearing sheeps."); + c.get("command.info.output.explore.info", "Explore"); + c.get("command.info.output.explore.none", "%jobname% does not get money from exploring."); + c.get("command.info.output.custom-kill.info", "Custom kill"); + c.get("command.info.output.custom-kill.none", "%jobname% does not get money from custom player kills."); + + c.get("command.playerinfo.help.info", "Show how much each job is getting paid and for what on another player."); + c.get("command.playerinfo.help.args", "[playername] [jobname] [action]"); + Jobs.getGCManager().commandArgs.put("playerinfo", Arrays.asList("[playername]", "[jobname]", "[action]")); + + c.get("command.join.help.info", "Join the selected job."); + c.get("command.join.help.args", "[jobname]"); + Jobs.getGCManager().commandArgs.put("join", Arrays.asList("[jobname]")); + c.get("command.join.error.alreadyin", "You are already in the job %jobname%."); + c.get("command.join.error.fullslots", "You cannot join the job %jobname%, there are no slots available."); + c.get("command.join.error.maxjobs", "You have already joined too many jobs."); + c.get("command.join.success", "You have joined the job %jobname%."); + + c.get("command.leave.help.info", "Leave the selected job."); + c.get("command.leave.help.args", "[oldplayerjob]"); + Jobs.getGCManager().commandArgs.put("leave", Arrays.asList("[oldplayerjob]")); + c.get("command.leave.success", "You have left the job %jobname%."); + + c.get("command.leaveall.help.info", "Leave all your jobs."); + c.get("command.leaveall.error.nojobs", "You do not have any jobs to leave!"); + c.get("command.leaveall.success", "You have left all your jobs."); + + c.get("command.browse.help.info", "List the jobs available to you."); + c.get("command.browse.error.nojobs", "There are no jobs you can join."); + c.get("command.browse.output.header", "You are allowed to join the following jobs:"); + c.get("command.browse.output.footer", "For more information type in /jobs info [JobName]"); + c.get("command.browse.output.totalWorkers", " &7Workers: &e[amount]"); + c.get("command.browse.output.penalty", " &4Penalty: &c[amount]%"); + c.get("command.browse.output.bonus", " &2Bonus: &a[amount]%"); + + c.get("command.fire.help.info", "Fire the player from the job."); + c.get("command.fire.help.args", "[playername] [jobname]"); + Jobs.getGCManager().commandArgs.put("fire", Arrays.asList("[playername]", "[oldjob]")); + c.get("command.fire.error.nojob", "Player does not have the job %jobname%."); + c.get("command.fire.output.target", "You have been fired from %jobname%."); + + c.get("command.fireall.help.info", "Fire player from all their jobs."); + c.get("command.fireall.help.args", "[playername]"); + Jobs.getGCManager().commandArgs.put("fireall", Arrays.asList("[playername]")); + c.get("command.fireall.error.nojobs", "Player does not have any jobs to be fired from!"); + c.get("command.fireall.output.target", "You have been fired from all your jobs."); + + c.get("command.employ.help.info", "Employ the player to the job."); + c.get("command.employ.help.args", "[playername] [jobname]"); + Jobs.getGCManager().commandArgs.put("employ", Arrays.asList("[playername]", "[jobname]")); + c.get("command.employ.error.alreadyin", "Player is already in the job %jobname%."); + c.get("command.employ.output.target", "You have been employed as a %jobname%."); + + c.get("command.top.help.info", "Shows top 15 players by jobs name."); + c.get("command.top.help.args", "[jobname]"); + Jobs.getGCManager().commandArgs.put("top", Arrays.asList("[jobname]")); + c.get("command.top.error.nojob", "Cant find any job with this name."); + c.get("command.top.output.topline", "&aTop&e 15 &aplayers by &e%jobname% &ajob"); + c.get("command.top.output.list", "&e%number%&a. &e%playername% &alvl &e%level% &awith&e %exp% &aexp"); + c.get("command.top.output.prev", "&e<<<<< Prev page &2|"); + c.get("command.top.output.next", "&2|&e Next Page >>>>"); + c.get("command.top.output.show", "&2Show from &e[from] &2until &e[until] &2top list"); + + c.get("command.gtop.help.info", "Shows top 15 players by global jobs level."); + c.get("command.gtop.help.args", ""); + c.get("command.gtop.error.nojob", "Cant find any information."); + c.get("command.gtop.output.topline", "&aTop&e 15 &aplayers by global job level"); + c.get("command.gtop.output.list", "&e%number%&a. &e%playername% &alvl &e%level% &awith&e %exp% &aexp"); + c.get("command.gtop.output.prev", "&e<<<<< Prev page &2|"); + c.get("command.gtop.output.next", "&2|&e Next Page >>>>"); + c.get("command.gtop.output.show", "&2Show from &e[from] &2until &e[until] &2global top list"); + + c.get("command.log.help.info", "Shows statistics."); + c.get("command.log.help.args", "[playername]"); + Jobs.getGCManager().commandArgs.put("log", Arrays.asList("[playername]")); + c.get("command.log.output.topline", "&7************************* &6%playername% &7*************************"); + c.get("command.log.output.list", "&7* &6%number%. &3%action%: &6%item% &eqty: %qty% &6money: %money% &eexp: %exp%"); + c.get("command.log.output.bottomline", "&7***********************************************************"); + c.get("command.log.output.prev", "&e<<<<< Prev page &2|"); + c.get("command.log.output.next", "&2|&e Next Page >>>>"); + c.get("command.log.output.nodata", "&cData not found"); + + c.get("command.glog.help.info", "Shows global statistics."); + c.get("command.glog.help.args", ""); + c.get("command.glog.output.topline", "&7*********************** &6Global statistics &7***********************"); + c.get("command.glog.output.list", "&7* &6%number%. &3%username% &e%action%: &6%item% &eqty: %qty% &6money: %money% &eexp: %exp%"); + c.get("command.glog.output.bottomline", "&7**************************************************************"); + c.get("command.glog.output.nodata", "&cData not found"); + + c.get("command.transfer.help.info", "Transfer a player's job from an old job to a new job."); + c.get("command.transfer.help.args", "[playername] [oldjob] [newjob]"); + Jobs.getGCManager().commandArgs.put("transfer", Arrays.asList("[playername]", "[oldjob]", "[jobname]")); + c.get("command.transfer.output.target", "You have been transferred from %oldjobname% to %newjobname%."); + + c.get("command.promote.help.info", "Promote the player X levels in a job."); + c.get("command.promote.help.args", "[playername] [jobname] [levels]"); + Jobs.getGCManager().commandArgs.put("promote", Arrays.asList("[playername]", "[jobname]", "[levels]")); + c.get("command.promote.output.target", "You have been promoted %levelsgained% levels in %jobname%."); + + c.get("command.demote.help.info", "Demote the player X levels in a job."); + c.get("command.demote.help.args", "[playername] [jobname] [levels]"); + Jobs.getGCManager().commandArgs.put("demote", Arrays.asList("[playername]", "[jobname]", "[levels]")); + c.get("command.demote.output.target", "You have been demoted %levelslost% levels in %jobname%."); + + c.get("command.grantxp.help.info", "Grant the player X experience in a job."); + c.get("command.grantxp.help.args", "[playername] [jobname] [xp]"); + Jobs.getGCManager().commandArgs.put("grantxp", Arrays.asList("[playername]", "[jobname]", "[xp]")); + c.get("command.grantxp.output.target", "You have been granted %xpgained% experience in %jobname%."); + + c.get("command.removexp.help.info", "Remove X experience from the player in a job."); + c.get("command.removexp.help.args", "[playername] [jobname] [xp]"); + Jobs.getGCManager().commandArgs.put("removexp", Arrays.asList("[playername]", "[jobname]", "[xp]")); + c.get("command.removexp.output.target", "You have lost %xplost% experience in %jobname%."); + + c.get("command.signupdate.help.info", "Manualy updates sign by its name"); + c.get("command.signupdate.help.args", "[jobname]"); + Jobs.getGCManager().commandArgs.put("signupdate", Arrays.asList("[jobname]")); + + c.get("command.reload.help.info", "Reload configurations."); + + c.get("command.toggle.help.info", "Toggles payment output on action bar."); + c.get("command.toggle.help.args", ""); + c.get("command.toggle.output.turnedoff", "&4This feature are turned off!"); + c.get("command.toggle.output.paid.main", "&aYou got:"); + c.get("command.toggle.output.paid.money", "&e[amount] money"); + c.get("command.toggle.output.paid.exp", "&7[exp] exp"); + c.get("command.toggle.output.paid.points", "&6[points] points"); + c.get("command.toggle.output.on", "&aToggled: &aON"); + c.get("command.toggle.output.off", "&aToggled: &4OFF"); + Jobs.getGCManager().commandArgs.put("toggle", Arrays.asList("ActionBar%%BossBar")); + + c.get("message.skillup.broadcast", "%playername% has been promoted to a %titlename% %jobname%."); + c.get("message.skillup.nobroadcast", "Congratulations, you have been promoted to a %titlename% %jobname%."); + + c.get("message.levelup.broadcast", "%playername% is now a level %joblevel% %jobname%."); + c.get("message.levelup.nobroadcast", "You are now a level %joblevel% %jobname%."); + + c.get("message.cowtimer", "&eYou still need to wait &6%time% &esec to get paid for this job."); + c.get("message.blocktimer", "&eYou need to wait: &3[time] &esec more to get paid for this!"); + c.get("message.placeblocktimer", "&eYou cant place block faster than &6[time] &esec interval in same place!"); + c.get("message.taxes", "&3[amount] &eserver taxes where transfered to this account"); + + c.get("message.boostStarted", "&eJobs boost time have been started!"); + c.get("message.boostStoped", "&eJobs boost time have been ended!"); + + c.get("message.crafting.fullinventory", "Your inventory is full!"); + + c.get("signs.List", "&0[number].&8[player]&7:&4[level]"); + c.get("signs.SpecialList.1.1", "&b** &8First &b**"); + c.get("signs.SpecialList.1.2", "&9[player]"); + c.get("signs.SpecialList.1.3", "&8[level] level"); + c.get("signs.SpecialList.1.4", "&b************"); + c.get("signs.SpecialList.2.1", "&b** &8Second &b**"); + c.get("signs.SpecialList.2.2", "&9[player]"); + c.get("signs.SpecialList.2.3", "&8[level] level"); + c.get("signs.SpecialList.2.4", "&b************"); + c.get("signs.SpecialList.3.1", "&b** &8Third &b**"); + c.get("signs.SpecialList.3.2", "&9[player]"); + c.get("signs.SpecialList.3.3", "&8[level] level"); + c.get("signs.SpecialList.3.4", "&b************"); + c.get("signs.cantcreate", "&4You can't create this sign!"); + c.get("signs.cantdestroy", "&4You can't destroy this sign!"); + c.get("signs.topline", "&2[Jobs]"); + c.get("signs.secondline.join", "&2Join"); + c.get("signs.secondline.leave", "&4Leave"); + c.get("signs.secondline.toggle", "&2Toggle"); + c.get("signs.secondline.top", "&2Top"); + c.get("signs.secondline.browse", "&2Browse"); + c.get("signs.secondline.stats", "&2Stats"); + c.get("signs.secondline.limit", "&2Limit"); + c.get("signs.secondline.info", "&2Info"); + c.get("signs.secondline.archive", "&2Archive"); + + //c.get("scoreboard.clear", "&eIf you want to remove scoreboard, type &2/jobs top clear"); + c.get("scoreboard.topline", "&2Top &e%jobname%"); + c.get("scoreboard.gtopline", "&2Global top list"); + c.get("scoreboard.lines", "&2%number%. &e%playername%"); + +// keys = new ArrayList<String>(c.getC().getConfigurationSection("signs.secondline").getKeys(false)); + + // Write back config + try { + c.getW().save(f); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/com/gamingmesh/jobs/config/NameTranslatorManager.java b/com/gamingmesh/jobs/config/NameTranslatorManager.java new file mode 100644 index 00000000..1afd7656 --- /dev/null +++ b/com/gamingmesh/jobs/config/NameTranslatorManager.java @@ -0,0 +1,1627 @@ +package com.gamingmesh.jobs.config; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Set; + +import org.bukkit.Bukkit; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.java.JavaPlugin; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.container.JobInfo; +import com.gamingmesh.jobs.container.LocaleReader; +import com.gamingmesh.jobs.container.NameList; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class NameTranslatorManager { + + private JobsPlugin plugin; + + public ArrayList<NameList> ListOfNames = new ArrayList<NameList>(); + public ArrayList<NameList> ListOfEntities = new ArrayList<NameList>(); + public ArrayList<NameList> ListOfEnchants = new ArrayList<NameList>(); + public ArrayList<NameList> ListOfColors = new ArrayList<NameList>(); + + public NameTranslatorManager(JobsPlugin plugin) { + this.plugin = plugin; + } + + public String Translate(String materialName, JobInfo info) { + + // Translating name to user friendly + if (Jobs.getGCManager().UseCustomNames) + switch (info.getActionType()) { + case BREAK: + case TNTBREAK: + case EAT: + case CRAFT: + case DYE: + case PLACE: + case SMELT: + case REPAIR: + case BREW: + case FISH: + for (NameList one : ListOfNames) { + String ids = one.getId() + ":" + one.getMeta(); + if (!one.getMeta().equalsIgnoreCase("") && ids.equalsIgnoreCase(info.getId() + ":" + info.getMeta()) && !one.getId().equalsIgnoreCase("0")) { + return one.getName(); + } + } + for (NameList one : ListOfNames) { + String ids = one.getId(); + if (ids.equalsIgnoreCase(String.valueOf(info.getId())) && !one.getId().equalsIgnoreCase("0")) { + return one.getName(); + } + } + break; + case BREED: + case KILL: + case MILK: + case TAME: + for (NameList one : ListOfEntities) { + String ids = one.getId() + ":" + one.getMeta(); + if (!one.getMeta().equalsIgnoreCase("") && ids.equalsIgnoreCase(info.getId() + ":" + info.getMeta()) && !one.getId().equalsIgnoreCase("0")) { + return one.getName(); + } + } + for (NameList one : ListOfEntities) { + String ids = one.getId(); + if (ids.equalsIgnoreCase(String.valueOf(info.getId())) && !one.getId().equalsIgnoreCase("0")) { + return materialName = one.getName(); + } + } + break; + case ENCHANT: + for (NameList one : ListOfEnchants) { + String ids = one.getId(); + if (ids.equalsIgnoreCase(String.valueOf(info.getId()))) { + return one.getName() + " " + info.getMeta(); + } + } + for (NameList one : ListOfNames) { + String ids = one.getId() + ":" + one.getMeta(); + if (!one.getMeta().equalsIgnoreCase("") && ids.equalsIgnoreCase(info.getId() + ":" + info.getMeta()) && !one.getId().equalsIgnoreCase("0")) { + return one.getName(); + } + } + for (NameList one : ListOfNames) { + String ids = one.getId(); + if (ids.equalsIgnoreCase(String.valueOf(info.getId())) && !one.getId().equalsIgnoreCase("0")) { + return one.getName(); + } + } + break; + case CUSTOMKILL: + case MMKILL: + case EXPLORE: + break; + case SHEAR: + for (NameList one : ListOfColors) { + String ids = one.getMinecraftName(); + if (ids.equalsIgnoreCase(String.valueOf(info.getName()))) { + return one.getName(); + } + } + break; + } + + return materialName; + } + + public void readFile() { + YmlMaker ItemFile = new YmlMaker((JavaPlugin) plugin, "TranslatableWords.yml"); + ItemFile.saveDefaultConfig(); + ConfigurationSection section = ItemFile.getConfig().getConfigurationSection("ItemList"); + Set<String> keys = section.getKeys(false); + ListOfNames.clear(); + for (String one : keys) { + String id = one.contains(":") ? one.split(":")[0] : one; + String meta = one.contains(":") ? one.split(":")[1] : ""; + String MCName = section.getString(one + ".MCName"); + String Name = section.getString(one + ".Name"); + ListOfNames.add(new NameList(id, meta, Name, MCName)); + } + + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + ListOfNames.size() + " custom item names!"); + + section = ItemFile.getConfig().getConfigurationSection("EntityList"); + keys = section.getKeys(false); + ListOfEntities.clear(); + for (String one : keys) { + String id = one.contains(":") ? one.split(":")[0] : one; + String meta = one.contains(":") ? one.split(":")[1] : ""; + String MCName = section.getString(one + ".MCName"); + String Name = section.getString(one + ".Name"); + ListOfEntities.add(new NameList(id, meta, Name, MCName)); + } + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + ListOfEntities.size() + " custom entity names!"); + + section = ItemFile.getConfig().getConfigurationSection("EnchantList"); + keys = section.getKeys(false); + ListOfEnchants.clear(); + for (String one : keys) { + String id = one.contains(":") ? one.split(":")[0] : one; + String meta = one.contains(":") ? one.split(":")[1] : ""; + String MCName = section.getString(one + ".MCName"); + String Name = section.getString(one + ".Name"); + ListOfEnchants.add(new NameList(id, meta, Name, MCName)); + } + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + ListOfEnchants.size() + " custom enchant names!"); + + section = ItemFile.getConfig().getConfigurationSection("ColorList"); + keys = section.getKeys(false); + ListOfColors.clear(); + for (String one : keys) { + String id = one.contains(":") ? one.split(":")[0] : one; + String meta = one.contains(":") ? one.split(":")[1] : ""; + String MCName = section.getString(one + ".MCName"); + String Name = section.getString(one + ".Name"); + ListOfColors.add(new NameList(id, meta, Name, MCName)); + } + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + ListOfColors.size() + " custom color names!"); + } + + synchronized void load() { + File f = new File(plugin.getDataFolder(), "TranslatableWords.yml"); + YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); + CommentedYamlConfiguration write = new CommentedYamlConfiguration(); + LocaleReader c = new LocaleReader(conf, write); + + c.get("ItemList.0.MCName", "air"); + c.get("ItemList.0.Name", "Air"); + c.get("ItemList.1.MCName", "stone"); + c.get("ItemList.1.Name", "All Stone"); + c.get("ItemList.1:0.MCName", "stone"); + c.get("ItemList.1:0.Name", "Stone"); + c.get("ItemList.1:1.MCName", "stone"); + c.get("ItemList.1:1.Name", "Granite"); + c.get("ItemList.1:2.MCName", "stone"); + c.get("ItemList.1:2.Name", "Polished Granite"); + c.get("ItemList.1:3.MCName", "stone"); + c.get("ItemList.1:3.Name", "Diorite"); + c.get("ItemList.1:4.MCName", "stone"); + c.get("ItemList.1:4.Name", "Polished Diorite"); + c.get("ItemList.1:5.MCName", "stone"); + c.get("ItemList.1:5.Name", "Andesite"); + c.get("ItemList.1:6.MCName", "stone"); + c.get("ItemList.1:6.Name", "Polished Andesite"); + c.get("ItemList.2.MCName", "grass"); + c.get("ItemList.2.Name", "Grass"); + c.get("ItemList.3.MCName", "dirt"); + c.get("ItemList.3.Name", "All Dirt"); + c.get("ItemList.3:0.MCName", "dirt"); + c.get("ItemList.3:0.Name", "Dirt"); + c.get("ItemList.3:1.MCName", "dirt"); + c.get("ItemList.3:1.Name", "Coarse Dirt"); + c.get("ItemList.3:2.MCName", "dirt"); + c.get("ItemList.3:2.Name", "Podzol"); + c.get("ItemList.4.MCName", "cobblestone"); + c.get("ItemList.4.Name", "Cobblestone"); + c.get("ItemList.5.MCName", "planks"); + c.get("ItemList.5.Name", "All Wood Plank"); + c.get("ItemList.5:0.MCName", "planks"); + c.get("ItemList.5:0.Name", "Oak Wood Plank"); + c.get("ItemList.5:1.MCName", "planks"); + c.get("ItemList.5:1.Name", "Spruce Wood Plank"); + c.get("ItemList.5:2.MCName", "planks"); + c.get("ItemList.5:2.Name", "Birch Wood Plank"); + c.get("ItemList.5:3.MCName", "planks"); + c.get("ItemList.5:3.Name", "Jungle Wood Plank"); + c.get("ItemList.5:4.MCName", "planks"); + c.get("ItemList.5:4.Name", "Acacia Wood Plank"); + c.get("ItemList.5:5.MCName", "planks"); + c.get("ItemList.5:5.Name", "Dark Oak Wood Plank"); + c.get("ItemList.6.MCName", "sapling"); + c.get("ItemList.6.Name", "All Saplings"); + c.get("ItemList.6:0.MCName", "sapling"); + c.get("ItemList.6:0.Name", "Oak Sapling"); + c.get("ItemList.6:1.MCName", "sapling"); + c.get("ItemList.6:1.Name", "Spruce Sapling"); + c.get("ItemList.6:2.MCName", "sapling"); + c.get("ItemList.6:2.Name", "Birch Sapling"); + c.get("ItemList.6:3.MCName", "sapling"); + c.get("ItemList.6:3.Name", "Jungle Sapling"); + c.get("ItemList.6:4.MCName", "sapling"); + c.get("ItemList.6:4.Name", "Acacia Sapling"); + c.get("ItemList.6:5.MCName", "sapling"); + c.get("ItemList.6:5.Name", "Dark Oak Sapling"); + c.get("ItemList.7.MCName", "bedrock"); + c.get("ItemList.7.Name", "Bedrock"); + c.get("ItemList.8.MCName", "flowing_water"); + c.get("ItemList.8.Name", "Flowing Water"); + c.get("ItemList.9.MCName", "water"); + c.get("ItemList.9.Name", "Still Water"); + c.get("ItemList.10.MCName", "flowing_lava"); + c.get("ItemList.10.Name", "Flowing Lava"); + c.get("ItemList.11.MCName", "lava"); + c.get("ItemList.11.Name", "Still Lava"); + c.get("ItemList.12.MCName", "sand"); + c.get("ItemList.12.Name", "All Sand"); + c.get("ItemList.12:0.MCName", "sand"); + c.get("ItemList.12:0.Name", "Sand"); + c.get("ItemList.12:1.MCName", "sand"); + c.get("ItemList.12:1.Name", "Red Sand"); + c.get("ItemList.13.MCName", "gravel"); + c.get("ItemList.13.Name", "Gravel"); + c.get("ItemList.14.MCName", "gold_ore"); + c.get("ItemList.14.Name", "Gold Ore"); + c.get("ItemList.15.MCName", "iron_ore"); + c.get("ItemList.15.Name", "Iron Ore"); + c.get("ItemList.16.MCName", "coal_ore"); + c.get("ItemList.16.Name", "Coal Ore"); + c.get("ItemList.17.MCName", "log"); + c.get("ItemList.17.Name", "All Wood"); + c.get("ItemList.17:0.MCName", "log"); + c.get("ItemList.17:0.Name", "Oak Wood"); + c.get("ItemList.17:1.MCName", "log"); + c.get("ItemList.17:1.Name", "Spruce Wood"); + c.get("ItemList.17:2.MCName", "log"); + c.get("ItemList.17:2.Name", "Birch Wood"); + c.get("ItemList.17:3.MCName", "log"); + c.get("ItemList.17:3.Name", "Jungle Wood"); + c.get("ItemList.18.MCName", "leaves"); + c.get("ItemList.18.Name", "All Leaves"); + c.get("ItemList.18:0.MCName", "leaves"); + c.get("ItemList.18:0.Name", "Oak Leaves"); + c.get("ItemList.18:1.MCName", "leaves"); + c.get("ItemList.18:1.Name", "Spruce Leaves"); + c.get("ItemList.18:2.MCName", "leaves"); + c.get("ItemList.18:2.Name", "Birch Leaves"); + c.get("ItemList.18:3.MCName", "leaves"); + c.get("ItemList.18:3.Name", "Jungle Leaves"); + c.get("ItemList.19.MCName", "sponge"); + c.get("ItemList.19.Name", "Sponge"); + c.get("ItemList.19:1.MCName", "sponge"); + c.get("ItemList.19:1.Name", "Wet Sponge"); + c.get("ItemList.20.MCName", "glass"); + c.get("ItemList.20.Name", "Glass"); + c.get("ItemList.21.MCName", "lapis_ore"); + c.get("ItemList.21.Name", "Lapis Lazuli Ore"); + c.get("ItemList.22.MCName", "lapis_block"); + c.get("ItemList.22.Name", "Lapis Lazuli Block"); + c.get("ItemList.23.MCName", "dispenser"); + c.get("ItemList.23.Name", "Dispenser"); + c.get("ItemList.24.MCName", "sandstone"); + c.get("ItemList.24.Name", "Sandstone"); + c.get("ItemList.24:1.MCName", "sandstone"); + c.get("ItemList.24:1.Name", "Chiseled Sandstone"); + c.get("ItemList.24:2.MCName", "sandstone"); + c.get("ItemList.24:2.Name", "Smooth Sandstone"); + c.get("ItemList.25.MCName", "noteblock"); + c.get("ItemList.25.Name", "Note Block"); + c.get("ItemList.26.MCName", "bed"); + c.get("ItemList.26.Name", "Bed"); + c.get("ItemList.27.MCName", "golden_rail"); + c.get("ItemList.27.Name", "Powered Rail"); + c.get("ItemList.28.MCName", "detector_rail"); + c.get("ItemList.28.Name", "Detector Rail"); + c.get("ItemList.29.MCName", "sticky_piston"); + c.get("ItemList.29.Name", "Sticky Piston"); + c.get("ItemList.30.MCName", "web"); + c.get("ItemList.30.Name", "Cobweb"); + c.get("ItemList.31.MCName", "tallgrass"); + c.get("ItemList.31.Name", "Dead Shrub"); + c.get("ItemList.31:1.MCName", "tallgrass"); + c.get("ItemList.31:1.Name", "Grass"); + c.get("ItemList.31:2.MCName", "tallgrass"); + c.get("ItemList.31:2.Name", "Fern"); + c.get("ItemList.32.MCName", "deadbush"); + c.get("ItemList.32.Name", "Dead Shrub"); + c.get("ItemList.33.MCName", "piston"); + c.get("ItemList.33.Name", "Piston"); + c.get("ItemList.34.MCName", "piston_head"); + c.get("ItemList.34.Name", "Piston Head"); + c.get("ItemList.35.MCName", "wool"); + c.get("ItemList.35.Name", "All Wool"); + c.get("ItemList.35:0.MCName", "wool"); + c.get("ItemList.35:0.Name", "White Wool"); + c.get("ItemList.35:1.MCName", "wool"); + c.get("ItemList.35:1.Name", "Orange Wool"); + c.get("ItemList.35:2.MCName", "wool"); + c.get("ItemList.35:2.Name", "Magenta Wool"); + c.get("ItemList.35:3.MCName", "wool"); + c.get("ItemList.35:3.Name", "Light Blue Wool"); + c.get("ItemList.35:4.MCName", "wool"); + c.get("ItemList.35:4.Name", "Yellow Wool"); + c.get("ItemList.35:5.MCName", "wool"); + c.get("ItemList.35:5.Name", "Lime Wool"); + c.get("ItemList.35:6.MCName", "wool"); + c.get("ItemList.35:6.Name", "Pink Wool"); + c.get("ItemList.35:7.MCName", "wool"); + c.get("ItemList.35:7.Name", "Gray Wool"); + c.get("ItemList.35:8.MCName", "wool"); + c.get("ItemList.35:8.Name", "Light Gray Wool"); + c.get("ItemList.35:9.MCName", "wool"); + c.get("ItemList.35:9.Name", "Cyan Wool"); + c.get("ItemList.35:10.MCName", "wool"); + c.get("ItemList.35:10.Name", "Purple Wool"); + c.get("ItemList.35:11.MCName", "wool"); + c.get("ItemList.35:11.Name", "Blue Wool"); + c.get("ItemList.35:12.MCName", "wool"); + c.get("ItemList.35:12.Name", "Brown Wool"); + c.get("ItemList.35:13.MCName", "wool"); + c.get("ItemList.35:13.Name", "Green Wool"); + c.get("ItemList.35:14.MCName", "wool"); + c.get("ItemList.35:14.Name", "Red Wool"); + c.get("ItemList.35:15.MCName", "wool"); + c.get("ItemList.35:15.Name", "Black Wool"); + c.get("ItemList.37.MCName", "yellow_flower"); + c.get("ItemList.37.Name", "Dandelion"); + c.get("ItemList.38.MCName", "red_flower"); + c.get("ItemList.38.Name", "All Flowers"); + c.get("ItemList.38:0.MCName", "red_flower"); + c.get("ItemList.38:0.Name", "Poppy"); + c.get("ItemList.38:1.MCName", "red_flower"); + c.get("ItemList.38:1.Name", "Blue Orchid"); + c.get("ItemList.38:2.MCName", "red_flower"); + c.get("ItemList.38:2.Name", "Allium"); + c.get("ItemList.38:3.MCName", "red_flower"); + c.get("ItemList.38:3.Name", "Azure Bluet"); + c.get("ItemList.38:4.MCName", "red_flower"); + c.get("ItemList.38:4.Name", "Red Tulip"); + c.get("ItemList.38:5.MCName", "red_flower"); + c.get("ItemList.38:5.Name", "Orange Tulip"); + c.get("ItemList.38:6.MCName", "red_flower"); + c.get("ItemList.38:6.Name", "White Tulip"); + c.get("ItemList.38:7.MCName", "red_flower"); + c.get("ItemList.38:7.Name", "Pink Tulip"); + c.get("ItemList.38:8.MCName", "red_flower"); + c.get("ItemList.38:8.Name", "Oxeye Daisy"); + c.get("ItemList.39.MCName", "brown_mushroom"); + c.get("ItemList.39.Name", "Brown Mushroom"); + c.get("ItemList.40.MCName", "red_mushroom"); + c.get("ItemList.40.Name", "Red Mushroom"); + c.get("ItemList.41.MCName", "gold_block"); + c.get("ItemList.41.Name", "Gold Block"); + c.get("ItemList.42.MCName", "iron_block"); + c.get("ItemList.42.Name", "Iron Block"); + c.get("ItemList.43.MCName", "double_stone_slab"); + c.get("ItemList.43.Name", "All Double Slabs"); + c.get("ItemList.43:0.MCName", "double_stone_slab"); + c.get("ItemList.43:0.Name", "Double Stone Slab"); + c.get("ItemList.43:1.MCName", "double_stone_slab"); + c.get("ItemList.43:1.Name", "Double Sandstone Slab"); + c.get("ItemList.43:2.MCName", "double_stone_slab"); + c.get("ItemList.43:2.Name", "Double Wooden Slab"); + c.get("ItemList.43:3.MCName", "double_stone_slab"); + c.get("ItemList.43:3.Name", "Double Cobblestone Slab"); + c.get("ItemList.43:4.MCName", "double_stone_slab"); + c.get("ItemList.43:4.Name", "Double Brick Slab"); + c.get("ItemList.43:5.MCName", "double_stone_slab"); + c.get("ItemList.43:5.Name", "Double Stone Brick Slab"); + c.get("ItemList.43:6.MCName", "double_stone_slab"); + c.get("ItemList.43:6.Name", "Double Nether Brick Slab"); + c.get("ItemList.43:7.MCName", "double_stone_slab"); + c.get("ItemList.43:7.Name", "Double Quartz Slab"); + c.get("ItemList.44.MCName", "stone_slab"); + c.get("ItemList.44.Name", "All Slabs"); + c.get("ItemList.44:0.MCName", "stone_slab"); + c.get("ItemList.44:0.Name", "Stone Slab"); + c.get("ItemList.44:1.MCName", "stone_slab"); + c.get("ItemList.44:1.Name", "Sandstone Slab"); + c.get("ItemList.44:2.MCName", "stone_slab"); + c.get("ItemList.44:2.Name", "Wooden Slab"); + c.get("ItemList.44:3.MCName", "stone_slab"); + c.get("ItemList.44:3.Name", "Cobblestone Slab"); + c.get("ItemList.44:4.MCName", "stone_slab"); + c.get("ItemList.44:4.Name", "Brick Slab"); + c.get("ItemList.44:5.MCName", "stone_slab"); + c.get("ItemList.44:5.Name", "Stone Brick Slab"); + c.get("ItemList.44:6.MCName", "stone_slab"); + c.get("ItemList.44:6.Name", "Nether Brick Slab"); + c.get("ItemList.44:7.MCName", "stone_slab"); + c.get("ItemList.44:7.Name", "Quartz Slab"); + c.get("ItemList.45.MCName", "brick_block"); + c.get("ItemList.45.Name", "Bricks"); + c.get("ItemList.46.MCName", "tnt"); + c.get("ItemList.46.Name", "TNT"); + c.get("ItemList.47.MCName", "bookshelf"); + c.get("ItemList.47.Name", "Bookshelf"); + c.get("ItemList.48.MCName", "mossy_cobblestone"); + c.get("ItemList.48.Name", "Moss Stone"); + c.get("ItemList.49.MCName", "obsidian"); + c.get("ItemList.49.Name", "Obsidian"); + c.get("ItemList.50.MCName", "torch"); + c.get("ItemList.50.Name", "Torch"); + c.get("ItemList.51.MCName", "fire"); + c.get("ItemList.51.Name", "Fire"); + c.get("ItemList.52.MCName", "mob_spawner"); + c.get("ItemList.52.Name", "Monster Spawner"); + c.get("ItemList.53.MCName", "oak_stairs"); + c.get("ItemList.53.Name", "Oak Wood Stairs"); + c.get("ItemList.54.MCName", "chest"); + c.get("ItemList.54.Name", "Chest"); + c.get("ItemList.55.MCName", "redstone_wire"); + c.get("ItemList.55.Name", "Redstone Wire"); + c.get("ItemList.56.MCName", "diamond_ore"); + c.get("ItemList.56.Name", "Diamond Ore"); + c.get("ItemList.57.MCName", "diamond_block"); + c.get("ItemList.57.Name", "Diamond Block"); + c.get("ItemList.58.MCName", "crafting_table"); + c.get("ItemList.58.Name", "Crafting Table"); + c.get("ItemList.59.MCName", "wheat"); + c.get("ItemList.59.Name", "Wheat Crops"); + c.get("ItemList.60.MCName", "farmland"); + c.get("ItemList.60.Name", "Farmland"); + c.get("ItemList.61.MCName", "furnace"); + c.get("ItemList.61.Name", "Furnace"); + c.get("ItemList.62.MCName", "lit_furnace"); + c.get("ItemList.62.Name", "Burning Furnace"); + c.get("ItemList.63.MCName", "standing_sign"); + c.get("ItemList.63.Name", "Standing Sign Block"); + c.get("ItemList.64.MCName", "wooden_door"); + c.get("ItemList.64.Name", "Wooden Door Block"); + c.get("ItemList.65.MCName", "ladder"); + c.get("ItemList.65.Name", "Ladder"); + c.get("ItemList.66.MCName", "rail"); + c.get("ItemList.66.Name", "Rail"); + c.get("ItemList.67.MCName", "stone_stairs"); + c.get("ItemList.67.Name", "Cobblestone Stairs"); + c.get("ItemList.68.MCName", "wall_sign"); + c.get("ItemList.68.Name", "Wall-mounted Sign Block"); + c.get("ItemList.69.MCName", "lever"); + c.get("ItemList.69.Name", "Lever"); + c.get("ItemList.70.MCName", "stone_pressure_plate"); + c.get("ItemList.70.Name", "Stone Pressure Plate"); + c.get("ItemList.71.MCName", "iron_door"); + c.get("ItemList.71.Name", "Iron Door Block"); + c.get("ItemList.72.MCName", "wooden_pressure_plate"); + c.get("ItemList.72.Name", "Wooden Pressure Plate"); + c.get("ItemList.73.MCName", "redstone_ore"); + c.get("ItemList.73.Name", "Redstone Ore"); + c.get("ItemList.74.MCName", "lit_redstone_ore"); + c.get("ItemList.74.Name", "Glowing Redstone Ore"); + c.get("ItemList.75.MCName", "unlit_redstone_torch"); + c.get("ItemList.75.Name", "Redstone Torch (off)"); + c.get("ItemList.76.MCName", "redstone_torch"); + c.get("ItemList.76.Name", "Redstone Torch (on)"); + c.get("ItemList.77.MCName", "stone_button"); + c.get("ItemList.77.Name", "Stone Button"); + c.get("ItemList.78.MCName", "snow_layer"); + c.get("ItemList.78.Name", "Snow"); + c.get("ItemList.79.MCName", "ice"); + c.get("ItemList.79.Name", "Ice"); + c.get("ItemList.80.MCName", "snow"); + c.get("ItemList.80.Name", "Snow Block"); + c.get("ItemList.81.MCName", "cactus"); + c.get("ItemList.81.Name", "Cactus"); + c.get("ItemList.82.MCName", "clay"); + c.get("ItemList.82.Name", "Clay"); + c.get("ItemList.83.MCName", "reeds"); + c.get("ItemList.83.Name", "Sugar Canes"); + c.get("ItemList.84.MCName", "jukebox"); + c.get("ItemList.84.Name", "Jukebox"); + c.get("ItemList.85.MCName", "fence"); + c.get("ItemList.85.Name", "Oak Fence"); + c.get("ItemList.86.MCName", "pumpkin"); + c.get("ItemList.86.Name", "Pumpkin"); + c.get("ItemList.87.MCName", "netherrack"); + c.get("ItemList.87.Name", "Netherrack"); + c.get("ItemList.88.MCName", "soul_sand"); + c.get("ItemList.88.Name", "Soul Sand"); + c.get("ItemList.89.MCName", "glowstone"); + c.get("ItemList.89.Name", "Glowstone"); + c.get("ItemList.90.MCName", "portal"); + c.get("ItemList.90.Name", "Nether Portal"); + c.get("ItemList.91.MCName", "lit_pumpkin"); + c.get("ItemList.91.Name", "Jack o'Lantern"); + c.get("ItemList.92.MCName", "cake"); + c.get("ItemList.92.Name", "Cake Block"); + c.get("ItemList.93.MCName", "unpowered_repeater"); + c.get("ItemList.93.Name", "Redstone Repeater Block (off)"); + c.get("ItemList.94.MCName", "powered_repeater"); + c.get("ItemList.94.Name", "Redstone Repeater Block (on)"); + c.get("ItemList.95.MCName", "stained_glass"); + c.get("ItemList.95.Name", "All Stained Glass"); + c.get("ItemList.95:0.MCName", "stained_glass"); + c.get("ItemList.95:0.Name", "White Stained Glass"); + c.get("ItemList.95:1.MCName", "stained_glass"); + c.get("ItemList.95:1.Name", "Orange Stained Glass"); + c.get("ItemList.95:2.MCName", "stained_glass"); + c.get("ItemList.95:2.Name", "Magenta Stained Glass"); + c.get("ItemList.95:3.MCName", "stained_glass"); + c.get("ItemList.95:3.Name", "Light Blue Stained Glass"); + c.get("ItemList.95:4.MCName", "stained_glass"); + c.get("ItemList.95:4.Name", "Yellow Stained Glass"); + c.get("ItemList.95:5.MCName", "stained_glass"); + c.get("ItemList.95:5.Name", "Lime Stained Glass"); + c.get("ItemList.95:6.MCName", "stained_glass"); + c.get("ItemList.95:6.Name", "Pink Stained Glass"); + c.get("ItemList.95:7.MCName", "stained_glass"); + c.get("ItemList.95:7.Name", "Gray Stained Glass"); + c.get("ItemList.95:8.MCName", "stained_glass"); + c.get("ItemList.95:8.Name", "Light Gray Stained Glass"); + c.get("ItemList.95:9.MCName", "stained_glass"); + c.get("ItemList.95:9.Name", "Cyan Stained Glass"); + c.get("ItemList.95:10.MCName", "stained_glass"); + c.get("ItemList.95:10.Name", "Purple Stained Glass"); + c.get("ItemList.95:11.MCName", "stained_glass"); + c.get("ItemList.95:11.Name", "Blue Stained Glass"); + c.get("ItemList.95:12.MCName", "stained_glass"); + c.get("ItemList.95:12.Name", "Brown Stained Glass"); + c.get("ItemList.95:13.MCName", "stained_glass"); + c.get("ItemList.95:13.Name", "Green Stained Glass"); + c.get("ItemList.95:14.MCName", "stained_glass"); + c.get("ItemList.95:14.Name", "Red Stained Glass"); + c.get("ItemList.95:15.MCName", "stained_glass"); + c.get("ItemList.95:15.Name", "Black Stained Glass"); + c.get("ItemList.96.MCName", "trapdoor"); + c.get("ItemList.96.Name", "Wooden Trapdoor"); + c.get("ItemList.97.MCName", "monster_egg"); + c.get("ItemList.97.Name", "Stone Monster Egg"); + c.get("ItemList.97:1.MCName", "monster_egg"); + c.get("ItemList.97:1.Name", "Cobblestone Monster Egg"); + c.get("ItemList.97:2.MCName", "monster_egg"); + c.get("ItemList.97:2.Name", "Stone Brick Monster Egg"); + c.get("ItemList.97:3.MCName", "monster_egg"); + c.get("ItemList.97:3.Name", "Mossy Stone Brick Monster Egg"); + c.get("ItemList.97:4.MCName", "monster_egg"); + c.get("ItemList.97:4.Name", "Cracked Stone Brick Monster Egg"); + c.get("ItemList.97:5.MCName", "monster_egg"); + c.get("ItemList.97:5.Name", "Chiseled Stone Brick Monster Egg"); + c.get("ItemList.98.MCName", "stonebrick"); + c.get("ItemList.98.Name", "Stone Bricks"); + c.get("ItemList.98:1.MCName", "stonebrick"); + c.get("ItemList.98:1.Name", "Mossy Stone Bricks"); + c.get("ItemList.98:2.MCName", "stonebrick"); + c.get("ItemList.98:2.Name", "Cracked Stone Bricks"); + c.get("ItemList.98:3.MCName", "stonebrick"); + c.get("ItemList.98:3.Name", "Chiseled Stone Bricks"); + c.get("ItemList.99.MCName", "stonebrick"); + c.get("ItemList.99.Name", "Red Mushroom Cap"); + c.get("ItemList.100.MCName", "stonebrick"); + c.get("ItemList.100.Name", "Brown Mushroom Cap"); + c.get("ItemList.101.MCName", "iron_bars"); + c.get("ItemList.101.Name", "Iron Bars"); + c.get("ItemList.102.MCName", "glass_pane"); + c.get("ItemList.102.Name", "Glass Pane"); + c.get("ItemList.103.MCName", "melon_block"); + c.get("ItemList.103.Name", "Melon Block"); + c.get("ItemList.104.MCName", "pumpkin_stem"); + c.get("ItemList.104.Name", "Pumpkin Stem"); + c.get("ItemList.105.MCName", "melon_stem"); + c.get("ItemList.105.Name", "Melon Stem"); + c.get("ItemList.106.MCName", "vine"); + c.get("ItemList.106.Name", "Vines"); + c.get("ItemList.107.MCName", "fence_gate"); + c.get("ItemList.107.Name", "Oak Fence Gate"); + c.get("ItemList.108.MCName", "brick_stairs"); + c.get("ItemList.108.Name", "Brick Stairs"); + c.get("ItemList.109.MCName", "stone_brick_stairs"); + c.get("ItemList.109.Name", "Stone Brick Stairs"); + c.get("ItemList.110.MCName", "mycelium"); + c.get("ItemList.110.Name", "Mycelium"); + c.get("ItemList.111.MCName", "waterlily"); + c.get("ItemList.111.Name", "Lily Pad"); + c.get("ItemList.112.MCName", "nether_brick"); + c.get("ItemList.112.Name", "Nether Brick"); + c.get("ItemList.113.MCName", "nether_brick_fence"); + c.get("ItemList.113.Name", "Nether Brick Fence"); + c.get("ItemList.114.MCName", "nether_brick_stairs"); + c.get("ItemList.114.Name", "Nether Brick Stairs"); + c.get("ItemList.115.MCName", "nether_wart"); + c.get("ItemList.115.Name", "Nether Wart"); + c.get("ItemList.116.MCName", "enchanting_table"); + c.get("ItemList.116.Name", "Enchantment Table"); + c.get("ItemList.117.MCName", "brewing_stand"); + c.get("ItemList.117.Name", "Brewing Stand"); + c.get("ItemList.118.MCName", "cauldron"); + c.get("ItemList.118.Name", "Cauldron"); + c.get("ItemList.119.MCName", "end_portal"); + c.get("ItemList.119.Name", "End Portal"); + c.get("ItemList.120.MCName", "end_portal_frame"); + c.get("ItemList.120.Name", "End Portal Frame"); + c.get("ItemList.121.MCName", "end_stone"); + c.get("ItemList.121.Name", "End Stone"); + c.get("ItemList.122.MCName", "dragon_egg"); + c.get("ItemList.122.Name", "Dragon Egg"); + c.get("ItemList.123.MCName", "redstone_lamp"); + c.get("ItemList.123.Name", "Redstone Lamp (inactive)"); + c.get("ItemList.124.MCName", "lit_redstone_lamp"); + c.get("ItemList.124.Name", "Redstone Lamp (active)"); + c.get("ItemList.125.MCName", "double_wooden_slab"); + c.get("ItemList.125.Name", "All Double Wood Slab"); + c.get("ItemList.125:0.MCName", "double_wooden_slab"); + c.get("ItemList.125:0.Name", "Double Oak Wood Slab"); + c.get("ItemList.125:1.MCName", "double_wooden_slab"); + c.get("ItemList.125:1.Name", "Double Spruce Wood Slab"); + c.get("ItemList.125:2.MCName", "double_wooden_slab"); + c.get("ItemList.125:2.Name", "Double Birch Wood Slab"); + c.get("ItemList.125:3.MCName", "double_wooden_slab"); + c.get("ItemList.125:3.Name", "Double Jungle Wood Slab"); + c.get("ItemList.125:4.MCName", "double_wooden_slab"); + c.get("ItemList.125:4.Name", "Double Acacia Wood Slab"); + c.get("ItemList.125:5.MCName", "double_wooden_slab"); + c.get("ItemList.125:5.Name", "Double Dark Oak Wood Slab"); + c.get("ItemList.126.MCName", "wooden_slab"); + c.get("ItemList.126.Name", "All Wood Slab"); + c.get("ItemList.126:0.MCName", "wooden_slab"); + c.get("ItemList.126:0.Name", "Oak Wood Slab"); + c.get("ItemList.126:1.MCName", "wooden_slab"); + c.get("ItemList.126:1.Name", "Spruce Wood Slab"); + c.get("ItemList.126:2.MCName", "wooden_slab"); + c.get("ItemList.126:2.Name", "Birch Wood Slab"); + c.get("ItemList.126:3.MCName", "wooden_slab"); + c.get("ItemList.126:3.Name", "Jungle Wood Slab"); + c.get("ItemList.126:4.MCName", "wooden_slab"); + c.get("ItemList.126:4.Name", "Acacia Wood Slab"); + c.get("ItemList.126:5.MCName", "wooden_slab"); + c.get("ItemList.126:5.Name", "Dark Oak Wood Slab"); + c.get("ItemList.127.MCName", "cocoa"); + c.get("ItemList.127.Name", "Cocoa"); + c.get("ItemList.128.MCName", "sandstone_stairs"); + c.get("ItemList.128.Name", "Sandstone Stairs"); + c.get("ItemList.129.MCName", "emerald_ore"); + c.get("ItemList.129.Name", "Emerald Ore"); + c.get("ItemList.130.MCName", "ender_chest"); + c.get("ItemList.130.Name", "Ender Chest"); + c.get("ItemList.131.MCName", "tripwire_hook"); + c.get("ItemList.131.Name", "Tripwire Hook"); + c.get("ItemList.132.MCName", "tripwire_hook"); + c.get("ItemList.132.Name", "Tripwire"); + c.get("ItemList.133.MCName", "emerald_block"); + c.get("ItemList.133.Name", "Emerald Block"); + c.get("ItemList.134.MCName", "spruce_stairs"); + c.get("ItemList.134.Name", "Spruce Wood Stairs"); + c.get("ItemList.135.MCName", "birch_stairs"); + c.get("ItemList.135.Name", "Birch Wood Stairs"); + c.get("ItemList.136.MCName", "jungle_stairs"); + c.get("ItemList.136.Name", "Jungle Wood Stairs"); + c.get("ItemList.137.MCName", "command_block"); + c.get("ItemList.137.Name", "Command Block"); + c.get("ItemList.138.MCName", "beacon"); + c.get("ItemList.138.Name", "Beacon"); + c.get("ItemList.139.MCName", "cobblestone_wall"); + c.get("ItemList.139.Name", "Cobblestone Wall"); + c.get("ItemList.139:1.MCName", "cobblestone_wall"); + c.get("ItemList.139:1.Name", "Mossy Cobblestone Wall"); + c.get("ItemList.140.MCName", "flower_pot"); + c.get("ItemList.140.Name", "Flower Pot"); + c.get("ItemList.141.MCName", "carrots"); + c.get("ItemList.141.Name", "Carrots"); + c.get("ItemList.142.MCName", "potatoes"); + c.get("ItemList.142.Name", "Potatoes"); + c.get("ItemList.143.MCName", "wooden_button"); + c.get("ItemList.143.Name", "Wooden Button"); + c.get("ItemList.144.MCName", "skull"); + c.get("ItemList.144.Name", "Mob Head"); + c.get("ItemList.145.MCName", "anvil"); + c.get("ItemList.145.Name", "Anvil"); + c.get("ItemList.146.MCName", "trapped_chest"); + c.get("ItemList.146.Name", "Trapped Chest"); + c.get("ItemList.147.MCName", "light_weighted_pressure_plate"); + c.get("ItemList.147.Name", "Weighted Pressure Plate (light)"); + c.get("ItemList.148.MCName", "heavy_weighted_pressure_plate"); + c.get("ItemList.148.Name", "Weighted Pressure Plate (heavy)"); + c.get("ItemList.149.MCName", "unpowered_comparator"); + c.get("ItemList.149.Name", "Redstone Comparator (inactive)"); + c.get("ItemList.150.MCName", "powered_comparator"); + c.get("ItemList.150.Name", "Redstone Comparator (active)"); + c.get("ItemList.151.MCName", "daylight_detector"); + c.get("ItemList.151.Name", "Daylight Sensor"); + c.get("ItemList.152.MCName", "redstone_block"); + c.get("ItemList.152.Name", "Redstone Block"); + c.get("ItemList.153.MCName", "quartz_ore"); + c.get("ItemList.153.Name", "Nether Quartz Ore"); + c.get("ItemList.154.MCName", "hopper"); + c.get("ItemList.154.Name", "Hopper"); + c.get("ItemList.155.MCName", "quartz_block"); + c.get("ItemList.155.Name", "Quartz Block"); + c.get("ItemList.155:1.MCName", "quartz_block"); + c.get("ItemList.155:1.Name", "Chiseled Quartz Block"); + c.get("ItemList.155:2.MCName", "quartz_block"); + c.get("ItemList.155:2.Name", "Pillar Quartz Block"); + c.get("ItemList.156.MCName", "quartz_stairs"); + c.get("ItemList.156.Name", "Quartz Stairs"); + c.get("ItemList.157.MCName", "activator_rail"); + c.get("ItemList.157.Name", "Activator Rail"); + c.get("ItemList.158.MCName", "dropper"); + c.get("ItemList.158.Name", "Dropper"); + c.get("ItemList.159.MCName", "stained_hardened_clay"); + c.get("ItemList.159.Name", "All Stained Clays"); + c.get("ItemList.159:0.MCName", "stained_hardened_clay"); + c.get("ItemList.159:0.Name", "White Stained Clay"); + c.get("ItemList.159:1.MCName", "stained_hardened_clay"); + c.get("ItemList.159:1.Name", "Orange Stained Clay"); + c.get("ItemList.159:2.MCName", "stained_hardened_clay"); + c.get("ItemList.159:2.Name", "Magenta Stained Clay"); + c.get("ItemList.159:3.MCName", "stained_hardened_clay"); + c.get("ItemList.159:3.Name", "Light Blue Stained Clay"); + c.get("ItemList.159:4.MCName", "stained_hardened_clay"); + c.get("ItemList.159:4.Name", "Yellow Stained Clay"); + c.get("ItemList.159:5.MCName", "stained_hardened_clay"); + c.get("ItemList.159:5.Name", "Lime Stained Clay"); + c.get("ItemList.159:6.MCName", "stained_hardened_clay"); + c.get("ItemList.159:6.Name", "Pink Stained Clay"); + c.get("ItemList.159:7.MCName", "stained_hardened_clay"); + c.get("ItemList.159:7.Name", "Gray Stained Clay"); + c.get("ItemList.159:8.MCName", "stained_hardened_clay"); + c.get("ItemList.159:8.Name", "Light Gray Stained Clay"); + c.get("ItemList.159:9.MCName", "stained_hardened_clay"); + c.get("ItemList.159:9.Name", "Cyan Stained Clay"); + c.get("ItemList.159:10.MCName", "stained_hardened_clay"); + c.get("ItemList.159:10.Name", "Purple Stained Clay"); + c.get("ItemList.159:11.MCName", "stained_hardened_clay"); + c.get("ItemList.159:11.Name", "Blue Stained Clay"); + c.get("ItemList.159:12.MCName", "stained_hardened_clay"); + c.get("ItemList.159:12.Name", "Brown Stained Clay"); + c.get("ItemList.159:13.MCName", "stained_hardened_clay"); + c.get("ItemList.159:13.Name", "Green Stained Clay"); + c.get("ItemList.159:14.MCName", "stained_hardened_clay"); + c.get("ItemList.159:14.Name", "Red Stained Clay"); + c.get("ItemList.159:15.MCName", "stained_hardened_clay"); + c.get("ItemList.159:15.Name", "Black Stained Clay"); + c.get("ItemList.160.MCName", "stained_glass_pane"); + c.get("ItemList.160.Name", "All Stained Glass Panes"); + c.get("ItemList.160:0.MCName", "stained_glass_pane"); + c.get("ItemList.160:0.Name", "White Stained Glass Pane"); + c.get("ItemList.160:1.MCName", "stained_glass_pane"); + c.get("ItemList.160:1.Name", "Orange Stained Glass Pane"); + c.get("ItemList.160:2.MCName", "stained_glass_pane"); + c.get("ItemList.160:2.Name", "Magenta Stained Glass Pane"); + c.get("ItemList.160:3.MCName", "stained_glass_pane"); + c.get("ItemList.160:3.Name", "Light Blue Stained Glass Pane"); + c.get("ItemList.160:4.MCName", "stained_glass_pane"); + c.get("ItemList.160:4.Name", "Yellow Stained Glass Pane"); + c.get("ItemList.160:5.MCName", "stained_glass_pane"); + c.get("ItemList.160:5.Name", "Lime Stained Glass Pane"); + c.get("ItemList.160:6.MCName", "stained_glass_pane"); + c.get("ItemList.160:6.Name", "Pink Stained Glass Pane"); + c.get("ItemList.160:7.MCName", "stained_glass_pane"); + c.get("ItemList.160:7.Name", "Gray Stained Glass Pane"); + c.get("ItemList.160:8.MCName", "stained_glass_pane"); + c.get("ItemList.160:8.Name", "Light Gray Stained Glass Pane"); + c.get("ItemList.160:9.MCName", "stained_glass_pane"); + c.get("ItemList.160:9.Name", "Cyan Stained Glass Pane"); + c.get("ItemList.160:10.MCName", "stained_glass_pane"); + c.get("ItemList.160:10.Name", "Purple Stained Glass Pane"); + c.get("ItemList.160:11.MCName", "stained_glass_pane"); + c.get("ItemList.160:11.Name", "Blue Stained Glass Pane"); + c.get("ItemList.160:12.MCName", "stained_glass_pane"); + c.get("ItemList.160:12.Name", "Brown Stained Glass Pane"); + c.get("ItemList.160:13.MCName", "stained_glass_pane"); + c.get("ItemList.160:13.Name", "Green Stained Glass Pane"); + c.get("ItemList.160:14.MCName", "stained_glass_pane"); + c.get("ItemList.160:14.Name", "Red Stained Glass Pane"); + c.get("ItemList.160:15.MCName", "stained_glass_pane"); + c.get("ItemList.160:15.Name", "Black Stained Glass Pane"); + c.get("ItemList.161.MCName", "leaves2"); + c.get("ItemList.161.Name", "Acacia Or Dark Oak Leaves"); + c.get("ItemList.161:0.MCName", "leaves2"); + c.get("ItemList.161:0.Name", "Acacia Leaves"); + c.get("ItemList.161:1.MCName", "leaves2"); + c.get("ItemList.161:1.Name", "Dark Oak Leaves"); + c.get("ItemList.162.MCName", "logs2"); + c.get("ItemList.162.Name", "Acacia Or Dark Oak Wood"); + c.get("ItemList.162:0.MCName", "logs2"); + c.get("ItemList.162:0.Name", "Acacia Wood"); + c.get("ItemList.162:1.MCName", "logs2"); + c.get("ItemList.162:1.Name", "Dark Oak Wood"); + c.get("ItemList.163.MCName", "acacia_stairs"); + c.get("ItemList.163.Name", "Acacia Wood Stairs"); + c.get("ItemList.164.MCName", "dark_oak_stairs"); + c.get("ItemList.164.Name", "Dark Oak Wood Stairs"); + c.get("ItemList.165.MCName", "slime"); + c.get("ItemList.165.Name", "Slime Block"); + c.get("ItemList.166.MCName", "barrier"); + c.get("ItemList.166.Name", "Barrier"); + c.get("ItemList.167.MCName", "iron_trapdoor"); + c.get("ItemList.167.Name", "Iron Trapdoor"); + c.get("ItemList.168.MCName", "prismarine"); + c.get("ItemList.168.Name", "All Prismarine"); + c.get("ItemList.168:0.MCName", "prismarine"); + c.get("ItemList.168:0.Name", "Prismarine"); + c.get("ItemList.168:1.MCName", "prismarine"); + c.get("ItemList.168:1.Name", "Prismarine Bricks"); + c.get("ItemList.168:2.MCName", "prismarine"); + c.get("ItemList.168:2.Name", "Dark Prismarine"); + c.get("ItemList.169.MCName", "sea_lantern"); + c.get("ItemList.169.Name", "Sea Lantern"); + c.get("ItemList.170.MCName", "hay_block"); + c.get("ItemList.170.Name", "Hay Bale"); + c.get("ItemList.171.MCName", "carpet"); + c.get("ItemList.171.Name", "All Carpet"); + c.get("ItemList.171:0.MCName", "carpet"); + c.get("ItemList.171:0.Name", "White Carpet"); + c.get("ItemList.171:1.MCName", "carpet"); + c.get("ItemList.171:1.Name", "Orange Carpet"); + c.get("ItemList.171:2.MCName", "carpet"); + c.get("ItemList.171:2.Name", "Magenta Carpet"); + c.get("ItemList.171:3.MCName", "carpet"); + c.get("ItemList.171:3.Name", "Light Blue Carpet"); + c.get("ItemList.171:4.MCName", "carpet"); + c.get("ItemList.171:4.Name", "Yellow Carpet"); + c.get("ItemList.171:5.MCName", "carpet"); + c.get("ItemList.171:5.Name", "Lime Carpet"); + c.get("ItemList.171:6.MCName", "carpet"); + c.get("ItemList.171:6.Name", "Pink Carpet"); + c.get("ItemList.171:7.MCName", "carpet"); + c.get("ItemList.171:7.Name", "Gray Carpet"); + c.get("ItemList.171:8.MCName", "carpet"); + c.get("ItemList.171:8.Name", "Light Gray Carpet"); + c.get("ItemList.171:9.MCName", "carpet"); + c.get("ItemList.171:9.Name", "Cyan Carpet"); + c.get("ItemList.171:10.MCName", "carpet"); + c.get("ItemList.171:10.Name", "Purple Carpet"); + c.get("ItemList.171:11.MCName", "carpet"); + c.get("ItemList.171:11.Name", "Blue Carpet"); + c.get("ItemList.171:12.MCName", "carpet"); + c.get("ItemList.171:12.Name", "Brown Carpet"); + c.get("ItemList.171:13.MCName", "carpet"); + c.get("ItemList.171:13.Name", "Green Carpet"); + c.get("ItemList.171:14.MCName", "carpet"); + c.get("ItemList.171:14.Name", "Red Carpet"); + c.get("ItemList.171:15.MCName", "carpet"); + c.get("ItemList.171:15.Name", "Black Carpet"); + c.get("ItemList.172.MCName", "hardened_clay"); + c.get("ItemList.172.Name", "Hardened Clay"); + c.get("ItemList.173.MCName", "coal_block"); + c.get("ItemList.173.Name", "Block of Coal"); + c.get("ItemList.174.MCName", "packed_ice"); + c.get("ItemList.174.Name", "Packed Ice"); + c.get("ItemList.175.MCName", "double_plant"); + c.get("ItemList.175.Name", "All Big Flowers"); + c.get("ItemList.175:0.MCName", "double_plant"); + c.get("ItemList.175:0.Name", "Sunflower"); + c.get("ItemList.175:1.MCName", "double_plant"); + c.get("ItemList.175:1.Name", "Lilac"); + c.get("ItemList.175:2.MCName", "double_plant"); + c.get("ItemList.175:2.Name", "Double Tallgrass"); + c.get("ItemList.175:3.MCName", "double_plant"); + c.get("ItemList.175:3.Name", "Large Fern"); + c.get("ItemList.175:4.MCName", "double_plant"); + c.get("ItemList.175:4.Name", "Rose Bush"); + c.get("ItemList.175:5.MCName", "double_plant"); + c.get("ItemList.175:5.Name", "Peony"); + c.get("ItemList.176.MCName", "standing_banner"); + c.get("ItemList.176.Name", "Free-standing Banner"); + c.get("ItemList.177.MCName", "wall_banner"); + c.get("ItemList.177.Name", "Wall-mounted Banner"); + c.get("ItemList.178.MCName", "daylight_detector_inverted"); + c.get("ItemList.178.Name", "Inverted Daylight Sensor"); + c.get("ItemList.179.MCName", "red_sandstone"); + c.get("ItemList.179.Name", "Red Sandstone"); + c.get("ItemList.179:1.MCName", "red_sandstone"); + c.get("ItemList.179:1.Name", "Smooth Red Sandstone"); + c.get("ItemList.179:2.MCName", "red_sandstone"); + c.get("ItemList.179:2.Name", "Chiseled Red Sandstone"); + c.get("ItemList.180.MCName", "red_sandstone_stairs"); + c.get("ItemList.180.Name", "Red Sandstone Stairs"); + c.get("ItemList.181.MCName", "stone_slab2"); + c.get("ItemList.181.Name", "Double Red Sandstone Slab"); + c.get("ItemList.182.MCName", "double_stone_slab2"); + c.get("ItemList.182.Name", "Red Sandstone Slab"); + c.get("ItemList.183.MCName", "spruce_fence_gate"); + c.get("ItemList.183.Name", "Spruce Fence Gate"); + c.get("ItemList.184.MCName", "birch_fence_gate"); + c.get("ItemList.184.Name", "Birch Fence Gate"); + c.get("ItemList.185.MCName", "jungle_fence_gate"); + c.get("ItemList.185.Name", "Jungle Fence Gate"); + c.get("ItemList.186.MCName", "dark_oak_fence_gate"); + c.get("ItemList.186.Name", "Dark Oak Fence Gate"); + c.get("ItemList.187.MCName", "acacia_fence_gate"); + c.get("ItemList.187.Name", "Acacia Fence Gate"); + c.get("ItemList.188.MCName", "spruce_fence"); + c.get("ItemList.188.Name", "Spruce Fence"); + c.get("ItemList.189.MCName", "birch_fence"); + c.get("ItemList.189.Name", "Birch Fence"); + c.get("ItemList.190.MCName", "jungle_fence"); + c.get("ItemList.190.Name", "Jungle Fence"); + c.get("ItemList.191.MCName", "dark_oak_fence"); + c.get("ItemList.191.Name", "Dark Oak Fence"); + c.get("ItemList.192.MCName", "acacia_fence"); + c.get("ItemList.192.Name", "Acacia Fence"); + c.get("ItemList.193.MCName", "spruce_door"); + c.get("ItemList.193.Name", "Spure Door Block"); + c.get("ItemList.194.MCName", "birch_door"); + c.get("ItemList.194.Name", "Birch Door Block"); + c.get("ItemList.195.MCName", "jungle_door"); + c.get("ItemList.195.Name", "Jungle Door Block"); + c.get("ItemList.196.MCName", "acacia_door"); + c.get("ItemList.196.Name", "Acacia Door Block"); + c.get("ItemList.197.MCName", "dark_oak_door"); + c.get("ItemList.197.Name", "Dark Oak Door Block"); + c.get("ItemList.198.MCName", "end_rod"); + c.get("ItemList.198.Name", "End Rod"); + c.get("ItemList.199.MCName", "chorus_plant"); + c.get("ItemList.199.Name", "Chorus Plant"); + c.get("ItemList.200.MCName", "chorus_flower"); + c.get("ItemList.200.Name", "Chorus Flower"); + c.get("ItemList.201.MCName", "purpur_block"); + c.get("ItemList.201.Name", "Purpur Block"); + c.get("ItemList.202.MCName", "purpur_pillar"); + c.get("ItemList.202.Name", "Purpur Pillar"); + c.get("ItemList.203.MCName", "purpur_stairs"); + c.get("ItemList.203.Name", "Purpur Stairs"); + c.get("ItemList.204.MCName", "purpur_double_slab"); + c.get("ItemList.204.Name", "Double Purpur Slab"); + c.get("ItemList.205.MCName", "purpur_slab"); + c.get("ItemList.205.Name", "Purpur Slab"); + c.get("ItemList.206.MCName", "end_bricks"); + c.get("ItemList.206.Name", "End Stone Bricks"); + c.get("ItemList.208.MCName", "grass_path"); + c.get("ItemList.208.Name", "Grass Path"); + c.get("ItemList.209.MCName", "end_gateway"); + c.get("ItemList.209.Name", "End Gateway Block"); + c.get("ItemList.212.MCName", "frosted_ice"); + c.get("ItemList.212.Name", "Frosted Ice"); + c.get("ItemList.256.MCName", "iron_shovel"); + c.get("ItemList.256.Name", "Iron Shovel"); + c.get("ItemList.257.MCName", "iron_pickaxe"); + c.get("ItemList.257.Name", "Iron Pickaxe"); + c.get("ItemList.258.MCName", "iron_axe"); + c.get("ItemList.258.Name", "Iron Axe"); + c.get("ItemList.259.MCName", "flint_and_steel"); + c.get("ItemList.259.Name", "Flint and Steel"); + c.get("ItemList.260.MCName", "apple"); + c.get("ItemList.260.Name", "Apple"); + c.get("ItemList.261.MCName", "bow"); + c.get("ItemList.261.Name", "Bow"); + c.get("ItemList.262.MCName", "arrow"); + c.get("ItemList.262.Name", "Arrow"); + c.get("ItemList.263.MCName", "coal"); + c.get("ItemList.263.Name", "Coal"); + c.get("ItemList.263:1.MCName", "coal"); + c.get("ItemList.263:1.Name", "Charcoal"); + c.get("ItemList.264.MCName", "diamond"); + c.get("ItemList.264.Name", "Diamond"); + c.get("ItemList.265.MCName", "iron_ingot"); + c.get("ItemList.265.Name", "Iron Ingot"); + c.get("ItemList.266.MCName", "gold_ingot"); + c.get("ItemList.266.Name", "Gold Ingot"); + c.get("ItemList.267.MCName", "iron_sword"); + c.get("ItemList.267.Name", "Iron Sword"); + c.get("ItemList.268.MCName", "wooden_sword"); + c.get("ItemList.268.Name", "Wooden Sword"); + c.get("ItemList.269.MCName", "wooden_shovel"); + c.get("ItemList.269.Name", "Wooden Shovel"); + c.get("ItemList.270.MCName", "wooden_pickaxe"); + c.get("ItemList.270.Name", "Wooden Pickaxe"); + c.get("ItemList.271.MCName", "wooden_axe"); + c.get("ItemList.271.Name", "Wooden Axe"); + c.get("ItemList.272.MCName", "stone_sword"); + c.get("ItemList.272.Name", "Stone Sword"); + c.get("ItemList.273.MCName", "stone_shovel"); + c.get("ItemList.273.Name", "Stone Shovel"); + c.get("ItemList.274.MCName", "stone_pickaxe"); + c.get("ItemList.274.Name", "Stone Pickaxe"); + c.get("ItemList.275.MCName", "stone_axe"); + c.get("ItemList.275.Name", "Stone Axe"); + c.get("ItemList.276.MCName", "diamond_sword"); + c.get("ItemList.276.Name", "Diamond Sword"); + c.get("ItemList.277.MCName", "diamond_shovel"); + c.get("ItemList.277.Name", "Diamond Shovel"); + c.get("ItemList.278.MCName", "diamond_pickaxe"); + c.get("ItemList.278.Name", "Diamond Pickaxe"); + c.get("ItemList.279.MCName", "diamond_axe"); + c.get("ItemList.279.Name", "Diamond Axe"); + c.get("ItemList.280.MCName", "stick"); + c.get("ItemList.280.Name", "Stick"); + c.get("ItemList.281.MCName", "bowl"); + c.get("ItemList.281.Name", "Bowl"); + c.get("ItemList.282.MCName", "mushroom_stew"); + c.get("ItemList.282.Name", "Mushroom Stew"); + c.get("ItemList.283.MCName", "golden_sword"); + c.get("ItemList.283.Name", "Golden Sword"); + c.get("ItemList.284.MCName", "golden_shovel"); + c.get("ItemList.284.Name", "Golden Shovel"); + c.get("ItemList.285.MCName", "golden_pickaxe"); + c.get("ItemList.285.Name", "Golden Pickaxe"); + c.get("ItemList.286.MCName", "golden_axe"); + c.get("ItemList.286.Name", "Golden Axe"); + c.get("ItemList.287.MCName", "string"); + c.get("ItemList.287.Name", "String"); + c.get("ItemList.288.MCName", "feather"); + c.get("ItemList.288.Name", "Feather"); + c.get("ItemList.289.MCName", "gunpowder"); + c.get("ItemList.289.Name", "Gunpowder"); + c.get("ItemList.290.MCName", "wooden_hoe"); + c.get("ItemList.290.Name", "Wooden Hoe"); + c.get("ItemList.291.MCName", "stone_hoe"); + c.get("ItemList.291.Name", "Stone Hoe"); + c.get("ItemList.292.MCName", "iron_hoe"); + c.get("ItemList.292.Name", "Iron Hoe"); + c.get("ItemList.293.MCName", "diamond_hoe"); + c.get("ItemList.293.Name", "Diamond Hoe"); + c.get("ItemList.294.MCName", "golden_hoe"); + c.get("ItemList.294.Name", "Golden Hoe"); + c.get("ItemList.295.MCName", "wheat_seeds"); + c.get("ItemList.295.Name", "Wheat Seeds"); + c.get("ItemList.296.MCName", "wheat"); + c.get("ItemList.296.Name", "Wheat"); + c.get("ItemList.297.MCName", "bread"); + c.get("ItemList.297.Name", "Bread"); + c.get("ItemList.298.MCName", "leather_helmet"); + c.get("ItemList.298.Name", "Leather Helmet"); + c.get("ItemList.299.MCName", "leather_chestplate"); + c.get("ItemList.299.Name", "Leather Tunic"); + c.get("ItemList.300.MCName", "leather_leggings"); + c.get("ItemList.300.Name", "Leather Pants"); + c.get("ItemList.301.MCName", "leather_boots"); + c.get("ItemList.301.Name", "Leather Boots"); + c.get("ItemList.302.MCName", "chainmail_helmet"); + c.get("ItemList.302.Name", "Chainmail Helmet"); + c.get("ItemList.303.MCName", "chainmail_chestplate"); + c.get("ItemList.303.Name", "Chainmail Chestplate"); + c.get("ItemList.304.MCName", "chainmail_leggings"); + c.get("ItemList.304.Name", "Chainmail Leggings"); + c.get("ItemList.305.MCName", "chainmail_boots"); + c.get("ItemList.305.Name", "Chainmail Boots"); + c.get("ItemList.306.MCName", "iron_helmet"); + c.get("ItemList.306.Name", "Iron Helmet"); + c.get("ItemList.307.MCName", "iron_chestplate"); + c.get("ItemList.307.Name", "Iron Chestplate"); + c.get("ItemList.308.MCName", "iron_leggings"); + c.get("ItemList.308.Name", "Iron Leggings"); + c.get("ItemList.309.MCName", "iron_boots"); + c.get("ItemList.309.Name", "Iron Boots"); + c.get("ItemList.310.MCName", "diamond_helmet"); + c.get("ItemList.310.Name", "Diamond Helmet"); + c.get("ItemList.311.MCName", "diamond_chestplate"); + c.get("ItemList.311.Name", "Diamond Chestplate"); + c.get("ItemList.312.MCName", "diamond_leggings"); + c.get("ItemList.312.Name", "Diamond Leggings"); + c.get("ItemList.313.MCName", "diamond_boots"); + c.get("ItemList.313.Name", "Diamond Boots"); + c.get("ItemList.314.MCName", "golden_helmet"); + c.get("ItemList.314.Name", "Golden Helmet"); + c.get("ItemList.315.MCName", "golden_chestplate"); + c.get("ItemList.315.Name", "Golden Chestplate"); + c.get("ItemList.316.MCName", "golden_leggings"); + c.get("ItemList.316.Name", "Golden Leggings"); + c.get("ItemList.317.MCName", "golden_boots"); + c.get("ItemList.317.Name", "Golden Boots"); + c.get("ItemList.318.MCName", "flint_and_steel"); + c.get("ItemList.318.Name", "Flint"); + c.get("ItemList.319.MCName", "porkchop"); + c.get("ItemList.319.Name", "Raw Porkchop"); + c.get("ItemList.320.MCName", "cooked_porkchop"); + c.get("ItemList.320.Name", "Cooked Porkchop"); + c.get("ItemList.321.MCName", "painting"); + c.get("ItemList.321.Name", "Painting"); + c.get("ItemList.322.MCName", "golden_apple"); + c.get("ItemList.322.Name", "Golden Apple"); + c.get("ItemList.322:1.MCName", "golden_apple"); + c.get("ItemList.322:1.Name", "Enchanted Golden Apple"); + c.get("ItemList.323.MCName", "sign"); + c.get("ItemList.323.Name", "Sign"); + c.get("ItemList.324.MCName", "wooden_door"); + c.get("ItemList.324.Name", "Wooden Door"); + c.get("ItemList.325.MCName", "bucket"); + c.get("ItemList.325.Name", "Bucket"); + c.get("ItemList.326.MCName", "water_bucket"); + c.get("ItemList.326.Name", "Water Bucket"); + c.get("ItemList.327.MCName", "lava_bucket"); + c.get("ItemList.327.Name", "Lava Bucket"); + c.get("ItemList.328.MCName", "minecart"); + c.get("ItemList.328.Name", "Minecart"); + c.get("ItemList.329.MCName", "saddle"); + c.get("ItemList.329.Name", "Saddle"); + c.get("ItemList.330.MCName", "iron_door"); + c.get("ItemList.330.Name", "Iron Door"); + c.get("ItemList.331.MCName", "redstone"); + c.get("ItemList.331.Name", "Redstone"); + c.get("ItemList.332.MCName", "snowball"); + c.get("ItemList.332.Name", "Snowball"); + c.get("ItemList.333.MCName", "boat"); + c.get("ItemList.333.Name", "Boat"); + c.get("ItemList.334.MCName", "leather"); + c.get("ItemList.334.Name", "Leather"); + c.get("ItemList.335.MCName", "milk_bucket"); + c.get("ItemList.335.Name", "Milk Bucket"); + c.get("ItemList.336.MCName", "brick"); + c.get("ItemList.336.Name", "Brick"); + c.get("ItemList.337.MCName", "clay_ball"); + c.get("ItemList.337.Name", "Clay Ball"); + c.get("ItemList.338.MCName", "reeds"); + c.get("ItemList.338.Name", "Sugar Canes"); + c.get("ItemList.339.MCName", "paper"); + c.get("ItemList.339.Name", "Paper"); + c.get("ItemList.340.MCName", "book"); + c.get("ItemList.340.Name", "Book"); + c.get("ItemList.341.MCName", "slime_ball"); + c.get("ItemList.341.Name", "Slimeball"); + c.get("ItemList.342.MCName", "chest_minecart"); + c.get("ItemList.342.Name", "Minecart with Chest"); + c.get("ItemList.343.MCName", "furnace_minecart"); + c.get("ItemList.343.Name", "Minecart with Furnace"); + c.get("ItemList.344.MCName", "egg"); + c.get("ItemList.344.Name", "Egg"); + c.get("ItemList.345.MCName", "compass"); + c.get("ItemList.345.Name", "Compass"); + c.get("ItemList.346.MCName", "fishing_rod"); + c.get("ItemList.346.Name", "Fishing Rod"); + c.get("ItemList.347.MCName", "clock"); + c.get("ItemList.347.Name", "Clock"); + c.get("ItemList.348.MCName", "glowstone_dust"); + c.get("ItemList.348.Name", "Glowstone Dust"); + c.get("ItemList.349.MCName", "fish"); + c.get("ItemList.349.Name", "Raw Fish"); + c.get("ItemList.349:1.MCName", "fish"); + c.get("ItemList.349:1.Name", "Raw Salmon"); + c.get("ItemList.349:2.MCName", "fish"); + c.get("ItemList.349:2.Name", "Clownfish"); + c.get("ItemList.349:3.MCName", "fish"); + c.get("ItemList.349:3.Name", "Pufferfish"); + c.get("ItemList.350.MCName", "cooked_fish"); + c.get("ItemList.350.Name", "Cooked Fish"); + c.get("ItemList.350:1.MCName", "cooked_fish"); + c.get("ItemList.350:1.Name", "Cooked Salmon"); + c.get("ItemList.351.MCName", "dye"); + c.get("ItemList.351.Name", "All Dyes"); + c.get("ItemList.351:0.MCName", "dye"); + c.get("ItemList.351:0.Name", "Ink Sack"); + c.get("ItemList.351:1.MCName", "dye"); + c.get("ItemList.351:1.Name", "Rose Red"); + c.get("ItemList.351:2.MCName", "dye"); + c.get("ItemList.351:2.Name", "Cactus Green"); + c.get("ItemList.351:3.MCName", "dye"); + c.get("ItemList.351:3.Name", "Coco Beans"); + c.get("ItemList.351:4.MCName", "dye"); + c.get("ItemList.351:4.Name", "Lapis Lazuli"); + c.get("ItemList.351:5.MCName", "dye"); + c.get("ItemList.351:5.Name", "Purple Dye"); + c.get("ItemList.351:6.MCName", "dye"); + c.get("ItemList.351:6.Name", "Cyan Dye"); + c.get("ItemList.351:7.MCName", "dye"); + c.get("ItemList.351:7.Name", "Light Gray Dye"); + c.get("ItemList.351:8.MCName", "dye"); + c.get("ItemList.351:8.Name", "Gray Dye"); + c.get("ItemList.351:9.MCName", "dye"); + c.get("ItemList.351:9.Name", "Pink Dye"); + c.get("ItemList.351:10.MCName", "dye"); + c.get("ItemList.351:10.Name", "Lime Dye"); + c.get("ItemList.351:11.MCName", "dye"); + c.get("ItemList.351:11.Name", "Dandelion Yellow"); + c.get("ItemList.351:12.MCName", "dye"); + c.get("ItemList.351:12.Name", "Light Blue Dye"); + c.get("ItemList.351:13.MCName", "dye"); + c.get("ItemList.351:13.Name", "Magenta Dye"); + c.get("ItemList.351:14.MCName", "dye"); + c.get("ItemList.351:14.Name", "Orange Dye"); + c.get("ItemList.351:15.MCName", "dye"); + c.get("ItemList.351:15.Name", "Bone Meal"); + c.get("ItemList.352.MCName", "bone"); + c.get("ItemList.352.Name", "Bone"); + c.get("ItemList.353.MCName", "sugar"); + c.get("ItemList.353.Name", "Sugar"); + c.get("ItemList.354.MCName", "cake"); + c.get("ItemList.354.Name", "Cake"); + c.get("ItemList.355.MCName", "bed"); + c.get("ItemList.355.Name", "Bed"); + c.get("ItemList.356.MCName", "repeater"); + c.get("ItemList.356.Name", "Redstone Repeater"); + c.get("ItemList.357.MCName", "cookie"); + c.get("ItemList.357.Name", "Cookie"); + c.get("ItemList.358.MCName", "filled_map"); + c.get("ItemList.358.Name", "Map"); + c.get("ItemList.359.MCName", "shears"); + c.get("ItemList.359.Name", "Shears"); + c.get("ItemList.360.MCName", "melon"); + c.get("ItemList.360.Name", "Melon"); + c.get("ItemList.361.MCName", "pumpkin_seeds"); + c.get("ItemList.361.Name", "Pumpkin Seeds"); + c.get("ItemList.362.MCName", "melon_seeds"); + c.get("ItemList.362.Name", "Melon Seeds"); + c.get("ItemList.363.MCName", "beef"); + c.get("ItemList.363.Name", "Raw Beef"); + c.get("ItemList.364.MCName", "cooked_beef"); + c.get("ItemList.364.Name", "Steak"); + c.get("ItemList.365.MCName", "chicken"); + c.get("ItemList.365.Name", "Raw Chicken"); + c.get("ItemList.366.MCName", "cooked_chicken"); + c.get("ItemList.366.Name", "Cooked Chicken"); + c.get("ItemList.367.MCName", "rotten_flesh"); + c.get("ItemList.367.Name", "Rotten Flesh"); + c.get("ItemList.368.MCName", "ender_pearl"); + c.get("ItemList.368.Name", "Ender Pearl"); + c.get("ItemList.369.MCName", "blaze_rod"); + c.get("ItemList.369.Name", "Blaze Rod"); + c.get("ItemList.370.MCName", "ghast_tear"); + c.get("ItemList.370.Name", "Ghast Tear"); + c.get("ItemList.371.MCName", "gold_nugget"); + c.get("ItemList.371.Name", "Gold Nugget"); + c.get("ItemList.372.MCName", "nether_wart"); + c.get("ItemList.372.Name", "Nether Wart"); + c.get("ItemList.373.MCName", "potion"); + c.get("ItemList.373.Name", "Potion"); + c.get("ItemList.374.MCName", "glass_bottle"); + c.get("ItemList.374.Name", "Glass Bottle"); + c.get("ItemList.375.MCName", "spider_eye"); + c.get("ItemList.375.Name", "Spider Eye"); + c.get("ItemList.376.MCName", "fermented_spider_eye"); + c.get("ItemList.376.Name", "Fermented Spider Eye"); + c.get("ItemList.377.MCName", "blaze_powder"); + c.get("ItemList.377.Name", "Blaze Powder"); + c.get("ItemList.378.MCName", "magma_cream"); + c.get("ItemList.378.Name", "Magma Cream"); + c.get("ItemList.379.MCName", "brewing_stand"); + c.get("ItemList.379.Name", "Brewing Stand"); + c.get("ItemList.380.MCName", "cauldron"); + c.get("ItemList.380.Name", "Cauldron"); + c.get("ItemList.381.MCName", "ender_eye"); + c.get("ItemList.381.Name", "Eye of Ender"); + c.get("ItemList.382.MCName", "speckled_melon"); + c.get("ItemList.382.Name", "Glistering Melon"); + c.get("ItemList.383:50.MCName", "spawn_egg"); + c.get("ItemList.383:50.Name", "Spawn Creeper"); + c.get("ItemList.383:51.MCName", "spawn_egg"); + c.get("ItemList.383:51.Name", "Spawn Skeleton"); + c.get("ItemList.383:52.MCName", "spawn_egg"); + c.get("ItemList.383:52.Name", "Spawn Spider"); + c.get("ItemList.383:54.MCName", "spawn_egg"); + c.get("ItemList.383:54.Name", "Spawn Zombie"); + c.get("ItemList.383:55.MCName", "spawn_egg"); + c.get("ItemList.383:55.Name", "Spawn Slime"); + c.get("ItemList.383:56.MCName", "spawn_egg"); + c.get("ItemList.383:56.Name", "Spawn Ghast"); + c.get("ItemList.383:57.MCName", "spawn_egg"); + c.get("ItemList.383:57.Name", "Spawn Pigman"); + c.get("ItemList.383:58.MCName", "spawn_egg"); + c.get("ItemList.383:58.Name", "Spawn Enderman"); + c.get("ItemList.383:59.MCName", "spawn_egg"); + c.get("ItemList.383:59.Name", "Spawn Cave Spider"); + c.get("ItemList.383:60.MCName", "spawn_egg"); + c.get("ItemList.383:60.Name", "Spawn Silverfish"); + c.get("ItemList.383:61.MCName", "spawn_egg"); + c.get("ItemList.383:61.Name", "Spawn Blaze"); + c.get("ItemList.383:62.MCName", "spawn_egg"); + c.get("ItemList.383:62.Name", "Spawn Magma Cube"); + c.get("ItemList.383:65.MCName", "spawn_egg"); + c.get("ItemList.383:65.Name", "Spawn Bat"); + c.get("ItemList.383:66.MCName", "spawn_egg"); + c.get("ItemList.383:66.Name", "Spawn Witch"); + c.get("ItemList.383:67.MCName", "spawn_egg"); + c.get("ItemList.383:67.Name", "Spawn Endermite"); + c.get("ItemList.383:68.MCName", "spawn_egg"); + c.get("ItemList.383:68.Name", "Spawn Guardian"); + c.get("ItemList.383:90.MCName", "spawn_egg"); + c.get("ItemList.383:90.Name", "Spawn Pig"); + c.get("ItemList.383:91.MCName", "spawn_egg"); + c.get("ItemList.383:91.Name", "Spawn Sheep"); + c.get("ItemList.383:92.MCName", "spawn_egg"); + c.get("ItemList.383:92.Name", "Spawn Cow"); + c.get("ItemList.383:93.MCName", "spawn_egg"); + c.get("ItemList.383:93.Name", "Spawn Chicken"); + c.get("ItemList.383:94.MCName", "spawn_egg"); + c.get("ItemList.383:94.Name", "Spawn Squid"); + c.get("ItemList.383:95.MCName", "spawn_egg"); + c.get("ItemList.383:95.Name", "Spawn Wolf"); + c.get("ItemList.383:96.MCName", "spawn_egg"); + c.get("ItemList.383:96.Name", "Spawn Mooshroom"); + c.get("ItemList.383:98.MCName", "spawn_egg"); + c.get("ItemList.383:98.Name", "Spawn Ocelot"); + c.get("ItemList.383:100.MCName", "spawn_egg"); + c.get("ItemList.383:100.Name", "Spawn Horse"); + c.get("ItemList.383:101.MCName", "spawn_egg"); + c.get("ItemList.383:101.Name", "Spawn Rabbit"); + c.get("ItemList.383:120.MCName", "spawn_egg"); + c.get("ItemList.383:120.Name", "Spawn Villager"); + c.get("ItemList.384.MCName", "experience_bottle"); + c.get("ItemList.384.Name", "Bottle o' Enchanting"); + c.get("ItemList.385.MCName", "fire_charge"); + c.get("ItemList.385.Name", "Fire Charge"); + c.get("ItemList.386.MCName", "writable_book"); + c.get("ItemList.386.Name", "Book and Quill"); + c.get("ItemList.387.MCName", "written_book"); + c.get("ItemList.387.Name", "Written Book"); + c.get("ItemList.388.MCName", "emerald"); + c.get("ItemList.388.Name", "Emerald"); + c.get("ItemList.389.MCName", "item_frame"); + c.get("ItemList.389.Name", "Item Frame"); + c.get("ItemList.390.MCName", "flower_pot"); + c.get("ItemList.390.Name", "Flower Pot"); + c.get("ItemList.391.MCName", "carrot"); + c.get("ItemList.391.Name", "Carrot"); + c.get("ItemList.392.MCName", "potato"); + c.get("ItemList.392.Name", "Potato"); + c.get("ItemList.393.MCName", "baked_potato"); + c.get("ItemList.393.Name", "Baked Potato"); + c.get("ItemList.394.MCName", "poisonous_potato"); + c.get("ItemList.394.Name", "Poisonous Potato"); + c.get("ItemList.395.MCName", "map"); + c.get("ItemList.395.Name", "Empty Map"); + c.get("ItemList.396.MCName", "golden_carrot"); + c.get("ItemList.396.Name", "Golden Carrot"); + c.get("ItemList.397.MCName", "skull"); + c.get("ItemList.397.Name", "Mob Head (Skeleton)"); + c.get("ItemList.397:1.MCName", "skull"); + c.get("ItemList.397:1.Name", "Mob Head (Wither Skeleton)"); + c.get("ItemList.397:2.MCName", "skull"); + c.get("ItemList.397:2.Name", "Mob Head (Zombie)"); + c.get("ItemList.397:3.MCName", "skull"); + c.get("ItemList.397:3.Name", "Mob Head (Human)"); + c.get("ItemList.397:4.MCName", "skull"); + c.get("ItemList.397:4.Name", "Mob Head (Creeper)"); + c.get("ItemList.398.MCName", "carrot_on_a_stick"); + c.get("ItemList.398.Name", "Carrot on a Stick"); + c.get("ItemList.399.MCName", "nether_star"); + c.get("ItemList.399.Name", "Nether Star"); + c.get("ItemList.400.MCName", "pumpkin_pie"); + c.get("ItemList.400.Name", "Pumpkin Pie"); + c.get("ItemList.401.MCName", "fireworks"); + c.get("ItemList.401.Name", "Firework Rocket"); + c.get("ItemList.402.MCName", "firework_charge"); + c.get("ItemList.402.Name", "Firework Star"); + c.get("ItemList.403.MCName", "enchanted_book"); + c.get("ItemList.403.Name", "Enchanted Book"); + c.get("ItemList.404.MCName", "comparator"); + c.get("ItemList.404.Name", "Redstone Comparator"); + c.get("ItemList.405.MCName", "netherbrick"); + c.get("ItemList.405.Name", "Nether Brick"); + c.get("ItemList.406.MCName", "quartz"); + c.get("ItemList.406.Name", "Nether Quartz"); + c.get("ItemList.407.MCName", "tnt_minecart"); + c.get("ItemList.407.Name", "Minecart with TNT"); + c.get("ItemList.408.MCName", "hopper_minecart"); + c.get("ItemList.408.Name", "Minecart with Hopper"); + c.get("ItemList.409.MCName", "prismarine_shard"); + c.get("ItemList.409.Name", "Prismarine Shard"); + c.get("ItemList.410.MCName", "prismarine_crystals"); + c.get("ItemList.410.Name", "Prismarine Crystals"); + c.get("ItemList.411.MCName", "rabbit"); + c.get("ItemList.411.Name", "Raw Rabbit"); + c.get("ItemList.412.MCName", "cooked_rabbit"); + c.get("ItemList.412.Name", "Cooked Rabbit"); + c.get("ItemList.413.MCName", "rabbit_stew"); + c.get("ItemList.413.Name", "Rabbit Stew"); + c.get("ItemList.414.MCName", "rabbit_foot"); + c.get("ItemList.414.Name", "Rabbit's Foot"); + c.get("ItemList.415.MCName", "rabbit_hide"); + c.get("ItemList.415.Name", "Rabbit Hide"); + c.get("ItemList.416.MCName", "armor_stand"); + c.get("ItemList.416.Name", "Armor Stand"); + c.get("ItemList.417.MCName", "iron_horse_armor"); + c.get("ItemList.417.Name", "Iron Horse Armor"); + c.get("ItemList.418.MCName", "golden_horse_armor"); + c.get("ItemList.418.Name", "Golden Horse Armor"); + c.get("ItemList.419.MCName", "diamond_horse_armor"); + c.get("ItemList.419.Name", "Diamond Horse Armor"); + c.get("ItemList.420.MCName", "lead"); + c.get("ItemList.420.Name", "Lead"); + c.get("ItemList.421.MCName", "name_tag"); + c.get("ItemList.421.Name", "Name Tag"); + c.get("ItemList.422.MCName", "command_block_minecart"); + c.get("ItemList.422.Name", "Minecart with Command Block"); + c.get("ItemList.423.MCName", "mutton"); + c.get("ItemList.423.Name", "Raw Mutton"); + c.get("ItemList.424.MCName", "cooked_mutton"); + c.get("ItemList.424.Name", "Cooked Mutton"); + c.get("ItemList.425.MCName", "banner"); + c.get("ItemList.425.Name", "Banner"); + c.get("ItemList.426.MCName", "end_crystal"); + c.get("ItemList.426.Name", "End Crystal"); + c.get("ItemList.427.MCName", "spruce_door"); + c.get("ItemList.427.Name", "Spruce Door"); + c.get("ItemList.428.MCName", "birch_door"); + c.get("ItemList.428.Name", "Birch Door"); + c.get("ItemList.429.MCName", "jungle_door"); + c.get("ItemList.429.Name", "Jungle Door"); + c.get("ItemList.430.MCName", "acacia_door"); + c.get("ItemList.430.Name", "Acacia Door"); + c.get("ItemList.431.MCName", "dark_oak_door"); + c.get("ItemList.431.Name", "Dark Oak Door"); + c.get("ItemList.432.MCName", "chorus_fruit"); + c.get("ItemList.432.Name", "Chorus Fruit"); + c.get("ItemList.433.MCName", "chorus_fruit_popped"); + c.get("ItemList.433.Name", "Popped Chorus Fruit"); + c.get("ItemList.434.MCName", "beetroot"); + c.get("ItemList.434.Name", "Beetroot"); + c.get("ItemList.435.MCName", "beetroot_seeds"); + c.get("ItemList.435.Name", "Beetroot Seeds"); + c.get("ItemList.436.MCName", "beetroot_soup"); + c.get("ItemList.436.Name", "Beetroot Soup"); + c.get("ItemList.437.MCName", "dragon_breath"); + c.get("ItemList.437.Name", "Dragon's Breath"); + c.get("ItemList.439.MCName", "spectral_arrow"); + c.get("ItemList.439.Name", "Spectral Arrow"); + c.get("ItemList.440.MCName", "tipped_arrow"); + c.get("ItemList.440.Name", "Tipped Arrow"); + c.get("ItemList.441.MCName", "lingering_potion"); + c.get("ItemList.441.Name", "Lingering Potion"); + c.get("ItemList.442.MCName", "shield"); + c.get("ItemList.442.Name", "Shield"); + c.get("ItemList.443.MCName", "elytra"); + c.get("ItemList.443.Name", "Elytra"); + c.get("ItemList.2256.MCName", "record_13"); + c.get("ItemList.2256.Name", "13 Disc"); + c.get("ItemList.2257.MCName", "record_cat"); + c.get("ItemList.2257.Name", "Cat Disc"); + c.get("ItemList.2258.MCName", "record_blocks"); + c.get("ItemList.2258.Name", "Blocks Disc"); + c.get("ItemList.2259.MCName", "record_chirp"); + c.get("ItemList.2259.Name", "Chirp Disc"); + c.get("ItemList.2260.MCName", "record_far"); + c.get("ItemList.2260.Name", "Far Disc"); + c.get("ItemList.2261.MCName", "record_mall"); + c.get("ItemList.2261.Name", "Mall Disc"); + c.get("ItemList.2262.MCName", "record_mellohi"); + c.get("ItemList.2262.Name", "Mellohi Disc"); + c.get("ItemList.2263.MCName", "record_stal"); + c.get("ItemList.2263.Name", "Stal Disc"); + c.get("ItemList.2264.MCName", "record_strad"); + c.get("ItemList.2264.Name", "Strad Disc"); + c.get("ItemList.2265.MCName", "record_ward"); + c.get("ItemList.2265.Name", "Ward Disc"); + c.get("ItemList.2266.MCName", "record_11"); + c.get("ItemList.2266.Name", "11 Disc"); + c.get("ItemList.2267.MCName", "record_wait"); + c.get("ItemList.2267.Name", "Wait Disc"); + + // Entity list + c.get("EntityList.50.MCName", "Creeper"); + c.get("EntityList.50.Name", "Creeper"); + c.get("EntityList.51.MCName", "Skeleton"); + c.get("EntityList.51.Name", "Skeleton"); + c.get("EntityList.51:1.MCName", "Skeleton"); + c.get("EntityList.51:1.Name", "WitherSkeleton"); + c.get("EntityList.52.MCName", "Spider"); + c.get("EntityList.52.Name", "Spider"); + c.get("EntityList.53.MCName", "Giant"); + c.get("EntityList.53.Name", "Giant"); + c.get("EntityList.54.MCName", "Zombie"); + c.get("EntityList.54.Name", "Zombie"); + c.get("EntityList.54:1.MCName", "Zombie"); + c.get("EntityList.54:1.Name", "Zombie Villager"); + c.get("EntityList.55.MCName", "Slime"); + c.get("EntityList.55.Name", "Slime"); + c.get("EntityList.56.MCName", "Ghast"); + c.get("EntityList.56.Name", "Ghast"); + c.get("EntityList.57.MCName", "PigZombie"); + c.get("EntityList.57.Name", "Zombie Pigman"); + c.get("EntityList.58.MCName", "Enderman"); + c.get("EntityList.58.Name", "Enderman"); + c.get("EntityList.59.MCName", "CaveSpider"); + c.get("EntityList.59.Name", "Cave Spider"); + c.get("EntityList.60.MCName", "Silverfish"); + c.get("EntityList.60.Name", "Silverfish"); + c.get("EntityList.61.MCName", "Blaze"); + c.get("EntityList.61.Name", "Blaze"); + c.get("EntityList.62.MCName", "LavaSlime"); + c.get("EntityList.62.Name", "LavaSlime"); + c.get("EntityList.63.MCName", "EnderDragon"); + c.get("EntityList.63.Name", "EnderDragon"); + c.get("EntityList.64.MCName", "WitherBoss"); + c.get("EntityList.64.Name", "Wither"); + c.get("EntityList.65.MCName", "Bat"); + c.get("EntityList.65.Name", "Bat"); + c.get("EntityList.66.MCName", "Witch"); + c.get("EntityList.66.Name", "Witch"); + c.get("EntityList.67.MCName", "Endermite"); + c.get("EntityList.67.Name", "Endermite"); + c.get("EntityList.68.MCName", "Guardian"); + c.get("EntityList.68.Name", "Guardian"); + c.get("EntityList.68:1.MCName", "Guardian"); + c.get("EntityList.68:1.Name", "Elder Guardian"); + c.get("EntityList.68.MCName", "Shulker"); + c.get("EntityList.68.Name", "Shulker"); + c.get("EntityList.90.MCName", "Pig"); + c.get("EntityList.90.Name", "Pig"); + c.get("EntityList.91.MCName", "Sheep"); + c.get("EntityList.91.Name", "Sheep"); + c.get("EntityList.92.MCName", "Cow"); + c.get("EntityList.92.Name", "Cow"); + c.get("EntityList.93.MCName", "Chicken"); + c.get("EntityList.93.Name", "Chicken"); + c.get("EntityList.94.MCName", "Squid"); + c.get("EntityList.94.Name", "Squid"); + c.get("EntityList.95.MCName", "Wolf"); + c.get("EntityList.95.Name", "Wolf"); + c.get("EntityList.96.MCName", "MushroomCow"); + c.get("EntityList.96.Name", "MushroomCow"); + c.get("EntityList.97.MCName", "SnowMan"); + c.get("EntityList.97.Name", "Snow Golem"); + c.get("EntityList.98.MCName", "Ozelot"); + c.get("EntityList.98.Name", "Ocelot"); + c.get("EntityList.99.MCName", "VillagerGolem"); + c.get("EntityList.99.Name", "Iron Golem"); + c.get("EntityList.100.MCName", "EntityHorse"); + c.get("EntityList.100.Name", "Horse"); + c.get("EntityList.101.MCName", "Rabbit"); + c.get("EntityList.101.Name", "Rabbit"); + c.get("EntityList.120.MCName", "Villager"); + c.get("EntityList.120.Name", "Villager"); + + // Enchant list + c.get("EnchantList.0.MCName", "PROTECTION_ENVIRONMENTAL"); + c.get("EnchantList.0.Name", "Protection"); + c.get("EnchantList.1.MCName", "PROTECTION_FIRE"); + c.get("EnchantList.1.Name", "Fire Protection"); + c.get("EnchantList.2.MCName", "PROTECTION_FALL"); + c.get("EnchantList.2.Name", "Feather Falling"); + c.get("EnchantList.3.MCName", "PROTECTION_EXPLOSIONS"); + c.get("EnchantList.3.Name", "Blast Protection"); + c.get("EnchantList.4.MCName", "ROTECTION_PROJECTILE"); + c.get("EnchantList.4.Name", "Projectile Protection"); + c.get("EnchantList.5.MCName", "OXYGEN"); + c.get("EnchantList.5.Name", "Respiration"); + c.get("EnchantList.6.MCName", "DIG_SPEED"); + c.get("EnchantList.6.Name", "Aqua Affinity"); + c.get("EnchantList.7.MCName", "THORNS"); + c.get("EnchantList.7.Name", "Thorns"); + c.get("EnchantList.8.MCName", "DEPTH_STRIDER"); + c.get("EnchantList.8.Name", "Depth Strider"); + c.get("EnchantList.9.MCName", "FROST_WALKER"); + c.get("EnchantList.9.Name", "Frost Walker"); + c.get("EnchantList.16.MCName", "DAMAGE_ALL"); + c.get("EnchantList.16.Name", "Sharpness"); + c.get("EnchantList.17.MCName", "DAMAGE_UNDEAD"); + c.get("EnchantList.17.Name", "Smite"); + c.get("EnchantList.18.MCName", "DAMAGE_ARTHROPODS"); + c.get("EnchantList.18.Name", "Bane of Arthropods"); + c.get("EnchantList.19.MCName", "KNOCKBACK"); + c.get("EnchantList.19.Name", "Knockback"); + c.get("EnchantList.20.MCName", "FIRE_ASPECT"); + c.get("EnchantList.20.Name", "Fire Aspect"); + c.get("EnchantList.21.MCName", "LOOT_BONUS_MOBS"); + c.get("EnchantList.21.Name", "Looting"); + c.get("EnchantList.32.MCName", "DIG_SPEED"); + c.get("EnchantList.32.Name", "Efficiency"); + c.get("EnchantList.33.MCName", "SILK_TOUCH"); + c.get("EnchantList.33.Name", "Silk Touch"); + c.get("EnchantList.34.MCName", "DURABILITY"); + c.get("EnchantList.34.Name", "Unbreaking"); + c.get("EnchantList.35.MCName", "LOOT_BONUS_BLOCKS"); + c.get("EnchantList.35.Name", "Fortune"); + c.get("EnchantList.48.MCName", "ARROW_DAMAGE"); + c.get("EnchantList.48.Name", "Power"); + c.get("EnchantList.49.MCName", "ARROW_KNOCKBACK"); + c.get("EnchantList.49.Name", "Punch"); + c.get("EnchantList.50.MCName", "ARROW_FIRE"); + c.get("EnchantList.50.Name", "Flame"); + c.get("EnchantList.51.MCName", "ARROW_INFINITE"); + c.get("EnchantList.51.Name", "Infinity"); + c.get("EnchantList.61.MCName", "LUCK"); + c.get("EnchantList.61.Name", "Luck of the Sea"); + c.get("EnchantList.62.MCName", "LURE"); + c.get("EnchantList.62.Name", "Lure"); + c.get("EnchantList.70.MCName", "MENDING"); + c.get("EnchantList.70.Name", "Mending"); + + // Color list + c.get("ColorList.0.MCName", "white"); + c.get("ColorList.0.Name", "&fWhite"); + c.get("ColorList.1.MCName", "orange"); + c.get("ColorList.1.Name", "&6Orange"); + c.get("ColorList.2.MCName", "magenta"); + c.get("ColorList.2.Name", "&dMagenta"); + c.get("ColorList.3.MCName", "lightBlue"); + c.get("ColorList.3.Name", "%9Light blue"); + c.get("ColorList.4.MCName", "yellow"); + c.get("ColorList.4.Name", "&eYellow"); + c.get("ColorList.5.MCName", "lime"); + c.get("ColorList.5.Name", "&aLime"); + c.get("ColorList.6.MCName", "pink"); + c.get("ColorList.6.Name", "&dPink"); + c.get("ColorList.7.MCName", "gray"); + c.get("ColorList.7.Name", "&8Gray"); + c.get("ColorList.8.MCName", "silver"); + c.get("ColorList.8.Name", "&7Light gray"); + c.get("ColorList.9.MCName", "cyan"); + c.get("ColorList.9.Name", "&3Cyan"); + c.get("ColorList.10.MCName", "purple"); + c.get("ColorList.10.Name", "&5Purple"); + c.get("ColorList.11.MCName", "blue"); + c.get("ColorList.11.Name", "&1Blue"); + c.get("ColorList.12.MCName", "brown"); + c.get("ColorList.12.Name", "&4Brown"); + c.get("ColorList.13.MCName", "green"); + c.get("ColorList.13.Name", "&2Green"); + c.get("ColorList.14.MCName", "red"); + c.get("ColorList.14.Name", "&cRed"); + c.get("ColorList.15.MCName", "black"); + c.get("ColorList.15.Name", "&0Black"); + + try { + c.getW().save(f); + } catch (IOException e) { + e.printStackTrace(); + } + readFile(); + } + +} diff --git a/com/gamingmesh/jobs/config/RestrictedAreaManager.java b/com/gamingmesh/jobs/config/RestrictedAreaManager.java new file mode 100644 index 00000000..37cb555a --- /dev/null +++ b/com/gamingmesh/jobs/config/RestrictedAreaManager.java @@ -0,0 +1,112 @@ +package com.gamingmesh.jobs.config; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.container.RestrictedArea; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class RestrictedAreaManager { + + protected ArrayList<RestrictedArea> restrictedAreas = new ArrayList<RestrictedArea>(); + + private JobsPlugin plugin; + + public RestrictedAreaManager(JobsPlugin plugin) { + this.plugin = plugin; + } + + /** + * Gets the area multiplier for the player + * @param player + * @return - the multiplier + */ + public synchronized double getRestrictedMultiplier(Player player) { + for (RestrictedArea area : restrictedAreas) { + if (area.inRestrictedArea(player)) + return area.getMultiplier(); + } + return 1.0; + } + + /** + * Method to load the restricted areas configuration + * + * loads from Jobs/restrictedAreas.yml + */ + public synchronized void load() { + this.restrictedAreas.clear(); + File f = new File(plugin.getDataFolder(), "restrictedAreas.yml"); + YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); + conf.options().indent(2); + conf.options().copyDefaults(true); + StringBuilder header = new StringBuilder(); + + header.append("Restricted area configuration"); + header.append(System.getProperty("line.separator")) + .append(System.getProperty("line.separator")) + .append("Configures restricted areas where you cannot get experience or money").append(System.getProperty("line.separator")) + .append("when performing a job.").append(System.getProperty("line.separator")).append(System.getProperty("line.separator")) + .append("The multiplier changes the experience/money gains in an area.").append(System.getProperty("line.separator")) + .append("A multiplier of 0.0 means no money or xp, while 0.5 means you will get half the normal money/exp").append(System.getProperty("line.separator")) + .append(System.getProperty("line.separator")) + .append("restrictedareas:").append(System.getProperty("line.separator")) + .append(" area1:").append(System.getProperty("line.separator")) + .append(" world: 'world'").append(System.getProperty("line.separator")) + .append(" multiplier: 0.0").append(System.getProperty("line.separator")) + .append(" point1:").append(System.getProperty("line.separator")) + .append(" x: 125").append(System.getProperty("line.separator")) + .append(" y: 0").append(System.getProperty("line.separator")) + .append(" z: 125").append(System.getProperty("line.separator")) + .append(" point2:").append(System.getProperty("line.separator")) + .append(" x: 150").append(System.getProperty("line.separator")) + .append(" y: 100").append(System.getProperty("line.separator")) + .append(" z: 150").append(System.getProperty("line.separator")) + .append(" area2:").append(System.getProperty("line.separator")) + .append(" world: 'world_nether'").append(System.getProperty("line.separator")) + .append(" multiplier: 0.0").append(System.getProperty("line.separator")) + .append(" point1:").append(System.getProperty("line.separator")) + .append(" x: -100").append(System.getProperty("line.separator")) + .append(" y: 0").append(System.getProperty("line.separator")) + .append(" z: -100").append(System.getProperty("line.separator")) + .append(" point2:").append(System.getProperty("line.separator")) + .append(" x: -150").append(System.getProperty("line.separator")) + .append(" y: 100").append(System.getProperty("line.separator")) + .append(" z: -150"); + conf.options().header(header.toString()); + ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas"); + if (areaSection != null) { + for (String areaKey : areaSection.getKeys(false)) { + String worldName = conf.getString("restrictedareas." + areaKey + ".world"); + double multiplier = conf.getDouble("restrictedareas." + areaKey + ".multiplier", 0.0); + World world = Bukkit.getServer().getWorld(worldName); + if (world == null) + continue; + Location point1 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point1.x", 0.0), conf.getDouble("restrictedareas." + areaKey + + ".point1.y", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point1.z", 0.0)); + + Location point2 = new Location(world, conf.getDouble("restrictedareas." + areaKey + ".point2.x", 0.0), conf.getDouble("restrictedareas." + areaKey + + ".point2.y", 0.0), conf.getDouble("restrictedareas." + areaKey + ".point2.z", 0.0)); + this.restrictedAreas.add(new RestrictedArea(point1, point2, multiplier)); + } + } + + + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + restrictedAreas.size() + " restricted areas!"); + + try { + conf.save(f); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/com/gamingmesh/jobs/config/RestrictedBlockManager.java b/com/gamingmesh/jobs/config/RestrictedBlockManager.java new file mode 100644 index 00000000..120ff796 --- /dev/null +++ b/com/gamingmesh/jobs/config/RestrictedBlockManager.java @@ -0,0 +1,126 @@ +package com.gamingmesh.jobs.config; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; + +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.YamlConfiguration; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.container.LocaleReader; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class RestrictedBlockManager { + + public ArrayList<String> restrictedBlocks = new ArrayList<String>(); + public ArrayList<String> restrictedBlocksTimer = new ArrayList<String>(); + public ArrayList<Integer> restrictedPlaceBlocksTimer = new ArrayList<Integer>(); + + private JobsPlugin plugin; + + public RestrictedBlockManager(JobsPlugin plugin) { + this.plugin = plugin; + } + + /** + * Method to load the restricted areas configuration + * + * loads from Jobs/restrictedAreas.yml + */ + public synchronized void load() { + File f = new File(plugin.getDataFolder(), "restrictedBlocks.yml"); + YamlConfiguration config = YamlConfiguration.loadConfiguration(f); + CommentedYamlConfiguration writer = new CommentedYamlConfiguration(); + + LocaleReader c = new LocaleReader(config, writer); + + config.options().copyDefaults(true); + + c.getW().addComment("restrictedblocks", "All block to be protected from place/break exploit.", "This will prevent piston moving all blocks in list", + "Dont count in vegetables or any single click break blocks"); + restrictedBlocks.add("14"); + restrictedBlocks.add("15"); + restrictedBlocks.add("16"); + restrictedBlocks.add("21"); + restrictedBlocks.add("48"); + restrictedBlocks.add("56"); + restrictedBlocks.add("73"); + restrictedBlocks.add("74"); + restrictedBlocks.add("129"); + restrictedBlocks.add("153"); + c.getC().addDefault("restrictedblocks", restrictedBlocks); + restrictedBlocks = (ArrayList<String>) c.getC().getStringList("restrictedblocks"); + c.copySetting("restrictedblocks"); + + + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + restrictedBlocks.size() + " restricted blocks!"); + + c.getW().addComment("blockstimer", "Block protected by timer in sec", + "141-60 means that carrot can be harvested after 60 sec (remember to use id's from placed objects, not from your inventory)"); + restrictedBlocksTimer.add("2-60"); + restrictedBlocksTimer.add("3-60"); + restrictedBlocksTimer.add("6-60"); + restrictedBlocksTimer.add("12-60"); + restrictedBlocksTimer.add("18-60"); + restrictedBlocksTimer.add("31-60"); + restrictedBlocksTimer.add("32-60"); + restrictedBlocksTimer.add("37-60"); + restrictedBlocksTimer.add("38-60"); + restrictedBlocksTimer.add("39-60"); + restrictedBlocksTimer.add("40-60"); + restrictedBlocksTimer.add("55-60"); + restrictedBlocksTimer.add("59-60"); + restrictedBlocksTimer.add("80-60"); + restrictedBlocksTimer.add("81-60"); + restrictedBlocksTimer.add("83-60"); + restrictedBlocksTimer.add("103-60"); + restrictedBlocksTimer.add("106-60"); + restrictedBlocksTimer.add("111-60"); + restrictedBlocksTimer.add("141-60"); + restrictedBlocksTimer.add("142-60"); + restrictedBlocksTimer.add("161-60"); + restrictedBlocksTimer.add("171-60"); + restrictedBlocksTimer.add("175-60"); + c.getC().addDefault("blockstimer", restrictedBlocksTimer); + restrictedBlocksTimer = (ArrayList<String>) c.getC().getStringList("blockstimer"); + c.copySetting("blockstimer"); + + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + restrictedBlocksTimer.size() + " restricted blocks timers!"); + + c.getW().addComment("PlacedBlockTimer", "Block place protected by timer in sec", "For this to work CoreProtect plugin should be installed"); + restrictedPlaceBlocksTimer.add(2); + restrictedPlaceBlocksTimer.add(3); + restrictedPlaceBlocksTimer.add(6); + restrictedPlaceBlocksTimer.add(12); + restrictedPlaceBlocksTimer.add(18); + restrictedPlaceBlocksTimer.add(31); + restrictedPlaceBlocksTimer.add(32); + restrictedPlaceBlocksTimer.add(37); + restrictedPlaceBlocksTimer.add(38); + restrictedPlaceBlocksTimer.add(39); + restrictedPlaceBlocksTimer.add(40); + restrictedPlaceBlocksTimer.add(55); + restrictedPlaceBlocksTimer.add(59); + restrictedPlaceBlocksTimer.add(80); + restrictedPlaceBlocksTimer.add(81); + restrictedPlaceBlocksTimer.add(83); + restrictedPlaceBlocksTimer.add(103); + restrictedPlaceBlocksTimer.add(106); + restrictedPlaceBlocksTimer.add(111); + restrictedPlaceBlocksTimer.add(141); + restrictedPlaceBlocksTimer.add(142); + restrictedPlaceBlocksTimer.add(161); + restrictedPlaceBlocksTimer.add(171); + restrictedPlaceBlocksTimer.add(175); + c.getC().addDefault("PlacedBlockTimer", restrictedPlaceBlocksTimer); + restrictedPlaceBlocksTimer = (ArrayList<Integer>) c.getC().getIntegerList("PlacedBlockTimer"); + c.copySetting("PlacedBlockTimer"); + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + restrictedPlaceBlocksTimer.size() + " restricted place blocks timers!"); + + try { + writer.save(f); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/com/gamingmesh/jobs/stuff/Scboard.java b/com/gamingmesh/jobs/config/ScboardManager.java similarity index 78% rename from com/gamingmesh/jobs/stuff/Scboard.java rename to com/gamingmesh/jobs/config/ScboardManager.java index 4d62738b..e450a845 100644 --- a/com/gamingmesh/jobs/stuff/Scboard.java +++ b/com/gamingmesh/jobs/config/ScboardManager.java @@ -1,4 +1,4 @@ -package com.gamingmesh.jobs.stuff; +package com.gamingmesh.jobs.config; import java.util.Iterator; import java.util.Map.Entry; @@ -8,18 +8,15 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.scoreboard.DisplaySlot; +import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.JobsPlugin; -import com.gamingmesh.jobs.config.ConfigManager; -public class Scboard { +public class ScboardManager { private ConcurrentHashMap<String, Long> timerMap = new ConcurrentHashMap<String, Long>(); private JobsPlugin plugin; - public Scboard() { - } - - public Scboard(JobsPlugin plugin) { + public ScboardManager(JobsPlugin plugin) { this.plugin = plugin; } @@ -28,7 +25,7 @@ public class Scboard { while (MeinMapIter.hasNext()) { Entry<String, Long> Map = MeinMapIter.next(); - if (System.currentTimeMillis() > Map.getValue() + (ConfigManager.getJobsConfiguration().ToplistInScoreboardInterval * 1000)) { + if (System.currentTimeMillis() > Map.getValue() + (Jobs.getGCManager().ToplistInScoreboardInterval * 1000)) { Player player = Bukkit.getPlayer(Map.getKey()); if (player != null) { player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); diff --git a/com/gamingmesh/jobs/config/ScheduleManager.java b/com/gamingmesh/jobs/config/ScheduleManager.java new file mode 100644 index 00000000..8ed74f46 --- /dev/null +++ b/com/gamingmesh/jobs/config/ScheduleManager.java @@ -0,0 +1,230 @@ +package com.gamingmesh.jobs.config; + +import java.io.File; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.YamlConfiguration; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.Schedule; +import com.gamingmesh.jobs.stuff.ChatColor; +import com.gamingmesh.jobs.stuff.TimeManage; + +public class ScheduleManager { + + public int dateByInt = 0; + + private JobsPlugin plugin; + + public ScheduleManager(JobsPlugin plugin) { + this.plugin = plugin; + } + + public int getDateByInt() { + return dateByInt; + } + + public void setDateByInt(int time) { + dateByInt = time; + } + + public void DateUpdater() { + if (dateByInt == 0) + dateByInt = TimeManage.timeInInt(); + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + public void run() { + + dateByInt = TimeManage.timeInInt(); + + DateUpdater(); + return; + } + }, 60 * 20L); + } + + public boolean scheduler() { + if (Jobs.getGCManager().BoostSchedule.size() > 0 && Jobs.getGCManager().useGlobalBoostScheduler) { + + DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); + Date date = new Date(); + + String currenttime = dateFormat.format(date); + + int Current = Integer.valueOf(currenttime.replace(":", "")).intValue(); + + String CurrentDayName = GetWeekDay(); + + for (Schedule one : Jobs.getGCManager().BoostSchedule) { + + int From = one.GetFrom(); + int Until = one.GetUntil(); + + List<String> days = one.GetDays(); + + if (one.isStarted() && one.getBroadcastInfoOn() < System.currentTimeMillis() && one.GetBroadcastInterval() > 0) { + one.setBroadcastInfoOn(System.currentTimeMillis() + one.GetBroadcastInterval() * 60 * 1000); + for (String oneMsg : one.GetMessageToBroadcast()) { + Bukkit.broadcastMessage(oneMsg); + } + } + + if (((one.isNextDay() && (Current >= From && Current < one.GetUntil() || Current >= one.GetNextFrom() && Current < one.GetNextUntil()) && !one + .isStarted()) || !one.isNextDay() && (Current >= From && Current < Until)) && (days.contains(CurrentDayName) || days.contains("all")) && !one + .isStarted()) { + + if (one.isBroadcastOnStart()) + if (one.GetMessageOnStart().size() == 0) + Bukkit.broadcastMessage(Jobs.getLanguage().getMessage("message.boostStarted")); + else + for (String oneMsg : one.GetMessageOnStart()) { + Bukkit.broadcastMessage(oneMsg); + } + + for (Job onejob : one.GetJobs()) { + onejob.setExpBoost(one.GetExpBoost()); + onejob.setMoneyBoost(one.GetMoneyBoost()); + } + + one.setBroadcastInfoOn(System.currentTimeMillis() + one.GetBroadcastInterval() * 60 * 1000); + + one.setStarted(true); + one.setStoped(false); + break; + } else if (((one.isNextDay() && Current > one.GetNextUntil() && Current < one.GetFrom() && !one.isStoped()) || !one.isNextDay() && Current > Until + && ((days.contains(CurrentDayName)) || days.contains("all"))) && !one.isStoped()) { + if (one.isBroadcastOnStop()) + if (one.GetMessageOnStop().size() == 0) + Bukkit.broadcastMessage(Jobs.getLanguage().getMessage("message.boostStoped")); + else + for (String oneMsg : one.GetMessageOnStop()) { + Bukkit.broadcastMessage(oneMsg); + } + for (Job onejob : one.GetJobs()) { + onejob.setExpBoost(1.0); + onejob.setMoneyBoost(1.0); + } + one.setStoped(true); + one.setStarted(false); + } + + } + + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + public void run() { + scheduler(); + return; + } + }, 30 * 20L); + } + return true; + } + + public static String GetWeekDay() { + Calendar c = Calendar.getInstance(); + int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); + switch (dayOfWeek) { + case 2: + return "monday"; + case 3: + return "tuesday"; + case 4: + return "wednesday"; + case 5: + return "thursday"; + case 6: + return "friday"; + case 7: + return "saturday"; + case 1: + return "sunday"; + } + return "all"; + } + + /** + * Method to load the scheduler configuration + * + * loads from Jobs/schedule.yml + */ + public void load() { + File f = new File(plugin.getDataFolder(), "schedule.yml"); + YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); + + conf.options().copyDefaults(true); + + if (!conf.contains("Boost")) + return; + + ArrayList<String> sections = new ArrayList<String>(conf.getConfigurationSection("Boost").getKeys(false)); + + for (String OneSection : sections) { + ConfigurationSection path = conf.getConfigurationSection("Boost." + OneSection); + + if (!path.contains("Enabled")) + continue; + + if (!conf.getConfigurationSection("Boost." + OneSection).getBoolean("Enabled")) + continue; + + Schedule sched = new Schedule(); + sched.setName(OneSection); + + if (!path.contains("From") || !path.getString("From").contains(":")) + continue; + + if (!path.contains("Until") || !path.getString("Until").contains(":")) + continue; + + if (!path.contains("Days") || !path.isList("Days")) + continue; + + if (!path.contains("Jobs") || !path.isList("Jobs")) + continue; + + if (!path.contains("Exp") || !path.isDouble("Exp")) + continue; + + if (!path.contains("Money") || !path.isDouble("Money")) + continue; + + sched.setDays(path.getStringList("Days")); + sched.setJobs(path.getStringList("Jobs")); + sched.setFrom(Integer.valueOf(path.getString("From").replace(":", ""))); + sched.setUntil(Integer.valueOf(path.getString("Until").replace(":", ""))); + + if (path.contains("MessageOnStart") && path.isList("MessageOnStart")) + sched.setMessageOnStart(path.getStringList("MessageOnStart"), path.getString("From"), path.getString("Until")); + + if (path.contains("BroadcastOnStart")) + sched.setBroadcastOnStart(path.getBoolean("BroadcastOnStart")); + + if (path.contains("MessageOnStop") && path.isList("MessageOnStop")) + sched.setMessageOnStop(path.getStringList("MessageOnStop"), path.getString("From"), path.getString("Until")); + + if (path.contains("BroadcastOnStop")) + sched.setBroadcastOnStop(path.getBoolean("BroadcastOnStop")); + + if (path.contains("BroadcastInterval")) + sched.setBroadcastInterval(path.getInt("BroadcastInterval")); + + if (path.contains("BroadcastMessage") && path.isList("BroadcastMessage")) + sched.setMessageToBroadcast(path.getStringList("BroadcastMessage"), path.getString("From"), path.getString("Until")); + + sched.setExpBoost(path.getDouble("Exp")); + sched.setMoneyBoost(path.getDouble("Money")); + + Jobs.getGCManager().BoostSchedule.add(sched); + + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + Jobs.getGCManager().BoostSchedule.size() + " schedulers!"); + } + } +} diff --git a/com/gamingmesh/jobs/config/ShopManager.java b/com/gamingmesh/jobs/config/ShopManager.java new file mode 100644 index 00000000..08c3aa39 --- /dev/null +++ b/com/gamingmesh/jobs/config/ShopManager.java @@ -0,0 +1,384 @@ +package com.gamingmesh.jobs.config; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.bukkit.inventory.meta.ItemMeta; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobItems; +import com.gamingmesh.jobs.container.JobProgression; +import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.container.PlayerPoints; +import com.gamingmesh.jobs.container.ShopItem; + +public class ShopManager { + private JobsPlugin plugin; + public List<ShopItem> list = new ArrayList<ShopItem>(); + public List<String> GuiList = new ArrayList<String>(); + + public ShopManager(JobsPlugin plugin) { + this.plugin = plugin; + } + + public List<ShopItem> getShopItemList() { + return list; + } + + public void checkSlot(Player player, int slot) { + + ShopItem item = list.get(slot); + PlayerPoints pointsInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(player.getUniqueId()); + + if (!player.hasPermission("jobs.items.bypass")) { + for (String onePerm : item.getRequiredPerm()) { + if (!player.hasPermission(onePerm)) { + player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPermForItem")); + return; + } + } + + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); + + if (jPlayer == null) + return; + + for (Entry<String, Integer> oneJob : item.getRequiredJobs().entrySet()) { + Job tempJob = Jobs.getJob(oneJob.getKey()); + if (tempJob == null) + continue; + JobProgression playerJob = jPlayer.getJobProgression(tempJob); + if (playerJob == null || playerJob.getLevel() < oneJob.getValue()) { + player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoJobReqForitem", + "%jobname%", tempJob.getName(), + "%joblevel%", oneJob.getValue())); + return; + } + } + + if (pointsInfo == null || pointsInfo.getCurrentPoints() < item.getPrice()) { + player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPoints")); + return; + } + } + + for (String one : item.getCommands()) { + if (one.toLowerCase().startsWith("msg ")) + player.sendMessage(one.substring(4, one.length()).replace("[player]", player.getName())); + else + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[player]", player.getName())); + } + + for (JobItems one : item.getitems()) { + @SuppressWarnings("deprecation") + Material mat = Material.getMaterial(one.getId()); + + if (mat == null) + continue; + + ItemStack itemStack = new ItemStack(mat, one.getAmount(), (byte) one.getData()); + + ItemMeta meta = itemStack.getItemMeta(); + + if (one.getName() != null) + meta.setDisplayName(one.getName()); + + if (one.getLore() != null) + meta.setLore(one.getLore()); + itemStack.setItemMeta(meta); + + if (itemStack.getType() == Material.ENCHANTED_BOOK) { + EnchantmentStorageMeta bookMeta = (EnchantmentStorageMeta) itemStack.getItemMeta(); + for (Entry<Enchantment, Integer> oneEnch : one.getenchants().entrySet()) { + bookMeta.addStoredEnchant(oneEnch.getKey(), oneEnch.getValue(), true); + } + if (bookMeta != null) + itemStack.setItemMeta(bookMeta); + } else + for (Entry<Enchantment, Integer> oneEnch : one.getenchants().entrySet()) { + itemStack.addUnsafeEnchantment(oneEnch.getKey(), oneEnch.getValue()); + } + + player.getInventory().addItem(itemStack); + + } + + if (!player.hasPermission("jobs.items.bypass")) { + pointsInfo.takePoints(item.getPrice()); + player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.Paid", "%amount%", item.getPrice())); + } + + player.getOpenInventory().getTopInventory().setContents(CreateJobsGUI(player).getContents()); + + } + + public Inventory CreateJobsGUI(Player player) { + + int GuiSize = 9; + + if (list.size() > 9) + GuiSize = 18; + + if (list.size() > 18) + GuiSize = 27; + + if (list.size() > 27) + GuiSize = 36; + + if (list.size() > 36) + GuiSize = 45; + + if (list.size() > 45) + GuiSize = 54; + + String title = Jobs.getLanguage().getMessage("command.shop.info.title"); + if (title.length() > 32) + title = title.substring(0, 30) + ".."; + + PlayerPoints pointsInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(player.getUniqueId()); + double points = 0D; + if (pointsInfo != null) + points = (int) (pointsInfo.getCurrentPoints() * 100.0) / 100.0; + + Inventory GuiInv = Bukkit.createInventory(null, GuiSize, title); + + for (int i = 0; i < list.size(); i++) { + + ShopItem item = list.get(i); + + ArrayList<String> Lore = new ArrayList<String>(); + + @SuppressWarnings("deprecation") + Material mat = Material.getMaterial(item.getIconId()); + + if (item.isHideWithoutPerm()) { + for (String onePerm : item.getRequiredPerm()) { + if (!player.hasPermission(onePerm)) { + mat = Material.STONE_BUTTON; + Lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPermToBuy")); + break; + } + } + } + + if (mat == null) + mat = Material.STONE_BUTTON; + + ItemStack GUIitem = new ItemStack(mat, item.getIconAmount(), (byte) item.getIconData()); + + ItemMeta meta = GUIitem.getItemMeta(); + + if (item.getIconName() != null) + meta.setDisplayName(item.getIconName()); + + Lore.addAll(item.getIconLore()); + + Lore.add(Jobs.getLanguage().getMessage("command.shop.info.currentPoints", "%currentpoints%", points)); + Lore.add(Jobs.getLanguage().getMessage("command.shop.info.price", "%price%", item.getPrice())); + + if (!item.getRequiredJobs().isEmpty()) { + Lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobs")); + for (Entry<String, Integer> one : item.getRequiredJobs().entrySet()) { + + String jobColor = ""; + String levelColor = ""; + + Job job = Jobs.getJob(one.getKey()); + + JobProgression prog = Jobs.getPlayerManager().getJobsPlayer(player).getJobProgression(job); + if (prog == null) { + jobColor = ChatColor.DARK_RED.toString(); + levelColor = ChatColor.DARK_RED.toString(); + } + + if (prog != null && prog.getLevel() < one.getValue()) + levelColor = ChatColor.DARK_RED.toString(); + + Lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobsList", "%jobsname%", jobColor + one.getKey(), "%level%", levelColor + one + .getValue())); + } + } + + meta.setLore(Lore); + GUIitem.setItemMeta(meta); + GuiInv.setItem(i, GUIitem); + } + return GuiInv; + } + + public void load() { + list.clear(); + File file = new File(plugin.getDataFolder(), "shopItems.yml"); + YamlConfiguration f = YamlConfiguration.loadConfiguration(file); + + if (!f.isConfigurationSection("Items")) + return; + + ConfigurationSection ConfCategory = f.getConfigurationSection("Items"); + ArrayList<String> categoriesList = new ArrayList<String>(ConfCategory.getKeys(false)); + if (categoriesList.size() == 0) + return; + for (String category : categoriesList) { + ConfigurationSection NameSection = ConfCategory.getConfigurationSection(category); + + if (!NameSection.isDouble("Price")) { + Jobs.getPluginLogger().severe("Shop item " + category + " has an invalid Price property. Skipping!"); + continue; + } + + double price = NameSection.getDouble("Price"); + + if (!NameSection.isInt("Icon.Id")) { + Jobs.getPluginLogger().severe("Shop item " + category + " has an invalid Icon Id property. Skipping!"); + continue; + } + + int IconId = NameSection.getInt("Icon.Id"); + ShopItem Sitem = new ShopItem(category, price, IconId); + + if (NameSection.isInt("Icon.Data")) + Sitem.setIconData(NameSection.getInt("Icon.Data")); + + if (NameSection.isInt("Icon.Amount")) + Sitem.setIconAmount(NameSection.getInt("Icon.Amount")); + + if (NameSection.isString("Icon.Name")) + Sitem.setIconName(ChatColor.translateAlternateColorCodes('&', NameSection.getString("Icon.Name"))); + + if (NameSection.isList("Icon.Lore")) { + List<String> lore = new ArrayList<String>(); + if (NameSection.getStringList("Icon.Lore") != null) + for (String eachLine : NameSection.getStringList("Icon.Lore")) { + lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine)); + } + Sitem.setIconLore(lore); + } + + if (NameSection.isBoolean("Icon.HideWithoutPermission")) { + Sitem.setHideWithoutPerm(NameSection.getBoolean("Icon.HideWithoutPermission")); + } + + if (NameSection.isList("RequiredPermission")) + Sitem.setRequiredPerm(NameSection.getStringList("RequiredPermission")); + + if (NameSection.isList("RequiredJobLevels")) { + HashMap<String, Integer> RequiredJobs = new HashMap<String, Integer>(); + for (String one : NameSection.getStringList("RequiredJobLevels")) { + if (!one.contains("-")) + continue; + + String job = one.split("-")[0]; + int lvl = -1; + try { + lvl = Integer.parseInt(one.split("-")[1]); + } catch (NumberFormatException e) { + continue; + } + RequiredJobs.put(job, lvl); + } + Sitem.setRequiredJobs(RequiredJobs); + } + + if (NameSection.isList("PerformCommands")) { + List<String> cmd = new ArrayList<String>(); + if (NameSection.getStringList("PerformCommands") != null) + for (String eachLine : NameSection.getStringList("PerformCommands")) { + cmd.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine)); + } + Sitem.setCommands(cmd); + } + + if (NameSection.isConfigurationSection("GiveItems")) { + ConfigurationSection itemsSection = NameSection.getConfigurationSection("GiveItems"); + Set<String> itemKeys = itemsSection.getKeys(false); + + List<JobItems> items = new ArrayList<JobItems>(); + + for (String oneItemName : itemKeys) { + + ConfigurationSection itemSection = itemsSection.getConfigurationSection(oneItemName); + + String node = oneItemName.toLowerCase(); + + int id = itemSection.getInt("Id"); + + int data = 0; + if (itemSection.isInt("Data")) + data = itemSection.getInt("Data"); + + int amount = 1; + if (itemSection.isInt("Amount")) + amount = itemSection.getInt("Amount"); + + String name = null; + if (itemSection.isString("Name")) + name = org.bukkit.ChatColor.translateAlternateColorCodes('&', itemSection.getString("Name")); + + List<String> lore = new ArrayList<String>(); + if (itemSection.getStringList("Lore") != null) + for (String eachLine : itemSection.getStringList("Lore")) { + lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine)); + } + + HashMap<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>(); + if (itemSection.getStringList("Enchants") != null) + for (String eachLine : itemSection.getStringList("Enchants")) { + + if (!eachLine.contains("=")) + continue; + + Enchantment ench = Enchantment.getByName(eachLine.split("=")[0]); + Integer level = -1; + try { + level = Integer.parseInt(eachLine.split("=")[1]); + } catch (NumberFormatException e) { + continue; + } + + if (ench != null && level != -1) + enchants.put(ench, level); + } + + items.add(new JobItems(node, id, data, amount, name, lore, enchants, 0, 0, 0)); + } + Sitem.setitems(items); + } + + if (list.size() >= 54) { + Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Jobs] To many jobs shop items, max allowed is 54! Only first 54 items will be used!"); + break; + } + list.add(Sitem); + } + + if (!list.isEmpty()) + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] " + list.size() + " shop items loaded!"); + + return; + } + + public void CloseInventories() { + for (String one : GuiList) { + Player player = Bukkit.getPlayer(one); + if (player != null) { + player.closeInventory(); + } + } + } +} diff --git a/com/gamingmesh/jobs/config/TitleManager.java b/com/gamingmesh/jobs/config/TitleManager.java new file mode 100644 index 00000000..66fafe33 --- /dev/null +++ b/com/gamingmesh/jobs/config/TitleManager.java @@ -0,0 +1,187 @@ +package com.gamingmesh.jobs.config; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.YamlConfiguration; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.container.LocaleReader; +import com.gamingmesh.jobs.container.Title; +import com.gamingmesh.jobs.stuff.ChatColor; + +public class TitleManager { + + protected List<Title> titles = new ArrayList<Title>(); + + private JobsPlugin plugin; + + public TitleManager(JobsPlugin plugin) { + this.plugin = plugin; + } + + /** + * Function to return the title for a given level + * @return the correct title + * @return null if no title matches + */ + public Title getTitleForLevel(int level, String jobName) { + Title title = null; + for (Title t : titles) { + if (title == null) { + if (t.getLevelReq() <= level) { + title = t; + } + } else { + if (t.getLevelReq() <= level && t.getLevelReq() > title.getLevelReq()) { + title = t; + } + } + } + return title; + } + + /** + * Method to load the title configuration + * + * loads from Jobs/titleConfig.yml + */ + synchronized void load() { + this.titles.clear(); + + File f = new File(plugin.getDataFolder(), "titleConfig.yml"); + YamlConfiguration config = YamlConfiguration.loadConfiguration(f); + CommentedYamlConfiguration writer = new CommentedYamlConfiguration(); + + LocaleReader c = new LocaleReader(config, writer); + + StringBuilder header = new StringBuilder() + .append("Title configuration") + .append(System.getProperty("line.separator")) + .append(System.getProperty("line.separator")) + .append("Stores the titles people gain at certain levels.") + .append(System.getProperty("line.separator")) + .append("Each title requres to have a name, short name (used when the player has more than") + .append(System.getProperty("line.separator")) + .append("1 job) the colour of the title and the level requrirement to attain the title.") + .append(System.getProperty("line.separator")) + .append(System.getProperty("line.separator")) + .append("It is recommended but not required to have a title at level 0.") + .append(System.getProperty("line.separator")) + .append(System.getProperty("line.separator")) + .append("Titles are completely optional.") + .append(System.getProperty("line.separator")) + .append("Posible variable are {level} to add current jobs level.") + .append(System.getProperty("line.separator")) + .append("Optionaly you can set different titles based by job.") + .append(System.getProperty("line.separator")) + .append(" JobName: Miner"); + c.getC().options().header(header.toString()); + c.getC().options().copyDefaults(true); + + ConfigurationSection titleSection = c.getC().getConfigurationSection("Titles"); + if (titleSection == null) { + titleSection = c.getC().createSection("Titles"); + + this.titles.add(new Title( + c.get("Titles.Novice.Name", "N"), + c.get("Titles.Novice.ShortName", "N"), + ChatColor.matchColor(c.get("Titles.Novice.ChatColour", "YELLOW")), + c.get("Titles.Novice.levelReq", 0), + null)); + + this.titles.add(new Title( + c.get("Titles.Apprentice.Name", "A"), + c.get("Titles.Apprentice.ShortName", "A"), + ChatColor.matchColor(c.get("Titles.Apprentice.ChatColour", "WHITE")), + c.get("Titles.Apprentice.levelReq", 25), + null)); + + this.titles.add(new Title( + c.get("Titles.Initiate.Name", "I"), + c.get("Titles.Initiate.ShortName", "I"), + ChatColor.matchColor(c.get("Titles.Initiate.ChatColour", "GOLD")), + c.get("Titles.Initiate.levelReq", 50), + null)); + + this.titles.add(new Title( + c.get("Titles.Journeyman.Name", "J"), + c.get("Titles.Journeyman.ShortName", "J"), + ChatColor.matchColor(c.get("Titles.Journeyman.ChatColour", "DARK_GREEN")), + c.get("Titles.Journeyman.levelReq", 75), + null)); + + this.titles.add(new Title( + c.get("Titles.Adept.Name", "Ad"), + c.get("Titles.Adept.ShortName", "Ad"), + ChatColor.matchColor(c.get("Titles.Adept.ChatColour", "DARK_PURPLE")), + c.get("Titles.Adept.levelReq", 100), + null)); + + this.titles.add(new Title( + c.get("Titles.Master.Name", "M"), + c.get("Titles.Master.ShortName", "M"), + ChatColor.matchColor(c.get("Titles.Master.ChatColour", "GRAY")), + c.get("Titles.Master.levelReq", 125), + null)); + + this.titles.add(new Title( + c.get("Titles.Grandmaster.Name", "GM"), + c.get("Titles.Grandmaster.ShortName", "GM"), + ChatColor.matchColor(c.get("Titles.Grandmaster.ChatColour", "DARK_GRAY")), + c.get("Titles.Grandmaster.levelReq", 150), + null)); + + this.titles.add(new Title( + c.get("Titles.Legendary.Name", "L"), + c.get("Titles.Legendary.ShortName", "L"), + ChatColor.matchColor(c.get("Titles.Legendary.ChatColour", "BLACK")), + c.get("Titles.Legendary.levelReq", 200), + null)); + } + + for (String titleKey : titleSection.getKeys(false)) { + String jobName = null; + String titleName = titleSection.getString(titleKey + ".Name"); + String titleShortName = titleSection.getString(titleKey + ".ShortName"); + ChatColor titleColor = ChatColor.matchColor(titleSection.getString(titleKey + ".ChatColour", "")); + int levelReq = titleSection.getInt(titleKey + ".levelReq", -1); + + if (titleSection.isString(titleKey + ".JobName")) { + jobName = titleSection.getString(titleKey + ".JobName"); + } + + if (titleName == null) { + Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid Name property. Skipping!"); + continue; + } + + if (titleShortName == null) { + Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid ShortName property. Skipping!"); + continue; + } + if (titleColor == null) { + Jobs.getPluginLogger().severe("Title " + titleKey + "has an invalid ChatColour property. Skipping!"); + continue; + } + if (levelReq <= -1) { + Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid levelReq property. Skipping!"); + continue; + } + + this.titles.add(new Title(titleName, titleShortName, titleColor, levelReq, jobName)); + } + + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + titles.size() + " titles!"); + try { + c.getC().save(f); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/com/gamingmesh/jobs/container/.gitignore b/com/gamingmesh/jobs/container/.gitignore index 6e01794b..db0090b2 100644 --- a/com/gamingmesh/jobs/container/.gitignore +++ b/com/gamingmesh/jobs/container/.gitignore @@ -26,3 +26,9 @@ /ExploreChunk.class /ExploreWorld.class /ExploreRespond.class +/PlayerInfo.class +/BossBarInfo.class +/PlayerPoints.class +/ShopItem.class +/LocaleReader.class +/BoostMultiplier.class diff --git a/com/gamingmesh/jobs/container/BoostMultiplier.java b/com/gamingmesh/jobs/container/BoostMultiplier.java new file mode 100644 index 00000000..e2f5ab06 --- /dev/null +++ b/com/gamingmesh/jobs/container/BoostMultiplier.java @@ -0,0 +1,25 @@ +package com.gamingmesh.jobs.container; + +public class BoostMultiplier { + double money; + double points; + double exp; + + public BoostMultiplier(double money, double points, double exp) { + this.money = money; + this.points = points; + this.exp = exp; + } + + public double getMoney() { + return this.money; + } + + public double getPoints() { + return this.points; + } + + public double getExp() { + return this.exp; + } +} diff --git a/com/gamingmesh/jobs/container/BossBarInfo.java b/com/gamingmesh/jobs/container/BossBarInfo.java new file mode 100644 index 00000000..1a4a6909 --- /dev/null +++ b/com/gamingmesh/jobs/container/BossBarInfo.java @@ -0,0 +1,39 @@ +package com.gamingmesh.jobs.container; + +import org.bukkit.Bukkit; +import org.bukkit.boss.BossBar; + +public class BossBarInfo { + String jobName; + String PlayerName; + BossBar bar; + int id = -1; + + public BossBarInfo(String PlayerName, String jobName, BossBar bar) { + this.PlayerName =PlayerName; + this.jobName = jobName; + this.bar = bar; + } + + public void setId(int id) { + cancel(); + this.id = id; + } + + public void cancel() { + if (id != -1) + Bukkit.getScheduler().cancelTask(this.id); + } + + public String getPlayerName() { + return this.PlayerName; + } + + public String getJobName() { + return this.jobName; + } + + public BossBar getBar() { + return this.bar; + } +} diff --git a/com/gamingmesh/jobs/container/Convert.java b/com/gamingmesh/jobs/container/Convert.java index 70c29cea..de2cb9fc 100644 --- a/com/gamingmesh/jobs/container/Convert.java +++ b/com/gamingmesh/jobs/container/Convert.java @@ -1,49 +1,41 @@ -package com.gamingmesh.jobs.container; - -import java.util.UUID; - -public class Convert { - - int id; - String name; - UUID uuid; - String jobname; - int level; - int exp; - - public Convert(int id, String name, UUID uuid2, String jobname, int level, int exp) { - this.id = id; - this.name = name; - this.uuid = uuid2; - this.jobname = jobname; - this.level = level; - this.exp = exp; - } - - public Convert() { - } - - public int GetId() { - return this.id; - } - - public String GetName() { - return this.name; - } - - public UUID GetUuid() { - return this.uuid; - } - - public String GetJobName() { - return this.jobname; - } - - public int GetLevel() { - return this.level; - } - - public int GetExp() { - return this.exp; - } -} +package com.gamingmesh.jobs.container; + +public class Convert { + + int id; + int userid; + String jobname; + int level; + int exp; + + public Convert(int id, int userid, String jobname, int level, int exp) { + this.id = id; + this.userid = userid; + this.jobname = jobname; + this.level = level; + this.exp = exp; + } + + public Convert() { + } + + public int GetId() { + return this.id; + } + + public int GetUserid() { + return this.userid; + } + + public String GetJobName() { + return this.jobname; + } + + public int GetLevel() { + return this.level; + } + + public int GetExp() { + return this.exp; + } +} diff --git a/com/gamingmesh/jobs/container/Job.java b/com/gamingmesh/jobs/container/Job.java index 7563b63d..a739c849 100644 --- a/com/gamingmesh/jobs/container/Job.java +++ b/com/gamingmesh/jobs/container/Job.java @@ -27,7 +27,6 @@ import java.util.Map; import org.bukkit.inventory.ItemStack; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.stuff.ChatColor; @@ -75,6 +74,8 @@ public class Job { private double ExpBoost = 1.0; private double MoneyBoost = 1.0; + + private double PointBoost = 1.0; /** * Constructor @@ -116,7 +117,15 @@ public class Job { this.CmdOnLeave = CmdOnLeave; this.GUIitem = GUIitem; } + + public void setPointBoost(double Point) { + this.PointBoost = Point; + } + public double getPointBoost() { + return this.PointBoost; + } + public void setMoneyBoost(double amount) { this.MoneyBoost = amount; } @@ -147,18 +156,18 @@ public class Job { } public void updateBonus() { - if (!ConfigManager.getJobsConfiguration().useDynamicPayment) + if (!Jobs.getGCManager().useDynamicPayment) return; - Parser eq = ConfigManager.getJobsConfiguration().DynamicPaymentEquation; + Parser eq = Jobs.getGCManager().DynamicPaymentEquation; eq.setVariable("totalworkers", Jobs.getJobsDAO().getTotalPlayers()); eq.setVariable("totaljobs", Jobs.getJobs().size()); eq.setVariable("jobstotalplayers", getTotalPlayers()); double now = eq.getValue(); - if (now > ConfigManager.getJobsConfiguration().DynamicPaymentMaxBonus) - now = ConfigManager.getJobsConfiguration().DynamicPaymentMaxBonus; - if (now < ConfigManager.getJobsConfiguration().DynamicPaymentMaxPenalty * -1) - now = ConfigManager.getJobsConfiguration().DynamicPaymentMaxPenalty * -1; + if (now > Jobs.getGCManager().DynamicPaymentMaxBonus) + now = Jobs.getGCManager().DynamicPaymentMaxBonus; + if (now < Jobs.getGCManager().DynamicPaymentMaxPenalty * -1) + now = Jobs.getGCManager().DynamicPaymentMaxPenalty * -1; this.bonus = now; } @@ -207,42 +216,13 @@ public class Job { public EnumMap<ActionType, List<JobInfo>> getJobInfoList() { return jobInfo; } - - /** - * Function to get the income for an action - * @param action - The action info - * @param level - players job level - * @param numjobs - number of jobs for the player - * @return the income received for performing action - */ - - public Double getIncome(ActionInfo action, int level, int numjobs) { - List<JobInfo> jobInfo = getJobInfo(action.getType()); - for (JobInfo info : jobInfo) { - if (info.getName().equalsIgnoreCase(action.getName()) || info.getName().equalsIgnoreCase(action.getNameWithSub())) { - if (!info.isInLevelRange(level)) - return 0D; - return info.getIncome(level, numjobs); - } - } - return null; - } - - /** - * Function to get the income for an action - * @param action - The action info - * @param level - players job level - * @param numjobs - number of jobs for the player - * @return the income received for performing action - */ - - public Double getExperience(ActionInfo action, int level, int numjobs) { - List<JobInfo> jobInfo = getJobInfo(action.getType()); - for (JobInfo info : jobInfo) { + + public JobInfo getJobInfo(ActionInfo action, int level) { + for (JobInfo info : getJobInfo(action.getType())) { if (info.getName().equalsIgnoreCase(action.getName()) || info.getName().equalsIgnoreCase(action.getNameWithSub())){ if (!info.isInLevelRange(level)) - return 0D; - return info.getExperience(level, numjobs); + break; + return info; } } return null; diff --git a/com/gamingmesh/jobs/container/JobInfo.java b/com/gamingmesh/jobs/container/JobInfo.java index d253fa3e..cf64bc74 100644 --- a/com/gamingmesh/jobs/container/JobInfo.java +++ b/com/gamingmesh/jobs/container/JobInfo.java @@ -25,23 +25,26 @@ public class JobInfo { private int id; private String meta; private String name; - private double baseIncome, baseXp; - private Parser moneyEquation, xpEquation; + private double baseIncome, baseXp, basePoints; + private Parser moneyEquation, xpEquation, pointsEquation; private int fromLevel; private int untilLevel; - public JobInfo(ActionType actionType, int id, String meta, String name, double baseIncome, Parser moneyEquation, double baseXp, Parser xpEquation, int fromLevel, - int untilLevel) { + public JobInfo(ActionType actionType, int id, String meta, String name, double baseIncome, Parser moneyEquation, double baseXp, Parser xpEquation, + Parser pointsEquation, double basePoints, int fromLevel, int untilLevel) { this.actionType = actionType; this.id = id; this.meta = meta; this.name = name; this.baseIncome = baseIncome; this.moneyEquation = moneyEquation; + this.pointsEquation = pointsEquation; + this.basePoints = basePoints; this.baseXp = baseXp; this.xpEquation = xpEquation; this.fromLevel = fromLevel; this.untilLevel = untilLevel; + } public int getFromLevel() { @@ -80,17 +83,28 @@ public class JobInfo { return this.baseXp; } - public double getIncome(int level, int numjobs) { + public double getBasePoints() { + return this.basePoints; + } + + public double getIncome(double level, double numjobs) { moneyEquation.setVariable("joblevel", level); moneyEquation.setVariable("numjobs", numjobs); moneyEquation.setVariable("baseincome", baseIncome); return moneyEquation.getValue(); } - public double getExperience(int level, int numjobs) { + public double getExperience(double level, double numjobs) { xpEquation.setVariable("joblevel", level); xpEquation.setVariable("numjobs", numjobs); xpEquation.setVariable("baseexperience", baseXp); return xpEquation.getValue(); } + + public double getPoints(double level, double numjobs) { + pointsEquation.setVariable("joblevel", level); + pointsEquation.setVariable("numjobs", numjobs); + pointsEquation.setVariable("basepoints", basePoints); + return pointsEquation.getValue(); + } } diff --git a/com/gamingmesh/jobs/container/JobItems.java b/com/gamingmesh/jobs/container/JobItems.java index d3dec80e..cc4c9a0b 100644 --- a/com/gamingmesh/jobs/container/JobItems.java +++ b/com/gamingmesh/jobs/container/JobItems.java @@ -24,49 +24,68 @@ import java.util.List; import org.bukkit.enchantments.Enchantment; public class JobItems { - private String node; - private int id; - private String name; - private List<String> lore; - private HashMap<Enchantment, Integer> enchants; - private Double moneyBoost; - private Double expBoost; + private String node; + private int id; + private int data; + private int amount; + private String name; + private List<String> lore; + private HashMap<Enchantment, Integer> enchants; + private Double moneyBoost = 0D; + private Double pointBoost = 0D; + private Double expBoost = 0D; - public JobItems(String node, int id, String name, List<String> lore, HashMap<Enchantment, Integer> enchants, double moneyBoost, double expBoost) { - this.node = node; - this.id = id; - this.name = name; - this.lore = lore; - this.enchants = enchants; - this.moneyBoost = moneyBoost; - this.expBoost = expBoost; - } + public JobItems(String node, int id, int data, int amount, String name, List<String> lore, HashMap<Enchantment, Integer> enchants, double moneyBoost, + double pointBoost, double expBoost) { + this.node = node; + this.id = id; + this.data = data; + this.amount = amount; + this.name = name; + this.lore = lore; + this.enchants = enchants; + this.moneyBoost = moneyBoost; + this.pointBoost = pointBoost; + this.expBoost = expBoost; + } - public String getNode() { - return this.node; - } + public String getNode() { + return this.node; + } - public int getId() { - return this.id; - } + public int getId() { + return this.id; + } - public String getName() { - return this.name; - } + public int getData() { + return this.data; + } - public List<String> getLore() { - return this.lore; - } + public int getAmount() { + return this.amount; + } - public HashMap<Enchantment, Integer> getenchants() { - return this.enchants; - } + public String getName() { + return this.name; + } - public Double getMoneyBoost() { - return this.moneyBoost; - } + public List<String> getLore() { + return this.lore; + } - public Double getExpBoost() { - return this.expBoost; - } + public HashMap<Enchantment, Integer> getenchants() { + return this.enchants; + } + + public Double getMoneyBoost() { + return this.moneyBoost; + } + + public Double getPointBoost() { + return this.pointBoost; + } + + public Double getExpBoost() { + return this.expBoost; + } } diff --git a/com/gamingmesh/jobs/container/JobProgression.java b/com/gamingmesh/jobs/container/JobProgression.java index ea4c3eed..ae3984ab 100644 --- a/com/gamingmesh/jobs/container/JobProgression.java +++ b/com/gamingmesh/jobs/container/JobProgression.java @@ -21,168 +21,180 @@ package com.gamingmesh.jobs.container; import java.util.HashMap; public class JobProgression { - private Job job; - private JobsPlayer jPlayer; - private double experience; - private int level; - private transient int maxExperience = -1; - private double MoneyBoost = -1; - private double ExpBoost = -1; + private Job job; + private JobsPlayer jPlayer; + private double experience; + private int level; + private transient int maxExperience = -1; + private double MoneyBoost = -1; + private double PointBoost = -1; + private double ExpBoost = -1; - public JobProgression(Job job, JobsPlayer jPlayer, int level, double experience, double MoneyBoost, double ExpBoost) { - this.job = job; - this.jPlayer = jPlayer; - this.experience = experience; - this.level = level; - this.MoneyBoost = MoneyBoost; - this.ExpBoost = ExpBoost; - } + public JobProgression(Job job, JobsPlayer jPlayer, int level, double experience, double MoneyBoost, double PointBoost, double ExpBoost) { + this.job = job; + this.jPlayer = jPlayer; + this.experience = experience; + this.level = level; + this.MoneyBoost = MoneyBoost; + this.PointBoost = PointBoost; + this.ExpBoost = ExpBoost; + } - /** - * Can the job level up? - * @return true if the job can level up - * @return false if the job cannot - */ - public boolean canLevelUp() { - return experience >= maxExperience; - } + /** + * Can the job level up? + * @return true if the job can level up + * @return false if the job cannot + */ + public boolean canLevelUp() { + return experience >= maxExperience; + } - /** - * Return the MoneyBoost - * @return the MoneyBoost - */ - public double getMoneyBoost() { - if (this.MoneyBoost == -1) - this.MoneyBoost = JobsPlayer.getMoneyBoost(this.job.getName(), this.jPlayer.getPlayer()); - return this.MoneyBoost; - } + /** + * Return the MoneyBoost + * @return the MoneyBoost + */ + public double getMoneyBoost() { + if (this.MoneyBoost == -1) + this.MoneyBoost = JobsPlayer.getMoneyBoost(this.job.getName(), this.jPlayer.getPlayer()); + return this.MoneyBoost; + } - /** - * Return the ExpBoost - * @return the ExpBoost - */ - public double getExpBoost() { - if (this.ExpBoost == -1) - this.ExpBoost = JobsPlayer.getExpBoost(this.job.getName(), this.jPlayer.getPlayer()); - return this.ExpBoost; - } + /** + * Return the PointBoost + * @return the PointBoost + */ + public double getPointBoost() { + if (this.PointBoost == -1) + this.PointBoost = JobsPlayer.getPointBoost(this.job.getName(), this.jPlayer.getPlayer()); + return this.PointBoost; + } - /** - * Return the job - * @return the job - */ - public Job getJob() { - return job; - } + /** + * Return the ExpBoost + * @return the ExpBoost + */ + public double getExpBoost() { + if (this.ExpBoost == -1) + this.ExpBoost = JobsPlayer.getExpBoost(this.job.getName(), this.jPlayer.getPlayer()); + return this.ExpBoost; + } - /** - * Set the job - * @param job - the new job to be set - */ - public void setJob(Job job) { + /** + * Return the job + * @return the job + */ + public Job getJob() { + return job; + } + + /** + * Set the job + * @param job - the new job to be set + */ + public void setJob(Job job) { // synchronized (jPlayer.saveLock) { - jPlayer.setSaved(false); - this.job = job; - reloadMaxExperienceAndCheckLevelUp(); + jPlayer.setSaved(false); + this.job = job; + reloadMaxExperienceAndCheckLevelUp(); // } - } + } - /** - * Get the experience in this job - * @return the experiece in this job - */ - public double getExperience() { - return experience; - } + /** + * Get the experience in this job + * @return the experiece in this job + */ + public double getExperience() { + return experience; + } - /** - * Adds experience for this job - * @param experience - the experience in this job - * @return - job level up - */ - public boolean addExperience(double experience) { + /** + * Adds experience for this job + * @param experience - the experience in this job + * @return - job level up + */ + public boolean addExperience(double experience) { // synchronized (jPlayer.saveLock) { - jPlayer.setSaved(false); - this.experience += experience; - return checkLevelUp(); + jPlayer.setSaved(false); + this.experience += experience; + return checkLevelUp(); // } - } + } - /** - * Get the maximum experience for this level - * @return the experience needed to level up - */ - public int getMaxExperience() { - return maxExperience; - } + /** + * Get the maximum experience for this level + * @return the experience needed to level up + */ + public int getMaxExperience() { + return maxExperience; + } - /** - * Get the current level of this job - * @return the level of this job - */ - public int getLevel() { - return level; - } + /** + * Get the current level of this job + * @return the level of this job + */ + public int getLevel() { + return level; + } - /** - * Set the level of this job - * @param level - the new level for this job - */ - public void setLevel(int level) { + /** + * Set the level of this job + * @param level - the new level for this job + */ + public void setLevel(int level) { // synchronized (jPlayer.saveLock) { - jPlayer.setSaved(false); - this.level = level; - reloadMaxExperienceAndCheckLevelUp(); + jPlayer.setSaved(false); + this.level = level; + reloadMaxExperienceAndCheckLevelUp(); // } + } + + /** + * Reloads max experience + */ + public void reloadMaxExperience() { + HashMap<String, Double> param = new HashMap<String, Double>(); + param.put("joblevel", (double) level); + param.put("numjobs", (double) jPlayer.getJobProgression().size()); + this.maxExperience = (int) job.getMaxExp(param); + } + + /** + * Performs a level up + * @returns if level up was performed + */ + private boolean checkLevelUp() { + boolean ret = false; + while (canLevelUp()) { + + int maxLevel = 0; + if (jPlayer.havePermission("jobs." + job.getName() + ".vipmaxlevel") && job.getVipMaxLevel() != 0) + maxLevel = job.getVipMaxLevel(); + else + maxLevel = job.getMaxLevel(); + + // Don't level up at max level + if (job.getMaxLevel() > 0 && level >= maxLevel) + break; + level++; + experience -= maxExperience; + ret = true; + reloadMaxExperience(); } - /** - * Reloads max experience - */ - public void reloadMaxExperience() { - HashMap<String, Double> param = new HashMap<String, Double>(); - param.put("joblevel", (double) level); - param.put("numjobs", (double) jPlayer.getJobProgression().size()); - this.maxExperience = (int) job.getMaxExp(param); - } + // At max level + if (experience > maxExperience) + experience = maxExperience; + return ret; + } - /** - * Performs a level up - * @returns if level up was performed - */ - private boolean checkLevelUp() { - boolean ret = false; - while (canLevelUp()) { + /** + * Reloads max experience and checks for level up + * Do this whenever job or level changes + * @return if leveled up + */ - int maxLevel = 0; - if (jPlayer.havePermission("jobs." + job.getName() + ".vipmaxlevel") && job.getVipMaxLevel() != 0) - maxLevel = job.getVipMaxLevel(); - else - maxLevel = job.getMaxLevel(); - - // Don't level up at max level - if (job.getMaxLevel() > 0 && level >= maxLevel) - break; - level++; - experience -= maxExperience; - ret = true; - reloadMaxExperience(); - } - - // At max level - if (experience > maxExperience) - experience = maxExperience; - return ret; - } - - /** - * Reloads max experience and checks for level up - * Do this whenever job or level changes - * @return if leveled up - */ - - private boolean reloadMaxExperienceAndCheckLevelUp() { - reloadMaxExperience(); - return checkLevelUp(); - } + private boolean reloadMaxExperienceAndCheckLevelUp() { + reloadMaxExperience(); + return checkLevelUp(); + } } diff --git a/com/gamingmesh/jobs/container/JobsPlayer.java b/com/gamingmesh/jobs/container/JobsPlayer.java index e04e43f5..c7a2230f 100644 --- a/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/com/gamingmesh/jobs/container/JobsPlayer.java @@ -27,11 +27,11 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.dao.JobsDAO; import com.gamingmesh.jobs.dao.JobsDAOData; import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.stuff.ChatColor; +import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.Perm; public class JobsPlayer { @@ -39,7 +39,7 @@ public class JobsPlayer { private String userName; // progression of the player in each job private UUID playerUUID; - private ArrayList<JobProgression> progression = new ArrayList<JobProgression>(); + public ArrayList<JobProgression> progression = new ArrayList<JobProgression>(); // display honorific private String honorific; // player save status @@ -53,14 +53,19 @@ public class JobsPlayer { private int MoneyLimit = 0; private int ExpLimit = 0; + private int PointLimit = 0; + private int userid = -1; + + List<BossBarInfo> barMap = new ArrayList<BossBarInfo>(); + List<String> updateBossBarFor = new ArrayList<String>(); // save lock // public final Object saveLock = new Object(); // log private List<Log> logList = new ArrayList<Log>(); - private JobsPlayer(String userName, OfflinePlayer player) { + public JobsPlayer(String userName, OfflinePlayer player) { this.userName = userName; this.player = player; } @@ -81,15 +86,16 @@ public class JobsPlayer { continue; // create the progression object - JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience(), -1, -1); + JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience(), -1, -1, -1); // calculate the max level // add the progression level. jPlayer.progression.add(jobProgression); } jPlayer.reloadMaxExperience(); - jPlayer.reloadMoneyLimit(); - jPlayer.reloadExpLimit(); + jPlayer.reloadLimits(); + jPlayer.setUserId(Jobs.getPlayerManager().getPlayerMap().get(player.getUniqueId().toString()).getID()); + Jobs.getJobsDAO().loadPoints(jPlayer); // } return jPlayer; } @@ -98,10 +104,32 @@ public class JobsPlayer { Jobs.getJobsDAO().loadLog(jPlayer); } + public List<String> getUpdateBossBarFor() { + return this.updateBossBarFor; + } + + public List<BossBarInfo> getBossBarInfo() { + return this.barMap; + } + + public void hideBossBars() { + for (BossBarInfo one : this.barMap) { + one.getBar().setVisible(false); + } + } + public List<Log> getLog() { return this.logList; } + public void setUserId(int id) { + this.userid = id; + } + + public int getUserId() { + return this.userid; + } + /** * Get the player * @return the player @@ -124,9 +152,9 @@ public class JobsPlayer { public void updateVipSpawnerMultiplier() { if (Perm.hasPermission(this.player, "jobs.vipspawner")) - this.VipSpawnerMultiplier = ConfigManager.getJobsConfiguration().VIPpayNearSpawnerMultiplier; + this.VipSpawnerMultiplier = Jobs.getGCManager().VIPpayNearSpawnerMultiplier; else - this.VipSpawnerMultiplier = ConfigManager.getJobsConfiguration().payNearSpawnerMultiplier; + this.VipSpawnerMultiplier = Jobs.getGCManager().payNearSpawnerMultiplier; } /** @@ -138,15 +166,30 @@ public class JobsPlayer { if (JobName != null) { if (Perm.hasPermission(player, "jobs.boost." + JobName + ".money") || Perm.hasPermission(player, "jobs.boost." + JobName + ".both") || Perm.hasPermission( player, "jobs.boost.all.both") || Perm.hasPermission(player, "jobs.boost.all.money")) { - MoneyBoost = ConfigManager.getJobsConfiguration().BoostMoney; + MoneyBoost = Jobs.getGCManager().BoostMoney; } } return MoneyBoost; } /** - * Get the MoneyBoost - * @return the MoneyBoost + * Get the PointBoost + * @return the PointBoost + */ + public static double getPointBoost(String JobName, OfflinePlayer player) { + double PointBoost = 1.0; + if (JobName != null) { + if (Perm.hasPermission(player, "jobs.boost." + JobName + ".points") || Perm.hasPermission(player, "jobs.boost." + JobName + ".both") || Perm.hasPermission( + player, "jobs.boost.all.both") || Perm.hasPermission(player, "jobs.boost.all.money")) { + PointBoost = Jobs.getGCManager().BoostPoints; + } + } + return PointBoost; + } + + /** + * Get the ExpBoost + * @return the ExpBoost */ public static double getExpBoost(String JobName, OfflinePlayer player) { Double ExpBoost = 1.0; @@ -154,7 +197,7 @@ public class JobsPlayer { return 1.0; if (Perm.hasPermission(player, "jobs.boost." + JobName + ".exp") || Perm.hasPermission(player, "jobs.boost." + JobName + ".both") || Perm.hasPermission(player, "jobs.boost.all.both") || Perm.hasPermission(player, "jobs.boost.all.exp")) { - ExpBoost = ConfigManager.getJobsConfiguration().BoostExp; + ExpBoost = Jobs.getGCManager().BoostExp; } return ExpBoost; } @@ -162,7 +205,7 @@ public class JobsPlayer { /** * Reloads max experience for this job. */ - private void reloadMaxExperience() { + public void reloadMaxExperience() { for (JobProgression prog : progression) { prog.reloadMaxExperience(); } @@ -171,12 +214,12 @@ public class JobsPlayer { /** * Reloads money limit for this player. */ - public void reloadMoneyLimit() { + public void reloadMoney() { int TotalLevel = 0; for (JobProgression prog : progression) { TotalLevel += prog.getLevel(); } - Parser eq = ConfigManager.getJobsConfiguration().maxMoneyEquation; + Parser eq = Jobs.getGCManager().maxMoneyEquation; eq.setVariable("totallevel", TotalLevel); MoneyLimit = (int) eq.getValue(); } @@ -184,16 +227,35 @@ public class JobsPlayer { /** * Reloads exp limit for this player. */ - public void reloadExpLimit() { + public void reloadExp() { int TotalLevel = 0; for (JobProgression prog : progression) { TotalLevel += prog.getLevel(); } - Parser eq = ConfigManager.getJobsConfiguration().maxExpEquation; + Parser eq = Jobs.getGCManager().maxExpEquation; eq.setVariable("totallevel", TotalLevel); ExpLimit = (int) eq.getValue(); } - + + /** + * Reloads exp limit for this player. + */ + public void reloadPoint() { + int TotalLevel = 0; + for (JobProgression prog : progression) { + TotalLevel += prog.getLevel(); + } + Parser eq = Jobs.getGCManager().maxPointEquation; + eq.setVariable("totallevel", TotalLevel); + PointLimit = (int) eq.getValue(); + } + + public void reloadLimits() { + reloadMoney(); + reloadExp(); + reloadPoint(); + } + public int getMoneyLimit() { return this.MoneyLimit; } @@ -202,6 +264,10 @@ public class JobsPlayer { return this.ExpLimit; } + public int getPointLimit() { + return this.PointLimit; + } + /** * Get the list of job progressions * @return the list of job progressions @@ -248,6 +314,10 @@ public class JobsPlayer { return playerUUID; } + public void setPlayerUUID(UUID uuid) { + playerUUID = uuid; + } + public String getDisplayHonorific() { return honorific; } @@ -268,10 +338,9 @@ public class JobsPlayer { Jobs.getJobsDAO().deleteArchive(jPlayer, job); } - progression.add(new JobProgression(job, this, level, exp, -1, -1)); + progression.add(new JobProgression(job, this, level, exp, -1, -1, -1)); reloadMaxExperience(); - reloadMoneyLimit(); - reloadExpLimit(); + reloadLimits(); reloadHonorific(); Jobs.getPermissionHandler().recalculatePermissions(this); return true; @@ -290,8 +359,7 @@ public class JobsPlayer { if (prog != null) { progression.remove(prog); reloadMaxExperience(); - reloadMoneyLimit(); - reloadExpLimit(); + reloadLimits(); reloadHonorific(); Jobs.getPermissionHandler().recalculatePermissions(this); return true; @@ -404,8 +472,7 @@ public class JobsPlayer { prog.setLevel(maxLevel); } reloadMaxExperience(); - reloadMoneyLimit(); - reloadExpLimit(); + reloadLimits(); reloadHonorific(); Jobs.getPermissionHandler().recalculatePermissions(this); @@ -444,10 +511,10 @@ public class JobsPlayer { if (method.equals(DisplayMethod.NONE)) continue; if (gotTitle) { - builder.append(ConfigManager.getJobsConfiguration().getModifyChatSeparator()); + builder.append(Jobs.getGCManager().getModifyChatSeparator()); gotTitle = false; } - Title title = ConfigManager.getJobsConfiguration().getTitleForLevel(prog.getLevel(), prog.getJob().getName()); + Title title = Jobs.gettitleManager().getTitleForLevel(prog.getLevel(), prog.getJob().getName()); if (numJobs == 1) { if (method.equals(DisplayMethod.FULL) || method.equals(DisplayMethod.TITLE)) { @@ -514,7 +581,7 @@ public class JobsPlayer { honorific = builder.toString().trim(); if (honorific.length() > 0) - honorific = ConfigManager.getJobsConfiguration().getModifyChatPrefix() + honorific + ConfigManager.getJobsConfiguration().getModifyChatSuffix(); + honorific = Jobs.getGCManager().getModifyChatPrefix() + honorific + Jobs.getGCManager().getModifyChatSuffix(); } @@ -523,10 +590,15 @@ public class JobsPlayer { * @param dao */ public void save(JobsDAO dao) { + long time = System.nanoTime(); // synchronized (saveLock) { if (!isSaved()) { dao.save(this); + Debug.D("1 " + (System.nanoTime() - time)); dao.saveLog(this); + Debug.D("2 " + (System.nanoTime() - time)); + dao.savePoints(this); + Debug.D("3 " + (System.nanoTime() - time)); setSaved(true); } // } @@ -544,9 +616,18 @@ public class JobsPlayer { * */ public void onDisconnect() { +// Jobs.getJobsDAO().savePoints(this); + clearBossMaps(); isOnline = false; } + public void clearBossMaps() { + for (BossBarInfo one : barMap) { + one.cancel(); + } + barMap.clear(); + } + /** * Whether or not player is online * @return true if online, otherwise false diff --git a/com/gamingmesh/jobs/container/LocaleReader.java b/com/gamingmesh/jobs/container/LocaleReader.java new file mode 100644 index 00000000..7e51f922 --- /dev/null +++ b/com/gamingmesh/jobs/container/LocaleReader.java @@ -0,0 +1,75 @@ +package com.gamingmesh.jobs.container; + +import java.util.List; + +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.ChatColor; + +import com.gamingmesh.jobs.config.CommentedYamlConfiguration; + +public class LocaleReader { + YamlConfiguration config; + CommentedYamlConfiguration writer; + + public LocaleReader(YamlConfiguration config, CommentedYamlConfiguration writer) { + this.config = config; + this.writer = writer; + } + + public CommentedYamlConfiguration getW() { + return writer; + } + + public YamlConfiguration getC() { + return config; + } + + public Boolean get(String path, Boolean boo) { + config.addDefault(path, boo); + copySetting(path); + return config.getBoolean(path); + } + + public int get(String path, int boo) { + config.addDefault(path, boo); + copySetting(path); + return config.getInt(path); + } + + public List<Integer> getIntList(String path, List<Integer> list) { + config.addDefault(path, list); + copySetting(path); + return config.getIntegerList(path); + } + + public List<String> getStringList(String path, List<String> list) { + config.addDefault(path, list); + copySetting(path); + return config.getStringList(path); + } + + public String get(String path, String boo) { + config.addDefault(path, boo); + copySetting(path); + return get(path, boo, true); + } + + public String get(String path, String boo, boolean colorize) { + config.addDefault(path, boo); + copySetting(path); + if (colorize) + return ChatColor.translateAlternateColorCodes('&', config.getString(path)); + else + return config.getString(path); + } + + public Double get(String path, Double boo) { + config.addDefault(path, boo); + copySetting(path); + return config.getDouble(path); + } + + public synchronized void copySetting(String path) { + writer.set(path, config.get(path)); + } +} diff --git a/com/gamingmesh/jobs/container/PlayerInfo.java b/com/gamingmesh/jobs/container/PlayerInfo.java new file mode 100644 index 00000000..f6e2114c --- /dev/null +++ b/com/gamingmesh/jobs/container/PlayerInfo.java @@ -0,0 +1,20 @@ +package com.gamingmesh.jobs.container; + +public class PlayerInfo { + + int id; + String name; + + public PlayerInfo(String name, int id) { + this.name = name; + this.id = id; + } + + public String getName() { + return name; + } + + public int getID() { + return id; + } +} diff --git a/com/gamingmesh/jobs/container/PlayerPoints.java b/com/gamingmesh/jobs/container/PlayerPoints.java new file mode 100644 index 00000000..f5c8023a --- /dev/null +++ b/com/gamingmesh/jobs/container/PlayerPoints.java @@ -0,0 +1,53 @@ +package com.gamingmesh.jobs.container; + +public class PlayerPoints { + + double current = 0D; + double total = 0D; + boolean newEntry = false; + + public PlayerPoints() { + newEntry = true; + } + + public PlayerPoints(double points, double total) { + if (points == 0D && total == 0D) + newEntry = true; + this.current = points; + this.total = total; + } + + public void addPoints(double points) { + this.current += points; + this.total += points; + } + + public void setPoints(double points) { + this.current = points; + this.total = points; + } + + public void takePoints(double points) { + this.current -= points; + } + + public boolean havePoints(double points) { + return this.current >= points; + } + + public double getCurrentPoints() { + return current; + } + + public double getTotalPoints() { + return total; + } + + public boolean isNewEntry() { + return newEntry; + } + + public void setNewEntry(boolean state) { + newEntry = state; + } +} diff --git a/com/gamingmesh/jobs/container/ShopItem.java b/com/gamingmesh/jobs/container/ShopItem.java new file mode 100644 index 00000000..7e4abb3b --- /dev/null +++ b/com/gamingmesh/jobs/container/ShopItem.java @@ -0,0 +1,117 @@ +package com.gamingmesh.jobs.container; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class ShopItem { + + private String NodeName = null; + + private double price = 0D; + + private int IconId = 1; + private int IconData = 0; + private int IconAmount = 1; + private String IconName = null; + private List<String> IconLore = new ArrayList<String>(); + + private boolean HideWithoutPerm = false; + + private List<String> RequiredPerm = new ArrayList<String>(); + private HashMap<String, Integer> RequiredJobs = new HashMap<String, Integer>(); + + private List<String> Commands = new ArrayList<String>(); + + private List<JobItems> items = new ArrayList<JobItems>(); + + public ShopItem(String NodeName, double price, int IconId) { + this.NodeName = NodeName; + this.price = price; + this.IconId = IconId; + } + + public void setitems(List<JobItems> items) { + this.items = items; + } + + public List<JobItems> getitems() { + return this.items; + } + + public void setCommands(List<String> Commands) { + this.Commands = Commands; + } + + public List<String> getCommands() { + return this.Commands; + } + + public void setRequiredJobs(HashMap<String, Integer> RequiredJobs) { + this.RequiredJobs = RequiredJobs; + } + + public HashMap<String, Integer> getRequiredJobs() { + return this.RequiredJobs; + } + + public void setRequiredPerm(List<String> RequiredPerm) { + this.RequiredPerm = RequiredPerm; + } + + public List<String> getRequiredPerm() { + return this.RequiredPerm; + } + + public void setHideWithoutPerm(boolean HideWithoutPerm) { + this.HideWithoutPerm = HideWithoutPerm; + } + + public boolean isHideWithoutPerm() { + return this.HideWithoutPerm; + } + + public void setIconLore(List<String> IconLore) { + this.IconLore = IconLore; + } + + public List<String> getIconLore() { + return this.IconLore; + } + + public String getNodeName() { + return this.NodeName; + } + + public int getIconId() { + return this.IconId; + } + + public int getIconData() { + return this.IconData; + } + + public void setIconData(int IconData) { + this.IconData = IconData; + } + + public double getPrice() { + return this.price; + } + + public void setIconAmount(int IconAmount) { + this.IconAmount = IconAmount; + } + + public int getIconAmount() { + return this.IconAmount; + } + + public void setIconName(String IconName) { + this.IconName = IconName; + } + + public String getIconName() { + return this.IconName; + } +} diff --git a/com/gamingmesh/jobs/container/TopList.java b/com/gamingmesh/jobs/container/TopList.java index 1cb4206f..e6e348d9 100644 --- a/com/gamingmesh/jobs/container/TopList.java +++ b/com/gamingmesh/jobs/container/TopList.java @@ -1,40 +1,28 @@ package com.gamingmesh.jobs.container; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; - -import com.gamingmesh.jobs.stuff.OfflinePlayerList; +import java.util.Map.Entry; +import com.gamingmesh.jobs.Jobs; public final class TopList { - private String player; + private int id; private int level; private int exp; - private UUID uuid; - public TopList(String player, int level, int exp, UUID uuid) { - this.player = player; + public TopList(int id, int level, int exp) { + this.id = id; this.level = level; this.exp = exp; - this.uuid = uuid; } public String getPlayerName() { - if (this.player == null || this.player == "") { - Player player = Bukkit.getPlayer(this.uuid); - if (player != null) - return player.getName(); - else { - OfflinePlayer Offlineplayer = OfflinePlayerList.getPlayer(this.uuid); - if (Offlineplayer != null) - return Offlineplayer.getName(); - else - return "Unknown"; - } + Entry<String, PlayerInfo> info = Jobs.getPlayerManager().getPlayerInfoById(this.id); + if (info != null) { + if (info.getValue().getName() != null) + return info.getValue().getName(); + else + return "Unknown"; } - return this.player; + return "Unknown"; } public int getLevel() { diff --git a/com/gamingmesh/jobs/dao/JobsConnection.java b/com/gamingmesh/jobs/dao/JobsConnection.java index 8316e61c..8adecfa2 100644 --- a/com/gamingmesh/jobs/dao/JobsConnection.java +++ b/com/gamingmesh/jobs/dao/JobsConnection.java @@ -24,46 +24,46 @@ import java.sql.SQLException; import java.sql.Statement; public class JobsConnection { - private Connection conn; + private Connection conn; - public JobsConnection(Connection conn) { - this.conn = conn; - } + public JobsConnection(Connection conn) { + this.conn = conn; + } - public synchronized boolean isClosed() { - try { - return conn.isClosed(); - } catch (SQLException e) { - // Assume it's closed - return true; - } + public synchronized boolean isClosed() { + try { + return conn.isClosed(); + } catch (SQLException e) { + // Assume it's closed + return true; } + } - public synchronized boolean isValid(int timeout) throws SQLException { - try { - return conn.isValid(timeout); - } catch (AbstractMethodError e) { - return true; - } + public synchronized boolean isValid(int timeout) throws SQLException { + try { + return conn.isValid(timeout); + } catch (AbstractMethodError e) { + return true; } + } - public synchronized void closeConnection() throws SQLException { - conn.close(); - } + public synchronized void closeConnection() throws SQLException { + conn.close(); + } - public synchronized Statement createStatement() throws SQLException { - return conn.createStatement(); - } + public synchronized Statement createStatement() throws SQLException { + return conn.createStatement(); + } - public synchronized PreparedStatement prepareStatement(String sql) throws SQLException { - return conn.prepareStatement(sql); - } + public synchronized PreparedStatement prepareStatement(String sql) throws SQLException { + return conn.prepareStatement(sql); + } - public synchronized void setAutoCommit(Boolean mode) throws SQLException { - conn.setAutoCommit(mode); - } + public synchronized void setAutoCommit(Boolean mode) throws SQLException { + conn.setAutoCommit(mode); + } - public synchronized void commit() throws SQLException { - conn.commit(); - } + public synchronized void commit() throws SQLException { + conn.commit(); + } } diff --git a/com/gamingmesh/jobs/dao/JobsDAO.java b/com/gamingmesh/jobs/dao/JobsDAO.java index 73ad9a78..3f91be47 100644 --- a/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/com/gamingmesh/jobs/dao/JobsDAO.java @@ -23,18 +23,15 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.UUID; import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.container.Convert; import com.gamingmesh.jobs.container.ExploreChunk; import com.gamingmesh.jobs.container.ExploreRegion; @@ -43,13 +40,12 @@ import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.Log; import com.gamingmesh.jobs.container.LogAmounts; +import com.gamingmesh.jobs.container.PlayerInfo; +import com.gamingmesh.jobs.container.PlayerPoints; import com.gamingmesh.jobs.container.TopList; -import com.gamingmesh.jobs.stuff.ChatColor; import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.Loging; -import com.gamingmesh.jobs.stuff.OfflinePlayerList; import com.gamingmesh.jobs.stuff.TimeManage; -import com.gamingmesh.jobs.stuff.UUIDUtil; /** * Data Access Object interface for the Jobs plugin @@ -98,7 +94,10 @@ public abstract class JobsDAO { // creating explore database checkUpdate8(); - version = 8; + if (version <= 8) + checkUpdate9(); + + version = 9; updateSchemaVersion(version); } finally { } @@ -120,6 +119,8 @@ public abstract class JobsDAO { protected abstract void checkUpdate8() throws SQLException; + protected abstract void checkUpdate9() throws SQLException; + /** * Gets the database prefix * @return the prefix @@ -128,22 +129,34 @@ public abstract class JobsDAO { return prefix; } + public synchronized List<JobsDAOData> getAllJobs(OfflinePlayer player) { + return getAllJobs(player.getName(), player.getUniqueId()); + } + /** * Get all jobs the player is part of. * @param playerUUID - the player being searched for * @return list of all of the names of the jobs the players are part of. */ - public synchronized List<JobsDAOData> getAllJobs(OfflinePlayer player) { + public synchronized List<JobsDAOData> getAllJobs(String playerName, UUID uuid) { + + int id = -1; + PlayerInfo userData = Jobs.getPlayerManager().getPlayerMap().get(uuid.toString()); + if (userData == null) { + id = recordNewPlayer(playerName, uuid); + } else + id = userData.getID(); + ArrayList<JobsDAOData> jobs = new ArrayList<JobsDAOData>(); JobsConnection conn = getConnection(); if (conn == null) return jobs; try { - PreparedStatement prest = conn.prepareStatement("SELECT `player_uuid`, `job`, `level`, `experience` FROM `" + prefix + "jobs` WHERE `player_uuid` = ?;"); - prest.setString(1, player.getUniqueId().toString()); + PreparedStatement prest = conn.prepareStatement("SELECT `job`, `level`, `experience` FROM `" + prefix + "jobs` WHERE `userid` = ?;"); + prest.setInt(1, id); ResultSet res = prest.executeQuery(); while (res.next()) { - jobs.add(new JobsDAOData(player.getUniqueId(), res.getString(2), res.getInt(3), res.getInt(4))); + jobs.add(new JobsDAOData(uuid, res.getString(1), res.getInt(2), res.getInt(3))); } prest.close(); } catch (SQLException e) { @@ -152,6 +165,47 @@ public abstract class JobsDAO { return jobs; } + public int recordNewPlayer(Player player) { + return recordNewPlayer((OfflinePlayer) player); + } + + public int recordNewPlayer(OfflinePlayer player) { + return recordNewPlayer(player.getName(), player.getUniqueId()); + } + + public int recordNewPlayer(String playerName, UUID uuid) { + + int id = -1; + + JobsConnection conn = getConnection(); + if (conn == null) + return id; + try { + PreparedStatement prest = conn.prepareStatement("INSERT INTO `" + prefix + "users` (`player_uuid`, `username`) VALUES (?, ?);"); + prest.setString(1, uuid.toString()); + prest.setString(2, playerName); + prest.executeUpdate(); + prest.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + + try { + PreparedStatement prest = conn.prepareStatement("SELECT `id` FROM `" + prefix + "users` WHERE `player_uuid` = ?;"); + prest.setString(1, uuid.toString()); + ResultSet res = prest.executeQuery(); + res.next(); + id = res.getInt("id"); + Jobs.getPlayerManager().getPlayerMap().put(uuid.toString(), new PlayerInfo(playerName, id)); + res.close(); + prest.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + + return id; + } + /** * Get player count for a job. * @param JobName - the job name @@ -205,16 +259,22 @@ public abstract class JobsDAO { * @return list of all of the names of the jobs the players are part of. */ public synchronized List<JobsDAOData> getAllJobsOffline(String userName) { + ArrayList<JobsDAOData> jobs = new ArrayList<JobsDAOData>(); + + Entry<String, PlayerInfo> info = Jobs.getPlayerManager().getPlayerInfoByName(userName); + if (info == null) + return jobs; + JobsConnection conn = getConnection(); if (conn == null) return jobs; try { - PreparedStatement prest = conn.prepareStatement("SELECT `player_uuid`, `job`, `level`, `experience` FROM `" + prefix + "jobs` WHERE `username` LIKE ?;"); - prest.setString(1, userName); + PreparedStatement prest = conn.prepareStatement("SELECT `job`, `level`, `experience` FROM `" + prefix + "jobs` WHERE `userid` = ?;"); + prest.setInt(1, info.getValue().getID()); ResultSet res = prest.executeQuery(); while (res.next()) { - jobs.add(new JobsDAOData(UUIDUtil.fromBytes(res.getBytes(1)), res.getString(2), res.getInt(3), res.getInt(4))); + jobs.add(new JobsDAOData(UUID.fromString(info.getKey()), res.getString(2), res.getInt(3), res.getInt(4))); } prest.close(); res.close(); @@ -241,13 +301,11 @@ public abstract class JobsDAO { level = info.get(0); deleteArchive(jPlayer, job); } - PreparedStatement prest = conn.prepareStatement("INSERT INTO `" + prefix - + "jobs` (`player_uuid`, `username`, `job`, `level`, `experience`) VALUES (?, ?, ?, ?, ?);"); - prest.setString(1, jPlayer.getPlayerUUID().toString()); - prest.setString(2, jPlayer.getUserName()); - prest.setString(3, job.getName()); - prest.setInt(4, level); - prest.setInt(5, exp); + PreparedStatement prest = conn.prepareStatement("INSERT INTO `" + prefix + "jobs` (`userid`, `job`, `level`, `experience`) VALUES (?, ?, ?, ?);"); + prest.setInt(1, jPlayer.getUserId()); + prest.setString(2, job.getName()); + prest.setInt(3, level); + prest.setInt(4, exp); prest.execute(); prest.close(); } catch (SQLException e) { @@ -271,8 +329,7 @@ public abstract class JobsDAO { PreparedStatement prest = conn.prepareStatement("SELECT * FROM `" + prefix + table + "`"); ResultSet res = prest.executeQuery(); while (res.next()) { - list.add(new Convert(res.getInt("id"), res.getString("username"), UUIDUtil.fromBytes(res.getBytes("player_uuid")), res.getString("job"), res.getInt( - "level"), res.getInt("experience"))); + list.add(new Convert(res.getInt("id"), res.getInt("userid"), res.getString("job"), res.getInt("level"), res.getInt("experience"))); } res.close(); prest.close(); @@ -297,22 +354,21 @@ public abstract class JobsDAO { try { Statement statement = conns.createStatement(); - if (ConfigManager.getJobsConfiguration().storageMethod.equalsIgnoreCase("sqlite")) { + if (Jobs.getGCManager().storageMethod.equalsIgnoreCase("sqlite")) { statement.executeUpdate("TRUNCATE `" + getPrefix() + table + "`"); } else { statement.executeUpdate("DELETE from `" + getPrefix() + table + "`"); } - insert = conns.prepareStatement("INSERT INTO `" + getPrefix() + table + "` (`username`,`player_uuid`, `job`, `level`, `experience`) VALUES (?, ?, ?, ?, ?);"); + insert = conns.prepareStatement("INSERT INTO `" + getPrefix() + table + "` (`userid`, `job`, `level`, `experience`) VALUES (?, ?, ?, ?);"); conns.setAutoCommit(false); while (i > 0) { i--; Convert convertData = list.get(i); - insert.setString(1, convertData.GetName()); - insert.setString(2, convertData.GetUuid().toString()); - insert.setString(3, convertData.GetJobName()); - insert.setInt(4, convertData.GetLevel()); - insert.setInt(5, convertData.GetExp()); + insert.setInt(1, convertData.GetId()); + insert.setString(2, convertData.GetJobName()); + insert.setInt(3, convertData.GetLevel()); + insert.setInt(4, convertData.GetExp()); insert.addBatch(); } insert.executeBatch(); @@ -339,8 +395,8 @@ public abstract class JobsDAO { if (conn == null) return; try { - PreparedStatement prest = conn.prepareStatement("DELETE FROM `" + prefix + "jobs` WHERE `player_uuid` = ? AND `job` = ?;"); - prest.setString(1, jPlayer.getPlayerUUID().toString()); + PreparedStatement prest = conn.prepareStatement("DELETE FROM `" + prefix + "jobs` WHERE `userid` = ? AND `job` = ?;"); + prest.setInt(1, jPlayer.getUserId()); prest.setString(2, job.getName()); prest.execute(); prest.close(); @@ -368,12 +424,11 @@ public abstract class JobsDAO { } } PreparedStatement prest = conn.prepareStatement("INSERT INTO `" + prefix - + "archive` (`player_uuid`, `username`, `job`, `level`, `experience`) VALUES (?, ?, ?, ?, ?);"); - prest.setString(1, jPlayer.getPlayerUUID().toString()); - prest.setString(2, jPlayer.getUserName()); - prest.setString(3, job.getName()); - prest.setInt(4, level); - prest.setInt(5, exp); + + "archive` (`userid`, `job`, `level`, `experience`) VALUES (?, ?, ?, ?);"); + prest.setInt(1, jPlayer.getUserId()); + prest.setString(2, job.getName()); + prest.setInt(3, level); + prest.setInt(4, exp); prest.execute(); prest.close(); } catch (SQLException e) { @@ -388,16 +443,16 @@ public abstract class JobsDAO { */ public synchronized List<Integer> checkArchive(JobsPlayer jPlayer, Job job) { JobsConnection conn = getConnection(); + List<Integer> info = new ArrayList<Integer>(); if (conn == null) - return null; + return info; try { - List<Integer> info = new ArrayList<Integer>(); - PreparedStatement prest = conn.prepareStatement("SELECT `level`, `experience` FROM `" + prefix + "archive` WHERE `player_uuid` = ? AND `job` = ?;"); - prest.setString(1, jPlayer.getPlayerUUID().toString()); + PreparedStatement prest = conn.prepareStatement("SELECT `level`, `experience` FROM `" + prefix + "archive` WHERE `userid` = ? AND `job` = ?;"); + prest.setInt(1, jPlayer.getUserId()); prest.setString(2, job.getName()); ResultSet res = prest.executeQuery(); if (res.next()) { - int level = (int) ((res.getInt(1) - (res.getInt(1) * (ConfigManager.getJobsConfiguration().levelLossPercentage / 100.0)))); + int level = (int) ((res.getInt(1) - (res.getInt(1) * (Jobs.getGCManager().levelLossPercentage / 100.0)))); if (level < 1) level = 1; @@ -407,7 +462,7 @@ public abstract class JobsDAO { else maxLevel = job.getMaxLevel(); - if (ConfigManager.getJobsConfiguration().fixAtMaxLevel && res.getInt(1) == maxLevel) + if (Jobs.getGCManager().fixAtMaxLevel && res.getInt(1) == maxLevel) level = res.getInt(1); info.add(level); info.add(res.getInt(2)); @@ -418,7 +473,7 @@ public abstract class JobsDAO { } catch (SQLException e) { e.printStackTrace(); } - return null; + return info; } public List<TopList> getGlobalTopList() { @@ -439,16 +494,21 @@ public abstract class JobsDAO { return null; try { - PreparedStatement prest = conn.prepareStatement("SELECT username, player_uuid, COUNT(*) AS amount, sum(level) AS totallvl FROM `" + prefix - + "jobs` GROUP BY username ORDER BY totallvl DESC LIMIT " + start + ",20;"); + PreparedStatement prest = conn.prepareStatement("SELECT userid, COUNT(*) AS amount, sum(level) AS totallvl FROM `" + prefix + + "jobs` GROUP BY userid ORDER BY totallvl DESC LIMIT " + start + ",20;"); ResultSet res = prest.executeQuery(); while (res.next()) { - if (res.getString("username") == null) + Entry<String, PlayerInfo> info = Jobs.getPlayerManager().getPlayerInfoById(res.getInt(1)); + + if (info == null) continue; - TopList top = new TopList(res.getString("username"), res.getInt("totallvl"), 0, UUID.fromString(res.getString("player_uuid"))); + if (info.getValue().getName() == null) + continue; + + TopList top = new TopList(res.getInt("userid"), res.getInt("totallvl"), 0); names.add(top); } @@ -472,12 +532,12 @@ public abstract class JobsDAO { return null; try { List<String> info = new ArrayList<String>(); - PreparedStatement prest = conn.prepareStatement("SELECT `job`, `level`, `experience` FROM `" + prefix + "archive` WHERE `player_uuid` = ?;"); - prest.setString(1, jPlayer.getPlayerUUID().toString()); + PreparedStatement prest = conn.prepareStatement("SELECT `job`, `level`, `experience` FROM `" + prefix + "archive` WHERE `userid` = ?;"); + prest.setInt(1, jPlayer.getUserId()); ResultSet res = prest.executeQuery(); while (res.next()) { - int level = (int) ((res.getInt(2) - (res.getInt(2) * (ConfigManager.getJobsConfiguration().levelLossPercentage / 100.0)))); + int level = (int) ((res.getInt(2) - (res.getInt(2) * (Jobs.getGCManager().levelLossPercentage / 100.0)))); if (level < 1) level = 1; @@ -487,7 +547,7 @@ public abstract class JobsDAO { else maxLevel = Jobs.getJob(res.getString(1)).getMaxLevel(); - if (ConfigManager.getJobsConfiguration().fixAtMaxLevel && res.getInt(2) == maxLevel) + if (Jobs.getGCManager().fixAtMaxLevel && res.getInt(2) == maxLevel) level = res.getInt(2); info.add(res.getString(1) + ":" + res.getInt(2) + ":" + level + ":" + res.getInt(3)); @@ -501,100 +561,29 @@ public abstract class JobsDAO { return null; } - public void fixUuid(final CommandSender sender) { + public void loadPlayerData() { + Jobs.getPlayerManager().getPlayerMap().clear(); JobsConnection conn = getConnection(); if (conn == null) return; + PreparedStatement prest = null; try { - PreparedStatement prest = conn.prepareStatement("SELECT `player_uuid`, `username` FROM `" + prefix + "jobs`;"); + prest = conn.prepareStatement("SELECT * FROM `" + prefix + "users`;"); ResultSet res = prest.executeQuery(); - HashMap<String, String> convert = new HashMap<String, String>(); - int failed = 0; while (res.next()) { - - UUID uuid = OfflinePlayerList.getPlayer(res.getString("username")).getUniqueId(); - if (uuid == null) - continue; - - convert.put(uuid.toString(), res.getString("username")); + Jobs.getPlayerManager().getPlayerMap().put(res.getString("player_uuid"), new PlayerInfo(res.getString("username"), res.getInt("id"))); } res.close(); - prest.close(); - - prest = conn.prepareStatement("UPDATE `" + prefix + "jobs` SET `player_uuid` = ? WHERE `username` = ?;"); - - for (Entry<String, String> oneEntry : convert.entrySet()) { - prest.setString(1, oneEntry.getKey()); - prest.setString(2, oneEntry.getValue()); - prest.execute(); - } - if (prest != null) - prest.close(); - - sender.sendMessage(ChatColor.GOLD + "[Jobs] Converted " + ChatColor.YELLOW + convert.size() + ChatColor.GOLD + " user uuids and failed " - + ChatColor.YELLOW + failed + ChatColor.GOLD + " to do so, most likely user data no longer exists in your player data folder"); - return; } catch (SQLException e) { e.printStackTrace(); - } - - return; - } - - public void fixName(final CommandSender sender) { - JobsConnection conn = getConnection(); - if (conn == null) - return; - try { - PreparedStatement prest = conn.prepareStatement("SELECT `player_uuid`, `username` FROM `" + prefix + "jobs` WHERE `username` IS NULL;"); - ResultSet res = prest.executeQuery(); - HashMap<String, String> convert = new HashMap<String, String>(); - int failed = 0; - while (res.next()) { - - String uuidString = res.getString("player_uuid"); - if (uuidString == null) - continue; - - UUID uuid = UUID.fromString(uuidString); - if (uuid == null) - continue; - - OfflinePlayer player = OfflinePlayerList.getPlayer(uuid); - - if (player == null) - player = Bukkit.getOfflinePlayer(uuid); - - if (player == null) - continue; - - if (player.getName() == null) { - failed++; - continue; + } finally { + if (prest != null) + try { + prest.close(); + } catch (SQLException e) { + e.printStackTrace(); } - - convert.put(uuidString, player.getName()); - } - res.close(); - prest.close(); - - prest = conn.prepareStatement("UPDATE `" + prefix + "jobs` SET `username` = ? WHERE `player_uuid` = ?;"); - - for (Entry<String, String> oneEntry : convert.entrySet()) { - prest.setString(1, oneEntry.getValue()); - prest.setString(2, oneEntry.getKey()); - prest.execute(); - } - if (prest != null) - prest.close(); - - sender.sendMessage(ChatColor.GOLD + "[Jobs] Converted " + ChatColor.YELLOW + convert.size() + ChatColor.GOLD + " user names and failed " - + ChatColor.YELLOW + failed + ChatColor.GOLD + " to do so, most likely user data no longer exists in your player data folder"); - - return; - } catch (SQLException e) { - e.printStackTrace(); } return; } @@ -609,8 +598,8 @@ public abstract class JobsDAO { if (conn == null) return; try { - PreparedStatement prest = conn.prepareStatement("DELETE FROM `" + prefix + "archive` WHERE `player_uuid` = ? AND `job` = ?;"); - prest.setString(1, jPlayer.getPlayerUUID().toString()); + PreparedStatement prest = conn.prepareStatement("DELETE FROM `" + prefix + "archive` WHERE `userid` = ? AND `job` = ?;"); + prest.setInt(1, jPlayer.getUserId()); prest.setString(2, job.getName()); prest.execute(); prest.close(); @@ -623,19 +612,18 @@ public abstract class JobsDAO { * Save player-job information * @param jobInfo - the information getting saved */ - public synchronized void save(JobsPlayer player) { + public void save(JobsPlayer player) { JobsConnection conn = getConnection(); if (conn == null) return; try { PreparedStatement prest = conn.prepareStatement("UPDATE `" + prefix - + "jobs` SET `level` = ?, `experience` = ?, `username` = ? WHERE `player_uuid` = ? AND `job` = ?;"); + + "jobs` SET `level` = ?, `experience` = ? WHERE `userid` = ? AND `job` = ?;"); for (JobProgression progression : player.getJobProgression()) { prest.setInt(1, progression.getLevel()); prest.setInt(2, (int) progression.getExperience()); - prest.setString(3, player.getPlayer().getName()); - prest.setString(4, player.getPlayerUUID().toString()); - prest.setString(5, progression.getJob().getName()); + prest.setInt(3, player.getUserId()); + prest.setString(4, progression.getJob().getName()); prest.execute(); } prest.close(); @@ -644,6 +632,54 @@ public abstract class JobsDAO { } } + public void savePoints(JobsPlayer player) { + Debug.D("Saving points: " + player.getUserName()); + JobsConnection conn = getConnection(); + if (conn == null) + return; + try { + + PlayerPoints pointInfo = Jobs.getPlayerManager().getPointsData().getPlayerPointsInfo(player.getPlayerUUID()); + + String req = "UPDATE `" + prefix + "points` SET `totalpoints` = ?, `currentpoints` = ? WHERE `userid` = ?;"; + if (pointInfo.isNewEntry()) { + pointInfo.setNewEntry(false); + req = "INSERT INTO `" + prefix + "points` (`totalpoints`, `currentpoints`, `userid`) VALUES (?, ?, ?);"; + } + + PreparedStatement prest = conn.prepareStatement(req); + + prest.setDouble(1, pointInfo.getTotalPoints()); + prest.setDouble(2, pointInfo.getCurrentPoints()); + prest.setInt(3, player.getUserId()); + prest.execute(); + prest.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + public void loadPoints(JobsPlayer player) { + JobsConnection conn = getConnection(); + if (conn == null) + return; + try { + PreparedStatement prest = conn.prepareStatement("SELECT `totalpoints`, `currentpoints` FROM `" + prefix + "points` WHERE `userid` = ?;"); + prest.setInt(1, player.getUserId()); + ResultSet res = prest.executeQuery(); + + if (res.next()) { + Jobs.getPlayerManager().getPointsData().addPlayer(player.getPlayerUUID(), res.getDouble("currentpoints"), res.getDouble("totalpoints")); + } else { + Jobs.getPlayerManager().getPointsData().addPlayer(player.getPlayerUUID()); + } + res.close(); + prest.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + /** * Save player-job information * @param jobInfo - the information getting saved @@ -655,7 +691,7 @@ public abstract class JobsDAO { try { PreparedStatement prest = conn.prepareStatement("UPDATE `" + prefix - + "log` SET `count` = ?, `money` = ?, `exp` = ? WHERE `player_uuid` = ? AND `time` = ? AND `action` = ? AND `itemname` = ?;"); + + "log` SET `count` = ?, `money` = ?, `exp` = ? WHERE `userid` = ? AND `time` = ? AND `action` = ? AND `itemname` = ?;"); for (Log log : player.getLog()) { for (Entry<String, LogAmounts> one : log.getAmountList().entrySet()) { if (one.getValue().isNewEntry()) @@ -665,7 +701,7 @@ public abstract class JobsDAO { prest.setDouble(2, one.getValue().getMoney()); prest.setDouble(3, one.getValue().getExp()); - prest.setString(4, player.getPlayerUUID().toString()); + prest.setInt(4, player.getUserId()); prest.setInt(5, log.getDate()); prest.setString(6, log.getActionType()); prest.setString(7, one.getKey()); @@ -673,7 +709,7 @@ public abstract class JobsDAO { } } prest = conn.prepareStatement("INSERT INTO `" + prefix - + "log` (`player_uuid`, `username`, `time`, `action`, `itemname`, `count`, `money`, `exp`) VALUES (?, ?, ?, ?, ?, ?, ?, ?);"); + + "log` (`userid`, `time`, `action`, `itemname`, `count`, `money`, `exp`) VALUES (?, ?, ?, ?, ?, ?, ?);"); for (Log log : player.getLog()) { for (Entry<String, LogAmounts> one : log.getAmountList().entrySet()) { @@ -682,14 +718,13 @@ public abstract class JobsDAO { one.getValue().setNewEntry(false); - prest.setString(1, player.getPlayerUUID().toString()); - prest.setString(2, player.getUserName()); - prest.setInt(3, log.getDate()); - prest.setString(4, log.getActionType()); - prest.setString(5, one.getKey()); - prest.setInt(6, one.getValue().getCount()); - prest.setDouble(7, one.getValue().getMoney()); - prest.setDouble(8, one.getValue().getExp()); + prest.setInt(1, player.getUserId()); + prest.setInt(2, log.getDate()); + prest.setString(3, log.getActionType()); + prest.setString(4, one.getKey()); + prest.setInt(5, one.getValue().getCount()); + prest.setDouble(6, one.getValue().getMoney()); + prest.setDouble(7, one.getValue().getExp()); prest.execute(); } } @@ -711,9 +746,8 @@ public abstract class JobsDAO { int time = TimeManage.timeInInt(); - PreparedStatement prest = conn.prepareStatement("SELECT `player_uuid`, `username`, `time`, `action`, `itemname`, `count`, `money`, `exp` FROM `" + prefix - + "log` WHERE `player_uuid` = ? AND `time` = ? ;"); - prest.setString(1, player.getPlayerUUID().toString()); + PreparedStatement prest = conn.prepareStatement("SELECT * FROM `" + prefix + "log` WHERE `userid` = ? AND `time` = ? ;"); + prest.setInt(1, player.getUserId()); prest.setInt(2, time); ResultSet res = prest.executeQuery(); while (res.next()) { @@ -734,15 +768,13 @@ public abstract class JobsDAO { if (!Jobs.getExplore().isExploreEnabled()) return; - Debug.D("Starting explorer save"); - JobsConnection conn = getConnection(); if (conn == null) return; try { PreparedStatement prest = null; - if (ConfigManager.getJobsConfiguration().storageMethod.equalsIgnoreCase("sqlite")) { + if (Jobs.getGCManager().storageMethod.equalsIgnoreCase("sqlite")) { prest = conn.prepareStatement("DELETE from `" + prefix + "explore`;"); } else prest = conn.prepareStatement("TRUNCATE TABLE `" + prefix + "explore`;"); @@ -770,7 +802,6 @@ public abstract class JobsDAO { } catch (SQLException e) { e.printStackTrace(); } - Debug.D("Explorer saved"); } /** @@ -803,21 +834,20 @@ public abstract class JobsDAO { * @param jobInfo - the information getting saved * @return */ - public List<String> getLognameList(int fromtime, int untiltime) { + public List<Integer> getLognameList(int fromtime, int untiltime) { JobsConnection conn = getConnection(); + List<Integer> nameList = new ArrayList<Integer>(); if (conn == null) - return null; + return nameList; try { - List<String> nameList = new ArrayList<String>(); - PreparedStatement prest = conn.prepareStatement("SELECT `username` FROM `" + prefix - + "log` WHERE `time` >= ? AND `time` <= ? ;"); + PreparedStatement prest = conn.prepareStatement("SELECT `userid` FROM `" + prefix + "log` WHERE `time` >= ? AND `time` <= ? ;"); prest.setInt(1, fromtime); prest.setInt(2, untiltime); ResultSet res = prest.executeQuery(); while (res.next()) { - if (!nameList.contains(res.getString("username"))) - nameList.add(res.getString("username")); + if (!nameList.contains(res.getInt("userid"))) + nameList.add(res.getInt("userid")); } res.close(); prest.close(); @@ -825,7 +855,7 @@ public abstract class JobsDAO { } catch (SQLException e) { e.printStackTrace(); } - return null; + return nameList; } /** @@ -839,21 +869,22 @@ public abstract class JobsDAO { if (conn == null) return jobs; try { - PreparedStatement prest = conn.prepareStatement("SELECT `username`, `level`, `experience`,`player_uuid` FROM `" + prefix - + "jobs` WHERE `job` LIKE ? ORDER BY `level` DESC, LOWER(username) ASC LIMIT " + limit + ", 15;"); + PreparedStatement prest = conn.prepareStatement("SELECT `userid`, `level`, `experience` FROM `" + prefix + + "jobs` WHERE `job` LIKE ? ORDER BY `level` DESC, LOWER(userid) ASC LIMIT " + limit + ", 15;"); prest.setString(1, jobsname); ResultSet res = prest.executeQuery(); - Debug.D("her2e"); while (res.next()) { - Debug.D("here"); + Entry<String, PlayerInfo> info = Jobs.getPlayerManager().getPlayerInfoById(res.getInt(1)); - String name = res.getString(1); - - if (name == null) + if (info == null) continue; + if (info.getValue().getName() == null) + continue; + + String name = info.getValue().getName(); Player player = Bukkit.getPlayer(name); if (player != null) { @@ -861,10 +892,10 @@ public abstract class JobsDAO { Job job = Jobs.getJob(jobsname); if (job != null) { JobProgression prog = jobsinfo.getJobProgression(job); - jobs.add(new TopList(player.getName(), prog.getLevel(), (int) prog.getExperience(), player.getUniqueId())); + jobs.add(new TopList(jobsinfo.getUserId(), prog.getLevel(), (int) prog.getExperience())); } } else - jobs.add(new TopList(res.getString(1), res.getInt(2), res.getInt(3), UUID.fromString(res.getString(4)))); + jobs.add(new TopList(res.getInt(1), res.getInt(2), res.getInt(3))); } res.close(); prest.close(); diff --git a/com/gamingmesh/jobs/dao/JobsDAOMySQL.java b/com/gamingmesh/jobs/dao/JobsDAOMySQL.java index 5a149491..27f6d56a 100644 --- a/com/gamingmesh/jobs/dao/JobsDAOMySQL.java +++ b/com/gamingmesh/jobs/dao/JobsDAOMySQL.java @@ -22,12 +22,14 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; +import java.util.HashMap; +import java.util.UUID; +import java.util.Map.Entry; +import org.bukkit.Bukkit; import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.container.PlayerInfo; import com.gamingmesh.jobs.stuff.ChatColor; -import com.gamingmesh.jobs.stuff.OfflinePlayerList; import com.gamingmesh.jobs.stuff.UUIDUtil; public class JobsDAOMySQL extends JobsDAO { @@ -186,11 +188,11 @@ public class JobsDAOMySQL extends JobsDAO { i = 0; } - OfflinePlayer offPlayer = OfflinePlayerList.getPlayer(names); - if (offPlayer == null) + Entry<String, PlayerInfo> info = Jobs.getPlayerManager().getPlayerInfoByName(names); + if (info == null) continue; - pst2.setBytes(1, UUIDUtil.toBytes(offPlayer.getUniqueId())); + pst2.setBytes(1, UUIDUtil.toBytes(UUID.fromString(info.getKey()))); pst2.setString(2, names); pst2.execute(); } @@ -471,4 +473,171 @@ public class JobsDAOMySQL extends JobsDAO { } finally { } } + + @Override + protected synchronized void checkUpdate9() throws SQLException { + JobsConnection conn = getConnection(); + if (conn == null) { + Jobs.getPluginLogger().severe("Could not run database updates! Could not connect to MySQL!"); + return; + } + + HashMap<String, String> tempMap = new HashMap<String, String>(); + PreparedStatement prest = null; + try { + prest = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "jobs;"); + ResultSet res = prest.executeQuery(); + while (res.next()) { + tempMap.put(res.getString("player_uuid"), res.getString("username")); + } + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + + try { + prest = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "archive;"); + ResultSet res = prest.executeQuery(); + while (res.next()) { + tempMap.put(res.getString("player_uuid"), res.getString("username")); + } + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + + try { + prest = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "log;"); + ResultSet res = prest.executeQuery(); + while (res.next()) { + tempMap.put(res.getString("player_uuid"), res.getString("username")); + } + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + + executeSQL("CREATE TABLE `" + getPrefix() + "users` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `player_uuid` varchar(36) NOT NULL, `username` varchar(20));"); + try { + prest = conn.prepareStatement("INSERT INTO `" + getPrefix() + "users` (`player_uuid`, `username`) VALUES (?, ?);"); + conn.setAutoCommit(false); + for (Entry<String, String> users : tempMap.entrySet()) { + prest.setString(1, users.getKey()); + prest.setString(2, users.getValue()); + prest.addBatch(); + } + prest.executeBatch(); + conn.commit(); + conn.setAutoCommit(true); + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + + HashMap<String, PlayerInfo> tempPlayerMap = new HashMap<String, PlayerInfo>(); + + try { + prest = conn.prepareStatement("SELECT * FROM " + getPrefix() + "users;"); + ResultSet res = prest.executeQuery(); + while (res.next()) { + tempPlayerMap.put(res.getString("player_uuid"), new PlayerInfo(res.getString("username"), res.getInt("id"))); + } + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + + // Modifying jobs main table + executeSQL("ALTER TABLE `" + getPrefix() + "jobs` ADD COLUMN `userid` int;"); + try { + prest = conn.prepareStatement("UPDATE `" + getPrefix() + "jobs` SET `userid` = ? WHERE `player_uuid` = ?;"); + conn.setAutoCommit(false); + for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) { + prest.setInt(1, users.getValue().getID()); + prest.setString(2, users.getKey()); + prest.addBatch(); + } + prest.executeBatch(); + conn.commit(); + conn.setAutoCommit(true); + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + executeSQL("ALTER TABLE `" + getPrefix() + "jobs` DROP COLUMN `player_uuid`, DROP COLUMN `username`;"); + + // Modifying jobs archive table + executeSQL("ALTER TABLE `" + getPrefix() + "archive` ADD COLUMN `userid` int;"); + try { + prest = conn.prepareStatement("UPDATE `" + getPrefix() + "archive` SET `userid` = ? WHERE `player_uuid` = ?;"); + conn.setAutoCommit(false); + for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) { + prest.setInt(1, users.getValue().getID()); + prest.setString(2, users.getKey()); + prest.addBatch(); + } + prest.executeBatch(); + conn.commit(); + conn.setAutoCommit(true); + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + executeSQL("ALTER TABLE `" + getPrefix() + "archive` DROP COLUMN `player_uuid`, DROP COLUMN `username`;"); + + // Modifying jobs log table + executeSQL("ALTER TABLE `" + getPrefix() + "log` ADD COLUMN `userid` int;"); + try { + prest = conn.prepareStatement("UPDATE `" + getPrefix() + "log` SET `userid` = ? WHERE `player_uuid` = ?;"); + conn.setAutoCommit(false); + for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) { + prest.setInt(1, users.getValue().getID()); + prest.setString(2, users.getKey()); + prest.addBatch(); + } + prest.executeBatch(); + conn.commit(); + conn.setAutoCommit(true); + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + executeSQL("ALTER TABLE `" + getPrefix() + "log` DROP COLUMN `player_uuid`, DROP COLUMN `username`;"); + + // Create new points table + executeSQL("CREATE TABLE `" + getPrefix() + + "points` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `userid` int, `totalpoints` double, `currentpoints` double);"); + } } diff --git a/com/gamingmesh/jobs/dao/JobsDAOSQLite.java b/com/gamingmesh/jobs/dao/JobsDAOSQLite.java index 9d31d19b..59edc0ad 100644 --- a/com/gamingmesh/jobs/dao/JobsDAOSQLite.java +++ b/com/gamingmesh/jobs/dao/JobsDAOSQLite.java @@ -23,12 +23,14 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; +import java.util.HashMap; +import java.util.UUID; +import java.util.Map.Entry; +import org.bukkit.Bukkit; import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.container.PlayerInfo; import com.gamingmesh.jobs.stuff.ChatColor; -import com.gamingmesh.jobs.stuff.OfflinePlayerList; import com.gamingmesh.jobs.stuff.UUIDUtil; public class JobsDAOSQLite extends JobsDAO { @@ -152,11 +154,11 @@ public class JobsDAOSQLite extends JobsDAO { i = 0; } - OfflinePlayer offPlayer = OfflinePlayerList.getPlayer(names); - if (offPlayer == null) + Entry<String, PlayerInfo> info = Jobs.getPlayerManager().getPlayerInfoByName(names); + if (info == null) continue; - pst2.setBytes(1, UUIDUtil.toBytes(offPlayer.getUniqueId())); + pst2.setBytes(1, UUIDUtil.toBytes(UUID.fromString(info.getKey()))); pst2.setString(2, names); pst2.execute(); } @@ -448,4 +450,246 @@ public class JobsDAOSQLite extends JobsDAO { } finally { } } + + @Override + protected synchronized void checkUpdate9() throws SQLException { + JobsConnection conn = getConnection(); + if (conn == null) { + Jobs.getPluginLogger().severe("Could not run database updates! Could not connect to SQLite!"); + return; + } + + HashMap<String, String> tempMap = new HashMap<String, String>(); + PreparedStatement prest = null; + try { + prest = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "jobs;"); + ResultSet res = prest.executeQuery(); + while (res.next()) { + tempMap.put(res.getString("player_uuid"), res.getString("username")); + } + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + + try { + prest = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "archive;"); + ResultSet res = prest.executeQuery(); + while (res.next()) { + tempMap.put(res.getString("player_uuid"), res.getString("username")); + } + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + + try { + prest = conn.prepareStatement("SELECT DISTINCT(player_uuid),username FROM " + getPrefix() + "log;"); + ResultSet res = prest.executeQuery(); + while (res.next()) { + tempMap.put(res.getString("player_uuid"), res.getString("username")); + } + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + + executeSQL("CREATE TABLE `" + getPrefix() + "users` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_uuid` varchar(36) NOT NULL, `username` varchar(20));"); + try { + prest = conn.prepareStatement("INSERT INTO `" + getPrefix() + "users` (`player_uuid`, `username`) VALUES (?, ?);"); + conn.setAutoCommit(false); + for (Entry<String, String> users : tempMap.entrySet()) { + prest.setString(1, users.getKey()); + prest.setString(2, users.getValue()); + prest.addBatch(); + } + prest.executeBatch(); + conn.commit(); + conn.setAutoCommit(true); + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + + HashMap<String, PlayerInfo> tempPlayerMap = new HashMap<String, PlayerInfo>(); + + try { + prest = conn.prepareStatement("SELECT * FROM " + getPrefix() + "users;"); + ResultSet res = prest.executeQuery(); + while (res.next()) { + tempPlayerMap.put(res.getString("player_uuid"), new PlayerInfo(res.getString("username"), res.getInt("id"))); + } + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + + // Modifying jobs main table + executeSQL("ALTER TABLE `" + getPrefix() + "jobs` ADD COLUMN `userid` int;"); + try { + prest = conn.prepareStatement("UPDATE `" + getPrefix() + "jobs` SET `userid` = ? WHERE `player_uuid` = ?;"); + conn.setAutoCommit(false); + for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) { + prest.setInt(1, users.getValue().getID()); + prest.setString(2, users.getKey()); + prest.addBatch(); + } + prest.executeBatch(); + conn.commit(); + conn.setAutoCommit(true); + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + + // dropping 2 columns + executeSQL("CREATE TABLE `" + getPrefix() + + "jobs_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `job` varchar(20), `experience` int, `level` int);"); + + PreparedStatement pst111 = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "jobs`;"); + ResultSet rs11 = pst111.executeQuery(); + PreparedStatement insert11 = null; + while (rs11.next()) { + + String uuid = UUIDUtil.fromBytes(rs11.getBytes("player_uuid")).toString(); + + if (uuid != null) { + insert11 = conn.prepareStatement("INSERT INTO `" + getPrefix() + "jobs_temp` (`userid`, `job`, `experience`, `level`) VALUES (?, ?, ?, ?);"); + insert11.setInt(1, rs11.getInt("userid")); + insert11.setString(2, rs11.getString("job")); + insert11.setInt(3, rs11.getInt("experience")); + insert11.setInt(4, rs11.getInt("level")); + insert11.execute(); + } + } + rs11.close(); + if (insert11 != null) + insert11.close(); + + executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "jobs`;"); + executeSQL("ALTER TABLE `" + getPrefix() + "jobs_temp` RENAME TO `" + getPrefix() + "jobs`;"); + + // Modifying jobs archive table + executeSQL("ALTER TABLE `" + getPrefix() + "archive` ADD COLUMN `userid` int;"); + try { + prest = conn.prepareStatement("UPDATE `" + getPrefix() + "archive` SET `userid` = ? WHERE `player_uuid` = ?;"); + conn.setAutoCommit(false); + for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) { + prest.setInt(1, users.getValue().getID()); + prest.setString(2, users.getKey()); + prest.addBatch(); + } + prest.executeBatch(); + conn.commit(); + conn.setAutoCommit(true); + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + + // dropping 2 columns + executeSQL("CREATE TABLE `" + getPrefix() + + "archive_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `job` varchar(20), `experience` int, `level` int);"); + + PreparedStatement pst = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "archive`;"); + ResultSet rs = pst.executeQuery(); + PreparedStatement insert = null; + while (rs.next()) { + String uuid = UUIDUtil.fromBytes(rs.getBytes("player_uuid")).toString(); + if (uuid != null) { + insert = conn.prepareStatement("INSERT INTO `" + getPrefix() + "archive_temp` (`userid`, `job`, `experience`, `level`) VALUES (?, ?, ?, ?);"); + insert.setInt(1, rs.getInt("userid")); + insert.setString(2, rs.getString("job")); + insert.setInt(3, rs.getInt("experience")); + insert.setInt(4, rs.getInt("level")); + insert.execute(); + } + } + + executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "archive`;"); + executeSQL("ALTER TABLE `" + getPrefix() + "archive_temp` RENAME TO `" + getPrefix() + "archive`;"); + + // Modifying jobs log table + executeSQL("ALTER TABLE `" + getPrefix() + "log` ADD COLUMN `userid` int;"); + try { + prest = conn.prepareStatement("UPDATE `" + getPrefix() + "log` SET `userid` = ? WHERE `player_uuid` = ?;"); + conn.setAutoCommit(false); + for (Entry<String, PlayerInfo> users : tempPlayerMap.entrySet()) { + prest.setInt(1, users.getValue().getID()); + prest.setString(2, users.getKey()); + prest.addBatch(); + } + prest.executeBatch(); + conn.commit(); + conn.setAutoCommit(true); + } finally { + if (prest != null) { + try { + prest.close(); + } catch (SQLException e) { + } + } + } + + // dropping 2 columns + executeSQL("CREATE TABLE `" + getPrefix() + + "log_temp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `time` bigint, `action` varchar(20), `itemname` varchar(60), `count` int, `money` double, `exp` double);"); + + pst = conn.prepareStatement("SELECT * FROM `" + getPrefix() + "log`;"); + rs = pst.executeQuery(); + insert = null; + while (rs.next()) { + String uuid = UUIDUtil.fromBytes(rs.getBytes("player_uuid")).toString(); + if (uuid != null) { + insert = conn.prepareStatement("INSERT INTO `" + getPrefix() + + "log_temp` (`userid`, `time`, `action`, `itemname`, `count`, `money`, `exp`) VALUES (?, ?, ?, ?, ?, ?, ?);"); + insert.setInt(1, rs.getInt("userid")); + insert.setLong(2, rs.getLong("time")); + insert.setString(3, rs.getString("action")); + insert.setString(4, rs.getString("itemname")); + insert.setInt(5, rs.getInt("count")); + insert.setDouble(6, rs.getDouble("money")); + insert.setDouble(7, rs.getDouble("exp")); + insert.execute(); + } + } + rs.close(); + if (insert != null) + insert.close(); + + executeSQL("DROP TABLE IF EXISTS `" + getPrefix() + "log`;"); + executeSQL("ALTER TABLE `" + getPrefix() + "log_temp` RENAME TO `" + getPrefix() + "log`;"); + + // Create new points table + executeSQL("CREATE TABLE `" + getPrefix() + + "points` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `totalpoints` double, `currentpoints` double);"); + } } diff --git a/com/gamingmesh/jobs/economy/.gitignore b/com/gamingmesh/jobs/economy/.gitignore index a1f1b23c..80ea2039 100644 --- a/com/gamingmesh/jobs/economy/.gitignore +++ b/com/gamingmesh/jobs/economy/.gitignore @@ -4,3 +4,4 @@ /Economy.class /VaultEconomy.class /PaymentData.class +/PointsData.class diff --git a/com/gamingmesh/jobs/economy/BufferedEconomy.java b/com/gamingmesh/jobs/economy/BufferedEconomy.java index 405974f8..9950ce4a 100644 --- a/com/gamingmesh/jobs/economy/BufferedEconomy.java +++ b/com/gamingmesh/jobs/economy/BufferedEconomy.java @@ -29,12 +29,8 @@ import org.bukkit.OfflinePlayer; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.api.JobsPaymentEvent; -import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.container.JobsPlayer; -import com.gamingmesh.jobs.i18n.Language; -import com.gamingmesh.jobs.stuff.ActionBar; import com.gamingmesh.jobs.stuff.ChatColor; -import com.gamingmesh.jobs.stuff.OfflinePlayerList; import com.gamingmesh.jobs.tasks.BufferedPaymentTask; public class BufferedEconomy { @@ -58,10 +54,10 @@ public class BufferedEconomy { * @param player - player to be paid * @param amount - amount to be paid */ - public void pay(JobsPlayer player, double amount, double exp) { - if (amount == 0) + public void pay(JobsPlayer player, double amount, double points, double exp) { + if (amount == 0 && points == 0) return; - pay(new BufferedPayment(player.getPlayer(), amount, exp)); + pay(new BufferedPayment(player.getPlayer(), amount, points, exp)); } /** @@ -79,6 +75,7 @@ public class BufferedEconomy { /** * Payout all players the amount they are going to be paid */ + @SuppressWarnings("deprecation") public void payAll() { if (payments.isEmpty()) return; @@ -86,15 +83,19 @@ public class BufferedEconomy { synchronized (paymentCache) { Double TotalAmount = 0.0; + Double TotalPoints = 0.0; Double TaxesAmount = 0.0; + Double TaxesPoints = 0.0; // combine all payments using paymentCache while (!payments.isEmpty()) { BufferedPayment payment = payments.remove(); TotalAmount += payment.getAmount(); + TotalPoints += payment.getPoints(); - if (ConfigManager.getJobsConfiguration().UseTaxes) { - TaxesAmount += payment.getAmount() * (ConfigManager.getJobsConfiguration().TaxesAmount / 100.0); + if (Jobs.getGCManager().UseTaxes) { + TaxesAmount += payment.getAmount() * (Jobs.getGCManager().TaxesAmount / 100.0); + TaxesPoints += payment.getPoints() * (Jobs.getGCManager().TaxesAmount / 100.0); } UUID uuid = payment.getOfflinePlayer().getUniqueId(); @@ -102,20 +103,25 @@ public class BufferedEconomy { BufferedPayment existing = paymentCache.get(uuid); double money = payment.getAmount(); + double points = payment.getPoints(); double exp = payment.getExp(); - if (ConfigManager.getJobsConfiguration().TakeFromPlayersPayment) { - money = money - (money * (ConfigManager.getJobsConfiguration().TaxesAmount / 100.0)); + if (Jobs.getGCManager().TakeFromPlayersPayment && Jobs.getGCManager().UseTaxes) { + money = money - (money * (Jobs.getGCManager().TaxesAmount / 100.0)); + points = points - (points * (Jobs.getGCManager().TaxesAmount / 100.0)); } existing.setAmount(existing.getAmount() + money); + existing.setPoints(existing.getPoints() + points); existing.setExp(existing.getExp() + exp); } else { double money = payment.getAmount(); + double points = payment.getPoints(); - if (ConfigManager.getJobsConfiguration().TakeFromPlayersPayment) { - payment.setAmount(money - (money * (ConfigManager.getJobsConfiguration().TaxesAmount / 100.0))); + if (Jobs.getGCManager().TakeFromPlayersPayment && Jobs.getGCManager().UseTaxes) { + payment.setAmount(money - (money * (Jobs.getGCManager().TaxesAmount / 100.0))); + payment.setPoints(points - (points * (Jobs.getGCManager().TaxesAmount / 100.0))); } paymentCache.put(uuid, payment); @@ -123,29 +129,29 @@ public class BufferedEconomy { } boolean hasMoney = false; - String ServerAccountname = ConfigManager.getJobsConfiguration().ServerAcountName; - String ServerTaxesAccountname = ConfigManager.getJobsConfiguration().ServertaxesAcountName; + String ServerAccountname = Jobs.getGCManager().ServerAcountName; + String ServerTaxesAccountname = Jobs.getGCManager().ServertaxesAcountName; if (this.ServerAccount == null) - this.ServerAccount = OfflinePlayerList.getPlayer(ServerAccountname); + this.ServerAccount = Bukkit.getOfflinePlayer(ServerAccountname); if (this.ServerTaxesAccount == null) - this.ServerTaxesAccount = OfflinePlayerList.getPlayer(ServerAccountname); + this.ServerTaxesAccount = Bukkit.getOfflinePlayer(ServerAccountname); - if (ConfigManager.getJobsConfiguration().UseTaxes && ConfigManager.getJobsConfiguration().TransferToServerAccount && ServerTaxesAccount != null) { + if (Jobs.getGCManager().UseTaxes && Jobs.getGCManager().TransferToServerAccount && ServerTaxesAccount != null) { economy.depositPlayer(ServerTaxesAccount, TaxesAmount); if (ServerTaxesAccount.isOnline()) { - if (!Jobs.actionbartoggle.containsKey(ServerTaxesAccountname) && ConfigManager.getJobsConfiguration().JobsToggleEnabled) - Jobs.actionbartoggle.put(ServerTaxesAccountname, true); - if (Jobs.actionbartoggle.containsKey(ServerTaxesAccountname) && Jobs.actionbartoggle.get(ServerTaxesAccountname)) { - ActionBar.send(Bukkit.getPlayer(ServerAccountname), Language.getMessage("message.taxes").replace("[amount]", String.valueOf((int) (TotalAmount - * 100) / 100.0))); + if (!Jobs.getActionbarToggleList().containsKey(ServerTaxesAccountname) && Jobs.getGCManager().ActionBarsMessageByDefault) + Jobs.getActionbarToggleList().put(ServerTaxesAccountname, true); + if (Jobs.getActionbarToggleList().containsKey(ServerTaxesAccountname) && Jobs.getActionbarToggleList().get(ServerTaxesAccountname)) { + Jobs.getActionBar().send(Bukkit.getPlayer(ServerAccountname), Jobs.getLanguage().getMessage("message.taxes", "[amount]", (int) (TotalAmount * 100) + / 100.0)); } } } - if (ConfigManager.getJobsConfiguration().UseServerAccount) { + if (Jobs.getGCManager().UseServerAccount) { if (economy.hasMoney(ServerAccountname, TotalAmount)) { hasMoney = true; economy.withdrawPlayer(ServerAccountname, TotalAmount); @@ -157,37 +163,37 @@ public class BufferedEconomy { for (BufferedPayment payment : paymentCache.values()) { i++; - // JobsJoin event - JobsPaymentEvent JobsPaymentEvent = new JobsPaymentEvent(payment.getOfflinePlayer(), payment.getAmount()); + // JobsPayment event + JobsPaymentEvent JobsPaymentEvent = new JobsPaymentEvent(payment.getOfflinePlayer(), payment.getAmount(), payment.getPoints()); Bukkit.getServer().getPluginManager().callEvent(JobsPaymentEvent); // If event is canceled, dont do anything if (JobsPaymentEvent.isCancelled()) continue; - if (ConfigManager.getJobsConfiguration().isEconomyAsync()) { - if (ConfigManager.getJobsConfiguration().UseServerAccount) { - if (!hasMoney) { - ActionBar.send(payment.getOfflinePlayer().getPlayer(), ChatColor.RED + Language.getMessage("economy.error.nomoney")); - continue; - } else + if (Jobs.getGCManager().UseServerAccount) { + if (!hasMoney) { + Jobs.getActionBar().send(payment.getOfflinePlayer().getPlayer(), ChatColor.RED + Jobs.getLanguage().getMessage("economy.error.nomoney")); + continue; + } else { + if (Jobs.getGCManager().isEconomyAsync()) Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new BufferedPaymentTask(this, economy, payment), i); - } else - Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new BufferedPaymentTask(this, economy, payment), i); - - // Action bar stuff - ActionBar.ShowActionBar(payment); - } else { - if (ConfigManager.getJobsConfiguration().UseServerAccount) { - if (!hasMoney) { - ActionBar.send(payment.getOfflinePlayer().getPlayer(), ChatColor.RED + Language.getMessage("economy.error.nomoney")); - continue; - } else + else Bukkit.getScheduler().runTaskLater(plugin, new BufferedPaymentTask(this, economy, payment), i); - } else - Bukkit.getScheduler().runTaskLater(plugin, new BufferedPaymentTask(this, economy, payment), i); + } + } else { + if (Jobs.getGCManager().isEconomyAsync()) + Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new BufferedPaymentTask(this, economy, payment), i); + else - // Action bar stuff - ActionBar.ShowActionBar(payment); + Bukkit.getScheduler().runTaskLater(plugin, new BufferedPaymentTask(this, economy, payment), i); + } + + // Action bar stuff + Jobs.getActionBar().ShowActionBar(payment); + + if (payment.getOfflinePlayer().isOnline()) { + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(payment.getOfflinePlayer().getName()); + Jobs.getBBManager().ShowJobProgression(jPlayer); } } // empty payment cache diff --git a/com/gamingmesh/jobs/economy/BufferedPayment.java b/com/gamingmesh/jobs/economy/BufferedPayment.java index 6efa59d1..f1fd30f2 100644 --- a/com/gamingmesh/jobs/economy/BufferedPayment.java +++ b/com/gamingmesh/jobs/economy/BufferedPayment.java @@ -22,32 +22,42 @@ import org.bukkit.OfflinePlayer; public class BufferedPayment { private OfflinePlayer offlinePlayer; - private double amount= 0.0; + private double amount = 0.0; + private double points = 0.0; private double exp = 0.0; - - public BufferedPayment(OfflinePlayer offlinePlayer, double amount, double exp) { - this.offlinePlayer = offlinePlayer; - this.amount = amount; - this.exp = exp; + + public BufferedPayment(OfflinePlayer offlinePlayer, double amount, double points, double exp) { + this.offlinePlayer = offlinePlayer; + this.amount = amount; + this.points = points; + this.exp = exp; } - + public OfflinePlayer getOfflinePlayer() { - return offlinePlayer; + return offlinePlayer; } - + public double getAmount() { - return amount; + return amount; } + public double getPoints() { + return points; + } + public double getExp() { - return exp; + return exp; + } + + public void setAmount(double amount) { + this.amount = amount; } - public void setAmount(double amount) { - this.amount = amount; + public void setPoints(double amount) { + this.points = amount; } public void setExp(double exp) { - this.exp = exp; + this.exp = exp; } } diff --git a/com/gamingmesh/jobs/economy/PaymentData.java b/com/gamingmesh/jobs/economy/PaymentData.java index 5ab81f4f..b09e59a5 100644 --- a/com/gamingmesh/jobs/economy/PaymentData.java +++ b/com/gamingmesh/jobs/economy/PaymentData.java @@ -1,171 +1,208 @@ -package com.gamingmesh.jobs.economy; - -public class PaymentData { - - Long time = 0L; - Long lastAnnouced = 0L; - Double Payment = 0.0; - Double Exp = 0.0; - public boolean Informed = false; - public boolean Reseted = false; - - public PaymentData(Long time, Double Payment, Double Exp, Long lastAnnouced, boolean Informed) { - this.time = time; - this.Payment = Payment; - this.Exp = Exp; - this.lastAnnouced = lastAnnouced; - this.Informed = Informed; - } - - public PaymentData() { - } - - public Long GetTime() { - return this.time; - } - - public void setReseted(boolean state) { - this.Reseted = state; - } - - public boolean isReseted() { - return this.Reseted; - } - - public Double GetAmount() { - return this.Payment; - } - - public Double GetAmountBylimit(int limit) { - if (this.Payment > limit) - return (double) limit; - return (int) (this.Payment * 100) / 100.0; - } - - public Double GetExpBylimit(int limit) { - if (this.Exp > limit) - return (double) limit; - return (int) (this.Exp * 100) / 100.0; - } - - public Long GetLastAnnounced() { - return this.lastAnnouced; - } - - public boolean IsAnnounceTime(int time) { - if (this.lastAnnouced + (time * 1000) > System.currentTimeMillis()) - return false; - SetAnnouncmentTime(); - return true; - } - - public void SetAnnouncmentTime() { - this.lastAnnouced = System.currentTimeMillis(); - } - - public void AddNewAmount(Double Payment) { - this.time = System.currentTimeMillis(); - this.Payment = Payment; - } - - public void Setinformed() { - this.Informed = true; - } - - public void SetNotInformed() { - this.Informed = false; - } - - public void AddAmount(Double Payment) { - this.Payment = this.Payment + Payment; - } - public void AddExpAmount(Double Exp) { - this.Exp = this.Exp + Exp; - } - - public int GetLeftTime(int time) { - int left = 0; - if (this.time + (time * 1000) > System.currentTimeMillis()) - left = (int) ((this.time + (time * 1000) - System.currentTimeMillis()) / 1000); - return left; - } - - public boolean IsOverMoneyLimit(int limit) { - if (this.Payment < limit) - return false; - return true; - } - - public boolean IsOverExpLimit(int limit) { - if (this.Exp < limit) - return false; - return true; - } - - public boolean IsOverTimeLimit(int time) { - if (this.time + (time * 1000) > System.currentTimeMillis()) - return false; - - if (this.Informed) - this.Informed = false; - - this.time = System.currentTimeMillis(); - this.Payment = 0.0; - this.Exp = 0.0; - this.Reseted = true; - return true; - } - - public boolean IsReachedMoneyLimit(int time, int money) { - if (IsOverTimeLimit(time)) - return true; - if (IsOverMoneyLimit(money)) - return true; - return false; - } - - public boolean IsReachedExpLimit(int time, int exp) { - if (IsOverTimeLimit(time)) - return true; - if (IsOverExpLimit(exp)) - return true; - return false; - } - - public int GetLeftsec(int time) { - int lefttime1 = GetLeftTime(time); - int sec = 0; - if (lefttime1 >= 3600) { - lefttime1 = lefttime1 - ((int) (lefttime1 / 3600) * 3600); - if (lefttime1 > 60 && lefttime1 < 3600) { - sec = lefttime1 - ((int) (lefttime1 / 60) * 60); - } else if (lefttime1 < 60) - sec = lefttime1; - } else if (lefttime1 > 60 && lefttime1 < 3600) { - sec = lefttime1 - ((int) (lefttime1 / 60) * 60); - } else - sec = lefttime1; - return sec; - } - - public int GetLeftMin(int time) { - int lefttime1 = GetLeftTime(time); - int min = 0; - if (lefttime1 >= 3600) { - lefttime1 = lefttime1 - ((int) (lefttime1 / 3600) * 3600); - if (lefttime1 > 60 && lefttime1 < 3600) - min = lefttime1 / 60; - } else if (lefttime1 > 60 && lefttime1 < 3600) - min = lefttime1 / 60; - return min; - } - - public int GetLeftHour(int time) { - int lefttime1 = GetLeftTime(time); - int hour = 0; - if (lefttime1 >= 3600) { - hour = lefttime1 / 3600; - } - return hour; - } -} +package com.gamingmesh.jobs.economy; + +public class PaymentData { + + Long time = 0L; + Long lastAnnouced = 0L; + Double Payment = 0.0; + Double Points = 0.0; + Double Exp = 0.0; + public boolean Informed = false; + public boolean Reseted = false; + + public PaymentData(Long time, Double Payment, Double Points, Double Exp, Long lastAnnouced, boolean Informed) { + this.time = time; + this.Payment = Payment; + this.Points = Points; + this.Exp = Exp; + this.lastAnnouced = lastAnnouced; + this.Informed = Informed; + } + + public PaymentData() { + } + + public Long GetTime() { + return this.time; + } + + public void setReseted(boolean state) { + this.Reseted = state; + } + + public boolean isReseted() { + return this.Reseted; + } + + public Double GetAmount() { + return this.Payment; + } + + public Double GetAmountBylimit(int limit) { + if (this.Payment > limit) + return (double) limit; + return (int) (this.Payment * 100) / 100.0; + } + + public Double GetPoints() { + return this.Points; + } + + public Double GetPointsBylimit(int limit) { + if (this.Points > limit) + return (double) limit; + return (int) (this.Points * 100) / 100.0; + } + + public Double GetExpBylimit(int limit) { + if (this.Exp > limit) + return (double) limit; + return (int) (this.Exp * 100) / 100.0; + } + + public Long GetLastAnnounced() { + return this.lastAnnouced; + } + + public boolean IsAnnounceTime(int time) { + if (this.lastAnnouced + (time * 1000) > System.currentTimeMillis()) + return false; + SetAnnouncmentTime(); + return true; + } + + public void SetAnnouncmentTime() { + this.lastAnnouced = System.currentTimeMillis(); + } + + public void AddNewAmount(Double Payment) { + this.time = System.currentTimeMillis(); + this.Payment = Payment; + } + + public void AddNewPoints(Double Points) { + this.time = System.currentTimeMillis(); + this.Points = Points; + } + + public void Setinformed() { + this.Informed = true; + } + + public void SetNotInformed() { + this.Informed = false; + } + + public void AddAmount(Double Payment) { + this.Payment = this.Payment + Payment; + } + + public void AddPoints(Double Points) { + this.Points = this.Points + Points; + } + + public void AddExpAmount(Double Exp) { + this.Exp = this.Exp + Exp; + } + + public int GetLeftTime(int time) { + int left = 0; + if (this.time + (time * 1000) > System.currentTimeMillis()) + left = (int) ((this.time + (time * 1000) - System.currentTimeMillis()) / 1000); + return left; + } + + public boolean IsOverMoneyLimit(int limit) { + if (this.Payment < limit) + return false; + return true; + } + + public boolean IsOverPointsLimit(int limit) { + if (this.Points < limit) + return false; + return true; + } + + public boolean IsOverExpLimit(int limit) { + if (this.Exp < limit) + return false; + return true; + } + + public boolean IsOverTimeLimit(int time) { + if (this.time + (time * 1000) > System.currentTimeMillis()) + return false; + + if (this.Informed) + this.Informed = false; + + this.time = System.currentTimeMillis(); + this.Payment = 0.0; + this.Exp = 0.0; + this.Points = 0.0; + this.Reseted = true; + return true; + } + + public boolean IsReachedMoneyLimit(int time, int money) { + if (IsOverTimeLimit(time)) + return true; + if (IsOverMoneyLimit(money)) + return true; + return false; + } + + public boolean IsReachedExpLimit(int time, int exp) { + if (IsOverTimeLimit(time)) + return true; + if (IsOverExpLimit(exp)) + return true; + return false; + } + + public boolean IsReachedPointLimit(int time, int point) { + if (IsOverTimeLimit(time)) + return true; + if (IsOverPointsLimit(point)) + return true; + return false; + } + + public int GetLeftsec(int time) { + int lefttime1 = GetLeftTime(time); + int sec = 0; + if (lefttime1 >= 3600) { + lefttime1 = lefttime1 - ((int) (lefttime1 / 3600) * 3600); + if (lefttime1 > 60 && lefttime1 < 3600) { + sec = lefttime1 - ((int) (lefttime1 / 60) * 60); + } else if (lefttime1 < 60) + sec = lefttime1; + } else if (lefttime1 > 60 && lefttime1 < 3600) { + sec = lefttime1 - ((int) (lefttime1 / 60) * 60); + } else + sec = lefttime1; + return sec; + } + + public int GetLeftMin(int time) { + int lefttime1 = GetLeftTime(time); + int min = 0; + if (lefttime1 >= 3600) { + lefttime1 = lefttime1 - ((int) (lefttime1 / 3600) * 3600); + if (lefttime1 > 60 && lefttime1 < 3600) + min = lefttime1 / 60; + } else if (lefttime1 > 60 && lefttime1 < 3600) + min = lefttime1 / 60; + return min; + } + + public int GetLeftHour(int time) { + int lefttime1 = GetLeftTime(time); + int hour = 0; + if (lefttime1 >= 3600) { + hour = lefttime1 / 3600; + } + return hour; + } +} diff --git a/com/gamingmesh/jobs/economy/PointsData.java b/com/gamingmesh/jobs/economy/PointsData.java new file mode 100644 index 00000000..1cdbb4e8 --- /dev/null +++ b/com/gamingmesh/jobs/economy/PointsData.java @@ -0,0 +1,43 @@ +package com.gamingmesh.jobs.economy; + +import java.util.HashMap; +import java.util.UUID; + +import com.gamingmesh.jobs.container.PlayerPoints; + +public class PointsData { + + HashMap<UUID, PlayerPoints> Pointbase = new HashMap<UUID, PlayerPoints>(); + + public PointsData() { + } + + public HashMap<UUID, PlayerPoints> getPointBase() { + return Pointbase; + } + + public void addPlayer(UUID uuid) { + addPlayer(uuid, 0D); + } + + public void addPlayer(UUID uuid, double points) { + addPlayer(uuid, points, 0D); + } + + public void addPlayer(UUID uuid, double points, double total) { + if (!Pointbase.containsKey(uuid)) + Pointbase.put(uuid, new PlayerPoints(points, total)); + } + + public void addPoints(UUID uuid, Double points) { + if (!Pointbase.containsKey(uuid)) + addPlayer(uuid, points); + else { + Pointbase.get(uuid).addPoints(points); + } + } + + public PlayerPoints getPlayerPointsInfo(UUID uuid) { + return Pointbase.containsKey(uuid) ? Pointbase.get(uuid) : new PlayerPoints(); + } +} diff --git a/com/gamingmesh/jobs/i18n/Language.java b/com/gamingmesh/jobs/i18n/Language.java index 60f43b02..98d534f4 100644 --- a/com/gamingmesh/jobs/i18n/Language.java +++ b/com/gamingmesh/jobs/i18n/Language.java @@ -23,8 +23,8 @@ import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.plugin.java.JavaPlugin; +import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.JobsPlugin; -import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.config.YmlMaker; public class Language { @@ -36,21 +36,11 @@ public class Language { this.plugin = plugin; } -// static { -// customlocale = new YmlMaker((JavaPlugin) plugin, "locale/messages_" + ConfigManager.getJobsConfiguration().localeString + ".yml").getConfig(); -// enlocale = new YmlMaker((JavaPlugin) JobsPlugin.instance, "locale/messages_en.yml").getConfig(); -// if (customlocale == null) -// customlocale = enlocale; -// } - - public Language() { - } - /** * Reloads the config */ public void reload(Locale locale) { - customlocale = new YmlMaker((JavaPlugin) plugin, "locale/messages_" + ConfigManager.getJobsConfiguration().localeString + ".yml").getConfig(); + customlocale = new YmlMaker((JavaPlugin) plugin, "locale/messages_" + Jobs.getGCManager().localeString + ".yml").getConfig(); enlocale = new YmlMaker((JavaPlugin) plugin, "locale/messages_en.yml").getConfig(); if (customlocale == null) customlocale = enlocale; @@ -61,10 +51,22 @@ public class Language { * @param key - the key of the message * @return the message */ - public static String getMessage(String key) { + public String getMessage(String key, Object... variables) { + String missing = "Missing locale for " + key + " "; + String msg = ""; if (customlocale == null || !customlocale.contains(key)) - return enlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', enlocale.getString(key)) : "Cant find locale"; - return customlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', customlocale.getString(key)) : "Cant find locale"; + msg = enlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', enlocale.getString(key)) : missing; + else + msg = customlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', customlocale.getString(key)) : missing; + + if (variables.length > 0) + for (int i = 0; i < variables.length; i++) { + if (variables.length >= i + 2) + msg = msg.replace(String.valueOf(variables[i]), String.valueOf(variables[i + 1])); + i++; + } + + return msg; } /** @@ -72,7 +74,7 @@ public class Language { * @param key - the key of the message * @return the message */ - public static String getDefaultMessage(String key) { + public String getDefaultMessage(String key) { return enlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', enlocale.getString(key)) : "Cant find locale"; } @@ -81,7 +83,7 @@ public class Language { * @param key - the key of the message * @return true/false */ - public static boolean containsKey(String key) { + public boolean containsKey(String key) { if (customlocale == null || !customlocale.contains(key)) return enlocale.contains(key); return customlocale.contains(key); diff --git a/com/gamingmesh/jobs/listeners/JobsListener.java b/com/gamingmesh/jobs/listeners/JobsListener.java index 3da08d26..28e155ee 100644 --- a/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/com/gamingmesh/jobs/listeners/JobsListener.java @@ -61,16 +61,11 @@ import org.bukkit.plugin.PluginManager; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.Gui.GuiInfoList; -import com.gamingmesh.jobs.Gui.GuiTools; import com.gamingmesh.jobs.api.JobsChunkChangeEvent; -import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobLimitedItems; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; -import com.gamingmesh.jobs.i18n.Language; -import com.gamingmesh.jobs.stuff.ActionBar; -import com.gamingmesh.jobs.stuff.OfflinePlayerList; public class JobsListener implements Listener { // hook to the main plugin @@ -81,39 +76,69 @@ public class JobsListener implements Listener { } @EventHandler(priority = EventPriority.LOWEST) - public void onGuiLeftClick(InventoryClickEvent event) { - - if (GuiTools.GuiList.isEmpty()) + public void onShopClick(InventoryClickEvent event) { + if (Jobs.getShopManager().GuiList.isEmpty()) return; Player player = (Player) event.getWhoClicked(); - if (!GuiTools.GuiList.containsKey(player.getName())) + if (!Jobs.getShopManager().GuiList.contains(player.getName())) return; event.setCancelled(true); - GuiInfoList joblist = GuiTools.GuiList.get(player.getName()); + if (event.getSlot() < 0 || event.getSlot() >= Jobs.getShopManager().list.size()) + return; + + Jobs.getShopManager().checkSlot(player, event.getSlot()); + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false) + public void onShopClose(InventoryCloseEvent event) { + if (Jobs.getShopManager().GuiList.isEmpty()) + return; + + Player player = (Player) event.getPlayer(); + + if (Jobs.getShopManager().GuiList.contains(player.getName())) + Jobs.getShopManager().GuiList.remove(player.getName()); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onGuiLeftClick(InventoryClickEvent event) { + + if (Jobs.getGUIManager().GuiList.isEmpty()) + return; + + Player player = (Player) event.getWhoClicked(); + + if (!Jobs.getGUIManager().GuiList.containsKey(player.getName())) + return; + + event.setCancelled(true); + + GuiInfoList joblist = Jobs.getGUIManager().GuiList.get(player.getName()); int slot = event.getRawSlot(); if (slot >= 0) { - if (!joblist.isJobInfo() && (!ConfigManager.getJobsConfiguration().JobsGUISwitcheButtons && event.getClick() == ClickType.LEFT || - ConfigManager.getJobsConfiguration().JobsGUISwitcheButtons && event.getClick() == ClickType.RIGHT)) { + if (!joblist.isJobInfo() && (!Jobs.getGCManager().JobsGUISwitcheButtons && event.getClick() == ClickType.LEFT || + Jobs.getGCManager().JobsGUISwitcheButtons && event.getClick() == ClickType.RIGHT)) { if (slot < joblist.getJobList().size()) { player.closeInventory(); - player.openInventory(GuiTools.CreateJobsSubGUI(player, joblist.getJobList().get(slot))); + player.openInventory(Jobs.getGUIManager().CreateJobsSubGUI(player, joblist.getJobList().get(slot))); } } else if (joblist.isJobInfo()) { if (slot == joblist.getbackButton()) { player.closeInventory(); - player.openInventory(GuiTools.CreateJobsGUI(player)); + player.openInventory(Jobs.getGUIManager().CreateJobsGUI(player)); } - } else if (!ConfigManager.getJobsConfiguration().JobsGUISwitcheButtons && event.getClick() == ClickType.RIGHT || - ConfigManager.getJobsConfiguration().JobsGUISwitcheButtons && event.getClick() == ClickType.LEFT) { + } else if (!Jobs.getGCManager().JobsGUISwitcheButtons && event.getClick() == ClickType.RIGHT || + Jobs.getGCManager().JobsGUISwitcheButtons && event.getClick() == ClickType.LEFT) { if (!joblist.isJobInfo() && slot < joblist.getJobList().size()) { Bukkit.dispatchCommand(player, "jobs join " + joblist.getJobList().get(slot).getName()); - player.getOpenInventory().getTopInventory().setContents(GuiTools.CreateJobsGUI(player).getContents()); + player.getOpenInventory().getTopInventory().setContents(Jobs.getGUIManager().CreateJobsGUI(player).getContents()); } } } @@ -121,13 +146,13 @@ public class JobsListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false) public void onGuiClose(InventoryCloseEvent event) { - if (GuiTools.GuiList.size() == 0) + if (Jobs.getGUIManager().GuiList.isEmpty()) return; Player player = (Player) event.getPlayer(); - if (GuiTools.GuiList.containsKey(player.getName())) - GuiTools.GuiList.remove(player.getName()); + if (Jobs.getGUIManager().GuiList.containsKey(player.getName())) + Jobs.getGUIManager().GuiList.remove(player.getName()); } @EventHandler(priority = EventPriority.MONITOR) @@ -160,7 +185,6 @@ public class JobsListener implements Listener { if (!plugin.isEnabled()) return; Jobs.getPlayerManager().playerQuit(event.getPlayer()); - OfflinePlayerList.addPlayer(event.getPlayer()); } @EventHandler(priority = EventPriority.MONITOR) @@ -178,7 +202,7 @@ public class JobsListener implements Listener { if (!plugin.isEnabled()) return; - if (!ConfigManager.getJobsConfiguration().SignsEnabled) + if (!Jobs.getGCManager().SignsEnabled) return; if (event.getAction() != Action.RIGHT_CLICK_BLOCK) @@ -195,13 +219,13 @@ public class JobsListener implements Listener { Sign sign = (Sign) block.getState(); String FirstLine = sign.getLine(0); - if (!FirstLine.equalsIgnoreCase(Language.getMessage("signs.topline"))) + if (!FirstLine.equalsIgnoreCase(Jobs.getLanguage().getMessage("signs.topline"))) return; String command = ChatColor.stripColor(sign.getLine(1)); - for (String key : ConfigManager.getJobsConfiguration().keys) { - if (command.equalsIgnoreCase(ChatColor.stripColor(Language.getMessage("signs.secondline." + key)))) { + for (String key : Jobs.getGCManager().keys) { + if (command.equalsIgnoreCase(ChatColor.stripColor(Jobs.getLanguage().getMessage("signs.secondline." + key)))) { command = key; break; } @@ -217,7 +241,7 @@ public class JobsListener implements Listener { if (!plugin.isEnabled()) return; - if (!ConfigManager.getJobsConfiguration().SignsEnabled) + if (!Jobs.getGCManager().SignsEnabled) return; Block block = event.getBlock(); @@ -232,10 +256,10 @@ public class JobsListener implements Listener { Sign sign = (Sign) block.getState(); String FirstLine = sign.getLine(0); - if (FirstLine.equalsIgnoreCase(Language.getMessage("signs.topline"))) + if (FirstLine.equalsIgnoreCase(Jobs.getLanguage().getMessage("signs.topline"))) if (!player.hasPermission("jobs.command.signs")) { event.setCancelled(true); - player.sendMessage(Language.getMessage("signs.cantdestroy")); + player.sendMessage(Jobs.getLanguage().getMessage("signs.cantdestroy")); return; } @@ -252,7 +276,7 @@ public class JobsListener implements Listener { if (!player.hasPermission("jobs.command.signs")) { event.setCancelled(true); - player.sendMessage(Language.getMessage("signs.cantdestroy")); + player.sendMessage(Jobs.getLanguage().getMessage("signs.cantdestroy")); return; } @@ -267,7 +291,7 @@ public class JobsListener implements Listener { if (!plugin.isEnabled()) return; - if (!ConfigManager.getJobsConfiguration().SignsEnabled) + if (!Jobs.getGCManager().SignsEnabled) return; Block block = event.getBlock(); @@ -289,7 +313,7 @@ public class JobsListener implements Listener { if (!event.getPlayer().hasPermission("jobs.command.signs")) { event.setCancelled(true); - player.sendMessage(Language.getMessage("signs.cantcreate")); + player.sendMessage(Jobs.getLanguage().getMessage("signs.cantcreate")); return; } @@ -298,7 +322,7 @@ public class JobsListener implements Listener { final Job job = Jobs.getJob(jobname); if (job == null && !signtype.equalsIgnoreCase("gtoplist")) { - player.sendMessage(Language.getMessage("command.top.error.nojob")); + player.sendMessage(Jobs.getLanguage().getMessage("command.top.error.nojob")); return; } @@ -313,7 +337,7 @@ public class JobsListener implements Listener { try { Number = Integer.parseInt(numberString); } catch (NumberFormatException e) { - player.sendMessage(Language.getMessage("command.error.notNumber")); + player.sendMessage(Jobs.getLanguage().getMessage("general.error.notNumber")); return; } @@ -356,26 +380,27 @@ public class JobsListener implements Listener { if (!plugin.isEnabled()) return; - if (!ConfigManager.getJobsConfiguration().SignsEnabled) + if (!Jobs.getGCManager().SignsEnabled) return; - if (ChatColor.stripColor(event.getLine(0)).equalsIgnoreCase(ChatColor.stripColor(Language.getMessage("signs.topline"))) && !ChatColor.stripColor(event.getLine(1)) + if (ChatColor.stripColor(event.getLine(0)).equalsIgnoreCase(ChatColor.stripColor(Jobs.getLanguage().getMessage("signs.topline"))) && !ChatColor.stripColor(event + .getLine(1)) .equalsIgnoreCase("toplist")) - event.setLine(0, Convert(Language.getMessage("signs.topline"))); + event.setLine(0, Convert(Jobs.getLanguage().getMessage("signs.topline"))); else return; if (!event.getPlayer().hasPermission("jobs.command.signs")) { event.setCancelled(true); - event.getPlayer().sendMessage(Language.getMessage("signs.cantcreate")); + event.getPlayer().sendMessage(Jobs.getLanguage().getMessage("signs.cantcreate")); return; } String command = ChatColor.stripColor(event.getLine(1)).toLowerCase(); - for (String key : ConfigManager.getJobsConfiguration().keys) { - if (command.equalsIgnoreCase(ChatColor.stripColor(Language.getMessage("signs.secondline." + key)))) { - event.setLine(1, Convert(Language.getMessage("signs.secondline." + key))); + for (String key : Jobs.getGCManager().keys) { + if (command.equalsIgnoreCase(ChatColor.stripColor(Jobs.getLanguage().getMessage("signs.secondline." + key)))) { + event.setLine(1, Convert(Jobs.getLanguage().getMessage("signs.secondline." + key))); break; } } @@ -385,7 +410,7 @@ public class JobsListener implements Listener { if (job == null) return; - String color = ConfigManager.getJobsConfiguration().SignsColorizeJobName ? job.getChatColor().toString() : ""; + String color = Jobs.getGCManager().SignsColorizeJobName ? job.getChatColor().toString() : ""; event.setLine(2, Convert(color + job.getName())); } @@ -400,7 +425,7 @@ public class JobsListener implements Listener { if (!plugin.isEnabled()) return; - if (!ConfigManager.getJobsConfiguration().getModifyChat()) + if (!Jobs.getGCManager().getModifyChat()) return; Player player = event.getPlayer(); @@ -421,7 +446,7 @@ public class JobsListener implements Listener { public void onPlayerChatLow(AsyncPlayerChatEvent event) { if (!plugin.isEnabled()) return; - if (ConfigManager.getJobsConfiguration().getModifyChat()) + if (Jobs.getGCManager().getModifyChat()) return; Player player = event.getPlayer(); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); @@ -440,7 +465,7 @@ public class JobsListener implements Listener { public void onPlayerChatHigh(AsyncPlayerChatEvent event) { if (!plugin.isEnabled()) return; - if (ConfigManager.getJobsConfiguration().getModifyChat()) + if (Jobs.getGCManager().getModifyChat()) return; Player player = event.getPlayer(); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); @@ -464,7 +489,12 @@ public class JobsListener implements Listener { @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onWaterBlockBreak(BlockFromToEvent event) { - if (!ConfigManager.getJobsConfiguration().WaterBlockBreake) + + //disabling plugin in world + if (event.getBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) + return; + + if (!Jobs.getGCManager().WaterBlockBreake) return; if (event.getBlock().getType() == Material.STATIONARY_WATER && event.getToBlock().getType() != Material.AIR && event.getToBlock() .getType() != Material.STATIONARY_WATER && event.getToBlock().getState().hasMetadata( @@ -475,7 +505,10 @@ public class JobsListener implements Listener { @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onCropGrown(final BlockGrowEvent event) { - if (!ConfigManager.getJobsConfiguration().WaterBlockBreake) + //disabling plugin in world + if (event.getBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) + return; + if (!Jobs.getGCManager().WaterBlockBreake) return; if (event.getBlock().getState().hasMetadata(JobsPaymentListener.PlacedBlockMetadata)) { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @@ -490,7 +523,9 @@ public class JobsListener implements Listener { @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onLimitedItemInteract(PlayerInteractEvent event) { - + //disabling plugin in world + if (event.getClickedBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getClickedBlock().getWorld())) + return; Player player = (Player) event.getPlayer(); ItemStack iih = player.getItemInHand(); @@ -533,7 +568,7 @@ public class JobsListener implements Listener { if (meinOk != null) { event.setCancelled(true); - ActionBar.send(player, Language.getMessage("limitedItem.error.levelup").replace("[jobname]", meinOk)); + Jobs.getActionBar().send(player, Jobs.getLanguage().getMessage("limitedItem.error.levelup", "[jobname]", meinOk)); } } @@ -576,7 +611,9 @@ public class JobsListener implements Listener { @EventHandler public void onChunkChangeMove(PlayerMoveEvent event) { - + //disabling plugin in world + if (event.getTo() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getTo().getWorld())) + return; Chunk from = event.getFrom().getChunk(); Chunk to = event.getTo().getChunk(); diff --git a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 70f7818e..c9fa69c6 100644 --- a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -77,16 +77,12 @@ import com.gamingmesh.jobs.actions.EntityActionInfo; import com.gamingmesh.jobs.actions.ExploreActionInfo; import com.gamingmesh.jobs.actions.ItemActionInfo; import com.gamingmesh.jobs.api.JobsChunkChangeEvent; -import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.ExploreRespond; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; -import com.gamingmesh.jobs.i18n.Language; -import com.gamingmesh.jobs.stuff.ActionBar; import com.gamingmesh.jobs.stuff.ChatColor; import com.gamingmesh.jobs.stuff.Perm; -import com.gmail.nossr50.api.AbilityAPI; import com.google.common.base.Objects; public class JobsPaymentListener implements Listener { @@ -106,6 +102,13 @@ public class JobsPaymentListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCowMilking(PlayerInteractEntityEvent event) { + //disabling plugin in world + if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) + return; + + // make sure plugin is enabled + if (!plugin.isEnabled()) + return; if (!(event.getRightClicked() instanceof LivingEntity)) return; @@ -114,30 +117,26 @@ public class JobsPaymentListener implements Listener { if (cow.getType() != EntityType.COW && cow.getType() != EntityType.MUSHROOM_COW) return; - // make sure plugin is enabled - if (!plugin.isEnabled()) - return; - Player player = (Player) event.getPlayer(); if (player == null) return; - if (ConfigManager.getJobsConfiguration().CowMilkingTimer > 0) + if (Jobs.getGCManager().CowMilkingTimer > 0) if (cow.hasMetadata(CowMetadata)) { long time = cow.getMetadata(CowMetadata).get(0).asLong(); - if (System.currentTimeMillis() < time + ConfigManager.getJobsConfiguration().CowMilkingTimer) { + if (System.currentTimeMillis() < time + Jobs.getGCManager().CowMilkingTimer) { - long timer = ((ConfigManager.getJobsConfiguration().CowMilkingTimer - (System.currentTimeMillis() - time)) / 1000); - player.sendMessage(Language.getMessage("message.cowtimer").replace("%time%", String.valueOf(timer))); + long timer = ((Jobs.getGCManager().CowMilkingTimer - (System.currentTimeMillis() - time)) / 1000); + player.sendMessage(Jobs.getLanguage().getMessage("message.cowtimer", "%time%", timer)); - if (ConfigManager.getJobsConfiguration().CancelCowMilking) + if (Jobs.getGCManager().CancelCowMilking) event.setCancelled(true); return; } } - ItemStack itemInHand = player.getItemInHand(); + ItemStack itemInHand = Jobs.getNms().getItemInMainHand(player); if (itemInHand == null) return; @@ -146,26 +145,18 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; - // Item in hand - ItemStack item = player.getItemInHand().hasItemMeta() ? player.getItemInHand() : null; - - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - - // restricted area multiplier - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); // pay JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); if (jPlayer == null) return; - Jobs.action(jPlayer, new EntityActionInfo(cow, ActionType.MILK), multiplier, item, armor); + Jobs.action(jPlayer, new EntityActionInfo(cow, ActionType.MILK), 0.0); Long Timer = System.currentTimeMillis(); @@ -174,7 +165,9 @@ public class JobsPaymentListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEntityShear(PlayerShearEntityEvent event) { - + //disabling plugin in world + if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) + return; // Entity that died must be living if (!(event.getEntity() instanceof Sheep)) return; @@ -196,30 +189,25 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; - // Item in hand - ItemStack item = player.getItemInHand().hasItemMeta() ? player.getItemInHand() : null; - - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - - // restricted area multiplier - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); // pay JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(player); if (jDamager == null) return; - Jobs.action(jDamager, new CustomKillInfo(sheep.getColor().name(), ActionType.SHEAR), multiplier, item, armor); + Jobs.action(jDamager, new CustomKillInfo(sheep.getColor().name(), ActionType.SHEAR), 0.0); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBrewEvent(BrewEvent event) { + //disabling plugin in world + if (event.getBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) + return; if (!plugin.isEnabled()) return; Block block = event.getBlock(); @@ -245,22 +233,19 @@ public class JobsPaymentListener implements Listener { if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); - ItemStack contents = event.getContents().getIngredient(); if (contents == null) return; - Jobs.action(jPlayer, new ItemActionInfo(contents, ActionType.BREW), multiplier, null, armor); + Jobs.action(jPlayer, new ItemActionInfo(contents, ActionType.BREW), 0.0); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { - + //disabling plugin in world + if (event.getBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) + return; // remove furnace metadata for broken block Block block = event.getBlock(); if (block == null) @@ -269,18 +254,18 @@ public class JobsPaymentListener implements Listener { if (block.getType().equals(Material.FURNACE) && block.hasMetadata(furnaceOwnerMetadata)) block.removeMetadata(furnaceOwnerMetadata, plugin); - if (ConfigManager.getJobsConfiguration().useBlockProtection) + if (Jobs.getGCManager().useBlockProtection) if (block.getState().hasMetadata(BlockMetadata)) return; - if (JobsPlugin.CPPresent && ConfigManager.getJobsConfiguration().useCoreProtect) + if (Jobs.getCoreProtectApi() != null && Jobs.getGCManager().useCoreProtect) if (PistonProtectionListener.CheckBlock(block)) { - List<String[]> blockLookup = JobsPlugin.CPAPI.blockLookup(block, ConfigManager.getJobsConfiguration().CoreProtectInterval); + List<String[]> blockLookup = Jobs.getCoreProtectApi().blockLookup(block, Jobs.getGCManager().CoreProtectInterval); if (blockLookup.size() > 0) return; } - if (ConfigManager.getJobsConfiguration().useBlockTimer) + if (Jobs.getGCManager().useBlockTimer) if (PistonProtectionListener.checkVegybreak(block, (Player) event.getPlayer())) return; @@ -293,22 +278,22 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; // Global block timer - if (ConfigManager.getJobsConfiguration().useGlobalTimer) { + if (Jobs.getGCManager().useGlobalTimer) { if (block.getState().hasMetadata(GlobalMetadata)) { long currentTime = System.currentTimeMillis(); List<MetadataValue> meta = block.getState().getMetadata(GlobalMetadata); if (meta.size() > 0) { long BlockTime = meta.get(0).asLong(); - if (currentTime < BlockTime + ConfigManager.getJobsConfiguration().globalblocktimer * 1000) { - int sec = Math.round((((BlockTime + ConfigManager.getJobsConfiguration().globalblocktimer * 1000) - currentTime)) / 1000); - ActionBar.send(player, Language.getMessage("message.blocktimer").replace("[time]", String.valueOf(sec))); + if (currentTime < BlockTime + Jobs.getGCManager().globalblocktimer * 1000) { + int sec = Math.round((((BlockTime + Jobs.getGCManager().globalblocktimer * 1000) - currentTime)) / 1000); + Jobs.getActionBar().send(player, Jobs.getLanguage().getMessage("message.blocktimer", "[time]", sec)); return; } } @@ -316,39 +301,28 @@ public class JobsPaymentListener implements Listener { } // restricted area multiplier - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); + double multiplier = 0.0; - try { - if (McMMOlistener.mcMMOPresent) - if (AbilityAPI.treeFellerEnabled(player)) - multiplier = multiplier * ConfigManager.getJobsConfiguration().TreeFellerMultiplier; - else if (AbilityAPI.gigaDrillBreakerEnabled(player)) - multiplier = multiplier * ConfigManager.getJobsConfiguration().gigaDrillMultiplier; - else if (AbilityAPI.superBreakerEnabled(player)) - multiplier = multiplier * ConfigManager.getJobsConfiguration().superBreakerMultiplier; - } catch (Exception e) { - } + if (McMMOlistener.mcMMOPresent) + multiplier = McMMOlistener.getMultiplier(player); // Item in hand - ItemStack item = player.getItemInHand(); + ItemStack item = Jobs.getNms().getItemInMainHand(player); // Protection for block break with silktouch - if (ConfigManager.getJobsConfiguration().useSilkTouchProtection && item != null) + if (Jobs.getGCManager().useSilkTouchProtection && item != null) if (PistonProtectionListener.CheckBlock(block)) for (Entry<Enchantment, Integer> one : item.getEnchantments().entrySet()) if (one.getKey().getName().equalsIgnoreCase("SILK_TOUCH")) return; - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); if (jPlayer == null) return; BlockActionInfo bInfo = new BlockActionInfo(block, ActionType.BREAK); - Jobs.action(jPlayer, bInfo, multiplier, item, armor); + Jobs.action(jPlayer, bInfo, multiplier); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @@ -357,7 +331,11 @@ public class JobsPaymentListener implements Listener { if (block == null) return; - + + //disabling plugin in world + if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld())) + return; + // make sure plugin is enabled if (!plugin.isEnabled()) return; @@ -371,16 +349,15 @@ public class JobsPaymentListener implements Listener { if (!player.isOnline()) return; - if (JobsPlugin.CPPresent && ConfigManager.getJobsConfiguration().useCoreProtect && ConfigManager.getJobsConfiguration().BlockPlaceUse) { + if (Jobs.getCoreProtectApi() != null && Jobs.getGCManager().useCoreProtect && Jobs.getGCManager().BlockPlaceUse) { if (PistonProtectionListener.CheckPlaceBlock(block)) { - List<String[]> blockLookup = JobsPlugin.CPAPI.blockLookup(block, ConfigManager.getJobsConfiguration().BlockPlaceInterval + 1); + List<String[]> blockLookup = Jobs.getCoreProtectApi().blockLookup(block, Jobs.getGCManager().BlockPlaceInterval + 1); if (blockLookup.size() > 0) { long PlacedBlockTime = Integer.valueOf(blockLookup.get(0)[0]); long CurrentTime = System.currentTimeMillis() / 1000; - if (PlacedBlockTime + ConfigManager.getJobsConfiguration().BlockPlaceInterval > CurrentTime) { - if (ConfigManager.getJobsConfiguration().EnableAnounceMessage) - ActionBar.send(player, Language.getMessage("message.placeblocktimer").replace("[time]", String.valueOf(ConfigManager - .getJobsConfiguration().BlockPlaceInterval))); + if (PlacedBlockTime + Jobs.getGCManager().BlockPlaceInterval > CurrentTime) { + if (Jobs.getGCManager().EnableAnounceMessage) + Jobs.getActionBar().send(player, Jobs.getLanguage().getMessage("message.placeblocktimer", "[time]", Jobs.getGCManager().BlockPlaceInterval)); return; } } @@ -388,44 +365,42 @@ public class JobsPaymentListener implements Listener { } // check if in creative - if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; // Block place/break protection - if (ConfigManager.getJobsConfiguration().useBlockProtection) + if (Jobs.getGCManager().useBlockProtection) if (PistonProtectionListener.CheckBlock(block)) block.getState().setMetadata(BlockMetadata, new FixedMetadataValue(plugin, true)); - if (ConfigManager.getJobsConfiguration().WaterBlockBreake) + if (Jobs.getGCManager().WaterBlockBreake) block.getState().setMetadata(PlacedBlockMetadata, new FixedMetadataValue(plugin, true)); - if (ConfigManager.getJobsConfiguration().useBlockTimer) + if (Jobs.getGCManager().useBlockTimer) if (PistonProtectionListener.CheckVegy(block)) { long time = System.currentTimeMillis(); block.setMetadata(VegyMetadata, new FixedMetadataValue(plugin, time)); } - if (ConfigManager.getJobsConfiguration().useGlobalTimer) { + if (Jobs.getGCManager().useGlobalTimer) { long time = System.currentTimeMillis(); block.setMetadata(GlobalMetadata, new FixedMetadataValue(plugin, time)); } - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - - // restricted area multiplier - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); if (jPlayer == null) return; - Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.PLACE), multiplier, null, armor); + Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.PLACE), 0.0); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerFish(PlayerFishEvent event) { + //disabling plugin in world + if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) + return; // make sure plugin is enabled if (!plugin.isEnabled()) return; @@ -433,33 +408,26 @@ public class JobsPaymentListener implements Listener { Player player = event.getPlayer(); // check if in creative - if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; - // restricted area multiplier - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); - - // Item in hand - ItemStack item = player.getItemInHand().hasItemMeta() ? player.getItemInHand() : null; - - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - if (event.getState().equals(PlayerFishEvent.State.CAUGHT_FISH) && event.getCaught() instanceof Item) { JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); if (jPlayer == null) return; ItemStack items = ((Item) event.getCaught()).getItemStack(); - Jobs.action(jPlayer, new ItemActionInfo(items, ActionType.FISH), multiplier, item, armor); + Jobs.action(jPlayer, new ItemActionInfo(items, ActionType.FISH), 0.0); } } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onAnimalTame(EntityTameEvent event) { - + //disabling plugin in world + if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) + return; // Entity that died must be living if (!(event.getEntity() instanceof LivingEntity)) return; @@ -480,32 +448,26 @@ public class JobsPaymentListener implements Listener { if (player == null) return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; - // Item in hand - ItemStack item = player.getItemInHand().hasItemMeta() ? player.getItemInHand() : null; - - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - - // restricted area multiplier - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); // pay JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(player); if (jDamager == null) return; - Jobs.action(jDamager, new EntityActionInfo(animal, ActionType.TAME), multiplier, item, armor); + Jobs.action(jDamager, new EntityActionInfo(animal, ActionType.TAME), 0.0); } @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onInventoryCraft(CraftItemEvent event) { - + //disabling plugin in world + if (event.getWhoClicked() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld())) + return; // make sure plugin is enabled if (!plugin.isEnabled()) return; @@ -536,7 +498,7 @@ public class JobsPaymentListener implements Listener { //Check if inventory is full and using shift click, possible money dupping fix if (player.getInventory().firstEmpty() == -1 && event.isShiftClick()) { - player.sendMessage(ChatColor.RED + Language.getMessage("message.crafting.fullinventory")); + player.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("message.crafting.fullinventory")); return; } @@ -547,13 +509,10 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); + double multiplier = 0.0; JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); @@ -590,7 +549,7 @@ public class JobsPaymentListener implements Listener { if (y == 2) { if (first == second && third == second) { - Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR), multiplier, null, armor); + Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR), multiplier); return; } } @@ -598,17 +557,17 @@ public class JobsPaymentListener implements Listener { // Check Dyes if (y >= 2) { if ((third == 351 || second == 351) && leather) { - Jobs.action(jPlayer, new ItemActionInfo(sourceItems[0], ActionType.DYE), multiplier, null, armor); + Jobs.action(jPlayer, new ItemActionInfo(sourceItems[0], ActionType.DYE), multiplier); for (ItemStack OneDye : DyeStack) { - Jobs.action(jPlayer, new ItemActionInfo(OneDye, ActionType.DYE), multiplier, null, armor); + Jobs.action(jPlayer, new ItemActionInfo(OneDye, ActionType.DYE), multiplier); } return; } } // If we need to pay only by each craft action we will skip calculation how much was crafted - if (!ConfigManager.getJobsConfiguration().PayForEachCraft) { - Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT), multiplier, null, armor); + if (!Jobs.getGCManager().PayForEachCraft) { + Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT), multiplier); return; } @@ -618,14 +577,14 @@ public class JobsPaymentListener implements Listener { // Make sure we are actually crafting anything if (player != null && hasItems(toCraft)) if (event.isShiftClick()) - schedulePostDetection(player, toCraft, jPlayer, resultStack, multiplier, armor); + schedulePostDetection(player, toCraft, jPlayer, resultStack, multiplier); else { // The items are stored in the cursor. Make sure there's enough space. if (isStackSumLegal(toCraft, toStore)) { int newItemsCount = toCraft.getAmount(); while (newItemsCount >= 0) { newItemsCount--; - Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT), multiplier, null, armor); + Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT), multiplier); } } } @@ -635,7 +594,7 @@ public class JobsPaymentListener implements Listener { // HACK! The API doesn't allow us to easily determine the resulting number of // crafted items, so we're forced to compare the inventory before and after. private Integer schedulePostDetection(final HumanEntity player, final ItemStack compareItem, final JobsPlayer jPlayer, final ItemStack resultStack, - final double multiplier, final ItemStack[] armor) { + final double multiplier) { final ItemStack[] preInv = player.getInventory().getContents(); // Clone the array. The content may (was for me) be mutable. for (int i = 0; i < preInv.length; i++) { @@ -659,7 +618,7 @@ public class JobsPaymentListener implements Listener { if (newItemsCount > 0) { while (newItemsCount >= 0) { newItemsCount--; - Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT), multiplier, null, armor); + Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT), multiplier); } } return; @@ -691,6 +650,9 @@ public class JobsPaymentListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onInventoryRepair(InventoryClickEvent event) { + //disabling plugin in world + if (event.getWhoClicked() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld())) + return; // make sure plugin is enabled if (!plugin.isEnabled()) return; @@ -745,7 +707,7 @@ public class JobsPaymentListener implements Listener { if (resultStack.getItemMeta().getDisplayName() != null) NewName = resultStack.getItemMeta().getDisplayName(); if (OriginalName != NewName && event.getInventory().getItem(1) == null) - if (!ConfigManager.getJobsConfiguration().PayForRenaming) + if (!Jobs.getGCManager().PayForRenaming) return; // Check for world permissions @@ -753,21 +715,20 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); if (jPlayer == null) return; - Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR), multiplier, null, armor); + Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR), 0.0); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEnchantItem(EnchantItemEvent event) { + //disabling plugin in world + if (event.getEnchanter() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEnchanter().getWorld())) + return; // make sure plugin is enabled if (!plugin.isEnabled()) return; @@ -791,13 +752,9 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); if (jPlayer == null) @@ -817,14 +774,17 @@ public class JobsPaymentListener implements Listener { if (level == null) continue; - Jobs.action(jPlayer, new EnchantActionInfo(enchantName, level, ActionType.ENCHANT), multiplier, null, armor); + Jobs.action(jPlayer, new EnchantActionInfo(enchantName, level, ActionType.ENCHANT), 0.0); } - Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.ENCHANT), multiplier, null, armor); + Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.ENCHANT), 0.0); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onFurnaceSmelt(FurnaceSmeltEvent event) { + //disabling plugin in world + if (event.getBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) + return; if (!plugin.isEnabled()) return; Block block = event.getBlock(); @@ -847,19 +807,17 @@ public class JobsPaymentListener implements Listener { if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); if (jPlayer == null) return; - Jobs.action(jPlayer, new ItemActionInfo(event.getResult(), ActionType.SMELT), multiplier, null, armor); + Jobs.action(jPlayer, new ItemActionInfo(event.getResult(), ActionType.SMELT), 0.0); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEntityDeath(EntityDeathEvent event) { - + //disabling plugin in world + if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) + return; // Entity that died must be living if (!(event.getEntity() instanceof LivingEntity)) return; @@ -870,13 +828,13 @@ public class JobsPaymentListener implements Listener { if (lVictim.getKiller().hasMetadata("NPC")) return; - if (ConfigManager.getJobsConfiguration().MythicMobsEnabled && MythicMobsListener.Present) { - if (JobsPlugin.MMAPI.getMobAPI().isMythicMob(lVictim)) + if (Jobs.getGCManager().MythicMobsEnabled && Jobs.getMythicManager().MMAPI != null) { + if (Jobs.getMythicManager().MMAPI.getMobAPI().isMythicMob(lVictim)) return; } // mob spawner, no payment or experience - if (lVictim.hasMetadata(mobSpawnerMetadata) && !ConfigManager.getJobsConfiguration().payNearSpawner()) { + if (lVictim.hasMetadata(mobSpawnerMetadata) && !Jobs.getGCManager().payNearSpawner()) { //lVictim.removeMetadata(mobSpawnerMetadata, plugin); return; } @@ -887,7 +845,7 @@ public class JobsPaymentListener implements Listener { Player pDamager = null; - Double PetPayMultiplier = 1.0; + Double PetPayMultiplier = 0.0; // Checking if killer is player if (event.getEntity().getKiller() instanceof Player) pDamager = (Player) event.getEntity().getKiller(); @@ -898,9 +856,9 @@ public class JobsPaymentListener implements Listener { if (t.isTamed() && t.getOwner() instanceof Player) { pDamager = (Player) t.getOwner(); if (Perm.hasPermission(pDamager, "jobs.petpay") || Perm.hasPermission(pDamager, "jobs.vippetpay")) - PetPayMultiplier = ConfigManager.getJobsConfiguration().VipPetPay; + PetPayMultiplier = Jobs.getGCManager().VipPetPay; else - PetPayMultiplier = ConfigManager.getJobsConfiguration().PetPay; + PetPayMultiplier = Jobs.getGCManager().PetPay; } } } else @@ -909,33 +867,24 @@ public class JobsPaymentListener implements Listener { if (pDamager == null) return; // check if in creative - if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName())) return; - // restricted area multiplier - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(pDamager); - // pay JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager); if (jDamager == null) return; - Double NearSpawnerMultiplier = 1.0; + Double NearSpawnerMultiplier = 0.0; if (lVictim.hasMetadata(mobSpawnerMetadata)) NearSpawnerMultiplier = jDamager.getVipSpawnerMultiplier(); - // Item in hand - ItemStack item = pDamager.getItemInHand().hasItemMeta() ? pDamager.getItemInHand() : null; - - // Wearing armor - ItemStack[] armor = pDamager.getInventory().getArmorContents(); - // Calulating multiplaier - multiplier = multiplier * NearSpawnerMultiplier * PetPayMultiplier; + double multiplier = ((NearSpawnerMultiplier * 100) - 100) + ((PetPayMultiplier * 100) - 100); if (lVictim instanceof Player && !lVictim.hasMetadata("NPC")) { Player VPlayer = (Player) lVictim; @@ -943,20 +892,23 @@ public class JobsPaymentListener implements Listener { return; } - Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), multiplier, item, armor); + Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), multiplier); // Payment for killing player with particular job, except NPC's if (lVictim instanceof Player && !lVictim.hasMetadata("NPC")) { List<JobProgression> jobs = Jobs.getPlayerManager().getJobsPlayer((Player) lVictim).getJobProgression(); if (jobs != null) for (JobProgression job : jobs) { - Jobs.action(jDamager, new CustomKillInfo(job.getJob().getName(), ActionType.CUSTOMKILL), multiplier, item, armor); + Jobs.action(jDamager, new CustomKillInfo(job.getJob().getName(), ActionType.CUSTOMKILL), multiplier); } } } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent event) { + //disabling plugin in world + if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) + return; if (event.getSpawnReason() == SpawnReason.SPAWNER) { LivingEntity creature = (LivingEntity) event.getEntity(); creature.setMetadata(mobSpawnerMetadata, new FixedMetadataValue(plugin, true)); @@ -965,18 +917,20 @@ public class JobsPaymentListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCreatureSpawn(SlimeSplitEvent event) { - + //disabling plugin in world + if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) + return; if (!event.getEntity().hasMetadata(mobSpawnerMetadata)) return; EntityType type = event.getEntityType(); - if (type == EntityType.SLIME && ConfigManager.getJobsConfiguration().PreventSlimeSplit) { + if (type == EntityType.SLIME && Jobs.getGCManager().PreventSlimeSplit) { event.setCancelled(true); return; } - if (type == EntityType.MAGMA_CUBE && ConfigManager.getJobsConfiguration().PreventMagmaCubeSplit) { + if (type == EntityType.MAGMA_CUBE && Jobs.getGCManager().PreventMagmaCubeSplit) { event.setCancelled(true); return; } @@ -984,8 +938,10 @@ public class JobsPaymentListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCreatureBreed(CreatureSpawnEvent event) { - - if (!ConfigManager.getJobsConfiguration().useBreederFinder) + //disabling plugin in world + if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) + return; + if (!Jobs.getGCManager().useBreederFinder) return; SpawnReason reason = event.getSpawnReason(); @@ -1018,32 +974,26 @@ public class JobsPaymentListener implements Listener { if (player != null && closest < 30.0) { // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; - // Item in hand - ItemStack item = player.getItemInHand().hasItemMeta() ? player.getItemInHand() : null; - - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - - // restricted area multiplier - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); // pay JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(player); if (jDamager == null) return; - Jobs.action(jDamager, new EntityActionInfo(animal, ActionType.BREED), multiplier, item, armor); + Jobs.action(jDamager, new EntityActionInfo(animal, ActionType.BREED), 0.0); } } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerEat(FoodLevelChangeEvent event) { - + //disabling plugin in world + if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) + return; // make sure plugin is enabled if (!plugin.isEnabled()) return; @@ -1063,36 +1013,32 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; - // restricted area multiplier - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); - // Item in hand - ItemStack item = player.getItemInHand(); - - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); + ItemStack item = Jobs.getNms().getItemInMainHand(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); if (jPlayer == null) return; - Jobs.action(jPlayer, new ItemActionInfo(item, ActionType.EAT), multiplier, item, armor); + Jobs.action(jPlayer, new ItemActionInfo(item, ActionType.EAT), 0.0); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onTntExplode(EntityExplodeEvent event) { - + //disabling plugin in world + if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) + return; // make sure plugin is enabled if (!plugin.isEnabled()) return; - if (!ConfigManager.getJobsConfiguration().isUseTntFinder()) + if (!Jobs.getGCManager().isUseTntFinder()) return; if (event.getEntityType() != EntityType.PRIMED_TNT && event.getEntityType() != EntityType.MINECART_TNT) @@ -1120,21 +1066,12 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; - // restricted area multiplier - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); - - // Item in hand - ItemStack item = player.getItemInHand(); - - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); if (jPlayer == null) return; @@ -1146,17 +1083,20 @@ public class JobsPaymentListener implements Listener { if (block.getType().equals(Material.FURNACE) && block.hasMetadata(furnaceOwnerMetadata)) block.removeMetadata(furnaceOwnerMetadata, plugin); - if (ConfigManager.getJobsConfiguration().useBlockProtection) + if (Jobs.getGCManager().useBlockProtection) if (block.getState().hasMetadata(BlockMetadata)) return; BlockActionInfo bInfo = new BlockActionInfo(block, ActionType.TNTBREAK); - Jobs.action(jPlayer, bInfo, multiplier, item, armor); + Jobs.action(jPlayer, bInfo, 0.0); } } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { + //disabling plugin in world + if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) + return; if (!plugin.isEnabled()) return; @@ -1179,13 +1119,15 @@ public class JobsPaymentListener implements Listener { @EventHandler public void onExplore(JobsChunkChangeEvent event) { - + //disabling plugin in world + if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) + return; if (!Jobs.getExplore().isExploreEnabled()) return; Player player = (Player) event.getPlayer(); - if (!ConfigManager.getJobsConfiguration().payExploringWhenFlying()) + if (!Jobs.getGCManager().payExploringWhenFlying()) return; ExploreRespond respond = Jobs.getExplore().ChunkRespond(event.getPlayer(), event.getNewChunk()); @@ -1201,25 +1143,16 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; - // restricted area multiplier - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); - - // Item in hand - ItemStack item = player.getItemInHand(); - - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); if (jPlayer == null) return; - Jobs.action(jPlayer, new ExploreActionInfo(String.valueOf(respond.getCount()), ActionType.EXPLORE), multiplier, item, armor); + Jobs.action(jPlayer, new ExploreActionInfo(String.valueOf(respond.getCount()), ActionType.EXPLORE), 0.0); } } diff --git a/com/gamingmesh/jobs/listeners/McMMOlistener.java b/com/gamingmesh/jobs/listeners/McMMOlistener.java index 156e7a20..5fedd4ef 100644 --- a/com/gamingmesh/jobs/listeners/McMMOlistener.java +++ b/com/gamingmesh/jobs/listeners/McMMOlistener.java @@ -12,9 +12,9 @@ import org.bukkit.plugin.Plugin; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.actions.ItemActionInfo; -import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.JobsPlayer; +import com.gmail.nossr50.api.AbilityAPI; import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent; public class McMMOlistener implements Listener { @@ -28,6 +28,9 @@ public class McMMOlistener implements Listener { @EventHandler public void OnItemrepair(McMMOPlayerRepairCheckEvent event) { + //disabling plugin in world + if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) + return; // make sure plugin is enabled if (!plugin.isEnabled()) return; @@ -46,20 +49,36 @@ public class McMMOlistener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; - // Wearing armor - ItemStack[] armor = player.getInventory().getArmorContents(); - - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); - Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR), multiplier, null, armor); + Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR), 0.0); + } + + public static double getMultiplier(Player player) { + if (AbilityAPI.treeFellerEnabled(player)) + return Jobs.getGCManager().TreeFellerMultiplier; + else if (AbilityAPI.gigaDrillBreakerEnabled(player)) + return Jobs.getGCManager().gigaDrillMultiplier; + else if (AbilityAPI.superBreakerEnabled(player)) + return Jobs.getGCManager().superBreakerMultiplier; + return 0.0; } public static boolean CheckmcMMO() { Plugin McMMO = Bukkit.getPluginManager().getPlugin("mcMMO"); if (McMMO != null) { + try { + Class.forName("com.gmail.nossr50.api.AbilityAPI"); + } catch (ClassNotFoundException e) { + // Disabling skill API check; + mcMMOPresent = false; + Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', + "&e[Jobs] &6mcMMO was found - &cBut your McMMO version is outdated, please update for full support.")); + // Still enabling event listener for repair + return true; + } mcMMOPresent = true; Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6mcMMO was found - Enabling capabilities.")); return true; diff --git a/com/gamingmesh/jobs/listeners/MythicMobsListener.java b/com/gamingmesh/jobs/listeners/MythicMobsListener.java index bb0298da..e6173544 100644 --- a/com/gamingmesh/jobs/listeners/MythicMobsListener.java +++ b/com/gamingmesh/jobs/listeners/MythicMobsListener.java @@ -9,31 +9,34 @@ import org.bukkit.entity.Tameable; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.actions.MMKillInfo; -import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.stuff.Perm; + +import net.elseland.xikage.MythicMobs.MythicMobs; +import net.elseland.xikage.MythicMobs.API.MythicMobsAPI; import net.elseland.xikage.MythicMobs.API.Bukkit.Events.MythicMobDeathEvent; import net.elseland.xikage.MythicMobs.Mobs.MythicMob; public class MythicMobsListener implements Listener { private JobsPlugin plugin; - public static boolean Present = false; + public MythicMobsAPI MMAPI = null; public MythicMobsListener(JobsPlugin plugin) { this.plugin = plugin; } @EventHandler - public void OnItemrepair(MythicMobDeathEvent event) { - + public void OnMythicMobDeath(MythicMobDeathEvent event) { + //disabling plugin in world + if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) + return; // Entity that died must be living if (!(event.getEntity() instanceof LivingEntity)) return; @@ -45,7 +48,7 @@ public class MythicMobsListener implements Listener { Player pDamager = null; - Double PetPayMultiplier = 1.0; + Double PetPayMultiplier = 0.0; // Checking if killer is player if (event.getKiller() instanceof Player) pDamager = (Player) event.getKiller(); @@ -56,9 +59,9 @@ public class MythicMobsListener implements Listener { if (t.isTamed() && t.getOwner() instanceof Player) { pDamager = (Player) t.getOwner(); if (Perm.hasPermission(pDamager, "jobs.petpay") || Perm.hasPermission(pDamager, "jobs.vippetpay")) - PetPayMultiplier = ConfigManager.getJobsConfiguration().VipPetPay; + PetPayMultiplier = Jobs.getGCManager().VipPetPay; else - PetPayMultiplier = ConfigManager.getJobsConfiguration().PetPay; + PetPayMultiplier = Jobs.getGCManager().PetPay; } } } else @@ -67,40 +70,40 @@ public class MythicMobsListener implements Listener { if (pDamager == null) return; // check if in creative - if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) + if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName())) return; - // restricted area multiplier - double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(pDamager); - // pay JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager); if (jDamager == null) return; - // Item in hand - ItemStack item = pDamager.getItemInHand().hasItemMeta() ? pDamager.getItemInHand() : null; - - // Wearing armor - ItemStack[] armor = pDamager.getInventory().getArmorContents(); - - // Calulating multiplaier - multiplier = multiplier * PetPayMultiplier; - - Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), multiplier, item, armor); + Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), PetPayMultiplier); } - public static boolean Check() { + public boolean Check() { Plugin mm = Bukkit.getPluginManager().getPlugin("MythicMobs"); - if (mm != null) { - Present = true; - Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6MythicMobs was found - Enabling capabilities.")); - return true; + if (mm == null) + return false; + + try { + Class.forName("net.elseland.xikage.MythicMobs.API.Bukkit.Events.MythicMobDeathEvent"); + Class.forName("net.elseland.xikage.MythicMobs.API.MythicMobsAPI"); + Class.forName("net.elseland.xikage.MythicMobs.Mobs.MythicMob"); + } catch (ClassNotFoundException e) { + // Disabling + Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', + "&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support.")); + return false; } - return false; + + MMAPI = ((MythicMobs) mm).getAPI(); + Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6MythicMobs was found - Enabling capabilities.")); + return true; + } } diff --git a/com/gamingmesh/jobs/listeners/PistonProtectionListener.java b/com/gamingmesh/jobs/listeners/PistonProtectionListener.java index 88e52950..39402089 100644 --- a/com/gamingmesh/jobs/listeners/PistonProtectionListener.java +++ b/com/gamingmesh/jobs/listeners/PistonProtectionListener.java @@ -10,10 +10,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; +import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.JobsPlugin; -import com.gamingmesh.jobs.config.ConfigManager; -import com.gamingmesh.jobs.i18n.Language; -import com.gamingmesh.jobs.stuff.ActionBar; public class PistonProtectionListener implements Listener { @@ -26,7 +24,7 @@ public class PistonProtectionListener implements Listener { @SuppressWarnings("deprecation") public static boolean CheckBlock(Block block) { - for (String BlockId : ConfigManager.getJobsConfiguration().restrictedBlocks) { + for (String BlockId : Jobs.getRestrictedBlockManager().restrictedBlocks) { if (BlockId.equalsIgnoreCase(String.valueOf(block.getTypeId()))) { return true; } @@ -36,7 +34,7 @@ public class PistonProtectionListener implements Listener { @SuppressWarnings("deprecation") public static boolean CheckPlaceBlock(Block block) { - for (int BlockId : ConfigManager.getJobsConfiguration().restrictedPlaceBlocksTimer) { + for (int BlockId : Jobs.getRestrictedBlockManager().restrictedPlaceBlocksTimer) { if (BlockId == block.getTypeId()) { return true; } @@ -46,7 +44,7 @@ public class PistonProtectionListener implements Listener { @SuppressWarnings("deprecation") public static boolean CheckVegy(Block block) { - for (String ConfigOneBlock : ConfigManager.getJobsConfiguration().restrictedBlocksTimer) { + for (String ConfigOneBlock : Jobs.getRestrictedBlockManager().restrictedBlocksTimer) { int ConfigPlacedBlockId = Integer.valueOf(ConfigOneBlock.split("-")[0]); if (block.getTypeId() == ConfigPlacedBlockId) { return true; @@ -57,7 +55,7 @@ public class PistonProtectionListener implements Listener { @SuppressWarnings("deprecation") public static boolean checkVegybreak(Block block, Player player) { - for (String ConfigOneBlock : ConfigManager.getJobsConfiguration().restrictedBlocksTimer) { + for (String ConfigOneBlock : Jobs.getRestrictedBlockManager().restrictedBlocksTimer) { int ConfigPlacedBlockId = Integer.valueOf(ConfigOneBlock.split("-")[0]); if (block.getTypeId() == ConfigPlacedBlockId) { if (CheckVegyTimer(block, Integer.valueOf(ConfigOneBlock.split("-")[1]), player)) { @@ -80,16 +78,19 @@ public class PistonProtectionListener implements Listener { int sec = Math.round((((BlockTime + time * 1000) - currentTime)) / 1000); - ActionBar.send(player, Language.getMessage("message.blocktimer").replace("[time]", String.valueOf(sec))); + Jobs.getActionBar().send(player, Jobs.getLanguage().getMessage("message.blocktimer", "[time]", sec)); return true; } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public static void OnBlockMove(BlockPistonExtendEvent event) { + //disabling plugin in world + if (event.getBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) + return; if (event.isCancelled()) return; - if (!ConfigManager.getJobsConfiguration().useBlockPiston) + if (!Jobs.getGCManager().useBlockPiston) return; List<Block> block = event.getBlocks(); @@ -103,14 +104,16 @@ public class PistonProtectionListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void OnBlockRetractMove(BlockPistonRetractEvent event) { - + //disabling plugin in world + if (event.getBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) + return; if (event.isCancelled()) return; - if (!ConfigManager.getJobsConfiguration().useBlockPiston) + if (!Jobs.getGCManager().useBlockPiston) return; - List<Block> block = JobsPlugin.getNms().getPistonRetractBlocks(event); + List<Block> block = Jobs.getNms().getPistonRetractBlocks(event); for (Block OneBlock : block) { if (CheckBlock(OneBlock)) { event.setCancelled(true); diff --git a/com/gamingmesh/jobs/nmsUtil/v1_7.java b/com/gamingmesh/jobs/nmsUtil/v1_7.java index 30d18033..deceac83 100644 --- a/com/gamingmesh/jobs/nmsUtil/v1_7.java +++ b/com/gamingmesh/jobs/nmsUtil/v1_7.java @@ -4,7 +4,9 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.block.Block; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.event.block.BlockPistonRetractEvent; +import org.bukkit.inventory.ItemStack; import com.gamingmesh.jobs.NMS; @@ -20,4 +22,10 @@ public class v1_7 implements NMS { public boolean isElderGuardian(Entity entity) { return false; } + + @SuppressWarnings("deprecation") + @Override + public ItemStack getItemInMainHand(Player player) { + return player.getInventory().getItemInHand(); + } } diff --git a/com/gamingmesh/jobs/nmsUtil/v1_8.java b/com/gamingmesh/jobs/nmsUtil/v1_8.java index 680dbf81..3d71cc4a 100644 --- a/com/gamingmesh/jobs/nmsUtil/v1_8.java +++ b/com/gamingmesh/jobs/nmsUtil/v1_8.java @@ -5,7 +5,9 @@ import java.util.List; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.Guardian; +import org.bukkit.entity.Player; import org.bukkit.event.block.BlockPistonRetractEvent; +import org.bukkit.inventory.ItemStack; import com.gamingmesh.jobs.NMS; @@ -26,5 +28,9 @@ public class v1_8 implements NMS { } return false; } - + @SuppressWarnings("deprecation") + @Override + public ItemStack getItemInMainHand(Player player) { + return player.getInventory().getItemInHand(); + } } diff --git a/com/gamingmesh/jobs/nmsUtil/v1_9.class b/com/gamingmesh/jobs/nmsUtil/v1_9.class index d3b7976b2866d83c89ae5acfce0a04b913fe5db0..f373a3ee4882c6da4df28fa85da8bf49118d1a5a 100644 GIT binary patch delta 431 zcmZ`#OHRUI5dNlZsMLa~2qMM}F$Q(fg~nG=@hyoaCU}9W4QVPxn~LemL;M%fm8lEk z(s&tfKpbcUHf(0{WxmJEylZhr`{{ms0$9V@oAxE=jiwXUL#I{uFKyR9xBWXpRT%Qj z%hkOdIf1o&(GHsC&6DT3q3QY^#}C^<WcD<T(7yGoNo>PXu|p`1Fq!6tk(rq2sA89( z_p<&S2$jkh@4l!N45%Ejj{_Ao!s1B8aG4}!z}K;XLqd6+|8RFg>Y;z8c$5ojVq=MK zd5IM9E3Z&il$7hVfeB0_hn#p;Iz|yH=Afg5JmxWr1<_U38=D}c`L8wZ5_f$y#ug#Q i9^sX-#0ntAQ=p6t*FwTW7E_E^fg>FAoN&TO!s#EPjc+sn delta 77 zcmdnVyPb>c)W2Q(7#J9g87ww(9blgPk41%%d9pIA79-DOKh_XVeg+N(0R~|P!O5#x g%LK(3*crqbco-xYL>VN3Ea}NcY$mJ>3``8>0QP<kw*UYD diff --git a/com/gamingmesh/jobs/nmsUtil/v1_9.java b/com/gamingmesh/jobs/nmsUtil/v1_9.java index 516619de..ece9a27f 100644 --- a/com/gamingmesh/jobs/nmsUtil/v1_9.java +++ b/com/gamingmesh/jobs/nmsUtil/v1_9.java @@ -5,7 +5,9 @@ import java.util.List; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.Guardian; +import org.bukkit.entity.Player; import org.bukkit.event.block.BlockPistonRetractEvent; +import org.bukkit.inventory.ItemStack; import com.gamingmesh.jobs.NMS; @@ -26,5 +28,10 @@ public class v1_9 implements NMS { } return false; } + + @Override + public ItemStack getItemInMainHand(Player player) { + return player.getInventory().getItemInMainHand(); + } } diff --git a/com/gamingmesh/jobs/stuff/.gitignore b/com/gamingmesh/jobs/stuff/.gitignore index dcf06ebb..289813ad 100644 --- a/com/gamingmesh/jobs/stuff/.gitignore +++ b/com/gamingmesh/jobs/stuff/.gitignore @@ -29,3 +29,5 @@ /OfflinePlayerList.class /OfflinePlayerList$1.class /Explore.class +/BossBarManager.class +/BossBarManager$1.class diff --git a/com/gamingmesh/jobs/stuff/ActionBar.java b/com/gamingmesh/jobs/stuff/ActionBar.java index 729daed3..d9a38004 100644 --- a/com/gamingmesh/jobs/stuff/ActionBar.java +++ b/com/gamingmesh/jobs/stuff/ActionBar.java @@ -10,26 +10,30 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.config.ConfigManager; import com.gamingmesh.jobs.economy.BufferedPayment; -import com.gamingmesh.jobs.i18n.Language; /** * * @author hamzaxx */ public class ActionBar { - private static int cleanVersion = 1820; - private static String version = ""; - private static Object packet; - private static Method getHandle; - private static Method sendPacket; - private static Field playerConnection; - private static Class<?> nmsChatSerializer; - private static Class<?> nmsIChatBaseComponent; - private static Class<?> packetType; + private int cleanVersion = -1; + private String version = ""; + private Object packet; + private Method getHandle; + private Method sendPacket; + private Field playerConnection; + private Class<?> nmsChatSerializer; + private Class<?> nmsIChatBaseComponent; + private Class<?> packetType; - static { + public int getVersion() { + if (cleanVersion == -1) + getInfo(); + return cleanVersion; + } + + private void getInfo() { try { version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; @@ -52,8 +56,14 @@ public class ActionBar { cleanVersion = 1820; if (version.contains("v1_8_R3")) cleanVersion = 1830; + if (version.contains("v1_9_R1")) + cleanVersion = 1910; + if (version.contains("v1_9_R2")) + cleanVersion = 1920; } + if (cleanVersion < 100) + cleanVersion = cleanVersion * 10; if (cleanVersion < 1000) cleanVersion = cleanVersion * 10; @@ -72,29 +82,42 @@ public class ActionBar { } } - public static void ShowActionBar(BufferedPayment payment) { - String playername = payment.getOfflinePlayer().getName(); - if (!Jobs.actionbartoggle.containsKey(playername) && ConfigManager.getJobsConfiguration().JobsToggleEnabled) - Jobs.actionbartoggle.put(playername, true); + public void ShowActionBar(BufferedPayment payment) { + Debug.D("show action bar"); + if (cleanVersion == -1) + getInfo(); + + if (cleanVersion == -1) + return; + + String playername = payment.getOfflinePlayer().getName(); + if (!Jobs.getActionbarToggleList().containsKey(playername) && Jobs.getGCManager().ActionBarsMessageByDefault) + Jobs.getActionbarToggleList().put(playername, true); + + if (playername == null) return; - if (!Jobs.actionbartoggle.containsKey(playername)) + if (!Jobs.getActionbarToggleList().containsKey(playername)) return; - Boolean show = Jobs.actionbartoggle.get(playername); - Player abp = (Player) payment.getOfflinePlayer(); - if (abp != null && show) { - String Message = Language.getMessage("command.toggle.output.paid"); - Message = Message.replace("[amount]", String.format("%.2f", payment.getAmount())); - Message = Message.replace("[exp]", String.format("%.2f", payment.getExp())); - ActionBar.send(abp, ChatColor.GREEN + Message); - } + Boolean show = Jobs.getActionbarToggleList().get(playername); + Player abp = Bukkit.getPlayer(payment.getOfflinePlayer().getUniqueId()); + if (abp != null && show) { + String Message = Jobs.getLanguage().getMessage("command.toggle.output.paid.main"); + if (payment.getAmount() != 0D) + Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.money", "[amount]", String.format("%.2f", payment.getAmount())); + if (payment.getPoints() != 0D) + Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.points", "[points]", String.format("%.2f", payment.getPoints())); + if (payment.getExp() != 0D) + Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.exp", "[exp]", String.format("%.2f", payment.getExp())); + send(abp, ChatColor.GREEN + Message); + } } - public static void send(Player receivingPacket, String msg) { + public void send(Player receivingPacket, String msg) { try { if (msg == null || nmsChatSerializer == null) return; @@ -113,41 +136,32 @@ public class ActionBar { Object player = getHandle.invoke(receivingPacket); Object connection = playerConnection.get(player); sendPacket.invoke(connection, packet); - } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException ex) { - Bukkit.getLogger().log(Level.SEVERE, "Error {0}", ex); - } - - try { - Object player = getHandle.invoke(receivingPacket); - Object connection = playerConnection.get(player); - sendPacket.invoke(connection, packet); - } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { + } catch (SecurityException | IllegalArgumentException | IllegalAccessException | InvocationTargetException | InstantiationException | NoSuchMethodException ex) { Bukkit.getLogger().log(Level.SEVERE, "Error {0}", ex); } } - private static String getCraftPlayerClasspath() { + private String getCraftPlayerClasspath() { return "org.bukkit.craftbukkit." + version + ".entity.CraftPlayer"; } - private static String getPlayerConnectionClasspath() { + private String getPlayerConnectionClasspath() { return "net.minecraft.server." + version + ".PlayerConnection"; } - private static String getNMSPlayerClasspath() { + private String getNMSPlayerClasspath() { return "net.minecraft.server." + version + ".EntityPlayer"; } - private static String getPacketClasspath() { + private String getPacketClasspath() { return "net.minecraft.server." + version + ".Packet"; } - private static String getIChatBaseComponentClasspath() { + private String getIChatBaseComponentClasspath() { return "net.minecraft.server." + version + ".IChatBaseComponent"; } - private static String getChatSerializerClasspath() { - + private String getChatSerializerClasspath() { if (cleanVersion < 1820) { return "net.minecraft.server." + version + ".ChatSerializer"; } else { @@ -155,7 +169,7 @@ public class ActionBar { } } - private static String getPacketPlayOutChat() { + private String getPacketPlayOutChat() { return "net.minecraft.server." + version + ".PacketPlayOutChat"; } } \ No newline at end of file diff --git a/com/gamingmesh/jobs/stuff/ChatColor.java b/com/gamingmesh/jobs/stuff/ChatColor.java index b180cdd5..246069a7 100644 --- a/com/gamingmesh/jobs/stuff/ChatColor.java +++ b/com/gamingmesh/jobs/stuff/ChatColor.java @@ -22,7 +22,22 @@ import java.util.HashMap; import java.util.Map; public enum ChatColor { - BLACK('0', 0), DARK_BLUE('1', 1), DARK_GREEN('2', 2), DARK_AQUA('3', 3), DARK_RED('4', 4), DARK_PURPLE('5', 5), GOLD('6', 6), GRAY('7', 7), DARK_GRAY('8', 8), BLUE('9', 9), GREEN('a', 10), AQUA('b', 11), RED('c', 12), LIGHT_PURPLE('d', 13), YELLOW('e', 14), WHITE('f', 15); + BLACK('0', 0), + DARK_BLUE('1', 1), + DARK_GREEN('2', 2), + DARK_AQUA('3', 3), + DARK_RED('4', 4), + DARK_PURPLE('5', 5), + GOLD('6', 6), + GRAY('7', 7), + DARK_GRAY('8', 8), + BLUE('9', 9), + GREEN('a', 10), + AQUA('b', 11), + RED('c', 12), + LIGHT_PURPLE('d', 13), + YELLOW('e', 14), + WHITE('f', 15); private static final char COLOR_CHAR = '\u00A7'; private final char code; diff --git a/com/gamingmesh/jobs/stuff/FileDownloader.java b/com/gamingmesh/jobs/stuff/FileDownloader.java deleted file mode 100644 index cd4158c9..00000000 --- a/com/gamingmesh/jobs/stuff/FileDownloader.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Jobs Plugin for Bukkit - * Copyright (C) 2011 Zak Ford <zak.j.ford@gmail.com> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.gamingmesh.jobs.stuff; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.URL; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; - -public class FileDownloader { - public static void downloadFile(URL url, File file) throws IOException { - ReadableByteChannel rbc = Channels.newChannel(url.openStream()); - FileOutputStream fos = new FileOutputStream(file); - fos.getChannel().transferFrom(rbc, 0, 1 << 24); - fos.close(); - } -} diff --git a/com/gamingmesh/jobs/stuff/Loging.java b/com/gamingmesh/jobs/stuff/Loging.java index 91d5b7cf..e0eca796 100644 --- a/com/gamingmesh/jobs/stuff/Loging.java +++ b/com/gamingmesh/jobs/stuff/Loging.java @@ -17,9 +17,9 @@ public class Loging { List<Log> logList = jPlayer.getLog(); boolean found = false; - if (jPlayer.getLog().size() > 0 && Jobs.getSchedule().getDateByInt() != jPlayer.getLog().get(0).getDate()) { - Jobs.getSchedule().setDateByInt(TimeManage.timeInInt()); - if (Jobs.getSchedule().getDateByInt() != jPlayer.getLog().get(0).getDate()) { + if (jPlayer.getLog().size() > 0 && Jobs.getScheduleManager().getDateByInt() != jPlayer.getLog().get(0).getDate()) { + Jobs.getScheduleManager().setDateByInt(TimeManage.timeInInt()); + if (Jobs.getScheduleManager().getDateByInt() != jPlayer.getLog().get(0).getDate()) { Jobs.getJobsDAO().saveLog(jPlayer); jPlayer.getLog().clear(); } diff --git a/com/gamingmesh/jobs/stuff/OfflinePlayerList.java b/com/gamingmesh/jobs/stuff/OfflinePlayerList.java deleted file mode 100644 index 996dc2ca..00000000 --- a/com/gamingmesh/jobs/stuff/OfflinePlayerList.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.gamingmesh.jobs.stuff; - -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; - -import com.gamingmesh.jobs.config.ConfigManager; - -public class OfflinePlayerList { - - private static ConcurrentHashMap<String, OfflinePlayer> map = new ConcurrentHashMap<String, OfflinePlayer>(); - private static ConcurrentHashMap<UUID, OfflinePlayer> uuidmap = new ConcurrentHashMap<UUID, OfflinePlayer>(); - - public static void fillList() { - for (OfflinePlayer one : Bukkit.getOfflinePlayers()) { - if (one == null) - continue; - if (one.getName() == null) - continue; - if (one.getUniqueId() == null) - continue; - map.put(one.getName().toLowerCase(), one); - uuidmap.put(one.getUniqueId(), one); - } - return; - } - - public static OfflinePlayer getPlayer(UUID uuid) { - if (!ConfigManager.getJobsConfiguration().LocalOfflinePlayersData) - return Bukkit.getOfflinePlayer(uuid); - - if (uuidmap.containsKey(uuid)) - return uuidmap.get(uuid); - return null; - } - - @SuppressWarnings("deprecation") - public static OfflinePlayer getPlayer(String name) { - if (!ConfigManager.getJobsConfiguration().LocalOfflinePlayersData) - return Bukkit.getOfflinePlayer(name); - - if (map.containsKey(name.toLowerCase())) - return map.get(name.toLowerCase()); - return null; - } - - public static void addPlayer(OfflinePlayer player) { - map.put(player.getName().toLowerCase(), player); - uuidmap.put(player.getUniqueId(), player); - } - -} diff --git a/com/gamingmesh/jobs/stuff/PerformCommands.java b/com/gamingmesh/jobs/stuff/PerformCommands.java index 8b7f0c05..736fc467 100644 --- a/com/gamingmesh/jobs/stuff/PerformCommands.java +++ b/com/gamingmesh/jobs/stuff/PerformCommands.java @@ -1,33 +1,33 @@ -package com.gamingmesh.jobs.stuff; - -import java.util.List; - -import org.bukkit.Bukkit; - -import com.gamingmesh.jobs.container.Job; -import com.gamingmesh.jobs.container.JobsPlayer; - -public class PerformCommands { - - public static void PerformCommandsOnLeave(JobsPlayer jPlayer, Job job) { - - List<String> cmds = job.getCmdOnLeave(); - if (cmds.size() == 0) - return; - - for (String one : cmds) { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", jPlayer.getUserName()).replace("[jobname]", job.getName())); - } - } - - public static void PerformCommandsOnJoin(JobsPlayer jPlayer, Job job) { - - List<String> cmds = job.getCmdOnJoin(); - if (cmds.size() == 0) - return; - - for (String one : cmds) { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", jPlayer.getUserName()).replace("[jobname]", job.getName())); - } - } -} +package com.gamingmesh.jobs.stuff; + +import java.util.List; + +import org.bukkit.Bukkit; + +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobsPlayer; + +public class PerformCommands { + + public static void PerformCommandsOnLeave(JobsPlayer jPlayer, Job job) { + + List<String> cmds = job.getCmdOnLeave(); + if (cmds.size() == 0) + return; + + for (String one : cmds) { + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", jPlayer.getUserName()).replace("[jobname]", job.getName())); + } + } + + public static void PerformCommandsOnJoin(JobsPlayer jPlayer, Job job) { + + List<String> cmds = job.getCmdOnJoin(); + if (cmds.size() == 0) + return; + + for (String one : cmds) { + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", jPlayer.getUserName()).replace("[jobname]", job.getName())); + } + } +} diff --git a/com/gamingmesh/jobs/stuff/Perm.java b/com/gamingmesh/jobs/stuff/Perm.java index a4005ce0..2dfc45f3 100644 --- a/com/gamingmesh/jobs/stuff/Perm.java +++ b/com/gamingmesh/jobs/stuff/Perm.java @@ -1,25 +1,25 @@ -package com.gamingmesh.jobs.stuff; - -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.permissions.Permission; -import org.bukkit.permissions.PermissionDefault; - -public class Perm { - public static boolean hasPermission(OfflinePlayer player, String permission) { - Permission p = new Permission(permission, PermissionDefault.FALSE); - return ((Player) player).hasPermission(p); - } - - public static boolean hasPermission(CommandSender player, String permission) { - if (player instanceof Player) - return hasPermission((Player) player, permission); - return true; - } - - public static boolean hasPermission(Player player, String permission) { - Permission p = new Permission(permission, PermissionDefault.FALSE); - return player.hasPermission(p); - } -} +package com.gamingmesh.jobs.stuff; + +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; + +public class Perm { + public static boolean hasPermission(OfflinePlayer player, String permission) { + Permission p = new Permission(permission, PermissionDefault.FALSE); + return ((Player) player).hasPermission(p); + } + + public static boolean hasPermission(CommandSender player, String permission) { + if (player instanceof Player) + return hasPermission((Player) player, permission); + return true; + } + + public static boolean hasPermission(Player player, String permission) { + Permission p = new Permission(permission, PermissionDefault.FALSE); + return player.hasPermission(p); + } +} diff --git a/com/gamingmesh/jobs/stuff/ScheduleUtil.java b/com/gamingmesh/jobs/stuff/ScheduleUtil.java deleted file mode 100644 index b3d4020d..00000000 --- a/com/gamingmesh/jobs/stuff/ScheduleUtil.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.gamingmesh.jobs.stuff; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -import org.bukkit.Bukkit; - -import com.gamingmesh.jobs.JobsPlugin; -import com.gamingmesh.jobs.config.ConfigManager; -import com.gamingmesh.jobs.container.Job; -import com.gamingmesh.jobs.container.Schedule; -import com.gamingmesh.jobs.i18n.Language; - -public class ScheduleUtil { - - public int dateByInt = 0; - - private JobsPlugin plugin; - - public ScheduleUtil() { - } - - public ScheduleUtil(JobsPlugin plugin) { - this.plugin = plugin; - } - - public int getDateByInt(){ - return dateByInt; - } - public void setDateByInt(int time){ - dateByInt = time; - } - - public void DateUpdater() { - if (dateByInt == 0) - dateByInt = TimeManage.timeInInt(); - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - public void run() { - - dateByInt = TimeManage.timeInInt(); - - DateUpdater(); - return; - } - }, 60 * 20L); - } - - public boolean scheduler() { - if (ConfigManager.getJobsConfiguration().BoostSchedule.size() > 0 && ConfigManager.getJobsConfiguration().useGlobalBoostScheduler) { - - DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); - Date date = new Date(); - - String currenttime = dateFormat.format(date); - - int Current = Integer.valueOf(currenttime.replace(":", "")).intValue(); - - String CurrentDayName = GetWeekDay(); - - for (Schedule one : ConfigManager.getJobsConfiguration().BoostSchedule) { - - int From = one.GetFrom(); - int Until = one.GetUntil(); - - List<String> days = one.GetDays(); - - if (one.isStarted() && one.getBroadcastInfoOn() < System.currentTimeMillis() && one.GetBroadcastInterval() > 0) { - one.setBroadcastInfoOn(System.currentTimeMillis() + one.GetBroadcastInterval() * 60 * 1000); - for (String oneMsg : one.GetMessageToBroadcast()) { - Bukkit.broadcastMessage(oneMsg); - } - } - - if (((one.isNextDay() && (Current >= From && Current < one.GetUntil() || Current >= one.GetNextFrom() && Current < one.GetNextUntil()) && !one - .isStarted()) || !one.isNextDay() && (Current >= From && Current < Until)) && (days.contains(CurrentDayName) || days.contains("all")) && !one - .isStarted()) { - - if (one.isBroadcastOnStart()) - if (one.GetMessageOnStart().size() == 0) - Bukkit.broadcastMessage(Language.getMessage("message.boostStarted")); - else - for (String oneMsg : one.GetMessageOnStart()) { - Bukkit.broadcastMessage(oneMsg); - } - - for (Job onejob : one.GetJobs()) { - onejob.setExpBoost(one.GetExpBoost()); - onejob.setMoneyBoost(one.GetMoneyBoost()); - } - - one.setBroadcastInfoOn(System.currentTimeMillis() + one.GetBroadcastInterval() * 60 * 1000); - - one.setStarted(true); - one.setStoped(false); - break; - } else if (((one.isNextDay() && Current > one.GetNextUntil() && Current < one.GetFrom() && !one.isStoped()) || !one.isNextDay() && Current > Until - && ((days.contains(CurrentDayName)) || days.contains("all"))) && !one.isStoped()) { - if (one.isBroadcastOnStop()) - if (one.GetMessageOnStop().size() == 0) - Bukkit.broadcastMessage(Language.getMessage("message.boostStoped")); - else - for (String oneMsg : one.GetMessageOnStop()) { - Bukkit.broadcastMessage(oneMsg); - } - for (Job onejob : one.GetJobs()) { - onejob.setExpBoost(1.0); - onejob.setMoneyBoost(1.0); - } - one.setStoped(true); - one.setStarted(false); - } - - } - - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - public void run() { - scheduler(); - return; - } - }, 30 * 20L); - } - return true; - } - - public static String GetWeekDay() { - Calendar c = Calendar.getInstance(); - int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); - switch (dayOfWeek) { - case 2: - return "monday"; - case 3: - return "tuesday"; - case 4: - return "wednesday"; - case 5: - return "thursday"; - case 6: - return "friday"; - case 7: - return "saturday"; - case 1: - return "sunday"; - } - return "all"; - } -} diff --git a/com/gamingmesh/jobs/stuff/TabComplete.java b/com/gamingmesh/jobs/stuff/TabComplete.java index 4c027d0e..7c0de9a6 100644 --- a/com/gamingmesh/jobs/stuff/TabComplete.java +++ b/com/gamingmesh/jobs/stuff/TabComplete.java @@ -1,90 +1,109 @@ -package com.gamingmesh.jobs.stuff; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabCompleter; -import org.bukkit.entity.Player; -import org.bukkit.util.StringUtil; - -import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.container.ActionType; -import com.gamingmesh.jobs.container.Job; -import com.gamingmesh.jobs.container.JobItems; -import com.gamingmesh.jobs.i18n.Language; - -public class TabComplete implements TabCompleter { - - private static final List<String> BaseCommands = new ArrayList<>(Arrays.asList("Convert", "Limit", "Join", "Transfer", "Info", "Top", "Gtop", "Reload", "Removexp", "Leaveall", "Promote", "Browse", "Playerinfo", "Fireall", "Demote", "Grantxp", "Employ", "Fire", "Give", "Leave", "Stats", "Toggle", "Boost", "Archive")); - - @Override - public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { - List<String> completionList = new ArrayList<>(); - - if (args.length == 1) { - String PartOfCommand = args[0]; - List<String> temp = new ArrayList<String>(); - - for (String BCmd : BaseCommands) { - if (sender.hasPermission("jobs.command." + BCmd.toLowerCase())) { - temp.add(BCmd); - } - } - StringUtil.copyPartialMatches(PartOfCommand, temp, completionList); - } - if (args.length > 1) - for (int i = 1; i <= args.length; i++) - if (args.length == i + 1) { - - String PartOfCommand = args[i]; - String CommandArgs = Language.getDefaultMessage("command." + args[0].toLowerCase() + ".help.args"); - List<String> ArgsList = new ArrayList<String>(); - - if (!CommandArgs.contains(" ")) { - ArgsList.add(CommandArgs); - } else { - ArgsList.addAll(Arrays.asList(CommandArgs.split(" "))); - } - - if (ArgsList.size() < i) - continue; - - String arg = ArgsList.get(i - 1); - List<String> temp = new ArrayList<String>(); - if (arg.equalsIgnoreCase("[jobname]") || arg.equalsIgnoreCase("[oldjob]") || arg.equalsIgnoreCase("[newjob]")) { - List<Job> Jobsai = Jobs.getJobs(); - for (Job one : Jobsai) { - temp.add(one.getName()); - } - } - - if (arg.equalsIgnoreCase("[playername]")) { - for (Player player : Bukkit.getOnlinePlayers()) { - temp.add(player.getName()); - } - } - - if (arg.equalsIgnoreCase("[action]")) { - for (ActionType action : ActionType.values()) { - temp.add(action.getName()); - } - } - - if (arg.equalsIgnoreCase("[itemname]")) { - Job Jobsai = Jobs.getJob(args[i - 1]); - if (Jobsai != null) - for (JobItems item : Jobsai.getItems()) { - temp.add(item.getNode()); - } - } - StringUtil.copyPartialMatches(PartOfCommand, temp, completionList); - } - Collections.sort(completionList); - return completionList; - } -} +package com.gamingmesh.jobs.stuff; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map.Entry; + +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.command.TabCompleter; +import org.bukkit.entity.Player; +import org.bukkit.util.StringUtil; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.container.ActionType; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobItems; +import com.gamingmesh.jobs.container.JobProgression; +import com.gamingmesh.jobs.container.JobsPlayer; + +public class TabComplete implements TabCompleter { + + @Override + public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { + List<String> completionList = new ArrayList<>(); + + if (args.length == 1) { + String PartOfCommand = args[0]; + List<String> temp = new ArrayList<String>(); + + for (Entry<String, Integer> BCmd : Jobs.getCommandManager().GetCommands(sender).entrySet()) { + temp.add(BCmd.getKey()); + } + StringUtil.copyPartialMatches(PartOfCommand, temp, completionList); + } + if (args.length > 1) + for (int i = 1; i <= args.length; i++) + if (args.length == i + 1) { + + String PartOfCommand = args[i]; + + if (!Jobs.getGCManager().getCommandArgs().containsKey(args[0].toLowerCase())) + break; + + List<String> ArgsList = Jobs.getGCManager().getCommandArgs().get(args[0].toLowerCase()); + + if (ArgsList.size() < i) + continue; + + String arg = ArgsList.get(i - 1); + List<String> temp = new ArrayList<String>(); + + if (arg.contains("%%")) + for (String one : arg.split("%%")) { + temp.add(one); + } + + switch (arg) { + case "[jobname]": + List<Job> Jobsai = Jobs.getJobs(); + for (Job one : Jobsai) { + temp.add(one.getName()); + } + break; + case "[playername]": + for (Player player : Bukkit.getOnlinePlayers()) { + temp.add(player.getName()); + } + break; + case "[action]": + for (ActionType action : ActionType.values()) { + temp.add(action.getName()); + } + break; + case "[jobitemname]": + Job oneJob = Jobs.getJob(args[i - 1]); + if (oneJob != null) + for (JobItems item : oneJob.getItems()) { + temp.add(item.getNode()); + } + break; + case "[oldjob]": + JobsPlayer onePlayerJob = Jobs.getPlayerManager().getJobsPlayer(args[i - 1]); + if (onePlayerJob != null) + for (JobProgression oneOldJob : onePlayerJob.getJobProgression()) { + temp.add(oneOldJob.getJob().getName()); + } + break; + case "[oldplayerjob]": + if (sender instanceof Player) { + onePlayerJob = Jobs.getPlayerManager().getJobsPlayer((Player) sender); + if (onePlayerJob != null) + for (JobProgression oneOldJob : onePlayerJob.getJobProgression()) { + temp.add(oneOldJob.getJob().getName()); + } + } + break; + } + + StringUtil.copyPartialMatches(PartOfCommand, temp, completionList); + } + + if (completionList.isEmpty()) + Jobs.getCommandManager().sendUsage(sender, args[0].toLowerCase()); + Collections.sort(completionList); + return completionList; + } +} diff --git a/com/gamingmesh/jobs/stuff/TranslateName.java b/com/gamingmesh/jobs/stuff/TranslateName.java deleted file mode 100644 index 09431ac4..00000000 --- a/com/gamingmesh/jobs/stuff/TranslateName.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.gamingmesh.jobs.stuff; - -import com.gamingmesh.jobs.config.ConfigManager; -import com.gamingmesh.jobs.container.JobInfo; -import com.gamingmesh.jobs.container.NameList; - -public class TranslateName { - - public static String Translate(String materialName, JobInfo info) { - - // Translating name to user friendly - if (ConfigManager.getJobsConfiguration().UseCustomNames) - switch (info.getActionType()) { - case BREAK: - case TNTBREAK: - case EAT: - case CRAFT: - case DYE: - case PLACE: - case SMELT: - case REPAIR: - case BREW: - case FISH: - for (NameList one : ConfigManager.getJobsConfiguration().ListOfNames) { - String ids = one.getId() + ":" + one.getMeta(); - if (!one.getMeta().equalsIgnoreCase("") && ids.equalsIgnoreCase(info.getId() + ":" + info.getMeta()) && !one.getId().equalsIgnoreCase("0")) { - return one.getName(); - } - } - for (NameList one : ConfigManager.getJobsConfiguration().ListOfNames) { - String ids = one.getId(); - if (ids.equalsIgnoreCase(String.valueOf(info.getId())) && !one.getId().equalsIgnoreCase("0")) { - return one.getName(); - } - } - break; - case BREED: - case KILL: - case MILK: - case TAME: - for (NameList one : ConfigManager.getJobsConfiguration().ListOfEntities) { - String ids = one.getId() + ":" + one.getMeta(); - if (!one.getMeta().equalsIgnoreCase("") && ids.equalsIgnoreCase(info.getId() + ":" + info.getMeta()) && !one.getId().equalsIgnoreCase("0")) { - return one.getName(); - } - } - for (NameList one : ConfigManager.getJobsConfiguration().ListOfEntities) { - String ids = one.getId(); - if (ids.equalsIgnoreCase(String.valueOf(info.getId())) && !one.getId().equalsIgnoreCase("0")) { - return materialName = one.getName(); - } - } - break; - case ENCHANT: - for (NameList one : ConfigManager.getJobsConfiguration().ListOfEnchants) { - String ids = one.getId(); - if (ids.equalsIgnoreCase(String.valueOf(info.getId()))) { - return one.getName() + " " + info.getMeta(); - } - } - for (NameList one : ConfigManager.getJobsConfiguration().ListOfNames) { - String ids = one.getId() + ":" + one.getMeta(); - if (!one.getMeta().equalsIgnoreCase("") && ids.equalsIgnoreCase(info.getId() + ":" + info.getMeta()) && !one.getId().equalsIgnoreCase("0")) { - return one.getName(); - } - } - for (NameList one : ConfigManager.getJobsConfiguration().ListOfNames) { - String ids = one.getId(); - if (ids.equalsIgnoreCase(String.valueOf(info.getId())) && !one.getId().equalsIgnoreCase("0")) { - return one.getName(); - } - } - break; - case CUSTOMKILL: - case MMKILL: - case EXPLORE: - break; - case SHEAR: - for (NameList one : ConfigManager.getJobsConfiguration().ListOfColors) { - String ids = one.getMinecraftName(); - if (ids.equalsIgnoreCase(String.valueOf(info.getName()))) { - return one.getName(); - } - } - break; - } - - return materialName; - } -} diff --git a/com/gamingmesh/jobs/tasks/BufferedPaymentTask.java b/com/gamingmesh/jobs/tasks/BufferedPaymentTask.java index 8224718f..22250102 100644 --- a/com/gamingmesh/jobs/tasks/BufferedPaymentTask.java +++ b/com/gamingmesh/jobs/tasks/BufferedPaymentTask.java @@ -18,6 +18,7 @@ package com.gamingmesh.jobs.tasks; +import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.economy.BufferedEconomy; import com.gamingmesh.jobs.economy.BufferedPayment; import com.gamingmesh.jobs.economy.Economy; @@ -26,19 +27,24 @@ public class BufferedPaymentTask implements Runnable { private BufferedEconomy bufferedEconomy; private Economy economy; private BufferedPayment payment; + public BufferedPaymentTask(BufferedEconomy bufferedEconomy, Economy economy, BufferedPayment payment) { - this.bufferedEconomy = bufferedEconomy; - this.economy = economy; - this.payment = payment; + this.bufferedEconomy = bufferedEconomy; + this.economy = economy; + this.payment = payment; } + @Override public void run() { - if (payment.getAmount() > 0) { - economy.depositPlayer(payment.getOfflinePlayer(), payment.getAmount()); - } else { - if (!economy.withdrawPlayer(payment.getOfflinePlayer(), -payment.getAmount())) { - bufferedEconomy.pay(payment); - } - } + if (payment.getAmount() > 0) { + economy.depositPlayer(payment.getOfflinePlayer(), payment.getAmount()); + } else { + if (!economy.withdrawPlayer(payment.getOfflinePlayer(), -payment.getAmount())) { + bufferedEconomy.pay(payment); + } + } + + if (payment.getPoints() != 0D) + Jobs.getPlayerManager().getPointsData().addPoints(payment.getOfflinePlayer().getUniqueId(), payment.getPoints()); } } \ No newline at end of file diff --git a/com/gamingmesh/jobs/tasks/BufferedPaymentThread.java b/com/gamingmesh/jobs/tasks/BufferedPaymentThread.java index ae613cab..70c41463 100644 --- a/com/gamingmesh/jobs/tasks/BufferedPaymentThread.java +++ b/com/gamingmesh/jobs/tasks/BufferedPaymentThread.java @@ -37,7 +37,7 @@ public class BufferedPaymentThread extends Thread { @Override public void run() { - String message = ChatColor.translateAlternateColorCodes('&', "&2Started buffered payment thread."); + String message = ChatColor.YELLOW + "[Jobs] Started buffered payment thread."; ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); console.sendMessage(message); @@ -55,13 +55,13 @@ public class BufferedPaymentThread extends Thread { economy.payAll(); } catch (Throwable t) { t.printStackTrace(); - message = ChatColor.translateAlternateColorCodes('&', "&cException in BufferedPaymentThread, stopping economy payments!"); + message = ChatColor.RED + "[Jobs] Exception in BufferedPaymentThread, stopping economy payments!"; console.sendMessage(message); //Jobs.getPluginLogger().severe("Exception in BufferedPaymentThread, stopping economy payments!"); running = false; } } - message = ChatColor.translateAlternateColorCodes('&', "&6Buffered payment thread shutdown."); + message = ChatColor.YELLOW + "[Jobs] Buffered payment thread shutdown."; console.sendMessage(message); //Jobs.getPluginLogger().info("Buffered payment thread shutdown"); } diff --git a/com/gamingmesh/jobs/tasks/DatabaseSaveThread.java b/com/gamingmesh/jobs/tasks/DatabaseSaveThread.java index 25d507cb..29a4badb 100644 --- a/com/gamingmesh/jobs/tasks/DatabaseSaveThread.java +++ b/com/gamingmesh/jobs/tasks/DatabaseSaveThread.java @@ -38,7 +38,7 @@ public class DatabaseSaveThread extends Thread { public void run() { //Jobs.getPluginLogger().info("Started database save task"); - String message = ChatColor.translateAlternateColorCodes('&', "&2Started database save task."); + String message = ChatColor.YELLOW + "[Jobs] Started database save task."; ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); console.sendMessage(message); @@ -54,13 +54,13 @@ public class DatabaseSaveThread extends Thread { } catch (Throwable t) { t.printStackTrace(); //Jobs.getPluginLogger().severe("Exception in DatabaseSaveTask, stopping auto save!"); - message = ChatColor.translateAlternateColorCodes('&', "&cException in DatabaseSaveTask, stopping auto save!"); + message = ChatColor.RED + "[Jobs] Exception in DatabaseSaveTask, stopping auto save!"; console.sendMessage(message); running = false; } } - message = ChatColor.translateAlternateColorCodes('&', "&6Database save task shutdown!"); + message = ChatColor.YELLOW + "[Jobs] Database save task shutdown!"; console.sendMessage(message); //Jobs.getPluginLogger().info("Database save task shutdown"); diff --git a/jobConfig.yml b/jobConfig.yml index d9abd53a..8c6815be 100644 --- a/jobConfig.yml +++ b/jobConfig.yml @@ -31,7 +31,7 @@ Jobs: # [OPTIONAL] - the maximum level of this class max-level: 10 # [OPTIONAL] - the maximum level of this class with specific permission - # use jobs.[jobsname].vipmaxlevel + # use jobs.[jobsname].vipmaxlevel, in this case it will be jobs.exampleJob.vipmaxlevel vip-max-level: 20 # [OPTIONAL] - the maximum number of users on the server that can have this job at # any one time (includes offline players). @@ -41,19 +41,28 @@ Jobs: # numjobs - the number of jobs the player has # joblevel - the level the player has attained in the job. # NOTE: Please take care of the brackets when modifying this equation. - leveling-progression-equation: 100*((1.13+(0.01*(numjobs-1)))^(joblevel-1)) + leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4) # Equation used for calculating how much income is given per action for the job level. # Available parameters: + # numjobs - the number of jobs the player has # baseincome - the income for the action at level 1 (as set in the configuration). # joblevel - the level the player has attained in the job. # NOTE: Please take care of the brackets when modifying this equation. - income-progression-equation: baseincome*((1.05)^(joblevel-1)) + income-progression-equation: baseincome+(joblevel-1)*0.01-((baseincome+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + # Equation used for calculating how much points is given per action for the job level. + # Available parameters: + # numjobs - the number of jobs the player has + # basepoints - the points for the action at level 1 (as set in the configuration). + # joblevel - the level the player has attained in the job. + # NOTE: Please take care of the brackets when modifying this equation. + points-progression-equation: basepoints+(joblevel-1)*0.01-((basepoints+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) # Equation used for calculating how much experience is given per action for the job level. # Available parameters: + # numjobs - the number of jobs the player has # baseexperience - the experience for the action at level 1 (as set in the configuration). # joblevel - the level the player has attained in the job. # NOTE: Please take care of the brackets when modifying this equation. - experience-progression-equation: baseexperience*((1.05)^(joblevel-1)) + experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) # GUI icon information when using GUI function Gui: # id of block @@ -101,6 +110,7 @@ Jobs: # Sheep # Silverfish # Skeleton + # Shulker # Slime # Snowman # Spider @@ -109,7 +119,8 @@ Jobs: # Witch # Wither # Wolf - # Zombie + # Zombie + # # # NOTE: mob names are case sensitive. # @@ -434,9 +445,10 @@ Jobs: description: Earns money felling and planting trees ChatColour: GREEN chat-display: full - leveling-progression-equation: 100*((1.13+(0.01*(numjobs-1)))^(joblevel-1)) - income-progression-equation: baseincome*((1.05)^(joblevel-1)) - experience-progression-equation: baseexperience*((1.05)^(joblevel-1)) + leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4) + income-progression-equation: baseincome+(joblevel-1)*0.01-((baseincome+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + points-progression-equation: basepoints+(joblevel-1)*0.01-((basepoints+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) Gui: Id: 17 Data: 2 @@ -485,6 +497,7 @@ Jobs: Woodcutter: income: 10.0 experience: 10.0 + max-level: 200 Miner: fullname: Miner shortname: M @@ -493,51 +506,142 @@ Jobs: chat-display: full #max-level: 10 #slots: 10 - leveling-progression-equation: 100*((1.13+(0.01*(numjobs-1)))^(joblevel-1)) - income-progression-equation: baseincome*((1.05)^(joblevel-1)) - experience-progression-equation: baseexperience*((1.05)^(joblevel-1)) + leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4) + income-progression-equation: baseincome+(joblevel-1)*0.01-((baseincome+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + points-progression-equation: basepoints+(joblevel-1)*0.01-((basepoints+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) + Gui: + Id: 270 + Data: 0 + TNTBreak: + STONE: + income: 0.3 + points: 0.3 + experience: 0.3 + STONE-1: + income: 1 + points: 1 + experience: 1 + STONE-3: + income: 1 + points: 1 + experience: 1 + STONE-5: + income: 1 + points: 1 + experience: 1 Break: STONE: - income: 2.0 - experience: 2.0 + income: 0.3 + points: 0.3 + experience: 0.3 + STONE-1: + income: 1 + points: 1 + experience: 1 + STONE-3: + income: 1 + points: 1 + experience: 1 + STONE-5: + income: 1 + points: 1 + experience: 1 COAL_ORE: - income: 3.0 - experience: 3.0 + income: 3 + points: 2 + experience: 2 + SANDSTONE: + income: 0.15 + points: 0.15 + experience: 0.2 + SANDSTONE-1: + income: 0.15 + points: 0.15 + experience: 0.2 + SANDSTONE-2: + income: 0.15 + points: 0.15 + experience: 0.2 GLOWING_REDSTONE_ORE: - income: 3.0 - experience: 3.0 - IRON_ORE: - income: 4.0 - experience: 4.0 + income: 2.5 + points: 2 + experience: 2 + IRON_ORE: + income: 3.5 + points: 3 + experience: 2 GOLD_ORE: - income: 5.0 - experience: 5.0 + income: 5 + points: 4 + experience: 2 LAPIS_ORE: - income: 5.0 - experience: 5.0 - DIAMOND_ORE: - income: 6.0 - experience: 6.0 - OBSIDIAN: income: 7.5 - experience: 7.5 + points: 6 + experience: 2 + DIAMOND_ORE: + income: 10 + points: 10 + experience: 10 + EMERALD_ORE: + income: 15 + points: 15 + experience: 30 + QUARTZ_ORE: + income: 2.5 + points: 2.5 + experience: 2.5 + OBSIDIAN: + income: 5 + points: 5 + experience: 5 MOSSY_COBBLESTONE: - income: 6.0 - experience: 6.0 + income: 2.5 + points: 2.5 + experience: 2.5 + NETHER_BRICK: + income: 1.0 + points: 1 + experience: 1.0 + NETHER_BRICK_STAIRS: + income: 3 + points: 3 + experience: 3 + NETHER_FENCE: + income: 1 + points: 1 + experience: 1 + NETHERRACK: + income: 0.1 + points: 0.1 + experience: 0.1 + PRISMARINE: + income: 2.5 + points: 2.5 + experience: 2.5 Place: RAILS: income: 2.0 + points: 2.0 experience: 2.0 IRON_ORE: income: -5.0 + points: -5 experience: -5.0 GOLD_ORE: income: -6.0 + points: -6 experience: -6.0 + DIAMOND_ORE: + income: -10.0 + points: -10 + experience: -10.0 Kill: Player: income: 7.5 + points: 7.5 experience: 7.5 + max-level: 200 Builder: fullname: Builder shortname: B @@ -546,68 +650,244 @@ Jobs: chat-display: full #max-level: 10 #slots: 10 - leveling-progression-equation: 100*((1.13+(0.01*(numjobs-1)))^(joblevel-1)) - income-progression-equation: baseincome*((1.05)^(joblevel-1)) - experience-progression-equation: baseexperience*((1.05)^(joblevel-1)) + leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4) + income-progression-equation: baseincome+(joblevel-1)*0.01-((baseincome+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + points-progression-equation: basepoints+(joblevel-1)*0.01-((basepoints+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) + Gui: + Id: 108 + Data: 0 Place: + STONE-2: + income: 1.3 + experience: 2 + STONE-4: + income: 1.3 + experience: 2 + STONE-6: + income: 1.3 + experience: 2 COBBLESTONE: + income: 0.7 + experience: 2 + '5': + income: 1.5 + experience: 2 + '35': + income: 1.5 + experience: 2 + '41': + income: 1.5 + experience: 2 + '42': + income: 1.5 + experience: 2 + '44': + income: 0.8 + experience: 2 + '45': + income: 1.5 + experience: 2 + '47': + income: 1.5 + experience: 2 + '48': + income: 1.5 + experience: 2 + '49': + income: 1.5 + experience: 2 + '53': + income: 1.5 + experience: 2 + '54': + income: 1.5 + experience: 2 + '57': + income: 1.5 + experience: 2 + '58': + income: 1.5 + experience: 2 + '61': + income: 1.5 + experience: 2 + '65': + income: 1.5 + experience: 2 + '67': + income: 1.5 + experience: 2 + '79': + income: 1.5 + experience: 2 + '80': income: 1.0 - experience: 1.0 - WOOD: + experience: 2 + '84': + income: 1.0 + experience: 2 + '85': income: 1.5 - experience: 1.5 - FENCE: + experience: 2 + '89': income: 1.5 - experience: 1.5 - WOOL: + experience: 2 + '95': income: 1.5 - experience: 1.5 - STONE: - income: 2.25 - experience: 2.25 - GLOWSTONE: - income: 3.0 - experience: 3.0 - SANDSTONE: - income: 2.0 - experience: 2.0 - GLASS: - income: 3.0 - experience: 3.0 - BRICK: - income: 4.0 - experience: 4.0 - LAPIS_BLOCK: - income: 5.0 - experience: 5.0 - DOUBLE_STEP: - income: 2.0 - experience: 2.0 - STEP: - income: 2.0 - experience: 2.0 - BOOKSHELF: - income: 3.0 - experience: 3.0 - WOOD_STAIRS: - income: 2.0 - experience: 2.0 - COBBLESTONE_STAIRS: - income: 2.0 - experience: 2.0 - MOSSY_COBBLESTONE: - income: 5.0 - experience: 5.0 - DIAMOND_BLOCK: - income: 5.0 - experience: 5.0 - GOLD_BLOCK: - income: 5.0 - experience: 5.0 + experience: 2 + '96': + income: 1.5 + experience: 2 + '98': + income: 1.5 + experience: 2 + '101': + income: 1.5 + experience: 2 + '102': + income: 1.5 + experience: 2 + '107': + income: 1.5 + experience: 2 + '108': + income: 1.5 + experience: 2 + '109': + income: 1.5 + experience: 2 + '112': + income: 1.5 + experience: 2 + '113': + income: 1.5 + experience: 2 + '114': + income: 1.5 + experience: 2 + '116': + income: 1.5 + experience: 2 + '120': + income: 1.5 + experience: 2 + '123': + income: 1.0 + experience: 2 + '126': + income: 0.8 + experience: 2 + '128': + income: 1.5 + experience: 2 + '130': + income: 1.5 + experience: 2 + '133': + income: 1.5 + experience: 2 + '134': + income: 1.5 + experience: 2 + '139': + income: 1.5 + experience: 2 + '146': + income: 1.5 + experience: 2 + '152': + income: 1.5 + experience: 2 + '154': + income: 1.5 + experience: 2 + '155': + income: 1.5 + experience: 2 + '156': + income: 1.5 + experience: 2 + '159': + income: 1.5 + experience: 2 + '160': + income: 1.5 + experience: 2 + '161': + income: 1.5 + experience: 2 + '163': + income: 1.5 + experience: 2 + '164': + income: 1.5 + experience: 2 + '167': + income: 1.5 + experience: 2 + '168': + income: 1.3 + experience: 1.9 + '169': + income: 1.5 + experience: 2 + '170': + income: 1.5 + experience: 2 + '172': + income: 1.5 + experience: 2 + '173': + income: 1.5 + experience: 2 + '174': + income: 1.5 + experience: 2 + '179': + income: 1.5 + experience: 2 + '180': + income: 1.5 + experience: 2 + '182': + income: 0.8 + experience: 2 + '183': + income: 1.5 + experience: 2 + '184': + income: 1.5 + experience: 2 + '185': + income: 1.5 + experience: 2 + '186': + income: 1.5 + experience: 2 + '187': + income: 1.5 + experience: 2 + '188': + income: 1.5 + experience: 2 + '189': + income: 1.5 + experience: 2 + '190': + income: 1.5 + experience: 2 + '191': + income: 1.5 + experience: 2 + '192': + income: 1.5 + experience: 2 Kill: Player: income: 7.5 experience: 7.5 + max-level: 200 Digger: fullname: Digger shortname: D @@ -616,25 +896,35 @@ Jobs: chat-display: full #max-level: 10 #slots: 10 - leveling-progression-equation: 100*((1.13+(0.01*(numjobs-1)))^(joblevel-1)) - income-progression-equation: baseincome*((1.05)^(joblevel-1)) - experience-progression-equation: baseexperience*((1.05)^(joblevel-1)) + leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4) + income-progression-equation: baseincome+(joblevel-1)*0.01-((baseincome+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + points-progression-equation: basepoints+(joblevel-1)*0.01-((basepoints+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) + Gui: + Id: 269 + Data: 0 Break: + '179': + income: 1 + experience: 1 DIRT: - income: 2.0 - experience: 2.0 + income: 0.25 + experience: 0.25 GRASS: - income: 2.0 - experience: 2.0 + income: 0.3 + experience: 0.3 GRAVEL: - income: 2.0 - experience: 2.0 + income: 1 + experience: 1.0 SAND: - income: 2.0 - experience: 2.0 + income: 0.4 + experience: 0.5 CLAY: - income: 2.0 - experience: 2.0 + income: 1 + experience: 1.0 + '159': + income: 1 + experience: 1.0 Kill: Player: income: 7.5 @@ -643,6 +933,7 @@ Jobs: Digger: income: 10.0 experience: 10.0 + max-level: 200 Farmer: fullname: Farmer shortname: Fa @@ -651,24 +942,144 @@ Jobs: chat-display: full #max-level: 10 #slots: 10 - leveling-progression-equation: 100*((1.13+(0.01*(numjobs-1)))^(joblevel-1)) - income-progression-equation: baseincome*((1.05)^(joblevel-1)) - experience-progression-equation: baseexperience*((1.05)^(joblevel-1)) - Break: - CROPS-7: - income: 4.0 - experience: 4.0 - SUGAR_CANE_BLOCK: - income: 4.0 - experience: 4.0 + leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4) + income-progression-equation: baseincome+(joblevel-1)*0.01-((baseincome+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + points-progression-equation: basepoints+(joblevel-1)*0.01-((basepoints+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) + Gui: + Id: 290 + Data: 0 Tame: Wolf: income: 5.0 experience: 5.0 - Breed: - Wolf: + Horse: income: 5.0 experience: 5.0 + Breed: + Wolf: + income: 4.0 + experience: 5.0 + Ocelot: + income: 4.0 + experience: 5.0 + Pig: + income: 4.0 + experience: 5.0 + Cow: + income: 4.0 + experience: 5.0 + Horse: + income: 4.0 + experience: 5.0 + Rabbit: + income: 4.0 + experience: 5.0 + Sheep: + income: 4.0 + experience: 5.0 + Chicken: + income: 4.0 + experience: 5.0 + Shear: + Red: + income: 4.0 + experience: 5.0 + Orange: + income: 4.0 + experience: 5.0 + Yellow: + income: 4.0 + experience: 5.0 + Green: + income: 4.0 + experience: 5.0 + Blue: + income: 4.0 + experience: 5.0 + 'Light Blue': + income: 4.0 + experience: 5.0 + Magenta: + income: 4.0 + experience: 5.0 + Pink: + income: 4.0 + experience: 5.0 + White: + income: 4.0 + experience: 5.0 + 'Light Gray': + income: 4.0 + experience: 5.0 + Black: + income: 4.0 + experience: 5.0 + Brown: + income: 4.0 + experience: 5.0 + Purple: + income: 4.0 + experience: 5.0 + Cyan: + income: 4.0 + experience: 5.0 + Gray: + income: 4.0 + experience: 5.0 + 'Lime Green': + income: 4.0 + experience: 5.0 + Milk: + Cow: + income: 5.0 + experience: 5.0 + Break: + CROPS-7: + income: 1.5 + experience: 3.0 + CARROT-7: + income: 1.0 + experience: 1.0 + POTATO-7: + income: 1.0 + experience: 1.0 + PUMPKIN: + income: 0.5 + experience: 1.0 + SUGAR_CANE_BLOCK: + income: 0.2 + experience: 0.2 + COCOA-4: + income: 4 + experience: 4.0 + '6': + income: 2 + experience: 2.0 + '111': + income: 2 + experience: 2.0 + '37': + income: 2 + experience: 2.0 + '38': + income: 2 + experience: 2.0 + '39': + income: 1 + experience: 1.0 + '40': + income: 1 + experience: 1.0 + '106': + income: 1 + experience: 1.0 + '81': + income: 1 + experience: 1.0 + '115': + income: 1 + experience: 1.0 Place: CROPS-0: income: 3.0 @@ -680,6 +1091,7 @@ Jobs: Player: income: 7.5 experience: 7.5 + max-level: 200 Hunter: fullname: Hunter shortname: H @@ -688,43 +1100,329 @@ Jobs: chat-display: full #max-level: 10 #slots: 10 - leveling-progression-equation: 100*((1.13+(0.01*(numjobs-1)))^(joblevel-1)) - income-progression-equation: baseincome*((1.05)^(joblevel-1)) - experience-progression-equation: baseexperience*((1.05)^(joblevel-1)) + leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4) + income-progression-equation: baseincome+(joblevel-1)*0.01-((baseincome+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + points-progression-equation: basepoints+(joblevel-1)*0.01-((basepoints+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) + Gui: + Id: 261 + Data: 0 + Tame: + Wolf: + income: 20.0 + experience: 15.0 + Ocelot: + income: 20.0 + experience: 15.0 + Horse: + income: 20.0 + experience: 15.0 Kill: Chicken: - income: 2.5 - experience: 2.5 - Cow: - income: 2.5 - experience: 2.5 - Pig: - income: 2.5 - experience: 2.5 - Sheep: - income: 2.5 - experience: 2.5 - Wolf: income: 5.0 experience: 5.0 - Creeper: + Cow: + income: 6.0 + experience: 5.0 + Pig: + income: 5.0 + experience: 5.0 + Sheep: + income: 5.0 + experience: 5.0 + Wolf: income: 10.0 - experience: 10.0 - Skeleton: + experience: 5.0 + Creeper: + income: 15.0 + experience: 15.0 + Skeleton: income: 10.0 - experience: 10.0 - WitherSkeleton: - income: 10.0 - experience: 10.0 + experience: 15.0 Spider: income: 10.0 - experience: 10.0 - Zombie: + experience: 15.0 + Zombie: income: 10.0 - experience: 10.0 + experience: 15.0 + BLAZE: + income: 20.0 + experience: 15.0 + CAVE_SPIDER: + income: 20.0 + experience: 15.0 + ENDERMAN: + income: 2.0 + experience: 2.0 + GHAST: + income: 30.0 + experience: 30.0 + GIANT: + income: 250.0 + experience: 100.0 + IRON_GOLEM: + income: 30.0 + experience: 30.0 + MUSHROOM_COW: + income: 5.0 + experience: 5.0 + PIG_ZOMBIE: + income: 5.0 + experience: 5.0 + SILVERFISH: + income: 3.0 + experience: 5.0 + SNOWMAN: + income: 2.0 + experience: 4.0 + SQUID: + income: 2.0 + experience: 2.0 + RABBIT: + income: 2.0 + experience: 2.0 + GUARDIAN: + income: 2.0 + experience: 2.0 + SHULKER: + income: 5.0 + experience: 5.0 + WITHER: + income: 50.0 + experience: 120.0 + ENDER_DRAGON: + income: 2000.0 + experience: 2000.0 + Player: + income: 9.0 + experience: 7.5 + max-level: 200 + Explorer: + fullname: Explorer + shortname: Ex + description: Earns money from exploring map. + ChatColour: AQUA + chat-display: full + #max-level: 10 + #slots: 10 + leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4) + income-progression-equation: baseincome+(joblevel-1)*0.01-((baseincome+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + points-progression-equation: basepoints+(joblevel-1)*0.01-((basepoints+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) + Gui: + Id: 301 + Data: 0 + Explore: + 1: + income: 5.0 + experience: 5.0 + 2: + income: 2.5 + experience: 2.5 + 3: + income: 1.0 + experience: 1.0 + 4: + income: 0.5 + experience: 0.5 + 5: + income: 0.1 + experience: 0.1 + Kill: Player: income: 7.5 experience: 7.5 + max-level: 200 + Crafter: + fullname: Crafter + shortname: Cr + description: Earns money from crafting items. + ChatColour: RED + chat-display: full + #max-level: 10 + #slots: 10 + leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4) + income-progression-equation: baseincome+(joblevel-1)*0.01-((baseincome+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + points-progression-equation: basepoints+(joblevel-1)*0.01-((basepoints+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) + Gui: + Id: 61 + Data: 0 + Craft: + '280': + income: 0.1 + experience: 0.1 + '23': + income: 4.0 + experience: 4.0 + '25': + income: 1.5 + experience: 3.0 + '27': + income: 5.0 + experience: 5.0 + '28': + income: 5.0 + experience: 5.0 + '29': + income: 3.0 + experience: 3.0 + 'tnt': + income: 4.0 + experience: 4.0 + 'chest': + income: 1.3 + experience: 1.3 + '58': + income: 0.7 + experience: 1.0 + '61': + income: 1.0 + experience: 1.0 + '65': + income: 0.1 + experience: 0.1 + '66': + income: 1.1 + experience: 1.1 + '84': + income: 10.0 + experience: 20.0 + '95': + income: 0.3 + experience: 0.3 + '108': + income: 2.5 + experience: 3.0 + '109': + income: 0.5 + experience: 0.5 + '116': + income: 30.0 + experience: 40.0 + '138': + income: 100.0 + experience: 300.0 + '145': + income: 20.0 + experience: 25.0 + '146': + income: 1.5 + experience: 1.5 + '147': + income: 3.0 + experience: 3.0 + '148': + income: 2.5 + experience: 2.5 + '151': + income: 2.5 + experience: 2.5 + 'hopper': + income: 7.0 + experience: 7.0 + '157': + income: 4.0 + experience: 4.0 + '158': + income: 2.0 + experience: 3.0 + '159': + income: 1.5 + experience: 1.5 + '160': + income: 0.2 + experience: 0.2 + '165': + income: 1.0 + experience: 1.0 + '168': + income: 3.0 + experience: 3.0 + '169': + income: 10.0 + experience: 10.0 + '183': + income: 0.5 + experience: 0.5 + '184': + income: 0.5 + experience: 0.5 + '185': + income: 0.5 + experience: 0.5 + '186': + income: 0.5 + experience: 0.5 + '187': + income: 0.5 + experience: 0.5 + '188': + income: 0.5 + experience: 0.5 + '189': + income: 0.5 + experience: 0.5 + '190': + income: 0.5 + experience: 0.5 + '191': + income: 0.5 + experience: 0.5 + '192': + income: 0.5 + experience: 0.5 + '324': + income: 0.5 + experience: 0.5 + '330': + income: 8.0 + experience: 8.0 + '340': + income: 1.0 + experience: 1.0 + '345': + income: 4.0 + experience: 7.0 + '347': + income: 7.0 + experience: 7.0 + '354': + income: 8.0 + experience: 10.0 + '355': + income: 3.0 + experience: 3.0 + '379': + income: 2.8 + experience: 3.5 + '380': + income: 7.0 + experience: 7.0 + '427': + income: 0.15 + experience: 0.15 + '428': + income: 0.15 + experience: 0.15 + '429': + income: 0.15 + experience: 0.15 + '430': + income: 0.15 + experience: 0.15 + '431': + income: 0.15 + experience: 0.15 + Smelt: + COOKED_CHICKEN: + income: 3.0 + experience: 3.0 + Kill: + Player: + income: 7.5 + experience: 7.5 + max-level: 200 Fisherman: fullname: Fisherman shortname: Fi @@ -733,17 +1431,31 @@ Jobs: chat-display: full #max-level: 10 #slots: 10 - leveling-progression-equation: 100*((1.13+(0.01*(numjobs-1)))^(joblevel-1)) - income-progression-equation: baseincome*((1.05)^(joblevel-1)) - experience-progression-equation: baseexperience*((1.05)^(joblevel-1)) + leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4) + income-progression-equation: baseincome+(joblevel-1)*0.01-((baseincome+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + points-progression-equation: basepoints+(joblevel-1)*0.01-((basepoints+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) + Gui: + Id: 346 + Data: 0 Fish: - RAW_FISH: - income: 4.0 - experience: 4.0 + '349-0': + income: 15.0 + experience: 15.0 + '349-1': + income: 20.0 + experience: 25.0 + '349-2': + income: 25.0 + experience: 25.0 + '349-3': + income: 25.0 + experience: 25.0 Kill: Player: income: 7.5 experience: 7.5 + max-level: 200 Weaponsmith: fullname: Weaponsmith shortname: W @@ -752,22 +1464,80 @@ Jobs: chat-display: full #max-level: 10 #slots: 10 - leveling-progression-equation: 100*((1.13+(0.01*(numjobs-1)))^(joblevel-1)) - income-progression-equation: baseincome*((1.05)^(joblevel-1)) - experience-progression-equation: baseexperience*((1.05)^(joblevel-1)) + leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4) + income-progression-equation: baseincome+(joblevel-1)*0.01-((baseincome+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + points-progression-equation: basepoints+(joblevel-1)*0.01-((basepoints+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) + Gui: + Id: 58 + Data: 0 Craft: WOOD_SWORD: income: 1.0 - experience: 1.0 - IRON_SWORD: - income: 2.0 experience: 2.0 - GOLD_SWORD: + LEATHER_BOOTS: income: 3.0 - experience: 3.0 - DIAMOND_SWORD: - income: 4.0 experience: 4.0 + LEATHER_CHESTPLATE: + income: 4.0 + experience: 8.0 + LEATHER_HELMET: + income: 2.5 + experience: 5.0 + LEATHER_LEGGINGS: + income: 3.5 + experience: 7.0 + IRON_SWORD: + income: 4.0 + experience: 8.0 + IRON_BOOTS: + income: 8.0 + experience: 16.0 + IRON_CHESTPLATE: + income: 16.0 + experience: 32.0 + IRON_HELMET: + income: 10.0 + experience: 20.0 + IRON_LEGGINGS: + income: 14.0 + experience: 28.0 + GOLD_SWORD: + income: 6.0 + experience: 12.0 + GOLD_BOOTS: + income: 12.0 + experience: 24.0 + GOLD_CHESTPLATE: + income: 24.0 + experience: 48.0 + GOLD_HELMET: + income: 15.0 + experience: 30.0 + GOLD_LEGGINGS: + income: 21.0 + experience: 42.0 + DIAMOND_SWORD: + income: 8.0 + experience: 16.0 + DIAMOND_PICKAXE: + income: 12.0 + experience: 24.0 + DIAMOND_AXE: + income: 12.0 + experience: 24.0 + DIAMOND_HELMET: + income: 20.0 + experience: 40.0 + DIAMOND_CHESTPLATE: + income: 32.0 + experience: 64.0 + DIAMOND_LEGGINGS: + income: 28.0 + experience: 40.0 + DIAMOND_BOOTS: + income: 16.0 + experience: 32.0 Repair: WOOD_SWORD: income: 1.0 @@ -783,51 +1553,69 @@ Jobs: experience: 4.0 Smelt: IRON_INGOT: - income: 2.0 + income: 1.3 experience: 2.0 GOLD_INGOT: - income: 2.0 - experience: 2.0 + income: 5.0 + experience: 10 + DIAMOND: + income: 7.0 + experience: 20 + max-level: 200 Brewer: fullname: Brewer shortname: Br description: Earns money brewing potions. ChatColour: LIGHT_PURPLE chat-display: full - leveling-progression-equation: 100*((1.13+(0.01*(numjobs-1)))^(joblevel-1)) - income-progression-equation: baseincome*((1.05)^(joblevel-1)) - experience-progression-equation: baseexperience*((1.05)^(joblevel-1)) + leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4) + income-progression-equation: baseincome+(joblevel-1)*0.01-((baseincome+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + points-progression-equation: basepoints+(joblevel-1)*0.01-((basepoints+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) + Gui: + Id: 379 + Data: 0 Brew: NETHER_STALK: - income: 1.0 - experience: 1.0 + income: 6.0 + experience: 6.0 REDSTONE: - income: 2.0 - experience: 2.0 + income: 6.0 + experience: 6.0 GLOWSTONE_DUST: - income: 2.0 - experience: 2.0 + income: 8.0 + experience: 8.0 SPIDER_EYE: - income: 2.0 - experience: 2.0 + income: 9.0 + experience: 9.0 FERMENTED_SPIDER_EYE: - income: 2.0 - experience: 2.0 + income: 12.0 + experience: 12.0 BLAZE_POWDER: - income: 2.0 - experience: 2.0 + income: 12.0 + experience: 12.0 SUGAR: - income: 2.0 - experience: 2.0 + income: 7.0 + experience: 7.0 SPECKLED_MELON: - income: 4.0 - experience: 4.0 + income: 10.0 + experience: 10.0 MAGMA_CREAM: - income: 4.0 - experience: 4.0 + income: 12.0 + experience: 12.0 GHAST_TEAR: - income: 4.0 - experience: 4.0 + income: 22.0 + experience: 22.0 + GOLDEN_CARROT: + income: 14.0 + experience: 14.0 + 349-3: + income: 14.0 + experience: 14.0 + RABBIT_FOOT: + income: 18.0 + experience: 18.0 + max-level: 200 Enchanter: fullname: Enchanter shortname: E @@ -836,9 +1624,13 @@ Jobs: chat-display: full #max-level: 10 #slots: 10 - leveling-progression-equation: 100*((1.13+(0.01*(numjobs-1)))^(joblevel-1)) - income-progression-equation: baseincome*((1.05)^(joblevel-1)) - experience-progression-equation: baseexperience*((1.05)^(joblevel-1)) + leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4) + income-progression-equation: baseincome+(joblevel-1)*0.01-((baseincome+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + points-progression-equation: basepoints+(joblevel-1)*0.01-((basepoints+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) + Gui: + Id: 116 + Data: 0 Enchant: WOOD_SWORD: income: 1.5 @@ -910,19 +1702,19 @@ Jobs: income: 6.0 experience: 30.0 ARROW_DAMAGE-1: - income: 3.0 + income: 10.0 experience: 10.0 ARROW_DAMAGE-2: - income: 6.0 + income: 20.0 experience: 20.0 ARROW_DAMAGE-3: - income: 9.0 + income: 30.0 experience: 30.0 ARROW_DAMAGE-4: - income: 12.0 + income: 40.0 experience: 40.0 ARROW_DAMAGE-5: - income: 15.0 + income: 50.0 experience: 50.0 ARROW_FIRE: income: 10.0 @@ -931,10 +1723,10 @@ Jobs: income: 20.0 experience: 50.0 ARROW_KNOCKBACK-1: - income: 3.0 + income: 10.0 experience: 10.0 ARROW_KNOCKBACK-2: - income: 6.0 + income: 20.0 experience: 20.0 DAMAGE_ALL-1: income: 10.0 @@ -952,79 +1744,79 @@ Jobs: income: 50.0 experience: 50.0 DAMAGE_ARTHROPODS-1: - income: 3.0 + income: 10.0 experience: 10.0 DAMAGE_ARTHROPODS-2: - income: 6.0 + income: 20.0 experience: 20.0 DAMAGE_ARTHROPODS-3: - income: 9.0 + income: 30.0 experience: 30.0 DAMAGE_ARTHROPODS-4: - income: 12.0 + income: 40.0 experience: 40.0 DAMAGE_ARTHROPODS-5: - income: 15.0 + income: 50.0 experience: 50.0 DAMAGE_UNDEAD-1: - income: 3.0 + income: 10.0 experience: 10.0 DAMAGE_UNDEAD-2: - income: 6.0 + income: 20.0 experience: 20.0 DAMAGE_UNDEAD-3: - income: 9.0 + income: 30.0 experience: 30.0 DAMAGE_UNDEAD-4: - income: 12.0 + income: 40.0 experience: 40.0 DAMAGE_UNDEAD-5: - income: 15.0 + income: 50.0 experience: 50.0 DEPTH_STRIDER-1: - income: 3.0 + income: 10.0 experience: 10.0 DEPTH_STRIDER-2: - income: 6.0 + income: 20.0 experience: 20.0 DEPTH_STRIDER-3: - income: 9.0 + income: 30.0 experience: 30.0 DIG_SPEED-1: - income: 3.0 + income: 10.0 experience: 10.0 DIG_SPEED-2: - income: 6.0 + income: 20.0 experience: 20.0 DIG_SPEED-3: - income: 9.0 + income: 30.0 experience: 30.0 DIG_SPEED-4: - income: 12.0 + income: 40.0 experience: 40.0 DIG_SPEED-5: - income: 15.0 + income: 50.0 experience: 50.0 DURABILITY-1: - income: 3.0 + income: 10.0 experience: 10.0 DURABILITY-2: - income: 6.0 + income: 20.0 experience: 20.0 DURABILITY-3: - income: 9.0 + income: 30.0 experience: 30.0 FIRE_ASPECT-1: - income: 3.0 + income: 10.0 experience: 10.0 FIRE_ASPECT-2: - income: 6.0 + income: 20.0 experience: 20.0 KNOCKBACK-1: - income: 3.0 + income: 10.0 experience: 10.0 KNOCKBACK-2: - income: 6.0 + income: 20.0 experience: 20.0 LOOT_BONUS_BLOCKS-1: income: 20.0 @@ -1036,13 +1828,13 @@ Jobs: income: 80.0 experience: 300.0 LOOT_BONUS_MOBS-1: - income: 5.0 + income: 10.0 experience: 20.0 LOOT_BONUS_MOBS-2: - income: 12.0 + income: 20.0 experience: 40.0 LOOT_BONUS_MOBS-3: - income: 15.0 + income: 30.0 experience: 60.0 LUCK-1: income: 15.0 @@ -1063,49 +1855,49 @@ Jobs: income: 30.0 experience: 30.0 OXYGEN-1: - income: 3.0 + income: 10.0 experience: 10.0 OXYGEN-2: - income: 6.0 + income: 20.0 experience: 20.0 OXYGEN-3: - income: 9.0 + income: 30.0 experience: 30.0 PROTECTION_ENVIRONMENTAL-1: - income: 5.0 + income: 10.0 experience: 10.0 PROTECTION_ENVIRONMENTAL-2: - income: 10.0 + income: 20.0 experience: 20.0 PROTECTION_ENVIRONMENTAL-3: - income: 15.0 + income: 30.0 experience: 30.0 PROTECTION_ENVIRONMENTAL-4: - income: 20.0 + income: 40.0 experience: 40.0 PROTECTION_EXPLOSIONS-1: - income: 5.0 + income: 10.0 experience: 10.0 PROTECTION_EXPLOSIONS-2: - income: 10.0 + income: 20.0 experience: 20.0 PROTECTION_EXPLOSIONS-3: - income: 15.0 + income: 30.0 experience: 30.0 PROTECTION_EXPLOSIONS-4: - income: 20.0 + income: 40.0 experience: 40.0 PROTECTION_FALL-1: - income: 3.0 + income: 10.0 experience: 10.0 PROTECTION_FALL-2: - income: 6.0 + income: 20.0 experience: 20.0 PROTECTION_FALL-3: - income: 9.0 + income: 30.0 experience: 30.0 PROTECTION_FALL-4: - income: 12.0 + income: 40.0 experience: 40.0 PROTECTION_FIRE-1: income: 5.0 @@ -1114,10 +1906,10 @@ Jobs: income: 10.0 experience: 20.0 PROTECTION_FIRE-3: - income: 15.0 + income: 20.0 experience: 30.0 PROTECTION_FIRE-4: - income: 20.0 + income: 30.0 experience: 40.0 PROTECTION_PROJECTILE-1: income: 10.0 @@ -1135,17 +1927,18 @@ Jobs: income: 100.0 experience: 300.0 THORNS-1: - income: 4.0 + income: 10.0 experience: 10.0 THORNS-2: - income: 8.0 + income: 20.0 experience: 20.0 THORNS-3: - income: 12.0 + income: 30.0 experience: 30.0 WATER_WORKER: income: 30.0 experience: 100.0 + max-level: 200 None: fullname: None shortname: N @@ -1153,9 +1946,10 @@ Jobs: chat-display: none #max-level: 10 #slots: 10 - leveling-progression-equation: 100*((1.13+(0.01*(numjobs-1)))^(joblevel-1)) - income-progression-equation: baseincome*((1.05)^(joblevel-1)) - experience-progression-equation: baseexperience*((1.05)^(joblevel-1)) + leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4) + income-progression-equation: baseincome+(joblevel-1)*0.01-((baseincome+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + points-progression-equation: basepoints+(joblevel-1)*0.01-((basepoints+(joblevel-1)*0.01) * ((numjobs-1)*0.05)) + experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) Kill: Player: income: 7.5 \ No newline at end of file diff --git a/plugin.yml b/plugin.yml index 7b40e309..f6849ed0 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: Jobs description: Jobs Plugin for the BukkitAPI main: com.gamingmesh.jobs.JobsPlugin -version: 2.63.3 +version: 3.0.0 author: phrstbrn softdepend: [Vault, CoreProtect, MythicMobs, McMMO] commands: @@ -146,6 +146,12 @@ permissions: jobs.command.log: description: Grants access to the log command default: true + jobs.command.shop: + description: Grants access to the shop command + default: true + jobs.command.points: + description: Grants access to the points command + default: true jobs.command.log.others: description: Grants access to the log command default: op diff --git a/shopItems.yml b/shopItems.yml new file mode 100644 index 00000000..47ce4a56 --- /dev/null +++ b/shopItems.yml @@ -0,0 +1,109 @@ +Items: + SuperPickAxe: + # (REQUIRED) Item price in Jobs Points + Price: 10000.0 + Icon: + # (REQUIRED) Icon item id + Id: 278 + # (Optional - Default: 0) Icon item data value + Data: 0 + # (Optional - Default: 1) Icon item amount + Amount: 1 + # (Optional) Icon name. Supports usual color codes + Name: "&eBest pick axe ever!" + # (Optional) Icon lore. Supports usual color codes + Lore: + - "&6Efficiency V" + - "&6Unbreaking III" + - "&eAnd one tasty apple!" + # (Optional - default: false) Hides icon if player dont have permission to get this item + HideWithoutPermission: true + # (Optional) List of permissions required to buy this item + RequiredPermission: + - jobs.item.pickaxe + # (Optional) List of jobs and levels to buy this item + RequiredJobLevels: + - Miner-50 + - Woodcutter-10 + # (Optional) Performs comands on item purchase + # use 'msg ' at start of command to send nice message to player + # all other commands will be performed normaly as they would be executed from console + # use [player] variable to include buyers name + PerformCommands: + - "msg &eThanks for buying this super pick axe!" + # (Optional) Gives items by defined criteria + GiveItems: + # Can be any word + PickAxe: + # (Required) Item id + Id: 278 + # (Optional - Default: 0) Item data + Data: 0 + # (Optional - Default: 1) Item amount + Amount: 1 + # (Optional) Item name + Name: "&eSuper PickAxe" + # (Optional) Item lore + Lore: + - "&eUber pickAxe" + # (Optional) Item enchants + Enchants: + - DIG_SPEED=5 + - DURABILITY=3 + # Can be any word + Apple: + # (Required) Item id + Id: 260 + WoodenShovel: + Price: 100.0 + Icon: + Id: 269 + Name: "&eWooden shovel" + HideWithoutPermission: true + RequiredPermission: + - jobs.item.shovel + RequiredJobLevels: + - Digger-5 + PerformCommands: + - "msg &eThanks [player] for buying this shovel!" + - "give [player] 269 1" + LureEnchantBook: + Price: 100.0 + Icon: + Id: 403 + Name: "&eEnchant book" + Lore: + - "&eContains Lure 3 enchant" + HideWithoutPermission: true + RequiredPermission: + - jobs.item.LureBook + RequiredJobLevels: + - Fisherman-100 + PerformCommands: + - "msg &eThanks [player] for buying this book!" + # (Optional) Gives items by defined criteria + GiveItems: + # Can be any word + Book: + # (Required) Item id + Id: 403 + # (Optional) Item enchants + Enchants: + - LURE=3 + Elytra: + Price: 100000.0 + Icon: + Id: 443 + Name: "&eAngel wings" + HideWithoutPermission: true + RequiredPermission: + - jobs.item.elytra + PerformCommands: + - "msg &eThanks [player] for buying Angel Wings!" + # (Optional) Gives items by defined criteria + GiveItems: + # Can be any word + Elytra: + # (Required) Item id + Id: 443 + \ No newline at end of file