use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class CommandAsk method onCommand.
@Override
public void onCommand(@NotNull CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
// Command handling
String partyName = commandData.getArgs()[1];
PartyImpl party = getPlugin().getPartyManager().getParty(partyName);
if (party == null) {
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_PARTYNOTFOUND.replace("%party%", partyName));
return;
}
if (party.isFull()) {
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_PARTYFULL);
return;
}
boolean mustStartCooldown = false;
if (ConfigParties.ADDITIONAL_ASK_COOLDOWN_ENABLE && !commandData.havePermission(PartiesPermission.ADMIN_COOLDOWN_ASK_BYPASS)) {
// Check invite cooldown
mustStartCooldown = true;
RequestCooldown askCooldown = getPlugin().getCooldownManager().canMultiAction(CooldownManager.MultiAction.ASK, partyPlayer.getPlayerUUID(), party.getId());
if (askCooldown != null) {
sendMessage(sender, partyPlayer, (askCooldown.isGlobal() ? Messages.ADDCMD_ASK_COOLDOWN_GLOBAL : Messages.ADDCMD_ASK_COOLDOWN_INDIVIDUAL).replace("%seconds%", String.valueOf(askCooldown.getWaitTime())));
}
}
if (getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.ASK, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
return;
// Command starts
partyPlayer.askToJoin(party);
if (mustStartCooldown) {
getPlugin().getCooldownManager().startMultiAction(CooldownManager.MultiAction.ASK, partyPlayer.getPlayerUUID(), null, ConfigParties.ADDITIONAL_ASK_COOLDOWN_GLOBAL);
getPlugin().getCooldownManager().startMultiAction(CooldownManager.MultiAction.ASK, partyPlayer.getPlayerUUID(), party.getId(), ConfigParties.ADDITIONAL_ASK_COOLDOWN_INDIVIDUAL);
}
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_ASK, partyPlayer.getName(), party.getName() != null ? party.getName() : "_"), true);
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class CommandClose method onCommand.
@Override
public void onCommand(@NotNull CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
PartyImpl party;
// Command handling
if (commandData.getArgs().length == 1 && sender.isPlayer()) {
party = getPlugin().getPartyManager().getPartyOfPlayer(partyPlayer);
} else if (commandData.getArgs().length == 2 && commandData.havePermission(PartiesPermission.ADMIN_CLOSE_OTHERS)) {
party = getPlugin().getPartyManager().getParty(commandData.getArgs()[1]);
} else {
sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", getSyntaxForUser(sender)));
return;
}
if (party == null) {
if (commandData.getArgs().length > 1)
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_PARTYNOTFOUND.replace("%party%", commandData.getArgs()[1]));
else
sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_NOTINPARTY);
return;
}
if (!party.isOpen()) {
sendMessage(sender, partyPlayer, Messages.ADDCMD_JOIN_OPENCLOSE_ALREADY_CLOSED);
return;
}
boolean mustStartCooldown = false;
if (ConfigParties.ADDITIONAL_JOIN_OPENCLOSE_COOLDOWN_CLOSE > 0 && !commandData.havePermission(PartiesPermission.ADMIN_COOLDOWN_CLOSE_BYPASS)) {
mustStartCooldown = true;
long remainingCooldown = getPlugin().getCooldownManager().canAction(CooldownManager.Action.CLOSE, sender.getUUID(), ConfigParties.ADDITIONAL_JOIN_OPENCLOSE_COOLDOWN_CLOSE);
if (remainingCooldown > 0) {
sendMessage(sender, partyPlayer, Messages.ADDCMD_JOIN_OPENCLOSE_COOLDOWN.replace("%seconds%", String.valueOf(remainingCooldown)));
return;
}
}
if (getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.CLOSE, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
return;
if (mustStartCooldown)
getPlugin().getCooldownManager().startAction(CooldownManager.Action.CLOSE, sender.getUUID(), ConfigParties.ADDITIONAL_JOIN_OPENCLOSE_COOLDOWN_CLOSE);
// Command starts
party.setOpen(false);
sendMessage(sender, partyPlayer, Messages.ADDCMD_JOIN_OPENCLOSE_CLOSED);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_OPENCLOSE, partyPlayer.getName(), party.getName() != null ? party.getName() : "_", false), true);
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class BungeeCommandTeleport method teleportSinglePlayer.
public static void teleportSinglePlayer(PartiesPlugin plugin, PartyPlayerImpl player, PartyPlayerImpl targetPlayer, ServerInfo serverInfo) {
ProxiedPlayer bungeePlayer = ((BungeePartiesBootstrap) plugin.getBootstrap()).getProxy().getPlayer(player.getPlayerUUID());
if (bungeePlayer != null) {
boolean serverChange = false;
PartyImpl party = plugin.getPartyManager().getParty(player.getPartyId());
IPlayerPreTeleportEvent partiesPreTeleportEvent = plugin.getEventManager().preparePlayerPreTeleportEvent(player, party, serverInfo);
plugin.getEventManager().callEvent(partiesPreTeleportEvent);
if (!partiesPreTeleportEvent.isCancelled()) {
if (!bungeePlayer.getServer().getInfo().equals(serverInfo)) {
serverChange = true;
bungeePlayer.connect(serverInfo);
}
User bungeeUser = plugin.getPlayer(player.getPlayerUUID());
if (bungeeUser != null) {
if (serverChange) {
plugin.getScheduler().scheduleAsyncLater(() -> ((BungeePartiesMessageDispatcher) plugin.getMessenger().getMessageDispatcher()).sendTeleport(bungeeUser, targetPlayer, serverInfo), BungeeConfigParties.ADDITIONAL_TELEPORT_EXACT_LOCATION_DELAY, TimeUnit.MILLISECONDS);
} else {
((BungeePartiesMessageDispatcher) plugin.getMessenger().getMessageDispatcher()).sendTeleport(bungeeUser, targetPlayer, serverInfo);
}
player.sendMessage(Messages.ADDCMD_TELEPORT_PLAYER_TELEPORTED, targetPlayer);
IPlayerPostTeleportEvent partiesPostTeleportEvent = plugin.getEventManager().preparePlayerPostTeleportEvent(player, party, serverInfo);
plugin.getEventManager().callEvent(partiesPostTeleportEvent);
}
} else
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_API_TELEPORTEVENT_DENY, player.getName(), party.getName() != null ? party.getName() : "_"), true);
}
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class ApiHandler method createParty.
@Override
public boolean createParty(@Nullable String name, @Nullable PartyPlayer leader) {
if (name == null || !plugin.getDatabaseManager().existsParty(name) || leader == null || !leader.isInParty()) {
PartyImpl partyImpl = plugin.getPartyManager().initializeParty(UUID.randomUUID());
partyImpl.create(name, leader != null ? (PartyPlayerImpl) leader : null, null);
return true;
}
return false;
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class BukkitPartiesBungeecordListener method handleUnloadParty.
public void handleUnloadParty(PartiesPacket packet) {
PartyImpl party = ((PartiesPlugin) plugin).getPartyManager().getCacheParties().get(packet.getParty());
if (party != null) {
((PartiesPlugin) plugin).getPartyManager().unloadParty(party);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_MESSAGING_LISTEN_UNLOAD_PARTY, packet.getParty().toString()), true);
}
}
Aggregations