Skip to content

Commit 9c85ab2

Browse files
committed
Fix WorldGuard detection logic
1 parent 0562e9f commit 9c85ab2

4 files changed

Lines changed: 27 additions & 14 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.hm.antiworldfly</groupId>
55
<artifactId>AntiWorldFly</artifactId>
6-
<version>2.5.1</version>
6+
<version>2.5.2</version>
77
<url>https://github.com/PyvesB/AntiWorldFly</url>
88
<name>AntiWorldFly</name>
99
<description>A Minecraft plugin to disable flying and chosen commands when joining or playing in specific worlds.</description>

src/main/java/com/hm/antiworldfly/AntiWorldFly.java

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.hm.antiworldfly.worldguard.listener.RegionToggleGlide;
1212
import org.apache.commons.lang.StringEscapeUtils;
1313
import org.bstats.bukkit.Metrics;
14+
import org.bukkit.Bukkit;
1415
import org.bukkit.ChatColor;
1516
import org.bukkit.command.Command;
1617
import org.bukkit.command.CommandSender;
@@ -97,14 +98,17 @@ public AntiWorldFly() {
9798
public void onLoad() {
9899
extractParametersFromConfig(true);
99100

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+
}
108112
}
109113
}
110114

@@ -134,18 +138,27 @@ public void onEnable() {
134138
awfPlayerMove = new PlayerMove(this);
135139
awfRegionToggleGlide = new RegionToggleGlide(this);
136140
}
137-
catch (NoClassDefFoundError ignored) {} // already logged in onLoad()
141+
catch (NoClassDefFoundError ignored) {
142+
} // already logged in onLoad()
138143

139144
PluginManager pm = getServer().getPluginManager();
140145

146+
System.out.println(awfToggleGlide);
147+
System.out.println(awfPlayerMove);
148+
System.out.println(awfRegionToggleGlide);
149+
141150
pm.registerEvents(awfPreProcess, this);
142151
pm.registerEvents(awfWorldJoin, this);
143152
pm.registerEvents(awfPlayerJoin, this);
144153
pm.registerEvents(awfPlayerToggleFly, this);
145154
try {
146155
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+
}
149162
}
150163
catch (IllegalArgumentException ignored) {} // logged elsewhere
151164

src/main/resources/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#==============================O==============================#
22
# I---------------------------------------------------------I #
3-
# | Anti World Fly 2.5.1 configuration - Readme | #
3+
# | Anti World Fly 2.5.2 configuration - Readme | #
44
# 1---------------------------------------------------------1 #
55
#==============================o==============================#
66

src/main/resources/lang.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#============================================================#
22
# +--------------------------------------------------------+ #
3-
# | Anti World Fly 2.5.1 English language file | #
3+
# | Anti World Fly 2.5.2 English language file | #
44
# | By DarkPyves | #
55
# | Maintained by Sidpatchy | #
66
# +--------------------------------------------------------+ #

0 commit comments

Comments
 (0)