Skip to content

Commit

Permalink
Added a way to give some XP to the killer of a player.
Browse files Browse the repository at this point in the history
In the default config, two levels are given.
  • Loading branch information
AmauryCarrade committed Jul 23, 2014
1 parent 5e080e8 commit 0874d49
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/me/azenet/UHPlugin/UHPluginListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Ghast;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -63,7 +64,8 @@ public UHPluginListener(UHPlugin p) {
* - drop the skull of the dead player (if needed);
* - update the number of alive players/teams;
* - save the location of the death of the player, to allow a teleportation later;
* - show the death location on the dynmap (if needed)
* - show the death location on the dynmap (if needed);
* - give XP to the killer (if needed).
*
* @param ev
*/
Expand Down Expand Up @@ -114,6 +116,14 @@ public void run() {
}
}

// Give XP to the killer (if needed)
if(p.getConfig().getInt("death.give-xp.levels") > 0) {
Entity killer = ev.getEntity().getKiller();
if(killer != null && killer instanceof Player) {
((Player) killer).giveExpLevels(p.getConfig().getInt("death.give-xp.levels"));
}
}

// Sends a team-death message if needed.
if(p.getConfig().getBoolean("death.messages.notifyIfTeamHasFallen", false)) {
UHTeam team = p.getTeamManager().getTeamForPlayer((Player) ev.getEntity());
Expand All @@ -133,6 +143,7 @@ public void run() {
}
}

// Customizes the death message
ev.setDeathMessage(p.getConfig().getString("death.messages.deathMessagesPrefix", "") + ev.getDeathMessage());

// Updates the number of alive players/teams
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ death:
head:
drop: true
pvpOnly: false
give-xp:
levels: 2 # set to 0 to disable

# If true, the name of the players will be colorized according to the teams.
colorizeChat: true
Expand Down

0 comments on commit 0874d49

Please sign in to comment.