Alert player about shrunken backpack (Fixes #284)

This commit is contained in:
GeorgH93 2024-01-30 00:01:02 +01:00
parent f759a4b799
commit 0b9ec74747
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
4 changed files with 12 additions and 2 deletions

View File

@ -16,6 +16,7 @@ Language:
NotAllowedInBackpack_SendMethod: "action_bar"
DontRemoveShortcut: "&cYou must not remove the backpack shortcut from your inventory!"
DontRemoveShortcut_SendMethod: "action_bar"
BackpackShrunk: "&cYour backpack shrunk! Some items fell to the ground!"
Open:
#Parameter: {TimeLeft} time in seconds till the backpack can be reopened, {TimeSpanLeft} time formatted as string till the backpack can be reopened
Cooldown: "[{\"text\":\"Please wait \",\"color\":\"dark_green\"},{\"text\":\"{TimeSpanLeft}\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"{TimeLeft} seconds\"}},{\"text\":\" till you reopen your backpack.\"}]"

View File

@ -18,6 +18,7 @@
package at.pcgamingfreaks.Minepacks.Bukkit;
import at.pcgamingfreaks.Bukkit.MCVersion;
import at.pcgamingfreaks.Bukkit.Message.Message;
import at.pcgamingfreaks.Bukkit.Util.InventoryUtils;
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Helper.InventoryCompressor;
import at.pcgamingfreaks.Util.StringUtils;
@ -44,6 +45,7 @@
public class Backpack implements at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack
{
@Setter(AccessLevel.PACKAGE) private static ShrinkApproach shrinkApproach = ShrinkApproach.COMPRESS;
@Setter(AccessLevel.PACKAGE) private static Message messageBackpackShrunk = new Message("Backpack shrunk!");
private static Object titleOwnGlobal;
private static String titleFormat, titleOtherFormat;
private final Object titleOwn;
@ -142,14 +144,20 @@ public void checkResize()
int size = Minepacks.getInstance().getBackpackPermSize(owner);
if(size != bp.getSize())
{
boolean dropped = false;
List<ItemStack> items = setSize(size);
for(ItemStack i : items)
{
if(i != null)
{
owner.getWorld().dropItemNaturally(owner.getLocation(), i);
dropped = true;
}
}
if (dropped)
{
messageBackpackShrunk.send(owner);
}
}
}
}

View File

@ -193,6 +193,7 @@ private void load()
maxSize = config.getBackpackMaxSize();
at.pcgamingfreaks.Minepacks.Bukkit.Backpack.setShrinkApproach(config.getShrinkApproach());
at.pcgamingfreaks.Minepacks.Bukkit.Backpack.setTitle(config.getBPTitle(), config.getBPTitleOther());
at.pcgamingfreaks.Minepacks.Bukkit.Backpack.setMessageBackpackShrunk(lang.getMessage("Ingame.BackpackShrunk"));
messageNotFromConsole = lang.getMessage("NotFromConsole");
messageNoPermission = lang.getMessage("Ingame.NoPermission");
messageInvalidBackpack = lang.getMessage("Ingame.InvalidBackpack");

View File

@ -7,12 +7,12 @@
<packaging>pom</packaging>
<properties>
<revision>2.4.27-SNAPSHOT</revision>
<revision>2.4.27</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<configFileVersion>34</configFileVersion>
<languageFileVersion>20</languageFileVersion>
<languageFileVersion>21</languageFileVersion>
<pcgfPluginLibVersion>1.0.39.3-SNAPSHOT</pcgfPluginLibVersion>
<bukkitVersion>1.15.2-R0.1-SNAPSHOT</bukkitVersion>