fixes and features
- finished Maven implementation - removed Ant build version auto-increment because of Maven - added "send-tp-message-on-join" entry to config to enable/disable the "teleport-to-hub-on-join" message - renamed CommonValues to PluginCache
This commit is contained in:
parent
eb7feb4a87
commit
4fd71e0241
@ -1,9 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module type="JAVA_MODULE" version="4">
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_9">
|
||||||
<exclude-output />
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
@ -27,5 +30,12 @@
|
|||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
</orderEntry>
|
</orderEntry>
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.15-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.15.2-R0.1-SNAPSHOT" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -1,38 +0,0 @@
|
|||||||
<project name="BuildIncrement" default="init" basedir=".">
|
|
||||||
<description>
|
|
||||||
simple example increment build variable
|
|
||||||
</description>
|
|
||||||
<!-- set global properties for this build -->
|
|
||||||
<property name="src" location="src"/>
|
|
||||||
<property name="version" value="10.0"/>
|
|
||||||
<loadproperties>
|
|
||||||
<file file="build.number"/>
|
|
||||||
</loadproperties>
|
|
||||||
|
|
||||||
<target name="init">
|
|
||||||
<echo file="ant_buildversion_init.txt">Changing build version from BUILD_VERSION to ${version}.${build.number} in file plugin.yml...</echo>
|
|
||||||
|
|
||||||
<replaceregexp file="${src}/main/resources/plugin.yml"
|
|
||||||
match="BUILD_NUMBER"
|
|
||||||
replace="${version}.${build.number}"
|
|
||||||
byline="true"
|
|
||||||
/>
|
|
||||||
<echo file="ant_buildversion_init.txt">Changed!</echo>
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
|
|
||||||
<target name="end">
|
|
||||||
<echo file="ant_buildversion_end.txt">Changing back build version ${version}.${build.number} in file plugin.yml to BUILD_VERSION...</echo>
|
|
||||||
|
|
||||||
|
|
||||||
<replaceregexp file="${src}/java/resources/plugin.yml"
|
|
||||||
match="${version}.${build.number}"
|
|
||||||
replace="BUILD_NUMBER"
|
|
||||||
byline="true"
|
|
||||||
/>
|
|
||||||
<buildnumber/>
|
|
||||||
<echo file="ant_buildversion_init.txt">Changed!</echo>
|
|
||||||
|
|
||||||
</target>
|
|
||||||
</project>
|
|
@ -1 +0,0 @@
|
|||||||
Changing back build version 10.0.166 in file plugin.yml to BUILD_VERSION...
|
|
@ -1 +0,0 @@
|
|||||||
Changed!
|
|
@ -1,5 +0,0 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
|
||||||
#Fri Jun 12 13:54:11 CEST 2020
|
|
||||||
\#Build=Number for ANT. Do not edit\!
|
|
||||||
build.number=167
|
|
||||||
\#Tue=Jul 30 16\:09\:09 CEST 2019
|
|
3
buildNumber.properties
Normal file
3
buildNumber.properties
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#maven.buildNumber.plugin properties file
|
||||||
|
#Thu Jun 25 19:47:56 CEST 2020
|
||||||
|
buildNumber=180
|
48
pom.xml
48
pom.xml
@ -6,7 +6,13 @@
|
|||||||
|
|
||||||
<groupId>net.mindoverflow.hubthat</groupId>
|
<groupId>net.mindoverflow.hubthat</groupId>
|
||||||
<artifactId>HubThat</artifactId>
|
<artifactId>HubThat</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>10.1</version>
|
||||||
|
<scm>
|
||||||
|
<connection>scm:svn:http://127.0.0.1/dummy</connection>
|
||||||
|
<developerConnection>scm:svn:https://127.0.0.1/dummy</developerConnection>
|
||||||
|
<tag>HEAD</tag>
|
||||||
|
<url>http://127.0.0.1/dummy</url>
|
||||||
|
</scm>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -18,12 +24,46 @@
|
|||||||
</archive>
|
</archive>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||||
|
<version>1.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>buildnumber</id>
|
||||||
|
<phase>validate</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>create</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<format>{0,number}</format>
|
||||||
|
<items>
|
||||||
|
<item>buildNumber</item>
|
||||||
|
</items>
|
||||||
|
<doCheck>false</doCheck>
|
||||||
|
<doUpdate>false</doUpdate>
|
||||||
|
<revisionOnScmFailure>unknownbuild</revisionOnScmFailure>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<!-- Filter for version name in properties -->
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<includes>
|
||||||
|
<include>*.yml</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>1.9</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.9</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<versionName>${project.version}</versionName>
|
||||||
</properties>
|
</properties>
|
||||||
<repositories>
|
<repositories>
|
||||||
<!-- This adds the Spigot Maven repository to the build -->
|
<!-- This adds the Spigot Maven repository to the build -->
|
||||||
@ -38,7 +78,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class HubCommand implements CommandExecutor
|
public class HubCommand implements CommandExecutor
|
||||||
@ -89,10 +88,10 @@ public class HubCommand implements CommandExecutor
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Check if he's not already teleporting.
|
// Check if he's not already teleporting.
|
||||||
if(!CommonValues.teleporting.contains(username))
|
if(!PluginCache.teleporting.contains(username))
|
||||||
{
|
{
|
||||||
// Put the player in the ArrayList of players waiting to be teleported.
|
// Put the player in the ArrayList of players waiting to be teleported.
|
||||||
CommonValues.teleporting.add(username);
|
PluginCache.teleporting.add(username);
|
||||||
// Load the teleportation delay.
|
// Load the teleportation delay.
|
||||||
int delay = FileUtils.FileType.CONFIG_YAML.yaml.getInt(ConfigEntries.HUB_DELAY.path);
|
int delay = FileUtils.FileType.CONFIG_YAML.yaml.getInt(ConfigEntries.HUB_DELAY.path);
|
||||||
|
|
||||||
@ -108,11 +107,11 @@ public class HubCommand implements CommandExecutor
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if(!CommonValues.cancelRunnable.contains(username) && CommonValues.teleporting.contains(username))
|
if(!PluginCache.cancelRunnable.contains(username) && PluginCache.teleporting.contains(username))
|
||||||
{
|
{
|
||||||
teleportToHub(commandSender, (Player)commandSender);
|
teleportToHub(commandSender, (Player)commandSender);
|
||||||
}
|
}
|
||||||
CommonValues.cancelRunnable.remove(username);
|
PluginCache.cancelRunnable.remove(username);
|
||||||
|
|
||||||
}
|
}
|
||||||
}, delay * 20); // Convert seconds to ticks.
|
}, delay * 20); // Convert seconds to ticks.
|
||||||
@ -136,15 +135,20 @@ public class HubCommand implements CommandExecutor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to teleport the player to the hub.
|
public static void teleportToHub(CommandSender actor, Player player, boolean sendMessage)
|
||||||
public static void teleportToHub(CommandSender actor, Player player)
|
|
||||||
{
|
{
|
||||||
String username = player.getName();
|
String username = player.getName();
|
||||||
|
|
||||||
// Teleport the player to the destination.
|
// Teleport the player to the destination.
|
||||||
TeleportUtils.teleportPlayer(actor, player, FileUtils.FileType.HUB_YAML);
|
TeleportUtils.teleportPlayer(actor, player, FileUtils.FileType.HUB_YAML, sendMessage);
|
||||||
|
|
||||||
// Remove it from the "teleporting" list - so it won't get teleported if it's waiting the spawn delay.
|
// Remove it from the "teleporting" list - so it won't get teleported if it's waiting the spawn delay.
|
||||||
CommonValues.teleporting.remove(username);
|
PluginCache.teleporting.remove(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to teleport the player to the hub.
|
||||||
|
public static void teleportToHub(CommandSender actor, Player player)
|
||||||
|
{
|
||||||
|
teleportToHub(actor, player, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import net.mindoverflow.hubthat.commands.hubthatcommands.HelpCommand;
|
|||||||
import net.mindoverflow.hubthat.commands.hubthatcommands.ReloadCommand;
|
import net.mindoverflow.hubthat.commands.hubthatcommands.ReloadCommand;
|
||||||
import net.mindoverflow.hubthat.utils.Debugger;
|
import net.mindoverflow.hubthat.utils.Debugger;
|
||||||
import net.mindoverflow.hubthat.utils.MessageUtils;
|
import net.mindoverflow.hubthat.utils.MessageUtils;
|
||||||
|
import net.mindoverflow.hubthat.utils.PluginCache;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -46,10 +47,10 @@ public class HubThatCommand implements CommandExecutor
|
|||||||
// Check if there are any args.
|
// Check if there are any args.
|
||||||
if(args.length == 0)
|
if(args.length == 0)
|
||||||
{
|
{
|
||||||
MessageUtils.sendColorizedMessage(commandSender, "&7HubThat version &6" + plugin.getDescription().getVersion() + " for SpigotMC/CraftBukkit &61.7&7-&61.15&7.");
|
MessageUtils.sendColorizedMessage(commandSender, "&6" + plugin.getName() +"&7 version &6" + plugin.getDescription().getVersion() + "&7 for &6SpigotMC/CraftBukkit &6" + PluginCache.minSupportedVersion + "&7-&6" + PluginCache.maxSupportedVersion + "&7.");
|
||||||
MessageUtils.sendColorizedMessage(commandSender, "&7Coded by &6mind_overflow&7, all rights reserved (&6Copyright © '20&7).");
|
MessageUtils.sendColorizedMessage(commandSender, "&7Coded by &6" + debugger.authorName + "&7, all rights reserved (&6Copyright © '20&7).");
|
||||||
commandSender.sendMessage("");
|
commandSender.sendMessage("");
|
||||||
MessageUtils.sendColorizedMessage(commandSender, "&7Write &6/hubthat help&7 to see plugin commands.");
|
MessageUtils.sendColorizedMessage(commandSender, "&7Write &6/"+ plugin.getName().toLowerCase() + " help&7 to see plugin commands.");
|
||||||
}
|
}
|
||||||
// Check if there is a single argument after the command itself.
|
// Check if there is a single argument after the command itself.
|
||||||
else if (args.length == 1)
|
else if (args.length == 1)
|
||||||
|
@ -96,7 +96,7 @@ public class SpawnCommand implements CommandExecutor
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Check if he's not already teleporting.
|
// Check if he's not already teleporting.
|
||||||
if(!CommonValues.teleporting.contains(username))
|
if(!PluginCache.teleporting.contains(username))
|
||||||
{
|
{
|
||||||
if(args.length > 0)
|
if(args.length > 0)
|
||||||
{
|
{
|
||||||
@ -126,18 +126,18 @@ public class SpawnCommand implements CommandExecutor
|
|||||||
MessageUtils.sendColorizedMessage(commandSender, delayMessage);
|
MessageUtils.sendColorizedMessage(commandSender, delayMessage);
|
||||||
|
|
||||||
// Put the player in the ArrayList of players waiting to be teleported.
|
// Put the player in the ArrayList of players waiting to be teleported.
|
||||||
CommonValues.teleporting.add(username);
|
PluginCache.teleporting.add(username);
|
||||||
// Start a timer.
|
// Start a timer.
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,() ->
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,() ->
|
||||||
{
|
{
|
||||||
if(!CommonValues.cancelRunnable.contains(username) && CommonValues.teleporting.contains(username))
|
if(!PluginCache.cancelRunnable.contains(username) && PluginCache.teleporting.contains(username))
|
||||||
{
|
{
|
||||||
|
|
||||||
// Run method to check if there are any args and teleport the player accordingly.
|
// Run method to check if there are any args and teleport the player accordingly.
|
||||||
checkArgsAndTeleport(args, commandSender);
|
checkArgsAndTeleport(args, commandSender);
|
||||||
|
|
||||||
}
|
}
|
||||||
CommonValues.cancelRunnable.remove(username);
|
PluginCache.cancelRunnable.remove(username);
|
||||||
|
|
||||||
}, delay * 20); // Convert seconds to ticks.
|
}, delay * 20); // Convert seconds to ticks.
|
||||||
return true;
|
return true;
|
||||||
@ -201,6 +201,6 @@ public class SpawnCommand implements CommandExecutor
|
|||||||
TeleportUtils.teleportPlayer(sender, player, FileUtils.FileType.SPAWN_YAML, worldName);
|
TeleportUtils.teleportPlayer(sender, player, FileUtils.FileType.SPAWN_YAML, worldName);
|
||||||
// Remove the player from the teleporting list, since it's not teleporting anymore.
|
// Remove the player from the teleporting list, since it's not teleporting anymore.
|
||||||
// Also remove it from the "teleporting" list - so it won't get teleported if it's waiting the hub delay.
|
// Also remove it from the "teleporting" list - so it won't get teleported if it's waiting the hub delay.
|
||||||
CommonValues.teleporting.remove(username);
|
PluginCache.teleporting.remove(username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package net.mindoverflow.hubthat.commands;
|
|||||||
|
|
||||||
import net.mindoverflow.hubthat.HubThat;
|
import net.mindoverflow.hubthat.HubThat;
|
||||||
import net.mindoverflow.hubthat.utils.*;
|
import net.mindoverflow.hubthat.utils.*;
|
||||||
|
import org.bukkit.Difficulty;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -47,26 +48,29 @@ public class WorldListCommand implements CommandExecutor
|
|||||||
i++;
|
i++;
|
||||||
// Store world type and difficulty.
|
// Store world type and difficulty.
|
||||||
String worldType = currentWorld.getWorldType().getName().toLowerCase();
|
String worldType = currentWorld.getWorldType().getName().toLowerCase();
|
||||||
String worldDifficulty = currentWorld.getDifficulty().name().toLowerCase();
|
|
||||||
|
Difficulty difficulty = currentWorld.getDifficulty();
|
||||||
|
String worldDifficulty = difficulty.name().toLowerCase();
|
||||||
|
if(difficulty == Difficulty.PEACEFUL) worldDifficulty = "&b" + worldDifficulty;
|
||||||
|
else if(difficulty == Difficulty.EASY) worldDifficulty = "&a" + worldDifficulty;
|
||||||
|
else if(difficulty == Difficulty.NORMAL) worldDifficulty = "&e" + worldDifficulty;
|
||||||
|
else if(difficulty == Difficulty.HARD) worldDifficulty = "&c" + worldDifficulty;
|
||||||
|
|
||||||
World.Environment environment = currentWorld.getEnvironment();
|
World.Environment environment = currentWorld.getEnvironment();
|
||||||
String worldEnvironment = environment.name().toLowerCase();
|
String worldEnvironment = environment.name().toLowerCase();
|
||||||
if(environment == World.Environment.NETHER) worldEnvironment = "&c" + worldEnvironment;
|
if(environment == World.Environment.NETHER) worldEnvironment = "&c" + worldEnvironment;
|
||||||
else if(environment == World.Environment.THE_END) worldEnvironment = "&d" + worldEnvironment;
|
else if(environment == World.Environment.THE_END) worldEnvironment = "&dend";
|
||||||
else if(environment == World.Environment.NORMAL) worldEnvironment = "&a" + worldEnvironment;
|
else if(environment == World.Environment.NORMAL) worldEnvironment = "&a" + worldEnvironment;
|
||||||
|
|
||||||
// Store player numbers. We have a list of all players, so we will need to iterate through all of them.
|
// Store player numbers.
|
||||||
int playersNumber = 0;
|
int playersNumber = currentWorld.getPlayers().size();
|
||||||
for(Player p : currentWorld.getPlayers())
|
|
||||||
{
|
|
||||||
playersNumber++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the completed message.
|
// Send the completed message.
|
||||||
MessageUtils.sendColorizedMessage(commandSender, "&3" + i + "&7: &b" + currentWorld.getName() +
|
MessageUtils.sendColorizedMessage(commandSender, "&3" + i + "&7: &b" + currentWorld.getName() +
|
||||||
"&7, type: &e" + worldType +
|
"&7, type: &e" + worldType + //type (flat, normal, large biomes)
|
||||||
"&7, players: &e" + playersNumber +
|
"&7, pl: &e" + playersNumber + //players
|
||||||
"&7, difficulty: &e" + worldDifficulty +
|
"&7, diff: &e" + worldDifficulty +//difficulty (peaceful, easy, normal, hard)
|
||||||
"&7, environment: &e" + worldEnvironment);
|
"&7, env: &e" + worldEnvironment); //environment (normal, nether, the_end)
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageUtils.sendColorizedMessage(commandSender, "&7---------");
|
MessageUtils.sendColorizedMessage(commandSender, "&7---------");
|
||||||
|
@ -73,7 +73,7 @@ public class WorldTpCommand implements CommandExecutor
|
|||||||
// Cast Player to commandSender so we can teleport it.
|
// Cast Player to commandSender so we can teleport it.
|
||||||
Player player = (Player)commandSender;
|
Player player = (Player)commandSender;
|
||||||
// Teleport the Player.
|
// Teleport the Player.
|
||||||
fixInvisibilityBefore(player, destinationLocation);
|
fixInvisibilityBefore(destinationLocation);
|
||||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> player.teleport(destinationLocation), 1);
|
plugin.getServer().getScheduler().runTaskLater(plugin, () -> player.teleport(destinationLocation), 1);
|
||||||
fixInvisibilityAfter(player);
|
fixInvisibilityAfter(player);
|
||||||
// Tell the player he has been teleported.
|
// Tell the player he has been teleported.
|
||||||
|
@ -5,6 +5,7 @@ import net.mindoverflow.hubthat.commands.HubCommand;
|
|||||||
import net.mindoverflow.hubthat.utils.ConfigEntries;
|
import net.mindoverflow.hubthat.utils.ConfigEntries;
|
||||||
import net.mindoverflow.hubthat.utils.Debugger;
|
import net.mindoverflow.hubthat.utils.Debugger;
|
||||||
import net.mindoverflow.hubthat.utils.MessageUtils;
|
import net.mindoverflow.hubthat.utils.MessageUtils;
|
||||||
|
import net.mindoverflow.hubthat.utils.PluginCache;
|
||||||
import net.mindoverflow.hubthat.utils.files.FileUtils;
|
import net.mindoverflow.hubthat.utils.files.FileUtils;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -87,11 +88,11 @@ public class PlayerJoinListener implements Listener
|
|||||||
|
|
||||||
if(configYaml.getBoolean(ConfigEntries.MULTIVERSE_BYPASS.path))
|
if(configYaml.getBoolean(ConfigEntries.MULTIVERSE_BYPASS.path))
|
||||||
{
|
{
|
||||||
plugin.getServer().getScheduler().runTaskLater(plugin, ()-> HubCommand.teleportToHub(player, player), 10L);
|
plugin.getServer().getScheduler().runTaskLater(plugin, ()-> HubCommand.teleportToHub(player, player, PluginCache.sendJoinTpMessage), 10L);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HubCommand.teleportToHub(player, player);
|
HubCommand.teleportToHub(player, player, PluginCache.sendJoinTpMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package net.mindoverflow.hubthat.listeners;
|
package net.mindoverflow.hubthat.listeners;
|
||||||
|
|
||||||
import net.mindoverflow.hubthat.utils.CommonValues;
|
import net.mindoverflow.hubthat.utils.PluginCache;
|
||||||
import net.mindoverflow.hubthat.utils.ConfigEntries;
|
import net.mindoverflow.hubthat.utils.ConfigEntries;
|
||||||
import net.mindoverflow.hubthat.utils.LocalizedMessages;
|
import net.mindoverflow.hubthat.utils.LocalizedMessages;
|
||||||
import net.mindoverflow.hubthat.utils.MessageUtils;
|
import net.mindoverflow.hubthat.utils.MessageUtils;
|
||||||
@ -23,7 +23,7 @@ public class PlayerMoveListener implements Listener
|
|||||||
String playerName = event.getPlayer().getName();
|
String playerName = event.getPlayer().getName();
|
||||||
|
|
||||||
// Check if the player is waiting the teleport delay.
|
// Check if the player is waiting the teleport delay.
|
||||||
if (CommonValues.teleporting.contains(playerName))
|
if (PluginCache.teleporting.contains(playerName))
|
||||||
{
|
{
|
||||||
// Check if the player moved a whole block.
|
// Check if the player moved a whole block.
|
||||||
if(event.getFrom().getBlockX() != event.getTo().getBlockX() ||
|
if(event.getFrom().getBlockX() != event.getTo().getBlockX() ||
|
||||||
@ -31,8 +31,8 @@ public class PlayerMoveListener implements Listener
|
|||||||
event.getFrom().getBlockZ() != event.getTo().getBlockZ())
|
event.getFrom().getBlockZ() != event.getTo().getBlockZ())
|
||||||
{
|
{
|
||||||
// Remove the player from the list and warn him.
|
// Remove the player from the list and warn him.
|
||||||
CommonValues.teleporting.remove(playerName);
|
PluginCache.teleporting.remove(playerName);
|
||||||
CommonValues.cancelRunnable.add(playerName);
|
PluginCache.cancelRunnable.add(playerName);
|
||||||
MessageUtils.sendLocalizedMessage(event.getPlayer(), LocalizedMessages.WARNING_TELEPORTATION_CANCELLED);
|
MessageUtils.sendLocalizedMessage(event.getPlayer(), LocalizedMessages.WARNING_TELEPORTATION_CANCELLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@ public enum ConfigEntries
|
|||||||
|
|
||||||
TELEPORTATION_TP_HUB_ON_JOIN("teleportation.teleport-to-hub-on-join"),
|
TELEPORTATION_TP_HUB_ON_JOIN("teleportation.teleport-to-hub-on-join"),
|
||||||
|
|
||||||
|
TELEPORTATION_TP_MESSAGE_ON_JOIN("teleportation.send-tp-message-on-join"),
|
||||||
|
|
||||||
TELEPORTATION_TP_HUB_ON_RESPAWN("teleportation.teleport-to-hub-on-respawn"),
|
TELEPORTATION_TP_HUB_ON_RESPAWN("teleportation.teleport-to-hub-on-respawn"),
|
||||||
|
|
||||||
MULTIVERSE_BYPASS("settings.multiverse-bypass"),
|
MULTIVERSE_BYPASS("settings.multiverse-bypass"),
|
||||||
|
@ -5,7 +5,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class CommonValues
|
public class PluginCache
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -14,5 +14,9 @@ public class CommonValues
|
|||||||
|
|
||||||
public static Boolean updateChecker = true;
|
public static Boolean updateChecker = true;
|
||||||
public static boolean invisibilityFix = false; // sometimes, in buggy versions of Spigot, players become invisible after getting teleported. this fixes the problem.
|
public static boolean invisibilityFix = false; // sometimes, in buggy versions of Spigot, players become invisible after getting teleported. this fixes the problem.
|
||||||
|
public static boolean sendJoinTpMessage = true;
|
||||||
public static final ItemStack AIR = new ItemStack(Material.AIR, 1);
|
public static final ItemStack AIR = new ItemStack(Material.AIR, 1);
|
||||||
|
|
||||||
|
public static final double minSupportedVersion = 1.7;
|
||||||
|
public static final double maxSupportedVersion = 1.16;
|
||||||
}
|
}
|
@ -26,7 +26,7 @@ public class TeleportUtils
|
|||||||
Player player = plugin.getServer().getPlayer(playerName);
|
Player player = plugin.getServer().getPlayer(playerName);
|
||||||
if(player == null) return;
|
if(player == null) return;
|
||||||
|
|
||||||
fixInvisibilityBefore(player, location);
|
fixInvisibilityBefore(location);
|
||||||
plugin.getServer().getScheduler().runTaskLater(plugin, () ->
|
plugin.getServer().getScheduler().runTaskLater(plugin, () ->
|
||||||
{
|
{
|
||||||
player.teleport(location);
|
player.teleport(location);
|
||||||
@ -35,7 +35,7 @@ public class TeleportUtils
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Method to teleport a player, given its username and defined if it's a hub or a spawn.
|
// Method to teleport a player, given its username and defined if it's a hub or a spawn.
|
||||||
public static void teleportPlayer(CommandSender sender, Player player, FileUtils.FileType type, String currentWorldName)
|
public static void teleportPlayer(CommandSender sender, Player player, FileUtils.FileType type, String currentWorldName, boolean sendMessage)
|
||||||
{
|
{
|
||||||
// Get the Player object from his playername.
|
// Get the Player object from his playername.
|
||||||
//Player player = plugin.getServer().getPlayer(playerName);
|
//Player player = plugin.getServer().getPlayer(playerName);
|
||||||
@ -88,16 +88,16 @@ public class TeleportUtils
|
|||||||
if(type == FileUtils.FileType.HUB_YAML)
|
if(type == FileUtils.FileType.HUB_YAML)
|
||||||
{
|
{
|
||||||
// send a message about the hub being not set
|
// send a message about the hub being not set
|
||||||
MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_HUB_NOT_SET);
|
if(sendMessage) MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_HUB_NOT_SET);
|
||||||
}
|
}
|
||||||
else if(type == FileUtils.FileType.SPAWN_YAML)
|
else if(type == FileUtils.FileType.SPAWN_YAML)
|
||||||
{
|
{
|
||||||
// send a message about the spawn being not set.
|
// send a message about the spawn being not set.
|
||||||
MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_SPAWN_NOT_SET);
|
if(sendMessage) MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_SPAWN_NOT_SET);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageUtils.sendColorizedMessage(sender, "&cError in code. Contact the developer!");
|
if(sendMessage) MessageUtils.sendColorizedMessage(sender, "&cError in code. Contact the developer!");
|
||||||
}
|
}
|
||||||
// Stop.
|
// Stop.
|
||||||
return;
|
return;
|
||||||
@ -109,7 +109,7 @@ public class TeleportUtils
|
|||||||
if(worldName.equals("__UNSET__") && type == FileUtils.FileType.HUB_YAML)
|
if(worldName.equals("__UNSET__") && type == FileUtils.FileType.HUB_YAML)
|
||||||
{
|
{
|
||||||
// Warn the player about the hub not being set.
|
// Warn the player about the hub not being set.
|
||||||
MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_HUB_NOT_SET);
|
if(sendMessage) MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_HUB_NOT_SET);
|
||||||
// Stop.
|
// Stop.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -120,15 +120,18 @@ public class TeleportUtils
|
|||||||
if(destinationWorld == null)
|
if(destinationWorld == null)
|
||||||
{
|
{
|
||||||
// Tell the player that the world does not exist.
|
// Tell the player that the world does not exist.
|
||||||
String errorWorldNotExistingMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.ERROR_WORLD_NOT_EXISTING, false);
|
if(sendMessage)
|
||||||
errorWorldNotExistingMessage = errorWorldNotExistingMessage.replace("%w%", worldName);
|
{
|
||||||
MessageUtils.sendColorizedMessage(player, errorWorldNotExistingMessage);
|
String errorWorldNotExistingMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.ERROR_WORLD_NOT_EXISTING, false);
|
||||||
|
errorWorldNotExistingMessage = errorWorldNotExistingMessage.replace("%w%", worldName);
|
||||||
|
MessageUtils.sendColorizedMessage(player, errorWorldNotExistingMessage);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the location in a variable and teleport the player to it.
|
// Store the location in a variable and teleport the player to it.
|
||||||
final Location finalLocation = new Location(destinationWorld, x, y, z, (float)yaw, (float)pitch);
|
final Location finalLocation = new Location(destinationWorld, x, y, z, (float)yaw, (float)pitch);
|
||||||
fixInvisibilityBefore(player, finalLocation);
|
fixInvisibilityBefore(finalLocation);
|
||||||
plugin.getServer().getScheduler().runTaskLater(plugin, () ->
|
plugin.getServer().getScheduler().runTaskLater(plugin, () ->
|
||||||
{
|
{
|
||||||
player.teleport(finalLocation);
|
player.teleport(finalLocation);
|
||||||
@ -140,9 +143,9 @@ public class TeleportUtils
|
|||||||
if(type == FileUtils.FileType.HUB_YAML)
|
if(type == FileUtils.FileType.HUB_YAML)
|
||||||
{
|
{
|
||||||
// Send a message to the player about him being successfully teleported.
|
// Send a message to the player about him being successfully teleported.
|
||||||
MessageUtils.sendLocalizedMessage(player, LocalizedMessages.INFO_HUB_TELEPORTED);
|
if(sendMessage) MessageUtils.sendLocalizedMessage(player, LocalizedMessages.INFO_HUB_TELEPORTED);
|
||||||
|
|
||||||
if(sender != player)
|
if((sender != player) && (sendMessage))
|
||||||
{
|
{
|
||||||
String message = MessageUtils.getLocalizedMessage(LocalizedMessages.INFO_HUB_TELEPORTED_OTHER, true).replace("%player%", player.getName());
|
String message = MessageUtils.getLocalizedMessage(LocalizedMessages.INFO_HUB_TELEPORTED_OTHER, true).replace("%player%", player.getName());
|
||||||
sender.sendMessage(message);
|
sender.sendMessage(message);
|
||||||
@ -150,15 +153,26 @@ public class TeleportUtils
|
|||||||
}
|
}
|
||||||
else //if(type == FileUtils.FileType.SPAWN_YAML) // left here but commented, for easy understanding
|
else //if(type == FileUtils.FileType.SPAWN_YAML) // left here but commented, for easy understanding
|
||||||
{
|
{
|
||||||
MessageUtils.sendLocalizedMessage(player, LocalizedMessages.INFO_SPAWN_TELEPORTED);
|
if(sendMessage) MessageUtils.sendLocalizedMessage(player, LocalizedMessages.INFO_SPAWN_TELEPORTED);
|
||||||
|
|
||||||
if(sender != player)
|
if((sender != player) && (sendMessage))
|
||||||
{
|
{
|
||||||
String message = MessageUtils.getLocalizedMessage(LocalizedMessages.INFO_SPAWN_TELEPORTED_OTHER, true).replace("%player%", player.getName()).replace("%world%", worldName);
|
String message = MessageUtils.getLocalizedMessage(LocalizedMessages.INFO_SPAWN_TELEPORTED_OTHER, true).replace("%player%", player.getName()).replace("%world%", worldName);
|
||||||
sender.sendMessage(message);
|
sender.sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void teleportPlayer(CommandSender sender, Player player, FileUtils.FileType type, String currentWorldName)
|
||||||
|
{
|
||||||
|
teleportPlayer(sender, player, type, currentWorldName, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void teleportPlayer(CommandSender sender, Player player, FileUtils.FileType type, boolean sendMessage)
|
||||||
|
{
|
||||||
|
teleportPlayer(sender, player, type, null, sendMessage);
|
||||||
|
}
|
||||||
|
|
||||||
public static void teleportPlayer(CommandSender sender, Player player, FileUtils.FileType type)
|
public static void teleportPlayer(CommandSender sender, Player player, FileUtils.FileType type)
|
||||||
{
|
{
|
||||||
teleportPlayer(sender, player, type, null);
|
teleportPlayer(sender, player, type, null);
|
||||||
@ -166,14 +180,14 @@ public class TeleportUtils
|
|||||||
|
|
||||||
public static void fixInvisibilityAfter(Player player)
|
public static void fixInvisibilityAfter(Player player)
|
||||||
{
|
{
|
||||||
if(CommonValues.invisibilityFix)
|
if(PluginCache.invisibilityFix)
|
||||||
{
|
{
|
||||||
debugger.sendDebugMessage(Level.INFO, "Invisibility fix enabled!");
|
debugger.sendDebugMessage(Level.INFO, "Invisibility fix enabled!");
|
||||||
player.getInventory().addItem(CommonValues.AIR);
|
player.getInventory().addItem(PluginCache.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fixInvisibilityBefore(Player player, Location destination)
|
public static void fixInvisibilityBefore(Location destination)
|
||||||
{
|
{
|
||||||
destination.getChunk().load();
|
destination.getChunk().load();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.mindoverflow.hubthat.utils.files;
|
package net.mindoverflow.hubthat.utils.files;
|
||||||
|
|
||||||
import net.mindoverflow.hubthat.HubThat;
|
import net.mindoverflow.hubthat.HubThat;
|
||||||
import net.mindoverflow.hubthat.utils.CommonValues;
|
import net.mindoverflow.hubthat.utils.PluginCache;
|
||||||
import net.mindoverflow.hubthat.utils.ConfigEntries;
|
import net.mindoverflow.hubthat.utils.ConfigEntries;
|
||||||
import net.mindoverflow.hubthat.utils.Debugger;
|
import net.mindoverflow.hubthat.utils.Debugger;
|
||||||
import net.mindoverflow.hubthat.utils.statistics.UpdateChecker;
|
import net.mindoverflow.hubthat.utils.statistics.UpdateChecker;
|
||||||
@ -61,7 +61,7 @@ public class FileUtils
|
|||||||
|
|
||||||
if(config.getBoolean(ConfigEntries.UPDATE_CHECKER_ENABLED.path))
|
if(config.getBoolean(ConfigEntries.UPDATE_CHECKER_ENABLED.path))
|
||||||
{
|
{
|
||||||
CommonValues.updateChecker = true;
|
PluginCache.updateChecker = true;
|
||||||
if(UpdateChecker.task != null)
|
if(UpdateChecker.task != null)
|
||||||
{
|
{
|
||||||
plugin.getServer().getScheduler().cancelTask(UpdateChecker.task.getTaskId());
|
plugin.getServer().getScheduler().cancelTask(UpdateChecker.task.getTaskId());
|
||||||
@ -70,7 +70,8 @@ public class FileUtils
|
|||||||
UpdateChecker.task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, plugin.updateChecker, 1, 20 * 60 * 60 * 12);
|
UpdateChecker.task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, plugin.updateChecker, 1, 20 * 60 * 60 * 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonValues.invisibilityFix = config.getBoolean(ConfigEntries.INVISIBILITY_FIX.path);
|
PluginCache.invisibilityFix = config.getBoolean(ConfigEntries.INVISIBILITY_FIX.path);
|
||||||
|
PluginCache.sendJoinTpMessage = config.getBoolean(ConfigEntries.TELEPORTATION_TP_MESSAGE_ON_JOIN.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only reload the needed File.
|
// Only reload the needed File.
|
||||||
|
@ -233,7 +233,7 @@ public class UpdateChecker implements Runnable
|
|||||||
if(!(player instanceof Player)) return;
|
if(!(player instanceof Player)) return;
|
||||||
|
|
||||||
// Check if the updater is enabled.
|
// Check if the updater is enabled.
|
||||||
if(CommonValues.updateChecker)
|
if(PluginCache.updateChecker)
|
||||||
{
|
{
|
||||||
debugger.sendDebugMessage(Level.INFO, "Update Checker is enabled!");
|
debugger.sendDebugMessage(Level.INFO, "Update Checker is enabled!");
|
||||||
// Check if the player has permissions to get notifications about updates.
|
// Check if the player has permissions to get notifications about updates.
|
||||||
|
@ -13,6 +13,7 @@ gamemode:
|
|||||||
mode: 0
|
mode: 0
|
||||||
teleportation:
|
teleportation:
|
||||||
teleport-to-hub-on-join: true
|
teleport-to-hub-on-join: true
|
||||||
|
send-tp-message-on-join: true
|
||||||
teleport-to-hub-on-respawn: false
|
teleport-to-hub-on-respawn: false
|
||||||
respawn-handler: true
|
respawn-handler: true
|
||||||
settings:
|
settings:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: HubThat
|
name: HubThat
|
||||||
version: 10.0.167
|
version: ${versionName}.${buildNumber}
|
||||||
author: mind_overflow
|
author: mind_overflow
|
||||||
main: net.mindoverflow.hubthat.HubThat
|
main: net.mindoverflow.hubthat.HubThat
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
Loading…
Reference in New Issue
Block a user