mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Bring back PAPI placeholders and raw colour formatting
This commit is contained in:
parent
335cf5d2e9
commit
186a810bf6
@ -48,7 +48,6 @@ import com.plotsquared.bukkit.util.BukkitUtil;
|
|||||||
import com.plotsquared.bukkit.util.BukkitWorld;
|
import com.plotsquared.bukkit.util.BukkitWorld;
|
||||||
import com.plotsquared.bukkit.util.SetGenCB;
|
import com.plotsquared.bukkit.util.SetGenCB;
|
||||||
import com.plotsquared.bukkit.util.UpdateUtility;
|
import com.plotsquared.bukkit.util.UpdateUtility;
|
||||||
import com.plotsquared.bukkit.util.task.BukkitTaskManager;
|
|
||||||
import com.plotsquared.bukkit.util.task.PaperTimeConverter;
|
import com.plotsquared.bukkit.util.task.PaperTimeConverter;
|
||||||
import com.plotsquared.bukkit.util.task.SpigotTimeConverter;
|
import com.plotsquared.bukkit.util.task.SpigotTimeConverter;
|
||||||
import com.plotsquared.bukkit.uuid.BungeePermsUUIDService;
|
import com.plotsquared.bukkit.uuid.BungeePermsUUIDService;
|
||||||
@ -64,7 +63,7 @@ import com.plotsquared.core.backup.BackupManager;
|
|||||||
import com.plotsquared.core.command.WE_Anywhere;
|
import com.plotsquared.core.command.WE_Anywhere;
|
||||||
import com.plotsquared.core.components.ComponentPresetManager;
|
import com.plotsquared.core.components.ComponentPresetManager;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.ChatFormatter;
|
import com.plotsquared.core.configuration.caption.ChatFormatter;
|
||||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.ConfigurationUtil;
|
import com.plotsquared.core.configuration.ConfigurationUtil;
|
||||||
|
@ -26,15 +26,17 @@
|
|||||||
package com.plotsquared.bukkit.placeholder;
|
package com.plotsquared.bukkit.placeholder;
|
||||||
|
|
||||||
import com.plotsquared.bukkit.player.BukkitPlayer;
|
import com.plotsquared.bukkit.player.BukkitPlayer;
|
||||||
import com.plotsquared.core.configuration.ChatFormatter;
|
import com.plotsquared.core.configuration.caption.ChatFormatter;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class PlaceholderFormatter implements ChatFormatter {
|
public class PlaceholderFormatter implements ChatFormatter {
|
||||||
|
|
||||||
@Override public void format(final ChatContext context) {
|
@Override public void format(@Nonnull final ChatContext context) {
|
||||||
final PlotPlayer recipient = context.getRecipient();
|
final PlotPlayer<?> recipient = context.getRecipient();
|
||||||
if (recipient instanceof BukkitPlayer) {
|
if (recipient instanceof BukkitPlayer) {
|
||||||
if (context.isRawOutput()) {
|
if (context.isRawOutput()) {
|
||||||
context.setMessage(context.getMessage().replace('%', '\u2010'));
|
context.setMessage(context.getMessage().replace('%', '\u2010'));
|
||||||
|
@ -31,7 +31,7 @@ import com.plotsquared.bukkit.BukkitPlatform;
|
|||||||
import com.plotsquared.bukkit.player.BukkitPlayer;
|
import com.plotsquared.bukkit.player.BukkitPlayer;
|
||||||
import com.plotsquared.bukkit.player.BukkitPlayerManager;
|
import com.plotsquared.bukkit.player.BukkitPlayerManager;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.caption.LocaleHolder;
|
import com.plotsquared.core.configuration.caption.LocaleHolder;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core;
|
package com.plotsquared.core;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
|
@ -29,7 +29,7 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.caption.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
|
@ -27,7 +27,7 @@ package com.plotsquared.core.command;
|
|||||||
|
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.caption.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.StaticCaption;
|
import com.plotsquared.core.configuration.caption.StaticCaption;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.Template;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.caption.LocaleHolder;
|
import com.plotsquared.core.configuration.caption.LocaleHolder;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.caption.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
|
@ -27,7 +27,7 @@ package com.plotsquared.core.command;
|
|||||||
|
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.caption.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.database.DBFunc;
|
import com.plotsquared.core.database.DBFunc;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.StaticCaption;
|
import com.plotsquared.core.configuration.caption.StaticCaption;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -27,7 +27,7 @@ package com.plotsquared.core.command;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.core.backup.BackupManager;
|
import com.plotsquared.core.backup.BackupManager;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.caption.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.caption.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package com.plotsquared.core.configuration;
|
package com.plotsquared.core.configuration;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.plotsquared.core.configuration;
|
package com.plotsquared.core.configuration.caption;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.caption.LocaleHolder;
|
import com.plotsquared.core.configuration.caption.LocaleHolder;
|
||||||
|
|
@ -23,37 +23,46 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.plotsquared.core.configuration;
|
package com.plotsquared.core.configuration.caption;
|
||||||
|
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class CaptionUtility {
|
public class CaptionUtility {
|
||||||
|
|
||||||
public static String formatRaw(PlotPlayer recipient, String message, Object... args) {
|
/**
|
||||||
|
* Format a chat message but keep the formatting keys
|
||||||
|
*
|
||||||
|
* @param recipient Message recipient
|
||||||
|
* @param message Message
|
||||||
|
* @return Formatted message
|
||||||
|
*/
|
||||||
|
public static String formatRaw(PlotPlayer<?> recipient, String message) {
|
||||||
final ChatFormatter.ChatContext chatContext =
|
final ChatFormatter.ChatContext chatContext =
|
||||||
new ChatFormatter.ChatContext(recipient, message, args, true);
|
new ChatFormatter.ChatContext(recipient, message, true);
|
||||||
for (final ChatFormatter chatFormatter : ChatFormatter.formatters) {
|
for (final ChatFormatter chatFormatter : ChatFormatter.formatters) {
|
||||||
chatFormatter.format(chatContext);
|
chatFormatter.format(chatContext);
|
||||||
}
|
}
|
||||||
return chatContext.getMessage();
|
return chatContext.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String format(PlotPlayer recipient, String message, Object... args) {
|
/**
|
||||||
|
* Format a chat message
|
||||||
|
*
|
||||||
|
* @param recipient Message recipient
|
||||||
|
* @param message Message
|
||||||
|
* @return Formatted message
|
||||||
|
*/
|
||||||
|
public static String format(@Nullable final PlotPlayer<?> recipient,
|
||||||
|
@Nonnull final String message) {
|
||||||
final ChatFormatter.ChatContext chatContext =
|
final ChatFormatter.ChatContext chatContext =
|
||||||
new ChatFormatter.ChatContext(recipient, message, args, false);
|
new ChatFormatter.ChatContext(recipient, message, false);
|
||||||
for (final ChatFormatter chatFormatter : ChatFormatter.formatters) {
|
for (final ChatFormatter chatFormatter : ChatFormatter.formatters) {
|
||||||
chatFormatter.format(chatContext);
|
chatFormatter.format(chatContext);
|
||||||
}
|
}
|
||||||
return chatContext.getMessage();
|
return chatContext.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String format(PlotPlayer recipient, Caption caption, Object... args) {
|
|
||||||
if (caption.usePrefix() && caption.getTranslated().length() > 0) {
|
|
||||||
return Captions.PREFIX.getTranslated() + format(recipient, caption.getTranslated(),
|
|
||||||
args);
|
|
||||||
} else {
|
|
||||||
return format(recipient, caption.getTranslated(), args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -23,10 +23,12 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.plotsquared.core.configuration;
|
package com.plotsquared.core.configuration.caption;
|
||||||
|
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -34,43 +36,71 @@ import java.util.Collections;
|
|||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface ChatFormatter {
|
public interface ChatFormatter {
|
||||||
|
|
||||||
Collection<ChatFormatter> formatters =
|
Collection<ChatFormatter> formatters = new ArrayList<>(Collections.singletonList(new PlotSquaredChatFormatter()));
|
||||||
new ArrayList<>(Collections.singletonList(new PlotSquaredChatFormatter()));
|
|
||||||
|
|
||||||
void format(ChatContext context);
|
/**
|
||||||
|
* Format a message using all registered formatters
|
||||||
|
*
|
||||||
|
* @param context Message to format
|
||||||
|
*/
|
||||||
|
void format(@Nonnull ChatContext context);
|
||||||
|
|
||||||
final class ChatContext {
|
final class ChatContext {
|
||||||
|
|
||||||
private final PlotPlayer<?> recipient;
|
private final PlotPlayer<?> recipient;
|
||||||
private String message;
|
private String message;
|
||||||
private final Object[] args;
|
;
|
||||||
private final boolean rawOutput;
|
private final boolean rawOutput;
|
||||||
|
|
||||||
public ChatContext(final PlotPlayer<?> recipient, final String message, final Object[] args,
|
/**
|
||||||
|
* Create a new chat context
|
||||||
|
*
|
||||||
|
* @param recipient Message recipient
|
||||||
|
* @param message Message
|
||||||
|
* @param rawOutput Whether or not formatting keys should be included in the
|
||||||
|
* final message
|
||||||
|
*/
|
||||||
|
public ChatContext(@Nullable final PlotPlayer<?> recipient, @Nonnull final String message,
|
||||||
final boolean rawOutput) {
|
final boolean rawOutput) {
|
||||||
this.recipient = recipient;
|
this.recipient = recipient;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.args = args;
|
|
||||||
this.rawOutput = rawOutput;
|
this.rawOutput = rawOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotPlayer<?> getRecipient() {
|
/**
|
||||||
|
* Get the message recipient
|
||||||
|
*
|
||||||
|
* @return Recipient
|
||||||
|
*/
|
||||||
|
@Nullable public PlotPlayer<?> getRecipient() {
|
||||||
return this.recipient;
|
return this.recipient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
/**
|
||||||
|
* Get the message stored in the context
|
||||||
|
*
|
||||||
|
* @return Stored message
|
||||||
|
*/
|
||||||
|
@Nonnull public String getMessage() {
|
||||||
return this.message;
|
return this.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getArgs() {
|
/**
|
||||||
return this.args;
|
* Whether or not the output should escape
|
||||||
}
|
* any formatting keys
|
||||||
|
*
|
||||||
|
* @return True if raw output is to be used
|
||||||
|
*/
|
||||||
public boolean isRawOutput() {
|
public boolean isRawOutput() {
|
||||||
return this.rawOutput;
|
return this.rawOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message) {
|
/**
|
||||||
|
* Set the new message
|
||||||
|
*
|
||||||
|
* @param message Message
|
||||||
|
*/
|
||||||
|
public void setMessage(@Nonnull final String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,12 +25,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.configuration.caption;
|
package com.plotsquared.core.configuration.caption;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link com.plotsquared.core.configuration.Caption} that can be identified by a key
|
* A {@link Caption} that can be identified by a key
|
||||||
*/
|
*/
|
||||||
public interface KeyedCaption extends Caption {
|
public interface KeyedCaption extends Caption {
|
||||||
|
|
||||||
|
@ -23,39 +23,17 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.plotsquared.core.configuration;
|
package com.plotsquared.core.configuration.caption;
|
||||||
|
|
||||||
import com.plotsquared.core.util.StringMan;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class PlotSquaredChatFormatter implements ChatFormatter {
|
public class PlotSquaredChatFormatter implements ChatFormatter {
|
||||||
|
|
||||||
@Override public void format(final ChatContext context) {
|
@Override public void format(@Nonnull final ChatContext context) {
|
||||||
if (context.isRawOutput()) {
|
if (context.isRawOutput()) {
|
||||||
context.setMessage(
|
context.setMessage(
|
||||||
context.getMessage().replace('&', '\u2020').replace('\u00A7', '\u2030'));
|
context.getMessage().replace('&', '\u2020').replace('\u00A7', '\u2030'));
|
||||||
}
|
}
|
||||||
if (context.getArgs().length == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final Map<String, String> map = new LinkedHashMap<>();
|
|
||||||
for (int i = context.getArgs().length - 1; i >= 0; i--) {
|
|
||||||
String arg = "" + context.getArgs()[i];
|
|
||||||
if (arg.isEmpty()) {
|
|
||||||
map.put("%s" + i, "");
|
|
||||||
} else {
|
|
||||||
if (!context.isRawOutput()) {
|
|
||||||
arg = Captions.color(arg);
|
|
||||||
}
|
|
||||||
map.put("%s" + i, arg);
|
|
||||||
}
|
|
||||||
if (i == 0) {
|
|
||||||
map.put("%s", arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
context.setMessage(StringMan.replaceFromMap(context.getMessage(), map));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -23,10 +23,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.plotsquared.core.configuration;
|
package com.plotsquared.core.configuration.caption;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.plotsquared.core.configuration.caption.LocaleHolder;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
@ -34,10 +33,7 @@ public final class StaticCaption implements Caption {
|
|||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
/**
|
private StaticCaption(final String value) {
|
||||||
* @deprecated Use {@link #of(String)}
|
|
||||||
*/
|
|
||||||
@Deprecated public StaticCaption(final String value) {
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.configuration.caption;
|
package com.plotsquared.core.configuration.caption;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
@ -28,7 +28,7 @@ package com.plotsquared.core.player;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.command.RequiredType;
|
import com.plotsquared.core.command.RequiredType;
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
import com.plotsquared.core.database.DBFunc;
|
import com.plotsquared.core.database.DBFunc;
|
||||||
import com.plotsquared.core.events.TeleportCause;
|
import com.plotsquared.core.events.TeleportCause;
|
||||||
|
@ -30,10 +30,11 @@ import com.google.common.base.Preconditions;
|
|||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.command.CommandCaller;
|
import com.plotsquared.core.command.CommandCaller;
|
||||||
import com.plotsquared.core.command.RequiredType;
|
import com.plotsquared.core.command.RequiredType;
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.configuration.caption.CaptionMap;
|
import com.plotsquared.core.configuration.caption.CaptionMap;
|
||||||
|
import com.plotsquared.core.configuration.caption.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.caption.LocaleHolder;
|
import com.plotsquared.core.configuration.caption.LocaleHolder;
|
||||||
import com.plotsquared.core.configuration.caption.Templates;
|
import com.plotsquared.core.configuration.caption.Templates;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
@ -799,6 +800,10 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
|
|||||||
if (message.isEmpty()) {
|
if (message.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Replace placeholders, etc
|
||||||
|
message = CaptionUtility.format(this, message).
|
||||||
|
/* Magic replacement characters */
|
||||||
|
replace('\u2010', '%').replace('\u2020', '&').replace('\u2030', '&');
|
||||||
// Create the template list, and add the prefix as a replacement
|
// Create the template list, and add the prefix as a replacement
|
||||||
final List<Template> templates = Arrays.asList(replacements);
|
final List<Template> templates = Arrays.asList(replacements);
|
||||||
templates.add(Templates.of(this, "prefix", TranslatableCaption.of("core.prefix")));
|
templates.add(Templates.of(this, "prefix", TranslatableCaption.of("core.prefix")));
|
||||||
|
@ -31,7 +31,7 @@ import com.google.common.collect.Sets;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.command.Like;
|
import com.plotsquared.core.command.Like;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.caption.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.ConfigurationUtil;
|
import com.plotsquared.core.configuration.ConfigurationUtil;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
|
@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.plotsquared.core.collection.QuadMap;
|
import com.plotsquared.core.collection.QuadMap;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.caption.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot;
|
package com.plotsquared.core.plot;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -27,7 +27,7 @@ package com.plotsquared.core.plot.comment;
|
|||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.configuration.StaticCaption;
|
import com.plotsquared.core.configuration.caption.StaticCaption;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot.flag;
|
package com.plotsquared.core.plot.flag;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.caption.CaptionUtility;
|
||||||
|
|
||||||
public class FlagParseException extends Exception {
|
public class FlagParseException extends Exception {
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package com.plotsquared.core.plot.flag;
|
package com.plotsquared.core.plot.flag;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot.flag.types;
|
package com.plotsquared.core.plot.flag.types;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.plot.flag.FlagParseException;
|
import com.plotsquared.core.plot.flag.FlagParseException;
|
||||||
import com.plotsquared.core.util.BlockUtil;
|
import com.plotsquared.core.util.BlockUtil;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot.flag.types;
|
package com.plotsquared.core.plot.flag.types;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.plot.flag.FlagParseException;
|
import com.plotsquared.core.plot.flag.FlagParseException;
|
||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot.flag.types;
|
package com.plotsquared.core.plot.flag.types;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.plot.flag.FlagParseException;
|
import com.plotsquared.core.plot.flag.FlagParseException;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot.flag.types;
|
package com.plotsquared.core.plot.flag.types;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.plot.flag.FlagParseException;
|
import com.plotsquared.core.plot.flag.FlagParseException;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot.flag.types;
|
package com.plotsquared.core.plot.flag.types;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot.flag.types;
|
package com.plotsquared.core.plot.flag.types;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.plot.flag.FlagParseException;
|
import com.plotsquared.core.plot.flag.FlagParseException;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot.flag.types;
|
package com.plotsquared.core.plot.flag.types;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot.flag.types;
|
package com.plotsquared.core.plot.flag.types;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.plot.flag.FlagParseException;
|
import com.plotsquared.core.plot.flag.FlagParseException;
|
||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot.flag.types;
|
package com.plotsquared.core.plot.flag.types;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.plot.flag.FlagParseException;
|
import com.plotsquared.core.plot.flag.FlagParseException;
|
||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package com.plotsquared.core.setup;
|
package com.plotsquared.core.setup;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
import com.plotsquared.core.events.TeleportCause;
|
import com.plotsquared.core.events.TeleportCause;
|
||||||
import com.plotsquared.core.generator.GeneratorWrapper;
|
import com.plotsquared.core.generator.GeneratorWrapper;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package com.plotsquared.core.util;
|
package com.plotsquared.core.util;
|
||||||
|
|
||||||
import com.google.common.eventbus.EventBus;
|
import com.google.common.eventbus.EventBus;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.caption.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.events.PlayerAutoPlotEvent;
|
import com.plotsquared.core.events.PlayerAutoPlotEvent;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package com.plotsquared.core.util;
|
package com.plotsquared.core.util;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.caption.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.player.ConsolePlayer;
|
import com.plotsquared.core.player.ConsolePlayer;
|
||||||
|
@ -25,24 +25,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.util;
|
package com.plotsquared.core.util;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.command.Like;
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
|
||||||
import com.plotsquared.core.configuration.Settings;
|
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
|
||||||
import com.plotsquared.core.database.DBFunc;
|
|
||||||
import com.plotsquared.core.location.Location;
|
|
||||||
import com.plotsquared.core.player.ConsolePlayer;
|
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plot functions
|
* plot functions
|
||||||
* @deprecated Do not use
|
* @deprecated Do not use
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.util;
|
package com.plotsquared.core.util;
|
||||||
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package com.plotsquared.core.util;
|
package com.plotsquared.core.util;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
Loading…
Reference in New Issue
Block a user