mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 04:25:15 +01:00
Use Bukkit provided PotionType
This commit is contained in:
parent
7ecb265484
commit
ede05c85eb
@ -9,7 +9,6 @@ import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import com.gamingmesh.jobs.container.Potion;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
public class ItemManager {
|
||||
@ -54,8 +53,8 @@ public class ItemManager {
|
||||
mojangName = mojangName.replace("_", "").replace(" ", "").toLowerCase();
|
||||
|
||||
if (one.isCanHavePotionType()) {
|
||||
for (Potion p : Potion.values()) {
|
||||
byName.put(cmiName + ":" + p.toString().toLowerCase(), one);
|
||||
for (PotionType potType : PotionType.values()) {
|
||||
byName.put(cmiName + ":" + potType.toString().toLowerCase(), one);
|
||||
}
|
||||
} else if (byName.containsKey(cmiName)) {
|
||||
byName.put(cmiName + ":" + data, one);
|
||||
|
@ -17,7 +17,6 @@ import com.gamingmesh.jobs.CMILib.ConfigReader;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.NameList;
|
||||
import com.gamingmesh.jobs.container.Potion;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
@ -58,7 +57,7 @@ public class NameTranslatorManager {
|
||||
NameList nameLs = ListOfNames.get(mat);
|
||||
|
||||
if (nameLs != null) {
|
||||
if (meta != null && !meta.isEmpty() && mat.isCanHavePotionType() && Potion.getByName(meta) != null) {
|
||||
if (meta != null && !meta.isEmpty() && mat.isCanHavePotionType() && Util.getPotionByName(meta) != null) {
|
||||
return nameLs.getName() + ":" + meta;
|
||||
}
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
Jobs Plugin for Bukkit
|
||||
Copyright (C) 2011 Zak Ford <zak.j.ford@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
/**
|
||||
* <a href="https://papermc.io/javadocs/paper/1.13/org/bukkit/potion/PotionType.html">API reference for names</a>
|
||||
*/
|
||||
public enum Potion {
|
||||
AWKWARD,
|
||||
FIRE_RESISTANCE,
|
||||
INSTANT_DAMAGE,
|
||||
INSTANT_HEAL,
|
||||
INVISIBILITY,
|
||||
JUMP,
|
||||
LUCK,
|
||||
MUNDANE,
|
||||
NIGHT_VISION,
|
||||
LONG_NIGHT_VISION,
|
||||
POISON,
|
||||
REGENERATION,
|
||||
SLOW_FALLING,
|
||||
SLOWNESS,
|
||||
SPEED,
|
||||
STRENGTH,
|
||||
THICK,
|
||||
TURTLE_MASTER,
|
||||
WATER_BREATHING,
|
||||
WEAKNESS;
|
||||
|
||||
public static Potion getByName(String name) {
|
||||
for (Potion one : Potion.values()) {
|
||||
if (one.toString().equalsIgnoreCase(name)) {
|
||||
return one;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.potion.PotionType;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
@ -68,6 +69,16 @@ public class Util {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PotionType getPotionByName(String name) {
|
||||
for (PotionType one : PotionType.values()) {
|
||||
if (one.toString().equalsIgnoreCase(name)) {
|
||||
return one;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String firstToUpperCase(String name) {
|
||||
return name.toLowerCase().replace('_', ' ').substring(0, 1).toUpperCase() + name.toLowerCase().replace('_', ' ').substring(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user