Allow playername placeholder in own title.
This commit is contained in:
parent
5f3b80308d
commit
6d0022e413
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 GeorgH93
|
* Copyright (C) 2024 GeorgH93
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* 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 <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package at.pcgamingfreaks.Minepacks.Bukkit;
|
package at.pcgamingfreaks.Minepacks.Bukkit;
|
||||||
|
@ -21,9 +21,7 @@ import at.pcgamingfreaks.Bukkit.MCVersion;
|
||||||
import at.pcgamingfreaks.Bukkit.Util.InventoryUtils;
|
import at.pcgamingfreaks.Bukkit.Util.InventoryUtils;
|
||||||
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Helper.InventoryCompressor;
|
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Helper.InventoryCompressor;
|
||||||
import at.pcgamingfreaks.Util.StringUtils;
|
import at.pcgamingfreaks.Util.StringUtils;
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
@ -33,6 +31,10 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -42,8 +44,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
public class Backpack implements at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack
|
public class Backpack implements at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack
|
||||||
{
|
{
|
||||||
@Setter(AccessLevel.PACKAGE) private static ShrinkApproach shrinkApproach = ShrinkApproach.COMPRESS;
|
@Setter(AccessLevel.PACKAGE) private static ShrinkApproach shrinkApproach = ShrinkApproach.COMPRESS;
|
||||||
private static Object titleOwn;
|
private static Object titleOwnGlobal;
|
||||||
private static String titleOtherFormat;
|
private static String titleFormat, titleOtherFormat;
|
||||||
|
private final Object titleOwn;
|
||||||
private final String titleOther;
|
private final String titleOther;
|
||||||
@Getter private final UUID ownerId;
|
@Getter private final UUID ownerId;
|
||||||
private final Map<Player, Boolean> opened = new ConcurrentHashMap<>(); //Thanks Minecraft 1.14
|
private final Map<Player, Boolean> opened = new ConcurrentHashMap<>(); //Thanks Minecraft 1.14
|
||||||
|
@ -54,7 +57,8 @@ public class Backpack implements at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack
|
||||||
|
|
||||||
public static void setTitle(final @NotNull String title, final @NotNull String titleOther)
|
public static void setTitle(final @NotNull String title, final @NotNull String titleOther)
|
||||||
{
|
{
|
||||||
titleOwn = InventoryUtils.prepareTitleForOpenInventoryWithCustomTitle(title);
|
titleOwnGlobal = title.contains("%s") ? null : InventoryUtils.prepareTitleForOpenInventoryWithCustomTitle(title);
|
||||||
|
titleFormat = title;
|
||||||
titleOtherFormat = titleOther;
|
titleOtherFormat = titleOther;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +84,9 @@ public class Backpack implements at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack
|
||||||
bp = Bukkit.createInventory(this, size, titleOther);
|
bp = Bukkit.createInventory(this, size, titleOther);
|
||||||
this.size = size;
|
this.size = size;
|
||||||
ownerDatabaseId = ID;
|
ownerDatabaseId = ID;
|
||||||
|
|
||||||
|
if (titleOwnGlobal != null) titleOwn = titleOwnGlobal;
|
||||||
|
else titleOwn = InventoryUtils.prepareTitleForOpenInventoryWithCustomTitle(String.format(titleFormat, owner.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Backpack(final OfflinePlayer owner, ItemStack[] backpack, final int ID)
|
public Backpack(final OfflinePlayer owner, ItemStack[] backpack, final int ID)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2023 GeorgH93
|
* Copyright (C) 2024 GeorgH93
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* 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 <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package at.pcgamingfreaks.Minepacks.Bukkit.Database;
|
package at.pcgamingfreaks.Minepacks.Bukkit.Database;
|
||||||
|
@ -31,6 +31,7 @@ import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
|
||||||
import at.pcgamingfreaks.Minepacks.Bukkit.ShrinkApproach;
|
import at.pcgamingfreaks.Minepacks.Bukkit.ShrinkApproach;
|
||||||
import at.pcgamingfreaks.Minepacks.MagicValues;
|
import at.pcgamingfreaks.Minepacks.MagicValues;
|
||||||
import at.pcgamingfreaks.Version;
|
import at.pcgamingfreaks.Version;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -175,7 +176,7 @@ public class Config extends Configuration implements DatabaseConnectionConfigura
|
||||||
|
|
||||||
public String getBPTitle()
|
public String getBPTitle()
|
||||||
{
|
{
|
||||||
return ChatColor.translateAlternateColorCodes('&', getConfigE().getString("BackpackTitle", "Backpack"));
|
return ChatColor.translateAlternateColorCodes('&', getConfigE().getString("BackpackTitle", "Backpack").replace("%", "%%").replace("{OwnerName}", "%s"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getDropOnDeath()
|
public boolean getDropOnDeath()
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -7,7 +7,7 @@
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>2.4.25</revision>
|
<revision>2.4.26</revision>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue