Merge pull request '1.7.5' (#10) from dev into main

Reviewed-on: https://g.tylerm.dev/tylermurphy534/KenshinsHideAndSeek/pulls/10
This commit is contained in:
Murphy 2023-07-30 22:13:49 +00:00
commit a2ea5a635e
100 changed files with 1362 additions and 965 deletions

34
.project Normal file
View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>KenshinsHideAndSeek</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
<filteredResources>
<filter>
<id>1690577727676</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

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>
<groupId>dev.tylerm</groupId>
<artifactId>KenshinsHideAndSeek</artifactId>
<version>1.7.4</version>
<version>1.7.5</version>
<name>Hide and Seek Plugin</name>
<properties>
@ -27,11 +27,11 @@
<relocations>
<relocation>
<pattern>com.cryptomorin.xseries</pattern>
<shadedPattern>net.tylermurphy.dependencies.xseries</shadedPattern>
<shadedPattern>dev.tylerm.depend.xseries</shadedPattern>
</relocation>
<relocation>
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>net.tylermurphy.dependencies.hikari</shadedPattern>
<shadedPattern>dev.tylerm.depend.hikari</shadedPattern>
</relocation>
</relocations>
<artifactSet>

View file

@ -1,18 +1,24 @@
package net.tylermurphy.hideAndSeek;
package dev.tylerm.khs;
import net.tylermurphy.hideAndSeek.command.*;
import net.tylermurphy.hideAndSeek.command.map.*;
import net.tylermurphy.hideAndSeek.command.map.blockhunt.Enabled;
import net.tylermurphy.hideAndSeek.command.map.set.*;
import net.tylermurphy.hideAndSeek.command.world.Create;
import net.tylermurphy.hideAndSeek.command.world.Delete;
import net.tylermurphy.hideAndSeek.command.world.Tp;
import net.tylermurphy.hideAndSeek.configuration.*;
import net.tylermurphy.hideAndSeek.database.Database;
import net.tylermurphy.hideAndSeek.game.*;
import net.tylermurphy.hideAndSeek.command.util.CommandGroup;
import net.tylermurphy.hideAndSeek.game.listener.*;
import net.tylermurphy.hideAndSeek.util.PAPIExpansion;
import dev.tylerm.khs.command.*;
import dev.tylerm.khs.command.map.Debug;
import dev.tylerm.khs.command.map.GoTo;
import dev.tylerm.khs.command.map.Save;
import dev.tylerm.khs.command.map.blockhunt.blocks.Add;
import dev.tylerm.khs.command.map.blockhunt.blocks.List;
import dev.tylerm.khs.command.map.blockhunt.blocks.Remove;
import dev.tylerm.khs.command.map.set.*;
import dev.tylerm.khs.configuration.*;
import dev.tylerm.khs.game.*;
import dev.tylerm.khs.game.listener.*;
import dev.tylerm.khs.game.util.Status;
import dev.tylerm.khs.util.PAPIExpansion;
import dev.tylerm.khs.command.map.blockhunt.Enabled;
import dev.tylerm.khs.command.world.Create;
import dev.tylerm.khs.command.world.Delete;
import dev.tylerm.khs.command.world.Tp;
import dev.tylerm.khs.database.Database;
import dev.tylerm.khs.command.util.CommandGroup;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -27,8 +33,8 @@ import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.*;
import static dev.tylerm.khs.configuration.Localization.message;
public class Main extends JavaPlugin implements Listener {
@ -94,9 +100,9 @@ public class Main extends JavaPlugin implements Listener {
new CommandGroup("map",
new CommandGroup("blockhunt",
new CommandGroup("blocks",
new net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks.Add(),
new net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks.Remove(),
new net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks.List()
new Add(),
new Remove(),
new List()
),
new Enabled()
),
@ -107,10 +113,13 @@ public class Main extends JavaPlugin implements Listener {
new Border(),
new Bounds()
),
new Add(),
new Remove(),
new List(),
new Status(),
new CommandGroup("unset",
new dev.tylerm.khs.command.map.unset.Border()
),
new dev.tylerm.khs.command.map.Add(),
new dev.tylerm.khs.command.map.Remove(),
new dev.tylerm.khs.command.map.List(),
new dev.tylerm.khs.command.map.Status(),
new Save(),
new Debug(),
new GoTo()
@ -118,7 +127,7 @@ public class Main extends JavaPlugin implements Listener {
new CommandGroup("world",
new Create(),
new Delete(),
new net.tylermurphy.hideAndSeek.command.world.List(),
new dev.tylerm.khs.command.world.List(),
new Tp()
),
new SetExitLocation(),
@ -170,7 +179,7 @@ public class Main extends JavaPlugin implements Listener {
}
private void onTick() {
if(game.getStatus() == net.tylermurphy.hideAndSeek.game.util.Status.ENDED) game = new Game(game.getCurrentMap(), board);
if(game.getStatus() == Status.ENDED) game = new Game(game.getCurrentMap(), board);
game.onTick();
disguiser.check();
}

View file

@ -1,14 +1,14 @@
package net.tylermurphy.hideAndSeek.command;
package dev.tylerm.khs.command;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import dev.tylerm.khs.command.util.ICommand;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.function.Consumer;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.errorPrefix;
import static dev.tylerm.khs.configuration.Localization.message;
public class Confirm implements ICommand {

View file

@ -1,8 +1,8 @@
package net.tylermurphy.hideAndSeek.command;
package dev.tylerm.khs.command;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.util.Pair;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.util.Pair;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@ -11,8 +11,8 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.errorPrefix;
import static dev.tylerm.khs.configuration.Localization.message;
public class Help implements ICommand {

View file

@ -1,15 +1,15 @@
package net.tylermurphy.hideAndSeek.command;
package dev.tylerm.khs.command;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.errorPrefix;
import static dev.tylerm.khs.configuration.Localization.message;
public class Join implements ICommand {

View file

@ -1,15 +1,15 @@
package net.tylermurphy.hideAndSeek.command;
package dev.tylerm.khs.command;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.errorPrefix;
import static dev.tylerm.khs.configuration.Localization.message;
public class Leave implements ICommand {

View file

@ -1,17 +1,17 @@
package net.tylermurphy.hideAndSeek.command;
package dev.tylerm.khs.command;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.*;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.*;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.errorPrefix;
import static dev.tylerm.khs.configuration.Config.messagePrefix;
import static dev.tylerm.khs.configuration.Localization.message;
public class Reload implements ICommand {

View file

@ -1,41 +1,40 @@
package net.tylermurphy.hideAndSeek.command;
package dev.tylerm.khs.command;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Send implements ICommand {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
sender.sendMessage(Config.errorPrefix + Localization.message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP"));
return;
}
if(map.isNotSetup()){
sender.sendMessage(errorPrefix + message("MAP_NOT_SETUP"));
sender.sendMessage(Config.errorPrefix + Localization.message("MAP_NOT_SETUP"));
return;
}
if (!Main.getInstance().getBoard().contains(sender)) {
sender.sendMessage(errorPrefix + message("GAME_NOT_INGAME"));
sender.sendMessage(Config.errorPrefix + Localization.message("GAME_NOT_INGAME"));
return;
}
@ -61,7 +60,7 @@ public class Send implements ICommand {
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().filter(map -> !map.isNotSetup()).map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
return Maps.getAllMaps().stream().filter(map -> !map.isNotSetup()).map(Map::getName).collect(Collectors.toList());
}
return null;
}

View file

@ -0,0 +1,42 @@
package dev.tylerm.khs.command;
import dev.tylerm.khs.command.location.LocationUtils;
import dev.tylerm.khs.command.location.Locations;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.util.Location;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class SetExitLocation implements ICommand {
public void execute(Player sender, String[] args) {
LocationUtils.setLocation(sender, Locations.EXIT, null, map -> {
Config.addToConfig("exit.x", sender.getLocation().getBlockX());
Config.addToConfig("exit.y", sender.getLocation().getBlockY());
Config.addToConfig("exit.z", sender.getLocation().getBlockZ());
Config.addToConfig("exit.world", sender.getLocation().getWorld().getName());
Config.exitPosition = Location.from(sender);
Config.saveConfig();
});
}
public String getLabel() {
return "setexit";
}
public String getUsage() {
return "";
}
public String getDescription() {
return "Sets the plugins exit location";
}
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
return null;
}
}

View file

@ -0,0 +1,77 @@
package dev.tylerm.khs.command;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import static dev.tylerm.khs.configuration.Config.*;
import static dev.tylerm.khs.configuration.Localization.message;
public class Start implements ICommand {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().checkCurrentMap()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
if (!Main.getInstance().getBoard().contains(sender)) {
sender.sendMessage(errorPrefix + message("GAME_NOT_INGAME"));
return;
}
if (Main.getInstance().getBoard().size() < minPlayers) {
sender.sendMessage(errorPrefix + message("START_MIN_PLAYERS").addAmount(minPlayers));
return;
}
if (args.length < 1) {
Main.getInstance().getGame().start();
return;
};
List<Player> initialSeekers = new ArrayList<>();
for (int i = 0; i < args.length; i++) {
Player seeker = Bukkit.getPlayer(args[i]);
if (seeker == null || !Main.getInstance().getBoard().contains(seeker) || initialSeekers.contains(seeker)) {
sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(args[i]));
return;
}
initialSeekers.add(seeker);
}
int minHiders = minPlayers - startingSeekerCount;
if (Main.getInstance().getBoard().size() - initialSeekers.size() < minHiders) {
sender.sendMessage(errorPrefix + message("START_MIN_PLAYERS").addAmount(minPlayers));
return;
}
Main.getInstance().getGame().start(initialSeekers);
}
public String getLabel() {
return "start";
}
public String getUsage() {
return "<*seekers...>";
}
public String getDescription() {
return "Starts the game either with a random set of seekers or a chosen list";
}
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
return Main.getInstance().getBoard().getPlayers().stream().map(Player::getName).collect(Collectors.toList());
}
}

View file

@ -1,16 +1,16 @@
package net.tylermurphy.hideAndSeek.command;
package dev.tylerm.khs.command;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.abortPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.abortPrefix;
import static dev.tylerm.khs.configuration.Config.errorPrefix;
import static dev.tylerm.khs.configuration.Localization.message;
public class Stop implements ICommand {

View file

@ -1,8 +1,8 @@
package net.tylermurphy.hideAndSeek.command;
package dev.tylerm.khs.command;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.database.util.PlayerInfo;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@ -10,8 +10,8 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.errorPrefix;
import static dev.tylerm.khs.configuration.Localization.message;
public class Top implements ICommand {

View file

@ -1,8 +1,10 @@
package net.tylermurphy.hideAndSeek.command;
package dev.tylerm.khs.command;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.database.util.PlayerInfo;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@ -11,9 +13,6 @@ import java.util.Collections;
import java.util.List;
import java.util.UUID;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Wins implements ICommand {
public void execute(Player sender, String[] args) {
@ -30,16 +29,16 @@ public class Wins implements ICommand {
uuid = Main.getInstance().getDatabase().getNameData().getUUID(args[0]);
}
if(uuid == null){
sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(args[0]));
sender.sendMessage(Config.errorPrefix + Localization.message("START_INVALID_NAME").addPlayer(args[0]));
return;
}
PlayerInfo info = Main.getInstance().getDatabase().getGameData().getInfo(uuid);
if (info == null) {
sender.sendMessage(errorPrefix + message("NO_GAME_INFO"));
sender.sendMessage(Config.errorPrefix + Localization.message("NO_GAME_INFO"));
return;
}
String message = ChatColor.WHITE + "" + ChatColor.BOLD + "==============================\n";
message = message + message("INFORMATION_FOR").addPlayer(name) + "\n";
message = message + Localization.message("INFORMATION_FOR").addPlayer(name) + "\n";
message = message + "==============================\n";
message = message + String.format("%sTOTAL WINS: %s%s\n%sHIDER WINS: %s%s\n%sSEEKER WINS: %s%s\n%sGAMES PLAYED: %s",
ChatColor.YELLOW, ChatColor.WHITE, info.getSeekerWins() +info.getHiderWins(), ChatColor.GOLD, ChatColor.WHITE, info.getHiderWins(),

View file

@ -1,17 +1,16 @@
package net.tylermurphy.hideAndSeek.command.location;
package dev.tylerm.khs.command.location;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
/**
* @author bobby29831
*/
@ -20,12 +19,12 @@ public class LocationUtils {
public static void setLocation(@NotNull Player player, @NotNull Locations place, String mapName, @NotNull Consumer<Map> consumer) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
player.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
player.sendMessage(Config.errorPrefix + Localization.message("GAME_INPROGRESS"));
return;
}
if (player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0){
player.sendMessage(errorPrefix + message("NOT_AT_ZERO"));
player.sendMessage(Config.errorPrefix + Localization.message("NOT_AT_ZERO"));
return;
}
@ -33,7 +32,7 @@ public class LocationUtils {
if(mapName != null) {
map = Maps.getMap(mapName);
if (map == null) {
player.sendMessage(errorPrefix + message("INVALID_MAP"));
player.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP"));
return;
}
}
@ -41,13 +40,13 @@ public class LocationUtils {
try {
consumer.accept(map);
} catch (Exception e) {
player.sendMessage(errorPrefix + e.getMessage());
player.sendMessage(Config.errorPrefix + e.getMessage());
return;
}
if(map != null)
Maps.setMap(mapName, map);
player.sendMessage(messagePrefix + message(place.message()));
player.sendMessage(Config.messagePrefix + Localization.message(place.message()));
}
}

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.command.location;
package dev.tylerm.khs.command.location;
/**
* @author bobby29831

View file

@ -1,35 +1,33 @@
package net.tylermurphy.hideAndSeek.command.map;
package dev.tylerm.khs.command.map;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Add implements ICommand {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
sender.sendMessage(Config.errorPrefix + Localization.message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map != null) {
sender.sendMessage(errorPrefix + message("MAP_ALREADY_EXISTS"));
sender.sendMessage(Config.errorPrefix + Localization.message("MAP_ALREADY_EXISTS"));
} else if(!args[0].matches("[a-zA-Z0-9]*") || args[0].length() < 1) {
sender.sendMessage(errorPrefix + message("INVALID_MAP_NAME"));
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP_NAME"));
} else {
Maps.setMap(args[0], new Map(args[0]));
sender.sendMessage(messagePrefix + message("MAP_CREATED").addAmount(args[0]));
sender.sendMessage(Config.messagePrefix + Localization.message("MAP_CREATED").addAmount(args[0]));
}
}

View file

@ -1,11 +1,13 @@
package net.tylermurphy.hideAndSeek.command.map;
package dev.tylerm.khs.command.map;
import com.cryptomorin.xseries.XMaterial;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.PlayerLoader;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.PlayerLoader;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -20,46 +22,43 @@ import java.util.Map;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Debug implements ICommand {
private static final Map<Player, Map<Integer, Consumer<Player>>> debugMenuFunctions = new HashMap<>();
public void execute(Player sender, String[] args) {
net.tylermurphy.hideAndSeek.configuration.Map map = Maps.getMap(args[0]);
dev.tylerm.khs.configuration.Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP"));
return;
}
Inventory debugMenu = createMenu(map, sender);
sender.openInventory(debugMenu);
}
private Inventory createMenu(net.tylermurphy.hideAndSeek.configuration.Map map, Player sender){
private Inventory createMenu(dev.tylerm.khs.configuration.Map map, Player sender){
Map<Integer, Consumer<Player>> functions = new HashMap<>();
Inventory debugMenu = Main.getInstance().getServer().createInventory(null, 9, "Debug Menu");
debugMenu.setItem(0, createOption(functions, 0, XMaterial.LEATHER_CHESTPLATE.parseMaterial(), "&6Become a &lHider", 1, player -> {
if(mapSaveEnabled) {
if(Config.mapSaveEnabled) {
if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap();
}
Main.getInstance().getBoard().addHider(player);
PlayerLoader.loadHider(player, map);
if(Main.getInstance().getGame().getStatus() != Status.STARTING)
if(Main.getInstance().getGame().getStatus() != dev.tylerm.khs.game.util.Status.STARTING)
PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
}));
debugMenu.setItem(1, createOption(functions, 1, XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&cBecome a &lSeeker", 1, player -> {
if(mapSaveEnabled) {
if(Config.mapSaveEnabled) {
if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap();
}
Main.getInstance().getBoard().addSeeker(player);
PlayerLoader.loadSeeker(player, map);
if(Main.getInstance().getGame().getStatus() != Status.STARTING)
if(Main.getInstance().getGame().getStatus() != dev.tylerm.khs.game.util.Status.STARTING)
PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
}));
debugMenu.setItem(2, createOption(functions, 2, XMaterial.IRON_CHESTPLATE.parseMaterial(), "&8Become a &lSpectator", 1, player -> {
if(mapSaveEnabled) {
if(Config.mapSaveEnabled) {
if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap();
}
Main.getInstance().getBoard().addSpectator(player);
@ -68,7 +67,7 @@ public class Debug implements ICommand {
debugMenu.setItem(3, createOption(functions, 3, XMaterial.BARRIER.parseMaterial(), "&cUnload from Game", 1, player -> {
Main.getInstance().getBoard().remove(player);
PlayerLoader.unloadPlayer(player);
exitPosition.teleport(player);
Config.exitPosition.teleport(player);
}));
debugMenu.setItem(4, createOption(functions, 4, XMaterial.BARRIER.parseMaterial(), "&cDie In Game", 2, player -> {
if((Main.getInstance().getBoard().isSeeker(player) || Main.getInstance().getBoard().isHider(player)) && Main.getInstance().getGame().getStatus() == Status.PLAYING){
@ -115,7 +114,7 @@ public class Debug implements ICommand {
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
return Maps.getAllMaps().stream().map(dev.tylerm.khs.configuration.Map::getName).collect(Collectors.toList());
}
return null;
}

View file

@ -1,8 +1,10 @@
package net.tylermurphy.hideAndSeek.command.map;
package dev.tylerm.khs.command.map;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@ -10,19 +12,16 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class GoTo implements ICommand {
public void execute(Player sender, String[] args) {
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP"));
return;
}
if (map.isNotSetup()) {
sender.sendMessage(errorPrefix + message("MAP_NOT_SETUP").addAmount(map.getName()));
sender.sendMessage(Config.errorPrefix + Localization.message("MAP_NOT_SETUP").addAmount(map.getName()));
return;
}
switch (args[1].toLowerCase()) {
@ -33,9 +32,9 @@ public class GoTo implements ICommand {
case "seekerlobby":
map.getSeekerLobby().teleport(sender); break;
case "exit":
exitPosition.teleport(sender); break;
Config.exitPosition.teleport(sender); break;
default:
sender.sendMessage(errorPrefix + message("COMMAND_INVALID_ARG").addAmount(args[1].toLowerCase()));
sender.sendMessage(Config.errorPrefix + Localization.message("COMMAND_INVALID_ARG").addAmount(args[1].toLowerCase()));
}
}
@ -53,7 +52,7 @@ public class GoTo implements ICommand {
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList());
} else if(parameter.equals("spawn")) {
return Arrays.asList("spawn","lobby","seekerlobby","exit");
}

View file

@ -1,27 +1,25 @@
package net.tylermurphy.hideAndSeek.command.map;
package dev.tylerm.khs.command.map;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class List implements ICommand {
public void execute(Player sender, String[] args) {
Collection<Map> maps = Maps.getAllMaps();
if(maps.size() < 1) {
sender.sendMessage(errorPrefix + message("NO_MAPS"));
sender.sendMessage(Config.errorPrefix + Localization.message("NO_MAPS"));
return;
}
StringBuilder response = new StringBuilder(messagePrefix + message("LIST_MAPS"));
StringBuilder response = new StringBuilder(Config.messagePrefix + Localization.message("LIST_MAPS"));
for(Map map : maps) {
response.append("\n ").append(map.getName()).append(": ").append(map.isNotSetup() ? ChatColor.RED + "NOT SETUP" : ChatColor.GREEN + "SETUP").append(ChatColor.WHITE);
}

View file

@ -0,0 +1,52 @@
package dev.tylerm.khs.command.map;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.stream.Collectors;
public class Remove implements ICommand {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(Config.errorPrefix + Localization.message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP"));
} else if(!Maps.removeMap(args[0])){
sender.sendMessage(Config.errorPrefix + Localization.message("MAP_FAIL_DELETE").addAmount(args[0]));
} else {
sender.sendMessage(Config.messagePrefix + Localization.message("MAP_DELETED").addAmount(args[0]));
}
}
public String getLabel() {
return "remove";
}
public String getUsage() {
return "<map>";
}
public String getDescription() {
return "Remove a map from the plugin!";
}
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList());
}
return null;
}
}

View file

@ -1,10 +1,12 @@
package net.tylermurphy.hideAndSeek.command.map;
package dev.tylerm.khs.command.map;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@ -13,40 +15,37 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Save implements ICommand {
public static boolean runningBackup = false;
public void execute(Player sender, String[] args) {
if (!mapSaveEnabled) {
sender.sendMessage(errorPrefix + message("MAPSAVE_DISABLED"));
if (!Config.mapSaveEnabled) {
sender.sendMessage(Config.errorPrefix + Localization.message("MAPSAVE_DISABLED"));
return;
}
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
sender.sendMessage(Config.errorPrefix + Localization.message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP"));
return;
}
if (map.getSpawn().isNotSetup()) {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
sender.sendMessage(Config.errorPrefix + Localization.message("ERROR_GAME_SPAWN"));
return;
}
if (map.isBoundsNotSetup()) {
sender.sendMessage(errorPrefix + message("ERROR_MAP_BOUNDS"));
sender.sendMessage(Config.errorPrefix + Localization.message("ERROR_MAP_BOUNDS"));
return;
}
sender.sendMessage(messagePrefix + message("MAPSAVE_START"));
sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING"));
sender.sendMessage(Config.messagePrefix + Localization.message("MAPSAVE_START"));
sender.sendMessage(Config.warningPrefix + Localization.message("MAPSAVE_WARNING"));
World world = map.getSpawn().load();
if (world == null) {
sender.sendMessage(warningPrefix + message("MAPSAVE_FAIL_WORLD"));
sender.sendMessage(Config.warningPrefix + Localization.message("MAPSAVE_FAIL_WORLD"));
return;
}
world.save();
@ -76,7 +75,7 @@ public class Save implements ICommand {
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList());
}
return null;
}

View file

@ -1,58 +1,57 @@
package net.tylermurphy.hideAndSeek.command.map;
package dev.tylerm.khs.command.map;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Status implements ICommand {
public void execute(Player sender, String[] args) {
String msg = message("SETUP").toString();
String msg = Localization.message("SETUP").toString();
int count = 0;
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP"));
return;
}
if (map.getSpawn().getBlockX() == 0 && map.getSpawn().getBlockY() == 0 && map.getSpawn().getBlockZ() == 0 || !map.getSpawn().exists()) {
msg = msg + "\n" + message("SETUP_GAME");
msg = msg + "\n" + Localization.message("SETUP_GAME");
count++;
}
if (map.getLobby().getBlockX() == 0 && map.getLobby().getBlockY() == 0 && map.getLobby().getBlockZ() == 0 || !map.getLobby().exists()) {
msg = msg + "\n" + message("SETUP_LOBBY");
msg = msg + "\n" + Localization.message("SETUP_LOBBY");
count++;
}
if (map.getSeekerLobby().getBlockX() == 0 && map.getSeekerLobby().getBlockY() == 0 && map.getSeekerLobby().getBlockZ() == 0 || !map.getSeekerLobby().exists()) {
msg = msg + "\n" + message("SETUP_SEEKER_LOBBY");
msg = msg + "\n" + Localization.message("SETUP_SEEKER_LOBBY");
count++;
}
if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || !exitPosition.exists()) {
msg = msg + "\n" + message("SETUP_EXIT");
if (Config.exitPosition.getBlockX() == 0 && Config.exitPosition.getBlockY() == 0 && Config.exitPosition.getBlockZ() == 0 || !Config.exitPosition.exists()) {
msg = msg + "\n" + Localization.message("SETUP_EXIT");
count++;
}
if (map.isBoundsNotSetup()) {
msg = msg + "\n" + message("SETUP_BOUNDS");
msg = msg + "\n" + Localization.message("SETUP_BOUNDS");
count++;
}
if (mapSaveEnabled && !map.getGameSpawn().exists()) {
msg = msg + "\n" + message("SETUP_SAVEMAP");
if (Config.mapSaveEnabled && !map.getGameSpawn().exists()) {
msg = msg + "\n" + Localization.message("SETUP_SAVEMAP");
count++;
}
if (map.isBlockHuntEnabled() && map.getBlockHunt().isEmpty()) {
msg = msg + "\n" + message("SETUP_BLOCKHUNT");
msg = msg + "\n" + Localization.message("SETUP_BLOCKHUNT");
count++;
}
if (count < 1) {
sender.sendMessage(messagePrefix + message("SETUP_COMPLETE"));
sender.sendMessage(Config.messagePrefix + Localization.message("SETUP_COMPLETE"));
} else {
sender.sendMessage(msg);
}
@ -72,7 +71,7 @@ public class Status implements ICommand {
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList());
}
return null;
}

View file

@ -1,10 +1,12 @@
package net.tylermurphy.hideAndSeek.command.map.blockhunt;
package dev.tylerm.khs.command.map.blockhunt;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@ -13,30 +15,26 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Enabled implements ICommand {
public void execute(Player sender, String[] args) {
if (!Main.getInstance().supports(9)) {
sender.sendMessage(errorPrefix + message("BLOCKHUNT_UNSUPPORTED"));
sender.sendMessage(Config.errorPrefix + Localization.message("BLOCKHUNT_UNSUPPORTED"));
return;
}
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
sender.sendMessage(Config.errorPrefix + Localization.message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP"));
return;
}
boolean bool = Boolean.parseBoolean(args[1]);
map.setBlockhunt(bool, map.getBlockHunt());
Maps.setMap(map.getName(), map);
sender.sendMessage(messagePrefix + message("BLOCKHUNT_SET_TO")
sender.sendMessage(Config.messagePrefix + Localization.message("BLOCKHUNT_SET_TO")
.addAmount(bool ? ChatColor.GREEN + "true" : ChatColor.RED + "false") + ChatColor.WHITE);
}
@ -54,7 +52,7 @@ public class Enabled implements ICommand {
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList());
}
if(parameter.equals("bool")) {
return Arrays.asList("true", "false");

View file

@ -1,10 +1,12 @@
package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks;
package dev.tylerm.khs.command.map.blockhunt.blocks;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@ -13,40 +15,36 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Add implements ICommand {
public void execute(Player sender, String[] args) {
if (!Main.getInstance().supports(9)) {
sender.sendMessage(errorPrefix + message("BLOCKHUNT_UNSUPPORTED"));
sender.sendMessage(Config.errorPrefix + Localization.message("BLOCKHUNT_UNSUPPORTED"));
return;
}
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
sender.sendMessage(Config.errorPrefix + Localization.message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP"));
return;
}
Material block;
try { block = Material.valueOf(args[1]); }
catch (IllegalArgumentException e) {
sender.sendMessage(errorPrefix + message("COMMAND_INVALID_ARG").addAmount(args[1]));
sender.sendMessage(Config.errorPrefix + Localization.message("COMMAND_INVALID_ARG").addAmount(args[1]));
return;
}
List<Material> blocks = map.getBlockHunt();
if(blocks.contains(block)) {
sender.sendMessage(errorPrefix + message("BLOCKHUNT_BLOCK_EXISTS").addAmount(args[1]));
sender.sendMessage(Config.errorPrefix + Localization.message("BLOCKHUNT_BLOCK_EXISTS").addAmount(args[1]));
}
blocks.add(block);
map.setBlockhunt(map.isBlockHuntEnabled(), blocks);
Maps.setMap(map.getName(), map);
sender.sendMessage(messagePrefix + message("BLOCKHUNT_BLOCK_ADDED").addAmount(args[1]));
sender.sendMessage(Config.messagePrefix + Localization.message("BLOCKHUNT_BLOCK_ADDED").addAmount(args[1]));
}
public String getLabel() {
@ -63,7 +61,7 @@ public class Add implements ICommand {
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList());
} else if(parameter.equals("block")) {
return Arrays.stream(Material.values())
.filter(Material::isBlock)

View file

@ -1,9 +1,11 @@
package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks;
package dev.tylerm.khs.command.map.blockhunt.blocks;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -11,28 +13,24 @@ import org.jetbrains.annotations.NotNull;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class List implements ICommand {
public void execute(Player sender, String[] args) {
if (!Main.getInstance().supports(9)) {
sender.sendMessage(errorPrefix + message("BLOCKHUNT_UNSUPPORTED"));
sender.sendMessage(Config.errorPrefix + Localization.message("BLOCKHUNT_UNSUPPORTED"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP"));
return;
}
java.util.List<Material> blocks = map.getBlockHunt();
if(blocks.isEmpty()) {
sender.sendMessage(errorPrefix + message("NO_BLOCKS"));
sender.sendMessage(Config.errorPrefix + Localization.message("NO_BLOCKS"));
return;
}
StringBuilder response = new StringBuilder(messagePrefix + message("BLOCKHUNT_LIST_BLOCKS"));
StringBuilder response = new StringBuilder(Config.messagePrefix + Localization.message("BLOCKHUNT_LIST_BLOCKS"));
for(int i = 0; i < blocks.size(); i++) {
response.append(String.format("\n%s. %s", i, blocks.get(i).toString()));
}
@ -53,7 +51,7 @@ public class List implements ICommand {
public java.util.List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList());
}
return null;
}

View file

@ -1,10 +1,12 @@
package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks;
package dev.tylerm.khs.command.map.blockhunt.blocks;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@ -13,40 +15,36 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Remove implements ICommand {
public void execute(Player sender, String[] args) {
if (!Main.getInstance().supports(9)) {
sender.sendMessage(errorPrefix + message("BLOCKHUNT_UNSUPPORTED"));
sender.sendMessage(Config.errorPrefix + Localization.message("BLOCKHUNT_UNSUPPORTED"));
return;
}
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
sender.sendMessage(Config.errorPrefix + Localization.message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP"));
return;
}
Material block;
try { block = Material.valueOf(args[1]); }
catch (IllegalArgumentException e) {
sender.sendMessage(errorPrefix + message("COMMAND_INVALID_ARG").addAmount(args[1]));
sender.sendMessage(Config.errorPrefix + Localization.message("COMMAND_INVALID_ARG").addAmount(args[1]));
return;
}
java.util.List<Material> blocks = map.getBlockHunt();
if(!blocks.contains(block)) {
sender.sendMessage(errorPrefix + message("BLOCKHUNT_BLOCK_DOESNT_EXIT").addAmount(args[1]));
sender.sendMessage(Config.errorPrefix + Localization.message("BLOCKHUNT_BLOCK_DOESNT_EXIT").addAmount(args[1]));
}
blocks.remove(block);
map.setBlockhunt(map.isBlockHuntEnabled(), blocks);
Maps.setMap(map.getName(), map);
sender.sendMessage(messagePrefix + message("BLOCKHUNT_BLOCK_REMOVED").addAmount(args[1]));
sender.sendMessage(Config.messagePrefix + Localization.message("BLOCKHUNT_BLOCK_REMOVED").addAmount(args[1]));
}
public String getLabel() {
@ -63,7 +61,7 @@ public class Remove implements ICommand {
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList());
} else if(parameter.equals("block")) {
return Arrays.stream(Material.values())
.filter(Material::isBlock)

View file

@ -0,0 +1,86 @@
package dev.tylerm.khs.command.map.set;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class Border implements ICommand {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(Config.errorPrefix + Localization.message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP"));
return;
}
if (map.getSpawn().isNotSetup()) {
sender.sendMessage(Config.errorPrefix + Localization.message("ERROR_GAME_SPAWN"));
return;
}
int num,delay,change;
try { num = Integer.parseInt(args[1]); } catch (Exception e) {
sender.sendMessage(Config.errorPrefix + Localization.message("WORLDBORDER_INVALID_INPUT").addAmount(args[0]));
return;
}
try { delay = Integer.parseInt(args[2]); } catch (Exception e) {
sender.sendMessage(Config.errorPrefix + Localization.message("WORLDBORDER_INVALID_INPUT").addAmount(args[1]));
return;
}
try { change = Integer.parseInt(args[3]); } catch (Exception e) {
sender.sendMessage(Config.errorPrefix + Localization.message("WORLDBORDER_INVALID_INPUT").addAmount(args[2]));
return;
}
if (num < 100) {
sender.sendMessage(Config.errorPrefix + Localization.message("WORLDBORDER_MIN_SIZE"));
return;
}
if (change < 1) {
sender.sendMessage(Config.errorPrefix + Localization.message("WORLDBORDER_CHANGE_SIZE"));
return;
}
map.setWorldBorderData(
sender.getLocation().getBlockX(),
sender.getLocation().getBlockZ(),
num,
delay,
change
);
Maps.setMap(map.getName(), map);
sender.sendMessage(Config.messagePrefix + Localization.message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay).addAmount(change));
map.getWorldBorder().resetWorldBorder();
}
public String getLabel() {
return "border";
}
public String getUsage() {
return "<map> <size> <delay> <move>";
}
public String getDescription() {
return "Sets a maps world border information";
}
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList());
}
return Collections.singletonList(parameter);
}
}

View file

@ -1,46 +1,45 @@
package net.tylermurphy.hideAndSeek.command.map.set;
package dev.tylerm.khs.command.map.set;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import net.tylermurphy.hideAndSeek.util.Location;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.util.Status;
import dev.tylerm.khs.util.Location;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Bounds implements ICommand {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
sender.sendMessage(Config.errorPrefix + Localization.message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP"));
return;
}
if (map.getSpawn().isNotSetup()) {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
sender.sendMessage(Config.errorPrefix + Localization.message("ERROR_GAME_SPAWN"));
return;
}
if (map.getSeekerLobby().isNotSetup()) {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SEEKER_SPAWN"));
sender.sendMessage(Config.errorPrefix + Localization.message("ERROR_GAME_SEEKER_SPAWN"));
return;
}
if (!sender.getWorld().getName().equals(map.getSpawnName())) {
sender.sendMessage(errorPrefix + message("BOUNDS_WRONG_WORLD"));
sender.sendMessage(Config.errorPrefix + Localization.message("BOUNDS_WRONG_WORLD"));
return;
}
if (sender.getLocation().getBlockX() == 0 || sender.getLocation().getBlockZ() == 0) {
sender.sendMessage(errorPrefix + message("NOT_AT_ZERO"));
sender.sendMessage(Config.errorPrefix + Localization.message("NOT_AT_ZERO"));
return;
}
boolean first = true;
@ -77,18 +76,18 @@ public class Bounds implements ICommand {
if(!map.getSpawn().isNotSetup()) {
if(map.getSpawn().isNotInBounds(bxs, bxl, bzs, bzl)) {
map.setSpawn(Location.getDefault());
sender.sendMessage(warningPrefix + message("WARN_SPAWN_RESET"));
sender.sendMessage(Config.warningPrefix + Localization.message("WARN_SPAWN_RESET"));
}
}
if(!map.getSeekerLobby().isNotSetup()) {
if(map.getSeekerLobby().isNotInBounds(bxs, bxl, bzs, bzl)) {
map.setSeekerLobby(Location.getDefault());
sender.sendMessage(warningPrefix + message("WARN_SEEKER_SPAWN_RESET"));
sender.sendMessage(Config.warningPrefix + Localization.message("WARN_SEEKER_SPAWN_RESET"));
}
}
}
Maps.setMap(map.getName(), map);
sender.sendMessage(messagePrefix + message("BOUNDS").addAmount(first ? 1 : 2));
sender.sendMessage(Config.messagePrefix + Localization.message("BOUNDS").addAmount(first ? 1 : 2));
}
public String getLabel() {
@ -105,7 +104,7 @@ public class Bounds implements ICommand {
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList());
}
return null;
}

View file

@ -1,10 +1,11 @@
package net.tylermurphy.hideAndSeek.command.map.set;
package dev.tylerm.khs.command.map.set;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.util.Location;
import dev.tylerm.khs.command.location.LocationUtils;
import dev.tylerm.khs.command.location.Locations;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.util.Location;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@ -33,7 +34,7 @@ public class Lobby implements ICommand {
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList());
}
return null;
}

View file

@ -1,10 +1,11 @@
package net.tylermurphy.hideAndSeek.command.map.set;
package dev.tylerm.khs.command.map.set;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.util.Location;
import dev.tylerm.khs.command.location.LocationUtils;
import dev.tylerm.khs.command.location.Locations;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.*;
import dev.tylerm.khs.util.Location;
import dev.tylerm.khs.configuration.Maps;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
@ -12,25 +13,22 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.warningPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SeekerLobby implements ICommand {
public void execute(Player sender, String[] args) {
LocationUtils.setLocation(sender, Locations.SEEKER, args[0], map -> {
if(map.getSpawn().isNotSetup()) {
throw new RuntimeException(message("GAME_SPAWN_NEEDED").toString());
throw new RuntimeException(Localization.message("GAME_SPAWN_NEEDED").toString());
}
if(!map.getSpawnName().equals(sender.getLocation().getWorld().getName())) {
throw new RuntimeException(message("SEEKER_LOBBY_INVALID").toString());
throw new RuntimeException(Localization.message("SEEKER_LOBBY_INVALID").toString());
}
map.setSeekerLobby(Location.from(sender));
if(!map.isBoundsNotSetup()) {
Vector boundsMin = map.getBoundsMin();
Vector boundsMax = map.getBoundsMax();
if(map.getSeekerLobby().isNotInBounds(boundsMin.getBlockX(), boundsMax.getBlockX(), boundsMin.getBlockZ(), boundsMax.getBlockZ())) {
sender.sendMessage(warningPrefix + message("WARN_MAP_BOUNDS"));
sender.sendMessage(Config.warningPrefix + Localization.message("WARN_MAP_BOUNDS"));
}
}
});
@ -50,7 +48,7 @@ public class SeekerLobby implements ICommand {
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList());
}
return null;
}

View file

@ -1,10 +1,11 @@
package net.tylermurphy.hideAndSeek.command.map.set;
package dev.tylerm.khs.command.map.set;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.util.Location;
import dev.tylerm.khs.command.location.LocationUtils;
import dev.tylerm.khs.command.location.Locations;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.*;
import dev.tylerm.khs.util.Location;
import dev.tylerm.khs.configuration.Maps;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
@ -12,9 +13,6 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Spawn implements ICommand {
public void execute(Player sender, String[] args) {
@ -22,7 +20,7 @@ public class Spawn implements ICommand {
if (map.isWorldBorderEnabled() &&
new Vector(sender.getLocation().getX(), 0, sender.getLocation().getZ()).distance(map.getWorldBorderPos()) > 100) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
sender.sendMessage(Config.errorPrefix + Localization.message("WORLDBORDER_POSITION"));
throw new RuntimeException("World border not enabled or not in valid position!");
}
@ -32,16 +30,16 @@ public class Spawn implements ICommand {
Vector boundsMin = map.getBoundsMin();
Vector boundsMax = map.getBoundsMax();
if(map.getSpawn().isNotInBounds(boundsMin.getBlockX(), boundsMax.getBlockX(), boundsMin.getBlockZ(), boundsMax.getBlockZ())) {
sender.sendMessage(warningPrefix + message("WARN_MAP_BOUNDS"));
sender.sendMessage(Config.warningPrefix + Localization.message("WARN_MAP_BOUNDS"));
}
}
if(map.getSeekerLobby().getWorld() != null && !map.getSeekerLobby().getWorld().equals(sender.getLocation().getWorld().getName())) {
sender.sendMessage(warningPrefix + message("SEEKER_LOBBY_SPAWN_RESET"));
sender.sendMessage(Config.warningPrefix + Localization.message("SEEKER_LOBBY_SPAWN_RESET"));
map.setSeekerLobby(Location.getDefault());
}
if (!sender.getLocation().getWorld().getName().equals(map.getSpawnName()) && mapSaveEnabled) {
if (!sender.getLocation().getWorld().getName().equals(map.getSpawnName()) && Config.mapSaveEnabled) {
map.getWorldLoader().unloadMap();
}
});
@ -61,7 +59,7 @@ public class Spawn implements ICommand {
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList());
}
return null;
}

View file

@ -0,0 +1,58 @@
package dev.tylerm.khs.command.map.unset;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.stream.Collectors;
public class Border implements ICommand {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(Config.errorPrefix + Localization.message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP"));
return;
}
if (map.getSpawn().isNotSetup()) {
sender.sendMessage(Config.errorPrefix + Localization.message("ERROR_GAME_SPAWN"));
return;
}
map.setWorldBorderData(0, 0, 0, 0, 0);
Config.addToConfig("worldBorder.enabled",false);
Config.saveConfig();
sender.sendMessage(Config.messagePrefix + Localization.message("WORLDBORDER_DISABLE"));
map.getWorldBorder().resetWorldBorder();
}
public String getLabel() {
return "border";
}
public String getUsage() {
return "<map>";
}
public String getDescription() {
return "Removes a maps world border information";
}
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList());
}
return null;
}
}

View file

@ -1,8 +1,10 @@
package net.tylermurphy.hideAndSeek.command.util;
package dev.tylerm.khs.command.util;
import net.tylermurphy.hideAndSeek.command.map.Save;
import net.tylermurphy.hideAndSeek.util.Pair;
import net.tylermurphy.hideAndSeek.util.Tuple;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.util.Pair;
import dev.tylerm.khs.util.Tuple;
import dev.tylerm.khs.command.map.Save;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
@ -10,10 +12,6 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.permissionsRequired;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class CommandGroup {
private final Map<String, Object> commandRegister;
@ -51,7 +49,7 @@ public class CommandGroup {
if (data == null) {
player.sendMessage(
String.format("%s%sKenshin's Hide and Seek %s(%s1.7.4%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY, ChatColor.WHITE, ChatColor.GRAY) +
String.format("%s%sKenshin's Hide and Seek %s(%s1.7.5%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)
);
@ -63,25 +61,25 @@ public class CommandGroup {
String[] parameters = data.getRight();
if (Save.runningBackup) {
player.sendMessage(errorPrefix + message("MAPSAVE_INPROGRESS"));
player.sendMessage(Config.errorPrefix + Localization.message("MAPSAVE_INPROGRESS"));
return;
}
if (permissionsRequired && !player.hasPermission(permission)) {
player.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED"));
if (Config.permissionsRequired && !player.hasPermission(permission)) {
player.sendMessage(Config.errorPrefix + Localization.message("COMMAND_NOT_ALLOWED"));
return;
}
int parameterCount = (int) Arrays.stream(command.getUsage().split(" ")).filter(p -> p.startsWith("<") && !p.startsWith("<*")).count();
if(parameters.length < parameterCount) {
player.sendMessage(errorPrefix + message("ARGUMENT_COUNT"));
player.sendMessage(Config.errorPrefix + Localization.message("ARGUMENT_COUNT"));
return;
}
try {
command.execute(player, parameters);
} catch (Exception e) {
player.sendMessage(errorPrefix + "An error has occurred.");
player.sendMessage(Config.errorPrefix + "An error has occurred.");
e.printStackTrace();
}
}
@ -122,10 +120,10 @@ public class CommandGroup {
Object object = commandRegister.get(handle);
if (object instanceof ICommand) {
ICommand command = (ICommand) object;
return !permissionsRequired || player.hasPermission(permission + "." + command.getLabel());
return !Config.permissionsRequired || player.hasPermission(permission + "." + command.getLabel());
} else if (object instanceof CommandGroup) {
CommandGroup group = (CommandGroup) object;
return !permissionsRequired || group.hasPermission(player, permission + "." + group.getLabel());
return !Config.permissionsRequired || group.hasPermission(player, permission + "." + group.getLabel());
}
return false;
})

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.command.util;
package dev.tylerm.khs.command.util;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

View file

@ -1,8 +1,10 @@
package net.tylermurphy.hideAndSeek.command.world;
package dev.tylerm.khs.command.world;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.util.Location;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.util.Location;
import dev.tylerm.khs.command.util.ICommand;
import org.bukkit.World;
import org.bukkit.WorldType;
import org.bukkit.entity.Player;
@ -12,16 +14,12 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Create implements ICommand {
public void execute(Player sender, String[] args) {
List<String> worlds = Main.getInstance().getWorlds();
if(worlds.contains(args[0])) {
sender.sendMessage(errorPrefix + message("WORLD_EXISTS").addAmount(args[0]));
sender.sendMessage(Config.errorPrefix + Localization.message("WORLD_EXISTS").addAmount(args[0]));
return;
}
WorldType type;
@ -44,16 +42,16 @@ public class Create implements ICommand {
environment = World.Environment.THE_END;
break;
default:
sender.sendMessage(errorPrefix + message("INVALID_WORLD_TYPE").addAmount(args[1]));
sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_WORLD_TYPE").addAmount(args[1]));
return;
}
Location temp = new Location(args[0], 0, 0, 0);
if (temp.load(type, environment) == null) {
sender.sendMessage(errorPrefix + message("WORLD_ADDED_FAILED"));
sender.sendMessage(Config.errorPrefix + Localization.message("WORLD_ADDED_FAILED"));
} else {
sender.sendMessage(messagePrefix + message("WORLD_ADDED").addAmount(args[0]));
sender.sendMessage(Config.messagePrefix + Localization.message("WORLD_ADDED").addAmount(args[0]));
}
}

View file

@ -1,9 +1,11 @@
package net.tylermurphy.hideAndSeek.command.world;
package dev.tylerm.khs.command.world;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.Confirm;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.world.WorldLoader;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.Confirm;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.world.WorldLoader;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
@ -12,46 +14,42 @@ import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Delete implements ICommand {
public void execute(Player sender, String[] args) {
java.util.List<String> worlds = Main.getInstance().getWorlds();
if(!worlds.contains(args[0])) {
sender.sendMessage(errorPrefix + message("WORLD_DOESNT_EXIST").addAmount(args[0]));
sender.sendMessage(Config.errorPrefix + Localization.message("WORLD_DOESNT_EXIST").addAmount(args[0]));
return;
}
Confirm.Confirmation confirmation = new Confirm.Confirmation(args[0], world -> {
java.util.List<String> worlds_now = Main.getInstance().getWorlds();
if(!worlds_now.contains(world)) {
sender.sendMessage(errorPrefix + message("WORLD_DOESNT_EXIST").addAmount(world));
sender.sendMessage(Config.errorPrefix + Localization.message("WORLD_DOESNT_EXIST").addAmount(world));
return;
}
World bukkit_world = Bukkit.getWorld(world);
if(bukkit_world != null && bukkit_world.getPlayers().size() > 0) {
sender.sendMessage(errorPrefix + message("WORLD_NOT_EMPTY"));
sender.sendMessage(Config.errorPrefix + Localization.message("WORLD_NOT_EMPTY"));
return;
}
String path = Main.getInstance().getWorldContainer().getPath() + File.separator + world;
if (!Bukkit.getServer().unloadWorld(world, false)) {
sender.sendMessage(errorPrefix + message("WORLD_REMOVED_FAILED"));
sender.sendMessage(Config.errorPrefix + Localization.message("WORLD_REMOVED_FAILED"));
return;
}
try {
WorldLoader.deleteDirectory(new File(path));
} catch (Exception e) {
sender.sendMessage(errorPrefix + message("WORLD_REMOVED_FAILED"));
sender.sendMessage(Config.errorPrefix + Localization.message("WORLD_REMOVED_FAILED"));
return;
}
sender.sendMessage(messagePrefix + message("WORLD_REMOVED").addAmount(world));
sender.sendMessage(Config.messagePrefix + Localization.message("WORLD_REMOVED").addAmount(world));
});
Confirm.confirmations.put(sender.getUniqueId(), confirmation);
sender.sendMessage(messagePrefix + message("CONFIRMATION"));
sender.sendMessage(Config.messagePrefix + Localization.message("CONFIRMATION"));
}

View file

@ -1,25 +1,23 @@
package net.tylermurphy.hideAndSeek.command.world;
package dev.tylerm.khs.command.world;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.command.util.ICommand;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class List implements ICommand {
public void execute(Player sender, String[] args) {
java.util.List<String> worlds = Main.getInstance().getWorlds();
if(worlds.isEmpty()) {
sender.sendMessage(errorPrefix + message("NO_WORLDS"));
sender.sendMessage(Config.errorPrefix + Localization.message("NO_WORLDS"));
} else {
StringBuilder response = new StringBuilder(messagePrefix + message("LIST_WORLDS"));
StringBuilder response = new StringBuilder(Config.messagePrefix + Localization.message("LIST_WORLDS"));
for (String world : worlds) {
String status = ChatColor.GRAY + "NOT LOADED";
World bukkit_world = Bukkit.getWorld(world);

View file

@ -1,27 +1,26 @@
package net.tylermurphy.hideAndSeek.command.world;
package dev.tylerm.khs.command.world;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.util.Location;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.util.ICommand;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.configuration.Localization;
import dev.tylerm.khs.util.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Tp implements ICommand {
public void execute(Player sender, String[] args) {
Location test = new Location(args[0], 0, 0,0);
if(!test.exists()) {
sender.sendMessage(errorPrefix + message("WORLD_DOESNT_EXIT"));
sender.sendMessage(Config.errorPrefix + Localization.message("WORLD_DOESNT_EXIT"));
return;
}
World world = test.load();
if(world == null) {
sender.sendMessage(errorPrefix + message("WORLD_LOAD_FAILED"));
sender.sendMessage(Config.errorPrefix + Localization.message("WORLD_LOAD_FAILED"));
return;
}
Location loc = new Location(world.getName(), world.getSpawnLocation());

View file

@ -1,11 +1,11 @@
package net.tylermurphy.hideAndSeek.configuration;
package dev.tylerm.khs.configuration;
import com.cryptomorin.xseries.XItemStack;
import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XSound;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.util.CountdownDisplay;
import net.tylermurphy.hideAndSeek.util.Location;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.game.util.CountdownDisplay;
import dev.tylerm.khs.util.Location;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@ -62,8 +62,12 @@ public class Config {
allowNaturalCauses,
saveInventory,
delayedRespawn,
dontRewardQuit,
spawnPatch,
dropItems,
respawnAsSpectator,
waitTillNoneLeft,
gameOverTitle,
regenHealth;
public static int
@ -82,7 +86,10 @@ public class Config {
lobbyItemStartPosition,
flightToggleItemPosition,
teleportItemPosition,
delayedRespawnDelay;
startingSeekerCount,
delayedRespawnDelay,
hidingTimer,
endGameDelay;
public static float
seekerPingLeadingVolume,
@ -154,7 +161,9 @@ public class Config {
}
//Lobby
minPlayers = Math.max(2, config.getInt("minPlayers"));
startingSeekerCount = Math.max(1, config.getInt("startingSeekerCount"));
waitTillNoneLeft = config.getBoolean("waitTillNoneLeft");
minPlayers = Math.max(1 + startingSeekerCount + (waitTillNoneLeft ? 0 : 1), config.getInt("minPlayers"));
countdown = Math.max(10, config.getInt("lobby.countdown"));
changeCountdown = Math.max(minPlayers, config.getInt("lobby.changeCountdown"));
lobbyMin = Math.max(minPlayers, config.getInt("lobby.min"));
@ -188,6 +197,12 @@ public class Config {
placeholderError = config.getString("placeholder.incorrect");
placeholderNoData = config.getString("placeholder.noData");
saveInventory = config.getBoolean("saveInventory");
respawnAsSpectator = config.getBoolean("respawnAsSpectator");
dontRewardQuit = config.getBoolean("dontRewardQuit");
endGameDelay = Math.max(0,config.getInt("endGameDelay"));
gameOverTitle = config.getBoolean("gameOverTitle");
hidingTimer = Math.max(10, config.getInt("hidingTimer"));
try {
countdownDisplay = CountdownDisplay.valueOf(config.getString("hideCountdownDisplay"));
} catch (IllegalArgumentException e) {

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.configuration;
package dev.tylerm.khs.configuration;
import net.tylermurphy.hideAndSeek.Main;
import dev.tylerm.khs.Main;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;

View file

@ -1,7 +1,7 @@
package net.tylermurphy.hideAndSeek.configuration;
package dev.tylerm.khs.configuration;
import com.cryptomorin.xseries.XItemStack;
import net.tylermurphy.hideAndSeek.Main;
import dev.tylerm.khs.Main;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@ -16,6 +16,12 @@ import java.util.List;
public class Items {
public static List<ItemStack> HIDER_ITEMS, SEEKER_ITEMS;
public static ItemStack
HIDER_HELM, SEEKER_HELM,
HIDER_CHEST, SEEKER_CHEST,
HIDER_LEGS, SEEKER_LEGS,
HIDER_BOOTS, SEEKER_BOOTS;
public static List<PotionEffect> HIDER_EFFECTS, SEEKER_EFFECTS;
public static void loadItems() {
@ -23,29 +29,109 @@ public class Items {
ConfigManager manager = ConfigManager.create("items.yml");
SEEKER_ITEMS = new ArrayList<>();
SEEKER_HELM = null;
SEEKER_CHEST = null;
SEEKER_LEGS = null;
SEEKER_BOOTS = null;
ConfigurationSection SeekerItems = manager.getConfigurationSection("items.seeker");
int i = 1;
while (true) {
for (int i = 0; i < 9; i++) {
ConfigurationSection section = SeekerItems.getConfigurationSection(String.valueOf(i));
if (section == null) break;
if (section == null) {
SEEKER_ITEMS.add(null);
continue;
}
ItemStack item = createItem(section);
if (item != null) SEEKER_ITEMS.add(item);
i++;
SEEKER_ITEMS.add(item);
}
ConfigurationSection SeekerHelmet = SeekerItems.getConfigurationSection("helmet");
if (SeekerHelmet != null) {
ItemStack item = createItem(SeekerHelmet);
if (item != null) {
SEEKER_HELM = item;
}
}
ConfigurationSection SeekerChestplate = SeekerItems.getConfigurationSection("chestplate");
if (SeekerChestplate != null) {
ItemStack item = createItem(SeekerChestplate);
if (item != null) {
SEEKER_CHEST = item;
}
}
ConfigurationSection SeekerLeggings = SeekerItems.getConfigurationSection("leggings");
if (SeekerLeggings != null) {
ItemStack item = createItem(SeekerLeggings);
if (item != null) {
SEEKER_LEGS = item;
}
}
ConfigurationSection SeekerBoots = SeekerItems.getConfigurationSection("boots");
if (SeekerBoots != null) {
ItemStack item = createItem(SeekerBoots);
if (item != null) {
SEEKER_BOOTS = item;
}
}
HIDER_ITEMS = new ArrayList<>();
HIDER_HELM = null;
HIDER_CHEST = null;
HIDER_LEGS = null;
HIDER_BOOTS = null;
ConfigurationSection HiderItems = manager.getConfigurationSection("items.hider");
i = 1;
while (true) {
for (int i = 0; i < 9; i++) {
ConfigurationSection section = HiderItems.getConfigurationSection(String.valueOf(i));
if (section == null) break;
ItemStack item = createItem(section);
if (item != null) HIDER_ITEMS.add(item);
i++;
if (section == null) {
HIDER_ITEMS.add(null);
continue;
}
ItemStack item = createItem(section);
HIDER_ITEMS.add(item);
}
ConfigurationSection HiderHelmet = HiderItems.getConfigurationSection("helmet");
if (HiderHelmet != null) {
ItemStack item = createItem(HiderHelmet);
if (item != null) {
HIDER_HELM = item;
}
}
ConfigurationSection HiderChestplate = HiderItems.getConfigurationSection("chestplate");
if (HiderChestplate != null) {
ItemStack item = createItem(HiderChestplate);
if (item != null) {
HIDER_CHEST = item;
}
}
ConfigurationSection HiderLeggings = HiderItems.getConfigurationSection("leggings");
if (HiderLeggings != null) {
ItemStack item = createItem(HiderLeggings);
if (item != null) {
HIDER_LEGS = item;
}
}
ConfigurationSection HiderBoots = HiderItems.getConfigurationSection("boots");
if (HiderBoots != null) {
ItemStack item = createItem(HiderBoots);
if (item != null) {
HIDER_BOOTS = item;
}
}
SEEKER_EFFECTS = new ArrayList<>();
ConfigurationSection SeekerEffects = manager.getConfigurationSection("effects.seeker");
i = 1;
int i = 1;
while (true) {
ConfigurationSection section = SeekerEffects.getConfigurationSection(String.valueOf(i));
if (section == null) break;
@ -64,7 +150,6 @@ public class Items {
if (effect != null) HIDER_EFFECTS.add(effect);
i++;
}
}
private static ItemStack createItem(ConfigurationSection item) {
@ -94,7 +179,9 @@ public class Items {
if (material.equalsIgnoreCase("POTION") || material.equalsIgnoreCase("SPLASH_POTION") || material.equalsIgnoreCase("LINGERING_POTION"))
config.set("base-effect", String.format("%s,%s,%s", item.getString("type"), false, splash));
ItemStack stack = XItemStack.deserialize(config);
stack.setAmount(item.getInt("amount"));
int amt = item.getInt("amount");
if (amt < 1) amt = 1;
stack.setAmount(amt);
if (stack.getData().getItemType() == Material.AIR) return null;
return stack;
}
@ -121,7 +208,7 @@ public class Items {
}
private static boolean equals(ItemStack a, ItemStack b) {
if (a == null) {
if (a == null || b == null) {
return false;
} else if (a == b) {
return true;

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.configuration;
package dev.tylerm.khs.configuration;
import java.util.Collections;
import java.util.List;

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.configuration;
package dev.tylerm.khs.configuration;
import net.md_5.bungee.api.ChatColor;
@ -15,12 +15,14 @@ public class Localization {
put("en-US", new String[][]{
{"WORLDBORDER_DECREASING"},
{"START","TAUNTED"},
{"GAME_SETUP", "SETUP_GAME", "SETUP_LOBBY", "SETUP_SEEKER_LOBBY", "SETUP_EXIT", "SETUP_SAVEMAP", "SETUP_BOUNDS"}
{"GAME_SETUP", "SETUP_GAME", "SETUP_LOBBY", "SETUP_SEEKER_LOBBY", "SETUP_EXIT", "SETUP_SAVEMAP", "SETUP_BOUNDS"},
{"GAME_PLAYER_FOUND", "GAME_PLAYER_FOUND_BY"}
});
put("de-DE", new String[][]{
{},
{"TAUNTED"},
{"GAME_SETUP", "SETUP_GAME", "SETUP_LOBBY", "SETUP_SEEKER_LOBBY", "SETUP_EXIT", "SETUP_SAVEMAP", "SETUP_BOUNDS"}
{"GAME_SETUP", "SETUP_GAME", "SETUP_LOBBY", "SETUP_SEEKER_LOBBY", "SETUP_EXIT", "SETUP_SAVEMAP", "SETUP_BOUNDS"},
{"GAME_PLAYER_FOUND", "GAME_PLAYER_FOUND_BY"}
});
}};

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.configuration;
package dev.tylerm.khs.configuration;
import org.bukkit.entity.Entity;

View file

@ -1,26 +1,26 @@
package net.tylermurphy.hideAndSeek.configuration;
package dev.tylerm.khs.configuration;
import java.util.ArrayList;
import java.util.List;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.events.Border;
import net.tylermurphy.hideAndSeek.world.WorldLoader;
import net.tylermurphy.hideAndSeek.util.Location;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.game.events.Border;
import dev.tylerm.khs.util.Location;
import dev.tylerm.khs.world.WorldLoader;
import org.bukkit.*;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static dev.tylerm.khs.configuration.Config.*;
public class Map {
private final String name;
private Location
spawnPosition = Location.getDefault(),
lobbyPosition = Location.getDefault(),
seekerLobbyPosition = Location.getDefault();
private dev.tylerm.khs.util.Location
spawnPosition = dev.tylerm.khs.util.Location.getDefault(),
lobbyPosition = dev.tylerm.khs.util.Location.getDefault(),
seekerLobbyPosition = dev.tylerm.khs.util.Location.getDefault();
private int
xBoundMin = 0,
@ -51,15 +51,15 @@ public class Map {
this.worldLoader = new WorldLoader(this);
}
public void setSpawn(Location pos) {
public void setSpawn(dev.tylerm.khs.util.Location pos) {
this.spawnPosition = pos;
}
public void setLobby(Location pos) {
public void setLobby(dev.tylerm.khs.util.Location pos) {
this.lobbyPosition = pos;
}
public void setSeekerLobby(Location pos) {
public void setSeekerLobby(dev.tylerm.khs.util.Location pos) {
this.seekerLobbyPosition = pos;
}
@ -100,7 +100,7 @@ public class Map {
}
@NotNull
public Location getGameSpawn() {
public dev.tylerm.khs.util.Location getGameSpawn() {
if(mapSaveEnabled) {
return spawnPosition.changeWorld("hs_"+name);
} else {
@ -117,7 +117,7 @@ public class Map {
}
@NotNull
public Location getSpawn() {
public dev.tylerm.khs.util.Location getSpawn() {
return spawnPosition;
}
@ -127,7 +127,7 @@ public class Map {
}
@NotNull
public Location getLobby() {
public dev.tylerm.khs.util.Location getLobby() {
return lobbyPosition;
}
@ -137,7 +137,7 @@ public class Map {
}
@NotNull
public Location getSeekerLobby() {
public dev.tylerm.khs.util.Location getSeekerLobby() {
return seekerLobbyPosition;
}

View file

@ -1,10 +1,10 @@
package net.tylermurphy.hideAndSeek.configuration;
package dev.tylerm.khs.configuration;
import java.util.*;
import java.util.stream.Collectors;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.util.Location;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.util.Location;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;

View file

@ -1,6 +1,4 @@
package net.tylermurphy.hideAndSeek.database;
import static net.tylermurphy.hideAndSeek.configuration.Config.databaseType;
package dev.tylerm.khs.database;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@ -13,10 +11,11 @@ import java.util.UUID;
import com.google.common.io.ByteStreams;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.database.connections.DatabaseConnection;
import net.tylermurphy.hideAndSeek.database.connections.MySQLConnection;
import net.tylermurphy.hideAndSeek.database.connections.SQLiteConnection;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.configuration.Config;
import dev.tylerm.khs.database.connections.DatabaseConnection;
import dev.tylerm.khs.database.connections.MySQLConnection;
import dev.tylerm.khs.database.connections.SQLiteConnection;
public class Database {
@ -27,14 +26,14 @@ public class Database {
public Database(){
if(databaseType.equalsIgnoreCase("SQLITE")) {
if(Config.databaseType.equalsIgnoreCase("SQLITE")) {
Main.getInstance().getLogger().info("SQLITE database chosen");
connection = new SQLiteConnection();
} else if(databaseType.equalsIgnoreCase("MYSQL")) {
} else if(Config.databaseType.equalsIgnoreCase("MYSQL")) {
Main.getInstance().getLogger().info("MYSQL database chosen");
connection = new MySQLConnection();
} else {
throw new IllegalArgumentException("Invalid database type: " + databaseType);
throw new IllegalArgumentException("Invalid database type: " + Config.databaseType);
}
playerInfo = new GameDataTable(this);

View file

@ -17,12 +17,12 @@
*
*/
package net.tylermurphy.hideAndSeek.database;
package dev.tylerm.khs.database;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
import net.tylermurphy.hideAndSeek.game.Board;
import net.tylermurphy.hideAndSeek.game.util.WinType;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.database.util.PlayerInfo;
import dev.tylerm.khs.game.Board;
import dev.tylerm.khs.game.util.WinType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -79,7 +79,6 @@ public class GameDataTable {
rs.getInt("seeker_deaths")
);
rs.close();
connection.close();
CACHE.put(uuid, info);
return info;
}
@ -111,7 +110,6 @@ public class GameDataTable {
rs.getInt("seeker_deaths")
);
rs.close();
connection.close();
CACHE.put(uuid, info);
return info;
}
@ -145,7 +143,6 @@ public class GameDataTable {
infoList.add(info);
}
rs.close();
connection.close();
return infoList;
} catch (SQLException e) {
Main.getInstance().getLogger().severe("SQL Error: " + e.getMessage());
@ -190,8 +187,8 @@ public class GameDataTable {
database.encodeUUID(info.getUniqueId()),
info.getHiderWins() + (winners.contains(uuid) && type == WinType.HIDER_WIN ? 1 : 0),
info.getSeekerWins() + (winners.contains(uuid) && type == WinType.SEEKER_WIN ? 1 : 0),
info.getHiderGames() + (board.isHider(uuid) || (board.isSeeker(uuid) && !board.getFirstSeeker().getUniqueId().equals(uuid)) ? 1 : 0),
info.getSeekerGames() + (board.getFirstSeeker().getUniqueId().equals(uuid) ? 1 : 0),
info.getHiderGames() + (board.isHider(uuid) || (board.isSeeker(uuid) && winners.contains(uuid)) ? 1 : 0),
info.getSeekerGames() + (board.isSeeker(uuid) && winners.contains(uuid) ? 1 : 0),
info.getHiderKills() + hider_kills.getOrDefault(uuid, 0),
info.getSeekerKills() + seeker_kills.getOrDefault(uuid, 0),
info.getHiderDeaths() + hider_deaths.getOrDefault(uuid, 0),

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.database;
package dev.tylerm.khs.database;
import net.tylermurphy.hideAndSeek.Main;
import dev.tylerm.khs.Main;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.io.BukkitObjectInputStream;
import org.bukkit.util.io.BukkitObjectOutputStream;

View file

@ -17,9 +17,9 @@
*
*/
package net.tylermurphy.hideAndSeek.database;
package dev.tylerm.khs.database;
import net.tylermurphy.hideAndSeek.database.util.LegacyPlayerInfo;
import dev.tylerm.khs.database.util.LegacyPlayerInfo;
import java.sql.Connection;
import java.sql.ResultSet;

View file

@ -17,9 +17,9 @@
*
*/
package net.tylermurphy.hideAndSeek.database;
package dev.tylerm.khs.database;
import net.tylermurphy.hideAndSeek.Main;
import dev.tylerm.khs.Main;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;

View file

@ -17,7 +17,7 @@
*
*/
package net.tylermurphy.hideAndSeek.database.connections;
package dev.tylerm.khs.database.connections;
import java.sql.Connection;
import java.sql.SQLException;

View file

@ -17,17 +17,15 @@
*
*/
package net.tylermurphy.hideAndSeek.database.connections;
package dev.tylerm.khs.database.connections;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import net.tylermurphy.hideAndSeek.Main;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.configuration.Config;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
public class MySQLConnection implements DatabaseConnection {
@ -37,20 +35,20 @@ public class MySQLConnection implements DatabaseConnection {
HikariConfig config = new HikariConfig();
Main.getInstance().getLogger().info("Database host: " + databaseHost);
Main.getInstance().getLogger().info("Database port: " + databasePort);
Main.getInstance().getLogger().info("Database user: " + databaseUser);
Main.getInstance().getLogger().info("Database host: " + Config.databaseHost);
Main.getInstance().getLogger().info("Database port: " + Config.databasePort);
Main.getInstance().getLogger().info("Database user: " + Config.databaseUser);
Main.getInstance().getLogger().info("Database pass: xxxxxxxxxxx");
Main.getInstance().getLogger().info("Database name: " + databaseName);
Main.getInstance().getLogger().info("Database name: " + Config.databaseName);
config.setDriverClassName(org.mariadb.jdbc.Driver.class.getName());
config.setJdbcUrl("jdbc:mariadb://"+databaseHost+":"+databasePort+"/"+databaseName.trim());
config.setJdbcUrl("jdbc:mariadb://"+ Config.databaseHost+":"+ Config.databasePort+"/"+ Config.databaseName.trim());
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
config.addDataSourceProperty("user", databaseUser);
config.addDataSourceProperty("password",databasePass);
config.addDataSourceProperty("user", Config.databaseUser);
config.addDataSourceProperty("password", Config.databasePass);
config.addDataSourceProperty("autoCommit", "true");
config.setAutoCommit(true);
config.setMaximumPoolSize(20);

View file

@ -17,9 +17,9 @@
*
*/
package net.tylermurphy.hideAndSeek.database.connections;
package dev.tylerm.khs.database.connections;
import net.tylermurphy.hideAndSeek.Main;
import dev.tylerm.khs.Main;
import org.sqlite.SQLiteConfig;
import java.io.File;
@ -52,7 +52,7 @@ public class SQLiteConnection implements DatabaseConnection {
public Connection connect() {
Connection conn = null;
try {
String url = "jdbc:sqlite:"+databaseFile;
String url = "jdbc:sqlite:"+databaseFile.getPath();
conn = DriverManager.getConnection(url, config.toProperties());
} catch (SQLException e) {
Main.getInstance().getLogger().severe(e.getMessage());

View file

@ -17,7 +17,7 @@
*
*/
package net.tylermurphy.hideAndSeek.database.util;
package dev.tylerm.khs.database.util;
public class LegacyPlayerInfo {

View file

@ -17,7 +17,7 @@
*
*/
package net.tylermurphy.hideAndSeek.database.util;
package dev.tylerm.khs.database.util;
import java.util.UUID;

View file

@ -1,10 +1,10 @@
package net.tylermurphy.hideAndSeek.game;
package dev.tylerm.khs.game;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.events.Border;
import net.tylermurphy.hideAndSeek.game.events.Glow;
import net.tylermurphy.hideAndSeek.game.events.Taunt;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.game.events.Border;
import dev.tylerm.khs.game.events.Glow;
import dev.tylerm.khs.game.events.Taunt;
import dev.tylerm.khs.game.util.Status;
import dev.tylerm.khs.Main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -13,9 +13,9 @@ import org.bukkit.scoreboard.*;
import java.util.*;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Leaderboard.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.*;
import static dev.tylerm.khs.configuration.Leaderboard.*;
import static dev.tylerm.khs.configuration.Localization.message;
public class Board {
@ -25,7 +25,7 @@ public class Board {
SPECTATOR,
}
private UUID initialSeeker = null;
private List<UUID> initialSeekers = null;
private final Map<UUID, Type> Players = new HashMap<>();
private final Map<UUID, CustomBoard> customBoards = new HashMap<>();
private final Map<UUID, Integer> hider_kills = new HashMap<>(), seeker_kills = new HashMap<>(), hider_deaths = new HashMap<>(), seeker_deaths = new HashMap<>();
@ -34,6 +34,10 @@ public class Board {
return Players.containsKey(player.getUniqueId());
}
public boolean containsUUID(UUID uuid) {
return Players.containsKey(uuid);
}
public boolean isHider(Player player) {
return isHider(player.getUniqueId());
}
@ -104,9 +108,15 @@ public class Board {
.collect(Collectors.toList());
}
public Player getFirstSeeker() {
if(initialSeeker == null) return null;
return Bukkit.getPlayer(initialSeeker);
public void setInitialSeekers(List<UUID> seekers) {
initialSeekers = seekers;
}
public List<Player> getInitialSeekers() {
if(initialSeekers == null) return null;
return initialSeekers.stream().map(u -> {
return Bukkit.getPlayer(u);
}).collect(Collectors.toList());
}
public Player getPlayer(UUID uuid) {
@ -121,9 +131,6 @@ public class Board {
}
public void addSeeker(Player player) {
if(initialSeeker == null) {
initialSeeker = player.getUniqueId();
}
Players.put(player.getUniqueId(), Type.SEEKER);
}
@ -223,7 +230,7 @@ public class Board {
}
public String getMapName() {
net.tylermurphy.hideAndSeek.configuration.Map map = Main.getInstance().getGame().getCurrentMap();
dev.tylerm.khs.configuration.Map map = Main.getInstance().getGame().getCurrentMap();
if(map == null) return "Invalid";
else return map.getName();
}
@ -347,7 +354,7 @@ public class Board {
public void cleanup() {
Players.clear();;
initialSeeker = null;
initialSeekers = null;
customBoards.clear();
}
@ -415,13 +422,8 @@ class CustomBoard {
seekerTeam.setNameTagVisibility(NameTagVisibility.NEVER);
}
}
if (Main.getInstance().supports(12)) {
hiderTeam.setColor(ChatColor.GOLD);
seekerTeam.setColor(ChatColor.RED);
} else {
hiderTeam.setPrefix(ChatColor.translateAlternateColorCodes('&', "&6"));
seekerTeam.setPrefix(ChatColor.translateAlternateColorCodes('&', "&c"));
}
hiderTeam.setPrefix(message("HIDER_TEAM_NAME").toString() + " " + ChatColor.RESET);
seekerTeam.setPrefix(message("SEEKER_TEAM_NAME").toString() + " " + ChatColor.RESET);
}
public void setLine(String key, String message) {

View file

@ -1,10 +1,10 @@
package net.tylermurphy.hideAndSeek.game;
package dev.tylerm.khs.game;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.*;
import static dev.tylerm.khs.configuration.Localization.message;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.game.util.Disguise;
import dev.tylerm.khs.game.util.Disguise;
import dev.tylerm.khs.configuration.Map;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.game;
package dev.tylerm.khs.game;
import static com.comphenix.protocol.PacketType.Play.Server.*;

View file

@ -17,19 +17,21 @@
*
*/
package net.tylermurphy.hideAndSeek.game;
package dev.tylerm.khs.game;
import com.cryptomorin.xseries.messages.ActionBar;
import com.cryptomorin.xseries.messages.Titles;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.events.Glow;
import net.tylermurphy.hideAndSeek.game.events.Taunt;
import net.tylermurphy.hideAndSeek.game.listener.RespawnHandler;
import net.tylermurphy.hideAndSeek.game.util.*;
import dev.tylerm.khs.game.events.Glow;
import dev.tylerm.khs.game.events.Taunt;
import dev.tylerm.khs.game.listener.RespawnHandler;
import dev.tylerm.khs.game.util.CountdownDisplay;
import dev.tylerm.khs.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.util.WinType;
import org.bukkit.*;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -38,8 +40,8 @@ import org.bukkit.inventory.ItemStack;
import java.util.*;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.*;
import static dev.tylerm.khs.configuration.Localization.message;
public class Game {
@ -58,6 +60,8 @@ public class Game {
private int gameTimer;
private boolean hiderLeft;
private Random random;
public Game(Map map, Board board) {
this.currentMap = map;
@ -74,6 +78,8 @@ public class Game {
this.startingTimer = -1;
this.gameTimer = 0;
this.hiderLeft = false;
this.random = new Random();
}
public Status getStatus(){
@ -97,22 +103,28 @@ public class Game {
}
public void start() {
Player seeker;
List<Player> seekers = new ArrayList<>(startingSeekerCount);
List<Player> pool = board.getPlayers();
for (int i = 0; i < startingSeekerCount; i++) {
try {
int rand = (int) (Math.random() * board.getPlayers().size());
seeker = board.getPlayers().get(rand);
int rand = random.nextInt(0, pool.size());
seekers.add(pool.remove(rand));
} catch (Exception e){
Main.getInstance().getLogger().warning("Failed to select random seeker.");
return;
}
start(seeker);
}
start(seekers);
}
public void start(Player seeker) {
public void start(List<Player> seekers) {
if (mapSaveEnabled) currentMap.getWorldLoader().rollback();
board.reload();
board.setInitialSeekers(seekers.stream().map(Player::getUniqueId).collect(Collectors.toList()));
seekers.forEach(seeker -> {
board.addSeeker(seeker);
PlayerLoader.loadSeeker(seeker, currentMap);
});
board.getPlayers().forEach(player -> {
if(board.isSeeker(player)) return;
board.addHider(player);
@ -122,7 +134,7 @@ public class Game {
currentMap.getWorldBorder().resetWorldBorder();
if (gameLength > 0) gameTimer = gameLength;
status = Status.STARTING;
startingTimer = 30;
startingTimer = hidingTimer;
}
private void stop(WinType type) {
@ -133,10 +145,15 @@ public class Game {
Main.getInstance().getDatabase().getGameData().addWins(board, players, winners, board.getHiderKills(), board.getHiderDeaths(), board.getSeekerKills(), board.getSeekerDeaths(), type);
} else if (type == WinType.SEEKER_WIN) {
List<UUID> winners = new ArrayList<>();
winners.add(board.getFirstSeeker().getUniqueId());
board.getInitialSeekers().forEach(p -> {
winners.add(p.getUniqueId());
});
if (!waitTillNoneLeft && board.getHiders().size() == 1) {
winners.add(board.getHiders().get(0).getUniqueId());
}
Main.getInstance().getDatabase().getGameData().addWins(board, players, winners, board.getHiderKills(), board.getHiderDeaths(), board.getSeekerKills(), board.getSeekerDeaths(), type);
}
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), this::end, 5*20);
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), this::end, endGameDelay*20);
}
public void end() {
@ -332,6 +349,12 @@ public class Game {
}
}
public void broadcastTitle(String title, String subtitle) {
for (Player player : board.getPlayers()) {
Titles.sendTitle(player, 10, 70, 20, title, subtitle);
}
}
public boolean isCurrentMapValid() {
return currentMap != null && !currentMap.isNotSetup();
}
@ -351,23 +374,35 @@ public class Game {
}
private void checkWinConditions() {
if (board.sizeHider() < 1) {
if (hiderLeft) {
int hiderCount = board.sizeHider();
if (hiderCount < 1 || (!waitTillNoneLeft && hiderCount < 2)) {
if (hiderLeft && dontRewardQuit) {
if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_HIDERS_QUIT"));
else broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_HIDERS_QUIT"));
if (gameOverTitle) broadcastTitle(message("GAME_TITLE_NO_WIN").toString(), message("GAME_GAMEOVER_HIDERS_QUIT").toString());
stop(WinType.NONE);
} else {
if (hiderCount < 1 || waitTillNoneLeft) {
if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND"));
else broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND"));
if (gameOverTitle) broadcastTitle(message("GAME_TITLE_SEEKERS_WIN").toString(), message("GAME_GAMEOVER_HIDERS_FOUND").toString());
} else {
Player hider = board.getHiders().get(0);
if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_LAST_HIDER").addPlayer(hider));
else broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_LAST_HIDER").addPlayer(hider));
if (gameOverTitle) broadcastTitle(message("GAME_TITLE_SINGLE_HIDER_WIN").addPlayer(hider).toString(), message("GAME_SUBTITLE_SINGLE_HIDER_WIN").addPlayer(hider).toString());
}
stop(WinType.SEEKER_WIN);
}
} else if (board.sizeSeeker() < 1) {
if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + message("GAME_GAMEOVER_SEEKERS_QUIT"));
else broadcastMessage(abortPrefix + message("GAME_GAMEOVER_SEEKERS_QUIT"));
stop(WinType.NONE);
if (gameOverTitle) broadcastTitle(message("GAME_TITLE_NO_WIN").toString(), message("GAME_GAMEOVER_SEEKERS_QUIT").toString());
stop(dontRewardQuit ? WinType.NONE : WinType.HIDER_WIN);
} else if (gameTimer < 1) {
if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_TIME"));
else broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_TIME"));
if (gameOverTitle) broadcastTitle(message("GAME_TITLE_HIDERS_WIN").toString(), message("GAME_GAMEOVER_TIME").toString());
stop(WinType.HIDER_WIN);
}
hiderLeft = false;

View file

@ -17,13 +17,13 @@
*
*/
package net.tylermurphy.hideAndSeek.game;
package dev.tylerm.khs.game;
import com.cryptomorin.xseries.messages.Titles;
import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Items;
import net.tylermurphy.hideAndSeek.configuration.Map;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.configuration.Items;
import dev.tylerm.khs.configuration.Map;
import org.bukkit.GameMode;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
@ -33,8 +33,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.*;
import static dev.tylerm.khs.configuration.Items.HIDER_ITEMS;
import static dev.tylerm.khs.configuration.Items.SEEKER_ITEMS;
import static dev.tylerm.khs.configuration.Localization.message;
@SuppressWarnings("deprecation")
public class PlayerLoader {
@ -67,19 +69,52 @@ public class PlayerLoader {
Titles.sendTitle(player, 10, 70, 20, ChatColor.GRAY + "" + ChatColor.BOLD + "SPECTATING", ChatColor.WHITE + message("SPECTATOR_SUBTITLE").toString());
}
public static void loadDeadHiderSpectator(Player player, Map map) {
map.getGameSpawn().teleport(player);
loadPlayer(player);
player.setAllowFlight(true);
player.setFlying(true);
player.setFallDistance(0.0F);
player.getInventory().setItem(flightToggleItemPosition, flightToggleItem);
player.getInventory().setItem(teleportItemPosition, teleportItem);
Main.getInstance().getBoard().getPlayers().forEach(otherPlayer -> otherPlayer.hidePlayer(player));
}
public static void resetPlayer(Player player, Board board){
if(board.isSpectator(player)) return;
loadPlayer(player);
if (board.isSeeker(player)) {
if (pvpEnabled)
for(ItemStack item : Items.SEEKER_ITEMS)
player.getInventory().addItem(item);
if (pvpEnabled) {
for(int i = 0; i < 9; i++) {
if (SEEKER_ITEMS.get(i) == null) continue;
player.getInventory().setItem(i, SEEKER_ITEMS.get(i));
}
if (Items.SEEKER_HELM != null)
player.getInventory().setHelmet(Items.SEEKER_HELM);
if (Items.SEEKER_CHEST != null)
player.getInventory().setChestplate(Items.SEEKER_CHEST);
if (Items.SEEKER_LEGS != null)
player.getInventory().setLeggings(Items.SEEKER_LEGS);
if (Items.SEEKER_BOOTS != null)
player.getInventory().setBoots(Items.SEEKER_BOOTS);
}
for(PotionEffect effect : Items.SEEKER_EFFECTS)
player.addPotionEffect(effect);
} else if (board.isHider(player)) {
if (pvpEnabled)
for(ItemStack item : Items.HIDER_ITEMS)
player.getInventory().addItem(item);
if (pvpEnabled) {
for(int i = 0; i < 9; i++) {
if (HIDER_ITEMS.get(i) == null) continue;
player.getInventory().setItem(i, HIDER_ITEMS.get(i));
}
if (Items.HIDER_HELM != null)
player.getInventory().setHelmet(Items.HIDER_HELM);
if (Items.HIDER_CHEST != null)
player.getInventory().setChestplate(Items.HIDER_CHEST);
if (Items.HIDER_LEGS != null)
player.getInventory().setLeggings(Items.HIDER_LEGS);
if (Items.HIDER_BOOTS != null)
player.getInventory().setBoots(Items.HIDER_BOOTS);
}
for(PotionEffect effect : Items.HIDER_EFFECTS)
player.addPotionEffect(effect);
if (glowEnabled) {

View file

@ -1,10 +1,10 @@
package net.tylermurphy.hideAndSeek.game.events;
package dev.tylerm.khs.game.events;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Map;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.configuration.Map;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.*;
import static dev.tylerm.khs.configuration.Localization.message;
public class Border {

View file

@ -1,17 +1,12 @@
package net.tylermurphy.hideAndSeek.game.events;
package dev.tylerm.khs.game.events;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.util.packet.EntityMetadataPacket;
import dev.tylerm.khs.util.packet.EntityMetadataPacket;
import dev.tylerm.khs.Main;
import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static dev.tylerm.khs.configuration.Config.*;
public class Glow {

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.game.events;
package dev.tylerm.khs.game.events;
import net.tylermurphy.hideAndSeek.Main;
import dev.tylerm.khs.Main;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.World;
@ -13,9 +13,9 @@ import java.util.Optional;
import java.util.Random;
import java.util.UUID;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Config.tauntDelay;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.*;
import static dev.tylerm.khs.configuration.Config.tauntDelay;
import static dev.tylerm.khs.configuration.Localization.message;
public class Taunt {

View file

@ -1,16 +1,16 @@
package net.tylermurphy.hideAndSeek.game.listener;
package dev.tylerm.khs.game.listener;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import static net.tylermurphy.hideAndSeek.configuration.Config.blockedCommands;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.blockedCommands;
import static dev.tylerm.khs.configuration.Config.errorPrefix;
import static dev.tylerm.khs.configuration.Localization.message;
public class BlockedCommandHandler implements Listener {

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.game.listener;
package dev.tylerm.khs.game.listener;
import net.tylermurphy.hideAndSeek.Main;
import dev.tylerm.khs.Main;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -9,7 +9,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
public class ChatHandler implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onChat(AsyncPlayerChatEvent event) {
if (Main.getInstance().getBoard().isSpectator(event.getPlayer())) {
event.setCancelled(true);

View file

@ -1,11 +1,11 @@
package net.tylermurphy.hideAndSeek.game.listener;
package dev.tylerm.khs.game.listener;
import com.cryptomorin.xseries.XSound;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.Board;
import net.tylermurphy.hideAndSeek.game.Game;
import net.tylermurphy.hideAndSeek.game.PlayerLoader;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.game.Board;
import dev.tylerm.khs.game.Game;
import dev.tylerm.khs.game.PlayerLoader;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
@ -16,8 +16,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.*;
import static dev.tylerm.khs.configuration.Localization.message;
public class DamageHandler implements Listener {
@ -94,7 +94,7 @@ public class DamageHandler implements Listener {
// Reveal player if they are disguised
Main.getInstance().getDisguiser().reveal(player);
// Teleport player to seeker spawn
if(delayedRespawn){
if(delayedRespawn && !respawnAsSpectator){
game.getCurrentMap().getGameSeekerLobby().teleport(player);
player.sendMessage(messagePrefix + message("RESPAWN_NOTICE").addAmount(delayedRespawnDelay));
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> {
@ -117,10 +117,14 @@ public class DamageHandler implements Listener {
} else {
game.broadcastMessage(message("GAME_PLAYER_FOUND_BY").addPlayer(player).addPlayer(attacker).toString());
}
if (respawnAsSpectator) {
board.addSpectator(player);
PlayerLoader.loadDeadHiderSpectator(player, game.getCurrentMap());
} else {
board.addSeeker(player);
}
//Reload player
PlayerLoader.resetPlayer(player, board);
}
}
board.reloadBoardTeams();
}

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.game.listener;
package dev.tylerm.khs.game.listener;
import static com.comphenix.protocol.PacketType.Play.Client.*;
@ -8,15 +8,11 @@ import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.WrappedEnumEntityUseAction;
import com.comphenix.protocol.wrappers.EnumWrappers.EntityUseAction;
import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.messages.ActionBar;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.util.Disguise;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.game.util.Disguise;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;

View file

@ -1,9 +1,10 @@
package net.tylermurphy.hideAndSeek.game.listener;
package dev.tylerm.khs.game.listener;
import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.messages.ActionBar;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.game.Board;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -13,14 +14,15 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.util.ArrayList;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Config.glowPowerupItem;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.*;
import static dev.tylerm.khs.configuration.Config.glowPowerupItem;
import static dev.tylerm.khs.configuration.Localization.message;
@SuppressWarnings("deprecation")
public class InteractHandler implements Listener {
@ -94,17 +96,82 @@ public class InteractHandler implements Listener {
return;
}
if(temp.isSimilar(teleportItem)){
int amount = Main.getInstance().getBoard().getHiders().size() + Main.getInstance().getBoard().getSeekers().size();
Inventory teleportMenu = Main.getInstance().getServer().createInventory(null, 9*(((amount-1)/9)+1), ChatColor.stripColor(teleportItem.getItemMeta().getDisplayName()));
List<String> hider_lore = new ArrayList<>(); hider_lore.add(message("HIDER_TEAM_NAME").toString());
Main.getInstance().getBoard().getHiders().forEach(hider -> teleportMenu.addItem(getSkull(hider, hider_lore)));
List<String> seeker_lore = new ArrayList<>(); seeker_lore.add(message("SEEKER_TEAM_NAME").toString());
Main.getInstance().getBoard().getSeekers().forEach(seeker -> teleportMenu.addItem(getSkull(seeker, seeker_lore)));
event.getPlayer().openInventory(teleportMenu);
// int amount = Main.getInstance().getBoard().getHiders().size() + Main.getInstance().getBoard().getSeekers().size();
// Inventory teleportMenu = Main.getInstance().getServer().createInventory(null, 9*(((amount-1)/9)+1), ChatColor.stripColor(teleportItem.getItemMeta().getDisplayName()));
// List<String> hider_lore = new ArrayList<>(); hider_lore.add(message("HIDER_TEAM_NAME").toString());
// Main.getInstance().getBoard().getHiders().forEach(hider -> teleportMenu.addItem(getSkull(hider, hider_lore)));
// List<String> seeker_lore = new ArrayList<>(); seeker_lore.add(message("SEEKER_TEAM_NAME").toString());
// Main.getInstance().getBoard().getSeekers().forEach(seeker -> teleportMenu.addItem(getSkull(seeker, seeker_lore)));
// event.getPlayer().openInventory(teleportMenu);
createSpectatorTeleportPage(event.getPlayer(), 0);
}
}
private ItemStack getSkull(Player player, List<String> lore){
public static void createSpectatorTeleportPage(Player player, int page) {
if (page < 0) {
return;
}
final Board board = Main.getInstance().getBoard();
List<Player> players = new ArrayList<>();
players.addAll(board.getHiders());
players.addAll(board.getSeekers());
final int page_size = 9 * 5;
final int amount = players.size();
final int start = page * page_size;
int page_amount = amount - start;
if (page_amount < 1) {
return;
}
boolean next = false, prev = true;
if (page_amount > page_size) {
page_amount = page_size;
next = true;
}
if (page == 0) {
prev = false;
}
final int rows = ((amount - 1) / 9) + 2;
final Inventory teleportMenu = Main.getInstance().getServer().createInventory(null, 9 * rows, ChatColor.stripColor(teleportItem.getItemMeta().getDisplayName()));
final List<String> hider_lore = new ArrayList<>(); hider_lore.add(message("HIDER_TEAM_NAME").toString());
final List<String> seeker_lore = new ArrayList<>(); seeker_lore.add(message("SEEKER_TEAM_NAME").toString());
for (int i = 0; i < page_amount; i++) {
Player plr = players.get(i);
teleportMenu.addItem(getSkull(plr, board.isHider(plr) ? hider_lore : seeker_lore));
}
final int lastRow = (rows - 1) * 9;
if (prev) {
teleportMenu.setItem(lastRow, getPageItem(page - 1));
}
if (next) {
teleportMenu.setItem(lastRow + 8, getPageItem(page + 1));
}
player.openInventory(teleportMenu);
}
private static ItemStack getPageItem(int page) {
ItemStack prevItem = new ItemStack(XMaterial.ENCHANTED_BOOK.parseMaterial(), page + 1);
ItemMeta meta = prevItem.getItemMeta();
meta.setDisplayName("Page " + (page+1));
prevItem.setItemMeta(meta);
return prevItem;
}
private static ItemStack getSkull(Player player, List<String> lore){
assert XMaterial.PLAYER_HEAD.parseMaterial() != null;
ItemStack playerHead = new ItemStack(XMaterial.PLAYER_HEAD.parseMaterial(), 1, (byte) 3);
SkullMeta playerHeadMeta = (SkullMeta) playerHead.getItemMeta();

View file

@ -17,14 +17,14 @@
*
*/
package net.tylermurphy.hideAndSeek.game.listener;
package dev.tylerm.khs.game.listener;
import com.cryptomorin.xseries.XMaterial;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.map.Debug;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.command.map.Debug;
import dev.tylerm.khs.configuration.Map;
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -32,6 +32,8 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class InventoryHandler implements Listener {
@ -52,13 +54,30 @@ public class InventoryHandler implements Listener {
private void checkForSpectatorTeleportMenu(InventoryClickEvent event){
Player player = (Player) event.getWhoClicked();
if (Main.getInstance().getBoard().isSpectator(player) && event.getCurrentItem().getType() == XMaterial.PLAYER_HEAD.parseMaterial()) {
ItemStack item = event.getCurrentItem();
ItemMeta meta = item.getItemMeta();
String name = meta.getDisplayName();
if (Main.getInstance().getBoard().isSpectator(player)) {
if (XMaterial.PLAYER_HEAD.isSimilar(item)) {
event.setCancelled(true);
player.closeInventory();
String name = event.getCurrentItem().getItemMeta().getDisplayName();
Player clicked = Main.getInstance().getServer().getPlayer(name);
if(clicked == null) return;
if (clicked == null) return;
player.teleport(clicked);
} else if (XMaterial.ENCHANTED_BOOK.isSimilar(item)) {
event.setCancelled(true);
player.closeInventory();
if (!name.startsWith("Page ")) return;
String number_str = name.substring(5);
try {
int page = Integer.parseInt(number_str);
InteractHandler.createSpectatorTeleportPage(player, page - 1);
} catch(Exception ignored) {
return;
}
}
}
}

View file

@ -1,9 +1,9 @@
package net.tylermurphy.hideAndSeek.game.listener;
package dev.tylerm.khs.game.listener;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Items;
import net.tylermurphy.hideAndSeek.game.PlayerLoader;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.configuration.Items;
import dev.tylerm.khs.game.PlayerLoader;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -14,8 +14,8 @@ import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.*;
import static dev.tylerm.khs.configuration.Localization.message;
public class JoinLeaveHandler implements Listener {
@ -83,12 +83,16 @@ public class JoinLeaveHandler implements Listener {
}
private void removeItems(Player player) {
for(ItemStack si : Items.SEEKER_ITEMS)
for(ItemStack i : player.getInventory().getContents())
for(ItemStack si : Items.SEEKER_ITEMS) {
if (si == null) continue;
for (ItemStack i : player.getInventory().getContents())
if (si.isSimilar(i)) player.getInventory().remove(i);
for(ItemStack hi : Items.HIDER_ITEMS)
for(ItemStack i : player.getInventory().getContents())
}
for(ItemStack hi : Items.HIDER_ITEMS) {
if (hi == null) continue;
for (ItemStack i : player.getInventory().getContents())
if (hi.isSimilar(i)) player.getInventory().remove(i);
}
}
}

View file

@ -1,9 +1,9 @@
package net.tylermurphy.hideAndSeek.game.listener;
package dev.tylerm.khs.game.listener;
import com.google.common.collect.Sets;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.game.listener.events.PlayerJumpEvent;
import dev.tylerm.khs.game.listener.events.PlayerJumpEvent;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.configuration.Map;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;

View file

@ -1,8 +1,8 @@
package net.tylermurphy.hideAndSeek.game.listener;
package dev.tylerm.khs.game.listener;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Items;
import net.tylermurphy.hideAndSeek.game.util.Status;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.configuration.Items;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -13,8 +13,8 @@ import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.inventory.ItemStack;
import static net.tylermurphy.hideAndSeek.configuration.Config.dropItems;
import static net.tylermurphy.hideAndSeek.configuration.Config.regenHealth;
import static dev.tylerm.khs.configuration.Config.dropItems;
import static dev.tylerm.khs.configuration.Config.regenHealth;
public class PlayerHandler implements Listener {

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.game.listener;
package dev.tylerm.khs.game.listener;
import net.tylermurphy.hideAndSeek.Main;
import dev.tylerm.khs.Main;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;

View file

@ -1,7 +1,7 @@
package net.tylermurphy.hideAndSeek.game.listener;
package dev.tylerm.khs.game.listener;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.Board;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.game.Board;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;

View file

@ -17,7 +17,7 @@
*
*/
package net.tylermurphy.hideAndSeek.game.listener.events;
package dev.tylerm.khs.game.listener.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;

View file

@ -17,7 +17,7 @@
*
*/
package net.tylermurphy.hideAndSeek.game.util;
package dev.tylerm.khs.game.util;
public enum CountdownDisplay {
CHAT,

View file

@ -1,10 +1,10 @@
package net.tylermurphy.hideAndSeek.game.util;
package dev.tylerm.khs.game.util;
import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.messages.ActionBar;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.util.packet.BlockChangePacket;
import net.tylermurphy.hideAndSeek.util.packet.EntityTeleportPacket;
import dev.tylerm.khs.util.packet.BlockChangePacket;
import dev.tylerm.khs.util.packet.EntityTeleportPacket;
import dev.tylerm.khs.Main;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.game.util;
package dev.tylerm.khs.game.util;
public enum Status {

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.game.util;
package dev.tylerm.khs.game.util;
public enum WinType {

View file

@ -1,7 +1,7 @@
package net.tylermurphy.hideAndSeek.util;
package dev.tylerm.khs.util;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.world.VoidGenerator;
import dev.tylerm.khs.world.VoidGenerator;
import dev.tylerm.khs.Main;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
import java.io.File;
import static net.tylermurphy.hideAndSeek.configuration.Config.spawnPatch;
import static dev.tylerm.khs.configuration.Config.spawnPatch;
public class Location {

View file

@ -1,9 +1,12 @@
package net.tylermurphy.hideAndSeek.util;
package dev.tylerm.khs.util;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.database.Database;
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.database.Database;
import dev.tylerm.khs.database.util.PlayerInfo;
import dev.tylerm.khs.game.Board;
import dev.tylerm.khs.game.util.Status;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -11,8 +14,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.Optional;
import java.util.UUID;
import static net.tylermurphy.hideAndSeek.configuration.Config.placeholderError;
import static net.tylermurphy.hideAndSeek.configuration.Config.placeholderNoData;
import static dev.tylerm.khs.configuration.Config.placeholderError;
import static dev.tylerm.khs.configuration.Config.placeholderNoData;
public class PAPIExpansion extends PlaceholderExpansion {
@ -28,7 +31,7 @@ public class PAPIExpansion extends PlaceholderExpansion {
@Override
public @NotNull String getVersion() {
return "1.4.3";
return "1.7.5";
}
@Override
@ -41,8 +44,33 @@ public class PAPIExpansion extends PlaceholderExpansion {
public String onRequest(OfflinePlayer player, @NotNull String params) {
Database database = Main.getInstance().getDatabase();
String[] args = params.split("_");
Status status = Main.getInstance().getGame().getStatus();
Board board = Main.getInstance().getBoard();
System.out.println(args);
if (args.length < 1) return null;
if (args.length == 1 && args[0].equals("hiders")) {
if (!board.containsUUID(player.getUniqueId())) {
return "-";
} else if (status == Status.PLAYING || status == Status.STARTING) {
return "" + Main.getInstance().getBoard().getHiders().size();
} else {
return "-";
}
}
if (args.length == 1 && args[0].equals("seekers")) {
if (!board.containsUUID(player.getUniqueId())) {
return "-";
} else if (status == Status.PLAYING || status == Status.STARTING) {
return "" + Main.getInstance().getBoard().getSeekers().size();
} else {
return "-";
}
}
if ((args.length == 2 || args.length == 3) && (args[0].equals("stats") || args[0].equals("rank-place"))) {
Optional<PlayerInfo> info = this.getPlayerInfo(args.length == 2 ? player.getUniqueId() : database.getNameData().getUUID(args[2]));
if (info.isPresent()) {

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.util;
package dev.tylerm.khs.util;
public class Pair<L, R> {

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.util;
package dev.tylerm.khs.util;
public class Tuple<L, C, R> {

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.util.packet;
package dev.tylerm.khs.util.packet;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.util.packet;
package dev.tylerm.khs.util.packet;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.wrappers.BlockPosition;

View file

@ -1,11 +1,11 @@
package net.tylermurphy.hideAndSeek.util.packet;
package dev.tylerm.khs.util.packet;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.wrappers.WrappedDataValue;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import net.tylermurphy.hideAndSeek.Main;
import dev.tylerm.khs.Main;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull;

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.util.packet;
package dev.tylerm.khs.util.packet;
import com.comphenix.protocol.PacketType;
import org.bukkit.entity.Entity;

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.world;
package dev.tylerm.khs.world;
import org.bukkit.Location;
import org.bukkit.World;

View file

@ -1,16 +1,17 @@
package net.tylermurphy.hideAndSeek.world;
package dev.tylerm.khs.world;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Map;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.configuration.Map;
import org.bukkit.Bukkit;
import org.bukkit.GameRule;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import java.io.*;
import java.nio.file.Files;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import static dev.tylerm.khs.configuration.Config.*;
import static dev.tylerm.khs.configuration.Localization.message;
public class WorldLoader {

View file

@ -1,43 +0,0 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.Locations;
import net.tylermurphy.hideAndSeek.util.Location;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
public class SetExitLocation implements ICommand {
public void execute(Player sender, String[] args) {
LocationUtils.setLocation(sender, Locations.EXIT, null, map -> {
addToConfig("exit.x", sender.getLocation().getBlockX());
addToConfig("exit.y", sender.getLocation().getBlockY());
addToConfig("exit.z", sender.getLocation().getBlockZ());
addToConfig("exit.world", sender.getLocation().getWorld().getName());
exitPosition = Location.from(sender);
saveConfig();
});
}
public String getLabel() {
return "setexit";
}
public String getUsage() {
return "";
}
public String getDescription() {
return "Sets the plugins exit location";
}
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
return null;
}
}

View file

@ -1,70 +0,0 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.minPlayers;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Start implements ICommand {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().checkCurrentMap()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
if (!Main.getInstance().getBoard().contains(sender)) {
sender.sendMessage(errorPrefix + message("GAME_NOT_INGAME"));
return;
}
if (Main.getInstance().getBoard().size() < minPlayers) {
sender.sendMessage(errorPrefix + message("START_MIN_PLAYERS").addAmount(minPlayers));
return;
}
String seekerName;
if (args.length < 1) {
Main.getInstance().getGame().start();
return;
} else {
seekerName = args[0];
}
Player seeker = Bukkit.getPlayer(seekerName);
if (seeker == null || !Main.getInstance().getBoard().contains(seeker)) {
sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(seekerName));
return;
}
Main.getInstance().getGame().start(seeker);
}
public String getLabel() {
return "start";
}
public String getUsage() {
return "<*player>";
}
public String getDescription() {
return "Starts the game either with a random seeker or chosen one";
}
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("player")) {
return Main.getInstance().getBoard().getPlayers().stream().map(Player::getName).collect(Collectors.toList());
}
return null;
}
}

View file

@ -1,54 +0,0 @@
package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Remove implements ICommand {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
} else if(!Maps.removeMap(args[0])){
sender.sendMessage(errorPrefix + message("MAP_FAIL_DELETE").addAmount(args[0]));
} else {
sender.sendMessage(messagePrefix + message("MAP_DELETED").addAmount(args[0]));
}
}
public String getLabel() {
return "remove";
}
public String getUsage() {
return "<map>";
}
public String getDescription() {
return "Remove a map from the plugin!";
}
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
}
return null;
}
}

View file

@ -1,94 +0,0 @@
package net.tylermurphy.hideAndSeek.command.map.set;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Border implements ICommand {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
return;
}
if (map.getSpawn().isNotSetup()) {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
return;
}
if (args.length < 4) {
map.setWorldBorderData(0, 0, 0, 0, 0);
addToConfig("worldBorder.enabled",false);
saveConfig();
sender.sendMessage(messagePrefix + message("WORLDBORDER_DISABLE"));
map.getWorldBorder().resetWorldBorder();
return;
}
int num,delay,change;
try { num = Integer.parseInt(args[1]); } catch (Exception e) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[0]));
return;
}
try { delay = Integer.parseInt(args[2]); } catch (Exception e) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[1]));
return;
}
try { change = Integer.parseInt(args[3]); } catch (Exception e) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[2]));
return;
}
if (num < 100) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_MIN_SIZE"));
return;
}
if (change < 1) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_CHANGE_SIZE"));
return;
}
map.setWorldBorderData(
sender.getLocation().getBlockX(),
sender.getLocation().getBlockZ(),
num,
delay,
change
);
Maps.setMap(map.getName(), map);
sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay).addAmount(change));
map.getWorldBorder().resetWorldBorder();
}
public String getLabel() {
return "border";
}
public String getUsage() {
return "<map> <*size> <*delay> <*move>";
}
public String getDescription() {
return "Sets a maps world border information";
}
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
}
return Collections.singletonList(parameter);
}
}

View file

@ -15,6 +15,10 @@ spawnPatch: false
# default: 1200 aka 20min
gameLength: 1200
# How long in seconds will the initial hiding period last, minimum is 10 seconds
# default: 30
hidingTimer: 30
# Announce join/leave/game over messages to people not playing the game
# default: true
announceMessagesToNonPlayers: true
@ -48,6 +52,33 @@ permissionsRequired: true
# default: 2
minPlayers: 2
# Amount of initial seekers when game starts
# default: 1
startingSeekerCount: 1
# By default, when a HIDER dies they will join the SEEKER team. If enabled they will instead become a spectator
# default: false
respawnAsSpectator: false
# If enabled, the game will go until no hiders are left. If the timer runs out all hiders left will be marked as winning.
# If disabled the game wll go until there is only one hider left. If the timer runs out, all hiders left win, if there is one
# hider left, all inital seekers win along with the last hider.
# default: true
waitTillNoneLeft: true
# By default, if the last hider or seeker quits the game, a win type of NONE is given, which doesnt mark anyone as winning. This can be
# used as a way to prevent players form quitting in a loop to get someone else points.
# default: true
dontRewardQuit: false
# The amount of seconds the game will wait until the players are teleported to the lobby after a game over
# default: 5
endGameDelay: 5
# Along with a chat message, display a title describing the gameover
# default: false
gameOverTitle: true
# This plugin by default functions as not tag to catch Hiders, but to pvp. All players are given weapons,
# and seekers slightly better weapons (this can be changed in items.yml). If you want, you can disable this
# entire pvp functionality, and make Hiders get found on a single hit. Hiders would also not be able to fight

View file

@ -4,7 +4,7 @@
# If pvp is disabled in config.yml, only effects will be given to players.
items:
seeker:
'1':
'0':
material: DIAMOND_SWORD
amount: 1
enchantments:
@ -13,7 +13,7 @@ items:
unbreakable: true
lore:
- 'This is the seeker sword'
'2':
'1':
material: STICK
amount: 1
enchantments:
@ -22,8 +22,19 @@ items:
lore:
- 'It will launch people very far'
- 'Use wisely!'
'helmet':
material: LEATHER_HELMET
'chestplate':
material: LEATHER_CHESTPLATE
'leggings':
material: LEATHER_LEGGINGS
'boots':
material: LEATHER_BOOTS
enchantments:
feather_falling: 4
hider:
'1':
'0':
material: STONE_SWORD
amount: 1
enchantments:
@ -32,11 +43,11 @@ items:
unbreakable: true
lore:
- 'This is the hider sword'
'2':
'1':
material: SPLASH_POTION
amount: 1
type: REGEN
'3':
'2':
material: POTION
amount: 2
type: INSTANT_HEAL
@ -55,12 +66,6 @@ effects:
amplifier: 1
ambient: false
particles: false
'3':
type: SLOW_FALLING
duration: 1000000
amplifier: 1
ambient: false
particles: false
'4':
type: WATER_BREATHING
duration: 1000000

View file

@ -12,12 +12,18 @@ Localization:
COMMAND_ERROR: "Ein unbekannter Fehler ist aufgetreten."
COMMAND_INVALID_ARG: "Ungültiges Argument: {AMOUNT}"
GAME_PLAYER_DEATH: "&c{PLAYER}&f ist gestorben."
GAME_PLAYER_FOUND: "&e{PLAYER}&f wurde gefunden und ist nun ein Seeker."
GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f wurde von &c{PLAYER}&f gefunden und ist nun ein Seeker."
GAME_PLAYER_FOUND: "&e{PLAYER}&f wurde gefunden"
GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f wurde von &c{PLAYER}&f gefunden"
GAME_GAMEOVER_HIDERS_FOUND: "Alle Hider wurden gefunden."
GAME_GAMEOVER_LAST_HIDER: "Der letzte Hider, &e{PLAYER}&f, hat gewonnen!"
GAME_GAMEOVER_SEEKERS_QUIT: "All Seeker haben das Spiel verlassen."
GAME_GAMEOVER_HIDERS_QUIT: "All Hider haben das Spiel verlassen."
GAME_GAMEOVER_TIME: "Seekers haben keine Spielzeit mehr. Die Hiders haben gewonnen!"
GAME_TITLE_HIDERS_WIN: "&aHiders haben gewonnen!"
GAME_TITLE_SINGLE_HIDER_WIN: "&a{PLAYER} haben gewonnen!"
GAME_TITLE_SEEKERS_WIN: "&cSeekers haben gewonnen!"
GAME_TITLE_NO_WIN: "&bSpiel ist aus"
GAME_SUBTITLE_SINGLE_HIDER_WIN: "{PLAYER} ist der letzte lebende Hider!"
GAME_SETUP: "Es gibt keine Setup-Karten! Führen Sie /hs map status auf einer Karte aus, um zu sehen, was Sie tun müssen."
GAME_INGAME: "Du bist bereits in der Lobby oder im Spiel."
GAME_NOT_INGAME: "Du bist weder in einer Lobby noch in einem Spiel."
@ -128,5 +134,5 @@ Localization:
CONFIRMATION: "Führen Sie /hs confirm innerhalb von 10s aus, um zu bestätigen."
# DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE
version: 4
version: 5
type: "de-DE"

View file

@ -12,12 +12,18 @@ Localization:
COMMAND_ERROR: "An internal error has occurred."
COMMAND_INVALID_ARG: "Invalid argument: {AMOUNT}"
GAME_PLAYER_DEATH: "&c{PLAYER}&f was killed."
GAME_PLAYER_FOUND: "&e{PLAYER}&f was found and became a seeker."
GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f was found by &c{PLAYER}&f and became a seeker."
GAME_PLAYER_FOUND: "&e{PLAYER}&f was found"
GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f was found by &c{PLAYER}&f"
GAME_GAMEOVER_HIDERS_FOUND: "All hiders have been found."
GAME_GAMEOVER_LAST_HIDER: "The last hider, &e{PLAYER}&f, has won!"
GAME_GAMEOVER_SEEKERS_QUIT: "All seekers have quit."
GAME_GAMEOVER_HIDERS_QUIT: "All hiders have quit."
GAME_GAMEOVER_TIME: "Seekers ran out of time. Hiders win!"
GAME_TITLE_HIDERS_WIN: "&aHiders Win!"
GAME_TITLE_SINGLE_HIDER_WIN: "&a{PLAYER} Wins!"
GAME_TITLE_SEEKERS_WIN: "&cSeekers Win!"
GAME_TITLE_NO_WIN: "&bGame Over"
GAME_SUBTITLE_SINGLE_HIDER_WIN: "{PLAYER} is the last hider alive!"
GAME_SETUP: "There are no setup maps! Run /hs map status on a map to see what you need to do."
GAME_INGAME: "You are already in the lobby/game."
GAME_NOT_INGAME: "You are not in a lobby/game."
@ -128,5 +134,5 @@ Localization:
CONFIRMATION: "Run /hs confirm within 10s to confirm."
# DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE
version: 4
version: 5
type: "en-US"

View file

@ -1,6 +1,6 @@
name: KenshinsHideAndSeek
main: net.tylermurphy.hideAndSeek.Main
version: 1.7.4
main: dev.tylerm.khs.Main
version: 1.7.5
author: KenshinEto
load: STARTUP
api-version: 1.13