use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class PartiesSQLDispatcher method getParty.
@Override
public PartyImpl getParty(UUID id) {
PartyImpl ret = this.connectionFactory.getJdbi().withHandle(handle -> handle.attach(partiesDao).get(id.toString())).orElse(null);
if (ret != null) {
ret.setAccessible(true);
ret.setMembers(this.connectionFactory.getJdbi().withHandle(handle -> handle.attach(playersDao).getInParty(id.toString())));
ret.setAccessible(false);
}
return ret;
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class BukkitCommandClaim method onCommand.
@Override
public void onCommand(CommandData commandData) {
User sender = commandData.getSender();
PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
PartyImpl party = ((PartiesCommandData) commandData).getParty();
// Command handling
Selection selection = Selection.FAILED_GENERAL;
if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_TRUST))
selection = Selection.TRUST;
else if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_CONTAINER))
selection = Selection.CONTAINER;
else if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_ACCESS))
selection = Selection.ACCESS;
else if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_MANAGER) && ClaimHandler.canChangeManager())
selection = Selection.MANAGER;
else if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_REMOVE))
selection = Selection.REMOVE;
if (!selection.equals(Selection.FAILED_GENERAL)) {
Player bukkitSender = Bukkit.getPlayer(sender.getUUID());
if (bukkitSender == null)
return;
ClaimHandler.Result res = ClaimHandler.isManager(bukkitSender);
switch(res) {
case NOEXIST:
selection = Selection.FAILED_NOEXIST;
break;
case NOMANAGER:
selection = Selection.FAILED_NOMANAGER;
break;
default:
// Success, selection it's okay
break;
}
}
if (getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.CLAIM, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
return;
// Command starts
switch(selection) {
case FAILED_NOEXIST:
// Return: No exist claim
sendMessage(sender, partyPlayer, BukkitMessages.ADDCMD_CLAIM_CLAIMNOEXISTS);
break;
case FAILED_NOMANAGER:
// Return: No manager
sendMessage(sender, partyPlayer, BukkitMessages.ADDCMD_CLAIM_NOMANAGER);
break;
case FAILED_GENERAL:
// Return: Wrong command
sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
sendMessage(sender, partyPlayer, BukkitMessages.ADDCMD_CLAIM_ALLOWED_PERMISSIONS);
break;
default:
ClaimHandler.addPartyPermission(Bukkit.getPlayer(commandData.getSender().getUUID()), party, selection.getPermission());
sendMessage(sender, partyPlayer, selection.getPermission().isRemove() ? BukkitMessages.ADDCMD_CLAIM_REMOVED : BukkitMessages.ADDCMD_CLAIM_CLAIMED);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_CLAIM, partyPlayer.getName(), selection.name()), true);
break;
}
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class BukkitCommandHome method teleportToPartyHome.
public static void teleportToPartyHome(PartiesPlugin plugin, PartyPlayerImpl player, BukkitUser bukkitUser, PartyHome home, Location location, String message) {
PartyImpl party = plugin.getPartyManager().getParty(player.getPartyId());
IPlayerPreHomeEvent partiesPreHomeEvent = plugin.getEventManager().preparePlayerPreHomeEvent(player, party, home);
plugin.getEventManager().callEvent(partiesPreHomeEvent);
if (!partiesPreHomeEvent.isCancelled()) {
plugin.getScheduler().getSyncExecutor().execute(() -> {
EssentialsHandler.updateLastTeleportLocation(player.getPlayerUUID());
bukkitUser.teleportAsync(location).thenAccept(result -> {
if (result) {
player.sendMessage(message);
IPlayerPostHomeEvent partiesPostHomeEvent = plugin.getEventManager().preparePlayerPostHomeEvent(player, party, home);
plugin.getEventManager().callEvent(partiesPostHomeEvent);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_TASK_TELEPORT_DONE, player.getPlayerUUID()), true);
} else {
plugin.getLoggerManager().logError(String.format(PartiesConstants.DEBUG_TELEPORT_ASYNC, player.getPlayerUUID()));
}
});
});
} else
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_API_HOMEEVENT_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 EssentialsChatHandler method onChatPlayer.
@EventHandler
public void onChatPlayer(AsyncPlayerChatEvent event) {
String old = event.getFormat();
if (CommonUtils.toLowerCase(old).contains("{parties_")) {
// Bypass useless checks if this isn't an Parties placeholder
boolean somethingChanged = false;
PartyPlayerImpl partyPlayer = plugin.getPlayerManager().getPlayer(event.getPlayer().getUniqueId());
PartyImpl party = plugin.getPartyManager().getParty(partyPlayer.getPartyId());
Matcher mat = PATTERN.matcher(old);
while (mat.find()) {
String base = mat.group(0);
String identifier = mat.group(1);
if (identifier != null) {
identifier = CommonUtils.toLowerCase(identifier);
PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder(identifier);
if (placeholder != null) {
String parsed = placeholder.formatPlaceholder(partyPlayer, party, identifier);
if (parsed != null) {
old = old.replace(base, Color.translateAlternateColorCodes(parsed));
somethingChanged = true;
}
}
}
}
if (somethingChanged)
event.setFormat(old);
}
}
use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.
the class PAPIHook method onRequest.
@Override
public String onRequest(OfflinePlayer offlinePlayer, @NotNull String identifier) {
if (offlinePlayer != null) {
PartyPlayerImpl partyPlayer = plugin.getPlayerManager().getPlayer(offlinePlayer.getUniqueId());
PartyImpl party = plugin.getPartyManager().getParty(partyPlayer.getPartyId());
PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder(identifier);
return placeholder != null ? placeholder.formatPlaceholder(partyPlayer, party, identifier) : null;
}
return null;
}
Aggregations