Skip to content

Commit

Permalink
update (dependencies) to 1.21 and Java 21 - please note: our tests ar…
Browse files Browse the repository at this point in the history
…e even more broken, since MockBukkit is not up-to-date yet.
  • Loading branch information
FireInstall committed Jul 19, 2024
1 parent 798964e commit 05c760c
Show file tree
Hide file tree
Showing 47 changed files with 192 additions and 183 deletions.
45 changes: 22 additions & 23 deletions Minigames/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>au.com.mineauz</groupId>
<artifactId>MinigamesProject</artifactId>
<version>1.20-SNAPSHOT</version>
<version>1.21-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>Minigames</artifactId>
Expand Down Expand Up @@ -76,7 +76,7 @@
<dependency>
<groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit-v1.20</artifactId>
<version>3.87.0</version>
<version>3.93.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand All @@ -88,7 +88,7 @@
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.4.0</version>
<version>9.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -100,7 +100,7 @@
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.5</version>
<version>2.11.6</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand All @@ -117,13 +117,13 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<version>3.15.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.11.0</version>
<version>1.12.0</version>
</dependency>
<!-- part of org.apache.commons -->
<dependency>
Expand All @@ -135,7 +135,7 @@
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.3.0-SNAPSHOT</version>
<version>7.3.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -180,7 +180,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version>
<version>3.6.0</version>
<configuration>
<filters>
<filter>
Expand Down Expand Up @@ -222,7 +222,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -236,7 +236,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<version>3.3.1</version>
<configuration>
<skipTests>true</skipTests>
<forkCount>1</forkCount>
Expand All @@ -246,19 +246,19 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.1</version>
<version>3.7.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.16.1</version>
<version>2.17.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -314,21 +314,20 @@
<configuration>
<apiToken>${codacy.api.token}</apiToken>
<projectToken>9a3fb2fe5b374cb5ad11e69df7db98fb</projectToken>
<coverageReportFile>${project.build.directory}/site/jacoco/jacoco.xml
</coverageReportFile>
<coverageReportFile>${project.build.directory}/site/jacoco/jacoco.xml</coverageReportFile>
<commit>${travis.commit}</commit>
<codacyApiBaseUrl>https://api.codacy.com</codacyApiBaseUrl>
<failOnMissingReportFile>false</failOnMissingReportFile>
</configuration>
<!--Disabled as Codacy parser fails with jococo reports.-->
<!--<executions>
<execution>
<id>upload</id>
<phase>verify</phase>
<goals>
<goal>coverage</goal>
</goals>
</execution>
<execution>
<id>post-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>coverage</goal>
</goals>
</execution>
</executions>-->
</plugin>
</plugins>
Expand Down
25 changes: 15 additions & 10 deletions Minigames/src/main/java/au/com/mineauz/minigames/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import org.jetbrains.annotations.NotNull;

import java.io.File;
Expand Down Expand Up @@ -666,7 +667,7 @@ private void clickMenu(@NotNull InventoryClickEvent event) {
switch (event.getAction()) {
case NOTHING, DROP_ALL_CURSOR, DROP_ONE_CURSOR, CLONE_STACK, UNKNOWN -> {
} // nothing
case PICKUP_ALL, PICKUP_SOME, PICKUP_HALF, PICKUP_ONE, DROP_ALL_SLOT, DROP_ONE_SLOT, HOTBAR_MOVE_AND_READD, // may take
case PICKUP_ALL, PICKUP_SOME, PICKUP_HALF, PICKUP_ONE, DROP_ALL_SLOT, DROP_ONE_SLOT, // may take
PLACE_ALL, PLACE_SOME, PLACE_ONE, /*may place*/
SWAP_WITH_CURSOR, HOTBAR_SWAP /*may give and take*/ -> {
if (event.getClickedInventory() == topInv) {
Expand Down Expand Up @@ -780,7 +781,7 @@ private void breakScoreboard(@NotNull BlockBreakEvent event) {
Block block = event.getBlock();
if (Tag.WALL_SIGNS.isTagged(block.getType())) {
if (block.hasMetadata("MGScoreboardSign")) {
Minigame minigame = (Minigame) block.getMetadata("Minigame").get(0).value();
Minigame minigame = (Minigame) block.getMetadata("Minigame").getFirst().value();
minigame.getScoreboardData().removeDisplay(block);
}
}
Expand All @@ -799,7 +800,7 @@ private void potionAffectsPlayer(@NotNull PotionSplashEvent event) {
.filter(p -> pdata.getMinigamePlayer(p).getMinigame() == mgPlayer.getMinigame())
.toList();
if (list.isEmpty()) return;
List<PotionEffectType> effects = event.getPotion().getEffects().stream().map(PotionEffect::getType).toList();
Collection<PotionEffect> effects = event.getPotion().getEffects();
list.stream().filter(Predicate.not(p -> isEffectApplicable(effects, mgPlayer, pdata.getMinigamePlayer(p)))).forEach(p -> event.setIntensity(p, 0.0));
}
}
Expand All @@ -818,22 +819,26 @@ private void effectAreaAffectsPlayer(@NotNull AreaEffectCloudApplyEvent event) {
.map(p -> (Player) p)
.toList();
if (list.isEmpty()) return;
List<PotionEffectType> effects = List.of(event.getEntity().getBasePotionData().getType().getEffectType());
event.getAffectedEntities().removeAll(list.stream().filter(Predicate.not(p -> isEffectApplicable(effects, mgPlayer, pdata.getMinigamePlayer(p)))).toList());
PotionType basePotionType = event.getEntity().getBasePotionType();
if (basePotionType != null) {
@NotNull List<PotionEffect> effects = basePotionType.getPotionEffects();
event.getAffectedEntities().removeAll(list.stream().filter(Predicate.not(p ->
isEffectApplicable(effects, mgPlayer, pdata.getMinigamePlayer(p)))).toList());
}
}

private boolean isEffectApplicable(@NotNull Collection<@NotNull PotionEffectType> effectTypes,
private boolean isEffectApplicable(@NotNull Collection<@NotNull PotionEffect> effectTypes,
@NotNull MinigamePlayer mgPlayerEffecting, @NotNull MinigamePlayer mgPlayerReceiving) {
if (mgPlayerEffecting.getMinigame().isTeamGame()) {
if (mgPlayerEffecting.getTeam() == mgPlayerReceiving.getTeam()) {
return effectTypes.stream().noneMatch(s -> s.getEffectCategory() == PotionEffectType.Category.HARMFUL);
return effectTypes.stream().noneMatch(s -> s.getType().getEffectCategory() == PotionEffectType.Category.HARMFUL);
} else {
return effectTypes.stream().anyMatch(s -> s.getEffectCategory() == PotionEffectType.Category.BENEFICIAL);
return effectTypes.stream().anyMatch(s -> s.getType().getEffectCategory() == PotionEffectType.Category.BENEFICIAL);
}
} else if (mgPlayerEffecting == mgPlayerReceiving) {
return effectTypes.stream().noneMatch(s -> s.getEffectCategory() == PotionEffectType.Category.HARMFUL);
return effectTypes.stream().noneMatch(s -> s.getType().getEffectCategory() == PotionEffectType.Category.HARMFUL);
} else {
return effectTypes.stream().noneMatch(s -> s.getEffectCategory() == PotionEffectType.Category.BENEFICIAL);
return effectTypes.stream().noneMatch(s -> s.getType().getEffectCategory() == PotionEffectType.Category.BENEFICIAL);
}
}
}
14 changes: 11 additions & 3 deletions Minigames/src/main/java/au/com/mineauz/minigames/Minigames.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import org.bstats.charts.MultiLineChart;
import org.bstats.charts.SimpleBarChart;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.command.PluginCommand;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.ConfigurationSection;
Expand Down Expand Up @@ -150,8 +152,14 @@ public void onDisable() {
}
if (!loadout.getAllPotionEffects().isEmpty()) {
for (final PotionEffect eff : loadout.getAllPotionEffects()) {
globalConfig.set(loadout.getName() + globalPathSeparator + "potions" + globalPathSeparator + eff.getType().getName() + globalPathSeparator + "amp", eff.getAmplifier());
globalConfig.set(loadout.getName() + globalPathSeparator + "potions" + globalPathSeparator + eff.getType().getName() + globalPathSeparator + "dur", eff.getDuration());
globalConfig.set(loadout.getName() +
globalPathSeparator + "potions" +
globalPathSeparator + eff.getType().getKey().getKey() +
globalPathSeparator + "amp", eff.getAmplifier());
globalConfig.set(loadout.getName() +
globalPathSeparator + "potions" +
globalPathSeparator + eff.getType().getKey().getKey() +
globalPathSeparator + "dur", eff.getDuration());
}
} else {
globalConfig.set(loadout.getName() + globalPathSeparator + "potions", null);
Expand Down Expand Up @@ -276,7 +284,7 @@ private void setupLoadOuts() {
if (potionLoadOutSection != null) {
final Set<String> pots = potionLoadOutSection.getKeys(false);
for (final String eff : pots) {
PotionEffectType type = PotionEffectType.getByName(eff);
PotionEffectType type = Registry.EFFECT.get(NamespacedKey.fromString(eff));
if (type != null) {
final PotionEffect effect = new PotionEffect(type,
globalConfig.getInt(loadoutName + globalPathSeparator + "potions" + globalPathSeparator + eff + globalPathSeparator + "dur"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Component getUsage() {
public boolean onCommand(@NotNull CommandSender sender,
@NotNull String @NotNull [] args) {
if (args.length > 0) {
switch (args[0].toUpperCase()) {
switch (args[0].toUpperCase()) { //todo
case "ON" -> {
if (Minigames.getPlugin().isDebugging()) {
sender.sendMessage(ChatColor.GRAY + "Debug mode already active.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ public boolean onCommand(@NotNull CommandSender sender,
Component.join(JoinConfiguration.commas(true), mgs.stream().map(Minigame::getDisplayName).toList())));

} else {
TreasureHuntModule thm = TreasureHuntModule.getMinigameModule(mgs.get(0));
TreasureHuntModule thm = TreasureHuntModule.getMinigameModule(mgs.getFirst());
if (thm != null && thm.hasTreasureLocation() && !thm.isTreasureFound()) {
thm.getHints(player);
} else {
MinigameMessageManager.sendMgMessage(sender, MinigameMessageType.ERROR, MgMiscLangKey.MINIGAME_ERROR_NOTSTARTED,
Placeholder.unparsed(MinigamePlaceHolderKey.MINIGAME.getKey(), mgs.get(0).getName()));
Placeholder.unparsed(MinigamePlaceHolderKey.MINIGAME.getKey(), mgs.getFirst().getName()));
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public boolean onCommand(@NotNull CommandSender sender,
} else {
List<Player> playerMatch = Bukkit.matchPlayer(args[0]);
if (!playerMatch.isEmpty()) {
MinigamePlayer mgPlayer = Minigames.getPlugin().getPlayerManager().getMinigamePlayer(playerMatch.get(0));
MinigamePlayer mgPlayer = Minigames.getPlugin().getPlayerManager().getMinigamePlayer(playerMatch.getFirst());

if (mgPlayer.isInMinigame()) {
TextComponent.Builder message = Component.text();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public boolean onCommand(@NotNull CommandSender sender,
Placeholder.unparsed(MinigamePlaceHolderKey.TEXT.getKey(), args[0]));
return true;
} else {
mgPlayer = PLUGIN.getPlayerManager().getMinigamePlayer(players.get(0));
mgPlayer = PLUGIN.getPlayerManager().getMinigamePlayer(players.getFirst());
}

if (mgPlayer.isInMinigame()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import org.jetbrains.annotations.Nullable;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -99,7 +101,7 @@ public boolean onCommand(final @NotNull CommandSender sender, @NotNull String @N
case "addnew" -> {
if (args.length >= 3) {
try {
URL url = new URL(args[2]);
URL url = new URI(args[2]).toURL();
final ResourcePack newPack = new ResourcePack(MiniMessage.miniMessage().deserialize(args[1]), url);
PLUGIN.getServer().getScheduler().runTaskLaterAsynchronously(PLUGIN, () -> {
if (newPack.isValid()) {
Expand All @@ -112,7 +114,7 @@ public boolean onCommand(final @NotNull CommandSender sender, @NotNull String @N
}, 100);
return true;

} catch (MalformedURLException e) {
} catch (MalformedURLException | URISyntaxException e) {
MinigameMessageManager.sendMgMessage(sender, MinigameMessageType.ERROR, MgCommandLangKey.COMMAND_RESSOUCEPACK_ADDRESOURCE_ERROR_BADURL);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public boolean onCommand(@NotNull CommandSender sender,
if (color == null) {
List<Player> plys = PLUGIN.getServer().matchPlayer(args[1]);
if (!plys.isEmpty()) {
mgPlayer = PLUGIN.getPlayerManager().getMinigamePlayer(plys.get(0));
mgPlayer = PLUGIN.getPlayerManager().getMinigamePlayer(plys.getFirst());
} else {
MinigameMessageManager.sendMgMessage(sender, MinigameMessageType.ERROR, MgCommandLangKey.COMMAD_ERROR_NOTPLAYER,
Placeholder.unparsed(MinigamePlaceHolderKey.TEXT.getKey(), args[1]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public boolean onCommand(@NotNull CommandSender sender,
List<Player> plys = PLUGIN.getServer().matchPlayer(args[0]);
MinigamePlayer mgPlayer;
if (!plys.isEmpty()) {
mgPlayer = PLUGIN.getPlayerManager().getMinigamePlayer(plys.get(0));
mgPlayer = PLUGIN.getPlayerManager().getMinigamePlayer(plys.getFirst());
} else {
MinigameMessageManager.sendMgMessage(sender, MinigameMessageType.ERROR, MgCommandLangKey.COMMAD_ERROR_NOTPLAYER,
Placeholder.unparsed(MinigamePlaceHolderKey.TEXT.getKey(), args[0]));
Expand Down Expand Up @@ -184,7 +184,7 @@ public boolean onCommand(@NotNull CommandSender sender,
MinigamePlayer mgPlayer2;

if (!plys.isEmpty()) {
mgPlayer2 = PLUGIN.getPlayerManager().getMinigamePlayer(plys.get(0));
mgPlayer2 = PLUGIN.getPlayerManager().getMinigamePlayer(plys.getFirst());
} else {
MinigameMessageManager.sendMgMessage(sender, MinigameMessageType.ERROR, MgCommandLangKey.COMMAD_ERROR_NOTPLAYER,
Placeholder.unparsed(MinigamePlaceHolderKey.TEXT.getKey(), args[1]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ public class SetHintDelayCommand extends ASetCommand {
return "hintdelay";
}

@Override
public @NotNull String @Nullable [] getAliases() {
return null;
}

@Override
public boolean canBeConsole() {
return true;
Expand Down
Loading

0 comments on commit 05c760c

Please sign in to comment.