Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgH93 committed Jun 7, 2022
2 parents bda2fff + 98dfefb commit 567c90a
Show file tree
Hide file tree
Showing 38 changed files with 573 additions and 305 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
package at.pcgamingfreaks.MarriageMaster.Bukkit.API.Events;

import at.pcgamingfreaks.MarriageMaster.Bukkit.API.Marriage;
import at.pcgamingfreaks.MarriageMaster.Bukkit.API.MarriagePlayer;

import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* Event is fired after two players got married.
Expand Down Expand Up @@ -48,6 +50,36 @@ public MarriedEvent(@NotNull Marriage marriageData)
return marriageData;
}

/**
* Gets the first player of the marriage.
*
* @return The first player of the marriage.
*/
public @NotNull MarriagePlayer getPlayer1()
{
return marriageData.getPartner1();
}

/**
* Gets the second player of the marriage.
*
* @return The second player of the marriage.
*/
public @NotNull MarriagePlayer getPlayer2()
{
return marriageData.getPartner2();
}

/**
* Gets the priest involved in marrying the couple.
*
* @return The priest involved in marrying the couple.
*/
public @Nullable MarriagePlayer getPriest()
{
return marriageData.getPriest();
}

// Bukkit handler stuff
private static final HandlerList handlers = new HandlerList();

Expand Down
2 changes: 1 addition & 1 deletion API/MarriageMaster-API/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
2 changes: 1 addition & 1 deletion MarriageMaster/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<updateChannel>Release</updateChannel>

<mockito.version>4.2.0</mockito.version>
<mavenShade.version>3.3.0-SNAPSHOT</mavenShade.version>
<mavenShade.version>3.3.0</mavenShade.version>
</properties>

<repositories>
Expand Down
2 changes: 1 addition & 1 deletion MarriageMaster/resources/lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Language:
YouMadeAPriest: "{DisplayName}&r&a now is a priest."
FiredYou: "{DisplayName}&r&c has fired you as a priest."
YouFiredAPriest: "{DisplayName}&r&a is no longer a priest."
PerPermission: "{DisplayName}&r&c is set as a priest per permission. You can't fire him per command!"
PerPermission: "{DisplayName}&r&c is set as a priest per permission and can't be fired by command."
Surname:
SetSuccessful: "&aSurname changed."
SetFailed: "&cFailed changing surname."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void init()
marryCommand.setExecutor(this);
marryCommand.setTabCompleter(this);

helpFormat = plugin.getLanguage().getMessage("Commands.HelpFormat").replaceAll("\\{MainCommand}", "%1\\$s").replaceAll("\\{SubCommand}", "%2\\$s").replaceAll("\\{Parameters}", "%3\\$s").replaceAll("\\{Description}", "%4\\$s");
helpFormat = plugin.getLanguage().getMessage("Commands.HelpFormat").placeholder("MainCommand").placeholder("SubCommand").placeholder("Parameters").placeholder("Description");

// Setting the help format for the marry commands as well as the no permissions and not from console message
try
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 GeorgH93
* Copyright (C) 2022 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -22,6 +22,7 @@
import at.pcgamingfreaks.MarriageMaster.Bukkit.API.MarriagePlayer;
import at.pcgamingfreaks.MarriageMaster.Bukkit.API.MarryCommand;
import at.pcgamingfreaks.MarriageMaster.Bukkit.MarriageMaster;
import at.pcgamingfreaks.Message.MessageColor;

import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -49,7 +50,7 @@ private static List<Message> getMessages(final @NotNull MarriageMaster plugin, f
List<Message> messages = new ArrayList<>(stringMessages.size());
for(String message : stringMessages)
{
messages.add(new Message(plugin.getLanguage().translateColorCodes(message)));
messages.add(new Message(MessageColor.translateAlternateColorAndFormatCodes(message)));
}
return messages;
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 GeorgH93
* Copyright (C) 2022 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -24,6 +24,7 @@
import at.pcgamingfreaks.MarriageMaster.Bukkit.MarriageMaster;
import at.pcgamingfreaks.MarriageMaster.Bukkit.Range;
import at.pcgamingfreaks.MarriageMaster.Permissions;
import at.pcgamingfreaks.Message.Placeholder.Processors.FloatPlaceholderProcessor;

import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
Expand All @@ -50,8 +51,9 @@ public HugCommand(MarriageMaster plugin)
rangeSquared = plugin.getConfiguration().getRangeSquared(Range.Hug);
messageHugged = plugin.getLanguage().getMessage("Ingame.Hug.Hugged");
messageGotHugged = plugin.getLanguage().getMessage("Ingame.Hug.GotHugged");
messageTooFarAway = plugin.getLanguage().getMessage("Ingame.Hug.TooFarAway").replaceAll("\\{Distance}", "%.1f");
messageWait = plugin.getLanguage().getMessage("Ingame.Hug.Wait").replaceAll("\\{Time}", "%1\\$d").replaceAll("\\{TimeLeft}", "%2\\$.1f");
FloatPlaceholderProcessor singleDecimalPointProcessor = new FloatPlaceholderProcessor(1);
messageTooFarAway = plugin.getLanguage().getMessage("Ingame.Hug.TooFarAway").placeholder("Distance", singleDecimalPointProcessor);
messageWait = plugin.getLanguage().getMessage("Ingame.Hug.Wait").placeholder("Time").placeholder("TimeLeft", singleDecimalPointProcessor);
waitTime = plugin.getConfiguration().getHugWaitTime();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 GeorgH93
* Copyright (C) 2022 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -27,6 +27,7 @@
import at.pcgamingfreaks.MarriageMaster.Bukkit.MarriageMaster;
import at.pcgamingfreaks.MarriageMaster.Bukkit.Range;
import at.pcgamingfreaks.MarriageMaster.Permissions;
import at.pcgamingfreaks.Message.Placeholder.Processors.FloatPlaceholderProcessor;

import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
Expand All @@ -38,13 +39,15 @@
import org.bukkit.inventory.EquipmentSlot;
import org.jetbrains.annotations.NotNull;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

public class KissCommand extends MarryCommand implements Listener
{
@Getter private static KissCommand instance;
@Getter @Setter(AccessLevel.PRIVATE) private static KissCommand instance;

private final Message messageKissed, messageGotKissed, messageTooFarAway, messageWait;
private final double interactRange, range, rangeSquared, hearthVisibleRange;
Expand All @@ -66,21 +69,22 @@ public KissCommand(MarriageMaster plugin)

messageKissed = plugin.getLanguage().getMessage("Ingame.Kiss.Kissed");
messageGotKissed = plugin.getLanguage().getMessage("Ingame.Kiss.GotKissed");
messageTooFarAway = plugin.getLanguage().getMessage("Ingame.Kiss.TooFarAway").replaceAll("\\{Distance}", "%.1f");
messageWait = plugin.getLanguage().getMessage("Ingame.Kiss.Wait").replaceAll("\\{Time}", "%1\\$d").replaceAll("\\{TimeLeft}", "%2\\$.1f");
FloatPlaceholderProcessor singleDecimalPointProcessor = new FloatPlaceholderProcessor(1);
messageTooFarAway = plugin.getLanguage().getMessage("Ingame.Kiss.TooFarAway").placeholder("Distance", singleDecimalPointProcessor);
messageWait = plugin.getLanguage().getMessage("Ingame.Kiss.Wait").placeholder("Time").placeholder("TimeLeft", singleDecimalPointProcessor);

if(plugin.getConfiguration().isKissInteractEnabled())
{
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
instance = this;
setInstance(this);
}

@Override
public void close()
{
HandlerList.unregisterAll(this);
instance = null;
setInstance(null);
particleSpawner = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@
package at.pcgamingfreaks.MarriageMaster.Bukkit.Commands;

import at.pcgamingfreaks.Bukkit.Message.Message;
import at.pcgamingfreaks.Bukkit.Message.Sender.SendMethod;
import at.pcgamingfreaks.MarriageMaster.Bukkit.API.Marriage;
import at.pcgamingfreaks.MarriageMaster.Bukkit.API.MarriagePlayer;
import at.pcgamingfreaks.MarriageMaster.Bukkit.API.MarryCommand;
import at.pcgamingfreaks.MarriageMaster.Bukkit.Database.MarriagePlayerData;
import at.pcgamingfreaks.MarriageMaster.Bukkit.MarriageMaster;
import at.pcgamingfreaks.MarriageMaster.Permissions;
import at.pcgamingfreaks.MarriageMaster.Placeholder.Placeholders;
import at.pcgamingfreaks.Message.MessageComponent;
import at.pcgamingfreaks.Message.Placeholder.Processors.PassthroughMessageComponentPlaceholderProcessor;
import at.pcgamingfreaks.StringUtils;

import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
Expand All @@ -37,19 +41,22 @@ public class ListCommand extends MarryCommand
{
private final int entriesPerPage;
private final Message messageHeadlineMain, messageFooter, messageListFormat, messageNoMarriedPlayers;
private final boolean useFooter;

public ListCommand(final @NotNull MarriageMaster plugin)
{
super(plugin, "list", plugin.getLanguage().getTranslated("Commands.Description.List"), Permissions.LIST, plugin.getLanguage().getCommandAliases("List"));

useFooter = plugin.getConfiguration().useListFooter();
entriesPerPage = plugin.getConfiguration().getListEntriesPerPage();

messageListFormat = plugin.getLanguage().getMessage("Ingame.List.Format").replaceAll("\\{Player1Name}", "%1\\$s").replaceAll("\\{Player2Name}", "%2\\$s").replaceAll("\\{Player1DisplayName}", "%3\\$s").replaceAll("\\{Player2DisplayName}", "%4\\$s").replaceAll("\\{Surname}", "%5\\$s").replaceAll("\\{MagicHeart}", "%6\\$s");
messageHeadlineMain = plugin.getLanguage().getMessage("Ingame.List.Headline").replaceAll("\\{CurrentPage}", "%1\\$d").replaceAll("\\{MaxPage}", "%2\\$d").replaceAll("\\{MainCommand}", "%3\\$s").replaceAll("\\{SubCommand}", "%4\\$s").replaceAll("\\{PrevPage}", "%5\\$d").replaceAll("\\{NextPage}", "%6\\$d");
messageFooter = plugin.getLanguage().getMessage("Ingame.List.Footer").replaceAll("\\{CurrentPage}", "%1\\$d").replaceAll("\\{MaxPage}", "%2\\$d").replaceAll("\\{MainCommand}", "%3\\$s").replaceAll("\\{SubCommand}", "%4\\$s").replaceAll("\\{PrevPage}", "%5\\$d").replaceAll("\\{NextPage}", "%6\\$d");
messageListFormat = plugin.getLanguage().getMessage("Ingame.List.Format").placeholder("Player1Name").placeholder("Player2Name").placeholder("Player1DisplayName", PassthroughMessageComponentPlaceholderProcessor.INSTANCE).placeholder("Player2DisplayName", PassthroughMessageComponentPlaceholderProcessor.INSTANCE).placeholder("Surname").placeholder("MagicHeart");
messageHeadlineMain = plugin.getLanguage().getMessage("Ingame.List.Headline").placeholders(Placeholders.PAGE_OPTIONS);
messageFooter = plugin.getLanguage().getMessage("Ingame.List.Footer").placeholders(Placeholders.PAGE_OPTIONS);
messageNoMarriedPlayers = plugin.getLanguage().getMessage("Ingame.List.NoMarriedPlayers");

if (!plugin.getConfiguration().useListFooter())
{
messageFooter.setSendMethod(SendMethod.DISABLED);
}
}

@Override
Expand Down Expand Up @@ -79,19 +86,15 @@ public void execute(final @NotNull CommandSender sender, final @NotNull String m
{
couplesIterator.next();
}
final boolean isPlayer = sender instanceof Player;
while(couplesIterator.hasNext() && --c >= 0)
{
Marriage couple = couplesIterator.next();
MarriagePlayer p1 = couple.getPartner1(), p2 = couple.getPartner2();
String p1DName = isPlayer ? p1.getDisplayNameCheckVanished((Player) sender) : p1.getDisplayName();
String p2DName = isPlayer ? p2.getDisplayNameCheckVanished((Player) sender) : p2.getDisplayName();
MessageComponent p1DName = ((MarriagePlayerData) p1).getDisplayNameMessageComponentCheckVanished(sender);
MessageComponent p2DName = ((MarriagePlayerData) p2).getDisplayNameMessageComponentCheckVanished(sender);
messageListFormat.send(sender, p1.getName(), p2.getName(), p1DName, p2DName, couple.getSurnameString(), couple.getMagicHeart());
}
if(useFooter)
{
messageFooter.send(sender, page + 1, availablePages, mainCommandAlias, alias, page, page + 2);
}
messageFooter.send(sender, page + 1, availablePages, mainCommandAlias, alias, page, page + 2);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import at.pcgamingfreaks.MarriageMaster.Bukkit.API.MarryCommand;
import at.pcgamingfreaks.MarriageMaster.Bukkit.MarriageMaster;
import at.pcgamingfreaks.MarriageMaster.Permissions;
import at.pcgamingfreaks.MarriageMaster.Placeholder.Placeholders;
import at.pcgamingfreaks.StringUtils;

import org.bukkit.command.CommandSender;
Expand All @@ -44,9 +45,9 @@ public ListPriestsCommand(MarriageMaster plugin)
useFooter = plugin.getConfiguration().useListFooter();
entriesPerPage = plugin.getConfiguration().getListEntriesPerPage();

messageListFormat = plugin.getLanguage().getMessage("Ingame.ListPriests.Format").replaceAll("\\{PriestName}", "%1\\$s").replaceAll("\\{PriestDisplayName}", "%2\\$s");
messageHeadlineMain = plugin.getLanguage().getMessage("Ingame.ListPriests.Headline").replaceAll("\\{CurrentPage}", "%1\\$d").replaceAll("\\{MaxPage}", "%2\\$d").replaceAll("\\{MainCommand}", "%3\\$s").replaceAll("\\{SubCommand}", "%4\\$s").replaceAll("\\{PrevPage}", "%5\\$d").replaceAll("\\{NextPage}", "%6\\$d");
messageFooter = plugin.getLanguage().getMessage("Ingame.ListPriests.Footer").replaceAll("\\{CurrentPage}", "%1\\$d").replaceAll("\\{MaxPage}", "%2\\$d").replaceAll("\\{MainCommand}", "%3\\$s").replaceAll("\\{SubCommand}", "%4\\$s").replaceAll("\\{PrevPage}", "%5\\$d").replaceAll("\\{NextPage}", "%6\\$d");
messageListFormat = plugin.getLanguage().getMessage("Ingame.ListPriests.Format").placeholders(Placeholders.mkPlayerNameRegex("(Priest)?"));
messageHeadlineMain = plugin.getLanguage().getMessage("Ingame.ListPriests.Headline").placeholders(Placeholders.PAGE_OPTIONS);
messageFooter = plugin.getLanguage().getMessage("Ingame.ListPriests.Footer").placeholders(Placeholders.PAGE_OPTIONS);
messageNoPriestsOnline = plugin.getLanguage().getMessage("Ingame.ListPriests.NoPriestsOnline");
}

Expand Down Expand Up @@ -87,8 +88,7 @@ public void execute(final @NotNull CommandSender sender, final @NotNull String m

for(int i = page * entriesPerPage, end = Math.min(i + entriesPerPage, priests.size()); i < end; i++)
{
MarriagePlayer priest = priests.get(i);
messageListFormat.send(sender, priest.getName(), priest.getDisplayName());
messageListFormat.send(sender, priests.get(i));
}

if(useFooter) messageFooter.send(sender, page + 1, availablePages, mainCommandAlias, alias, page, page + 2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 GeorgH93
* Copyright (C) 2022 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -23,27 +23,28 @@
import at.pcgamingfreaks.MarriageMaster.Bukkit.API.MarryCommand;
import at.pcgamingfreaks.MarriageMaster.Bukkit.MarriageMaster;
import at.pcgamingfreaks.MarriageMaster.Permissions;
import at.pcgamingfreaks.MarriageMaster.Placeholder.Placeholders;
import at.pcgamingfreaks.Message.Placeholder.Placeholder;
import at.pcgamingfreaks.Message.Placeholder.Processors.SimpleDatePlaceholderProcessor;

import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class SeenCommand extends MarryCommand
{
private final Message messageLastSeen, messageCurrentlyOnline;
private final SimpleDateFormat dateFormat;

public SeenCommand(MarriageMaster plugin)
{
super(plugin, "seen", plugin.getLanguage().getTranslated("Commands.Description.Seen"), Permissions.SEEN, true, true, plugin.getLanguage().getCommandAliases("seen"));

dateFormat = new SimpleDateFormat(plugin.getLanguage().getLang().getString("Language.Ingame.Seen.DateFormat", "yyyy.MM.dd 'at' HH:mm:ss"));
messageLastSeen = plugin.getLanguage().getMessage("Ingame.Seen.LastSeen").replaceAll("\\{Name}", "%1\\$s").replaceAll("\\{Date}", "%2\\$s").replaceAll("\\{CountTotalDays}", "%3\\$d").replaceAll("\\{Count}", "%4\\$s");
messageCurrentlyOnline = plugin.getLanguage().getMessage("Ingame.Seen.CurrentlyOnline").replaceAll("\\{Name}", "%1\\$s").replaceAll("\\{DisplayName}", "%2\\$s");
Placeholder datePlaceholder = new Placeholder("Date", new SimpleDatePlaceholderProcessor(plugin.getLanguage().getLangE().getString("Language.Ingame.Seen.DateFormat", "yyyy.MM.dd 'at' HH:mm:ss")));
messageLastSeen = plugin.getLanguage().getMessage("Ingame.Seen.LastSeen").placeholders(Placeholders.PLAYER_NAME).placeholders(datePlaceholder).placeholder("CountTotalDays").placeholder("Count");
messageCurrentlyOnline = plugin.getLanguage().getMessage("Ingame.Seen.CurrentlyOnline").placeholders(Placeholders.PLAYER_NAME);
}

@Override
Expand All @@ -57,13 +58,13 @@ public void execute(@NotNull CommandSender sender, @NotNull String mainCommandAl
}
else if(partner.isOnline())
{
player.sendMessage(messageCurrentlyOnline, partner.getName(), partner.getDisplayName());
player.sendMessage(messageCurrentlyOnline, partner);
}
else
{
Date lastOnline = new Date(partner.getPlayer().getLastPlayed());
TimeSpan timeSpan = new TimeSpan(lastOnline);
player.send(messageLastSeen, partner.getName(), dateFormat.format(lastOnline), timeSpan.getTotalDays(), timeSpan.toString());
player.send(messageLastSeen, partner, lastOnline, timeSpan.getTotalDays(), timeSpan.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 GeorgH93
* Copyright (C) 2022 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -42,9 +42,9 @@ public SetColorCommand(final @NotNull MarriageMaster plugin)
super(plugin, "setcolor", plugin.getLanguage().getTranslated("Commands.Description.SetColor"), Permissions.SET_COLOR, true, true, plugin.getLanguage().getCommandAliases("SetColor"));
this.plugin = plugin;

messageUnknownColor = plugin.getLanguage().getMessage("Ingame.SetColor.UnknownColor").replaceAll("\\{Input}", "%s");
messageUnknownColor = plugin.getLanguage().getMessage("Ingame.SetColor.UnknownColor").placeholder("Input");
messageColorSet = plugin.getLanguage().getMessage("Ingame.SetColor.Set");
messageColorSelection = plugin.getLanguage().getMessage("Ingame.SetColor.Selection").replaceAll("\\{MainCmdAlias}", "%1\\$s").replaceAll("\\{SubCmdAlias}", "%2\\$s");
messageColorSelection = plugin.getLanguage().getMessage("Ingame.SetColor.Selection").placeholder("MainCmdAlias").placeholder("SubCmdAlias");
}

@Override
Expand Down
Loading

0 comments on commit 567c90a

Please sign in to comment.