Added McMMOPartyTeleportEvent for API usage - fires before a successful

teleportation would occur.
This commit is contained in:
GJ 2012-03-27 15:57:37 -04:00
parent f786c4db50
commit aaa63a7f5d
5 changed files with 56 additions and 6 deletions

View File

@ -11,6 +11,7 @@ Version 1.3.04-dev
+ Added McMMOPlayerRepairEvent for API usage - fires after completion of a repair.
+ Added McMMOPlayerRepairCheckEvent for API usage - fires before repair process begins, can be cancelled.
+ Added ability to get skill level from McMMOPlayerExperience events
+ Added McMMOPartyTeleportEvent for API usage - fires before a successful teleportation would occur.
= Fixed Shake ability dropping bonemeal instead of ink for squids.
= Fixed Green Terra & Super Breaker awarding 4x drops at high levels.
= Fixed summoned ocelots never changing skins.

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -11,6 +12,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
@ -61,10 +63,16 @@ public class PtpCommand implements CommandExecutor {
if (plugin.getServer().getPlayer(args[0]) != null) {
Player target = plugin.getServer().getPlayer(args[0]);
PlayerProfile PPt = Users.getProfile(target);
if (PP.getParty().equals(PPt.getParty())) {
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty());
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
player.teleport(target);
player.sendMessage(ChatColor.GREEN + "You have teleported to " + target.getName()); //TODO: Needs more locale.
target.sendMessage(ChatColor.GREEN + player.getName() + " has teleported to you."); //TODO: Needs more locale.
}
} else {
player.sendMessage(ChatColor.RED + "That player is in a different party than you."); //TODO: Needs more locale.
}

View File

@ -0,0 +1,37 @@
package com.gmail.nossr50.events.party;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerTeleportEvent;
public class McMMOPartyTeleportEvent extends PlayerTeleportEvent{
private String party;
private Player target;
public McMMOPartyTeleportEvent(Player player, Player target, String party) {
super(player, player.getLocation(), target.getLocation(), TeleportCause.COMMAND);
this.party = party;
this.target = target;
}
public String getParty() {
return party;
}
public Player getTarget() {
return target;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -21,6 +21,10 @@ public class McMMOPlayerSkillEvent extends PlayerEvent{
return skill;
}
public int getSkillLevel() {
return skillLevel;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();

View File

@ -295,7 +295,7 @@ public class Party {
savePartyLocks();
}
public void deleteParty(String partyName) {
private void deleteParty(String partyName) {
this.partyPlayers.remove(partyName);
this.partyLocks.remove(partyName);
this.partyPasswords.remove(partyName);