Added PlaceholderContext#copyWithItem
This commit is contained in:
@@ -131,12 +131,8 @@ public final class PlaceholderManager {
|
||||
getResult(
|
||||
plugin,
|
||||
identifier,
|
||||
new PlaceholderContext(
|
||||
player,
|
||||
null,
|
||||
EMPTY_INJECTABLE,
|
||||
Collections.emptyList()
|
||||
)
|
||||
new PlaceholderContext()
|
||||
.copyWithPlayer(player)
|
||||
),
|
||||
""
|
||||
);
|
||||
|
||||
@@ -50,6 +50,13 @@ public class PlaceholderContext {
|
||||
@NotNull
|
||||
private final Collection<AdditionalPlayer> additionalPlayers;
|
||||
|
||||
/**
|
||||
* Create an empty PlaceholderContext.
|
||||
*/
|
||||
public PlaceholderContext() {
|
||||
this(null, null, PlaceholderManager.EMPTY_INJECTABLE, Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new PlaceholderContext with the given parameters.
|
||||
*
|
||||
@@ -135,6 +142,21 @@ public class PlaceholderContext {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy with an item.
|
||||
*
|
||||
* @param itemStack The ItemStack.
|
||||
* @return The new context.
|
||||
*/
|
||||
public PlaceholderContext copyWithItem(@Nullable final ItemStack itemStack) {
|
||||
return new PlaceholderContext(
|
||||
this.getPlayer(),
|
||||
itemStack,
|
||||
this.getInjectableContext(),
|
||||
this.getAdditionalPlayers()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy with an extra injectable context.
|
||||
*
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -346,12 +345,8 @@ public final class StringUtils {
|
||||
if (option == FormatOption.WITH_PLACEHOLDERS) {
|
||||
return format(
|
||||
message,
|
||||
new PlaceholderContext(
|
||||
player,
|
||||
null,
|
||||
PlaceholderManager.EMPTY_INJECTABLE,
|
||||
Collections.emptyList()
|
||||
)
|
||||
new PlaceholderContext()
|
||||
.copyWithPlayer(player)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user