mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-19 00:45:27 +01:00
Made /party kick work on offline players
This commit is contained in:
parent
bcd8906315
commit
0aeff40aaa
@ -51,6 +51,7 @@ Version 1.4.00-dev
|
||||
= Fixed Experience.Gains.Mobspawners.Enabled not being used correctly (the check was inverted)
|
||||
= Fixed bug where Iron Grip was using the attacker's skill values rather than the defender's.
|
||||
= Fixed a bug where /party kick would trigger the PartyChangeEvent for the wrong player
|
||||
= Fixed /party kick not working on offline players
|
||||
= Fixed a bug where party join messages weren't displayed
|
||||
= Fixed a bug where Disarm and Deflect had wrong values
|
||||
= Fixed Magic Hunter (Fishing ability) favoring certain enchants
|
||||
|
@ -39,7 +39,7 @@ public final class PartyManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two players are in the same party.
|
||||
* Check if two online players are in the same party.
|
||||
*
|
||||
* @param firstPlayer The first player
|
||||
* @param secondPlayer The second player
|
||||
|
@ -7,8 +7,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@ -38,32 +36,25 @@ public class PartyKickCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOTarget = Users.getPlayer(args[1]);
|
||||
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
|
||||
|
||||
// Would be nice to find a way to check if a player is valid here - this won't work directly because it'll also throw null for an offline player
|
||||
// if (mcMMOTarget == null) {
|
||||
// sender.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
// return false;
|
||||
// }
|
||||
|
||||
Player target = mcMMOTarget.getPlayer();
|
||||
|
||||
if (!PartyManager.inSameParty(player, target)) {
|
||||
if (!playerParty.getMembers().contains(target)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mcMMO.p.getServer().getOfflinePlayer(args[1]).isOnline()) {
|
||||
if (target.isOnline()) {
|
||||
Player onlineTarget = target.getPlayer();
|
||||
String partyName = playerParty.getName();
|
||||
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(target, partyName, null, EventReason.KICKED_FROM_PARTY);
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
|
||||
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
|
||||
}
|
||||
|
||||
PartyManager.removeFromParty(target, playerParty);
|
||||
|
@ -121,7 +121,7 @@ public final class Users {
|
||||
* @param player The player whose McMMOPlayer to retrieve
|
||||
* @return the player's McMMOPlayer object
|
||||
*/
|
||||
public static McMMOPlayer getPlayer(Player player) {
|
||||
public static McMMOPlayer getPlayer(OfflinePlayer player) {
|
||||
return players.get(player.getName());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user