Update to SpoutStuff.java

This commit is contained in:
GJ 2012-03-20 22:33:58 -04:00
parent 664c9d9953
commit f2be996e3d
9 changed files with 686 additions and 542 deletions

View File

@ -236,7 +236,7 @@ public class HUDmmo
((GenericTexture) xpicon).setUrl(m.getCapitalized(theType.toString())+".png");
xpicon.setDirty(true);
((GenericTexture) xpbar).setUrl(SpoutStuff.getUrlBar(SpoutStuff.getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));
((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));
xpbar.setDirty(true);
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
@ -256,16 +256,82 @@ public class HUDmmo
if(theType == null)
return;
Color color = SpoutStuff.getRetroColor(theType);
Color color = getRetroColor(theType);
if(xpicon != null && theType != null)
xpicon.setUrl(m.getCapitalized(theType.toString())+"_r.png");
if(theType != null)
xpfill.setBottomColor(color).setTopColor(color).setWidth(SpoutStuff.getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.RETRO)).setDirty(true);
xpfill.setBottomColor(color).setTopColor(color).setWidth(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.RETRO)).setDirty(true);
else
System.out.println("theType was null!");
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
}
private static Color getRetroColor(SkillType type) {
switch (type) {
case ACROBATICS:
return new Color((float) LoadProperties.acrobatics_r, (float) LoadProperties.acrobatics_g, (float) LoadProperties.acrobatics_b, 1f);
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);
}
}
private static String getUrlBar(Integer number) {
char[] num = number.toString().toCharArray();
switch (num.length) {
case 1:
return "xpbar_inc00"+number+".png";
case 2:
return "xpbar_inc0"+number+".png";
default:
return "xpbar_inc"+number+".png";
}
}
private static Integer getXpInc(int skillxp, int xptolevel, HUDType hud) {
double percentage = (double) skillxp / xptolevel;
double inc;
switch (hud) {
case RETRO:
inc = 0.0079365079365079;
break;
case STANDARD:
inc = 0.0039370078740157;
break;
default:
return 1;
}
return (int) (percentage / inc);
}
}

View File

@ -16,8 +16,7 @@ import com.gmail.nossr50.skills.Herbalism;
import com.gmail.nossr50.skills.Mining;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.WoodCutting;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.spout.SpoutSounds;
import org.bukkit.Bukkit;
import org.bukkit.CropState;
@ -274,7 +273,7 @@ public class mcBlockListener implements Listener {
/* TREE FELLER SOUNDS */
if (LoadProperties.spoutEnabled && mat.equals(Material.LOG) && PP.getTreeFellerMode()) {
SpoutStuff.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
}
/*
@ -302,7 +301,7 @@ public class mcBlockListener implements Listener {
}
if (LoadProperties.spoutEnabled) {
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}
else if (PP.getSuperBreakerMode() && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {

View File

@ -14,14 +14,14 @@ import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
public class Party
{
public class Party {
/*
* This file is part of mmoMinecraft (http://code.google.com/p/mmo-minecraft/).
*

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.event.player.PlayerAnimationEvent;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcPermissions;
@ -139,7 +139,7 @@ public class Excavation {
}
if (LoadProperties.spoutEnabled) {
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}
}

View File

@ -15,7 +15,7 @@ import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
@ -259,7 +259,7 @@ public class Mining
miningBlockCheck(player, block);
if (LoadProperties.spoutEnabled) {
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}
}

View File

@ -15,7 +15,7 @@ import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
@ -145,7 +145,7 @@ public class Repair {
//CLANG CLANG
if (LoadProperties.spoutEnabled) {
SpoutStuff.playRepairNoise(player);
SpoutSounds.playRepairNoise(player);
}
}

View File

@ -20,7 +20,7 @@ import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.spout.SpoutSounds;
import org.getspout.spoutapi.sound.SoundEffect;
@ -311,7 +311,7 @@ public class WoodCutting {
}
if (LoadProperties.spoutEnabled) {
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}
}

View File

@ -0,0 +1,52 @@
package com.gmail.nossr50.spout;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
import org.getspout.spoutapi.sound.SoundEffect;
import org.getspout.spoutapi.sound.SoundManager;
public class SpoutSounds {
/**
* Play sound effect through Spout.
*
* @param effect The sound effect to play
* @param player The player to play the sound to
* @param location The location the sound should come from
*/
public static void playSoundForPlayer(SoundEffect effect, Player player, Location location) {
SoundManager SM = SpoutManager.getSoundManager();
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
SM.playSoundEffect(sPlayer, effect, location);
}
/**
* Play noise on successful repair.
*
* @param player The player who repaired an item
*/
public static void playRepairNoise(Player player) {
SoundManager SM = SpoutManager.getSoundManager();
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
//If this is pulling from online, why have it in the jar?
SM.playCustomSoundEffect(Bukkit.getServer().getPluginManager().getPlugin("mcMMO"), sPlayer, "repair.wav", false);
}
/**
* Play noise on level-up.
*
* @param player The player who leveled up
*/
protected static void playLevelUpNoise(Player player) {
SoundManager SM = SpoutManager.getSoundManager();
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
//If this is pulling from online, why have it in the jar?
SM.playCustomSoundEffect(Bukkit.getServer().getPluginManager().getPlugin("mcMMO"), sPlayer, "level.wav", false);
}
}

File diff suppressed because it is too large Load Diff