Skip to content

Commit

Permalink
Alert player about shrunken backpack (Fixes #284)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgH93 committed Jan 29, 2024
1 parent f759a4b commit 0b9ec74
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions Minepacks/resources/lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.\"}]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 0b9ec74

Please sign in to comment.