Skip to content

Commit 51e6767

Browse files
authored
Upstream
2 parents b81afaf + fe27182 commit 51e6767

14 files changed

Lines changed: 199 additions & 63 deletions

File tree

Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ public void onPlayerChangedWorldFlyReset(final PlayerChangedWorldEvent event) {
783783
}
784784

785785
final TickCountProvider tickCountProvider = ess.provider(TickCountProvider.class);
786-
if (tickCountProvider != null && user.getFlightTick() == tickCountProvider.getTickCount()) {
786+
if (tickCountProvider != null && user.getFlightTick() == tickCountProvider.getTickCount() && user.isAuthorized("essentials.fly")) {
787787
user.getBase().setAllowFlight(true);
788788
user.getBase().setFlying(true);
789789
}

Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.earth2me.essentials.textreader.BookInput;
44
import com.earth2me.essentials.textreader.BookPager;
55
import com.earth2me.essentials.textreader.IText;
6-
import com.earth2me.essentials.utils.EnumUtil;
76
import com.earth2me.essentials.utils.FormatUtil;
87
import com.earth2me.essentials.utils.MaterialUtil;
98
import com.earth2me.essentials.utils.NumberUtil;
@@ -217,8 +216,6 @@ public void addStringMeta(final CommandSource sender, final boolean allowUnsafe,
217216
return;
218217
}
219218

220-
final Material WRITTEN_BOOK = EnumUtil.getMaterial("WRITTEN_BOOK");
221-
222219
if (split.length > 1 && split[0].equalsIgnoreCase("name") && hasMetaPermission(sender, "name", false, true, ess)) {
223220
final String displayName = FormatUtil.replaceFormat(split[1].replaceAll("(?<!\\\\)_", " ").replace("\\_", "_"));
224221
final ItemMeta meta = stack.getItemMeta();
@@ -254,7 +251,7 @@ public void addStringMeta(final CommandSource sender, final boolean allowUnsafe,
254251
final IText input = new BookInput("book", true, ess);
255252
final BookPager pager = new BookPager(input);
256253
// This fix only applies to written books - which require an author and a title. https://bugs.mojang.com/browse/MC-59153
257-
if (stack.getType() == WRITTEN_BOOK) {
254+
if (stack.getType() == Material.WRITTEN_BOOK) {
258255
if (!meta.hasAuthor()) {
259256
// The sender can be null when this method is called from {@link com.earth2me.essentials.signs.EssentialsSign#getItemMeta(ItemStack, String, IEssentials)}
260257
meta.setAuthor(sender == null ? Console.getInstance().getDisplayName() : sender.getPlayer().getName());
@@ -267,12 +264,12 @@ public void addStringMeta(final CommandSource sender, final boolean allowUnsafe,
267264
final List<String> pages = pager.getPages(split[1]);
268265
meta.setPages(pages);
269266
stack.setItemMeta(meta);
270-
} else if (split.length > 1 && split[0].equalsIgnoreCase("author") && stack.getType() == WRITTEN_BOOK && hasMetaPermission(sender, "author", false, true, ess)) {
267+
} else if (split.length > 1 && split[0].equalsIgnoreCase("author") && stack.getType() == Material.WRITTEN_BOOK && hasMetaPermission(sender, "author", false, true, ess)) {
271268
final String author = FormatUtil.replaceFormat(split[1]);
272269
final BookMeta meta = (BookMeta) stack.getItemMeta();
273270
meta.setAuthor(author);
274271
stack.setItemMeta(meta);
275-
} else if (split.length > 1 && split[0].equalsIgnoreCase("title") && stack.getType() == WRITTEN_BOOK && hasMetaPermission(sender, "title", false, true, ess)) {
272+
} else if (split.length > 1 && split[0].equalsIgnoreCase("title") && stack.getType() == Material.WRITTEN_BOOK && hasMetaPermission(sender, "title", false, true, ess)) {
276273
final String title = FormatUtil.replaceFormat(split[1].replaceAll("(?<!\\\\)_", " ").replace("\\_", "_"));
277274
final BookMeta meta = (BookMeta) stack.getItemMeta();
278275
meta.setTitle(title);

Essentials/src/main/java/com/earth2me/essentials/UserData.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,17 @@ public void setMails(List<String> mails) {
348348
}
349349

350350
public int getMailAmount() {
351-
return holder.mail() == null ? 0 : holder.mail().size();
351+
if (holder.mail() == null) {
352+
return 0;
353+
}
354+
355+
int amount = 0;
356+
for (MailMessage element : holder.mail()) {
357+
if (!element.isExpired()) {
358+
amount++;
359+
}
360+
}
361+
return amount;
352362
}
353363

354364
public int getUnreadMailAmount() {
@@ -358,7 +368,7 @@ public int getUnreadMailAmount() {
358368

359369
int unread = 0;
360370
for (MailMessage element : holder.mail()) {
361-
if (!element.isRead()) {
371+
if (!element.isRead() && !element.isExpired()) {
362372
unread++;
363373
}
364374
}

Essentials/src/main/java/com/earth2me/essentials/commands/Commandbook.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
import com.earth2me.essentials.craftbukkit.Inventories;
55
import com.earth2me.essentials.utils.EnumUtil;
66
import com.earth2me.essentials.utils.FormatUtil;
7+
import com.earth2me.essentials.utils.VersionUtil;
78
import com.google.common.collect.Lists;
89
import net.ess3.api.TranslatableException;
910
import org.bukkit.Material;
1011
import org.bukkit.Server;
1112
import org.bukkit.inventory.ItemStack;
1213
import org.bukkit.inventory.meta.BookMeta;
14+
import org.bukkit.inventory.meta.WritableBookMeta;
1315

1416
import java.util.Collections;
1517
import java.util.List;
@@ -50,7 +52,14 @@ public void run(final Server server, final User user, final String commandLabel,
5052
} else {
5153
if (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others")) {
5254
final ItemStack newItem = new ItemStack(WRITABLE_BOOK, item.getAmount());
53-
newItem.setItemMeta(bmeta);
55+
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_20_6_R01)) {
56+
final WritableBookMeta wbmeta = (WritableBookMeta) newItem.getItemMeta();
57+
//noinspection DataFlowIssue
58+
wbmeta.setPages(bmeta.getPages());
59+
newItem.setItemMeta(wbmeta);
60+
} else {
61+
newItem.setItemMeta(bmeta);
62+
}
5463
Inventories.setItemInMainHand(user.getBase(), newItem);
5564
user.sendTl("editBookContents");
5665
} else {
@@ -63,7 +72,15 @@ public void run(final Server server, final User user, final String commandLabel,
6372
bmeta.setAuthor(player);
6473
}
6574
final ItemStack newItem = new ItemStack(Material.WRITTEN_BOOK, item.getAmount());
66-
newItem.setItemMeta(bmeta);
75+
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_20_6_R01)) {
76+
final BookMeta real = (BookMeta) newItem.getItemMeta();
77+
real.setAuthor(bmeta.getAuthor());
78+
real.setTitle(bmeta.getTitle());
79+
real.setPages(bmeta.getPages());
80+
newItem.setItemMeta(real);
81+
} else {
82+
newItem.setItemMeta(bmeta);
83+
}
6784
Inventories.setItemInMainHand(user.getBase(), newItem);
6885
user.sendTl("bookLocked");
6986
} else {

Essentials/src/main/resources/messages_cs.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ clearinventoryCommandUsage3=/<command> <hráč> <předmět> [počet]
142142
clearinventoryCommandUsage3Description=Vymaže všechny zadané předměty (nebo určitý počet) z inventáře zadaného hráče.
143143
clearinventoryconfirmtoggleCommandDescription=Přepíná, zda je třeba potvrzovat vyprázdnění inventáře.
144144
clearinventoryconfirmtoggleCommandUsage=/<command>
145+
commandArgumentOptional=<gray>
145146
commandCooldown=<secondary>Tento příkaz můžete použít až za {0}.
146147
commandDisabled=<secondary>Příkaz<primary> {0}<secondary>je vypnut.
147148
commandFailed=Příkaz {0} selhal\:

Essentials/src/main/resources/messages_es.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#Sat Feb 03 17:34:46 GMT 2024
2+
action=<dark_purple>* {0} <dark_purple>{1}
23
addedToAccount=<yellow>{0}<green> ha sido añadido a tu cuenta.
34
addedToOthersAccount=<yellow>{0}<green> han sido añadidos a la cuenta de<yellow> {1}<green>. Nuevo saldo\:<yellow> {2}
45
adventure=aventura
@@ -829,6 +830,7 @@ onlyDayNight=<primary>/time <dark_red>únicamente funciona con los valores <prim
829830
onlyPlayers=<dark_red>Solo jugadores dentro del juego pueden usar <secondary>{0}<dark_red>.
830831
onlyPlayerSkulls=<dark_red>Solo puedes indicar el propietario de las calaveras de jugadores (<secondary>397\:3<dark_red>).
831832
onlySunStorm=<secondary>/weather <dark_red>solo acepta los valores <secondary>sun <dark_red>o <secondary>storm <dark_red>(<primary>sol<dark_red>/<primary>tormenta<dark_red>).
833+
openingDisposal=<primary>Abriendo el basurero...
832834
orderBalances=Creando un ranking de {0} usuarios segun su saldo, espera...
833835
oversizedMute=<dark_red>No puedes silenciar a un jugador por este periodo de tiempo.
834836
oversizedTempban=<dark_red>No puedes banear por ese periodo de tiempo.

Essentials/src/main/resources/messages_it.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ month=mese
703703
months=mesi
704704
moreCommandDescription=Ti dà l''ammontare specificato per questo oggetto, o uno stack se non specificato.
705705
moreCommandUsage=/<command> [quantità]
706+
moreCommandUsage1=/<command> [quantità]
706707
moreCommandUsage1Description=Ti dà l''ammontare specificato per questo oggetto, o uno stack se non specificato.
707708
moreThanZero=La quantità deve essere maggiore di 0.
708709
motdCommandDescription=Mostra il MOTD.

Essentials/src/main/resources/messages_nl.properties

Lines changed: 0 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)