Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move all utility classes into a separate module #194

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ repositories {
}

dependencies {
api(project(":util"))
implementation("com.google.code.gson:gson:2.8.5")
implementation("org.apache.logging.log4j:log4j-core:2.11.1")
implementation("org.apache.logging.log4j:log4j-api:2.11.1")
Expand Down
2 changes: 1 addition & 1 deletion plugins/api/item/LootTableItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package api.item

import io.luna.game.model.def.ItemDefinition
import io.luna.game.model.item.Item
import io.luna.util.Rational
import io.luna.util.common.Rational

/**
* A model representing an item within a [LootTable].
Expand Down
2 changes: 1 addition & 1 deletion plugins/api/item/LootTableReceiver.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package api.item

import api.predef.*
import io.luna.util.Rational
import io.luna.util.common.Rational

/**
* A model representing the primary [lootTable] receiver.
Expand Down
2 changes: 1 addition & 1 deletion plugins/api/item/RarityReceiver.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package api.item

import io.luna.util.Rational
import io.luna.util.common.Rational

/**
* A model representing the [LootTableReceiver.rarity] receiver.
Expand Down
2 changes: 1 addition & 1 deletion plugins/api/predef/FunctionsPredef.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import io.luna.game.model.def.EquipmentDefinition
import io.luna.game.model.def.ItemDefinition
import io.luna.game.model.def.NpcDefinition
import io.luna.game.model.def.ObjectDefinition
import io.luna.util.StringUtils
import io.luna.util.common.StringUtils
import java.time.Duration
import java.util.concurrent.ThreadLocalRandom
import java.util.concurrent.TimeUnit
Expand Down
4 changes: 2 additions & 2 deletions plugins/api/predef/PropertiesPredef.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import io.luna.game.model.mob.PlayerRights
import io.luna.game.model.mob.Skill
import io.luna.game.plugin.KotlinBindings
import io.luna.game.plugin.PluginBootstrap
import io.luna.util.Rational
import io.luna.util.ReflectionUtils
import io.luna.util.common.Rational
import io.luna.util.common.ReflectionUtils

/**
* The Kotlin bindings. Not accessible to scripts.
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*/

rootProject.name = "luna"
include("util")
6 changes: 3 additions & 3 deletions src/main/java/io/luna/LunaServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import io.luna.net.LunaChannelFilter;
import io.luna.net.LunaChannelInitializer;
import io.luna.net.msg.GameMessageRepository;
import io.luna.util.AsyncExecutor;
import io.luna.util.ThreadUtils;
import io.luna.util.Tuple;
import io.luna.util.concurrent.AsyncExecutor;
import io.luna.util.concurrent.ThreadUtils;
import io.luna.util.common.Tuple;
import io.luna.util.parser.impl.BlacklistFileParser;
import io.luna.util.parser.impl.EquipmentDefinitionFileParser;
import io.luna.util.parser.impl.ItemDefinitionFileParser;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/luna/game/event/EventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.google.common.base.MoreObjects;
import io.luna.game.plugin.Script;
import io.luna.game.plugin.ScriptExecutionException;
import io.luna.util.ReflectionUtils;
import io.luna.util.common.ReflectionUtils;

import java.util.function.Consumer;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/luna/game/event/EventMatcherListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.luna.game.plugin.Script;
import io.luna.game.plugin.ScriptExecutionException;
import io.luna.util.ReflectionUtils;
import io.luna.util.common.ReflectionUtils;

import java.util.function.Consumer;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/luna/game/event/impl/CommandEvent.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.luna.game.event.impl;

import io.luna.game.model.mob.Player;
import io.luna.util.StringUtils;
import io.luna.util.common.StringUtils;

/**
* An event sent when a player activates a command.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/luna/game/model/Area.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.luna.game.model;

import io.luna.game.model.mob.Player;
import io.luna.util.RandomUtils;
import io.luna.util.common.RandomUtils;

import java.util.Objects;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/luna/game/model/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import io.luna.game.task.TaskManager;
import io.luna.net.msg.out.NpcUpdateMessageWriter;
import io.luna.net.msg.out.PlayerUpdateMessageWriter;
import io.luna.util.ThreadUtils;
import io.luna.util.concurrent.ThreadUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.luna.game.model.EntityType;
import io.luna.game.model.mob.Mob;
import io.luna.game.model.mob.Player;
import io.luna.util.Tuple;
import io.luna.util.common.Tuple;

import java.util.Comparator;
import java.util.function.BiFunction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.Arrays;
import java.util.Optional;

import static io.luna.util.StringUtils.addArticle;
import static io.luna.util.common.StringUtils.addArticle;

/**
* A model describing an equipment item definition.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/luna/game/model/item/Equipment.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import java.util.OptionalInt;
import java.util.function.IntUnaryOperator;

import static io.luna.util.OptionalUtils.ifPresent;
import static io.luna.util.OptionalUtils.mapToInt;
import static io.luna.util.OptionalUtils.matches;
import static io.luna.util.common.OptionalUtils.ifPresent;
import static io.luna.util.common.OptionalUtils.mapToInt;
import static io.luna.util.common.OptionalUtils.matches;

/**
* An item container model representing a player's equipment.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/luna/game/model/item/ItemContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import static com.google.common.base.Preconditions.checkState;
import static io.luna.game.model.item.ItemContainer.StackPolicy.ALWAYS;
import static io.luna.game.model.item.ItemContainer.StackPolicy.STANDARD;
import static io.luna.util.OptionalUtils.mapToInt;
import static io.luna.util.OptionalUtils.matches;
import static io.luna.util.common.OptionalUtils.mapToInt;
import static io.luna.util.common.OptionalUtils.matches;
import static java.util.Objects.requireNonNull;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.luna.game.model.mob;

import io.luna.util.StringUtils;
import io.luna.util.common.StringUtils;

/**
* A model representing a player's credentials.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/luna/game/model/mob/PlayerRights.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.luna.game.model.mob;

import io.luna.util.StringUtils;
import io.luna.util.common.StringUtils;

import static com.google.common.base.Preconditions.checkArgument;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.luna.game.model.mob.dialogue;

import io.luna.net.msg.out.WidgetAnimationMessageWriter;
import io.luna.util.RandomUtils;
import io.luna.util.common.RandomUtils;

import static com.google.common.base.Preconditions.checkArgument;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.luna.game.model.mob.Player;
import io.luna.game.model.mob.inter.DialogueInterface;
import io.luna.net.msg.out.WidgetItemModelMessageWriter;
import io.luna.util.StringUtils;
import io.luna.util.common.StringUtils;

/**
* A {@link DialogueInterface} implementation that opens a dialogue which grants the Player an item.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.luna.Luna;
import io.luna.game.model.mob.Player;
import io.luna.util.ReflectionUtils;
import io.luna.util.common.ReflectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mindrot.jbcrypt.BCrypt;
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/io/luna/game/plugin/PluginBootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import io.luna.game.event.EventListenerPipelineSet;
import io.luna.game.event.EventMatcherListener;
import io.luna.game.service.GameService;
import io.luna.util.AsyncExecutor;
import io.luna.util.ThreadUtils;
import io.luna.util.Tuple;
import io.luna.util.concurrent.AsyncExecutor;
import io.luna.util.concurrent.ThreadUtils;
import io.luna.util.common.Tuple;
import io.luna.util.gui.PluginGui;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
Expand All @@ -19,7 +19,6 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.google.common.util.concurrent.ListeningExecutorService;
import io.luna.game.model.World;
import io.luna.game.model.mob.persistence.PlayerPersistence;
import io.luna.util.ExecutorUtils;
import io.luna.util.concurrent.ExecutorUtils;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/luna/game/service/GameService.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import io.luna.game.plugin.PluginManager;
import io.luna.game.task.Task;
import io.luna.net.msg.out.SystemUpdateMessageWriter;
import io.luna.util.ExecutorUtils;
import io.luna.util.concurrent.ExecutorUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
Expand All @@ -23,7 +23,7 @@
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;

import static io.luna.util.ThreadUtils.awaitTerminationUninterruptibly;
import static io.luna.util.concurrent.ThreadUtils.awaitTerminationUninterruptibly;

/**
* An {@link AbstractScheduledService} implementation that handles the launch, processing, and termination
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/luna/game/service/LoginService.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;

import static io.luna.util.ThreadUtils.awaitTerminationUninterruptibly;
import static io.luna.util.concurrent.ThreadUtils.awaitTerminationUninterruptibly;
import static org.apache.logging.log4j.util.Unbox.box;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/luna/game/service/LogoutService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import java.util.Set;

import static io.luna.util.ThreadUtils.awaitTerminationUninterruptibly;
import static io.luna.util.concurrent.ThreadUtils.awaitTerminationUninterruptibly;
import static org.apache.logging.log4j.util.Unbox.box;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/luna/game/service/PersistenceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.luna.game.model.World;
import io.luna.game.model.mob.Player;
import io.luna.game.model.mob.persistence.PlayerData;
import io.luna.util.ExecutorUtils;
import io.luna.util.concurrent.ExecutorUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
Expand All @@ -18,7 +18,7 @@
import java.util.concurrent.Executors;
import java.util.function.Consumer;

import static io.luna.util.ThreadUtils.awaitTerminationUninterruptibly;
import static io.luna.util.concurrent.ThreadUtils.awaitTerminationUninterruptibly;
import static org.apache.logging.log4j.util.Unbox.box;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/luna/net/msg/in/ChatMessageReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.luna.net.msg.GameMessage;
import io.luna.net.msg.GameMessageReader;
import io.luna.util.LoggingSettings.FileOutputType;
import io.luna.util.StringUtils;
import io.luna.util.common.StringUtils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import io.luna.game.model.mob.inter.NameInputInterface;
import io.luna.net.msg.GameMessage;
import io.luna.net.msg.GameMessageReader;
import io.luna.util.StringUtils;
import io.luna.util.common.StringUtils;

import java.util.Optional;
import java.util.OptionalInt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.luna.net.msg.GameMessage;
import io.luna.net.msg.GameMessageReader;
import io.luna.util.LoggingSettings.FileOutputType;
import io.luna.util.StringUtils;
import io.luna.util.common.StringUtils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/luna/util/gui/PluginTreeItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.function.BiConsumer;
import java.util.stream.Collectors;

import static io.luna.util.StringUtils.COMMA_JOINER;
import static io.luna.util.common.StringUtils.COMMA_JOINER;
import static io.luna.util.gui.PluginGuiImage.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.google.gson.JsonObject;
import io.luna.game.model.def.EquipmentDefinition;
import io.luna.game.model.def.EquipmentDefinition.Requirement;
import io.luna.util.GsonUtils;
import io.luna.util.common.GsonUtils;
import io.luna.util.parser.AbstractJsonFileParser;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.google.common.collect.ImmutableList;
import com.google.gson.JsonObject;
import io.luna.game.model.def.ItemDefinition;
import io.luna.util.GsonUtils;
import io.luna.util.common.GsonUtils;
import io.luna.util.parser.AbstractJsonFileParser;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.google.common.collect.ImmutableList;
import com.google.gson.JsonObject;
import io.luna.game.model.def.NpcCombatDefinition;
import io.luna.util.GsonUtils;
import io.luna.util.common.GsonUtils;
import io.luna.util.parser.AbstractJsonFileParser;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.google.common.collect.ImmutableList;
import com.google.gson.JsonObject;
import io.luna.game.model.def.NpcDefinition;
import io.luna.util.GsonUtils;
import io.luna.util.common.GsonUtils;
import io.luna.util.parser.AbstractJsonFileParser;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.google.common.collect.ImmutableList;
import com.google.gson.JsonObject;
import io.luna.game.model.def.ObjectDefinition;
import io.luna.util.GsonUtils;
import io.luna.util.common.GsonUtils;
import io.luna.util.parser.AbstractJsonFileParser;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.luna.game.model.mob.attr;

import io.luna.util.GsonUtils;
import io.luna.util.common.GsonUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

Expand Down
22 changes: 22 additions & 0 deletions util/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
`java-library`
}

group = "luna"
version = "1.0"

repositories {
mavenCentral()
}

dependencies {
implementation("com.google.code.gson:gson:2.8.5")
implementation("com.google.guava:guava:27.0.1-jre")
implementation("org.apache.logging.log4j:log4j-core:2.11.1")
implementation("org.apache.logging.log4j:log4j-api:2.11.1")
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
Loading