diff options
author | Tyler Murphy <tylermurphy534@gmail.com> | 2022-11-26 14:23:39 -0500 |
---|---|---|
committer | Tyler Murphy <tylermurphy534@gmail.com> | 2022-11-26 14:23:39 -0500 |
commit | 6b453dde9758bc6d4d399528209addc2b817ce1a (patch) | |
tree | 3172b2afa630621a22cc65426f6b932b1b0f912f /src/main/java/net | |
parent | fix seeker/hider returning null (diff) | |
download | kenshinshideandseek-6b453dde9758bc6d4d399528209addc2b817ce1a.tar.gz kenshinshideandseek-6b453dde9758bc6d4d399528209addc2b817ce1a.tar.bz2 kenshinshideandseek-6b453dde9758bc6d4d399528209addc2b817ce1a.zip |
1.7.0RC1
Diffstat (limited to 'src/main/java/net')
38 files changed, 232 insertions, 666 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/Main.java b/src/main/java/net/tylermurphy/hideAndSeek/Main.java index ad49273..36d92ee 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/Main.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/Main.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek; import net.tylermurphy.hideAndSeek.command.*; @@ -204,6 +185,7 @@ public class Main extends JavaPlugin implements Listener { getServer().getPluginManager().registerEvents(new MovementHandler(), this); getServer().getPluginManager().registerEvents(new PlayerHandler(), this); getServer().getPluginManager().registerEvents(new RespawnHandler(), this); + getServer().getPluginManager().registerEvents(new WorldInteractHandler(), this); } private void updateVersion(){ diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java index 3efddcd..41db5a9 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command; import net.tylermurphy.hideAndSeek.Main; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java index 69387cd..0c01265 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command; import net.tylermurphy.hideAndSeek.Main; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java index cb0c745..109930b 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command; import net.tylermurphy.hideAndSeek.Main; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java index df2944b..0c2b6b1 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command; import net.tylermurphy.hideAndSeek.Main; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java index 0a57cfc..7da404f 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command; import net.tylermurphy.hideAndSeek.command.util.ICommand; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java index 74b8490..5184933 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command; import net.tylermurphy.hideAndSeek.Main; @@ -59,13 +40,8 @@ public class Start implements ICommand { } else { seekerName = args[0]; } - Player temp = Bukkit.getPlayer(seekerName); - if (temp == null) { - sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(seekerName)); - return; - } - Player seeker = Main.getInstance().getBoard().getPlayer(temp.getUniqueId()); - if (seeker == null) { + Player seeker = Bukkit.getPlayer(seekerName); + if (seeker == null || !Main.getInstance().getBoard().contains(seeker)) { sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(seekerName)); return; } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java index 4bc23fe..498e30d 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command; import net.tylermurphy.hideAndSeek.Main; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java index 4ac4aa7..13f3069 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command; import net.tylermurphy.hideAndSeek.Main; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java index 1ba44ac..fb61fb2 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command; import net.tylermurphy.hideAndSeek.Main; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Save.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Save.java index a612026..03e23a8 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Save.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Save.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command.map; import net.tylermurphy.hideAndSeek.Main; @@ -53,7 +34,7 @@ public class Save implements ICommand { sender.sendMessage(errorPrefix + message("INVALID_MAP")); return; } - if (map.isSpawnNotSetup()) { + if (map.getSpawn().isNotSetup()) { sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN")); return; } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Status.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Status.java index c7da88a..90615e5 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Status.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Status.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command.map; import net.tylermurphy.hideAndSeek.command.util.ICommand; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/Enabled.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/Enabled.java index 14ae8e0..2567427 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/Enabled.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/Enabled.java @@ -20,6 +20,10 @@ 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")); + return; + } if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); return; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Add.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Add.java index fbdeecb..fea08ef 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Add.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Add.java @@ -20,6 +20,10 @@ 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")); + return; + } if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); return; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/List.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/List.java index 18f1b3c..de783ce 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/List.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/List.java @@ -1,5 +1,6 @@ package net.tylermurphy.hideAndSeek.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; @@ -17,6 +18,10 @@ 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")); + return; + } Map map = Maps.getMap(args[0]); if(map == null) { sender.sendMessage(errorPrefix + message("INVALID_MAP")); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Remove.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Remove.java index d2afdc1..1c16fdc 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Remove.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Remove.java @@ -20,6 +20,10 @@ 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")); + return; + } if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); return; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Border.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Border.java index f9e14f8..64bf5d4 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Border.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Border.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command.map.set; import net.tylermurphy.hideAndSeek.Main; @@ -46,7 +27,7 @@ public class Border implements ICommand { sender.sendMessage(errorPrefix + message("INVALID_MAP")); return; } - if (map.isSpawnNotSetup()) { + if (map.getSpawn().isNotSetup()) { sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN")); return; } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Bounds.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Bounds.java index 960863b..3d1f036 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Bounds.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Bounds.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command.map.set; import net.tylermurphy.hideAndSeek.Main; @@ -24,6 +5,7 @@ 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 org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; @@ -45,10 +27,14 @@ public class Bounds implements ICommand { sender.sendMessage(errorPrefix + message("INVALID_MAP")); return; } - if (map.isSpawnNotSetup()) { + if (map.getSpawn().isNotSetup()) { sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN")); return; } + if (map.getSeekerLobby().isNotSetup()) { + sender.sendMessage(errorPrefix + message("ERROR_GAME_SEEKER_SPAWN")); + return; + } if (!sender.getWorld().getName().equals(map.getSpawnName())) { sender.sendMessage(errorPrefix + message("BOUNDS_WRONG_WORLD")); return; @@ -87,6 +73,20 @@ public class Bounds implements ICommand { } map.setBoundMin(bxs, bzs); map.setBoundMax(bxl, bzl); + if(!map.isBoundsNotSetup()) { + if(!map.getSpawn().isNotSetup()) { + if(map.getSpawn().isNotInBounds(bxs, bxl, bzs, bzl)) { + map.setSpawn(Location.getDefault()); + sender.sendMessage(warningPrefix + 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")); + } + } + } Maps.setMap(map.getName(), map); sender.sendMessage(messagePrefix + message("BOUNDS").addAmount(first ? 1 : 2)); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Lobby.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Lobby.java index ada76e2..6690ae9 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Lobby.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Lobby.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command.map.set; import net.tylermurphy.hideAndSeek.command.util.ICommand; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/SeekerLobby.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/SeekerLobby.java index 9bc0249..b6c5cf0 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/SeekerLobby.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/SeekerLobby.java @@ -6,24 +6,33 @@ import net.tylermurphy.hideAndSeek.command.location.Locations; import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.util.Location; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; -import java.util.List; +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.isSpawnNotSetup()) { + if(map.getSpawn().isNotSetup()) { throw new RuntimeException(message("GAME_SPAWN_NEEDED").toString()); } if(!map.getSpawnName().equals(sender.getLocation().getWorld().getName())) { throw new RuntimeException(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")); + } + } }); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Spawn.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Spawn.java index b983404..0baf55e 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Spawn.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Spawn.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command.map.set; import net.tylermurphy.hideAndSeek.command.util.ICommand; @@ -47,8 +28,16 @@ public class Spawn implements ICommand { map.setSpawn(Location.from(sender)); + if(!map.isBoundsNotSetup()) { + 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")); + } + } + if(map.getSeekerLobby().getWorld() != null && !map.getSeekerLobby().getWorld().equals(sender.getLocation().getWorld().getName())) { - sender.sendMessage(message("SEEKER_LOBBY_SPAWN_RESET").toString()); + sender.sendMessage(warningPrefix + message("SEEKER_LOBBY_SPAWN_RESET")); map.setSeekerLobby(Location.getDefault()); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/util/CommandGroup.java b/src/main/java/net/tylermurphy/hideAndSeek/command/util/CommandGroup.java index b366b9a..0cb307b 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/util/CommandGroup.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/util/CommandGroup.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command.util; import net.tylermurphy.hideAndSeek.command.map.Save; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/util/ICommand.java b/src/main/java/net/tylermurphy/hideAndSeek/command/util/ICommand.java index 3aa0ca4..1be678c 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/util/ICommand.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/util/ICommand.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.command.util; import org.bukkit.entity.Player; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java index dbc9e37..5881d19 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.configuration; import com.cryptomorin.xseries.XItemStack; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java index 958d1ca..92fa4ce 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.configuration; import net.tylermurphy.hideAndSeek.Main; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java index 06dbb99..e5f970b 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Items.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.configuration; import com.cryptomorin.xseries.XItemStack; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java index 6f3f88b..b9f9b69 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.configuration; import net.md_5.bungee.api.ChatColor; @@ -38,7 +19,8 @@ public class Localization { }); put("de-DE", new String[][]{ {}, - {"TAUNTED"} + {"TAUNTED"}, + {"GAME_SETUP", "SETUP_GAME", "SETUP_LOBBY", "SETUP_SEEKER_LOBBY", "SETUP_EXIT", "SETUP_SAVEMAP", "SETUP_BOUNDS"} }); }}; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/LocalizationString.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/LocalizationString.java index 3d8bc0f..b457622 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/LocalizationString.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/LocalizationString.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.configuration; import org.bukkit.entity.Entity; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Map.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Map.java index 8c3f8a7..a23a1f7 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Map.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Map.java @@ -3,6 +3,7 @@ package net.tylermurphy.hideAndSeek.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; @@ -80,7 +81,11 @@ public class Map { } public void setBlockhunt(boolean enabled, List<Material> blocks) { - this.blockhunt = enabled; + if (Main.getInstance().supports(9)) { + this.blockhunt = enabled; + } else { + this.blockhunt = false; + } this.blockhuntBlocks = blocks; } @@ -226,10 +231,6 @@ public class Map { return xBoundMin == 0 || zBoundMin == 0 || xBoundMax == 0 || zBoundMax == 0; } - public boolean isSpawnNotSetup() { - return spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0; - } - public boolean isBoundsNotSetup() { return xBoundMin == 0 || zBoundMin == 0 || xBoundMax == 0 || zBoundMax == 0; } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/Database.java b/src/main/java/net/tylermurphy/hideAndSeek/database/Database.java index d2fb40d..dca2de0 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/database/Database.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/database/Database.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.database; import com.google.common.io.ByteStreams; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/GameDataTable.java b/src/main/java/net/tylermurphy/hideAndSeek/database/GameDataTable.java index 8f0ddde..c01f615 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/database/GameDataTable.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/database/GameDataTable.java @@ -175,10 +175,10 @@ public class GameDataTable { @NotNull Board board, @NotNull List<UUID> uuids, @NotNull List<UUID> winners, - @NotNull Map<String,Integer> hider_kills, - @NotNull Map<String,Integer> hider_deaths, - @NotNull Map<String,Integer> seeker_kills, - @NotNull Map<String,Integer> seeker_deaths, + @NotNull Map<UUID,Integer> hider_kills, + @NotNull Map<UUID,Integer> hider_deaths, + @NotNull Map<UUID,Integer> seeker_kills, + @NotNull Map<UUID,Integer> seeker_deaths, @NotNull WinType type ) { for(UUID uuid : uuids) { @@ -192,10 +192,10 @@ public class GameDataTable { 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.getHiderKills() + hider_kills.getOrDefault(uuid.toString(), 0), - info.getSeekerKills() + seeker_kills.getOrDefault(uuid.toString(), 0), - info.getHiderDeaths() + hider_deaths.getOrDefault(uuid.toString(), 0), - info.getSeekerDeaths() + seeker_deaths.getOrDefault(uuid.toString(), 0) + info.getHiderKills() + hider_kills.getOrDefault(uuid, 0), + info.getSeekerKills() + seeker_kills.getOrDefault(uuid, 0), + info.getHiderDeaths() + hider_deaths.getOrDefault(uuid, 0), + info.getSeekerDeaths() + seeker_deaths.getOrDefault(uuid, 0) ); } } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java index 8c26bc8..2050f33 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.game; import net.tylermurphy.hideAndSeek.Main; @@ -38,109 +19,128 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message; public class Board { - private final List<String> Hider = new ArrayList<>(), Seeker = new ArrayList<>(), Spectator = new ArrayList<>(); - private final Map<String, Player> playerList = new HashMap<>(); - private final Map<String, CustomBoard> customBoards = new HashMap<>(); - private final Map<String, Integer> hider_kills = new HashMap<>(), seeker_kills = new HashMap<>(), hider_deaths = new HashMap<>(), seeker_deaths = new HashMap<>(); + private enum Type { + HIDER, + SEEKER, + SPECTATOR, + } + + private UUID initialSeeker = 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<>(); public boolean contains(Player player) { - return playerList.containsKey(player.getUniqueId().toString()); + return Players.containsKey(player.getUniqueId()); } public boolean isHider(Player player) { - return Hider.contains(player.getUniqueId().toString()); + return isHider(player.getUniqueId()); } public boolean isHider(UUID uuid) { - return Hider.contains(uuid.toString()); + if(!Players.containsKey(uuid)) return false; + return Players.get(uuid) == Type.HIDER; } public boolean isSeeker(Player player) { - return Seeker.contains(player.getUniqueId().toString()); + return isSeeker(player.getUniqueId()); } public boolean isSeeker(UUID uuid) { - return Seeker.contains(uuid.toString()); + if(!Players.containsKey(uuid)) return false; + return Players.get(uuid) == Type.SEEKER; } public boolean isSpectator(Player player) { - return Spectator.contains(player.getUniqueId().toString()); + return isSpectator(player.getUniqueId()); + } + + public boolean isSpectator(UUID uuid) { + if(!Players.containsKey(uuid)) return false; + return Players.get(uuid) == Type.SPECTATOR; } public int sizeHider() { - return Hider.size(); + return getHiders().size(); } public int sizeSeeker() { - return Seeker.size(); + return getSeekers().size(); } public int size() { - return playerList.values().size(); + return getPlayers().size(); } public List<Player> getHiders() { - return Hider.stream().filter(Objects::nonNull).map(playerList::get).filter(Objects::nonNull).collect(Collectors.toList()); + return Players.keySet().stream() + .filter(s -> Players.get(s) == Type.HIDER) + .map(Bukkit::getPlayer) + .filter(Objects::nonNull) + .collect(Collectors.toList()); } public List<Player> getSeekers() { - return Seeker.stream().filter(Objects::nonNull).map(playerList::get).filter(Objects::nonNull).collect(Collectors.toList()); - } - - public Player getFirstSeeker() { - return playerList.get(Seeker.get(0)); + return Players.keySet().stream() + .filter(s -> Players.get(s) == Type.SEEKER) + .map(Bukkit::getPlayer) + .filter(Objects::nonNull) + .collect(Collectors.toList()); } public List<Player> getSpectators() { - return Spectator.stream().filter(Objects::nonNull).map(playerList::get).filter(Objects::nonNull).collect(Collectors.toList()); + return Players.keySet().stream() + .filter(s -> Players.get(s) == Type.SPECTATOR) + .map(Bukkit::getPlayer) + .filter(Objects::nonNull) + .collect(Collectors.toList()); } public List<Player> getPlayers() { - return playerList.values().stream().filter(Objects::nonNull).collect(Collectors.toList()); + return Players.keySet().stream() + .map(Bukkit::getPlayer) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + } + + public Player getFirstSeeker() { + if(initialSeeker == null) return null; + return Bukkit.getPlayer(initialSeeker); } public Player getPlayer(UUID uuid) { - return playerList.get(uuid.toString()); + if(!Players.containsKey(uuid)) { + return null; + } + return Bukkit.getPlayer(uuid); } public void addHider(Player player) { - Hider.add(player.getUniqueId().toString()); - Seeker.remove(player.getUniqueId().toString()); - Spectator.remove(player.getUniqueId().toString()); - playerList.put(player.getUniqueId().toString(), player); + Players.put(player.getUniqueId(), Type.HIDER); } public void addSeeker(Player player) { - Hider.remove(player.getUniqueId().toString()); - Seeker.add(player.getUniqueId().toString()); - Spectator.remove(player.getUniqueId().toString()); - playerList.put(player.getUniqueId().toString(), player); + if(initialSeeker == null) { + initialSeeker = player.getUniqueId(); + } + Players.put(player.getUniqueId(), Type.SEEKER); } public void addSpectator(Player player) { - Hider.remove(player.getUniqueId().toString()); - Seeker.remove(player.getUniqueId().toString()); - Spectator.add(player.getUniqueId().toString()); - playerList.put(player.getUniqueId().toString(), player); + Players.put(player.getUniqueId(), Type.SPECTATOR); } public void remove(Player player) { - Hider.remove(player.getUniqueId().toString()); - Seeker.remove(player.getUniqueId().toString()); - Spectator.remove(player.getUniqueId().toString()); - playerList.remove(player.getUniqueId().toString()); + Players.remove(player.getUniqueId()); } public boolean onSameTeam(Player player1, Player player2) { - if (Hider.contains(player1.getUniqueId().toString()) && Hider.contains(player2.getUniqueId().toString())) return true; - else if (Seeker.contains(player1.getUniqueId().toString()) && Seeker.contains(player2.getUniqueId().toString())) return true; - else return Spectator.contains(player1.getUniqueId().toString()) && Spectator.contains(player2.getUniqueId().toString()); + return Players.get(player1.getUniqueId()) == Players.get(player2.getUniqueId()); } public void reload() { - Hider.clear(); - Seeker.clear(); - Spectator.clear(); + Players.replaceAll((u, v) -> Type.HIDER); hider_kills.clear(); seeker_kills.clear(); hider_deaths.clear(); @@ -148,47 +148,38 @@ public class Board { } public void addKill(UUID uuid) { - if (Hider.contains(uuid.toString())) { - if (hider_kills.containsKey(uuid.toString())) { - hider_kills.put(uuid.toString(), hider_kills.get(uuid.toString())+1); - } else { - hider_kills.put(uuid.toString(), 1); - } - } else if (Seeker.contains(uuid.toString())) { - if (seeker_kills.containsKey(uuid.toString())) { - seeker_kills.put(uuid.toString(), seeker_kills.get(uuid.toString())+1); - } else { - seeker_kills.put(uuid.toString(), 1); - } + if(Players.get(uuid) == Type.HIDER) { + int kills = hider_kills.getOrDefault(uuid, 0); + hider_kills.put(uuid, kills + 1); + } else if(Players.get(uuid) == Type.SEEKER) { + int kills = seeker_kills.getOrDefault(uuid, 0); + seeker_kills.put(uuid, kills + 1); } } public void addDeath(UUID uuid) { - if (Hider.contains(uuid.toString())) { - if (hider_deaths.containsKey(uuid.toString())) { - hider_deaths.put(uuid.toString(), hider_deaths.get(uuid.toString())+1); - } else { - hider_deaths.put(uuid.toString(), 1); - } - } else if (Seeker.contains(uuid.toString())) { - if (seeker_deaths.containsKey(uuid.toString())) { - seeker_deaths.put(uuid.toString(), seeker_deaths.get(uuid.toString())+1); - } else { - seeker_deaths.put(uuid.toString(), 1); - } + if(Players.get(uuid) == Type.HIDER) { + int kills = hider_deaths.getOrDefault(uuid, 0); + hider_deaths.put(uuid, kills + 1); + } else if(Players.get(uuid) == Type.SEEKER) { + int kills = seeker_deaths.getOrDefault(uuid, 0); + seeker_deaths.put(uuid, kills + 1); } } - public Map<String, Integer> getHiderKills() { + public Map<UUID, Integer> getHiderKills() { return new HashMap<>(hider_kills); } - public Map<String, Integer> getSeekerKills() { + + public Map<UUID, Integer> getSeekerKills() { return new HashMap<>(seeker_kills); } - public Map<String, Integer> getHiderDeaths() { + + public Map<UUID, Integer> getHiderDeaths() { return new HashMap<>(hider_deaths); } - public Map<String, Integer> getSeekerDeaths() { + + public Map<UUID, Integer> getSeekerDeaths() { return new HashMap<>(seeker_deaths); } @@ -197,7 +188,7 @@ public class Board { } private void createLobbyBoard(Player player, boolean recreate) { - CustomBoard board = customBoards.get(player.getUniqueId().toString()); + CustomBoard board = customBoards.get(player.getUniqueId()); if (recreate || board == null) { board = new CustomBoard(player, LOBBY_TITLE); board.updateTeams(); @@ -228,7 +219,7 @@ public class Board { i++; } board.display(); - customBoards.put(player.getUniqueId().toString(), board); + customBoards.put(player.getUniqueId(), board); } public String getMapName() { @@ -242,7 +233,7 @@ public class Board { } private void createGameBoard(Player player, boolean recreate) { - CustomBoard board = customBoards.get(player.getUniqueId().toString()); + CustomBoard board = customBoards.get(player.getUniqueId()); if (recreate || board == null) { board = new CustomBoard(player, GAME_TITLE); board.updateTeams(); @@ -279,7 +270,7 @@ public class Board { if (!tauntEnabled) continue; if (taunt == null || status == Status.STARTING) { board.setLine(String.valueOf(i), line.replace("{TAUNT}", TAUNT_COUNTING.replace("{AMOUNT}", "0"))); - } else if (!tauntLast && Hider.size() == 1) { + } else if (!tauntLast && sizeHider() == 1) { board.setLine(String.valueOf(i), line.replace("{TAUNT}", TAUNT_EXPIRED)); } else if (!taunt.isRunning()) { board.setLine(String.valueOf(i), line.replace("{TAUNT}", TAUNT_COUNTING.replaceFirst("\\{AMOUNT}", taunt.getDelay() / 60 + "").replaceFirst("\\{AMOUNT}", taunt.getDelay() % 60 + ""))); @@ -306,23 +297,23 @@ public class Board { i++; } board.display(); - customBoards.put(player.getUniqueId().toString(), board); + customBoards.put(player.getUniqueId(), board); } public void removeBoard(Player player) { ScoreboardManager manager = Bukkit.getScoreboardManager(); assert manager != null; player.setScoreboard(manager.getMainScoreboard()); - customBoards.remove(player.getUniqueId().toString()); + customBoards.remove(player.getUniqueId()); } public void reloadLobbyBoards() { - for(Player player : playerList.values()) + for(Player player : getPlayers()) createLobbyBoard(player, false); } public void reloadGameBoards() { - for(Player player : playerList.values()) + for(Player player : getPlayers()) createGameBoard(player, false); } @@ -332,17 +323,19 @@ public class Board { } private String getSeekerPercent() { - if (playerList.values().size() < 2) + int size = size(); + if (size < 2) return " --"; else - return " "+(int)(100*(1.0/playerList.size())); + return " "+(int)(100*(1.0/size)); } private String getHiderPercent() { - if (playerList.size() < 2) + int size = size(); + if (size < 2) return " --"; else - return " "+(int)(100-100*(1.0/playerList.size())); + return " "+(int)(100-100*(1.0/size)); } private String getTeam(Player player) { @@ -353,10 +346,8 @@ public class Board { } public void cleanup() { - playerList.clear(); - Hider.clear(); - Seeker.clear(); - Spectator.clear(); + Players.clear();; + initialSeeker = null; customBoards.clear(); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/WorldInteractHandler.java b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/WorldInteractHandler.java new file mode 100644 index 0000000..10b8e3e --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/WorldInteractHandler.java @@ -0,0 +1,48 @@ +package net.tylermurphy.hideAndSeek.game.listener; + +import net.tylermurphy.hideAndSeek.Main; +import net.tylermurphy.hideAndSeek.game.Board; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.EntityBreakDoorEvent; +import org.bukkit.event.hanging.HangingBreakByEntityEvent; + +public class WorldInteractHandler implements Listener { + + @EventHandler(priority = EventPriority.HIGHEST) + public void onBlockBreak(BlockBreakEvent event) { + Player player = event.getPlayer(); + Board board = Main.getInstance().getBoard(); + if(board.contains(player)) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onHangingEntityBreakByEntity(HangingBreakByEntityEvent event) { + if (!(event.getRemover() instanceof Player)) { + return; + } + Player player = (Player) event.getRemover(); + Board board = Main.getInstance().getBoard(); + if(board.contains(player)) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onBreakDoor(EntityBreakDoorEvent event) { + if (!(event.getEntity() instanceof Player)) { + return; + } + Player player = (Player) event.getEntity(); + Board board = Main.getInstance().getBoard(); + if(board.contains(player)) { + event.setCancelled(true); + } + } + +} diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/util/Status.java b/src/main/java/net/tylermurphy/hideAndSeek/game/util/Status.java index e630070..44f19b2 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/util/Status.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/util/Status.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.game.util; public enum Status { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/util/WinType.java b/src/main/java/net/tylermurphy/hideAndSeek/game/util/WinType.java index f584d80..24544ba 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/util/WinType.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/util/WinType.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.game.util; public enum WinType { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/Location.java b/src/main/java/net/tylermurphy/hideAndSeek/util/Location.java index 10fa783..a5060c6 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/util/Location.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/Location.java @@ -134,4 +134,12 @@ public class Location { return destination.isDirectory(); } + public boolean isNotSetup() { + return getBlockX() == 0 && getBlockY() == 0 && getBlockZ() == 0; + } + + public boolean isNotInBounds(int xmin, int xmax, int zmin, int zmax) { + return getBlockX() < xmin || getBlockX() > xmax || getBlockZ() < zmin || getBlockZ() > zmax; + } + } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java b/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java index 15ff45f..4f9ad0d 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.world; import org.bukkit.Location; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java b/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java index d14f617..e5913aa 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java @@ -1,22 +1,3 @@ -/* - * This file is part of Kenshins Hide and Seek - * - * Copyright (c) 2021 Tyler Murphy. - * - * Kenshins Hide and Seek free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * he Free Software Foundation version 3. - * - * Kenshins Hide and Seek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - package net.tylermurphy.hideAndSeek.world; import net.tylermurphy.hideAndSeek.Main; |