2013-02-09 12:24:02 +01:00
|
|
|
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;
|
|
|
|
|
2013-02-12 18:08:04 +01:00
|
|
|
import com.gmail.nossr50.config.Config;
|
2013-02-09 12:24:02 +01:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.party.Party;
|
|
|
|
import com.gmail.nossr50.party.ShareHandler;
|
|
|
|
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
|
|
|
import com.gmail.nossr50.util.Permissions;
|
2013-02-13 17:45:48 +01:00
|
|
|
import com.gmail.nossr50.util.StringUtils;
|
2013-02-09 12:24:02 +01:00
|
|
|
import com.gmail.nossr50.util.Users;
|
|
|
|
|
|
|
|
public class PartyItemShareCommand implements CommandExecutor {
|
|
|
|
private Party playerParty;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
2013-02-12 18:08:04 +01:00
|
|
|
if (!Config.getInstance().getItemShareEnabled()) {
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Party.ItemShare.Disabled"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-02-09 12:24:02 +01:00
|
|
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.party.itemshare")) {
|
|
|
|
sender.sendMessage(command.getPermissionMessage());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (args.length) {
|
|
|
|
case 2:
|
2013-02-12 17:25:56 +01:00
|
|
|
playerParty = Users.getPlayer((Player) sender).getParty();
|
2013-02-09 12:24:02 +01:00
|
|
|
|
|
|
|
if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) {
|
|
|
|
handleChangingShareMode(ShareMode.NONE);
|
|
|
|
}
|
|
|
|
// else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) {
|
|
|
|
// handleChangingShareMode(ShareMode.EQUAL);
|
|
|
|
// }
|
|
|
|
else if (args[1].equalsIgnoreCase("random")) {
|
|
|
|
handleChangingShareMode(ShareMode.RANDOM);
|
|
|
|
}
|
|
|
|
else {
|
2013-02-11 06:07:58 +01:00
|
|
|
// sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | RANDOM>"));
|
2013-02-09 12:24:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
2013-02-11 06:07:58 +01:00
|
|
|
// sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | RANDOM>"));
|
2013-02-09 12:24:02 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleChangingShareMode(ShareHandler.ShareMode mode) {
|
|
|
|
playerParty.setItemShareMode(mode);
|
|
|
|
|
|
|
|
for (Player member : playerParty.getOnlineMembers()) {
|
2013-02-13 17:45:48 +01:00
|
|
|
member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))));
|
2013-02-09 12:24:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|