Skip to content

Commit b9d4bfb

Browse files
committed
Revert "🤖 Apply quick-fixes by Qodana"
This reverts commit f0c4d9d.
1 parent b8f93eb commit b9d4bfb

File tree

57 files changed

+573
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+573
-191
lines changed

‎mongo-connector/src/main/java/net/codingarea/commons/common/config/document/BsonDocument.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public String getString(@Nonnull String path) {
8080
@Override
8181
public long getLong(@Nonnull String path, long def) {
8282
try {
83-
return Long.parseLong(Objects.requireNonNull(getString(path)));
83+
return Long.parseLong(getString(path));
8484
} catch (Exception ex) {
8585
return def;
8686
}
@@ -89,7 +89,7 @@ public long getLong(@Nonnull String path, long def) {
8989
@Override
9090
public int getInt(@Nonnull String path, int def) {
9191
try {
92-
return Integer.parseInt(Objects.requireNonNull(getString(path)));
92+
return Integer.parseInt(getString(path));
9393
} catch (Exception ex) {
9494
return def;
9595
}
@@ -98,7 +98,7 @@ public int getInt(@Nonnull String path, int def) {
9898
@Override
9999
public short getShort(@Nonnull String path, short def) {
100100
try {
101-
return Short.parseShort(Objects.requireNonNull(getString(path)));
101+
return Short.parseShort(getString(path));
102102
} catch (Exception ex) {
103103
return def;
104104
}
@@ -107,7 +107,7 @@ public short getShort(@Nonnull String path, short def) {
107107
@Override
108108
public byte getByte(@Nonnull String path, byte def) {
109109
try {
110-
return Byte.parseByte(Objects.requireNonNull(getString(path)));
110+
return Byte.parseByte(getString(path));
111111
} catch (Exception ex) {
112112
return def;
113113
}
@@ -116,7 +116,7 @@ public byte getByte(@Nonnull String path, byte def) {
116116
@Override
117117
public double getDouble(@Nonnull String path, double def) {
118118
try {
119-
return Double.parseDouble(Objects.requireNonNull(getString(path)));
119+
return Double.parseDouble(getString(path));
120120
} catch (Exception ex) {
121121
return def;
122122
}
@@ -125,7 +125,7 @@ public double getDouble(@Nonnull String path, double def) {
125125
@Override
126126
public float getFloat(@Nonnull String path, float def) {
127127
try {
128-
return Float.parseFloat(Objects.requireNonNull(getString(path)));
128+
return Float.parseFloat(getString(path));
129129
} catch (Exception ex) {
130130
return def;
131131
}
@@ -137,7 +137,7 @@ public boolean getBoolean(@Nonnull String path, boolean def) {
137137
Object value = bsonDocument.get(path);
138138
if (value instanceof Boolean) return (Boolean) value;
139139
if (value instanceof String) return Boolean.parseBoolean((String) value);
140-
} catch (Exception ignored) {
140+
} catch (Exception ex) {
141141
}
142142
return def;
143143
}
@@ -161,7 +161,7 @@ public UUID getUUID(@Nonnull String path) {
161161
Object value = bsonDocument.get(path);
162162
if (value instanceof UUID) return (UUID) value;
163163
if (value instanceof String) return UUID.fromString((String) value);
164-
} catch (Exception ignored) {
164+
} catch (Exception ex) {
165165
}
166166
return null;
167167
}

‎mongo-connector/src/main/java/net/codingarea/commons/common/misc/BsonUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
public final class BsonUtils {
1818

19-
private static final ILogger logger = ILogger.forThisClass();
19+
protected static final ILogger logger = ILogger.forThisClass();
2020

2121
private BsonUtils() {
2222
}

‎mongo-connector/src/main/java/net/codingarea/commons/common/misc/MongoUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static Object packObject(@Nullable Object value) {
5757
BsonUtils.setDocumentProperties(bson, values);
5858
return bson;
5959
} else if (value instanceof UUID) {
60-
return value.toString();
60+
return ((UUID) value).toString();
6161
} else {
6262
return value;
6363
}

‎plugin/src/main/java/net/codingarea/challenges/plugin/challenges/implementation/challenge/effect/RandomPotionEffectChallenge.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public RandomPotionEffectChallenge() {
6565

6666
@Nullable
6767
public static PotionEffectType getNewRandomEffect(@Nonnull LivingEntity entity) {
68-
List<PotionEffectType> activeEffects = entity.getActivePotionEffects().stream().map(PotionEffect::getType).toList();
68+
List<PotionEffectType> activeEffects = entity.getActivePotionEffects().stream().map(PotionEffect::getType).collect(Collectors.toList());
6969

7070
ArrayList<PotionEffectType> possibleEffects = new ArrayList<>(Arrays.asList(PotionEffectType.values()));
7171
possibleEffects.removeAll(activeEffects);

‎plugin/src/main/java/net/codingarea/challenges/plugin/challenges/implementation/challenge/inventory/PermanentItemChallenge.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.bukkit.inventory.Inventory;
1818

1919
import javax.annotation.Nonnull;
20-
import java.util.Objects;
2120

2221
@Since("2.0")
2322
public class PermanentItemChallenge extends Setting {
@@ -41,7 +40,7 @@ public void onInventoryClick(@Nonnull PlayerInventoryClickEvent event) {
4140
Inventory clickedInventory = event.getClickedInventory();
4241
if (event.getCursor() == null) return;
4342
if (clickedInventory == null) return;
44-
InventoryType type = Objects.requireNonNull(CompatibilityUtils.getTopInventory(player)).getType();
43+
InventoryType type = CompatibilityUtils.getTopInventory(player).getType();
4544
if (type == InventoryType.WORKBENCH || type == InventoryType.CRAFTING) return;
4645
if (clickedInventory.getType() == InventoryType.CRAFTING) return;
4746
if (clickedInventory.getType() == InventoryType.PLAYER) {

‎plugin/src/main/java/net/codingarea/challenges/plugin/challenges/implementation/challenge/miscellaneous/EnderGamesChallenge.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private void teleportRandom(@Nonnull Player player) {
6464
List<Entity> list = player.getWorld().getNearbyEntities(player.getLocation(), 200, 200, 200).stream()
6565
.filter(entity -> !(entity instanceof Player))
6666
.filter(entity -> entity instanceof LivingEntity)
67-
.toList();
67+
.collect(Collectors.toList());
6868

6969
Entity targetEntity = list.get(globalRandom.nextInt(list.size()));
7070

‎plugin/src/main/java/net/codingarea/challenges/plugin/challenges/implementation/challenge/quiz/QuizChallenge.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ class DocumentCountStatistic extends DocumentStatistic {
423423
}
424424
}
425425

426-
List<String> newAnswers = answers.stream().map(StringUtils::getEnumName).toList();
426+
List<String> newAnswers = answers.stream().map(StringUtils::getEnumName).collect(Collectors.toList());
427427
answers.clear();
428428
answers.addAll(newAnswers);
429429

‎plugin/src/main/java/net/codingarea/challenges/plugin/challenges/implementation/challenge/randomizer/HotBarRandomizerChallenge.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
import javax.annotation.Nonnull;
3131
import javax.annotation.Nullable;
32-
import java.util.Objects;
3332

3433
@Since("2.1.2")
3534
public class HotBarRandomizerChallenge extends TimedChallenge {
@@ -118,7 +117,7 @@ public void onInventoryClick(@Nonnull PlayerInventoryClickEvent event) {
118117
Inventory clickedInventory = event.getClickedInventory();
119118
if (event.getCursor() == null) return;
120119
if (clickedInventory == null) return;
121-
InventoryType type = Objects.requireNonNull(CompatibilityUtils.getTopInventory(player)).getType();
120+
InventoryType type = CompatibilityUtils.getTopInventory(player).getType();
122121
if (type == InventoryType.WORKBENCH || type == InventoryType.CRAFTING) return;
123122
if (clickedInventory.getType() == InventoryType.CRAFTING) return;
124123
if (clickedInventory.getType() == InventoryType.PLAYER) {

‎plugin/src/main/java/net/codingarea/challenges/plugin/challenges/implementation/challenge/world/SnakeChallenge.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void writeGameState(@Nonnull Document document) {
5656
public void loadGameState(@Nonnull Document document) {
5757
super.loadGameState(document);
5858

59-
blocks.addAll(document.getSerializableList("blocks", Location.class).stream().map(Location::getBlock).toList());
59+
blocks.addAll(document.getSerializableList("blocks", Location.class).stream().map(Location::getBlock).collect(Collectors.toList()));
6060
}
6161

6262
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)

‎plugin/src/main/java/net/codingarea/challenges/plugin/challenges/type/abstraction/CollectionGoal.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected void collect(@Nonnull Player player, @Nonnull Object item, @Nonnull Ru
7070
}
7171

7272
protected List<String> getCollectionFiltered(@Nonnull UUID uuid) {
73-
List<String> targetStringList = Arrays.stream(target).map(Object::toString).toList();
73+
List<String> targetStringList = Arrays.stream(target).map(Object::toString).collect(Collectors.toList());
7474
return collections.computeIfAbsent(uuid, key -> new ArrayList<>()).stream().filter(targetStringList::contains).collect(Collectors.toList());
7575
}
7676

‎plugin/src/main/java/net/codingarea/challenges/plugin/management/menu/generator/MenuGenerator.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import javax.annotation.Nonnegative;
1515
import javax.annotation.Nonnull;
1616
import java.util.List;
17-
import java.util.Objects;
1817

1918
@Getter
2019
@Setter
@@ -32,7 +31,7 @@ public abstract class MenuGenerator {
3231
public boolean hasInventoryOpen(Player player) {
3332
MenuPosition menuPosition = MenuPosition.get(player);
3433
return menuPosition instanceof GeneratorMenuPosition
35-
&& Objects.requireNonNull(CompatibilityUtils.getTopInventory(player)).getType() != InventoryType.CRAFTING
34+
&& CompatibilityUtils.getTopInventory(player).getType() != InventoryType.CRAFTING
3635
&& ((GeneratorMenuPosition) menuPosition).getGenerator() == this;
3736
}
3837

‎plugin/src/main/java/net/codingarea/challenges/plugin/management/menu/info/ChallengeMenuClickInfo.java

+10
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,14 @@ public boolean isLowerItemClick() {
3030
return !upperItem;
3131
}
3232

33+
@Nonnull
34+
public Player getPlayer() {
35+
return player;
36+
}
37+
38+
@Nonnull
39+
public Inventory getInventory() {
40+
return inventory;
41+
}
42+
3343
}

‎plugin/src/main/java/net/codingarea/challenges/plugin/management/team/TeamProvider.java

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import net.codingarea.commons.bukkit.utils.logging.Logger;
44
import org.bukkit.entity.Player;
5+
import org.jetbrains.annotations.NotNull;
56

67
import java.util.LinkedList;
78
import java.util.List;

‎plugin/src/main/java/net/codingarea/challenges/plugin/spigot/listener/CheatListener.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public void onGameModeChange(@Nonnull PlayerGameModeChangeEvent event) {
3333

3434
@EventHandler(priority = EventPriority.MONITOR)
3535
public void onSneak(PlayerToggleSneakEvent event) {
36-
event.isSneaking();
36+
if (!event.isSneaking()) {
37+
}
3738
//// Structure structure = entry.getValue();
3839

3940
}

‎plugin/src/main/java/net/codingarea/challenges/plugin/utils/bukkit/misc/BukkitStringUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public static List<BaseComponent> format(@Nonnull String sequence, @Nonnull Obje
149149
if (!currentText.getText().isEmpty()) {
150150
results.add(currentText);
151151
}
152-
if (!argument.isEmpty()) {
152+
if (argument.length() > 0) {
153153
results.add(new TextComponent(String.valueOf(start)));
154154
results.add(new TextComponent(String.valueOf(argument)));
155155
}

‎plugin/src/main/java/net/codingarea/challenges/plugin/utils/bukkit/nms/NMSProvider.java

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class NMSProvider {
1919
/**
2020
* -- GETTER --
2121
*
22+
* @return A border packet factory
2223
*/
2324
@Getter
2425
private static final BorderPacketFactory borderPacketFactory;

‎plugin/src/main/java/net/codingarea/challenges/plugin/utils/item/ItemBuilder.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ public ItemDescription getBuiltByItemDescription() {
214214

215215
@Override
216216
public ItemBuilder clone() {
217-
ItemBuilder itemBuilder = (ItemBuilder) super.clone();
218-
ItemBuilder builder = new ItemBuilder(item.clone(), getMeta().clone());
217+
ItemBuilder builder = new ItemBuilder(item.clone(), getMeta().clone());
219218
builder.builtByItemDescription = builtByItemDescription;
220219
return builder;
221220
}

‎plugin/src/main/java/net/codingarea/challenges/plugin/utils/misc/ImageUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package net.codingarea.challenges.plugin.utils.misc;
22

3-
import net.codingarea.commons.common.collection.IOUtils;
43
import org.bukkit.entity.Player;
54

65
import javax.annotation.Nonnull;
@@ -21,7 +20,8 @@ private ImageUtils() {
2120

2221
@Nullable
2322
public static BufferedImage getImage(@Nonnull String url) throws IOException {
24-
HttpURLConnection connection = IOUtils.createConnection(url);
23+
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
24+
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36");
2525
return ImageIO.read(connection.getInputStream());
2626
}
2727

‎plugin/src/main/java/net/codingarea/commons/bukkit/core/BukkitModule.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package net.codingarea.commons.bukkit.core;
22

33
import com.google.common.base.Charsets;
4-
import lombok.Getter;
54
import net.codingarea.commons.bukkit.utils.menu.MenuPosition;
65
import net.codingarea.commons.bukkit.utils.menu.MenuPositionListener;
76
import net.codingarea.commons.bukkit.utils.misc.MinecraftVersion;
@@ -55,8 +54,7 @@ public abstract class BukkitModule extends JavaPlugin {
5554
private ExecutorService executorService;
5655
private Document config, pluginConfig;
5756
private Version version;
58-
@Getter
59-
private boolean devMode;
57+
private boolean devMode;
6058
private boolean firstInstall;
6159
private boolean isReloaded;
6260
private boolean isLoaded;
@@ -77,10 +75,10 @@ public final void onLoad() {
7775
ILogger.setConstantFactory(this.getILogger());
7876
trySaveDefaultConfig();
7977
if (wasShutdown) isReloaded = true;
80-
if (firstInstall == !getDataFolder().exists()) {
78+
if (firstInstall = !getDataFolder().exists()) {
8179
getILogger().info("Detected first install!");
8280
}
83-
if (devMode == getConfigDocument().getBoolean("dev-mode") || getConfigDocument().getBoolean("dev-mode.enabled")) {
81+
if (devMode = getConfigDocument().getBoolean("dev-mode") || getConfigDocument().getBoolean("dev-mode.enabled")) {
8482
getILogger().setLevel(Level.ALL);
8583
getILogger().debug("Devmode is enabled: Showing debug messages. This can be disabled in the plugin.yml ('dev-mode')");
8684
} else {
@@ -144,7 +142,11 @@ protected void handleLoad() throws Exception {}
144142
protected void handleEnable() throws Exception {}
145143
protected void handleDisable() throws Exception {}
146144

147-
public final boolean isFirstInstall() {
145+
public boolean isDevMode() {
146+
return devMode;
147+
}
148+
149+
public final boolean isFirstInstall() {
148150
return firstInstall;
149151
}
150152

@@ -183,7 +185,7 @@ public void reloadConfig() {
183185
@Nonnull
184186
public Document getPluginDocument() {
185187
return pluginConfig != null ? pluginConfig :
186-
(pluginConfig = new YamlDocument(YamlConfiguration.loadConfiguration(new InputStreamReader(Objects.requireNonNull(getResource("plugin.yml")), Charsets.UTF_8))));
188+
(pluginConfig = new YamlDocument(YamlConfiguration.loadConfiguration(new InputStreamReader(getResource("plugin.yml"), Charsets.UTF_8))));
187189
}
188190

189191
@Nonnull
@@ -342,7 +344,7 @@ private void injectInstance() {
342344
Field instanceField = this.getClass().getDeclaredField("instance");
343345
instanceField.setAccessible(true);
344346
instanceField.set(null, this);
345-
} catch (Throwable ignored) {
347+
} catch (Throwable ex) {
346348
}
347349
}
348350

‎plugin/src/main/java/net/codingarea/commons/bukkit/core/RequirementsChecker.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import org.bukkit.Bukkit;
77

88
import javax.annotation.Nonnull;
9-
import java.util.Objects;
109

1110
public final class RequirementsChecker {
1211

@@ -19,7 +18,7 @@ public RequirementsChecker(@Nonnull BukkitModule module) {
1918
public void checkExceptionally(@Nonnull Document requirements) throws IllegalStateException {
2019
if (requirements.getBoolean("spigot")) requireSpigot();
2120
if (requirements.getBoolean("paper")) requirePaper();
22-
if (requirements.contains("version")) requireVersion(Objects.requireNonNull(requirements.getVersion("version")));
21+
if (requirements.contains("version")) requireVersion(requirements.getVersion("version"));
2322
}
2423

2524
public boolean checkBoolean(@Nonnull Document requirements) {

‎plugin/src/main/java/net/codingarea/commons/bukkit/utils/animation/AnimationFrame.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import javax.annotation.Nonnull;
88
import javax.annotation.Nullable;
99
import java.util.Arrays;
10-
import java.util.Objects;
1110

1211
public class AnimationFrame implements Cloneable {
1312

@@ -60,7 +59,7 @@ public ItemStack getItem(int slot) {
6059

6160
@Nullable
6261
public Material getItemType(int slot) {
63-
return getItem(slot) == null ? Material.AIR : Objects.requireNonNull(getItem(slot)).getType();
62+
return getItem(slot) == null ? Material.AIR : getItem(slot).getType();
6463
}
6564

6665
@Nonnull
@@ -79,8 +78,7 @@ public int getSize() {
7978
@Nonnull
8079
@Override
8180
public AnimationFrame clone() {
82-
AnimationFrame animationFrame = (AnimationFrame) super.clone();
83-
return new AnimationFrame(content);
81+
return new AnimationFrame(content);
8482
}
8583

8684
}

0 commit comments

Comments
 (0)