mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
No point in repeating this check over multiple classes.
This commit is contained in:
parent
45ebc2b89b
commit
e5c7e81b08
@ -13,9 +13,6 @@ import com.gmail.nossr50.util.Permissions;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class PartyChangeOwnerCommand implements CommandExecutor {
|
public class PartyChangeOwnerCommand implements CommandExecutor {
|
||||||
private Player player;
|
|
||||||
private Party playerParty;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (!Permissions.hasPermission(sender, "mcmmo.commands.party.owner")) {
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.party.owner")) {
|
||||||
@ -25,16 +22,10 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
|
|||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
player = (Player) sender;
|
Party playerParty = Users.getPlayer((Player) sender).getParty();
|
||||||
playerParty = Users.getPlayer(player).getParty();
|
|
||||||
|
|
||||||
if (!playerParty.getLeader().equals(player.getName())) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!playerParty.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) {
|
if (!playerParty.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,13 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
else if (args[0].equalsIgnoreCase("invite")) {
|
else if (args[0].equalsIgnoreCase("invite")) {
|
||||||
return partyInviteCommand.onCommand(sender, command, label, args);
|
return partyInviteCommand.onCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("kick")) {
|
|
||||||
|
if (!mcMMOPlayer.getParty().getLeader().equals(player.getName())) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("kick")) {
|
||||||
return partyKickCommand.onCommand(sender, command, label, args);
|
return partyKickCommand.onCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("disband")) {
|
else if (args[0].equalsIgnoreCase("disband")) {
|
||||||
|
@ -13,9 +13,6 @@ import com.gmail.nossr50.util.Permissions;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class PartyDisbandCommand implements CommandExecutor {
|
public class PartyDisbandCommand implements CommandExecutor {
|
||||||
private Player player;
|
|
||||||
private Party playerParty;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (!Permissions.hasPermission(sender, "mcmmo.commands.party.disband")) {
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.party.disband")) {
|
||||||
@ -25,13 +22,7 @@ public class PartyDisbandCommand implements CommandExecutor {
|
|||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
player = (Player) sender;
|
Party playerParty = Users.getPlayer((Player) sender).getParty();
|
||||||
playerParty = Users.getPlayer(player).getParty();
|
|
||||||
|
|
||||||
if (!playerParty.getLeader().equals(player.getName())) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Player member : playerParty.getOnlineMembers()) {
|
for (Player member : playerParty.getOnlineMembers()) {
|
||||||
if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), null, EventReason.KICKED_FROM_PARTY)) {
|
if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), null, EventReason.KICKED_FROM_PARTY)) {
|
||||||
|
@ -15,9 +15,6 @@ import com.gmail.nossr50.util.Permissions;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class PartyKickCommand implements CommandExecutor {
|
public class PartyKickCommand implements CommandExecutor {
|
||||||
private Player player;
|
|
||||||
private Party playerParty;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (!Permissions.hasPermission(sender, "mcmmo.commands.party.kick")) {
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.party.kick")) {
|
||||||
@ -27,13 +24,7 @@ public class PartyKickCommand implements CommandExecutor {
|
|||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
player = (Player) sender;
|
Party playerParty = Users.getPlayer((Player) sender).getParty();
|
||||||
playerParty = Users.getPlayer(player).getParty();
|
|
||||||
|
|
||||||
if (!playerParty.getLeader().equals(player.getName())) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
|
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
|
||||||
|
|
||||||
@ -61,5 +52,4 @@ public class PartyKickCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,18 +11,11 @@ import com.gmail.nossr50.util.Permissions;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class PartyLockCommand implements CommandExecutor {
|
public class PartyLockCommand implements CommandExecutor {
|
||||||
private Player player;
|
|
||||||
private Party playerParty;
|
private Party playerParty;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
player = (Player) sender;
|
playerParty = Users.getPlayer((Player) sender).getParty();
|
||||||
playerParty = Users.getPlayer(player).getParty();
|
|
||||||
|
|
||||||
if (!playerParty.getLeader().equals(player.getName())) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -89,11 +82,11 @@ public class PartyLockCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!playerParty.isLocked()) {
|
if (!playerParty.isLocked()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
|
sender.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerParty.setLocked(false);
|
playerParty.setLocked(false);
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Unlocked"));
|
sender.sendMessage(LocaleLoader.getString("Party.Unlocked"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user