[Idea]: Folia support for OpenInv #196
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2021 lishid. All rights reserved.
|
* Copyright (C) 2011-2022 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -44,7 +44,7 @@ public class SearchContainerCommand implements TabExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player senderPlayer)) {
|
||||||
plugin.sendMessage(sender, "messages.error.consoleUnsupported");
|
plugin.sendMessage(sender, "messages.error.consoleUnsupported");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,6 @@ public class SearchContainerCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Player senderPlayer = (Player) sender;
|
|
||||||
World world = senderPlayer.getWorld();
|
World world = senderPlayer.getWorld();
|
||||||
Chunk centerChunk = senderPlayer.getLocation().getChunk();
|
Chunk centerChunk = senderPlayer.getLocation().getChunk();
|
||||||
StringBuilder locations = new StringBuilder();
|
StringBuilder locations = new StringBuilder();
|
||||||
@@ -84,10 +83,9 @@ public class SearchContainerCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
Chunk chunk = world.getChunkAt(centerChunk.getX() + dX, centerChunk.getZ() + dZ);
|
Chunk chunk = world.getChunkAt(centerChunk.getX() + dX, centerChunk.getZ() + dZ);
|
||||||
for (BlockState tileEntity : chunk.getTileEntities()) {
|
for (BlockState tileEntity : chunk.getTileEntities()) {
|
||||||
if (!(tileEntity instanceof InventoryHolder)) {
|
if (!(tileEntity instanceof InventoryHolder holder)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
InventoryHolder holder = (InventoryHolder) tileEntity;
|
|
||||||
if (!holder.getInventory().contains(material)) {
|
if (!holder.getInventory().contains(material)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2021 lishid. All rights reserved.
|
* Copyright (C) 2011-2022 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -127,7 +127,6 @@ public class SearchEnchantCommand implements TabExecutor {
|
|||||||
|
|
||||||
private boolean containsEnchantment(Inventory inventory, @Nullable Enchantment enchant, int minLevel) {
|
private boolean containsEnchantment(Inventory inventory, @Nullable Enchantment enchant, int minLevel) {
|
||||||
for (ItemStack item : inventory.getContents()) {
|
for (ItemStack item : inventory.getContents()) {
|
||||||
//noinspection ConstantConditions // Spigot improperly annotated, should be ItemStack @NotNull []
|
|
||||||
if (item == null || item.getType() == Material.AIR) {
|
if (item == null || item.getType() == Material.AIR) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2021 lishid. All rights reserved.
|
* Copyright (C) 2011-2022 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.lishid.openinv.internal;
|
package com.lishid.openinv.internal;
|
||||||
|
|
||||||
import com.lishid.openinv.OpenInv;
|
import com.lishid.openinv.OpenInv;
|
||||||
|
import java.util.Objects;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
@@ -70,11 +71,7 @@ public class OpenInventoryView extends InventoryView {
|
|||||||
titleKey,
|
titleKey,
|
||||||
"%player%",
|
"%player%",
|
||||||
owner.getName());
|
owner.getName());
|
||||||
if (localTitle != null) {
|
title = Objects.requireNonNullElseGet(localTitle, () -> owner.getName() + titleDefaultSuffix);
|
||||||
title = localTitle;
|
|
||||||
} else {
|
|
||||||
title = owner.getName() + titleDefaultSuffix;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return title;
|
return title;
|
||||||
|
@@ -50,7 +50,7 @@ public class LanguageManager {
|
|||||||
getOrLoadLocale(defaultLocale);
|
getOrLoadLocale(defaultLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
private YamlConfiguration getOrLoadLocale(@NotNull String locale) {
|
private @NotNull YamlConfiguration getOrLoadLocale(@NotNull String locale) {
|
||||||
YamlConfiguration loaded = locales.get(locale);
|
YamlConfiguration loaded = locales.get(locale);
|
||||||
if (loaded != null) {
|
if (loaded != null) {
|
||||||
return loaded;
|
return loaded;
|
||||||
@@ -136,8 +136,7 @@ public class LanguageManager {
|
|||||||
return localeConfig;
|
return localeConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public @Nullable String getValue(@NotNull String key, @Nullable String locale) {
|
||||||
public String getValue(@NotNull String key, @Nullable String locale) {
|
|
||||||
String value = getOrLoadLocale(locale == null ? defaultLocale : locale.toLowerCase()).getString(key);
|
String value = getOrLoadLocale(locale == null ? defaultLocale : locale.toLowerCase()).getString(key);
|
||||||
if (value == null || value.isEmpty()) {
|
if (value == null || value.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
@@ -148,8 +147,7 @@ public class LanguageManager {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public @Nullable String getValue(@NotNull String key, @Nullable String locale, String @NotNull ... replacements) {
|
||||||
public String getValue(@NotNull String key, @Nullable String locale, @NotNull String... replacements) {
|
|
||||||
if (replacements.length % 2 != 0) {
|
if (replacements.length % 2 != 0) {
|
||||||
plugin.getLogger().log(Level.WARNING, "[LanguageManager] Replacement data is uneven", new Exception());
|
plugin.getLogger().log(Level.WARNING, "[LanguageManager] Replacement data is uneven", new Exception());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user