2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.util.spout;
|
|
|
|
|
|
|
|
import java.io.BufferedOutputStream;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.jar.JarFile;
|
|
|
|
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.entity.Player;
|
2013-05-15 23:08:43 +02:00
|
|
|
import org.bukkit.plugin.PluginManager;
|
2013-03-01 06:52:01 +01:00
|
|
|
import org.getspout.spoutapi.SpoutManager;
|
|
|
|
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
|
|
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
2013-05-15 23:08:43 +02:00
|
|
|
import com.gmail.nossr50.config.spout.SpoutConfig;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
|
|
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.util.StringUtils;
|
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
|
|
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
|
|
|
|
|
|
public class SpoutUtils {
|
2013-05-15 23:08:43 +02:00
|
|
|
// The order of the values is extremely important, a few methods depend on it to work properly
|
|
|
|
protected enum Tier {
|
|
|
|
FOUR(4) {
|
|
|
|
@Override public int getLevel() { return SpoutConfig.getInstance().getNotificationTier4(); }
|
|
|
|
@Override protected Material getAcrobaticsNotificationItem() { return Material.DIAMOND_BOOTS; }
|
|
|
|
@Override protected Material getArcheryNotificationItem() { return Material.BOW; }
|
|
|
|
@Override protected Material getAxesNotificationItem() { return Material.DIAMOND_AXE; }
|
|
|
|
@Override protected Material getExcavationNotificationItem() { return Material.CLAY; }
|
|
|
|
@Override protected Material getFishingNotificationItem() { return Material.FISHING_ROD; }
|
|
|
|
@Override protected Material getHerbalismNotificationItem() { return Material.WATER_LILY; }
|
|
|
|
@Override protected Material getMiningNotificationItem() { return Material.EMERALD_ORE; }
|
|
|
|
@Override protected Material getSwordsNotificationItem() { return Material.DIAMOND_SWORD; }
|
|
|
|
@Override protected Material getTamingNotificationItem() { return Material.BONE; }
|
|
|
|
@Override protected Material getUnarmedNotificationItem() { return Material.DIAMOND_HELMET; }
|
|
|
|
@Override protected Material getWoodcuttingNotificationItem() { return Material.LOG; }},
|
|
|
|
THREE(3) {
|
|
|
|
@Override public int getLevel() { return SpoutConfig.getInstance().getNotificationTier3(); }
|
|
|
|
@Override protected Material getAcrobaticsNotificationItem() { return Material.GOLD_BOOTS; }
|
|
|
|
@Override protected Material getArcheryNotificationItem() { return Material.ARROW; }
|
|
|
|
@Override protected Material getAxesNotificationItem() { return Material.GOLD_AXE; }
|
|
|
|
@Override protected Material getExcavationNotificationItem() { return Material.SAND; }
|
|
|
|
@Override protected Material getFishingNotificationItem() { return Material.COOKED_FISH; }
|
|
|
|
@Override protected Material getHerbalismNotificationItem() { return Material.RED_ROSE; }
|
|
|
|
@Override protected Material getMiningNotificationItem() { return Material.DIAMOND_ORE; }
|
|
|
|
@Override protected Material getSwordsNotificationItem() { return Material.GOLD_SWORD; }
|
|
|
|
@Override protected Material getTamingNotificationItem() { return Material.GRILLED_PORK; }
|
|
|
|
@Override protected Material getUnarmedNotificationItem() { return Material.GOLD_HELMET; }
|
|
|
|
@Override protected Material getWoodcuttingNotificationItem() { return Material.WOOD; }},
|
|
|
|
TWO(2) {
|
|
|
|
@Override public int getLevel() { return SpoutConfig.getInstance().getNotificationTier2(); }
|
|
|
|
@Override protected Material getAcrobaticsNotificationItem() { return Material.IRON_BOOTS; }
|
|
|
|
@Override protected Material getArcheryNotificationItem() { return Material.ARROW; }
|
|
|
|
@Override protected Material getAxesNotificationItem() { return Material.IRON_AXE; }
|
|
|
|
@Override protected Material getExcavationNotificationItem() { return Material.GRAVEL; }
|
|
|
|
@Override protected Material getFishingNotificationItem() { return Material.COOKED_FISH; }
|
|
|
|
@Override protected Material getHerbalismNotificationItem() { return Material.YELLOW_FLOWER; }
|
|
|
|
@Override protected Material getMiningNotificationItem() { return Material.GOLD_ORE; }
|
|
|
|
@Override protected Material getSwordsNotificationItem() { return Material.IRON_SWORD; }
|
|
|
|
@Override protected Material getTamingNotificationItem() { return Material.GRILLED_PORK; }
|
|
|
|
@Override protected Material getUnarmedNotificationItem() { return Material.IRON_HELMET; }
|
|
|
|
@Override protected Material getWoodcuttingNotificationItem() { return Material.LEAVES; }},
|
|
|
|
ONE(1) {
|
|
|
|
@Override public int getLevel() { return SpoutConfig.getInstance().getNotificationTier1(); }
|
|
|
|
@Override protected Material getAcrobaticsNotificationItem() { return Material.CHAINMAIL_BOOTS; }
|
|
|
|
@Override protected Material getArcheryNotificationItem() { return Material.FLINT; }
|
|
|
|
@Override protected Material getAxesNotificationItem() { return Material.STONE_AXE; }
|
|
|
|
@Override protected Material getExcavationNotificationItem() { return Material.GRASS; }
|
|
|
|
@Override protected Material getFishingNotificationItem() { return Material.RAW_FISH; }
|
|
|
|
@Override protected Material getHerbalismNotificationItem() { return Material.CACTUS; }
|
|
|
|
@Override protected Material getMiningNotificationItem() { return Material.IRON_ORE; }
|
|
|
|
@Override protected Material getSwordsNotificationItem() { return Material.STONE_SWORD; }
|
|
|
|
@Override protected Material getTamingNotificationItem() { return Material.PORK; }
|
|
|
|
@Override protected Material getUnarmedNotificationItem() { return Material.CHAINMAIL_HELMET; }
|
|
|
|
@Override protected Material getWoodcuttingNotificationItem() { return Material.SAPLING; }};
|
|
|
|
|
|
|
|
int numerical;
|
|
|
|
|
|
|
|
private Tier(int numerical) {
|
|
|
|
this.numerical = numerical;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int toNumerical() {
|
|
|
|
return numerical;
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract protected int getLevel();
|
|
|
|
abstract protected Material getAcrobaticsNotificationItem();
|
|
|
|
abstract protected Material getArcheryNotificationItem();
|
|
|
|
abstract protected Material getAxesNotificationItem();
|
|
|
|
abstract protected Material getExcavationNotificationItem();
|
|
|
|
abstract protected Material getFishingNotificationItem();
|
|
|
|
abstract protected Material getHerbalismNotificationItem();
|
|
|
|
abstract protected Material getMiningNotificationItem();
|
|
|
|
abstract protected Material getSwordsNotificationItem();
|
|
|
|
abstract protected Material getTamingNotificationItem();
|
|
|
|
abstract protected Material getUnarmedNotificationItem();
|
|
|
|
abstract protected Material getWoodcuttingNotificationItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
private final static String spoutDirectory = mcMMO.getMainDirectory() + "Resources" + File.separator;
|
|
|
|
private final static String hudDirectory = spoutDirectory + "HUD" + File.separator;
|
|
|
|
private final static String hudStandardDirectory = hudDirectory + "Standard" + File.separator;
|
|
|
|
private final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator;
|
|
|
|
private final static String soundDirectory = spoutDirectory + "Sound" + File.separator;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Write file to disk.
|
|
|
|
*
|
2013-05-15 23:28:47 +02:00
|
|
|
* @param fileName The name of the file
|
|
|
|
* @param filePath The name of the file path
|
2013-03-01 06:52:01 +01:00
|
|
|
*/
|
2013-05-15 23:28:47 +02:00
|
|
|
private static File writeFile(String fileName, String filePath) {
|
|
|
|
File currentFile = new File(filePath + fileName);
|
2013-04-18 17:23:45 +02:00
|
|
|
BufferedOutputStream os = null;
|
2013-03-01 06:52:01 +01:00
|
|
|
JarFile jar = null;
|
|
|
|
|
2013-05-15 23:28:47 +02:00
|
|
|
// No point in writing the file again if it already exists.
|
|
|
|
if (currentFile.exists()) {
|
|
|
|
return currentFile;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:28:47 +02:00
|
|
|
try {
|
2013-03-01 06:52:01 +01:00
|
|
|
jar = new JarFile(mcMMO.mcmmo);
|
2013-04-18 17:23:45 +02:00
|
|
|
|
|
|
|
@SuppressWarnings("resource")
|
2013-05-15 23:28:47 +02:00
|
|
|
InputStream is = jar.getInputStream(jar.getJarEntry("resources/" + fileName));
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
byte[] buf = new byte[2048];
|
|
|
|
int nbRead;
|
|
|
|
|
|
|
|
os = new BufferedOutputStream(new FileOutputStream(currentFile));
|
|
|
|
|
|
|
|
while ((nbRead = is.read(buf)) != -1) {
|
|
|
|
os.write(buf, 0, nbRead);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (FileNotFoundException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
finally {
|
2013-04-18 17:23:45 +02:00
|
|
|
if (jar != null) {
|
2013-03-01 06:52:01 +01:00
|
|
|
try {
|
2013-04-18 17:23:45 +02:00
|
|
|
jar.close();
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
catch (IOException ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (os != null) {
|
|
|
|
try {
|
|
|
|
os.close();
|
|
|
|
}
|
|
|
|
catch (IOException ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-05-15 23:28:47 +02:00
|
|
|
|
|
|
|
return currentFile;
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extract Spout files to the Resources directory.
|
|
|
|
*/
|
2013-05-15 23:28:47 +02:00
|
|
|
public static ArrayList<File> extractFiles() {
|
|
|
|
ArrayList<File> files = new ArrayList<File>();
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
// Setup directories
|
|
|
|
new File(spoutDirectory).mkdir();
|
|
|
|
new File(hudDirectory).mkdir();
|
|
|
|
new File(hudStandardDirectory).mkdir();
|
|
|
|
new File(hudRetroDirectory).mkdir();
|
|
|
|
new File(soundDirectory).mkdir();
|
|
|
|
|
|
|
|
// XP Bar images
|
|
|
|
for (int x = 0; x < 255; x++) {
|
2013-05-15 23:28:47 +02:00
|
|
|
String fileName;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
if (x < 10) {
|
2013-05-15 23:28:47 +02:00
|
|
|
fileName = "xpbar_inc00" + x + ".png";
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
else if (x < 100) {
|
2013-05-15 23:28:47 +02:00
|
|
|
fileName = "xpbar_inc0" + x + ".png";
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
else {
|
2013-05-15 23:28:47 +02:00
|
|
|
fileName = "xpbar_inc" + x + ".png";
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-05-15 23:28:47 +02:00
|
|
|
files.add(writeFile(fileName, hudStandardDirectory));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Standard XP Icons
|
|
|
|
for (SkillType skillType : SkillType.values()) {
|
|
|
|
if (skillType.isChildSkill()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-05-15 23:28:47 +02:00
|
|
|
String skillName = StringUtils.getCapitalized(skillType.toString());
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:28:47 +02:00
|
|
|
files.add(writeFile(skillName + ".png", hudStandardDirectory));
|
|
|
|
files.add(writeFile(skillName + "_r.png", hudRetroDirectory));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Blank icons
|
2013-05-15 23:28:47 +02:00
|
|
|
files.add(writeFile("Icon.png", hudStandardDirectory));
|
|
|
|
files.add(writeFile("Icon_r.png", hudRetroDirectory));
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
// Sound FX
|
2013-05-15 23:28:47 +02:00
|
|
|
files.add(writeFile("level.wav", soundDirectory));
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
return files;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle level-up notifications through Spout.
|
|
|
|
*
|
|
|
|
* @param skillType The skill that leveled up
|
|
|
|
* @param spoutPlayer The player that leveled up
|
|
|
|
*/
|
|
|
|
public static void levelUpNotification(SkillType skillType, SpoutPlayer spoutPlayer) {
|
|
|
|
PlayerProfile profile = UserManager.getPlayer(spoutPlayer).getProfile();
|
2013-05-15 23:08:43 +02:00
|
|
|
int skillLevel = profile.getSkillLevel(skillType);
|
|
|
|
Material notificationItem;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
switch (skillType) {
|
2013-05-15 23:08:43 +02:00
|
|
|
case ACROBATICS:
|
|
|
|
notificationItem = getAcrobaticsNotificationItem(skillLevel);
|
2013-03-01 06:52:01 +01:00
|
|
|
break;
|
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
case ARCHERY:
|
|
|
|
notificationItem = getArcheryNotificationItem(skillLevel);
|
2013-03-01 06:52:01 +01:00
|
|
|
break;
|
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
case AXES:
|
|
|
|
notificationItem = getAxesNotificationItem(skillLevel);
|
|
|
|
break;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
case EXCAVATION:
|
|
|
|
notificationItem = getExcavationNotificationItem(skillLevel);
|
2013-03-01 06:52:01 +01:00
|
|
|
break;
|
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
case FISHING:
|
|
|
|
notificationItem = getFishingNotificationItem(skillLevel);
|
2013-03-01 06:52:01 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HERBALISM:
|
2013-05-15 23:08:43 +02:00
|
|
|
notificationItem = getHerbalismNotificationItem(skillLevel);
|
2013-03-01 06:52:01 +01:00
|
|
|
break;
|
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
case MINING:
|
|
|
|
notificationItem = getMiningNotificationItem(skillLevel);
|
|
|
|
break;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
case REPAIR:
|
|
|
|
notificationItem = Material.ANVIL;
|
2013-03-01 06:52:01 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SWORDS:
|
2013-05-15 23:08:43 +02:00
|
|
|
notificationItem = getSwordsNotificationItem(skillLevel);
|
2013-03-01 06:52:01 +01:00
|
|
|
break;
|
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
case TAMING:
|
|
|
|
notificationItem = getTamingNotificationItem(skillLevel);
|
2013-03-01 06:52:01 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UNARMED:
|
2013-05-15 23:08:43 +02:00
|
|
|
notificationItem = getUnarmedNotificationItem(skillLevel);
|
|
|
|
break;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
case WOODCUTTING:
|
|
|
|
notificationItem = getWoodcuttingNotificationItem(skillLevel);
|
|
|
|
break;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
default:
|
|
|
|
notificationItem = Material.MAP;
|
|
|
|
break;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.LevelUp.1"), LocaleLoader.getString("Spout.LevelUp.2", SkillUtils.getSkillName(skillType), skillLevel), notificationItem);
|
|
|
|
SpoutManager.getSoundManager().playCustomSoundEffect(mcMMO.p, spoutPlayer, "level.wav", false);
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
private static Material getAcrobaticsNotificationItem(int skillLevel) {
|
|
|
|
for (Tier tier : Tier.values()) {
|
|
|
|
if (skillLevel >= tier.getLevel()) {
|
|
|
|
return tier.getAcrobaticsNotificationItem();
|
|
|
|
}
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
return Material.LEATHER_BOOTS;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
private static Material getArcheryNotificationItem(int skillLevel) {
|
|
|
|
for (Tier tier : Tier.values()) {
|
|
|
|
if (skillLevel >= tier.getLevel()) {
|
|
|
|
return tier.getArcheryNotificationItem();
|
|
|
|
}
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
return Material.FEATHER;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
private static Material getAxesNotificationItem(int skillLevel) {
|
|
|
|
for (Tier tier : Tier.values()) {
|
|
|
|
if (skillLevel >= tier.getLevel()) {
|
|
|
|
return tier.getAxesNotificationItem();
|
|
|
|
}
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
return Material.WOOD_AXE;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
private static Material getExcavationNotificationItem(int skillLevel) {
|
|
|
|
for (Tier tier : Tier.values()) {
|
|
|
|
if (skillLevel >= tier.getLevel()) {
|
|
|
|
return tier.getExcavationNotificationItem();
|
|
|
|
}
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
return Material.DIRT;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
private static Material getFishingNotificationItem(int skillLevel) {
|
|
|
|
for (Tier tier : Tier.values()) {
|
|
|
|
if (skillLevel >= tier.getLevel()) {
|
|
|
|
return tier.getFishingNotificationItem();
|
|
|
|
}
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
return Material.RAW_FISH;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
private static Material getHerbalismNotificationItem(int skillLevel) {
|
|
|
|
for (Tier tier : Tier.values()) {
|
|
|
|
if (skillLevel >= tier.getLevel()) {
|
|
|
|
return tier.getHerbalismNotificationItem();
|
|
|
|
}
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
return Material.VINE;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
private static Material getMiningNotificationItem(int skillLevel) {
|
|
|
|
for (Tier tier : Tier.values()) {
|
|
|
|
if (skillLevel >= tier.getLevel()) {
|
|
|
|
return tier.getMiningNotificationItem();
|
|
|
|
}
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
return Material.COAL_ORE;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
private static Material getSwordsNotificationItem(int skillLevel) {
|
|
|
|
for (Tier tier : Tier.values()) {
|
|
|
|
if (skillLevel >= tier.getLevel()) {
|
|
|
|
return tier.getSwordsNotificationItem();
|
|
|
|
}
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
return Material.WOOD_SWORD;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
private static Material getTamingNotificationItem(int skillLevel) {
|
|
|
|
for (Tier tier : Tier.values()) {
|
|
|
|
if (skillLevel >= tier.getLevel()) {
|
|
|
|
return tier.getTamingNotificationItem();
|
|
|
|
}
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
return Material.PORK;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
private static Material getUnarmedNotificationItem(int skillLevel) {
|
|
|
|
for (Tier tier : Tier.values()) {
|
|
|
|
if (skillLevel >= tier.getLevel()) {
|
|
|
|
return tier.getUnarmedNotificationItem();
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
return Material.LEATHER_HELMET;
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-05-15 23:08:43 +02:00
|
|
|
private static Material getWoodcuttingNotificationItem(int skillLevel) {
|
|
|
|
for (Tier tier : Tier.values()) {
|
|
|
|
if (skillLevel >= tier.getLevel()) {
|
|
|
|
return tier.getWoodcuttingNotificationItem();
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2013-05-15 23:08:43 +02:00
|
|
|
|
|
|
|
return Material.STICK;
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Re-enable SpoutCraft for players after a /reload
|
|
|
|
*/
|
|
|
|
public static void reloadSpoutPlayers() {
|
2013-05-15 23:08:43 +02:00
|
|
|
PluginManager pluginManager = mcMMO.p.getServer().getPluginManager();
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
for (SpoutPlayer spoutPlayer : SpoutManager.getPlayerChunkMap().getOnlinePlayers()) {
|
2013-05-15 23:08:43 +02:00
|
|
|
pluginManager.callEvent(new SpoutCraftEnableEvent(spoutPlayer));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void reloadSpoutPlayer(Player player) {
|
|
|
|
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
|
|
|
|
|
|
|
if (spoutPlayer != null) {
|
|
|
|
mcMMO.p.getServer().getPluginManager().callEvent(new SpoutCraftEnableEvent(spoutPlayer));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void preCacheFiles() {
|
2013-05-15 23:28:47 +02:00
|
|
|
SpoutManager.getFileManager().addToPreLoginCache(mcMMO.p, extractFiles());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|