mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-05 10:20:46 +01:00
Support custom Potion colors, fixes #635
This commit is contained in:
parent
7909dbddad
commit
47be17c9f3
BIN
lib/Citizens-2.0.24-b1591.jar
Normal file
BIN
lib/Citizens-2.0.24-b1591.jar
Normal file
Binary file not shown.
BIN
lib/Heroes.jar
Normal file
BIN
lib/Heroes.jar
Normal file
Binary file not shown.
Binary file not shown.
BIN
lib/PlaceholderAPI-2.8.2.jar
Normal file
BIN
lib/PlaceholderAPI-2.8.2.jar
Normal file
Binary file not shown.
BIN
lib/Vault.jar
Normal file
BIN
lib/Vault.jar
Normal file
Binary file not shown.
BIN
lib/worldedit-bukkit-6.1.9.jar
Normal file
BIN
lib/worldedit-bukkit-6.1.9.jar
Normal file
Binary file not shown.
BIN
lib/worldguard-bukkit-6.2.2.jar
Normal file
BIN
lib/worldguard-bukkit-6.2.2.jar
Normal file
Binary file not shown.
@ -3,11 +3,7 @@ package me.blackvein.quests;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import net.aufdemrand.denizen.BukkitScriptEntryData;
|
||||
import net.aufdemrand.denizen.Denizen;
|
||||
import net.aufdemrand.denizen.objects.dPlayer;
|
||||
import net.aufdemrand.denizencore.scripts.ScriptRegistry;
|
||||
import net.aufdemrand.denizencore.scripts.containers.core.TaskScriptContainer;
|
||||
import net.citizensnpcs.api.CitizensPlugin;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
@ -22,6 +22,7 @@ import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||
@ -30,6 +31,7 @@ import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
|
||||
import me.blackvein.quests.Quester;
|
||||
|
||||
@ -163,8 +165,10 @@ public class ItemUtil {
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
String[] flags = new String[10];
|
||||
LinkedHashMap<Enchantment, Integer> stored = new LinkedHashMap<Enchantment, Integer>();
|
||||
int potionColor = -1;
|
||||
LinkedHashMap<String, Object> extra = new LinkedHashMap<String, Object>();
|
||||
ItemMeta meta = null;
|
||||
PotionMeta pmeta = null;
|
||||
EnchantmentStorageMeta esmeta = null;
|
||||
for (String targ : args) {
|
||||
String arg = targ.replace("minecraft|", "minecraft:");
|
||||
@ -267,10 +271,21 @@ public class ItemUtil {
|
||||
Bukkit.getLogger().info("You are running a version of CraftBukkit"
|
||||
+ " for which Quests cannot set the NBT tag " + key);
|
||||
}
|
||||
} else {
|
||||
} else if (!key.contains("custom-color")){
|
||||
extra.put(key, value);
|
||||
}
|
||||
} else if (arg.startsWith("[") && arg.endsWith("]")) {
|
||||
if (arg.contains("rgb")) {
|
||||
// Custom potion color
|
||||
String[] mapping = arg.replace("[", "").replace("]", "").split("x");
|
||||
potionColor = Integer.valueOf(mapping[1]);
|
||||
} else {
|
||||
Bukkit.getLogger().severe("Quests does not know how to handle "
|
||||
+ arg + " so please contact the developer on Github");
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
Bukkit.getLogger().severe("Quests was unable to read item argument: " + arg);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -314,6 +329,16 @@ public class ItemUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (potionColor != -1) {
|
||||
pmeta = (PotionMeta) meta;
|
||||
try {
|
||||
pmeta.setColor(Color.fromRGB(potionColor));
|
||||
} catch (Throwable tr) {
|
||||
// PotionMeta.setColor() not introduced until 1.11 (?)
|
||||
Bukkit.getLogger().info("You are running a version of CraftBukkit"
|
||||
+ " for which Quests cannot set the potion color " + potionColor);
|
||||
}
|
||||
}
|
||||
if (stack.getType().equals(Material.ENCHANTED_BOOK)) {
|
||||
esmeta = (EnchantmentStorageMeta) meta;
|
||||
for (Entry<Enchantment, Integer> e : stored.entrySet()) {
|
||||
|
Loading…
Reference in New Issue
Block a user