mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-24 17:47:44 +01:00
Convert /party shareexp to a subcommand
This commit is contained in:
parent
7a357634c7
commit
e14f8ad93c
@ -16,7 +16,6 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
@ -28,6 +27,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
private CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
|
private CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
|
||||||
private CommandExecutor partyCreateCommand = new PartyCreateCommand();
|
private CommandExecutor partyCreateCommand = new PartyCreateCommand();
|
||||||
private CommandExecutor partyQuitCommand = new PartyQuitCommand();
|
private CommandExecutor partyQuitCommand = new PartyQuitCommand();
|
||||||
|
private CommandExecutor partyShareExpCommand = new PartyShareExpCommand();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
@ -69,7 +69,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
return partyQuitCommand.onCommand(sender, command, label, args);
|
return partyQuitCommand.onCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("expshare")) {
|
else if (args[0].equalsIgnoreCase("expshare")) {
|
||||||
return shareExp(args);
|
return partyShareExpCommand.onCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("itemshare")) {
|
else if (args[0].equalsIgnoreCase("itemshare")) {
|
||||||
return shareItem();
|
return shareItem();
|
||||||
@ -176,43 +176,6 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shareExp(String[] args) {
|
|
||||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.expshare")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length < 2) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "[NONE / EQUAL]"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String playerName = player.getName();
|
|
||||||
Party party = mcMMOPlayer.getParty();
|
|
||||||
|
|
||||||
if (party.getLeader().equals(playerName)) {
|
|
||||||
if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("false")) {
|
|
||||||
party.setXpShareMode(ShareHandler.XpShareMode.NONE);
|
|
||||||
|
|
||||||
for (Player onlineMembers : party.getOnlineMembers()) {
|
|
||||||
onlineMembers.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode.NoShare")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) {
|
|
||||||
party.setXpShareMode(ShareHandler.XpShareMode.EQUAL);
|
|
||||||
|
|
||||||
for (Player onlineMembers : party.getOnlineMembers()) {
|
|
||||||
onlineMembers.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode.Equal")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "[NONE / EQUAL]"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean shareItem() {
|
private boolean shareItem() {
|
||||||
return (!CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.itemshare"));
|
return (!CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.itemshare"));
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
package com.gmail.nossr50.party.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.party.Party;
|
||||||
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
|
import com.gmail.nossr50.party.ShareHandler.XpShareMode;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
|
public class PartyShareExpCommand implements CommandExecutor {
|
||||||
|
private Player player;
|
||||||
|
private Party playerParty;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.party.expshare")) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 2:
|
||||||
|
player = (Player) sender;
|
||||||
|
playerParty = Users.getPlayer(player).getParty();
|
||||||
|
|
||||||
|
if (!playerParty.getLeader().equals(player.getName())) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) {
|
||||||
|
handleChangingShareMode(XpShareMode.NONE);
|
||||||
|
}
|
||||||
|
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true")) {
|
||||||
|
handleChangingShareMode(XpShareMode.EQUAL);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "[NONE | EQUAL]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "[NONE | EQUAL]"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleChangingShareMode(ShareHandler.XpShareMode mode) {
|
||||||
|
playerParty.setXpShareMode(mode);
|
||||||
|
|
||||||
|
for (Player member : playerParty.getOnlineMembers()) {
|
||||||
|
member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + Misc.getCapitalized(mode.toString()))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -550,7 +550,7 @@ Party.Status.Locked=[[DARK_RED]](INVITE-ONLY)
|
|||||||
Party.Status.Unlocked=[[DARK_GREEN]](OPEN)
|
Party.Status.Unlocked=[[DARK_GREEN]](OPEN)
|
||||||
Party.ShareType.Exp=EXP
|
Party.ShareType.Exp=EXP
|
||||||
Party.ShareType.Item=ITEM
|
Party.ShareType.Item=ITEM
|
||||||
Party.ShareMode.NoShare=NONE
|
Party.ShareMode.None=NONE
|
||||||
Party.ShareMode.Equal=EQUAL
|
Party.ShareMode.Equal=EQUAL
|
||||||
Party.ShareMode.Random=RANDOM
|
Party.ShareMode.Random=RANDOM
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user