The performance of this next update should be quite a step up from previous versions ;)

This commit is contained in:
nossr50 2011-08-05 19:53:33 -07:00
parent e621ab67d2
commit 434e7000f2
10 changed files with 93 additions and 77 deletions

View File

@ -1,8 +1,14 @@
Changelog:
#Versions without changelogs probably had very small misc fixes, like tweaks to the source code
Version 1.0.51
Converted many big numbers to much smaller numbers reducing memory usage
XP Bars
Brand new XP Bars and Skill Icons designed by BrandonXP
Noises added to leveling
MySpawn now works correctly when you are in the nether
MySpawn message when you right click a bed is now squelched
Intervals at which players renegerate hp have doubled in length
Rewrote many variables stored per player to be integer instead of long, reducing overall memory usage of mcMMO
Rewrote the Timer mcMMO relies on to instead use the BukkitScheduler for performance
Fixed the party member list of /party
Version 1.0.50
New /xprate command for those with mcmmo.admin permissions!

View File

@ -67,13 +67,11 @@ public class Item {
}
}
}
if(PP.getMySpawn(player) != null)
if(PP.getMySpawn(player, plugin) != null)
{
Location mySpawn = PP.getMySpawn(player);
if(mySpawn != null && plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)) != null)
mySpawn.setWorld(plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)));
Location mySpawn = PP.getMySpawn(player, plugin);
if(mySpawn != null){
player.teleport(mySpawn);//Do it twice to prevent weird stuff
player.teleport(mySpawn); //Do it twice to prevent weird stuff
player.teleport(mySpawn);
}
} else {

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.contrib;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
@ -26,9 +27,18 @@ public class SpoutStuff
{
//Contrib stuff
SoundManager SM = SpoutManager.getSoundManager();
SpoutPlayer sPlayer = (SpoutPlayer)player;
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
SM.playSoundEffect(sPlayer, effect, location);
}
public static void playLevelUpNoise(Player player)
{
SoundManager SM = SpoutManager.getSoundManager();
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
String r = String.valueOf((int) (Math.random()*8));
SM.playCustomMusic(Bukkit.getServer().getPluginManager().getPlugin("mcMMO"), sPlayer, "http://dl.dropbox.com/u/18212134/ANUSOUND/"+r+".wav", false);
}
public static void levelUpNotification(SkillType skillType, SpoutPlayer sPlayer)
{
PlayerProfile PP = Users.getProfile(sPlayer);
@ -247,6 +257,7 @@ public class SpoutStuff
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)

View File

@ -1068,7 +1068,7 @@ public class PlayerProfile
public boolean isDead(){
return dead;
}
public Location getMySpawn(Player player)
public Location getMySpawn(Player player, Plugin plugin)
{
Location loc = null;
if(myspawn != null)
@ -1082,7 +1082,9 @@ public class PlayerProfile
loc.setYaw(0);
loc.setPitch(0);
if(loc.getX() != 0 && loc.getY() != 0 && loc.getZ() != 0 && loc.getWorld() != null){
if(loc.getX() != 0 && loc.getY() != 0 && loc.getZ() != 0 && loc.getWorld() != null)
{
loc.setWorld(plugin.getServer().getWorld(this.getMySpawnWorld(plugin)));
return loc;
} else {
return null;

View File

@ -66,16 +66,18 @@ public class mcPlayerListener extends PlayerListener
if(player != null && PP != null)
{
PP.setRespawnATS(System.currentTimeMillis());
Location mySpawn = PP.getMySpawn(player);
if(mySpawn != null && plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)) != null)
mySpawn.setWorld(plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)));
Location mySpawn = PP.getMySpawn(player, plugin);
if(mySpawn != null)
{
{
event.setRespawnLocation(mySpawn);
}
}
}
}
}
public void onPlayerLogin(PlayerLoginEvent event)
{
Users.addUser(event.getPlayer());
@ -107,9 +109,7 @@ public class mcPlayerListener extends PlayerListener
if(mcPermissions.getInstance().motd(player) && LoadProperties.enableMotd)
{
//player.sendMessage(ChatColor.BLUE +"This server is running mcMMO "+plugin.getDescription().getVersion()+" type /"+ChatColor.YELLOW+LoadProperties.mcmmo+ChatColor.BLUE+ " for help.");
player.sendMessage(mcLocale.getString("mcPlayerListener.MOTD", new Object[] {plugin.getDescription().getVersion(), LoadProperties.mcmmo}));
//player.sendMessage(ChatColor.GREEN+"http://mcmmo.wikia.com"+ChatColor.BLUE+" - mcMMO Wiki");
player.sendMessage(mcLocale.getString("mcPlayerListener.WIKI"));
}
if(plugin.xpevent)
@ -156,7 +156,7 @@ public class mcPlayerListener extends PlayerListener
if(mcPermissions.getInstance().setMySpawn(player)){
PP.setMySpawn(loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName());
}
player.sendMessage(mcLocale.getString("mcPlayerListener.MyspawnSet"));
//player.sendMessage(mcLocale.getString("mcPlayerListener.MyspawnSet"));
}
}

View File

@ -34,7 +34,6 @@ import java.io.OutputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Timer;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -78,7 +77,7 @@ public class mcMMO extends JavaPlugin
public static mcPermissions permissionHandler = new mcPermissions();
private Permissions permissions;
private Timer mcMMO_Timer = new Timer(true); //BLEED AND REGENERATION
private Runnable mcMMO_Timer = new mcTimer(this); //BLEED AND REGENERATION
//private Timer mcMMO_SpellTimer = new Timer(true);
public static Database database = null;
@ -167,7 +166,7 @@ public class mcMMO extends JavaPlugin
for(Player player : getServer().getOnlinePlayers()){Users.addUser(player);} //In case of reload add all users back into PlayerProfile
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
mcMMO_Timer.schedule(new mcTimer(this), (long)0, (long)(1000));
Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, mcMMO_Timer, 0, 20);
}
public static void download(Logger log, URL url, File file) throws IOException
@ -1175,23 +1174,30 @@ public class mcMMO extends JavaPlugin
player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.addxp+" playername skillname xp");
}
}
else if(LoadProperties.ptpEnable && label.equalsIgnoreCase(LoadProperties.ptp) && PP != null && PP.inParty()){
else if(LoadProperties.ptpEnable && label.equalsIgnoreCase(LoadProperties.ptp) && PP.inParty())
{
if(!mcPermissions.getInstance().partyTeleport(player)){
if(!mcPermissions.getInstance().partyTeleport(player))
{
player.sendMessage(ChatColor.YELLOW+"[mcMMO] "+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission"));
return true;
}
if(split.length < 2){
if(split.length < 2)
{
player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.ptp+" <playername>");
return true;
}
if(!isPlayer(split[1])){
if(!isPlayer(split[1]))
{
player.sendMessage("That is not a valid player");
}
if(isPlayer(split[1])){
if(isPlayer(split[1]))
{
Player target = getPlayer(split[1]);
PlayerProfile PPt = Users.getProfile(target);
if(PP.getParty().equals(PPt.getParty())){
if(PP.getParty().equals(PPt.getParty()))
{
player.teleport(target);
player.sendMessage(ChatColor.GREEN+"You have teleported to "+target.getName());
target.sendMessage(ChatColor.GREEN+player.getName() + " has teleported to you.");
@ -1400,12 +1406,12 @@ public class mcMMO extends JavaPlugin
{
if(Pinstance.isPartyLeader(p, PP.getParty()))
{
tempList+=ChatColor.GOLD+p.getName();
tempList+=ChatColor.GOLD+p.getName()+", ";
x++;
}
else
{
tempList+= ChatColor.WHITE+p.getName();
tempList+= ChatColor.WHITE+p.getName()+", ";
x++;
}
}
@ -1697,18 +1703,18 @@ public class mcMMO extends JavaPlugin
player.sendMessage(ChatColor.YELLOW+"[mcMMO] "+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission"));
return true;
}
if(System.currentTimeMillis() < PP.getMySpawnATS() + 3600000){
long x = ((PP.getMySpawnATS() + 3600000) - System.currentTimeMillis());
if(System.currentTimeMillis() < (PP.getMySpawnATS()*1000) + 3600000){
long x = (((PP.getMySpawnATS()*1000) + 3600000) - System.currentTimeMillis());
int y = (int) (x/60000);
int z = (int) ((x/1000) - (y*60));
player.sendMessage(mcLocale.getString("mcPlayerListener.MyspawnTimeNotice", new Object[] {y, z}));
return true;
}
PP.setMySpawnATS(System.currentTimeMillis());
if(PP.getMySpawn(player) != null){
Location mySpawn = PP.getMySpawn(player);
if(mySpawn != null && this.getServer().getWorld(PP.getMySpawnWorld(this)) != null)
mySpawn.setWorld(this.getServer().getWorld(PP.getMySpawnWorld(this)));
if(PP.getMySpawn(player, this) != null)
{
Location mySpawn = PP.getMySpawn(player, this);
if(mySpawn != null){
//It's done twice because it acts oddly when you are in another world
player.teleport(mySpawn);

View File

@ -1,6 +1,4 @@
package com.gmail.nossr50;
import java.util.TimerTask;
import org.bukkit.entity.*;
import com.gmail.nossr50.config.LoadProperties;
@ -9,7 +7,7 @@ import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Swords;
public class mcTimer extends TimerTask
public class mcTimer implements Runnable
{
private final mcMMO plugin;
int thecount = 1;
@ -40,23 +38,6 @@ public class mcTimer extends TimerTask
*/
Skills.watchCooldowns(player);
/*
* MANA MONITORING
*/
/*
if(mcPermissions.getInstance().sorcery(player) && thecount == 20 && PP.getCurrentMana() < PP.getMaxMana())
{
PP.setMana(PP.getCurrentMana()+PP.getMaxMana()/5);
//MAKE SURE THE MANA IS NOT ABOVE MAXIMUM
if(PP.getMaxMana() < PP.getCurrentMana())
PP.setMana(PP.getMaxMana());
if(PP.getMaxMana() != PP.getCurrentMana())
player.sendMessage(Messages.getString("Sorcery.Current_Mana")+" "+ChatColor.GREEN+PP.getCurrentMana()+"/"+PP.getMaxMana());
}
*/
/*
* PLAYER BLEED MONITORING
*/
@ -68,14 +49,14 @@ public class mcTimer extends TimerTask
if(LoadProperties.enableRegen && mcPermissions.getInstance().regeneration(player) && System.currentTimeMillis() >= PP.getRecentlyHurt() + 60000)
{
if(thecount == 10 || thecount == 20 || thecount == 30 || thecount == 40){
if(thecount == 20 || thecount == 40 || thecount == 60 || thecount == 80){
if(player != null &&
player.getHealth() > 0 && player.getHealth() < 20
&& m.getPowerLevel(player) >= 1000){
player.setHealth(m.calculateHealth(player.getHealth(), 1));
}
}
if(thecount == 20 || thecount == 40){
if(thecount == 40 || thecount == 80){
if(player != null &&
player.getHealth() > 0 && player.getHealth() < 20
&& m.getPowerLevel(player) >= 500
@ -83,7 +64,7 @@ public class mcTimer extends TimerTask
player.setHealth(m.calculateHealth(player.getHealth(), 1));
}
}
if(thecount == 40)
if(thecount == 80)
{
if(player != null &&
player.getHealth() > 0 && player.getHealth() < 20
@ -104,7 +85,7 @@ public class mcTimer extends TimerTask
//SETUP FOR HP REGEN/BLEED
thecount++;
if(thecount >= 41)
if(thecount >= 81)
thecount = 1;
}
}

View File

@ -35,7 +35,8 @@ public class Axes {
ticks++;
}
if(!PP.getSkullSplitterMode() && Skills.cooldownOver(player, PP.getSkullSplitterDeactivatedTimeStamp(), LoadProperties.skullSplitterCooldown)){
if(!PP.getSkullSplitterMode() && Skills.cooldownOver(player, (PP.getSkullSplitterDeactivatedTimeStamp()*1000), LoadProperties.skullSplitterCooldown))
{
player.sendMessage(mcLocale.getString("Skills.SkullSplitterOn"));
for(Player y : pluginx.getServer().getOnlinePlayers()){
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
@ -45,9 +46,9 @@ public class Axes {
PP.setSkullSplitterDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
PP.setSkullSplitterMode(true);
}
if(!PP.getSkullSplitterMode() && !Skills.cooldownOver(player, PP.getSkullSplitterDeactivatedTimeStamp(), LoadProperties.skullSplitterCooldown)){
if(!PP.getSkullSplitterMode() && !Skills.cooldownOver(player, (PP.getSkullSplitterDeactivatedTimeStamp()*1000), LoadProperties.skullSplitterCooldown)){
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+Skills.calculateTimeLeft(player, PP.getSkullSplitterDeactivatedTimeStamp(), LoadProperties.skullSplitterCooldown)+"s)");
+ChatColor.YELLOW+" ("+Skills.calculateTimeLeft(player, (PP.getSkullSplitterDeactivatedTimeStamp()*1000), LoadProperties.skullSplitterCooldown)+"s)");
}
}
}

View File

@ -22,8 +22,8 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
public class Skills {
public class Skills
{
protected static final Logger log = Logger.getLogger("Minecraft");
public void updateSQLfromFile(Player player){

View File

@ -19,16 +19,20 @@ import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.config.*;
public class WoodCutting {
public class WoodCutting
{
static int w = 0;
private static boolean isdone = false;
public static void woodCuttingProcCheck(Player player, Block block){
public static void woodCuttingProcCheck(Player player, Block block)
{
PlayerProfile PP = Users.getProfile(player);
byte type = block.getData();
Material mat = Material.getMaterial(block.getTypeId());
if(player != null){
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.WOODCUTTING)){
if(player != null)
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.WOODCUTTING))
{
ItemStack item = new ItemStack(mat, 1, (short) 0, type);
block.getWorld().dropItemNaturally(block.getLocation(), item);
}
@ -53,14 +57,17 @@ public class WoodCutting {
}
int ticks = 2;
int x = PP.getSkillLevel(SkillType.WOODCUTTING);
while(x >= 50){
while(x >= 50)
{
x-=50;
ticks++;
}
if(!PP.getTreeFellerMode() && Skills.cooldownOver(player, PP.getTreeFellerDeactivatedTimeStamp(), LoadProperties.treeFellerCooldown)){
if(!PP.getTreeFellerMode() && Skills.cooldownOver(player, (PP.getTreeFellerDeactivatedTimeStamp()*1000), LoadProperties.treeFellerCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TreeFellerOn"));
for(Player y : pluginx.getServer().getOnlinePlayers()){
for(Player y : pluginx.getServer().getOnlinePlayers())
{
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
y.sendMessage(mcLocale.getString("Skills.TreeFellerPlayer", new Object[] {player.getName()}));
}
@ -68,9 +75,9 @@ public class WoodCutting {
PP.setTreeFellerDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
PP.setTreeFellerMode(true);
}
if(!PP.getTreeFellerMode() && !Skills.cooldownOver(player, PP.getTreeFellerDeactivatedTimeStamp(), LoadProperties.treeFellerCooldown)){
if(!PP.getTreeFellerMode() && !Skills.cooldownOver(player, (PP.getTreeFellerDeactivatedTimeStamp()*1000), LoadProperties.treeFellerCooldown)){
player.sendMessage(ChatColor.RED+"You are too tired to use that ability again."
+ChatColor.YELLOW+" ("+Skills.calculateTimeLeft(player, PP.getTreeFellerDeactivatedTimeStamp(), LoadProperties.treeFellerCooldown)+"s)");
+ChatColor.YELLOW+" ("+Skills.calculateTimeLeft(player, (PP.getTreeFellerDeactivatedTimeStamp()*1000), LoadProperties.treeFellerCooldown)+"s)");
}
}
}
@ -101,9 +108,11 @@ public class WoodCutting {
}
toAdd.clear();
}
public static void addBlocksToTreeFelling(ArrayList<Block> blocklist, ArrayList<Block> toAdd, Integer radius){
public static void addBlocksToTreeFelling(ArrayList<Block> blocklist, ArrayList<Block> toAdd, Integer radius)
{
int u = 0;
for (Block x : blocklist){
for (Block x : blocklist)
{
u++;
if(toAdd.contains(x))
continue;
@ -131,11 +140,13 @@ public class WoodCutting {
/*
* Add more blocks to blocklist so they can be 'felled'
*/
for(Block xx : toAdd){
for(Block xx : toAdd)
{
if(!blocklist.contains(xx))
blocklist.add(xx);
}
if(u >= blocklist.size()){
if(u >= blocklist.size())
{
isdone = true;
} else {
isdone = false;