Addressing (hopefully) npe in Compat listener.

This commit is contained in:
ProgrammerDan 2016-04-21 18:50:04 -04:00
parent d498cb52ec
commit 66297bd2e5
5 changed files with 16 additions and 18 deletions

View File

@ -3,8 +3,6 @@ root = true
[*]
end_of_line = lf
insert_final_newline = true
[*.java]
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true

View File

@ -4,7 +4,7 @@
<groupId>com.dre</groupId>
<artifactId>brewery</artifactId>
<version>1.4.0</version>
<version>1.4.1</version>
<name>Brewery</name>
<properties>
@ -18,7 +18,7 @@
<resources>
<!-- Static resources -->
<resource>
<filtering>false</filtering>
<filtering>true</filtering>
<directory>${project.basedir}/resources</directory>
<includes>
<include>**/*.yml</include>

View File

@ -1,5 +1,5 @@
name: Brewery
version: 1.4.0
name: ${project.name}
version: ${project.version}
main: com.dre.brewery.P
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan]
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault]

View File

@ -38,7 +38,7 @@ public class P extends JavaPlugin {
public static String configVersion = "1.3.1";
public static boolean debug;
public static boolean useUUID;
public static boolean use1_9;
public static boolean use1_9;
public static boolean updateCheck;
// Third Party Enabled
@ -55,7 +55,7 @@ public class P extends JavaPlugin {
public EntityListener entityListener;
public InventoryListener inventoryListener;
public WorldListener worldListener;
public Compat1_9 compat1_9;
public Compat1_9 compat1_9;
// Language
public String language;
@ -68,11 +68,10 @@ public class P extends JavaPlugin {
// Version check
String v = Bukkit.getBukkitVersion();
useUUID = !v.matches(".*1\\.[0-6].*") && !v.matches(".*1\\.7\\.[0-5].*");
use1_9 = !v.matches(".*1\\.[0-8].*");
if (use1_9) {
log("&cExperimental support for Bukkit 1.9 enabled.");
log("&cPlease note that the changes of 1.9 make a build of Brewery with the same quality as for older versions impossible.");
}
use1_9 = !v.matches(".*1\\.[0-8].*");
if (use1_9) {
log("&cExperimental support for Bukkit 1.9 enabled.");
}
// load the Config
try {
@ -98,7 +97,7 @@ public class P extends JavaPlugin {
entityListener = new EntityListener();
inventoryListener = new InventoryListener();
worldListener = new WorldListener();
compat1_9 = new Compat1_9();
compat1_9 = new Compat1_9();
getCommand("Brewery").setExecutor(new CommandListener());
p.getServer().getPluginManager().registerEvents(blockListener, p);
@ -106,9 +105,9 @@ public class P extends JavaPlugin {
p.getServer().getPluginManager().registerEvents(entityListener, p);
p.getServer().getPluginManager().registerEvents(inventoryListener, p);
p.getServer().getPluginManager().registerEvents(worldListener, p);
if (use1_9) {
p.getServer().getPluginManager().registerEvents(compat1_9, p);
}
if (use1_9) {
p.getServer().getPluginManager().registerEvents(compat1_9, p);
}
// Heartbeat
p.getServer().getScheduler().runTaskTimer(p, new BreweryRunnable(), 650, 1200);

View File

@ -22,7 +22,8 @@ public class Compat1_9 implements Listener {
if (item.getType() == Material.POTION) {
try {
PotionMeta meta = (PotionMeta) item.getItemMeta();
meta.setMainEffect(null);
// Throw away former "base" effect and replace with MUNDANE.
meta.setBasePotionData(new PotionData(PotionType.MUNDANE, false, false));
item.setItemMeta(meta);
} catch (Exception exception) {}
}