mirror of
https://github.com/JamesPeters98/ChestsPlusPlus.git
synced 2025-01-15 21:01:30 +01:00
Update to 2.5 Release
Updated dependencies. Added newer Java language features
This commit is contained in:
parent
52c5dad1b3
commit
4173a855ed
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||
<artifactId>ChestsPlusPlus-Master</artifactId>
|
||||
<version>2.5-Beta</version>
|
||||
<version>2.5-Release</version>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:JamesPeters98/ChestsPlusPlus.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:JamesPeters98/ChestsPlusPlus.git</developerConnection>
|
||||
@ -132,7 +132,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.4</version>
|
||||
<version>3.12.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -144,13 +144,13 @@
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>18.0.0</version>
|
||||
<version>22.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.20</version>
|
||||
<version>1.18.22</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.jamesdpeters.minecraft.chests</groupId>
|
||||
<artifactId>ChestsPlusPlus-Master</artifactId>
|
||||
<version>2.5-Beta</version>
|
||||
<version>2.5-Release</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.target>16</maven.compiler.target>
|
||||
@ -71,7 +71,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.4</version>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -96,7 +96,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.7</version>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -157,7 +157,7 @@
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>18.0.0</version>
|
||||
<version>22.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@ -165,7 +165,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.20</version>
|
||||
<version>1.18.22</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -114,20 +114,18 @@ public class ChestsPlusPlus extends JavaPlugin {
|
||||
if (PluginConfig.IS_UPDATE_CHECKER_ENABLED.get()) {
|
||||
String BUKKIT_URL = "https://dev.bukkit.org/projects/chests-plus-plus/files";
|
||||
UpdateChecker.init(this, 71355, UpdateChecker.VERSION_SCHEME_DECIMAL);
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
|
||||
UpdateChecker.get().requestUpdateCheck().whenCompleteAsync((updateResult, throwable) -> {
|
||||
switch (updateResult.getReason()) {
|
||||
case NEW_UPDATE:
|
||||
Bukkit.broadcastMessage(ChatColor.RED + "[Chests++] New version of the plugin was found: " + updateResult.getNewestVersion());
|
||||
Bukkit.broadcastMessage(ChatColor.RED + "[Chests++] Download at: " + ChatColor.WHITE + BUKKIT_URL);
|
||||
break;
|
||||
case UP_TO_DATE:
|
||||
if (!boot) getLogger().info("Plugin is up to date! Thank you for supporting Chests++!");
|
||||
break;
|
||||
}
|
||||
boot = true;
|
||||
});
|
||||
}, 0, PluginConfig.UPDATE_CHECKER_PERIOD.get() * 20);
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> UpdateChecker.get().requestUpdateCheck().whenCompleteAsync((updateResult, throwable) -> {
|
||||
switch (updateResult.getReason()) {
|
||||
case NEW_UPDATE:
|
||||
Bukkit.broadcastMessage(ChatColor.RED + "[Chests++] New version of the plugin was found: " + updateResult.getNewestVersion());
|
||||
Bukkit.broadcastMessage(ChatColor.RED + "[Chests++] Download at: " + ChatColor.WHITE + BUKKIT_URL);
|
||||
break;
|
||||
case UP_TO_DATE:
|
||||
if (!boot) getLogger().info("Plugin is up to date! Thank you for supporting Chests++!");
|
||||
break;
|
||||
}
|
||||
boot = true;
|
||||
}), 0, PluginConfig.UPDATE_CHECKER_PERIOD.get() * 20);
|
||||
}
|
||||
|
||||
// Remove armour stands if disabled
|
||||
|
@ -60,12 +60,11 @@ public class AutoCraftCommand extends ServerCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage("Only a player can use this command");
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
if (args != null && args.length > 0) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
@ -184,8 +183,7 @@ public class AutoCraftCommand extends ServerCommand {
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if ((sender instanceof Player)) {
|
||||
Player player = (Player) sender;
|
||||
if ((sender instanceof Player player)) {
|
||||
|
||||
if (args.length == 1) {
|
||||
return OPTIONS.valuesList;
|
||||
@ -208,11 +206,12 @@ public class AutoCraftCommand extends ServerCommand {
|
||||
if (args.length == 3) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case MEMBER:
|
||||
case MEMBER -> {
|
||||
if (args[1].equals("add-to-all")) return Utils.filterList(Utils.getAllPlayers(), args[2]);
|
||||
if (args[1].equals("remove-from-all"))
|
||||
return Utils.filterList(Utils.getAllPlayers(), args[2]);
|
||||
return Config.getAutoCraft().getStorageList(player, args[2]);
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
|
@ -64,12 +64,11 @@ public class ChestLinkCommand extends ServerCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage("Only a player can use this command");
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
if (args != null && args.length > 0) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
@ -206,8 +205,7 @@ public class ChestLinkCommand extends ServerCommand {
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if ((sender instanceof Player)) {
|
||||
Player player = (Player) sender;
|
||||
if ((sender instanceof Player player)) {
|
||||
|
||||
if (args.length == 1) {
|
||||
return OPTIONS.valuesList;
|
||||
|
@ -49,11 +49,10 @@ public class ChestsPlusPlusCommand extends ServerCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage("Only a player can use this command");
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if (args != null && args.length > 0) {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case VERSION:
|
||||
@ -84,8 +83,7 @@ public class ChestsPlusPlusCommand extends ServerCommand {
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if ((sender instanceof Player)) {
|
||||
Player player = (Player) sender;
|
||||
if ((sender instanceof Player player)) {
|
||||
if (args.length == 1) {
|
||||
return OPTIONS.valuesList;
|
||||
}
|
||||
@ -101,7 +99,7 @@ public class ChestsPlusPlusCommand extends ServerCommand {
|
||||
if (args.length == 3) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case PARTY: {
|
||||
case PARTY -> {
|
||||
String arg = args[1];
|
||||
if (arg.equals("delete") || arg.equals("invite") || arg.equals("remove-member")) {
|
||||
List<String> strings = PartyUtils.getPlayerPartyStorage(player).getOwnedPartiesAsStrings();
|
||||
@ -115,7 +113,7 @@ public class ChestsPlusPlusCommand extends ServerCommand {
|
||||
if (args.length == 4) {
|
||||
try {
|
||||
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
|
||||
case PARTY: {
|
||||
case PARTY -> {
|
||||
String arg = args[2];
|
||||
if (arg.equals("invite") || arg.equals("remove-member")) {
|
||||
return Utils.filterList(Utils.getAllPlayers(), args[3]);
|
||||
|
@ -98,13 +98,12 @@ public class UserShapedRecipe {
|
||||
|
||||
private Map<Character, Character> flipShape(String[] shape) {
|
||||
Map<Character, Character> map = new HashMap<>();
|
||||
for (int i = 0; i < shape.length; i++) {
|
||||
for (String s : shape) {
|
||||
StringBuilder input = new StringBuilder();
|
||||
String row = shape[i];
|
||||
String reverse = input.append(row).reverse().toString();
|
||||
char[] originalChars = row.toCharArray();
|
||||
String reverse = input.append(s).reverse().toString();
|
||||
char[] originalChars = s.toCharArray();
|
||||
char[] reverseChars = reverse.toCharArray();
|
||||
for (int c = 0; c < row.length(); c++) {
|
||||
for (int c = 0; c < s.length(); c++) {
|
||||
map.put(originalChars[c], reverseChars[c]);
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,7 @@ public class HopperFilter {
|
||||
Collection<Entity> ent = block.getWorld().getNearbyEntities(block.getLocation(), 1.01, 1.01, 1.01);
|
||||
List<Filter> filters = new ArrayList<>(ent.size());
|
||||
for (Entity entity : ent) {
|
||||
if (entity instanceof ItemFrame) {
|
||||
ItemFrame frame = (ItemFrame) entity;
|
||||
if (entity instanceof ItemFrame frame) {
|
||||
if (frame.getItem().getType().equals(Material.AIR)) continue;
|
||||
Block attachedBlock = frame.getLocation().getBlock().getRelative(frame.getAttachedFace());
|
||||
if (block.equals(attachedBlock)) {
|
||||
|
@ -74,8 +74,7 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
List<RecipeChoice> choiceList = shapelessRecipe.getChoiceList();
|
||||
for (int i = 0; i < choiceList.size(); i++) {
|
||||
RecipeChoice recipeChoice = choiceList.get(i);
|
||||
if (recipeChoice instanceof RecipeChoice.MaterialChoice) {
|
||||
RecipeChoice.MaterialChoice materialChoice = (RecipeChoice.MaterialChoice) recipeChoice;
|
||||
if (recipeChoice instanceof RecipeChoice.MaterialChoice materialChoice) {
|
||||
ItemStack[] choices = materialChoice.getChoices().stream().map(ItemStack::new).toArray(ItemStack[]::new);
|
||||
recipeChoices[i] = choices;
|
||||
}
|
||||
@ -90,8 +89,7 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
int col = 0;
|
||||
for (char c : r.toCharArray()) {
|
||||
RecipeChoice recipeChoice = recipe.getChoiceMap().get(c);
|
||||
if (recipeChoice instanceof RecipeChoice.MaterialChoice) {
|
||||
RecipeChoice.MaterialChoice materialChoice = (RecipeChoice.MaterialChoice) recipeChoice;
|
||||
if (recipeChoice instanceof RecipeChoice.MaterialChoice materialChoice) {
|
||||
ItemStack[] choices = materialChoice.getChoices().stream().map(ItemStack::new).toArray(ItemStack[]::new);
|
||||
int i = (row * 3) + col;
|
||||
recipeChoices[i] = choices;
|
||||
@ -242,8 +240,7 @@ public class VirtualCraftingHolder implements InventoryHolder {
|
||||
|
||||
Inventory output;
|
||||
|
||||
if (blockBelow.getState() instanceof Hopper) {
|
||||
Hopper hopper = (Hopper) blockBelow.getState();
|
||||
if (blockBelow.getState() instanceof Hopper hopper) {
|
||||
if (blockBelow.isBlockPowered() || blockBelow.isBlockIndirectlyPowered()) {
|
||||
continue; //If hopper is powered no crafting should happen.
|
||||
}
|
||||
|
@ -43,11 +43,13 @@ public class LanguageFile extends Properties {
|
||||
if (generated) {
|
||||
writeComments(bw, " Chests++ Language File (Version " + BuildConstants.VERSION + ")");
|
||||
writeComments(bw,
|
||||
" NOTE: This file gets replaced when the plugin launches! If you want to make modifications create a copy first!\n" +
|
||||
" To create a new language file simply create a copy of this file and rename it to your desired choice for example 'en_US.properties'\n" +
|
||||
" It should be located in the 'lang' folder\n" +
|
||||
" Then in config.yml 'language-file: default' would be renamed to 'language-file: en_US'\n" +
|
||||
" To help contribute to the plugin and provide new language files you can create a pull-request at https://github.com/JamesPeters98/ChestsPlusPlus or join our Discord https://discord.gg/YRs3mP5");
|
||||
"""
|
||||
NOTE: This file gets replaced when the plugin launches! If you want to make modifications create a copy first!
|
||||
To create a new language file simply create a copy of this file and rename it to your desired choice for example 'en_US.properties'
|
||||
It should be located in the 'lang' folder
|
||||
Then in config.yml 'language-file: default' would be renamed to 'language-file: en_US'
|
||||
To help contribute to the plugin and provide new language files you can create a pull-request at https://github.com/JamesPeters98/ChestsPlusPlus or join our Discord https://discord.gg/YRs3mP5
|
||||
""".indent(1));
|
||||
|
||||
for (String additionalComment : additionalComments) {
|
||||
writeComments(bw, additionalComment);
|
||||
|
@ -48,8 +48,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
public void inventoryUpdate(InventoryInteractEvent event) {
|
||||
InventoryHolder holder = event.getInventory().getHolder();
|
||||
if (holder instanceof VirtualInventoryHolder) {
|
||||
VirtualInventoryHolder vHolder = (VirtualInventoryHolder) holder;
|
||||
if (holder instanceof VirtualInventoryHolder vHolder) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ChestsPlusPlus.PLUGIN, () -> {
|
||||
vHolder.getStorage().sort();
|
||||
vHolder.getStorage().onItemDisplayUpdate(InventorySorter.getMostCommonItem(event.getInventory()));
|
||||
|
@ -89,8 +89,7 @@ public class StorageListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onSignBreak(BlockBreakEvent event) {
|
||||
if (event.getBlock().getState() instanceof Sign) {
|
||||
Sign sign = (Sign) event.getBlock().getState();
|
||||
if (event.getBlock().getState() instanceof Sign sign) {
|
||||
//Get blockface of sign.
|
||||
if (sign.getBlockData() instanceof Directional) {
|
||||
|
||||
|
@ -110,15 +110,10 @@ public class PartySelectorMenu implements InventoryProvider {
|
||||
}
|
||||
|
||||
private List<PlayerParty> getParties(OfflinePlayer player) {
|
||||
switch (type) {
|
||||
case ALL:
|
||||
return PartyUtils.getPlayerPartyStorage(player).getAllParties();
|
||||
case OWNED:
|
||||
return PartyUtils.getPlayerPartyStorage(player).getOwnedPartiesList();
|
||||
case MEMBER_OF:
|
||||
return PartyUtils.getPlayerPartyStorage(player).getPartiesMemberOf();
|
||||
default:
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return switch (type) {
|
||||
case ALL -> PartyUtils.getPlayerPartyStorage(player).getAllParties();
|
||||
case OWNED -> PartyUtils.getPlayerPartyStorage(player).getOwnedPartiesList();
|
||||
case MEMBER_OF -> PartyUtils.getPlayerPartyStorage(player).getPartiesMemberOf();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -75,8 +75,7 @@ public class ItemBuilder {
|
||||
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
}
|
||||
|
||||
if (skullOwner != null && meta instanceof SkullMeta) {
|
||||
SkullMeta skullMeta = (SkullMeta) meta;
|
||||
if (skullOwner != null && meta instanceof SkullMeta skullMeta) {
|
||||
skullMeta.setOwningPlayer(skullOwner);
|
||||
}
|
||||
itemStack.setItemMeta(meta);
|
||||
|
@ -3,25 +3,26 @@ package com.jamesdpeters.minecraft.chests.misc;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.Config;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.PluginConfig;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
|
||||
public class Stats {
|
||||
|
||||
public static void addCharts(Metrics metrics) {
|
||||
metrics.addCustomChart(new Metrics.SimplePie("chestlink-amount", () -> {
|
||||
metrics.addCustomChart(new SimplePie("chestlink-amount", () -> {
|
||||
int chestlinks = Config.getChestLink().getTotalLocations();
|
||||
return chestlinks + "";
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("autocraft-amount", () -> {
|
||||
metrics.addCustomChart(new SimplePie("autocraft-amount", () -> {
|
||||
int locations = Config.getAutoCraft().getTotalLocations();
|
||||
return locations + "";
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("update_checker_setting", () -> {
|
||||
metrics.addCustomChart(new SimplePie("update_checker_setting", () -> {
|
||||
if (PluginConfig.IS_UPDATE_CHECKER_ENABLED.get()) return "enabled";
|
||||
else return "disabled";
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("language-file", PluginConfig.LANG_FILE::get));
|
||||
metrics.addCustomChart(new SimplePie("language-file", PluginConfig.LANG_FILE::get));
|
||||
}
|
||||
}
|
||||
|
@ -62,8 +62,7 @@ public class Utils {
|
||||
private static void containerAnimation(Inventory inventory, LocationInfo location, boolean open) {
|
||||
if (location != null && Utils.isLocationChunkLoaded(location.getLocation())) {
|
||||
Block block = location.getLocation().getBlock();
|
||||
if (block.getState() instanceof Container) {
|
||||
Container chest = (Container) block.getState();
|
||||
if (block.getState() instanceof Container chest) {
|
||||
if (open) {
|
||||
location.setTileEntityOpener(ApiSpecific.getChestOpener().updateState(inventory, chest, location.getTileEntityOpener()));
|
||||
} else {
|
||||
|
@ -35,8 +35,7 @@ public class ChestLinkVerifier extends BukkitRunnable {
|
||||
public void run() {
|
||||
Chest chest = (Chest) block.getState();
|
||||
|
||||
if (chest.getInventory().getHolder() instanceof DoubleChest) {
|
||||
DoubleChest doubleChest = (DoubleChest) chest.getInventory().getHolder();
|
||||
if (chest.getInventory().getHolder() instanceof DoubleChest doubleChest) {
|
||||
InventoryHolder right = doubleChest.getRightSide();
|
||||
InventoryHolder left = doubleChest.getLeftSide();
|
||||
if (isChestLinked(doubleChest) && left != null && right != null) {
|
||||
@ -80,8 +79,7 @@ public class ChestLinkVerifier extends BukkitRunnable {
|
||||
}
|
||||
|
||||
private void manualCheck(Chest chest) {
|
||||
if (chest.getBlockData() instanceof Directional) {
|
||||
Directional directional = (Directional) chest.getBlockData();
|
||||
if (chest.getBlockData() instanceof Directional directional) {
|
||||
BlockFace facing = directional.getFacing();
|
||||
BlockFace[] perpendulcarFaces = getPerpendicularFaces(facing);
|
||||
if (perpendulcarFaces == null) return;
|
||||
@ -100,14 +98,10 @@ public class ChestLinkVerifier extends BukkitRunnable {
|
||||
private static final BlockFace[] WE = new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH};
|
||||
|
||||
private BlockFace[] getPerpendicularFaces(BlockFace face) {
|
||||
switch (face) {
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
return NS;
|
||||
case WEST:
|
||||
case EAST:
|
||||
return WE;
|
||||
}
|
||||
return null;
|
||||
return switch (face) {
|
||||
case NORTH, SOUTH -> NS;
|
||||
case WEST, EAST -> WE;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -38,8 +38,7 @@ public class VirtualChestToHopper extends BukkitRunnable {
|
||||
if (!PluginConfig.SHOULD_RUN_HOPPERS_UNLOADED_CHUNKS.get() && !Utils.isLocationChunkLoaded(location.getLocation()))
|
||||
continue;
|
||||
Location below = location.getLocation().clone().subtract(0, 1, 0);
|
||||
if (below.getBlock().getState() instanceof Hopper) {
|
||||
Hopper hopper = (Hopper) below.getBlock().getState();
|
||||
if (below.getBlock().getState() instanceof Hopper hopper) {
|
||||
if (below.getBlock().isBlockIndirectlyPowered() || below.getBlock().isBlockPowered()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -119,9 +119,9 @@ public class Config {
|
||||
|
||||
try {
|
||||
Path path = Paths.get(legacyFile.toURI());
|
||||
String content = new String(Files.readAllBytes(path), Charsets.UTF_8);
|
||||
String content = Files.readString(path, Charsets.UTF_8);
|
||||
content = legacyContentConverter(content);
|
||||
Files.write(getStorageFile().toPath(), content.getBytes(Charsets.UTF_8));
|
||||
Files.writeString(getStorageFile().toPath(), content, Charsets.UTF_8);
|
||||
legacyFile.createNewFile();
|
||||
legacyFile.delete();
|
||||
} catch (IOException e) {
|
||||
@ -139,9 +139,9 @@ public class Config {
|
||||
private void configConverter() {
|
||||
try {
|
||||
Path path = Paths.get(getStorageFile().toURI());
|
||||
String content = new String(Files.readAllBytes(path), Charsets.UTF_8);
|
||||
String content = Files.readString(path, Charsets.UTF_8);
|
||||
content = content.replaceAll("==: Recipe", "==: C++Recipe");
|
||||
Files.write(getStorageFile().toPath(), content.getBytes(Charsets.UTF_8));
|
||||
Files.writeString(getStorageFile().toPath(), content, Charsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -287,8 +287,7 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
BlockFace face = getStorageType().getStorageFacing(block);
|
||||
if (face != null) {
|
||||
Block signBlock = block.getRelative(face);
|
||||
if (signBlock.getState() instanceof Sign) {
|
||||
Sign sign = (Sign) signBlock.getState();
|
||||
if (signBlock.getState() instanceof Sign sign) {
|
||||
sign.setLine(1, ChatColor.GREEN + ChatColor.stripColor("[" + newName + "]"));
|
||||
sign.update();
|
||||
}
|
||||
@ -407,8 +406,7 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
List<LocationInfo> locationInfos = locationInfoList.stream().filter(locationInfo -> locationInfo.isInWorld(player)).collect(Collectors.toList()); // Create a utility method for this
|
||||
locationInfos.forEach(locationInfo -> {
|
||||
if (Utils.isLocationInViewDistance(player, locationInfo.getSignLocation())) {
|
||||
if (locationInfo.getSignLocation().getBlock().getState() instanceof Sign) {
|
||||
Sign sign = (Sign) locationInfo.getSignLocation().getBlock().getState();
|
||||
if (locationInfo.getSignLocation().getBlock().getState() instanceof Sign sign) {
|
||||
player.sendBlockChange(locationInfo.getSignLocation(), sign.getBlockData());
|
||||
player.sendSignChange(locationInfo.getSignLocation(), sign.getLines());
|
||||
}
|
||||
|
@ -27,8 +27,7 @@ public class StorageInfo<T extends AbstractStorage> {
|
||||
this.player = Bukkit.getOfflinePlayer(playerUUID);
|
||||
this.storage = storageType.getStorage(playerUUID, group);
|
||||
if (storage == null) {
|
||||
if (sign.getBlockData() instanceof Directional) {
|
||||
Directional directional = (Directional) sign.getBlockData();
|
||||
if (sign.getBlockData() instanceof Directional directional) {
|
||||
BlockFace storageFace = directional.getFacing().getOppositeFace();
|
||||
Block storageBlock = sign.getBlock().getRelative(storageFace);
|
||||
Player player = Bukkit.getPlayer(playerUUID);
|
||||
|
@ -49,8 +49,7 @@ public class ChestLinkStorage extends AbstractStorage implements ConfigurationSe
|
||||
this.sortMethod = SortMethod.OFF;
|
||||
|
||||
Block block = location.getBlock();
|
||||
if (block.getState() instanceof Container) {
|
||||
Container container = (Container) block.getState();
|
||||
if (block.getState() instanceof Container container) {
|
||||
getInventory().setContents(container.getInventory().getContents());
|
||||
container.getInventory().clear();
|
||||
updateDisplayItem();
|
||||
@ -103,8 +102,7 @@ public class ChestLinkStorage extends AbstractStorage implements ConfigurationSe
|
||||
@Override
|
||||
public void onStorageAdded(Block block, Player player) {
|
||||
//Migrates that chest into InventoryStorage and if full drops it at the chest location.
|
||||
if (block.getState() instanceof Container) {
|
||||
Container chest = (Container) block.getState();
|
||||
if (block.getState() instanceof Container chest) {
|
||||
boolean hasOverflow = false;
|
||||
for (ItemStack chestItem : chest.getInventory().getContents()) {
|
||||
if (chestItem != null) {
|
||||
@ -149,10 +147,9 @@ public class ChestLinkStorage extends AbstractStorage implements ConfigurationSe
|
||||
public ClickableItem getClickableItem(Player player) {
|
||||
return ClickableItem.from(getIventoryIcon(player), event -> {
|
||||
InventoryHolder inventoryHolder = getInventory().getHolder();
|
||||
if (inventoryHolder instanceof VirtualInventoryHolder) {
|
||||
((VirtualInventoryHolder) inventoryHolder).setPreviousInventory(() -> {
|
||||
Bukkit.getScheduler().runTask(ChestsPlusPlus.PLUGIN, () -> ChestLinkMenu.getMenu(player).openLastPage(player));
|
||||
});
|
||||
if (inventoryHolder instanceof VirtualInventoryHolder virtualInventoryHolder) {
|
||||
virtualInventoryHolder.setPreviousInventory(() ->
|
||||
Bukkit.getScheduler().runTask(ChestsPlusPlus.PLUGIN, () -> ChestLinkMenu.getMenu(player).openLastPage(player)));
|
||||
}
|
||||
Utils.openChestInventory(player, getInventory());
|
||||
});
|
||||
|
@ -68,8 +68,7 @@ public class ChestLinkStorageType extends StorageType<ChestLinkStorage> {
|
||||
}
|
||||
|
||||
private void createStorageForBlock(Player player, OfflinePlayer owner, Block block, String identifier, boolean requireSign) {
|
||||
if (block.getBlockData() instanceof Directional) {
|
||||
Directional chest = (Directional) block.getBlockData();
|
||||
if (block.getBlockData() instanceof Directional chest) {
|
||||
BlockFace facing = chest.getFacing();
|
||||
Block toReplace = block.getRelative(facing);
|
||||
placeSign(block, toReplace, facing, player, owner, identifier, Values.ChestLinkTag, requireSign);
|
||||
@ -98,8 +97,7 @@ public class ChestLinkStorageType extends StorageType<ChestLinkStorage> {
|
||||
|
||||
@Override
|
||||
public BlockFace getStorageFacing(Block block) {
|
||||
if (block.getBlockData() instanceof Directional) {
|
||||
Directional chest = (Directional) block.getBlockData();
|
||||
if (block.getBlockData() instanceof Directional chest) {
|
||||
return chest.getFacing();
|
||||
}
|
||||
return null;
|
||||
|
@ -1,9 +1,10 @@
|
||||
# Chests++ Language File (Version 2.5-Beta)
|
||||
# Chests++ Language File (Version 2.5-Release)
|
||||
# NOTE: This file gets replaced when the plugin launches! If you want to make modifications create a copy first!
|
||||
# To create a new language file simply create a copy of this file and rename it to your desired choice for example 'en_US.properties'
|
||||
# It should be located in the 'lang' folder
|
||||
# Then in config.yml 'language-file: default' would be renamed to 'language-file: en_US'
|
||||
# To help contribute to the plugin and provide new language files you can create a pull-request at https://github.com/JamesPeters98/ChestsPlusPlus or join our Discord https://discord.gg/YRs3mP5
|
||||
#
|
||||
ADDED_MEMBER = Successfully added {player_name} to {storage_type} group {storage_identifier}
|
||||
ADDED_MEMBER_TO_ALL = Successfully added {player_name} to all {storage_type} groups
|
||||
ALREADY_EXISTS_ANVIL = Already exists\!
|
||||
|
@ -24,12 +24,12 @@
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.9.0</version>
|
||||
<version>4.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.0</version>
|
||||
<version>2.8.9</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
Loading…
Reference in New Issue
Block a user