mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-04-06 11:46:24 +02:00

hardcore commands. Moved lots of duplicated code to functions in CommandUtils.java. Split /ptp into individual commands, just like /party. Used ternary logic to simplify some of our /skillname stat displays. Fixed skill guide to not allow for negative pages. Simplified logic for many /skillname data calculations. Use permission checks to prevent calculating data that will never be displayed. Made the skill guide into its own command.
52 lines
1.8 KiB
Java
52 lines
1.8 KiB
Java
package com.gmail.nossr50.commands.party;
|
|
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandExecutor;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
import com.gmail.nossr50.datatypes.party.Party;
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
import com.gmail.nossr50.party.PartyManager;
|
|
import com.gmail.nossr50.util.player.UserManager;
|
|
|
|
public class PartyCreateCommand implements CommandExecutor {
|
|
@Override
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
switch (args.length) {
|
|
case 2:
|
|
case 3:
|
|
Party newParty = PartyManager.getParty(args[1]);
|
|
|
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
|
Player player = mcMMOPlayer.getPlayer();
|
|
|
|
// Check to see if the party exists, and if it does cancel creating a new party
|
|
if (PartyManager.checkPartyExistence(player, newParty, args[1])) {
|
|
return true;
|
|
}
|
|
|
|
// Changing parties
|
|
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) {
|
|
return true;
|
|
}
|
|
|
|
PartyManager.createParty(player, mcMMOPlayer, args[1], getPassword(args));
|
|
return true;
|
|
|
|
default:
|
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "create", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]"));
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private String getPassword(String[] args) {
|
|
if (args.length == 3) {
|
|
return args[2];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|