mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-29 04:18:07 +01:00
3.0 update
This commit is contained in:
parent
2f8e12c829
commit
5847619458
11
.classpath
Normal file
11
.classpath
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_79"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/Vault1.5.3.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/mcMMO#127.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/CoreProtect_2.12.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/spigot-1.9.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/MythicMobs-2.1.8.jar"/>
|
||||
<classpathentry kind="output" path=""/>
|
||||
</classpath>
|
19
.externalToolBuilders/Create jar file.launch
Normal file
19
.externalToolBuilders/Create jar file.launch
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/Jobs"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Jobs"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/Jobs/com/gamingmesh/jobs/build.xml}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Jobs}"/>
|
||||
</launchConfiguration>
|
27
.project
Normal file
27
.project
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Jobs</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/Create jar file.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
702
ItemList.yml
702
ItemList.yml
@ -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'
|
1
com/gamingmesh/jobs/Gui/.gitignore
vendored
1
com/gamingmesh/jobs/Gui/.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
/Gui.class
|
||||
/GuiInfoList.class
|
||||
/GuiTools.class
|
||||
/GuiManager.class
|
||||
|
@ -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<String, GuiInfoList> GuiList = new HashMap<String, GuiInfoList>();
|
||||
public HashMap<String, GuiInfoList> GuiList = new HashMap<String, GuiInfoList>();
|
||||
|
||||
public static void CloseInventories() {
|
||||
public void CloseInventories() {
|
||||
for (Entry<String, GuiInfoList> 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<Job> JobsList = new ArrayList<Job>();
|
||||
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<JobProgression> 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<JobInfo> 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<String> Lore = new ArrayList<String>();
|
||||
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<String>();
|
||||
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);
|
||||
|
@ -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("==============================================");
|
||||
}
|
||||
|
||||
|
@ -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<Job, Integer> usedSlots = new WeakHashMap<Job, Integer>();
|
||||
public static WeakHashMap<String, Boolean> actionbartoggle = new WeakHashMap<String, Boolean>();
|
||||
public static WeakHashMap<String, Boolean> BossBartoggle = new WeakHashMap<String, Boolean>();
|
||||
// public static WeakHashMap<String, Double> GlobalBoost = new WeakHashMap<String, Double>();
|
||||
private static BufferedEconomy economy;
|
||||
private static PermissionHandler permissionHandler;
|
||||
@ -86,8 +107,68 @@ public class Jobs {
|
||||
|
||||
public final static HashMap<String, PaymentData> paymentLimit = new HashMap<String, PaymentData>();
|
||||
public final static HashMap<String, PaymentData> ExpLimit = new HashMap<String, PaymentData>();
|
||||
public final static HashMap<String, PaymentData> PointLimit = new HashMap<String, PaymentData>();
|
||||
|
||||
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<String, Boolean> getActionbarToggleList() {
|
||||
return actionbartoggle;
|
||||
}
|
||||
|
||||
public static WeakHashMap<String, Boolean> 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<String> lore = new ArrayList<String>();
|
||||
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<Enchantment, Integer> 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<Enchantment, Integer> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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.");
|
||||
|
@ -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<Block> getPistonRetractBlocks(BlockPistonRetractEvent event);
|
||||
|
||||
public boolean isElderGuardian(Entity entity);
|
||||
|
||||
public ItemStack getItemInMainHand(Player player);
|
||||
}
|
||||
|
@ -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<String, JobsPlayer> players = Collections.synchronizedMap(new HashMap<String, JobsPlayer>());
|
||||
private ConcurrentHashMap<String, JobsPlayer> players = new ConcurrentHashMap<String, JobsPlayer>();
|
||||
private PointsData PointsDatabase = new PointsData();
|
||||
|
||||
private HashMap<String, PlayerInfo> PlayerMap = new HashMap<String, PlayerInfo>();
|
||||
|
||||
public PointsData getPointsData() {
|
||||
return PointsDatabase;
|
||||
}
|
||||
|
||||
public HashMap<String, PlayerInfo> getPlayerMap() {
|
||||
return PlayerMap;
|
||||
}
|
||||
|
||||
public int getPlayerIdByName(String name) {
|
||||
for (Entry<String, PlayerInfo> one : PlayerMap.entrySet()) {
|
||||
if (one.getValue().getName() == null)
|
||||
continue;
|
||||
if (one.getValue().getName().equalsIgnoreCase(name))
|
||||
return one.getValue().getID();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public Entry<String, PlayerInfo> getPlayerInfoByName(String name) {
|
||||
for (Entry<String, PlayerInfo> one : PlayerMap.entrySet()) {
|
||||
if (one.getValue().getName() == null)
|
||||
continue;
|
||||
if (one.getValue().getName().equalsIgnoreCase(name))
|
||||
return one;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Entry<String, PlayerInfo> getPlayerInfoById(int id) {
|
||||
for (Entry<String, PlayerInfo> 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<JobsPlayer> list = null;
|
||||
// synchronized (players) {
|
||||
list = new ArrayList<JobsPlayer>(players.values());
|
||||
// }
|
||||
|
||||
for (JobsPlayer jPlayer : list) {
|
||||
jPlayer.save(dao);
|
||||
}
|
||||
|
||||
// synchronized (players) {
|
||||
Iterator<JobsPlayer> 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<String, PlayerInfo> 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<JobsDAOData> 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<String> lore = new ArrayList<String>();
|
||||
|
||||
if (item.hasItemMeta()) {
|
||||
if (meta.hasDisplayName())
|
||||
name = meta.getDisplayName();
|
||||
if (meta.hasLore())
|
||||
lore = meta.getLore();
|
||||
}
|
||||
|
||||
Map<Enchantment, Integer> 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<Enchantment, Integer> 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);
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +1,28 @@
|
||||
package com.gamingmesh.jobs.Signs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SignInfo {
|
||||
|
||||
List<Sign> AllSigns = new ArrayList<Sign>();
|
||||
|
||||
public SignInfo() {
|
||||
}
|
||||
|
||||
public void setAllSigns(List<Sign> AllSigns) {
|
||||
this.AllSigns = AllSigns;
|
||||
}
|
||||
|
||||
public List<Sign> 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<Sign> AllSigns = new ArrayList<Sign>();
|
||||
|
||||
public SignInfo() {
|
||||
}
|
||||
|
||||
public void setAllSigns(List<Sign> AllSigns) {
|
||||
this.AllSigns = AllSigns;
|
||||
}
|
||||
|
||||
public List<Sign> GetAllSigns() {
|
||||
return this.AllSigns;
|
||||
}
|
||||
|
||||
public void removeSign(Sign sign) {
|
||||
this.AllSigns.remove(sign);
|
||||
}
|
||||
|
||||
public void addSign(Sign sign) {
|
||||
this.AllSigns.add(sign);
|
||||
}
|
||||
}
|
||||
|
@ -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<String> categoriesList = new ArrayList<String>(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<String> categoriesList = new ArrayList<String>(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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -40,7 +40,7 @@ public abstract class MaterialActionInfo extends BaseActionInfo implements Actio
|
||||
|
||||
@Override
|
||||
public String getNameWithSub() {
|
||||
return getName()+":"+data;
|
||||
return getName() + ":" + data;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
5
com/gamingmesh/jobs/commands/.gitignore
vendored
5
com/gamingmesh/jobs/commands/.gitignore
vendored
@ -1,3 +1,8 @@
|
||||
/JobCommand.class
|
||||
/JobsCommands.class
|
||||
/JobsCommands$1.class
|
||||
/Cmd.class
|
||||
/CMICommands.class
|
||||
/CMICommands$1.class
|
||||
/oldcommands.class
|
||||
/oldcommands$1.class
|
||||
|
9
com/gamingmesh/jobs/commands/Cmd.java
Normal file
9
com/gamingmesh/jobs/commands/Cmd.java
Normal file
@ -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);
|
||||
}
|
@ -26,5 +26,5 @@ import java.lang.annotation.Target;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD})
|
||||
public @interface JobCommand {
|
||||
|
||||
int value();
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
45
com/gamingmesh/jobs/commands/list/.gitignore
vendored
Normal file
45
com/gamingmesh/jobs/commands/list/.gitignore
vendored
Normal file
@ -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
|
55
com/gamingmesh/jobs/commands/list/archive.java
Normal file
55
com/gamingmesh/jobs/commands/list/archive.java
Normal file
@ -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<String> 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;
|
||||
}
|
||||
}
|
109
com/gamingmesh/jobs/commands/list/bonus.java
Normal file
109
com/gamingmesh/jobs/commands/list/bonus.java
Normal file
@ -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 + "%");
|
||||
}
|
||||
|
||||
}
|
72
com/gamingmesh/jobs/commands/list/browse.java
Normal file
72
com/gamingmesh/jobs/commands/list/browse.java
Normal file
@ -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<String> lines = new ArrayList<String>();
|
||||
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;
|
||||
}
|
||||
}
|
78
com/gamingmesh/jobs/commands/list/convert.java
Normal file
78
com/gamingmesh/jobs/commands/list/convert.java
Normal file
@ -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<Convert> list = null;
|
||||
List<Convert> 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;
|
||||
}
|
||||
}
|
55
com/gamingmesh/jobs/commands/list/demote.java
Normal file
55
com/gamingmesh/jobs/commands/list/demote.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
69
com/gamingmesh/jobs/commands/list/editpoints.java
Normal file
69
com/gamingmesh/jobs/commands/list/editpoints.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
54
com/gamingmesh/jobs/commands/list/employ.java
Normal file
54
com/gamingmesh/jobs/commands/list/employ.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
79
com/gamingmesh/jobs/commands/list/expboost.java
Normal file
79
com/gamingmesh/jobs/commands/list/expboost.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
53
com/gamingmesh/jobs/commands/list/fire.java
Normal file
53
com/gamingmesh/jobs/commands/list/fire.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
50
com/gamingmesh/jobs/commands/list/fireall.java
Normal file
50
com/gamingmesh/jobs/commands/list/fireall.java
Normal file
@ -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<JobProgression> 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;
|
||||
}
|
||||
}
|
55
com/gamingmesh/jobs/commands/list/give.java
Normal file
55
com/gamingmesh/jobs/commands/list/give.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
101
com/gamingmesh/jobs/commands/list/glog.java
Normal file
101
com/gamingmesh/jobs/commands/list/glog.java
Normal file
@ -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<LogAmounts, Double> unsortMap = new HashMap<LogAmounts, Double>();
|
||||
|
||||
int time = TimeManage.timeInInt();
|
||||
|
||||
for (Integer OneP : Jobs.getJobsDAO().getLognameList(time, time)) {
|
||||
|
||||
Entry<String, PlayerInfo> 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<Log> logList = JPlayer.getLog();
|
||||
if (logList.size() == 0)
|
||||
continue;
|
||||
|
||||
for (Log one : logList) {
|
||||
HashMap<String, LogAmounts> AmountList = one.getAmountList();
|
||||
for (Entry<String, LogAmounts> 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<LogAmounts, Double> 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;
|
||||
}
|
||||
}
|
62
com/gamingmesh/jobs/commands/list/grantxp.java
Normal file
62
com/gamingmesh/jobs/commands/list/grantxp.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
105
com/gamingmesh/jobs/commands/list/gtop.java
Normal file
105
com/gamingmesh/jobs/commands/list/gtop.java
Normal file
@ -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<TopList> 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;
|
||||
}
|
||||
}
|
53
com/gamingmesh/jobs/commands/list/info.java
Normal file
53
com/gamingmesh/jobs/commands/list/info.java
Normal file
@ -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;
|
||||
}
|
||||
|
||||
}
|
83
com/gamingmesh/jobs/commands/list/join.java
Normal file
83
com/gamingmesh/jobs/commands/list/join.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
43
com/gamingmesh/jobs/commands/list/leave.java
Normal file
43
com/gamingmesh/jobs/commands/list/leave.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
37
com/gamingmesh/jobs/commands/list/leaveall.java
Normal file
37
com/gamingmesh/jobs/commands/list/leaveall.java
Normal file
@ -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<JobProgression> 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;
|
||||
}
|
||||
}
|
173
com/gamingmesh/jobs/commands/list/limit.java
Normal file
173
com/gamingmesh/jobs/commands/list/limit.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
100
com/gamingmesh/jobs/commands/list/log.java
Normal file
100
com/gamingmesh/jobs/commands/list/log.java
Normal file
@ -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<Log> 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<String, Double> unsortMap = new HashMap<String, Double>();
|
||||
|
||||
for (Log one : logList) {
|
||||
HashMap<String, LogAmounts> AmountList = one.getAmountList();
|
||||
for (Entry<String, LogAmounts> 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<String, LogAmounts> AmountList = one.getAmountList();
|
||||
for (Entry<String, Double> oneSorted : unsortMap.entrySet()) {
|
||||
for (Entry<String, LogAmounts> 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;
|
||||
}
|
||||
}
|
80
com/gamingmesh/jobs/commands/list/moneyboost.java
Normal file
80
com/gamingmesh/jobs/commands/list/moneyboost.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
42
com/gamingmesh/jobs/commands/list/playerinfo.java
Normal file
42
com/gamingmesh/jobs/commands/list/playerinfo.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
80
com/gamingmesh/jobs/commands/list/pointboost.java
Normal file
80
com/gamingmesh/jobs/commands/list/pointboost.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
53
com/gamingmesh/jobs/commands/list/points.java
Normal file
53
com/gamingmesh/jobs/commands/list/points.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
54
com/gamingmesh/jobs/commands/list/promote.java
Normal file
54
com/gamingmesh/jobs/commands/list/promote.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
28
com/gamingmesh/jobs/commands/list/reload.java
Normal file
28
com/gamingmesh/jobs/commands/list/reload.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
61
com/gamingmesh/jobs/commands/list/removexp.java
Normal file
61
com/gamingmesh/jobs/commands/list/removexp.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
41
com/gamingmesh/jobs/commands/list/shop.java
Normal file
41
com/gamingmesh/jobs/commands/list/shop.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
34
com/gamingmesh/jobs/commands/list/signupdate.java
Normal file
34
com/gamingmesh/jobs/commands/list/signupdate.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
52
com/gamingmesh/jobs/commands/list/stats.java
Normal file
52
com/gamingmesh/jobs/commands/list/stats.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
72
com/gamingmesh/jobs/commands/list/toggle.java
Normal file
72
com/gamingmesh/jobs/commands/list/toggle.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
114
com/gamingmesh/jobs/commands/list/top.java
Normal file
114
com/gamingmesh/jobs/commands/list/top.java
Normal file
@ -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<TopList> 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;
|
||||
}
|
||||
}
|
59
com/gamingmesh/jobs/commands/list/transfer.java
Normal file
59
com/gamingmesh/jobs/commands/list/transfer.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
26
com/gamingmesh/jobs/config/.gitignore
vendored
26
com/gamingmesh/jobs/config/.gitignore
vendored
@ -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
|
||||
|
130
com/gamingmesh/jobs/config/BossBarManager.java
Normal file
130
com/gamingmesh/jobs/config/BossBarManager.java
Normal file
@ -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));
|
||||
|
||||
}
|
||||
}
|
@ -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<Job> jobs = new ArrayList<Job>();
|
||||
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<JobPermission> jobPermissions = new ArrayList<JobPermission>();
|
||||
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> jobConditions = new ArrayList<JobConditions>();
|
||||
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<String> requires = permissionSection.getStringList("requires");
|
||||
List<String> perform = permissionSection.getStringList("perform");
|
||||
|
||||
jobConditions.add(new JobConditions(node, requires, perform));
|
||||
}
|
||||
}
|
||||
|
||||
// Command on leave
|
||||
List<String> JobsCommandOnLeave = new ArrayList<String>();
|
||||
if (jobSection.isList("cmd-on-leave")) {
|
||||
JobsCommandOnLeave = jobSection.getStringList("cmd-on-leave");
|
||||
}
|
||||
|
||||
// Command on join
|
||||
List<String> JobsCommandOnJoin = new ArrayList<String>();
|
||||
if (jobSection.isList("cmd-on-join")) {
|
||||
JobsCommandOnJoin = jobSection.getStringList("cmd-on-join");
|
||||
}
|
||||
|
||||
// Commands
|
||||
ArrayList<JobCommands> jobCommand = new ArrayList<JobCommands>();
|
||||
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> jobItems = new ArrayList<JobItems>();
|
||||
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<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);
|
||||
}
|
||||
|
||||
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> jobLimitedItems = new ArrayList<JobLimitedItems>();
|
||||
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<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);
|
||||
}
|
||||
|
||||
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> jobInfo = new ArrayList<JobInfo>();
|
||||
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();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
@ -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<String, ExploreRegion> worlds = new HashMap<String, ExploreRegion>();
|
||||
private boolean exploreEnabled = false;
|
||||
private int playerAmount = 1;
|
||||
|
||||
public Explore() {
|
||||
public ExploreManager() {
|
||||
}
|
||||
|
||||
public int getPlayerAmount() {
|
833
com/gamingmesh/jobs/config/GeneralConfigManager.java
Normal file
833
com/gamingmesh/jobs/config/GeneralConfigManager.java
Normal file
@ -0,0 +1,833 @@
|
||||
/**
|
||||
* 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.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<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;
|
||||
|
||||
// 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<String> 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<String> DisabledWorldsList = new ArrayList<String>();
|
||||
|
||||
public List<Schedule> BoostSchedule = new ArrayList<Schedule>();
|
||||
|
||||
public HashMap<String, List<String>> commandArgs = new HashMap<String, List<String>>();
|
||||
|
||||
public HashMap<String, List<String>> 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());
|
||||
}
|
||||
}
|
@ -1,561 +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.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<Job> jobs = new ArrayList<Job>();
|
||||
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<JobPermission> jobPermissions = new ArrayList<JobPermission>();
|
||||
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> jobConditions = new ArrayList<JobConditions>();
|
||||
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<String> requires = permissionSection.getStringList("requires");
|
||||
List<String> perform = permissionSection.getStringList("perform");
|
||||
|
||||
jobConditions.add(new JobConditions(node, requires, perform));
|
||||
}
|
||||
}
|
||||
|
||||
// Command on leave
|
||||
List<String> JobsCommandOnLeave = new ArrayList<String>();
|
||||
if (jobSection.isList("cmd-on-leave")) {
|
||||
JobsCommandOnLeave = jobSection.getStringList("cmd-on-leave");
|
||||
}
|
||||
|
||||
// Command on join
|
||||
List<String> JobsCommandOnJoin = new ArrayList<String>();
|
||||
if (jobSection.isList("cmd-on-join")) {
|
||||
JobsCommandOnJoin = jobSection.getStringList("cmd-on-join");
|
||||
}
|
||||
|
||||
// Commands
|
||||
ArrayList<JobCommands> jobCommand = new ArrayList<JobCommands>();
|
||||
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> jobItems = new ArrayList<JobItems>();
|
||||
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<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);
|
||||
}
|
||||
|
||||
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> jobLimitedItems = new ArrayList<JobLimitedItems>();
|
||||
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<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);
|
||||
}
|
||||
|
||||
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> jobInfo = new ArrayList<JobInfo>();
|
||||
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();
|
||||
//}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
436
com/gamingmesh/jobs/config/LanguageManager.java
Normal file
436
com/gamingmesh/jobs/config/LanguageManager.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1627
com/gamingmesh/jobs/config/NameTranslatorManager.java
Normal file
1627
com/gamingmesh/jobs/config/NameTranslatorManager.java
Normal file
File diff suppressed because it is too large
Load Diff
112
com/gamingmesh/jobs/config/RestrictedAreaManager.java
Normal file
112
com/gamingmesh/jobs/config/RestrictedAreaManager.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
126
com/gamingmesh/jobs/config/RestrictedBlockManager.java
Normal file
126
com/gamingmesh/jobs/config/RestrictedBlockManager.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
230
com/gamingmesh/jobs/config/ScheduleManager.java
Normal file
230
com/gamingmesh/jobs/config/ScheduleManager.java
Normal file
@ -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!");
|
||||
}
|
||||
}
|
||||
}
|
384
com/gamingmesh/jobs/config/ShopManager.java
Normal file
384
com/gamingmesh/jobs/config/ShopManager.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
187
com/gamingmesh/jobs/config/TitleManager.java
Normal file
187
com/gamingmesh/jobs/config/TitleManager.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
6
com/gamingmesh/jobs/container/.gitignore
vendored
6
com/gamingmesh/jobs/container/.gitignore
vendored
@ -26,3 +26,9 @@
|
||||
/ExploreChunk.class
|
||||
/ExploreWorld.class
|
||||
/ExploreRespond.class
|
||||
/PlayerInfo.class
|
||||
/BossBarInfo.class
|
||||
/PlayerPoints.class
|
||||
/ShopItem.class
|
||||
/LocaleReader.class
|
||||
/BoostMultiplier.class
|
||||
|
25
com/gamingmesh/jobs/container/BoostMultiplier.java
Normal file
25
com/gamingmesh/jobs/container/BoostMultiplier.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
39
com/gamingmesh/jobs/container/BossBarInfo.java
Normal file
39
com/gamingmesh/jobs/container/BossBarInfo.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
75
com/gamingmesh/jobs/container/LocaleReader.java
Normal file
75
com/gamingmesh/jobs/container/LocaleReader.java
Normal file
@ -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));
|
||||
}
|
||||
}
|
20
com/gamingmesh/jobs/container/PlayerInfo.java
Normal file
20
com/gamingmesh/jobs/container/PlayerInfo.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
53
com/gamingmesh/jobs/container/PlayerPoints.java
Normal file
53
com/gamingmesh/jobs/container/PlayerPoints.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
117
com/gamingmesh/jobs/container/ShopItem.java
Normal file
117
com/gamingmesh/jobs/container/ShopItem.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
@ -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() {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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);");
|
||||
}
|
||||
}
|
||||
|
@ -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);");
|
||||
}
|
||||
}
|
||||
|
1
com/gamingmesh/jobs/economy/.gitignore
vendored
1
com/gamingmesh/jobs/economy/.gitignore
vendored
@ -4,3 +4,4 @@
|
||||
/Economy.class
|
||||
/VaultEconomy.class
|
||||
/PaymentData.class
|
||||
/PointsData.class
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
43
com/gamingmesh/jobs/economy/PointsData.java
Normal file
43
com/gamingmesh/jobs/economy/PointsData.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user