mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Add McMMOPlayerXpGainEvent
Rename playername to playerName
This commit is contained in:
parent
5cbee8a4ab
commit
d97e97ae5f
@ -32,6 +32,7 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.events.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
@ -64,7 +65,7 @@ public class PlayerProfile
|
||||
//MySQL STUFF
|
||||
private int xpbarinc=0, lastlogin=0, userid = 0, bleedticks = 0;
|
||||
|
||||
private String playername;
|
||||
private String playerName;
|
||||
|
||||
//Time to HashMap this shiz
|
||||
HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and XP
|
||||
@ -92,7 +93,7 @@ public class PlayerProfile
|
||||
}
|
||||
}
|
||||
|
||||
playername = player.getName();
|
||||
playerName = player.getName();
|
||||
if (LoadProperties.useMySQL)
|
||||
{
|
||||
if(!loadMySQL(player)) {
|
||||
@ -219,7 +220,7 @@ public class PlayerProfile
|
||||
//Find if the line contains the player we want.
|
||||
String[] character = line.split(":");
|
||||
|
||||
if(!character[0].equals(playername)){continue;}
|
||||
if(!character[0].equals(playerName)){continue;}
|
||||
|
||||
//Get Mining
|
||||
if(character.length > 1 && m.isInt(character[1]))
|
||||
@ -377,13 +378,13 @@ public class PlayerProfile
|
||||
{
|
||||
//Read the line in and copy it to the output it's not the player
|
||||
//we want to edit
|
||||
if(!line.split(":")[0].equalsIgnoreCase(playername))
|
||||
if(!line.split(":")[0].equalsIgnoreCase(playerName))
|
||||
{
|
||||
writer.append(line).append("\r\n");
|
||||
|
||||
//Otherwise write the new player information
|
||||
} else {
|
||||
writer.append(playername + ":");
|
||||
writer.append(playerName + ":");
|
||||
writer.append(skills.get(SkillType.MINING) + ":");
|
||||
writer.append(myspawn + ":");
|
||||
writer.append(party+":");
|
||||
@ -442,7 +443,7 @@ public class PlayerProfile
|
||||
BufferedWriter out = new BufferedWriter(file);
|
||||
|
||||
//Add the player to the end
|
||||
out.append(playername + ":");
|
||||
out.append(playerName + ":");
|
||||
out.append(0 + ":"); //mining
|
||||
out.append(myspawn+":");
|
||||
out.append(party+":");
|
||||
@ -580,7 +581,7 @@ public class PlayerProfile
|
||||
|
||||
public boolean isPlayer(String player)
|
||||
{
|
||||
return player.equals(playername);
|
||||
return player.equals(Bukkit.getPlayer(playerName));
|
||||
}
|
||||
public boolean getPartyChatOnlyToggle(){return partyChatOnly;}
|
||||
public void togglePartyChatOnly(){partyChatOnly = !partyChatOnly;}
|
||||
@ -852,12 +853,14 @@ public class PlayerProfile
|
||||
{
|
||||
if(x == SkillType.ALL)
|
||||
continue;
|
||||
Bukkit.getPluginManager().callEvent(new McMMOPlayerXpGainEvent(Bukkit.getPlayer(playerName), x, newvalue));
|
||||
skillsXp.put(x, skillsXp.get(x)+newvalue);
|
||||
}
|
||||
} else {
|
||||
int xp = newvalue;
|
||||
|
||||
xp=xp*LoadProperties.xpGainMultiplier;
|
||||
Bukkit.getPluginManager().callEvent(new McMMOPlayerXpGainEvent(Bukkit.getPlayer(playerName), skillType, xp));
|
||||
skillsXp.put(skillType, skillsXp.get(skillType)+xp);
|
||||
lastgained = skillType;
|
||||
}
|
||||
@ -904,6 +907,7 @@ public class PlayerProfile
|
||||
{
|
||||
if(x == SkillType.ALL)
|
||||
continue;
|
||||
Bukkit.getPluginManager().callEvent(new McMMOPlayerXpGainEvent(Bukkit.getPlayer(playerName), x, newvalue));
|
||||
skillsXp.put(x, skillsXp.get(x)+newvalue);
|
||||
}
|
||||
} else {
|
||||
@ -958,6 +962,7 @@ public class PlayerProfile
|
||||
double percent = (trueBonus/oldxp)*100;
|
||||
thisplayer.sendMessage(ChatColor.GREEN+"XP: "+oldxp+" Bonus XP: "+trueBonus+" Total: "+xp+ChatColor.GOLD+" [Master: "+leaderName+" " +" +"+(int)percent+"%]");
|
||||
}
|
||||
Bukkit.getPluginManager().callEvent(new McMMOPlayerXpGainEvent(Bukkit.getPlayer(playerName), skillType, xp));
|
||||
skillsXp.put(skillType, skillsXp.get(skillType)+xp);
|
||||
lastgained = skillType;
|
||||
}
|
||||
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
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.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class McMMOPlayerXpGainEvent extends Event {
|
||||
private Player player;
|
||||
private SkillType skill;
|
||||
private int xpGained;
|
||||
|
||||
public McMMOPlayerXpGainEvent(Player player, SkillType skill, int xpGained) {
|
||||
this.player = player;
|
||||
this.skill = skill;
|
||||
this.xpGained = xpGained;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player gaining experience (can be null)
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SkillType that is gaining experience
|
||||
*/
|
||||
public SkillType getSkill() {
|
||||
return skill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The number experience gained in this event
|
||||
*/
|
||||
public int getXpGained() {
|
||||
return xpGained;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user