Preliminary level caps implementation

Also with an option to choose name/displayname for a and p commands, as well as enable/disable them
This commit is contained in:
NuclearW 2012-02-02 00:24:07 -05:00
parent c95d2a9b84
commit b8f4b6e2da
7 changed files with 111 additions and 23 deletions

View File

@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users; import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
@ -59,8 +60,9 @@ public class ACommand implements CommandExecutor {
aMessage = aMessage + " " + args[i]; aMessage = aMessage + " " + args[i];
} }
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getDisplayName() + ChatColor.AQUA + "} "; String name = (LoadProperties.aDisplayNames) ? player.getDisplayName() : player.getName();
log.log(Level.INFO, "[A]<" + player.getDisplayName() + "> " + aMessage); String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + name + ChatColor.AQUA + "} ";
log.log(Level.INFO, "[A]<" + name + "> " + aMessage);
for (Player herp : Bukkit.getServer().getOnlinePlayers()) { for (Player herp : Bukkit.getServer().getOnlinePlayers()) {
if (mcPermissions.getInstance().adminChat(herp) || herp.isOp()) if (mcPermissions.getInstance().adminChat(herp) || herp.isOp())
herp.sendMessage(aPrefix + aMessage); herp.sendMessage(aPrefix + aMessage);

View File

@ -69,9 +69,10 @@ public class PCommand implements CommandExecutor {
for (int i = 1; i <= args.length - 1; i++) { for (int i = 1; i <= args.length - 1; i++) {
pMessage = pMessage + " " + args[i]; pMessage = pMessage + " " + args[i];
} }
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getDisplayName() + ChatColor.GREEN + ") ";
log.log(Level.INFO, "[P](" + PP.getParty() + ")" + "<" + player.getDisplayName() + "> " + pMessage); String name = (LoadProperties.pDisplayNames) ? player.getDisplayName() : player.getName();
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + name + ChatColor.GREEN + ") ";
log.log(Level.INFO, "[P](" + PP.getParty() + ")" + "<" + name + "> " + pMessage);
for (Player herp : Bukkit.getServer().getOnlinePlayers()) { for (Player herp : Bukkit.getServer().getOnlinePlayers()) {
if (Users.getProfile(herp).inParty()) { if (Users.getProfile(herp).inParty()) {

View File

@ -33,8 +33,8 @@ public class LoadProperties {
mcmmoEnable, partyEnable, inviteEnable, acceptEnable, whoisEnable, mcmmoEnable, partyEnable, inviteEnable, acceptEnable, whoisEnable,
statsEnable, addxpEnable, ptpEnable, mmoeditEnable, statsEnable, addxpEnable, ptpEnable, mmoeditEnable,
clearmyspawnEnable, mcgodEnable, mcabilityEnable, mctopEnable, clearmyspawnEnable, mcgodEnable, mcabilityEnable, mctopEnable,
mcrefreshEnable, enableMotd, enableMySpawn, enableRegen, mcrefreshEnable, aEnable, pEnable, enableMotd, enableMySpawn,
enableCobbleToMossy, useMySQL, cocoabeans, mushrooms, enableRegen, enableCobbleToMossy, useMySQL, cocoabeans, mushrooms,
toolsLoseDurabilityFromAbilities, pvpxp, miningrequirespickaxe, toolsLoseDurabilityFromAbilities, pvpxp, miningrequirespickaxe,
excavationRequiresShovel, woodcuttingrequiresaxe, eggs, apples, excavationRequiresShovel, woodcuttingrequiresaxe, eggs, apples,
cake, music, diamond, glowstone, slowsand, sulphur, netherrack, cake, music, diamond, glowstone, slowsand, sulphur, netherrack,
@ -42,7 +42,7 @@ public class LoadProperties {
mayLoseEnchants, fishingDrops, leatherArmor, ironArmor, goldArmor, mayLoseEnchants, fishingDrops, leatherArmor, ironArmor, goldArmor,
diamondArmor, woodenTools, stoneTools, ironTools, goldTools, diamondArmor, woodenTools, stoneTools, ironTools, goldTools,
diamondTools, enderPearl, blazeRod, records, glowstoneDust, diamondTools, enderPearl, blazeRod, records, glowstoneDust,
fishingDiamonds; fishingDiamonds, aDisplayNames, pDisplayNames;
public static String MySQLtablePrefix, MySQLuserName, public static String MySQLtablePrefix, MySQLuserName,
MySQLserverName, MySQLdbName, MySQLdbPass, nWood, nStone, MySQLserverName, MySQLdbName, MySQLdbPass, nWood, nStone,
@ -66,7 +66,11 @@ public class LoadProperties {
keepEnchantsRank3, keepEnchantsRank4, fishingDropChanceTier1, keepEnchantsRank3, keepEnchantsRank4, fishingDropChanceTier1,
fishingDropChanceTier2, fishingDropChanceTier3, fishingDropChanceTier2, fishingDropChanceTier3,
fishingDropChanceTier4, fishingDropChanceTier5, mnetherwart, fishingDropChanceTier4, fishingDropChanceTier5, mnetherwart,
mvines, mlilypad, mnetherbrick, mendstone, mmossstone, mstonebrick; mvines, mlilypad, mnetherbrick, mendstone, mmossstone, mstonebrick,
levelCapAcrobatics, levelCapArchery, levelCapAxes, levelCapExcavation,
levelCapFishing, levelCapHerbalism, levelCapMining, levelCapRepair,
levelCapSwords, levelCapTaming, levelCapUnarmed, levelCapWoodcutting;
public static double xpbackground_r, xpbackground_g, xpbackground_b, public static double xpbackground_r, xpbackground_g, xpbackground_b,
xpborder_r, xpborder_g, xpborder_b, fishing_r, fishing_g, xpborder_r, xpborder_g, xpborder_b, fishing_r, fishing_g,
@ -339,6 +343,19 @@ public class LoadProperties {
nString = readString("Skills.Repair.String.Name", "String"); nString = readString("Skills.Repair.String.Name", "String");
rLeather = readInteger("Skills.Repair.Leather.ID", 334); rLeather = readInteger("Skills.Repair.Leather.ID", 334);
nLeather = readString("Skills.Repair.String.Name", "Leather"); nLeather = readString("Skills.Repair.String.Name", "Leather");
levelCapAcrobatics = readInteger("Skills.Acrobatics.Level_Cap", 0);
levelCapArchery = readInteger("Skills.Archery.Level_Cap", 0);
levelCapAxes = readInteger("Skills.Axes.Level_Cap", 0);
levelCapExcavation = readInteger("Skills.Excavation.Level_Cap", 0);
levelCapFishing = readInteger("Skills.Fishing.Level_Cap", 0);
levelCapHerbalism = readInteger("Skills.Herbalism.Level_Cap", 0);
levelCapMining = readInteger("Skills.Mining.Level_Cap", 0);
levelCapRepair = readInteger("Skills.Repair.Level_Cap", 0);
levelCapSwords = readInteger("Skills.Swords.Level_Cap", 0);
levelCapTaming = readInteger("Skills.Taming.Level_Cap", 0);
levelCapUnarmed = readInteger("Skills.Unarmed.Level_Cap", 0);
levelCapWoodcutting = readInteger("Skills.Woodcutting.Level_Cap", 0);
mayDowngradeEnchants = readBoolean("Arcane_Forging.Downgrades.Enabled", true); mayDowngradeEnchants = readBoolean("Arcane_Forging.Downgrades.Enabled", true);
downgradeRank1 = readInteger("Arcane_Forging.Downgrades.Chance.Rank_1", 75); downgradeRank1 = readInteger("Arcane_Forging.Downgrades.Chance.Rank_1", 75);
@ -408,5 +425,10 @@ public class LoadProperties {
inviteEnable = readBoolean("Commands.invite.Enabled", true); inviteEnable = readBoolean("Commands.invite.Enabled", true);
acceptEnable = readBoolean("Commands.accept.Enabled", true); acceptEnable = readBoolean("Commands.accept.Enabled", true);
clearmyspawnEnable = readBoolean("Commands.clearmyspawn.Enabled", true); clearmyspawnEnable = readBoolean("Commands.clearmyspawn.Enabled", true);
aEnable = readBoolean("Commands.a.Enabled", true);
pEnable = readBoolean("Commands.p.Enabled", true);
aDisplayNames = readBoolean("Commands.a.Display_Names", true);
pDisplayNames = readBoolean("Commands.p.Display_Names", true);
} }
} }

View File

@ -315,7 +315,8 @@ public class mcPlayerListener implements Listener
if(PP.getPartyChatMode()) if(PP.getPartyChatMode())
{ {
event.setCancelled(true); event.setCancelled(true);
String format = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getDisplayName() + ChatColor.GREEN + ") "+event.getMessage(); String name = (LoadProperties.pDisplayNames) ? player.getDisplayName() : player.getName();
String format = ChatColor.GREEN + "(" + ChatColor.WHITE + name + ChatColor.GREEN + ") "+event.getMessage();
for(Player x : Bukkit.getServer().getOnlinePlayers()) for(Player x : Bukkit.getServer().getOnlinePlayers())
{ {
if(Party.getInstance().inSameParty(player, x)) if(Party.getInstance().inSameParty(player, x))
@ -328,7 +329,8 @@ public class mcPlayerListener implements Listener
} }
} else if (PP.getAdminChatMode()) { } else if (PP.getAdminChatMode()) {
event.setCancelled(true); event.setCancelled(true);
String format = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getDisplayName() + ChatColor.AQUA + "} "+event.getMessage(); String name = (LoadProperties.aDisplayNames) ? player.getDisplayName() : player.getName();
String format = ChatColor.AQUA + "{" + ChatColor.WHITE + name + ChatColor.AQUA + "} "+event.getMessage();
for(Player x : Bukkit.getServer().getOnlinePlayers()) for(Player x : Bukkit.getServer().getOnlinePlayers())
{ {
if(x.isOp() || mcPermissions.getInstance().adminChat(x)) if(x.isOp() || mcPermissions.getInstance().adminChat(x))

View File

@ -301,10 +301,10 @@ public class mcMMO extends JavaPlugin
//Party commands //Party commands
if(LoadProperties.acceptEnable) getCommand("accept").setExecutor(new AcceptCommand()); if(LoadProperties.acceptEnable) getCommand("accept").setExecutor(new AcceptCommand());
getCommand("a").setExecutor(new ACommand()); if(LoadProperties.aEnable) getCommand("a").setExecutor(new ACommand());
if(LoadProperties.inviteEnable) getCommand("invite").setExecutor(new InviteCommand(this)); if(LoadProperties.inviteEnable) getCommand("invite").setExecutor(new InviteCommand(this));
if(LoadProperties.partyEnable) getCommand("party").setExecutor(new PartyCommand()); if(LoadProperties.partyEnable) getCommand("party").setExecutor(new PartyCommand());
getCommand("p").setExecutor(new PCommand()); if(LoadProperties.pEnable) getCommand("p").setExecutor(new PCommand());
if(LoadProperties.ptpEnable) getCommand("ptp").setExecutor(new PtpCommand(this)); if(LoadProperties.ptpEnable) getCommand("ptp").setExecutor(new PtpCommand(this));
//Other commands //Other commands

View File

@ -315,6 +315,11 @@ public class Skills
public static void XpCheckSkill(SkillType skillType, Player player) public static void XpCheckSkill(SkillType skillType, Player player)
{ {
if(skillType == SkillType.ALL) {
XpCheckAll(player);
return;
}
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
if(PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType)) if(PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType))
@ -323,12 +328,14 @@ public class Skills
while(PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType)) while(PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType))
{ {
skillups++; if(getSkillMaxLevel(skillType) >= PP.getSkillLevel(skillType) + 1) {
skillups++;
PP.skillUp(skillType, 1);
McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType);
Bukkit.getPluginManager().callEvent(eventToFire);
}
PP.removeXP(skillType, PP.getXpToLevel(skillType)); PP.removeXP(skillType, PP.getXpToLevel(skillType));
PP.skillUp(skillType, 1);
McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType);
Bukkit.getPluginManager().callEvent(eventToFire);
} }
if(!LoadProperties.useMySQL) if(!LoadProperties.useMySQL)
@ -376,6 +383,36 @@ public class Skills
XpCheckSkill(x, player); XpCheckSkill(x, player);
} }
} }
public static int getSkillMaxLevel(SkillType skillType) {
switch(skillType) {
case ACROBATICS:
return (LoadProperties.levelCapAcrobatics > 0) ? LoadProperties.levelCapAcrobatics : Integer.MAX_VALUE;
case ARCHERY:
return (LoadProperties.levelCapArchery > 0) ? LoadProperties.levelCapArchery : Integer.MAX_VALUE;
case AXES:
return (LoadProperties.levelCapAxes > 0) ? LoadProperties.levelCapAxes : Integer.MAX_VALUE;
case EXCAVATION:
return (LoadProperties.levelCapExcavation > 0) ? LoadProperties.levelCapExcavation : Integer.MAX_VALUE;
case FISHING:
return (LoadProperties.levelCapFishing > 0) ? LoadProperties.levelCapFishing : Integer.MAX_VALUE;
case HERBALISM:
return (LoadProperties.levelCapHerbalism > 0) ? LoadProperties.levelCapHerbalism : Integer.MAX_VALUE;
case MINING:
return (LoadProperties.levelCapMining > 0) ? LoadProperties.levelCapMining : Integer.MAX_VALUE;
case REPAIR:
return (LoadProperties.levelCapRepair > 0) ? LoadProperties.levelCapRepair : Integer.MAX_VALUE;
case SWORDS:
return (LoadProperties.levelCapSwords > 0) ? LoadProperties.levelCapSwords : Integer.MAX_VALUE;
case TAMING:
return (LoadProperties.levelCapTaming > 0) ? LoadProperties.levelCapTaming : Integer.MAX_VALUE;
case UNARMED:
return (LoadProperties.levelCapUnarmed > 0) ? LoadProperties.levelCapUnarmed : Integer.MAX_VALUE;
case WOODCUTTING:
return (LoadProperties.levelCapWoodcutting > 0) ? LoadProperties.levelCapWoodcutting : Integer.MAX_VALUE;
default:
return Integer.MAX_VALUE;
}
}
public static SkillType getSkillType(String skillName) public static SkillType getSkillType(String skillName)
{ {
for(SkillType x : SkillType.values()) for(SkillType x : SkillType.values())

View File

@ -106,19 +106,26 @@ Fishing:
Ender_Pearl: true Ender_Pearl: true
Wooden_Tools: true Wooden_Tools: true
Skills: Skills:
Taming: Acrobatics:
Call_Of_The_Wild: Level_Cap: 0 #Level cap of 0 for no limit
Bones_Required: 10 Archery:
Level_Cap: 0
Axes:
Level_Cap: 0
Excavation: Excavation:
Level_Cap: 0
Requires_Shovel: true Requires_Shovel: true
Woodcutting: Fishing:
Requires_Axe: true Level_Cap: 0
Herbalism: Herbalism:
Level_Cap: 0
Green_Thumb: Green_Thumb:
Cobble_To_Mossy: true Cobble_To_Mossy: true
Mining: Mining:
Level_Cap: 0
Requires_Pickaxe: true Requires_Pickaxe: true
Repair: Repair:
Level_Cap: 0
Leather: Leather:
ID: 334 ID: 334
String: String:
@ -141,6 +148,17 @@ Skills:
Iron: Iron:
Name: Iron Bars Name: Iron Bars
ID: 265 ID: 265
Swords:
Level_Cap: 0
Taming:
Level_Cap: 0
Call_Of_The_Wild:
Bones_Required: 10
Unarmed:
Level_Cap: 0
Woodcutting:
Level_Cap: 0
Requires_Axe: true
Experience: Experience:
Fishing: Fishing:
Base: 800 Base: 800
@ -327,4 +345,10 @@ Commands:
clearmyspawn: clearmyspawn:
Enabled: true Enabled: true
ptp: ptp:
Enabled: true Enabled: true
p:
Enabled: true
Display_Names: true
a:
Enabled: true
Display_Names: true