|
11 | 11 | import com.hm.antiworldfly.worldguard.listener.RegionToggleGlide; |
12 | 12 | import org.apache.commons.lang.StringEscapeUtils; |
13 | 13 | import org.bstats.bukkit.Metrics; |
| 14 | +import org.bukkit.Bukkit; |
14 | 15 | import org.bukkit.ChatColor; |
15 | 16 | import org.bukkit.command.Command; |
16 | 17 | import org.bukkit.command.CommandSender; |
@@ -97,14 +98,17 @@ public AntiWorldFly() { |
97 | 98 | public void onLoad() { |
98 | 99 | extractParametersFromConfig(true); |
99 | 100 |
|
100 | | - this.getLogger().info("Attempting to register WorldGuard flag."); |
101 | | - try { |
102 | | - FlagRegistry flagRegistry = new FlagRegistry(this); |
103 | | - flagRegistry.register(getAntiFlyFlag()); |
104 | | - flagRegistry.register(getAntiElytraFlag()); |
105 | | - } |
106 | | - catch (NoClassDefFoundError ignored) { |
107 | | - this.getLogger().info("WorldGuard not detected, continuing with a limited feature-set."); |
| 101 | + if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) { |
| 102 | + this.getLogger().info("WorldGuard detected! Attempting to register region flags."); |
| 103 | + try { |
| 104 | + FlagRegistry flagRegistry = new FlagRegistry(this); |
| 105 | + flagRegistry.register(getAntiFlyFlag()); |
| 106 | + flagRegistry.register(getAntiElytraFlag()); |
| 107 | + } |
| 108 | + catch (NoClassDefFoundError ignored) { |
| 109 | + this.getLogger().info("There were issues with WorldGuard... Was there a major update recently?" + |
| 110 | + "Please open an issue on the GitHub: https://github.com/PyvesB/AntiWorldFly/issues"); |
| 111 | + } |
108 | 112 | } |
109 | 113 | } |
110 | 114 |
|
@@ -134,18 +138,27 @@ public void onEnable() { |
134 | 138 | awfPlayerMove = new PlayerMove(this); |
135 | 139 | awfRegionToggleGlide = new RegionToggleGlide(this); |
136 | 140 | } |
137 | | - catch (NoClassDefFoundError ignored) {} // already logged in onLoad() |
| 141 | + catch (NoClassDefFoundError ignored) { |
| 142 | + } // already logged in onLoad() |
138 | 143 |
|
139 | 144 | PluginManager pm = getServer().getPluginManager(); |
140 | 145 |
|
| 146 | + System.out.println(awfToggleGlide); |
| 147 | + System.out.println(awfPlayerMove); |
| 148 | + System.out.println(awfRegionToggleGlide); |
| 149 | + |
141 | 150 | pm.registerEvents(awfPreProcess, this); |
142 | 151 | pm.registerEvents(awfWorldJoin, this); |
143 | 152 | pm.registerEvents(awfPlayerJoin, this); |
144 | 153 | pm.registerEvents(awfPlayerToggleFly, this); |
145 | 154 | try { |
146 | 155 | pm.registerEvents(awfToggleGlide, this); |
147 | | - pm.registerEvents(awfPlayerMove, this); |
148 | | - pm.registerEvents(awfRegionToggleGlide, this); |
| 156 | + |
| 157 | + // Do not register these events if WorldGuard isn't installed |
| 158 | + if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) { |
| 159 | + pm.registerEvents(awfPlayerMove, this); |
| 160 | + pm.registerEvents(awfRegionToggleGlide, this); |
| 161 | + } |
149 | 162 | } |
150 | 163 | catch (IllegalArgumentException ignored) {} // logged elsewhere |
151 | 164 |
|
|
0 commit comments