mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-18 15:18:34 +01:00
Improve Bukkit version comparison, fixes #516
This commit is contained in:
parent
9a6465e6a4
commit
c06879b2ec
@ -70,29 +70,29 @@ public class NpcEffectThread implements Runnable {
|
||||
*/
|
||||
private void showEffect(Player player, NPC npc, String effectType) {
|
||||
try {
|
||||
if (Quests.bukkitVersion >= 1132) {
|
||||
if (Quests.bukkitVersion.contains("1.13.2")) {
|
||||
showEffect_1_13_R2(player, npc, effectType);
|
||||
} else if (Quests.bukkitVersion >= 113) {
|
||||
} else if (Quests.bukkitVersion.contains("1.13")) {
|
||||
showEffect_1_13_R1(player, npc, effectType);
|
||||
} else if (Quests.bukkitVersion >= 112 ) {
|
||||
} else if (Quests.bukkitVersion.contains("1.12")) {
|
||||
showEffect_1_12_R1(player, npc, effectType);
|
||||
} else if (Quests.bukkitVersion >= 111) {
|
||||
} else if (Quests.bukkitVersion.contains("1.11")) {
|
||||
showEffect_1_11_R1(player, npc, effectType);
|
||||
} else if (Quests.bukkitVersion >= 110) {
|
||||
} else if (Quests.bukkitVersion.contains("1.10")) {
|
||||
showEffect_1_10_R1(player, npc, effectType);
|
||||
} else if (Quests.bukkitVersion >= 194) {
|
||||
} else if (Quests.bukkitVersion.contains("1.9.4")) {
|
||||
showEffect_1_9_R2(player, npc, effectType);
|
||||
} else if (Quests.bukkitVersion >= 19) {
|
||||
} else if (Quests.bukkitVersion.contains("1.9")) {
|
||||
showEffect_1_9_R1(player, npc, effectType);
|
||||
} else if (Quests.bukkitVersion >= 184) {
|
||||
} else if (Quests.bukkitVersion.contains("1.8.4")) {
|
||||
showEffect_1_8_R3(player, npc, effectType);
|
||||
} else if (Quests.bukkitVersion >= 183) {
|
||||
} else if (Quests.bukkitVersion.contains("1.8.3")) {
|
||||
showEffect_1_8_R2(player, npc, effectType);
|
||||
} else if (Quests.bukkitVersion >= 18) {
|
||||
} else if (Quests.bukkitVersion.contains("1.8")) {
|
||||
showEffect_1_8_R1(player, npc, effectType);
|
||||
} else if (Quests.bukkitVersion >= 1710) {
|
||||
} else if (Quests.bukkitVersion.contains("1.7.10")) {
|
||||
showEffect_R4(player, npc, effectType);
|
||||
} else if (Quests.bukkitVersion >= 179) {
|
||||
} else if (Quests.bukkitVersion.contains("1.7.9")) {
|
||||
showEffect_R3(player, npc, effectType);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -111,7 +111,7 @@ import ro.nicuch.citizensbooks.CitizensBooksPlugin;
|
||||
|
||||
public class Quests extends JavaPlugin implements ConversationAbandonedListener {
|
||||
|
||||
public static int bukkitVersion = 0;
|
||||
public static String bukkitVersion = "0";
|
||||
// Dependencies
|
||||
public static Economy economy = null;
|
||||
public static Permission permission = null;
|
||||
@ -174,7 +174,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
bukkitVersion = Integer.valueOf(Bukkit.getServer().getBukkitVersion().split("-")[0].replace(".", ""));
|
||||
bukkitVersion = Bukkit.getServer().getBukkitVersion().split("-")[0];
|
||||
pListener = new PlayerListener(this);
|
||||
effListener = new NpcEffectThread(this);
|
||||
npcListener = new NpcListener(this);
|
||||
@ -268,7 +268,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
|
||||
if (!outDir.exists()) {
|
||||
if (!outDir.mkdirs()) {
|
||||
getLogger().log(Level.SEVERE, "Failed to make directories for " + outFile.getName() + "(canWrite= " + outFile.canWrite());
|
||||
getLogger().log(Level.SEVERE, "Failed to make directories for " + outFile.getName() + " (canWrite= " + outFile.canWrite() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
package me.blackvein.quests.util;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
|
||||
@ -26,6 +27,7 @@ import org.bukkit.entity.Player;
|
||||
public class LocaleQuery {
|
||||
private static Class<?> craftMagicNumbers = null;
|
||||
private final Quests plugin;
|
||||
static boolean oldVersion = isBelow113();
|
||||
|
||||
public LocaleQuery(Quests plugin){
|
||||
this.plugin = plugin;
|
||||
@ -35,7 +37,7 @@ public class LocaleQuery {
|
||||
public void sendMessage(Player player, String message, Material material) {
|
||||
if (plugin.translateItems) {
|
||||
String key = queryByType(material);
|
||||
if (Quests.bukkitVersion <= 1122) {
|
||||
if (oldVersion) {
|
||||
if (key.startsWith("tile.") || key.startsWith("item.")) {
|
||||
key = key + ".name";
|
||||
}
|
||||
@ -52,13 +54,13 @@ public class LocaleQuery {
|
||||
public void sendMessage(Player player, String message, Material material, Enchantment enchantment) {
|
||||
if (plugin.translateItems) {
|
||||
String key = queryByType(material);
|
||||
if (Quests.bukkitVersion <= 1122) {
|
||||
if (oldVersion) {
|
||||
if (key.startsWith("tile.") || key.startsWith("item.")) {
|
||||
key = key + ".name";
|
||||
}
|
||||
}
|
||||
String key2 = "";
|
||||
if (Quests.bukkitVersion <= 1122) {
|
||||
if (oldVersion) {
|
||||
key2 = "enchantment." + MiscUtil.getProperEnchantmentName(enchantment).replace("_", ".")
|
||||
.replace("environmental", "all").replace("protection", "protect");
|
||||
} else {
|
||||
@ -78,7 +80,7 @@ public class LocaleQuery {
|
||||
public void sendMessage(Player player, String message, EntityType type) {
|
||||
if (plugin.translateItems) {
|
||||
String key = "";
|
||||
if (Quests.bukkitVersion <= 1122) {
|
||||
if (oldVersion) {
|
||||
key = "entity." + MiscUtil.getProperMobName(type) + ".name";
|
||||
} else {
|
||||
key = "entity.minecraft." + type.toString().toLowerCase();
|
||||
@ -121,4 +123,37 @@ public class LocaleQuery {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBelow113() {
|
||||
String ver = Quests.bukkitVersion;
|
||||
if (Quests.bukkitVersion.matches("^[0-9]+$")) {
|
||||
switch(ver) {
|
||||
case "1.12" :
|
||||
return true;
|
||||
case "1.11" :
|
||||
return true;
|
||||
case "1.10" :
|
||||
return true;
|
||||
case "1.9.4" :
|
||||
return true;
|
||||
case "1.9" :
|
||||
return true;
|
||||
case "1.8.4" :
|
||||
return true;
|
||||
case "1.8.3" :
|
||||
return true;
|
||||
case "1.8" :
|
||||
return true;
|
||||
case "1.7.10" :
|
||||
return true;
|
||||
case "1.7.9" :
|
||||
return true;
|
||||
default:
|
||||
// Bukkit version is 1.13+
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Bukkit.getLogger().severe("Invalid Bukkit version " + ver);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user