Skip to content

Commit

Permalink
v2.0.4 - minor code refactoring and update libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
lokka30 committed Aug 10, 2023
1 parent 0743eb0 commit 1a970ad
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 37 deletions.
Binary file added docs/img/Banner.pdn
Binary file not shown.
Binary file added docs/img/Banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/PhantomWorlds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.lokka30</groupId>
<artifactId>PhantomWorlds</artifactId>
<version>2.0.3</version>
<version>2.0.4</version>

<name>PhantomWorlds</name>
<description>The Robust World Manager for Minecraft Servers</description>
Expand Down Expand Up @@ -35,24 +35,24 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.lokka30</groupId>
<artifactId>MicroLib</artifactId>
<version>3.2.0</version>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.0</version>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>23.0.0</version>
<version>24.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand All @@ -63,7 +63,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -72,7 +72,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<version>3.5.0</version>
<configuration>
<relocations>
<relocation>
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/me/lokka30/phantomworlds/PhantomWorlds.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.lokka30.phantomworlds;

import java.io.File;
import me.lokka30.microlib.files.YamlConfigFile;
import me.lokka30.microlib.maths.QuickTimer;
import me.lokka30.microlib.other.UpdateChecker;
Expand All @@ -13,6 +12,9 @@
import org.bstats.bukkit.Metrics;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.util.concurrent.TimeUnit;

/**
* This is the main class of the PhantomWorlds plugin.
*
Expand All @@ -34,13 +36,13 @@ public class PhantomWorlds extends JavaPlugin {
/**
* If you have contributed code to the plugin, add your name to the end of this list! :)
*/
public final String[] contributors = new String[]{"madison-allen"};
public static final String[] CONTRIBUTORS = new String[]{"madison-allen"};

/**
* This is reported in the 'pw info' command to inform the command sender of what MC versions
* that this version of PW is designed to run on, and is therefore supported.
*/
public final String supportedServerVersions = "1.7.x to 1.18.x";
public final String supportedServerVersions = "1.7.x and newer";

/**
* Frequently used vars.
Expand Down Expand Up @@ -74,7 +76,7 @@ public class PhantomWorlds extends JavaPlugin {
*/
@Override
public void onEnable() {
final QuickTimer timer = new QuickTimer();
final QuickTimer timer = new QuickTimer(TimeUnit.MILLISECONDS);

checkCompatibility();
loadFiles();
Expand All @@ -83,7 +85,7 @@ public void onEnable() {
registerListeners();
miscStartupProcedures();

getLogger().info("Start-up complete (took " + timer.getTimer() + "ms)");
getLogger().info("Start-up complete (took " + timer.getDuration() + "ms)");
}

/**
Expand All @@ -94,11 +96,11 @@ public void onEnable() {
*/
@Override
public void onDisable() {
final QuickTimer timer = new QuickTimer();
final QuickTimer timer = new QuickTimer(TimeUnit.MILLISECONDS);

/* ... any on-disable content should be put here. nothing for now */

getLogger().info("Shut-down complete (took " + timer.getTimer() + "ms)");
getLogger().info("Shut-down complete (took " + timer.getDuration() + "ms)");
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package me.lokka30.phantomworlds.commands.phantomworlds.subcommands;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import me.lokka30.microlib.maths.QuickTimer;
import me.lokka30.microlib.messaging.MultiMessage;
import me.lokka30.phantomworlds.PhantomWorlds;
Expand All @@ -20,6 +14,10 @@
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeUnit;

/**
* @author lokka30
* @since v2.0.0
Expand Down Expand Up @@ -145,11 +143,13 @@ public void parseCommand(@NotNull PhantomWorlds main, CommandSender sender, Comm
option = option.substring(1);
} // remove - character if present, those switching from PW v1 may still use it by accident.

final String valueToLowerCase = value.toString().toLowerCase(Locale.ROOT);

switch(option) {
case "generatestructures":
case "genstructures":
case "structures":
switch(value.toString().toLowerCase(Locale.ROOT)) {
switch(valueToLowerCase) {
case "true":
case "t":
case "yes":
Expand Down Expand Up @@ -188,7 +188,7 @@ public void parseCommand(@NotNull PhantomWorlds main, CommandSender sender, Comm
generatorSettings = value.toString();
break;
case "hardcore":
switch(value.toString().toLowerCase(Locale.ROOT)) {
switch(valueToLowerCase) {
case "true":
case "t":
case "yes":
Expand Down Expand Up @@ -261,7 +261,7 @@ public void parseCommand(@NotNull PhantomWorlds main, CommandSender sender, Comm
break;
case "spawnmobs":
case "mobs":
switch(value.toString().toLowerCase(Locale.ROOT)) {
switch(valueToLowerCase) {
case "true":
case "t":
case "yes":
Expand Down Expand Up @@ -293,7 +293,7 @@ public void parseCommand(@NotNull PhantomWorlds main, CommandSender sender, Comm
break;
case "spawnanimals":
case "animals":
switch(value.toString().toLowerCase(Locale.ROOT)) {
switch(valueToLowerCase) {
case "true":
case "t":
case "yes":
Expand Down Expand Up @@ -325,7 +325,7 @@ public void parseCommand(@NotNull PhantomWorlds main, CommandSender sender, Comm
break;
case "keepspawninmemory":
case "spawninmemory":
switch(value.toString().toLowerCase(Locale.ROOT)) {
switch(valueToLowerCase) {
case "true":
case "t":
case "yes":
Expand Down Expand Up @@ -437,7 +437,7 @@ public void parseCommand(@NotNull PhantomWorlds main, CommandSender sender, Comm
spawnAnimals, keepSpawnInMemory, allowPvP, difficulty
);

final QuickTimer quickTimer = new QuickTimer();
final QuickTimer quickTimer = new QuickTimer(TimeUnit.MILLISECONDS);

(new MultiMessage(
main.messages.getConfig()
Expand Down Expand Up @@ -475,8 +475,8 @@ public void parseCommand(@NotNull PhantomWorlds main, CommandSender sender, Comm

try {
main.data.save();
} catch(IOException ex) {
ex.printStackTrace();
} catch(final IOException ex) {
throw new RuntimeException(ex);
}

(new MultiMessage(
Expand All @@ -499,7 +499,7 @@ public void parseCommand(@NotNull PhantomWorlds main, CommandSender sender, Comm
main.messages.getConfig().getString("common.prefix", "&b&lPhantomWorlds: &7"),
true),
new MultiMessage.Placeholder("world", worldName, false),
new MultiMessage.Placeholder("time", quickTimer.getTimer() + "", false),
new MultiMessage.Placeholder("time", Long.toString(quickTimer.getDuration()), false),
new MultiMessage.Placeholder("label", label, false)
))).send(sender);
}
Expand All @@ -516,7 +516,7 @@ public List<String> parseTabCompletion(PhantomWorlds main, CommandSender sender,
}

if(args.length == 2) {
return Collections.singletonList("MyNewWorld");
return Collections.singletonList("ExampleWorldName");
}

if(args.length == 3) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void parseCommand(@NotNull PhantomWorlds main, CommandSender sender, Comm
main.getDescription().getAuthors()), false),
new MultiMessage.Placeholder("contributors",
String.join(main.messages.getConfig().getString("common.list-delimiter", "&7, &b"),
main.contributors), false),
main.CONTRIBUTORS), false),
new MultiMessage.Placeholder("supportedServerVersions", main.supportedServerVersions,
false)
))).send(sender);
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/me/lokka30/phantomworlds/misc/Utils.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package me.lokka30.phantomworlds.misc;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import me.lokka30.microlib.messaging.MessageUtils;
import me.lokka30.phantomworlds.PhantomWorlds;
import org.bukkit.Bukkit;
Expand All @@ -13,6 +9,11 @@
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

/**
* This class contains Utility methods which are public & static which are used by multiple classes.
* If a method is only used by one class then it is advised to keep it in the class to avoid
Expand All @@ -34,7 +35,7 @@ public class Utils {
* This method returns a list of the names of worlds that are loaded on the server. Used in tab
* completion, for example.
*
* @return list of world names
* @return set of world names
* @author lokka30
* @since v2.0.0
*/
Expand Down Expand Up @@ -148,7 +149,7 @@ public static List<String> enumValuesToStringList(Object[] values) {
}

/**
* Credit: https://stackoverflow.com/q/11701399
* Credit: <a href="https://stackoverflow.com/q/11701399">StackOverflow</a>
*
* @param val value to round
* @return val, rounded to 2 decimal places.
Expand Down

0 comments on commit 1a970ad

Please sign in to comment.