1.5.0 Release Canidate 2 (Previously 1.4.3)

This commit is contained in:
Tyler Murphy 2022-05-18 21:45:38 -04:00
parent 0bcb3dee0e
commit e79c4ad1c5
9 changed files with 61 additions and 31 deletions

View file

@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion>
<groupId>net.tylermurphy</groupId>
<artifactId>HideAndSeek</artifactId>
<version>1.4.3</version>
<artifactId>KenshinsHideAndSeek</artifactId>
<version>1.5.0</version>
<name>Hide and Seek Plugin</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View file

@ -24,6 +24,7 @@ import net.tylermurphy.hideAndSeek.configuration.Items;
import net.tylermurphy.hideAndSeek.configuration.Localization;
import net.tylermurphy.hideAndSeek.database.Database;
import net.tylermurphy.hideAndSeek.game.Board;
import net.tylermurphy.hideAndSeek.game.PlayerLoader;
import net.tylermurphy.hideAndSeek.game.util.Status;
import net.tylermurphy.hideAndSeek.util.CommandHandler;
import net.tylermurphy.hideAndSeek.game.Game;
@ -31,6 +32,7 @@ import net.tylermurphy.hideAndSeek.game.listener.*;
import net.tylermurphy.hideAndSeek.util.PAPIExpansion;
import net.tylermurphy.hideAndSeek.util.TabCompleter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
@ -44,6 +46,9 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static net.tylermurphy.hideAndSeek.configuration.Config.exitPosition;
import static net.tylermurphy.hideAndSeek.configuration.Config.exitWorld;
public class Main extends JavaPlugin implements Listener {
private static Main instance;
@ -56,11 +61,7 @@ public class Main extends JavaPlugin implements Listener {
public Main() {
super();
instance = this;
Config.loadConfig();
Localization.loadLocalization();
Items.loadItems();
onConstructed();
board = new Board();
database = new Database();
@ -68,15 +69,27 @@ public class Main extends JavaPlugin implements Listener {
protected Main(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
super(loader, description, dataFolder, file);
onConstructed();
board = new Board();
database = new Database();
}
private void onConstructed(){
instance = this;
Matcher matcher = Pattern.compile("MC: \\d\\.(\\d+)").matcher(Bukkit.getVersion());
if (matcher.find()) {
version = Integer.parseInt(matcher.group(1));
} else {
throw new IllegalArgumentException("Failed to parse server version from: " + Bukkit.getVersion());
}
Config.loadConfig();
Localization.loadLocalization();
Items.loadItems();
board = new Board();
database = new Database();
}
public void onEnable() {
@ -94,16 +107,18 @@ public class Main extends JavaPlugin implements Listener {
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PAPIExpansion().register();
}
Matcher matcher = Pattern.compile("MC: \\d\\.(\\d+)").matcher(Bukkit.getVersion());
if (matcher.find()) {
version = Integer.parseInt(matcher.group(1));
} else {
throw new IllegalArgumentException("Failed to parse server version from: " + Bukkit.getVersion());
}
}
public void onDisable() {
version = 0;
board.getPlayers().forEach(player -> {
board.removeBoard(player);
PlayerLoader.unloadPlayer(player);
player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
});
Bukkit.getServer().getMessenger().unregisterOutgoingPluginChannel(this);
board.cleanup();
}

View file

@ -26,7 +26,7 @@ public class About implements ICommand {
public void execute(Player sender, String[] args) {
sender.sendMessage(
String.format("%s%sHide and Seek %s(%s1.4.3%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
String.format("%s%sHide and Seek %s(%s1.5.0%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
);

View file

@ -46,12 +46,25 @@ public class ConfigManager {
private ConfigManager(String filename, String defaultFilename) {
this.defaultFilename = defaultFilename;
this.file = new File(Main.getInstance().getDataFolder(), filename);
File dataFolder = Main.getInstance().getDataFolder();
File oldDataFolder = new File(Main.getInstance().getDataFolder().getParent() + File.separator + "HideAndSeek");
File folder = Main.getInstance().getDataFolder();
if (!folder.exists()) {
if (!folder.mkdirs()) {
this.defaultFilename = defaultFilename;
this.file = new File(dataFolder, filename);
if(oldDataFolder.exists()){
if(!dataFolder.exists()){
if(!oldDataFolder.renameTo(dataFolder)){
throw new RuntimeException("Could not rename folder: " + oldDataFolder.getPath());
}
} else {
throw new RuntimeException("Plugin folders for HideAndSeek & KenshinsHideAndSeek both exists. There can only be one!");
}
}
if (!dataFolder.exists()) {
if (!dataFolder.mkdirs()) {
throw new RuntimeException("Failed to make directory: " + file.getPath());
}
}

View file

@ -79,11 +79,11 @@ public class Board {
}
public List<Player> getHiders() {
return Hider.stream().map(playerList::get).collect(Collectors.toList());
return Hider.stream().filter(Objects::nonNull).map(playerList::get).collect(Collectors.toList());
}
public List<Player> getSeekers() {
return Seeker.stream().map(playerList::get).collect(Collectors.toList());
return Seeker.stream().filter(Objects::nonNull).map(playerList::get).collect(Collectors.toList());
}
public Player getFirstSeeker() {
@ -91,11 +91,11 @@ public class Board {
}
public List<Player> getSpectators() {
return Spectator.stream().map(playerList::get).collect(Collectors.toList());
return Spectator.stream().filter(Objects::nonNull).map(playerList::get).collect(Collectors.toList());
}
public List<Player> getPlayers() {
return new ArrayList<>(playerList.values());
return playerList.values().stream().filter(Objects::nonNull).collect(Collectors.toList());
}
public Player getPlayer(UUID uuid) {

View file

@ -121,11 +121,11 @@ public class Game {
board.addSeeker(seeker);
PlayerLoader.loadSeeker(seeker, getGameWorld());
board.getPlayers().forEach(player -> {
board.createGameBoard(player);
if(board.isSeeker(player)) return;
board.addHider(player);
PlayerLoader.loadHider(player, getGameWorld());
});
board.getPlayers().forEach(board::createGameBoard);
worldBorder.resetWorldBorder(getGameWorld());
if (gameLength > 0) gameTimer = gameLength;
status = Status.STARTING;

View file

@ -69,9 +69,9 @@ public class DamageHandler implements Listener {
// Spectators cannot take damage
if (board.isSpectator(player)) {
event.setCancelled(true);
if (Main.getInstance().supports(18) && player.getLocation().getY() < -64) {
if (Main.getInstance().supports(18) && player.getLocation().getBlockY() < -64) {
player.teleport(new Location(Bukkit.getWorld(game.getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
} else if (player.getLocation().getY() < 0) {
} else if (!Main.getInstance().supports(18) && player.getLocation().getY() < 0) {
player.teleport(new Location(Bukkit.getWorld(game.getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
}
return;

View file

@ -21,6 +21,7 @@ package net.tylermurphy.hideAndSeek.world;
import net.tylermurphy.hideAndSeek.Main;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
@ -55,6 +56,7 @@ public class WorldLoader {
Main.getInstance().getLogger().warning(saveName + " already unloaded.");
return;
}
world.getPlayers().forEach(player -> player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ())));
if (Bukkit.getServer().unloadWorld(world, false)) {
Main.getInstance().getLogger().info("Successfully unloaded " + saveName);
}else{

View file

@ -1,6 +1,6 @@
name: HideAndSeek
name: KenshinsHideAndSeek
main: net.tylermurphy.hideAndSeek.Main
version: 1.4.3
version: 1.5.0
author: KenshinEto
load: STARTUP
api-version: 1.13