use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class CommandSetHome method preRequisites.
@Override
public boolean preRequisites(CommandData commandData) {
Player player = (Player) commandData.getSender();
PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(player.getUniqueId());
/*
* Checks for command prerequisites
*/
if (!player.hasPermission(PartiesPermission.SETHOME.toString())) {
pp.sendNoPermission(PartiesPermission.SETHOME);
return false;
}
PartyEntity party = pp.getPartyName().isEmpty() ? null : plugin.getPartyManager().getParty(pp.getPartyName());
if (party == null) {
pp.sendMessage(Messages.PARTIES_COMMON_NOTINPARTY);
return false;
}
if (!PartiesUtils.checkPlayerRankAlerter(pp, PartiesPermission.PRIVATE_EDIT_HOME))
return false;
if (commandData.getArgs().length > 1 && !commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.COMMANDS_SUB_REMOVE)) {
pp.sendMessage(Messages.ADDCMD_SETHOME_WRONGCMD);
return false;
}
commandData.setPlayer(player);
commandData.setPartyPlayer(pp);
commandData.setParty(party);
return true;
}
use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class CommandSuffix method preRequisites.
@Override
public boolean preRequisites(CommandData commandData) {
Player player = (Player) commandData.getSender();
PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(player.getUniqueId());
/*
* Checks for command prerequisites
*/
if (!player.hasPermission(PartiesPermission.SUFFIX.toString())) {
pp.sendNoPermission(PartiesPermission.SUFFIX);
return false;
}
PartyEntity party = pp.getPartyName().isEmpty() ? null : plugin.getPartyManager().getParty(pp.getPartyName());
if (party == null) {
pp.sendMessage(Messages.PARTIES_COMMON_NOTINPARTY);
return false;
}
if (!PartiesUtils.checkPlayerRankAlerter(pp, PartiesPermission.PRIVATE_EDIT_SUFFIX))
return false;
if (commandData.getArgs().length < 2) {
pp.sendMessage(Messages.ADDCMD_SUFFIX_WRONGCMD);
return false;
}
commandData.setPlayer(player);
commandData.setPartyPlayer(pp);
commandData.setParty(party);
return true;
}
use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class PartyManager method reload.
public void reload() {
listParties = new HashMap<String, PartyEntity>();
listPartiesToDelete = new HashMap<String, Integer>();
if (ConfigParties.FIXED_ENABLE) {
List<Party> lst = plugin.getDatabaseManager().getAllFixed().join();
for (Party party : lst) {
LoggerManager.log(LogLevel.DEBUG, Constants.DEBUG_PARTY_FIXED_LOAD.replace("{party}", party.getName()), true);
loadParty(party.getName());
}
}
}
use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class PartyManager method getParty.
public PartyEntity getParty(String name) {
// Just get the party without save it into the party list
PartyEntity ret = null;
if (name != null && !name.isEmpty()) {
ret = getListParties().get(name.toLowerCase());
if (ret == null) {
Party p = plugin.getDatabaseManager().getParty(name).join();
if (p != null) {
ret = new PartyEntity(p, plugin);
LoggerManager.log(LogLevel.DEBUG, Constants.DEBUG_PARTY_GET_DATABASE.replace("{party}", ret.getName()), true);
}
} else
LoggerManager.log(LogLevel.DEBUG, Constants.DEBUG_PARTY_GET_LIST.replace("{party}", ret.getName()), true);
}
if (ret != null) {
plugin.getColorManager().loadDynamicColor(ret);
ret.refreshPlayers();
}
return ret;
}
use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class EssentialsChatHandler method onChatPlayer.
@EventHandler
public void onChatPlayer(AsyncPlayerChatEvent event) {
String old = event.getFormat();
if (old.toLowerCase().contains("{parties_")) {
// Bypass useless checks if parties doesn't exist
boolean somethingChanged = false;
PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(event.getPlayer().getUniqueId());
PartyEntity party = plugin.getPartyManager().getParty(pp.getPartyName());
Pattern pat = Pattern.compile("\\{parties_([a-z\\_]+)\\}", Pattern.CASE_INSENSITIVE);
Matcher mat = pat.matcher(old);
while (mat.find()) {
String base = mat.group(0);
String identifier = mat.group(1);
if (identifier != null) {
PartiesPlaceholder ph = PartiesPlaceholder.getPlaceholder(identifier);
if (ph != null) {
old = old.replace(base, ph.formatPlaceholder(pp, party));
somethingChanged = true;
}
}
}
if (somethingChanged)
event.setFormat(old);
}
}
Aggregations