Fixed issues on java 8

This commit is contained in:
Jules 2023-11-25 14:59:04 +01:00
parent 81efe1abcd
commit 0b57a2d47a
10 changed files with 58 additions and 77 deletions

View File

@ -12,26 +12,11 @@
<artifactId>MMOItems-API</artifactId> <artifactId>MMOItems-API</artifactId>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
<build> <build>
<finalName>${project.name}-${project.version}</finalName> <finalName>${project.name}-${project.version}</finalName>
<defaultGoal>clean package install</defaultGoal> <defaultGoal>clean package install</defaultGoal>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- <!--
This flattens the pom.xml from the API module as well so that it can be uploaded This flattens the pom.xml from the API module as well so that it can be uploaded

View File

@ -36,10 +36,10 @@ public class ItemSet {
for (int j = 2; j <= itemLimit; j++) for (int j = 2; j <= itemLimit; j++)
if (config.getConfigurationSection("bonuses").contains(String.valueOf(j))) { if (config.getConfigurationSection("bonuses").contains(String.valueOf(j))) {
final String bonusesKey = "bonuses.%d".formatted(j); final String bonusesKey = String.format("bonuses.%d", j);
final SetBonuses bonuses = new SetBonuses(); final SetBonuses bonuses = new SetBonuses();
final ConfigurationSection bonusesSection = config.getConfigurationSection(bonusesKey); final ConfigurationSection bonusesSection = config.getConfigurationSection(bonusesKey);
Validate.notNull(bonusesSection, "Item set '%s' is not a valid configuration section.".formatted(id)); Validate.notNull(bonusesSection, String.format("Item set '%s' is not a valid configuration section.", id));
// Add permissions // Add permissions
for (String perm : bonusesSection.getStringList("granted-permissions")) for (String perm : bonusesSection.getStringList("granted-permissions"))
@ -52,8 +52,8 @@ public class ItemSet {
// ability // ability
if (key.startsWith("ability-")) { if (key.startsWith("ability-")) {
final ConfigurationSection section = config.getConfigurationSection("%s.%s".formatted(bonusesKey, key)); final ConfigurationSection section = config.getConfigurationSection(String.format("%s.%s", bonusesKey, key));
Validate.notNull(section, "Ability '%s' is not a valid configuration section.".formatted(key)); Validate.notNull(section, String.format("Ability '%s' is not a valid configuration section.", key));
bonuses.addAbility(new AbilityData(section)); bonuses.addAbility(new AbilityData(section));
continue; continue;
} }
@ -61,26 +61,26 @@ public class ItemSet {
// potion effect // potion effect
if (key.startsWith("potion-")) { if (key.startsWith("potion-")) {
PotionEffectType potionEffectType = PotionEffectType.getByName(format.substring("potion-".length())); PotionEffectType potionEffectType = PotionEffectType.getByName(format.substring("potion-".length()));
Validate.notNull(potionEffectType, "Could not load potion effect type from '%s'".formatted(format)); Validate.notNull(potionEffectType, String.format("Could not load potion effect type from '%s'", format));
bonuses.addPotionEffect(new PotionEffect(potionEffectType, MMOUtils.getEffectDuration(potionEffectType), bonuses.addPotionEffect(new PotionEffect(potionEffectType, MMOUtils.getEffectDuration(potionEffectType),
config.getInt("%s.%s".formatted(bonusesKey, key)) - 1, true, false)); config.getInt(String.format("%s.%s", bonusesKey, key)) - 1, true, false));
continue; continue;
} }
// particle effect // particle effect
if (key.startsWith("particle-")) { if (key.startsWith("particle-")) {
final ConfigurationSection section = config.getConfigurationSection("bonuses.%d.%s".formatted(j, key)); final ConfigurationSection section = config.getConfigurationSection(String.format("bonuses.%d.%s", j, key));
Validate.notNull(section, "Particle effect '%s' is not a valid configuration section.".formatted(key)); Validate.notNull(section, String.format("Particle effect '%s' is not a valid configuration section.", key));
bonuses.addParticle(new ParticleData(section)); bonuses.addParticle(new ParticleData(section));
continue; continue;
} }
// stat // stat
ItemStat<?, ?> stat = MMOItems.plugin.getStats().get(format); ItemStat<?, ?> stat = MMOItems.plugin.getStats().get(format);
Validate.notNull(stat, "Could not find stat called '%s'".formatted(format)); Validate.notNull(stat, String.format("Could not find stat called '%s'", format));
bonuses.addStat(stat, config.getDouble("bonuses.%d.%s".formatted(j, key))); bonuses.addStat(stat, config.getDouble(String.format("bonuses.%d.%s", j, key)));
} catch (IllegalArgumentException exception) { } catch (IllegalArgumentException exception) {
throw new IllegalArgumentException("Could not load set bonus '%s': %s".formatted(key, exception.getMessage())); throw new IllegalArgumentException(String.format("Could not load set bonus '%s': %s", key, exception.getMessage()));
} }
} }

View File

@ -5,8 +5,10 @@ import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
// TODO: 2/13/2021 Remove this eventually. @Deprecated
public class NamedItemStack extends ItemStack { public class NamedItemStack extends ItemStack {
@Deprecated
public NamedItemStack(Material material, String name) { public NamedItemStack(Material material, String name) {
super(material); super(material);

View File

@ -87,10 +87,10 @@ public class ItemBrowser extends PluginInventory {
ItemStack item = currentType.getItem(); ItemStack item = currentType.getItem();
item.setAmount(Math.max(1, Math.min(64, items))); item.setAmount(Math.max(1, Math.min(64, items)));
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
AdventureUtils.setDisplayName(meta, "&a%s&8 (lick to browse)".formatted(currentType.getName())); AdventureUtils.setDisplayName(meta, String.format("&a%s&8 (lick to browse)", currentType.getName()));
meta.addItemFlags(ItemFlag.values()); meta.addItemFlags(ItemFlag.values());
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
lore.add("&7&oThere %s %s &7&oitem%s in that currentType.".formatted(items == 1 ? "is" : "are", items < 1 ? "&c&ono" : "&6&o%d".formatted(items), items == 1 ? "" : "s")); lore.add(String.format("&7&oThere %s %s &7&oitem%s in that currentType.", items == 1 ? "is" : "are", items < 1 ? "&c&ono" : "&6&o" + items, items == 1 ? "" : "s"));
AdventureUtils.setLore(meta, lore); AdventureUtils.setLore(meta, lore);
item.setItemMeta(meta); item.setItemMeta(meta);

View File

@ -1,20 +1,19 @@
package net.Indyuce.mmoitems.gui.edition; package net.Indyuce.mmoitems.gui.edition;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.api.util.ItemFactory;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.util.NamedItemStack;
import net.Indyuce.mmoitems.util.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
@ -23,7 +22,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class UpgradingEdition extends EditionInventory { public class UpgradingEdition extends EditionInventory {
private static final ItemStack notAvailable = new NamedItemStack(VersionMaterial.RED_STAINED_GLASS_PANE.toMaterial(), "&cNot Available"); private static final ItemStack notAvailable = ItemFactory.of(Material.RED_STAINED_GLASS_PANE).name("&cNot Available").build();
public UpgradingEdition(Player player, MMOItemTemplate template) { public UpgradingEdition(Player player, MMOItemTemplate template) {
super(player, template); super(player, template);

View File

@ -25,10 +25,10 @@ public class SetManager implements Reloadable {
try { try {
final ConfigurationSection section = config.getConfig().getConfigurationSection(id); final ConfigurationSection section = config.getConfig().getConfigurationSection(id);
if (section == null) if (section == null)
throw new IllegalStateException("Item set '%s' is not a valid configuration section.".formatted(id)); throw new IllegalStateException(String.format("Item set '%s' is not a valid configuration section.", id));
itemSets.put(id, new ItemSet(section)); itemSets.put(id, new ItemSet(section));
} catch (IllegalArgumentException exception) { } catch (IllegalArgumentException exception) {
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load item set '%s': %s".formatted(id, exception.getMessage())); MMOItems.plugin.getLogger().log(Level.WARNING, String.format("Could not load item set '%s': %s", id, exception.getMessage()));
} }
} }

View File

@ -57,7 +57,7 @@ public class ItemSetStat extends StringStat implements GemStoneStat {
@Override @Override
public ArrayList<ItemTag> getAppliedNBT(@NotNull StringData data) { public ArrayList<ItemTag> getAppliedNBT(@NotNull StringData data) {
ItemSet set = MMOItems.plugin.getSets().get(data.toString()); ItemSet set = MMOItems.plugin.getSets().get(data.toString());
Validate.notNull(set, "Could not find item set with ID '%s'".formatted(data)); Validate.notNull(set, String.format("Could not find item set with ID '%s'", data));
// Make Array // Make Array
ArrayList<ItemTag> ret = new ArrayList<>(); ArrayList<ItemTag> ret = new ArrayList<>();
@ -78,7 +78,7 @@ public class ItemSetStat extends StringStat implements GemStoneStat {
@Override @Override
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) { public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
ItemSet set = MMOItems.plugin.getSets().get(message); ItemSet set = MMOItems.plugin.getSets().get(message);
Validate.notNull(set, "Couldn't find the set named '%s'.".formatted(message)); Validate.notNull(set, String.format("Couldn't find the set named '%s'.", message));
super.whenInput(inv, message, info); super.whenInput(inv, message, info);
} }
} }

View File

@ -28,6 +28,6 @@ public class PluginUtils {
if (Bukkit.getPluginManager().getPlugin(name) == null) if (Bukkit.getPluginManager().getPlugin(name) == null)
return; return;
callback.accept(null); callback.accept(null);
MMOItems.plugin.getLogger().log(Level.INFO, "Hooked onto %s".formatted(name)); MMOItems.plugin.getLogger().log(Level.INFO, String.format("Hooked onto %s", name));
} }
} }

View File

@ -12,11 +12,6 @@
<artifactId>MMOItems-Dist</artifactId> <artifactId>MMOItems-Dist</artifactId>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
<!-- Dependencies --> <!-- Dependencies -->
<dependencies> <dependencies>

70
pom.xml
View File

@ -22,6 +22,41 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties> </properties>
<!-- Build -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!--
Clears all 'target' folders before building the plugin again.
This prevents MythicLib from including old versions of previous
classes when building the same version again
-->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- Repositories --> <!-- Repositories -->
<repositories> <repositories>
<repository> <repository>
@ -67,39 +102,4 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<!-- Build -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!--
Clears all 'target' folders before building the plugin again.
This prevents MythicLib from including old versions of previous
classes when building the same version again
-->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>