Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public String getString(@Nonnull String path) {
@Override
public long getLong(@Nonnull String path, long def) {
try {
return Long.parseLong(getString(path));
return Long.parseLong(Objects.requireNonNull(getString(path)));
} catch (Exception ex) {
return def;
}
Expand All @@ -89,7 +89,7 @@ public long getLong(@Nonnull String path, long def) {
@Override
public int getInt(@Nonnull String path, int def) {
try {
return Integer.parseInt(getString(path));
return Integer.parseInt(Objects.requireNonNull(getString(path)));
} catch (Exception ex) {
return def;
}
Expand All @@ -98,7 +98,7 @@ public int getInt(@Nonnull String path, int def) {
@Override
public short getShort(@Nonnull String path, short def) {
try {
return Short.parseShort(getString(path));
return Short.parseShort(Objects.requireNonNull(getString(path)));
} catch (Exception ex) {
return def;
}
Expand All @@ -107,7 +107,7 @@ public short getShort(@Nonnull String path, short def) {
@Override
public byte getByte(@Nonnull String path, byte def) {
try {
return Byte.parseByte(getString(path));
return Byte.parseByte(Objects.requireNonNull(getString(path)));
} catch (Exception ex) {
return def;
}
Expand All @@ -116,7 +116,7 @@ public byte getByte(@Nonnull String path, byte def) {
@Override
public double getDouble(@Nonnull String path, double def) {
try {
return Double.parseDouble(getString(path));
return Double.parseDouble(Objects.requireNonNull(getString(path)));
} catch (Exception ex) {
return def;
}
Expand All @@ -125,7 +125,7 @@ public double getDouble(@Nonnull String path, double def) {
@Override
public float getFloat(@Nonnull String path, float def) {
try {
return Float.parseFloat(getString(path));
return Float.parseFloat(Objects.requireNonNull(getString(path)));
} catch (Exception ex) {
return def;
}
Expand All @@ -137,7 +137,7 @@ public boolean getBoolean(@Nonnull String path, boolean def) {
Object value = bsonDocument.get(path);
if (value instanceof Boolean) return (Boolean) value;
if (value instanceof String) return Boolean.parseBoolean((String) value);
} catch (Exception ex) {
} catch (Exception ignored) {
}
return def;
}
Expand All @@ -161,7 +161,7 @@ public UUID getUUID(@Nonnull String path) {
Object value = bsonDocument.get(path);
if (value instanceof UUID) return (UUID) value;
if (value instanceof String) return UUID.fromString((String) value);
} catch (Exception ex) {
} catch (Exception ignored) {
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public final class BsonUtils {

protected static final ILogger logger = ILogger.forThisClass();
private static final ILogger logger = ILogger.forThisClass();

private BsonUtils() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static Object packObject(@Nullable Object value) {
BsonUtils.setDocumentProperties(bson, values);
return bson;
} else if (value instanceof UUID) {
return ((UUID) value).toString();
return value.toString();
} else {
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public RandomPotionEffectChallenge() {

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

ArrayList<PotionEffectType> possibleEffects = new ArrayList<>(Arrays.asList(PotionEffectType.values()));
possibleEffects.removeAll(activeEffects);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.bukkit.inventory.Inventory;

import javax.annotation.Nonnull;
import java.util.Objects;

@Since("2.0")
public class PermanentItemChallenge extends Setting {
Expand All @@ -40,7 +41,7 @@ public void onInventoryClick(@Nonnull PlayerInventoryClickEvent event) {
Inventory clickedInventory = event.getClickedInventory();
if (event.getCursor() == null) return;
if (clickedInventory == null) return;
InventoryType type = CompatibilityUtils.getTopInventory(player).getType();
InventoryType type = Objects.requireNonNull(CompatibilityUtils.getTopInventory(player)).getType();
if (type == InventoryType.WORKBENCH || type == InventoryType.CRAFTING) return;
if (clickedInventory.getType() == InventoryType.CRAFTING) return;
if (clickedInventory.getType() == InventoryType.PLAYER) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private void teleportRandom(@Nonnull Player player) {
List<Entity> list = player.getWorld().getNearbyEntities(player.getLocation(), 200, 200, 200).stream()
.filter(entity -> !(entity instanceof Player))
.filter(entity -> entity instanceof LivingEntity)
.collect(Collectors.toList());
.toList();

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ class DocumentCountStatistic extends DocumentStatistic {
}
}

List<String> newAnswers = answers.stream().map(StringUtils::getEnumName).collect(Collectors.toList());
List<String> newAnswers = answers.stream().map(StringUtils::getEnumName).toList();
answers.clear();
answers.addAll(newAnswers);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Objects;

@Since("2.1.2")
public class HotBarRandomizerChallenge extends TimedChallenge {
Expand Down Expand Up @@ -117,7 +118,7 @@ public void onInventoryClick(@Nonnull PlayerInventoryClickEvent event) {
Inventory clickedInventory = event.getClickedInventory();
if (event.getCursor() == null) return;
if (clickedInventory == null) return;
InventoryType type = CompatibilityUtils.getTopInventory(player).getType();
InventoryType type = Objects.requireNonNull(CompatibilityUtils.getTopInventory(player)).getType();
if (type == InventoryType.WORKBENCH || type == InventoryType.CRAFTING) return;
if (clickedInventory.getType() == InventoryType.CRAFTING) return;
if (clickedInventory.getType() == InventoryType.PLAYER) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void writeGameState(@Nonnull Document document) {
public void loadGameState(@Nonnull Document document) {
super.loadGameState(document);

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

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected void collect(@Nonnull Player player, @Nonnull Object item, @Nonnull Ru
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.Objects;

@Getter
@Setter
Expand All @@ -31,7 +32,7 @@ public abstract class MenuGenerator {
public boolean hasInventoryOpen(Player player) {
MenuPosition menuPosition = MenuPosition.get(player);
return menuPosition instanceof GeneratorMenuPosition
&& CompatibilityUtils.getTopInventory(player).getType() != InventoryType.CRAFTING
&& Objects.requireNonNull(CompatibilityUtils.getTopInventory(player)).getType() != InventoryType.CRAFTING
&& ((GeneratorMenuPosition) menuPosition).getGenerator() == this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,4 @@ public boolean isLowerItemClick() {
return !upperItem;
}

@Nonnull
public Player getPlayer() {
return player;
}

@Nonnull
public Inventory getInventory() {
return inventory;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.codingarea.commons.bukkit.utils.logging.Logger;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.LinkedList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public void onGameModeChange(@Nonnull PlayerGameModeChangeEvent event) {

@EventHandler(priority = EventPriority.MONITOR)
public void onSneak(PlayerToggleSneakEvent event) {
if (!event.isSneaking()) {
}
event.isSneaking();
//// Structure structure = entry.getValue();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static List<BaseComponent> format(@Nonnull String sequence, @Nonnull Obje
if (!currentText.getText().isEmpty()) {
results.add(currentText);
}
if (argument.length() > 0) {
if (!argument.isEmpty()) {
results.add(new TextComponent(String.valueOf(start)));
results.add(new TextComponent(String.valueOf(argument)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class NMSProvider {
/**
* -- GETTER --
*
* @return A border packet factory
*/
@Getter
private static final BorderPacketFactory borderPacketFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ public ItemDescription getBuiltByItemDescription() {

@Override
public ItemBuilder clone() {
ItemBuilder builder = new ItemBuilder(item.clone(), getMeta().clone());
ItemBuilder itemBuilder = (ItemBuilder) super.clone();
ItemBuilder builder = new ItemBuilder(item.clone(), getMeta().clone());
builder.builtByItemDescription = builtByItemDescription;
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.codingarea.challenges.plugin.utils.misc;

import net.codingarea.commons.common.collection.IOUtils;
import org.bukkit.entity.Player;

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

@Nullable
public static BufferedImage getImage(@Nonnull String url) throws IOException {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
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");
HttpURLConnection connection = IOUtils.createConnection(url);
return ImageIO.read(connection.getInputStream());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.codingarea.commons.bukkit.core;

import com.google.common.base.Charsets;
import lombok.Getter;
import net.codingarea.commons.bukkit.utils.menu.MenuPosition;
import net.codingarea.commons.bukkit.utils.menu.MenuPositionListener;
import net.codingarea.commons.bukkit.utils.misc.MinecraftVersion;
Expand Down Expand Up @@ -54,7 +55,8 @@ public abstract class BukkitModule extends JavaPlugin {
private ExecutorService executorService;
private Document config, pluginConfig;
private Version version;
private boolean devMode;
@Getter
private boolean devMode;
private boolean firstInstall;
private boolean isReloaded;
private boolean isLoaded;
Expand All @@ -75,10 +77,10 @@ public final void onLoad() {
ILogger.setConstantFactory(this.getILogger());
trySaveDefaultConfig();
if (wasShutdown) isReloaded = true;
if (firstInstall = !getDataFolder().exists()) {
if (firstInstall == !getDataFolder().exists()) {
getILogger().info("Detected first install!");
}
if (devMode = getConfigDocument().getBoolean("dev-mode") || getConfigDocument().getBoolean("dev-mode.enabled")) {
if (devMode == getConfigDocument().getBoolean("dev-mode") || getConfigDocument().getBoolean("dev-mode.enabled")) {
getILogger().setLevel(Level.ALL);
getILogger().debug("Devmode is enabled: Showing debug messages. This can be disabled in the plugin.yml ('dev-mode')");
} else {
Expand Down Expand Up @@ -142,11 +144,7 @@ protected void handleLoad() throws Exception {}
protected void handleEnable() throws Exception {}
protected void handleDisable() throws Exception {}

public boolean isDevMode() {
return devMode;
}

public final boolean isFirstInstall() {
public final boolean isFirstInstall() {
return firstInstall;
}

Expand Down Expand Up @@ -185,7 +183,7 @@ public void reloadConfig() {
@Nonnull
public Document getPluginDocument() {
return pluginConfig != null ? pluginConfig :
(pluginConfig = new YamlDocument(YamlConfiguration.loadConfiguration(new InputStreamReader(getResource("plugin.yml"), Charsets.UTF_8))));
(pluginConfig = new YamlDocument(YamlConfiguration.loadConfiguration(new InputStreamReader(Objects.requireNonNull(getResource("plugin.yml")), Charsets.UTF_8))));
}

@Nonnull
Expand Down Expand Up @@ -344,7 +342,7 @@ private void injectInstance() {
Field instanceField = this.getClass().getDeclaredField("instance");
instanceField.setAccessible(true);
instanceField.set(null, this);
} catch (Throwable ex) {
} catch (Throwable ignored) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.Bukkit;

import javax.annotation.Nonnull;
import java.util.Objects;

public final class RequirementsChecker {

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

public boolean checkBoolean(@Nonnull Document requirements) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Objects;

public class AnimationFrame implements Cloneable {

Expand Down Expand Up @@ -59,7 +60,7 @@ public ItemStack getItem(int slot) {

@Nullable
public Material getItemType(int slot) {
return getItem(slot) == null ? Material.AIR : getItem(slot).getType();
return getItem(slot) == null ? Material.AIR : Objects.requireNonNull(getItem(slot)).getType();
}

@Nonnull
Expand All @@ -78,7 +79,8 @@ public int getSize() {
@Nonnull
@Override
public AnimationFrame clone() {
return new AnimationFrame(content);
AnimationFrame animationFrame = (AnimationFrame) super.clone();
return new AnimationFrame(content);
}

}
Loading