|
1 | 1 | package com.shanebeestudios.survival.listeners; |
2 | 2 |
|
3 | | -import com.shanebeestudios.survival.listeners.block.LootTableListener; |
4 | | -import org.bukkit.Bukkit; |
5 | | -import org.bukkit.plugin.PluginManager; |
6 | 3 | import com.shanebeestudios.survival.SurvivalPlugin; |
7 | 4 | import com.shanebeestudios.survival.config.Config; |
8 | 5 | import com.shanebeestudios.survival.listeners.block.BlockBreakListener; |
9 | 6 | import com.shanebeestudios.survival.listeners.block.BlockPlaceListener; |
10 | 7 | import com.shanebeestudios.survival.listeners.block.Campfire; |
11 | 8 | import com.shanebeestudios.survival.listeners.block.Chairs; |
12 | | -import com.shanebeestudios.survival.listeners.block.SnowGeneration; |
| 9 | +import com.shanebeestudios.survival.listeners.block.LootTableListener; |
13 | 10 | import com.shanebeestudios.survival.listeners.block.SnowballThrow; |
14 | 11 | import com.shanebeestudios.survival.listeners.block.WorkbenchShare; |
15 | 12 | import com.shanebeestudios.survival.listeners.entity.BeeKeeperSuit; |
|
47 | 44 | import com.shanebeestudios.survival.listeners.server.LocalChat; |
48 | 45 | import com.shanebeestudios.survival.listeners.server.RecipeDiscovery; |
49 | 46 | import com.shanebeestudios.survival.listeners.server.ResourcePackListener; |
| 47 | +import org.bukkit.Bukkit; |
| 48 | +import org.bukkit.plugin.PluginManager; |
50 | 49 |
|
51 | 50 | /** |
52 | 51 | * Internal use only |
53 | 52 | */ |
54 | 53 | public class EventManager { |
55 | 54 |
|
56 | | - private final SurvivalPlugin plugin; |
57 | | - private final int LOCAL_CHAT; |
58 | | - private final Config config; |
| 55 | + private final SurvivalPlugin plugin; |
| 56 | + private final Config config; |
59 | 57 |
|
60 | | - public EventManager(SurvivalPlugin plugin) { |
61 | | - this.plugin = plugin; |
62 | | - this.config = plugin.getSurvivalConfig(); |
63 | | - this.LOCAL_CHAT = config.settings_local_chat_distance; |
64 | | - } |
| 58 | + public EventManager(SurvivalPlugin plugin) { |
| 59 | + this.plugin = plugin; |
| 60 | + this.config = plugin.getSurvivalConfig(); |
| 61 | + } |
65 | 62 |
|
66 | | - public void registerEvents() { |
67 | | - PluginManager pm = plugin.getServer().getPluginManager(); |
68 | | - pm.registerEvents(this.plugin, this.plugin); |
69 | | - pm.registerEvents(new RecipeDiscovery(plugin), this.plugin); |
| 63 | + public void registerEvents() { |
| 64 | + PluginManager pluginManager = plugin.getServer().getPluginManager(); |
| 65 | + pluginManager.registerEvents(this.plugin, this.plugin); |
| 66 | + pluginManager.registerEvents(new RecipeDiscovery(this.plugin), this.plugin); |
70 | 67 | Bukkit.getPluginManager().registerEvents(new PlayerDataListener(this.plugin), this.plugin); |
71 | 68 |
|
72 | | - if (config.survival_enabled) { |
73 | | - pm.registerEvents(new BlockBreakListener(plugin), this.plugin); |
74 | | - pm.registerEvents(new BlockPlaceListener(plugin), this.plugin); |
75 | | - pm.registerEvents(new FirestrikerListener(plugin), this.plugin); |
76 | | - pm.registerEvents(new ShivPoison(this.plugin), this.plugin); |
77 | | - pm.registerEvents(new WaterBowlListener(plugin), this.plugin); |
78 | | - pm.registerEvents(new Campfire(plugin), this.plugin); |
79 | | - //pm.registerEvents(new Backpack(), this.plugin); needs to be reworked |
80 | | - } |
81 | | - if (config.MECHANICS_BOW) |
82 | | - pm.registerEvents(new BowListener(plugin), this.plugin); |
83 | | - if (config.mechanics_grappling_hook) |
84 | | - pm.registerEvents(new GrapplingHookListener(plugin), this.plugin); |
85 | | - if (config.legendary_obsidian_mace) |
86 | | - pm.registerEvents(new ObsidianMaceWeakness(plugin), this.plugin); |
87 | | - if (config.legendary_valkyrie) |
88 | | - pm.registerEvents(new Valkyrie(plugin), this.plugin); |
89 | | - if (config.legendary_giant_blade) |
90 | | - pm.registerEvents(new GiantBlade(plugin), this.plugin); |
91 | | - if (config.legendary_blaze_sword) |
92 | | - pm.registerEvents(new BlazeSword(), this.plugin); |
93 | | - if (LOCAL_CHAT > -1) |
94 | | - pm.registerEvents(new LocalChat(plugin), this.plugin); |
95 | | - if (config.mechanics_compass_waypoint) |
96 | | - pm.registerEvents(new CompassWaypoint(this.plugin), this.plugin); |
97 | | - if (config.mechanics_medic_kit) |
98 | | - pm.registerEvents(new MedicKit(plugin), this.plugin); |
| 69 | + if (this.config.survival_enabled) { |
| 70 | + pluginManager.registerEvents(new BlockBreakListener(this.plugin), this.plugin); |
| 71 | + pluginManager.registerEvents(new BlockPlaceListener(this.plugin), this.plugin); |
| 72 | + pluginManager.registerEvents(new FirestrikerListener(this.plugin), this.plugin); |
| 73 | + pluginManager.registerEvents(new ShivPoison(this.plugin), this.plugin); |
| 74 | + pluginManager.registerEvents(new WaterBowlListener(this.plugin), this.plugin); |
| 75 | + pluginManager.registerEvents(new Campfire(this.plugin), this.plugin); |
| 76 | + } |
| 77 | + if (this.config.mechanics_bow) |
| 78 | + pluginManager.registerEvents(new BowListener(this.plugin), this.plugin); |
| 79 | + if (this.config.mechanics_grappling_hook) |
| 80 | + pluginManager.registerEvents(new GrapplingHookListener(this.plugin), this.plugin); |
| 81 | + if (this.config.legendary_obsidian_mace) |
| 82 | + pluginManager.registerEvents(new ObsidianMaceWeakness(this.plugin), this.plugin); |
| 83 | + if (this.config.legendary_valkyrie) |
| 84 | + pluginManager.registerEvents(new Valkyrie(this.plugin), this.plugin); |
| 85 | + if (this.config.legendary_giant_blade) |
| 86 | + pluginManager.registerEvents(new GiantBlade(this.plugin), this.plugin); |
| 87 | + if (this.config.legendary_blaze_sword) |
| 88 | + pluginManager.registerEvents(new BlazeSword(), this.plugin); |
| 89 | + if (this.config.settings_local_chat_distance > -1) |
| 90 | + pluginManager.registerEvents(new LocalChat(this.plugin), this.plugin); |
| 91 | + if (this.config.mechanics_compass_waypoint) |
| 92 | + pluginManager.registerEvents(new CompassWaypoint(this.plugin), this.plugin); |
| 93 | + if (this.config.mechanics_medic_kit) |
| 94 | + pluginManager.registerEvents(new MedicKit(this.plugin), this.plugin); |
99 | 95 |
|
100 | | - pm.registerEvents(new WaterBottleListener(plugin), this.plugin); |
| 96 | + pluginManager.registerEvents(new WaterBottleListener(this.plugin), this.plugin); |
101 | 97 |
|
102 | | - if (config.settings_resource_pack_enabled) { |
103 | | - pm.registerEvents(new ResourcePackListener(plugin), this.plugin); |
| 98 | + if (this.config.settings_resource_pack_enabled) { |
| 99 | + pluginManager.registerEvents(new ResourcePackListener(this.plugin), this.plugin); |
104 | 100 | } |
105 | 101 |
|
106 | | - if (config.mechanics_raw_meat_hunger) |
107 | | - pm.registerEvents(new RawMeatHunger(), this.plugin); |
108 | | - if (config.mechanics_thirst_enabled) { |
109 | | - pm.registerEvents(new ThirstListener(this.plugin), this.plugin); |
110 | | - if (config.mechanics_thirst_purify_water) |
111 | | - pm.registerEvents(new CauldronWaterBottle(), this.plugin); |
112 | | - } |
113 | | - if (config.mechanics_poison_potato) |
114 | | - pm.registerEvents(new PoisonousPotato(), this.plugin); |
115 | | - if (config.mechanics_shared_workbench) |
116 | | - pm.registerEvents(new WorkbenchShare(plugin), this.plugin); |
117 | | - if (config.mechanics_chairs_enabled) |
118 | | - pm.registerEvents(new Chairs(plugin), this.plugin); |
119 | | - if (config.mechanics_cookie_boost) |
120 | | - pm.registerEvents(new CookieHealthBoost(), this.plugin); |
121 | | - if (config.mechanics_beet_strength) |
122 | | - pm.registerEvents(new BeetrootStrength(), this.plugin); |
123 | | - if (config.mechanics_tropical_fish) |
124 | | - pm.registerEvents(new TropicalFish(this.plugin), this.plugin); |
125 | | - if (config.mechanics_living_slime) |
126 | | - pm.registerEvents(new LivingSlime(plugin), this.plugin); |
127 | | - if (config.mechanics_energy_enabled) |
128 | | - pm.registerEvents(new EnergyChange(plugin), this.plugin); |
129 | | - if (config.mechanics_food_diversity_enabled) |
130 | | - pm.registerEvents(new FoodDiversityConsume(plugin), this.plugin); |
131 | | - if (config.mechanics_recurved_bow) |
132 | | - pm.registerEvents(new RecurvedBowListener(plugin), this.plugin); |
133 | | - if (config.mechanics_snowball_revamp) |
134 | | - pm.registerEvents(new SnowballThrow(), this.plugin); |
135 | | - if (config.MECHANICS_SNOW_GEN_REVAMP) |
136 | | - pm.registerEvents(new SnowGeneration(plugin), this.plugin); |
137 | | - if (config.entity_mechanics_chicken_breeding_enabled) |
138 | | - pm.registerEvents(new ChickenSpawn(this.plugin), this.plugin); |
139 | | - if (config.welcome_guide_enabled) |
140 | | - pm.registerEvents(new Guide(plugin), this.plugin); |
| 102 | + if (this.config.mechanics_raw_meat_hunger) |
| 103 | + pluginManager.registerEvents(new RawMeatHunger(), this.plugin); |
| 104 | + if (this.config.mechanics_thirst_enabled) { |
| 105 | + pluginManager.registerEvents(new ThirstListener(this.plugin), this.plugin); |
| 106 | + if (this.config.mechanics_thirst_purify_water) |
| 107 | + pluginManager.registerEvents(new CauldronWaterBottle(), this.plugin); |
| 108 | + } |
| 109 | + if (this.config.mechanics_poison_potato) |
| 110 | + pluginManager.registerEvents(new PoisonousPotato(), this.plugin); |
| 111 | + if (this.config.mechanics_shared_workbench) |
| 112 | + pluginManager.registerEvents(new WorkbenchShare(this.plugin), this.plugin); |
| 113 | + if (this.config.mechanics_chairs_enabled) |
| 114 | + pluginManager.registerEvents(new Chairs(this.plugin), this.plugin); |
| 115 | + if (this.config.mechanics_cookie_boost) |
| 116 | + pluginManager.registerEvents(new CookieHealthBoost(), this.plugin); |
| 117 | + if (this.config.mechanics_beet_strength) |
| 118 | + pluginManager.registerEvents(new BeetrootStrength(), this.plugin); |
| 119 | + if (this.config.mechanics_tropical_fish) |
| 120 | + pluginManager.registerEvents(new TropicalFish(this.plugin), this.plugin); |
| 121 | + if (this.config.mechanics_living_slime) |
| 122 | + pluginManager.registerEvents(new LivingSlime(this.plugin), this.plugin); |
| 123 | + if (this.config.mechanics_energy_enabled) |
| 124 | + pluginManager.registerEvents(new EnergyChange(this.plugin), this.plugin); |
| 125 | + if (this.config.mechanics_food_diversity_enabled) |
| 126 | + pluginManager.registerEvents(new FoodDiversityConsume(this.plugin), this.plugin); |
| 127 | + if (this.config.mechanics_recurved_bow) |
| 128 | + pluginManager.registerEvents(new RecurvedBowListener(this.plugin), this.plugin); |
| 129 | + if (this.config.mechanics_snowball_revamp) |
| 130 | + pluginManager.registerEvents(new SnowballThrow(), this.plugin); |
| 131 | + if (this.config.entity_mechanics_chicken_breeding_enabled) |
| 132 | + pluginManager.registerEvents(new ChickenSpawn(this.plugin), this.plugin); |
| 133 | + if (this.config.welcome_guide_enabled) |
| 134 | + pluginManager.registerEvents(new Guide(this.plugin), this.plugin); |
141 | 135 |
|
142 | | - if (config.entity_mechanics_pigmen_chest_enabled) |
143 | | - pm.registerEvents(new ChestPigmen(this.plugin), this.plugin); |
| 136 | + if (this.config.entity_mechanics_pigmen_chest_enabled) |
| 137 | + pluginManager.registerEvents(new ChestPigmen(this.plugin), this.plugin); |
144 | 138 |
|
145 | | - if (config.entity_mechanics_beekeeper_suit_enabled) { |
| 139 | + if (this.config.entity_mechanics_beekeeper_suit_enabled) { |
146 | 140 | Bukkit.getPluginManager().registerEvents(new BeeKeeperSuit(), this.plugin); |
147 | 141 | } |
148 | | - if (config.survival_update_merchant_trades) { |
149 | | - pm.registerEvents(new MerchantTrades(this.plugin), this.plugin); |
| 142 | + if (this.config.survival_update_merchant_trades) { |
| 143 | + pluginManager.registerEvents(new MerchantTrades(this.plugin), this.plugin); |
150 | 144 | } |
151 | 145 | if (this.config.survival_update_loot_tables) { |
152 | | - pm.registerEvents(new LootTableListener(plugin), this.plugin); |
| 146 | + pluginManager.registerEvents(new LootTableListener(this.plugin), this.plugin); |
153 | 147 | } |
154 | | - pm.registerEvents(new PiglinBarter(this.plugin), this.plugin); |
| 148 | + pluginManager.registerEvents(new PiglinBarter(this.plugin), this.plugin); |
155 | 149 | // Config handled within this event |
156 | | - pm.registerEvents(new EntityDeath(this.plugin), this.plugin); |
157 | | - pm.registerEvents(new RepairCrafting(), this.plugin); |
| 150 | + pluginManager.registerEvents(new EntityDeath(this.plugin), this.plugin); |
| 151 | + pluginManager.registerEvents(new RepairCrafting(), this.plugin); |
158 | 152 |
|
159 | | - } |
| 153 | + } |
160 | 154 |
|
161 | 155 | } |
0 commit comments