1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2025-07-04 06:34:44 +02:00

Getting project ready for Maven

This commit is contained in:
TheYeti
2012-01-09 11:00:13 -08:00
parent 7e200fd6a3
commit 376048d5aa
402 changed files with 17076 additions and 17076 deletions
Changelog.txt
src/main
java
com
gmail
nossr50
Combat.javaDatabase.javaItem.javaLeaderboard.javaUsers.java
commands
config
datatypes
listeners
locale
m.javamcMMO.javamcPermissions.java
party
runnables
skills
spout
plugin.yml
resources
Acrobatics.pngAcrobatics_r.pngArchery.pngArchery_r.pngAxe_r.pngAxes.pngAxes_r.pngExcavation.pngExcavation_r.pngFishing.pngFishing_r.pngHerbalism.pngHerbalism_r.pngIcon.pngIcon_old.pngIcon_r.pngMining.pngMining_r.pngRepair.pngRepair_r.pngSwords.pngSwords_r.pngTaming.pngTaming_r.pngUnarmed.pngUnarmed_r.pngWoodcutting.pngWoodcutting_r.pnghealth_inc00.pnghealth_inc01.pnghealth_inc02.pnghealth_inc03.pnghealth_inc04.pnghealth_inc05.pnghealth_inc06.pnghealth_inc07.pnghealth_inc08.pnghealth_inc09.pnghealth_inc10.pnghealth_inc11.pnghealth_inc12.pnghealth_inc13.pnghealth_inc14.pnghealth_inc15.pnghealth_inc16.pnghealth_inc17.pnghealth_inc18.pnghealth_inc19.pnghealth_inc20.pnglevel.wavrepair.wavxpbar_inc000.pngxpbar_inc001.pngxpbar_inc002.pngxpbar_inc003.pngxpbar_inc004.pngxpbar_inc005.pngxpbar_inc006.pngxpbar_inc007.pngxpbar_inc008.pngxpbar_inc009.pngxpbar_inc010.pngxpbar_inc011.pngxpbar_inc012.pngxpbar_inc013.pngxpbar_inc014.pngxpbar_inc015.pngxpbar_inc016.pngxpbar_inc017.pngxpbar_inc018.pngxpbar_inc019.pngxpbar_inc020.pngxpbar_inc021.pngxpbar_inc022.pngxpbar_inc023.pngxpbar_inc024.pngxpbar_inc025.pngxpbar_inc026.pngxpbar_inc027.pngxpbar_inc028.pngxpbar_inc029.pngxpbar_inc030.pngxpbar_inc031.pngxpbar_inc032.pngxpbar_inc033.pngxpbar_inc034.pngxpbar_inc035.pngxpbar_inc036.pngxpbar_inc037.pngxpbar_inc038.pngxpbar_inc039.pngxpbar_inc040.pngxpbar_inc041.pngxpbar_inc042.pngxpbar_inc043.pngxpbar_inc044.pngxpbar_inc045.pngxpbar_inc046.pngxpbar_inc047.pngxpbar_inc048.pngxpbar_inc049.pngxpbar_inc050.pngxpbar_inc051.pngxpbar_inc052.pngxpbar_inc053.pngxpbar_inc054.pngxpbar_inc055.pngxpbar_inc056.pngxpbar_inc057.pngxpbar_inc058.pngxpbar_inc059.pngxpbar_inc060.pngxpbar_inc061.pngxpbar_inc062.pngxpbar_inc063.pngxpbar_inc064.pngxpbar_inc065.pngxpbar_inc066.pngxpbar_inc067.pngxpbar_inc068.pngxpbar_inc069.pngxpbar_inc070.pngxpbar_inc071.pngxpbar_inc072.pngxpbar_inc073.pngxpbar_inc074.pngxpbar_inc075.pngxpbar_inc076.pngxpbar_inc077.pngxpbar_inc078.pngxpbar_inc079.pngxpbar_inc080.pngxpbar_inc081.pngxpbar_inc082.pngxpbar_inc083.pngxpbar_inc084.pngxpbar_inc085.pngxpbar_inc086.pngxpbar_inc087.pngxpbar_inc088.pngxpbar_inc089.pngxpbar_inc090.pngxpbar_inc091.pngxpbar_inc092.pngxpbar_inc093.pngxpbar_inc094.pngxpbar_inc095.pngxpbar_inc096.pngxpbar_inc097.pngxpbar_inc098.pngxpbar_inc099.pngxpbar_inc100.pngxpbar_inc101.pngxpbar_inc102.pngxpbar_inc103.pngxpbar_inc104.pngxpbar_inc105.pngxpbar_inc106.pngxpbar_inc107.pngxpbar_inc108.pngxpbar_inc109.pngxpbar_inc110.pngxpbar_inc111.pngxpbar_inc112.pngxpbar_inc113.pngxpbar_inc114.pngxpbar_inc115.pngxpbar_inc116.pngxpbar_inc117.pngxpbar_inc118.pngxpbar_inc119.pngxpbar_inc120.pngxpbar_inc121.pngxpbar_inc122.pngxpbar_inc123.pngxpbar_inc124.pngxpbar_inc125.pngxpbar_inc126.pngxpbar_inc127.pngxpbar_inc128.pngxpbar_inc129.pngxpbar_inc130.pngxpbar_inc131.pngxpbar_inc132.pngxpbar_inc133.pngxpbar_inc134.pngxpbar_inc135.pngxpbar_inc136.pngxpbar_inc137.pngxpbar_inc138.pngxpbar_inc139.pngxpbar_inc140.pngxpbar_inc141.pngxpbar_inc142.pngxpbar_inc143.pngxpbar_inc144.pngxpbar_inc145.pngxpbar_inc146.pngxpbar_inc147.pngxpbar_inc148.pngxpbar_inc149.pngxpbar_inc150.pngxpbar_inc151.pngxpbar_inc152.pngxpbar_inc153.pngxpbar_inc154.pngxpbar_inc155.pngxpbar_inc156.pngxpbar_inc157.pngxpbar_inc158.pngxpbar_inc159.pngxpbar_inc160.pngxpbar_inc161.pngxpbar_inc162.pngxpbar_inc163.pngxpbar_inc164.pngxpbar_inc165.pngxpbar_inc166.pngxpbar_inc167.pngxpbar_inc168.pngxpbar_inc169.pngxpbar_inc170.pngxpbar_inc171.pngxpbar_inc172.pngxpbar_inc173.pngxpbar_inc174.pngxpbar_inc175.pngxpbar_inc176.pngxpbar_inc177.pngxpbar_inc178.pngxpbar_inc179.pngxpbar_inc180.pngxpbar_inc181.pngxpbar_inc182.pngxpbar_inc183.pngxpbar_inc184.pngxpbar_inc185.pngxpbar_inc186.pngxpbar_inc187.pngxpbar_inc188.pngxpbar_inc189.pngxpbar_inc190.pngxpbar_inc191.pngxpbar_inc192.pngxpbar_inc193.pngxpbar_inc194.pngxpbar_inc195.pngxpbar_inc196.pngxpbar_inc197.pngxpbar_inc198.pngxpbar_inc199.pngxpbar_inc200.pngxpbar_inc201.pngxpbar_inc202.pngxpbar_inc203.pngxpbar_inc204.pngxpbar_inc205.pngxpbar_inc206.pngxpbar_inc207.pngxpbar_inc208.pngxpbar_inc209.pngxpbar_inc210.pngxpbar_inc211.pngxpbar_inc212.pngxpbar_inc213.pngxpbar_inc214.pngxpbar_inc215.pngxpbar_inc216.pngxpbar_inc217.pngxpbar_inc218.pngxpbar_inc219.pngxpbar_inc220.pngxpbar_inc221.pngxpbar_inc222.pngxpbar_inc223.pngxpbar_inc224.pngxpbar_inc225.pngxpbar_inc226.pngxpbar_inc227.pngxpbar_inc228.pngxpbar_inc229.pngxpbar_inc230.pngxpbar_inc231.pngxpbar_inc232.pngxpbar_inc233.pngxpbar_inc234.pngxpbar_inc235.pngxpbar_inc236.pngxpbar_inc237.pngxpbar_inc238.pngxpbar_inc239.pngxpbar_inc240.pngxpbar_inc241.pngxpbar_inc242.pngxpbar_inc243.pngxpbar_inc244.pngxpbar_inc245.pngxpbar_inc246.pngxpbar_inc247.pngxpbar_inc248.pngxpbar_inc249.pngxpbar_inc250.pngxpbar_inc251.pngxpbar_inc252.pngxpbar_inc253.pngxpbar_inc254.png

@ -0,0 +1,577 @@
/*
This file is part of mcMMO.
mcMMO 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.
mcMMO 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 mcMMO. If not, see <http://www.gnu.org/licenses/>.
*/
package com.gmail.nossr50.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.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.gui.Color;
import org.getspout.spoutapi.keyboard.Keyboard;
import org.getspout.spoutapi.player.SpoutPlayer;
import org.getspout.spoutapi.sound.SoundEffect;
import org.getspout.spoutapi.sound.SoundManager;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.HUDType;
import com.gmail.nossr50.datatypes.HUDmmo;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.popups.PopupMMO;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.listeners.mcSpoutInputListener;
import com.gmail.nossr50.listeners.mcSpoutListener;
import com.gmail.nossr50.listeners.mcSpoutScreenListener;
public class SpoutStuff
{
static mcMMO plugin = (mcMMO) Bukkit.getServer().getPluginManager().getPlugin("mcMMO");
private final static mcSpoutListener spoutListener = new mcSpoutListener(plugin);
private final static mcSpoutInputListener spoutInputListener = new mcSpoutInputListener(plugin);
private final static mcSpoutScreenListener spoutScreenListener = new mcSpoutScreenListener(plugin);
public static HashMap<Player, HUDmmo> playerHUDs = new HashMap<Player, HUDmmo>();
public static HashMap<SpoutPlayer, PopupMMO> playerScreens = new HashMap<SpoutPlayer, PopupMMO>();
public static Keyboard keypress;
public static void writeFile(String theFileName, String theFilePath)
{
try {
File currentFile = new File("plugins/mcMMO/Resources/"+theFilePath+theFileName);
@SuppressWarnings("static-access")
JarFile jar = new JarFile(plugin.mcmmo);
JarEntry entry = jar.getJarEntry("resources/"+theFileName);
InputStream is = jar.getInputStream(entry);
byte[] buf = new byte[2048];
int nbRead;
OutputStream os = new BufferedOutputStream(new FileOutputStream(currentFile));
while((nbRead = is.read(buf)) != -1) {
os.write(buf, 0, nbRead);
}
os.flush();
os.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void extractFiles()
{
//Setup directories
new File("plugins/mcMMO/Resources/").mkdir();
new File("plugins/mcMMO/Resources/HUD/").mkdir();
new File("plugins/mcMMO/Resources/HUD/Standard/").mkdir();
new File("plugins/mcMMO/Resources/HUD/Retro/").mkdir();
new File("plugins/mcMMO/Resources/Sound/").mkdir();
//Xp Bar images
for(int x =0; x < 255; x++)
{
//String s = File.separator;
String theFilePath = "HUD/Standard/";
if(x < 10)
{
String theFileName = "xpbar_inc00"+x+".png";
writeFile(theFileName, theFilePath);
} else if (x < 100)
{
String theFileName = "xpbar_inc0"+x+".png";
writeFile(theFileName, theFilePath);
} else
{
String theFileName = "xpbar_inc"+x+".png";
writeFile(theFileName, theFilePath);
}
}
//Standard XP Icons
String theFilePathA = "HUD/Standard/";
String theFilePathB = "HUD/Retro/";
for(SkillType y : SkillType.values())
{
if(y == SkillType.ALL || y == SkillType.ENCHANTING || y == SkillType.ALCHEMY)
continue;
String theFileNameA = m.getCapitalized(y.toString())+".png";
String theFileNameB = m.getCapitalized(y.toString())+"_r.png";
writeFile(theFileNameA, theFilePathA);
writeFile(theFileNameB, theFilePathB);
}
//Blank icons
writeFile("Icon.png", theFilePathA);
writeFile("Icon_r.png", theFilePathB);
String theSoundFilePath = "Sound/";
//Repair SFX
writeFile("repair.wav", theSoundFilePath);
writeFile("level.wav", theSoundFilePath);
}
public static void setupSpoutConfigs()
{
String temp = LoadProperties.readString("Spout.Menu.Key", "KEY_M");
for(Keyboard x : Keyboard.values())
{
if(x.toString().equalsIgnoreCase(temp))
{
keypress = x;
}
}
if(keypress == null)
{
System.out.println("Invalid KEY for Spout.Menu.Key, using KEY_M");
keypress = Keyboard.KEY_M;
}
}
public static ArrayList<File> getFiles()
{
ArrayList<File> files = new ArrayList<File>();
String dir = "plugins/mcMMO/Resources/";
int x = 0;
//XP BAR
while(x < 255)
{
if(x < 10)
{
files.add(new File(dir+"HUD/Standard/xpbar_inc00"+x+".png"));
} else if (x < 100)
{
files.add(new File(dir+"HUD/Standard/xpbar_inc0"+x+".png"));
} else
{
files.add(new File(dir+"HUD/Standard/xpbar_inc"+x+".png"));
}
x++;
}
//Standard XP Icons
for(SkillType y : SkillType.values())
{
if(y == SkillType.ALL || y == SkillType.ENCHANTING || y == SkillType.ALCHEMY)
continue;
files.add(new File(dir+"HUD/Standard/"+m.getCapitalized(y.toString())+".png"));
files.add(new File(dir+"HUD/Retro/"+m.getCapitalized(y.toString())+"_r.png"));
}
//Blank icons
files.add(new File(dir+"HUD/Standard/Icon.png"));
files.add(new File(dir+"HUD/Retro/Icon_r.png"));
//Repair SFX
files.add(new File(dir+"Sound/repair.wav"));
//Level SFX
files.add(new File(dir+"Sound/level.wav"));
return files;
}
public static void registerCustomEvent()
{
Bukkit.getServer().getPluginManager().registerEvent(Event.Type.CUSTOM_EVENT, spoutListener, Priority.Normal, plugin);
Bukkit.getServer().getPluginManager().registerEvent(Event.Type.CUSTOM_EVENT, spoutInputListener, Priority.Normal, plugin);
Bukkit.getServer().getPluginManager().registerEvent(Event.Type.CUSTOM_EVENT, spoutScreenListener, Priority.Normal, plugin);
}
public static Color getRetroColor(SkillType type)
{
switch(type)
{
case ACROBATICS:
return new Color((float) LoadProperties.acrobatics_r, (float) LoadProperties.acrobatics_g, (float) LoadProperties.acrobatics_b, 1);
case ARCHERY:
return new Color((float) LoadProperties.archery_r, (float)LoadProperties.archery_g, (float)LoadProperties.archery_b, 1f);
case AXES:
return new Color((float) LoadProperties.axes_r, (float)LoadProperties.axes_g, (float)LoadProperties.axes_b, 1f);
case EXCAVATION:
return new Color((float)LoadProperties.excavation_r, (float)LoadProperties.excavation_g, (float)LoadProperties.excavation_b, 1f);
case HERBALISM:
return new Color((float)LoadProperties.herbalism_r, (float)LoadProperties.herbalism_g, (float)LoadProperties.herbalism_b, 1f);
case MINING:
return new Color((float)LoadProperties.mining_r, (float)LoadProperties.mining_g, (float)LoadProperties.mining_b, 1f);
case REPAIR:
return new Color((float)LoadProperties.repair_r, (float)LoadProperties.repair_g, (float)LoadProperties.repair_b, 1f);
case SWORDS:
return new Color((float)LoadProperties.swords_r, (float)LoadProperties.swords_g, (float)LoadProperties.swords_b, 1f);
case TAMING:
return new Color((float)LoadProperties.taming_r, (float)LoadProperties.taming_g, (float)LoadProperties.taming_b, 1f);
case UNARMED:
return new Color((float)LoadProperties.unarmed_r, (float)LoadProperties.unarmed_g, (float)LoadProperties.unarmed_b, 1f);
case WOODCUTTING:
return new Color((float)LoadProperties.woodcutting_r, (float)LoadProperties.woodcutting_g, (float)LoadProperties.woodcutting_b, 1f);
case FISHING:
return new Color((float)LoadProperties.fishing_r, (float)LoadProperties.fishing_g, (float)LoadProperties.fishing_b, 1f);
default:
return new Color(0.3f, 0.3f, 0.75f, 1f);
}
}
public static SpoutPlayer getSpoutPlayer(String playerName)
{
for(Player x : Bukkit.getServer().getOnlinePlayers())
{
if(x.getName().equalsIgnoreCase(playerName))
{
return SpoutManager.getPlayer(x);
}
}
return null;
}
public static void playSoundForPlayer(SoundEffect effect, Player player, Location location)
{
//Contrib stuff
SoundManager SM = SpoutManager.getSoundManager();
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
SM.playSoundEffect(sPlayer, effect, location);
}
public static void playRepairNoise(Player player)
{
SoundManager SM = SpoutManager.getSoundManager();
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
SM.playCustomSoundEffect(Bukkit.getServer().getPluginManager().getPlugin("mcMMO"), sPlayer, "http://mcmmo.rycochet.net/mcmmo/Sound/repair.wav", false);
}
public static void playLevelUpNoise(Player player)
{
SoundManager SM = SpoutManager.getSoundManager();
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
SM.playCustomSoundEffect(Bukkit.getServer().getPluginManager().getPlugin("mcMMO"), sPlayer, "http://mcmmo.rycochet.net/mcmmo/Sound/level.wav", false);
}
public static void levelUpNotification(SkillType skillType, SpoutPlayer sPlayer)
{
PlayerProfile PP = Users.getProfile(sPlayer);
Material mat = null;
switch(skillType)
{
case TAMING:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.PORK;
break;
case 2:
mat = Material.PORK;
break;
case 3:
mat = Material.GRILLED_PORK;
break;
case 4:
mat = Material.GRILLED_PORK;
break;
case 5:
mat = Material.BONE;
break;
}
break;
case MINING:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.COAL_ORE;
break;
case 2:
mat = Material.IRON_ORE;
break;
case 3:
mat = Material.GOLD_ORE;
break;
case 4:
mat = Material.LAPIS_ORE;
break;
case 5:
mat = Material.DIAMOND_ORE;
break;
}
break;
case WOODCUTTING:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.WOOD;
break;
case 2:
mat = Material.WOOD;
break;
case 3:
mat = Material.WOOD;
break;
case 4:
mat = Material.LOG;
break;
case 5:
mat = Material.LOG;
break;
}
break;
case REPAIR:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.COBBLESTONE;
break;
case 2:
mat = Material.IRON_BLOCK;
break;
case 3:
mat = Material.GOLD_BLOCK;
break;
case 4:
mat = Material.LAPIS_BLOCK;
break;
case 5:
mat = Material.DIAMOND_BLOCK;
break;
}
break;
case HERBALISM:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.YELLOW_FLOWER;
break;
case 2:
mat = Material.RED_ROSE;
break;
case 3:
mat = Material.BROWN_MUSHROOM;
break;
case 4:
mat = Material.RED_MUSHROOM;
break;
case 5:
mat = Material.PUMPKIN;
break;
}
break;
case ACROBATICS:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.LEATHER_BOOTS;
break;
case 2:
mat = Material.CHAINMAIL_BOOTS;
break;
case 3:
mat = Material.IRON_BOOTS;
break;
case 4:
mat = Material.GOLD_BOOTS;
break;
case 5:
mat = Material.DIAMOND_BOOTS;
break;
}
break;
case SWORDS:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.WOOD_SWORD;
break;
case 2:
mat = Material.STONE_SWORD;
break;
case 3:
mat = Material.IRON_SWORD;
break;
case 4:
mat = Material.GOLD_SWORD;
break;
case 5:
mat = Material.DIAMOND_SWORD;
break;
}
break;
case ARCHERY:
mat = Material.ARROW;
break;
case UNARMED:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.LEATHER_HELMET;
break;
case 2:
mat = Material.CHAINMAIL_HELMET;
break;
case 3:
mat = Material.IRON_HELMET;
break;
case 4:
mat = Material.GOLD_HELMET;
break;
case 5:
mat = Material.DIAMOND_HELMET;
break;
}
break;
case EXCAVATION:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.WOOD_SPADE;
break;
case 2:
mat = Material.STONE_SPADE;
break;
case 3:
mat = Material.IRON_SPADE;
break;
case 4:
mat = Material.GOLD_SPADE;
break;
case 5:
mat = Material.DIAMOND_SPADE;
break;
}
break;
case AXES:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.WOOD_AXE;
break;
case 2:
mat = Material.STONE_AXE;
break;
case 3:
mat = Material.IRON_AXE;
break;
case 4:
mat = Material.GOLD_AXE;
break;
case 5:
mat = Material.DIAMOND_AXE;
break;
}
break;
case FISHING:
switch(getNotificationTier(PP.getSkillLevel(skillType)))
{
case 1:
mat = Material.RAW_FISH;
break;
case 2:
mat = Material.RAW_FISH;
break;
case 3:
mat = Material.COOKED_FISH;
break;
case 4:
mat = Material.COOKED_FISH;
break;
case 5:
mat = Material.FISHING_ROD;
break;
}
default:
mat = Material.WATCH;
break;
}
sPlayer.sendNotification(ChatColor.GREEN+"Level Up!", ChatColor.YELLOW+m.getCapitalized(skillType.toString())+ChatColor.DARK_AQUA+" ("+ChatColor.GREEN+PP.getSkillLevel(skillType)+ChatColor.DARK_AQUA+")", mat);
playLevelUpNoise(sPlayer);
}
public static Integer getNotificationTier(Integer level)
{
if(level < 200)
return 1;
else if (level >= 200 && level < 400)
return 2;
else if (level >= 400 && level < 600)
return 3;
else if (level >= 600 && level < 800)
return 4;
else
return 5;
}
public static Integer getXpInc(int skillxp, int xptolevel, HUDType hud)
{
if(hud == HUDType.STANDARD)
{
double percentage = (double) skillxp/xptolevel;
double inc = 0.0039370078740157;
return (int) (percentage/inc);
} else if (hud == HUDType.RETRO)
{
double percentage = (double) skillxp/xptolevel;
double inc = 0.0079365079365079;
return (int) (percentage/inc);
} else {
return 1;
}
}
public static void updateXpBar(Player player)
{
playerHUDs.get(player).updateXpBarDisplay(Users.getProfile(player).getHUDType(), player);
}
public static String getUrlBar(Integer number)
{
if(number.toString().toCharArray().length == 1)
{
return "xpbar_inc00"+number+".png";
} else if (number.toString().toCharArray().length == 2)
{
return "xpbar_inc0"+number+".png";
} else {
return "xpbar_inc"+number+".png";
}
}
public static String getUrlIcon(SkillType skillType)
{
return m.getCapitalized(skillType.toString())+".png";
}
public static boolean shouldBeFilled(PlayerProfile PP)
{
return PP.getXpBarInc() < getXpInc(PP.getSkillXpLevel(PP.getLastGained()), PP.getXpToLevel(PP.getLastGained()), HUDType.STANDARD);
}
}

@ -0,0 +1,269 @@
/*
* This file is from mmoMinecraft (http://code.google.com/p/mmo-minecraft/).
*
* mmoMinecraft 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.gmail.nossr50.spout;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.entity.*;
import org.getspout.spoutapi.gui.Container;
import org.getspout.spoutapi.gui.GenericContainer;
import org.getspout.spoutapi.gui.Widget;
import org.getspout.spoutapi.gui.WidgetAnchor;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.spout.util.GenericLivingEntity;
public class mmoHelper
{
/**
* A map of player containers, each container is their party bar
*/
public static HashMap<Player, GenericContainer> containers = new HashMap<Player, GenericContainer>();
/**
* Get the percentage health of a Player.
* @param player The Player we're interested in
* @return The percentage of max health
*/
public static int getHealth(Entity player) {
if (player != null && player instanceof LivingEntity) {
try {
return Math.min(((LivingEntity) player).getHealth() * 5, 100);
} catch (Exception e) {
}
}
return 0;
}
/**
* Get the colour of a LivingEntity target from a player's point of view.
* @param player The player viewing the target
* @param target The target to name
* @return The name to use
*/
public static String getColor(Player player, LivingEntity target) {
if (target instanceof Player) {
if (((Player) target).isOp()) {
return ChatColor.GOLD.toString();
}
return ChatColor.YELLOW.toString();
} else {
if (target instanceof Monster) {
if (player != null && player.equals(((Monster) target).getTarget())) {
return ChatColor.RED.toString();
} else {
return ChatColor.YELLOW.toString();
}
} else if (target instanceof WaterMob) {
return ChatColor.GREEN.toString();
} else if (target instanceof Flying) {
return ChatColor.YELLOW.toString();
} else if (target instanceof Animals) {
if (player != null && player.equals(((Animals) target).getTarget())) {
return ChatColor.RED.toString();
} else if (target instanceof Tameable) {
Tameable pet = (Tameable) target;
if (pet.isTamed()) {
return ChatColor.GREEN.toString();
} else {
return ChatColor.YELLOW.toString();
}
} else {
return ChatColor.GRAY.toString();
}
} else {
return ChatColor.GRAY.toString();
}
}
}
/**
* Get the percentage armour of a Player.
* @param player The Player we're interested in
* @return The percentage of max armour
*/
public static int getArmor(Entity player) {
if (player != null && player instanceof Player) {
int armor = 0, max, multi[] = {15, 30, 40, 15};
ItemStack inv[] = ((Player) player).getInventory().getArmorContents();
for (int i = 0; i < inv.length; i++) {
max = inv[i].getType().getMaxDurability();
if (max >= 0) {
armor += multi[i] * (max - inv[i].getDurability()) / max;
}
}
return armor;
}
return 0;
}
public static String getSimpleName(LivingEntity target, boolean showOwner) {
String name = "";
if (target instanceof Player) {
if (LoadProperties.showDisplayName) {
name += ((Player) target).getName();
} else {
name += ((Player) target).getDisplayName();
}
} else if (target instanceof HumanEntity) {
name += ((HumanEntity) target).getName();
} else {
if (target instanceof Tameable) {
if (((Tameable) target).isTamed()) {
if (showOwner && ((Tameable) target).getOwner() instanceof Player) {
if (LoadProperties.showDisplayName) {
name += ((Player) ((Tameable) target).getOwner()).getName() + "'s ";
} else {
name += ((Player) ((Tameable) target).getOwner()).getDisplayName() + "'s ";
}
} else {
name += "Pet ";
}
}
}
if (target instanceof Chicken) {
name += "Chicken";
} else if (target instanceof Cow) {
name += "Cow";
} else if (target instanceof Creeper) {
name += "Creeper";
} else if (target instanceof Ghast) {
name += "Ghast";
} else if (target instanceof Giant) {
name += "Giant";
} else if (target instanceof Pig) {
name += "Pig";
} else if (target instanceof PigZombie) {
name += "PigZombie";
} else if (target instanceof Sheep) {
name += "Sheep";
} else if (target instanceof Slime) {
name += "Slime";
} else if (target instanceof Skeleton) {
name += "Skeleton";
} else if (target instanceof Spider) {
name += "Spider";
} else if (target instanceof Squid) {
name += "Squid";
} else if (target instanceof Wolf) {
name += "Wolf";
} else if (target instanceof Zombie) {
name += "Zombie";
} else if (target instanceof Monster) {
name += "Monster";
} else if (target instanceof Creature) {
name += "Creature";
} else {
name += "Unknown";
}
}
return name;
}
public static LivingEntity[] getPets(HumanEntity player) {
ArrayList<LivingEntity> pets = new ArrayList<LivingEntity>();
if (player != null && (!(player instanceof Player) || ((Player) player).isOnline())) {
String name = player.getName();
for (World world : Bukkit.getServer().getWorlds()) {
for (LivingEntity entity : world.getLivingEntities()) {
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && ((Tameable) entity).getOwner() instanceof Player) {
if (name.equals(((Player) ((Tameable) entity).getOwner()).getName())) {
pets.add(entity);
}
}
}
}
}
LivingEntity[] list = new LivingEntity[pets.size()];
pets.toArray(list);
return list;
}
public static void update(Player player)
{
//boolean show_pets = true;
Container container = containers.get(player);
if (container != null)
{
int index = 0;
Widget[] bars = container.getChildren();
for (String name : Party.getInstance().getPartyMembersByName(player).meFirst(player.getName()))
{
GenericLivingEntity bar;
if (index >= bars.length)
{
container.addChild(bar = new GenericLivingEntity());
} else {
bar = (GenericLivingEntity)bars[index];
}
bar.setEntity(name, Party.getInstance().isPartyLeader(name, Users.getProfile(Bukkit.getServer().getPlayer(name)).getParty()) ? ChatColor.GREEN + "@" : "");
//bar.setTargets(show_pets ? getPets(Bukkit.getServer().getPlayer(name)) : null);
index++;
}
while (index < bars.length) {
container.removeChild(bars[index++]);
}
container.updateLayout();
}
}
public static void initialize(SpoutPlayer sPlayer, Plugin plugin)
{
GenericContainer container = new GenericContainer();
container.setAlign(WidgetAnchor.TOP_LEFT)
.setAnchor(WidgetAnchor.TOP_LEFT)
.setX(3)
.setY(3)
.setWidth(427)
.setHeight(240)
.setFixed(true);
mmoHelper.containers.put(sPlayer, container);
sPlayer.getMainScreen().attachWidget(plugin, container);
}
/**
* Update all parties.
*/
public static void updateAll() {
for(Player x : Bukkit.getServer().getOnlinePlayers())
{
if(Users.getProfile(x).inParty())
{
update(x);
}
}
}
}

@ -0,0 +1,112 @@
/*
* This file is part of mmoMinecraft (http://code.google.com/p/mmo-minecraft/).
*
* mmoMinecraft 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.gmail.nossr50.spout.util;
import java.util.ArrayList;
/**
* Case insensitive ArrayList<String>.
* Overrides the .contains(), .indexOf(), .lastIndexOf() and .remove() methods.
*/
public class ArrayListString extends ArrayList<String> {
private static final long serialVersionUID = -8111006526598412404L;
/**
* Returns true if this list contains the specified string.
* @param o String whose presence in this list is to be tested
* @return true if this list contains the specified string
*/
public boolean contains(String o) {
for (String e : this) {
if (o == null ? e == null : o.equalsIgnoreCase(e)) {
return true;
}
}
return false;
}
/**
* Returns the index of the first occurrence of the specified string in this list, or -1 if this list does not contain the string.
* @param o String to search for
* @return The index of the first occurrence of the specified string in this list, or -1 if this list does not contain the string
*/
public int indexOf(String o) {
for (int i = 0; i < this.size(); i++) {
if (o == null ? get(i) == null : o.equalsIgnoreCase(get(i))) {
return i;
}
}
return -1;
}
/**
* Returns the index of the last occurrence of the specified string in this list, or -1 if this list does not contain the string.
* @param o String to search for
* @return The index of the last occurrence of the specified string in this list, or -1 if this list does not contain the string
*/
public int lastIndexOf(String o) {
for (int i = size() - 1; i >= 0; i--) {
if (o == null ? get(i) == null : o.equalsIgnoreCase(get(i))) {
return i;
}
}
return -1;
}
/**
* Removes the first occurrence of the specified string from this list, if it is present. If the list does not contain the string, it is unchanged.
* @param o String to be removed from this list, if present
* @return true if this list contained the specified string
*/
public boolean remove(String o) {
int i = indexOf(o);
if (i != -1) {
remove(i);
return true;
}
return false;
}
/**
* Returns the element at the specified position in this list.
* This is for finding the correct capitalisation of an element.
* @param index String to search for
* @return the correctly capitalised element
*/
public String get(String index) {
int i = this.indexOf(index);
if (i != -1) {
return this.get(i);
}
return null;
}
public ArrayListString meFirst(String name) {
ArrayListString copy = new ArrayListString();
if (this.contains(name)) {
copy.add(name);
}
for (String next : this) {
if (!next.equalsIgnoreCase(name)) {
copy.add(next);
}
}
return copy;
}
}

@ -0,0 +1,65 @@
/*
* This file is part of mmoMinecraft (https://github.com/mmoMinecraftDev).
*
* mmoMinecraft 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.gmail.nossr50.spout.util;
import org.getspout.spoutapi.gui.GenericTexture;
import com.gmail.nossr50.config.LoadProperties;
public final class GenericFace extends GenericTexture {
private static String facePath = "http://face.rycochet.net/";
private static int defaultSize = 8;
private String name;
public GenericFace() {
this("", defaultSize);
}
public GenericFace(String name) {
this(name, defaultSize);
}
public GenericFace(String name, int size) {
if (LoadProperties.showFaces) {
this.setWidth(size).setHeight(size).setFixed(true);
setName(name);
} else {
this.setVisible(false);
}
}
public String getName() {
return name;
}
public GenericFace setName(String name) {
if (LoadProperties.showFaces) {
this.name = name == null ? "" : name;
super.setUrl(facePath + this.name + ".png");
super.setDirty(true);
}
return this;
}
public GenericFace setSize(int size) {
if (LoadProperties.showFaces) {
super.setWidth(size).setHeight(size);
}
return this;
}
}

@ -0,0 +1,227 @@
/*
* This file is part of mmoHelperMinecraft (https://github.com/mmoHelperMinecraftDev).
*
* mmoHelperMinecraft 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.gmail.nossr50.spout.util;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.gui.*;
import com.gmail.nossr50.spout.mmoHelper;
public class GenericLivingEntity extends GenericContainer {
private Container _space;
private Label _label;
private Gradient _health;
private Gradient _armor;
private GenericFace _face;
private int health = 100;
private int armor = 100;
private int def_width = 80;
private int def_height = 14;
private boolean target = false;
String face = "~";
String label = "";
public GenericLivingEntity() {
super();
Color black = new Color(0, 0, 0, 0.75f);
this.addChildren(
new GenericContainer( // Used for the bar, this.children with an index 1+ are targets
_space = (Container) new GenericContainer()
.setMinWidth(def_width / 4)
.setMaxWidth(def_width / 4)
.setVisible(target),
new GenericContainer(
new GenericGradient()
.setTopColor(black)
.setBottomColor(black)
.setPriority(RenderPriority.Highest),
new GenericContainer(
_health = (Gradient) new GenericGradient(),
_armor = (Gradient) new GenericGradient()
) .setMargin(1)
.setPriority(RenderPriority.High),
new GenericContainer(
_face = (GenericFace) new GenericFace()
.setMargin(3, 0, 3, 3),
_label = (Label) new GenericLabel()
.setMargin(3)
) .setLayout(ContainerType.HORIZONTAL)
) .setLayout(ContainerType.OVERLAY)
) .setLayout(ContainerType.HORIZONTAL)
.setMargin(0, 0, 1, 0)
.setFixed(true)
.setWidth(def_width)
.setHeight(def_height)
) .setAlign(WidgetAnchor.TOP_LEFT)
.setFixed(true)
.setWidth(def_width)
.setHeight(def_height + 1);
this.setHealthColor(new Color(1f, 0, 0, 0.75f));
this.setArmorColor(new Color(0.75f, 0.75f, 0.75f, 0.75f));
}
/**
* Set the display from a possibly offline player
* @param name
* @return
*/
public GenericLivingEntity setEntity(String name) {
return setEntity(name, "");
}
/**
* Set the display from a possibly offline player
* @param name
* @param prefix Place before the name
* @return
*/
public GenericLivingEntity setEntity(String name, String prefix) {
Player player = this.getPlugin().getServer().getPlayer(name);
if (player != null && player.isOnline()) {
return setEntity(player, prefix);
}
setHealth(0);
setArmor(0);
setLabel((!"".equals(prefix) ? prefix : "") + mmoHelper.getColor(screen != null ? screen.getPlayer() : null, null) + name);
setFace("~" + name);
return this;
}
/**
* Set the display from a player or living entity
* @param entity
* @return
*/
public GenericLivingEntity setEntity(LivingEntity entity) {
return setEntity(entity, "");
}
/**
* Set the display from a player or living entity
* @param entity
* @param prefix Place before the name
* @return
*/
public GenericLivingEntity setEntity(LivingEntity entity, String prefix) {
if (entity != null && entity instanceof LivingEntity) {
setHealth(mmoHelper.getHealth(entity)); // Needs a maxHealth() check
setArmor(mmoHelper.getArmor(entity));
setLabel((!"".equals(prefix) ? prefix : "") + mmoHelper.getColor(screen != null ? screen.getPlayer() : null, entity) + mmoHelper.getSimpleName(entity, !target));
setFace(entity instanceof Player ? ((Player)entity).getName() : "+" + mmoHelper.getSimpleName(entity,false).replaceAll(" ", ""));
} else {
setHealth(0);
setArmor(0);
setLabel("");
setFace("");
}
return this;
}
/**
* Set the targets of this entity - either actual targets, or pets etc
* @param targets
* @return
*/
public GenericLivingEntity setTargets(LivingEntity... targets) {
Widget[] widgets = this.getChildren();
if (targets == null) {
targets = new LivingEntity[0]; // zero-length array is easier to handle
}
for (int i=targets.length + 1; i<widgets.length; i++) {
this.removeChild(widgets[i]);
}
for (int i=0; i<targets.length; i++) {
GenericLivingEntity child;
if (widgets.length > i + 1) {
child = (GenericLivingEntity) widgets[i+1];
} else {
this.addChild(child = new GenericLivingEntity());
}
child.setTarget(true);
child.setEntity(targets[i]);
}
setHeight((targets.length + 1) * (def_height + 1));
updateLayout();
return this;
}
public GenericLivingEntity setTarget(boolean target) {
if (this.target != target) {
this.target = target;
_space.setVisible(target);
updateLayout();
}
return this;
}
public GenericLivingEntity setHealth(int health) {
if (this.health != health) {
this.health = health;
updateLayout();
}
return this;
}
public GenericLivingEntity setHealthColor(Color color) {
_health.setTopColor(color).setBottomColor(color);
return this;
}
public GenericLivingEntity setArmor(int armor) {
if (this.armor != armor) {
this.armor = armor;
updateLayout();
}
return this;
}
public GenericLivingEntity setArmorColor(Color color) {
_armor.setTopColor(color).setBottomColor(color);
return this;
}
public GenericLivingEntity setLabel(String label) {
if (!this.label.equals(label)) {
this.label = label;
_label.setText(label).setDirty(true);
updateLayout();
}
return this;
}
public GenericLivingEntity setFace(String name) {
if (!this.face.equals(name)) {
this.face = name;
_face.setVisible(!name.isEmpty());
_face.setName(name);
updateLayout();
}
return this;
}
@Override
public Container updateLayout() {
super.updateLayout();
_armor.setWidth((_armor.getContainer().getWidth() * armor) / 100).setDirty(true);
_health.setWidth((_health.getContainer().getWidth() * health) / 100).setDirty(true);
return this;
}
}