use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class PartyPlayerImpl method getAllowedCommands.
/**
* Player allowed commands
*/
public Set<ADPCommand> getAllowedCommands() {
Set<ADPCommand> ret = new HashSet<>();
User player = plugin.getPlayer(getPlayerUUID());
if (player.hasPermission(PartiesPermission.USER_HELP))
ret.add(CommonCommands.HELP);
if (partyId != null) {
// In party
if (player.hasPermission(PartiesPermission.USER_SENDMESSAGE) && plugin.getRankManager().checkPlayerRank(this, RankPermission.SENDMESSAGE))
ret.add(CommonCommands.P);
// Common commands
if (player.hasPermission(PartiesPermission.USER_LEAVE))
ret.add(CommonCommands.LEAVE);
if (player.hasPermission(PartiesPermission.USER_INVITE) && plugin.getRankManager().checkPlayerRank(this, RankPermission.INVITE))
ret.add(CommonCommands.INVITE);
if (player.hasPermission(PartiesPermission.USER_INFO))
ret.add(CommonCommands.INFO);
// Other commands
if (ConfigParties.GENERAL_CHAT_TOGGLECOMMAND && player.hasPermission(PartiesPermission.USER_CHAT))
ret.add(CommonCommands.CHAT);
if (ConfigParties.ADDITIONAL_FRIENDLYFIRE_ENABLE && ConfigParties.ADDITIONAL_FRIENDLYFIRE_TYPE.equalsIgnoreCase("command") && player.hasPermission(PartiesPermission.USER_PROTECTION) && plugin.getRankManager().checkPlayerRank(this, RankPermission.EDIT_PROTECTION))
ret.add(CommonCommands.PROTECTION);
if (ConfigParties.ADDITIONAL_HOME_ENABLE) {
if (player.hasPermission(PartiesPermission.ADMIN_HOME_OTHERS) || (player.hasPermission(PartiesPermission.USER_HOME) && plugin.getRankManager().checkPlayerRank(this, RankPermission.HOME)))
ret.add(CommonCommands.HOME);
if (player.hasPermission(PartiesPermission.USER_SETHOME) && plugin.getRankManager().checkPlayerRank(this, RankPermission.EDIT_HOME))
ret.add(CommonCommands.SETHOME);
}
// Admin commands
if (ConfigParties.ADDITIONAL_ASK_ENABLE || (ConfigParties.ADDITIONAL_TELEPORT_ENABLE && ConfigParties.ADDITIONAL_TELEPORT_ACCEPT_REQUEST_ENABLE)) {
if (player.hasPermission(PartiesPermission.USER_ACCEPT) && (plugin.getRankManager().checkPlayerRank(this, RankPermission.ASK_ACCEPT) || plugin.getRankManager().checkPlayerRank(this, RankPermission.TELEPORT_ACCEPT)))
ret.add(CommonCommands.ACCEPT);
if (player.hasPermission(PartiesPermission.USER_DENY) && (plugin.getRankManager().checkPlayerRank(this, RankPermission.ASK_DENY) || plugin.getRankManager().checkPlayerRank(this, RankPermission.TELEPORT_DENY)))
ret.add(CommonCommands.DENY);
}
if (ConfigParties.ADDITIONAL_DESC_ENABLE && player.hasPermission(PartiesPermission.USER_DESC) && plugin.getRankManager().checkPlayerRank(this, RankPermission.EDIT_DESC))
ret.add(CommonCommands.DESC);
if (ConfigParties.ADDITIONAL_MOTD_ENABLE && player.hasPermission(PartiesPermission.USER_MOTD) && plugin.getRankManager().checkPlayerRank(this, RankPermission.EDIT_MOTD))
ret.add(CommonCommands.MOTD);
if (ConfigParties.ADDITIONAL_NICKNAME_ENABLE && player.hasPermission(PartiesPermission.USER_NICKNAME) && (plugin.getRankManager().checkPlayerRank(this, RankPermission.EDIT_NICKNAME_OWN) || plugin.getRankManager().checkPlayerRank(this, RankPermission.EDIT_NICKNAME_OTHERS)))
ret.add(CommonCommands.NICKNAME);
if (ConfigMain.ADDITIONAL_FOLLOW_ENABLE && ConfigMain.ADDITIONAL_FOLLOW_TOGGLECMD && player.hasPermission(PartiesPermission.USER_FOLLOW) && plugin.getRankManager().checkPlayerRank(this, RankPermission.EDIT_FOLLOW))
ret.add(CommonCommands.FOLLOW);
if (ConfigParties.ADDITIONAL_COLOR_ENABLE && ConfigParties.ADDITIONAL_COLOR_COLORCMD && player.hasPermission(PartiesPermission.USER_COLOR) && plugin.getRankManager().checkPlayerRank(this, RankPermission.EDIT_COLOR))
ret.add(CommonCommands.COLOR);
if (ConfigParties.ADDITIONAL_JOIN_ENABLE && ConfigParties.ADDITIONAL_JOIN_PASSWORD_ENABLE && player.hasPermission(PartiesPermission.USER_PASSWORD) && plugin.getRankManager().checkPlayerRank(this, RankPermission.EDIT_PASSWORD))
ret.add(CommonCommands.PASSWORD);
if (player.hasPermission(PartiesPermission.USER_RANK) && plugin.getRankManager().checkPlayerRank(this, RankPermission.ADMIN_RANK))
ret.add(CommonCommands.RANK);
if (player.hasPermission(PartiesPermission.ADMIN_RENAME_OTHERS) || (player.hasPermission(PartiesPermission.USER_RENAME) && plugin.getRankManager().checkPlayerRank(this, RankPermission.ADMIN_RENAME)))
ret.add(CommonCommands.RENAME);
if (ConfigParties.ADDITIONAL_TAG_ENABLE && (player.hasPermission(PartiesPermission.USER_TAG) && plugin.getRankManager().checkPlayerRank(this, RankPermission.EDIT_TAG)) || player.hasPermission(PartiesPermission.ADMIN_TAG_OTHERS))
ret.add(CommonCommands.TAG);
if (player.hasPermission(PartiesPermission.USER_KICK) && plugin.getRankManager().checkPlayerRank(this, RankPermission.KICK))
ret.add(CommonCommands.KICK);
if (ConfigParties.ADDITIONAL_TELEPORT_ENABLE && player.hasPermission(PartiesPermission.USER_TELEPORT) && plugin.getRankManager().checkPlayerRank(this, RankPermission.ADMIN_TELEPORT))
ret.add(CommonCommands.TELEPORT);
if (ConfigParties.ADDITIONAL_JOIN_OPENCLOSE_ENABLE) {
if (player.hasPermission(PartiesPermission.USER_CLOSE) && plugin.getRankManager().checkPlayerRank(this, RankPermission.EDIT_CLOSE)) {
PartyImpl party = plugin.getPartyManager().getPartyOfPlayer(this);
if (!ConfigParties.ADDITIONAL_JOIN_OPENCLOSE_HIDE_OPPOSITE || (party != null && party.isOpen()))
ret.add(CommonCommands.CLOSE);
}
if (player.hasPermission(PartiesPermission.USER_OPEN) && plugin.getRankManager().checkPlayerRank(this, RankPermission.EDIT_OPEN)) {
PartyImpl party = plugin.getPartyManager().getPartyOfPlayer(this);
if (!ConfigParties.ADDITIONAL_JOIN_OPENCLOSE_HIDE_OPPOSITE || (party != null && !party.isOpen()))
ret.add(CommonCommands.OPEN);
}
}
} else {
// Out of party
if (player.hasPermission(PartiesPermission.USER_CREATE))
ret.add(CommonCommands.CREATE);
if (ConfigParties.GENERAL_INVITE_AUTO_CREATE_PARTY_UPON_INVITE && player.hasPermission(PartiesPermission.USER_INVITE) && player.hasPermission(PartiesPermission.USER_CREATE))
ret.add(CommonCommands.INVITE);
if (player.hasPermission(PartiesPermission.USER_ACCEPT))
ret.add(CommonCommands.ACCEPT);
if (player.hasPermission(PartiesPermission.USER_DENY))
ret.add(CommonCommands.DENY);
if (ConfigParties.ADDITIONAL_ASK_ENABLE && player.hasPermission(PartiesPermission.USER_ASK))
ret.add(CommonCommands.ASK);
if (ConfigParties.ADDITIONAL_JOIN_ENABLE && player.hasPermission(PartiesPermission.USER_JOIN))
ret.add(CommonCommands.JOIN);
if (ConfigParties.ADDITIONAL_TAG_ENABLE && player.hasPermission(PartiesPermission.ADMIN_TAG_OTHERS))
ret.add(CommonCommands.TAG);
if (ConfigParties.ADDITIONAL_NICKNAME_ENABLE && player.hasPermission(PartiesPermission.ADMIN_NICKNAME_OTHERS))
ret.add(CommonCommands.NICKNAME);
if (player.hasPermission(PartiesPermission.USER_IGNORE))
ret.add(CommonCommands.IGNORE);
if (player.hasPermission(PartiesPermission.USER_INFO_OTHERS))
ret.add(CommonCommands.INFO);
if (player.hasPermission(PartiesPermission.USER_MUTE))
ret.add(CommonCommands.MUTE);
if (player.hasPermission(PartiesPermission.ADMIN_KICK_OTHERS))
ret.add(CommonCommands.KICK);
if (player.hasPermission(PartiesPermission.ADMIN_RENAME_OTHERS))
ret.add(CommonCommands.RENAME);
if (player.hasPermission(PartiesPermission.ADMIN_COOLDOWN_CLOSE_BYPASS))
ret.add(CommonCommands.CLOSE);
if (player.hasPermission(PartiesPermission.ADMIN_COOLDOWN_OPEN_BYPASS))
ret.add(CommonCommands.OPEN);
}
if (ConfigParties.ADDITIONAL_FIXED_ENABLE && player.hasPermission(PartiesPermission.ADMIN_CREATE_FIXED))
ret.add(CommonCommands.CREATEFIXED);
if (ConfigParties.ADDITIONAL_LIST_ENABLE && player.hasPermission(PartiesPermission.USER_LIST))
ret.add(CommonCommands.LIST);
if (player.hasPermission(PartiesPermission.ADMIN_SPY))
ret.add(CommonCommands.SPY);
if (player.hasPermission(PartiesPermission.ADMIN_DELETE))
ret.add(CommonCommands.DELETE);
if (player.hasPermission(PartiesPermission.ADMIN_RELOAD))
ret.add(CommonCommands.RELOAD);
if (player.hasPermission(PartiesPermission.ADMIN_VERSION))
ret.add(CommonCommands.VERSION);
if (ConfigMain.PARTIES_DEBUG_COMMAND && player.hasPermission(PartiesPermission.ADMIN_DEBUG))
ret.add(CommonCommands.DEBUG);
return ret;
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class PartiesSQLDispatcher method getPartyByName.
@Override
public PartyImpl getPartyByName(String name) {
PartyImpl ret = this.connectionFactory.getJdbi().withHandle(handle -> handle.attach(partiesDao).getByName(name)).orElse(null);
if (ret != null) {
ret.setAccessible(true);
ret.setMembers(this.connectionFactory.getJdbi().withHandle(handle -> handle.attach(playersDao).getInParty(ret.getId().toString())));
ret.setAccessible(false);
}
return ret;
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class PartiesSQLDispatcher method getListFixed.
@Override
public Set<PartyImpl> getListFixed() {
Set<PartyImpl> ret = this.connectionFactory.getJdbi().withHandle(handle -> handle.attach(partiesDao).getListFixed());
// Load members
for (PartyImpl party : ret) {
party.setAccessible(true);
party.setMembers(this.connectionFactory.getJdbi().withHandle(handle -> handle.attach(playersDao).getInParty(party.getId().toString())));
party.setAccessible(false);
}
return ret;
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class ChatListener method onPlayerCommandPreprocess.
protected void onPlayerCommandPreprocess(User sender, String message) {
if (ConfigMain.ADDITIONAL_AUTOCMD_ENABLE) {
plugin.getScheduler().runAsync(() -> {
boolean cancel = true;
try {
Pattern pattern = Pattern.compile(ConfigMain.ADDITIONAL_AUTOCMD_REGEXWHITELIST, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(message);
if (matcher.find()) {
cancel = false;
}
} catch (Exception ex) {
plugin.getLoggerManager().logError(PartiesConstants.DEBUG_AUTOCMD_REGEXERROR, ex);
}
if (!cancel) {
PartyPlayerImpl pp = plugin.getPlayerManager().getPlayer(sender.getUUID());
PartyImpl party = plugin.getPartyManager().getParty(pp.getPartyId());
if (party != null && plugin.getRankManager().checkPlayerRank(pp, RankPermission.AUTOCOMMAND)) {
for (PartyPlayer pl : party.getOnlineMembers(true)) {
if (!pl.getPlayerUUID().equals(sender.getUUID())) {
// Make it sync
plugin.getScheduler().getSyncExecutor().execute(() -> {
User user = plugin.getPlayer(pl.getPlayerUUID());
if (user != null) {
plugin.getBootstrap().executeCommandByUser(message.substring(1), user);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_AUTOCMD_PERFORM, pl.getPlayerUUID(), message), true);
}
});
}
}
}
}
});
}
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class JoinLeaveListener method onPlayerJoin.
/**
* Used by Bukkit, Bungeecord
*/
protected void onPlayerJoin(User player) {
// Make it async
plugin.getScheduler().runAsync(() -> {
PartyPlayerImpl partyPlayer = plugin.getPlayerManager().loadPlayer(player.getUUID());
// Party checking
PartyImpl party = plugin.getPartyManager().loadParty(partyPlayer.getPartyId(), true);
if (party != null) {
// Party found
party.addOnlineMember(partyPlayer);
party.memberJoinTimeout(partyPlayer);
if (ConfigParties.ADDITIONAL_MOTD_ENABLE && party.getMotd() != null && !plugin.isBungeeCordEnabled()) {
plugin.getScheduler().scheduleAsyncLater(new MotdTask(plugin, player.getUUID(), partyPlayer.getCreateID()), ConfigParties.ADDITIONAL_MOTD_DELAY, TimeUnit.MILLISECONDS);
}
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_PLAYER_JOIN, player.getName(), party.getName() + "|" + party.getId()), true);
} else if (ConfigParties.ADDITIONAL_FIXED_DEFAULT_ENABLE && !player.hasPermission(PartiesPermission.ADMIN_JOIN_DEFAULT_BYPASS)) {
// Party not found - checking for default one
party = plugin.getPartyManager().loadParty(ConfigParties.ADDITIONAL_FIXED_DEFAULT_PARTY);
if (party != null) {
party.addMember(partyPlayer, JoinCause.OTHERS, null);
if (ConfigParties.ADDITIONAL_MOTD_ENABLE && party.getMotd() != null) {
plugin.getScheduler().scheduleAsyncLater(new MotdTask(plugin, player.getUUID(), partyPlayer.getCreateID()), ConfigParties.ADDITIONAL_MOTD_DELAY, TimeUnit.MILLISECONDS);
}
partyPlayer.sendMessage(Messages.OTHER_FIXED_DEFAULTJOIN, party);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_PLAYER_JOIN_DEFAULTJOIN, player.getName(), party.getName() + "|" + party.getId()), true);
} else {
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_PLAYER_JOIN_DEFAULTFAIL, ConfigParties.ADDITIONAL_FIXED_DEFAULT_PARTY), true);
}
}
if (ConfigParties.GENERAL_JOIN_LEAVE_MESSAGES && party != null) {
party.broadcastMessage(Messages.OTHER_JOINLEAVE_SERVERJOIN, partyPlayer);
}
plugin.getLoginAlertsManager().sendAlerts(player);
onJoinComplete(partyPlayer);
});
}
Aggregations