summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/game/util
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2022-05-16 13:56:52 -0400
committerTyler Murphy <tylermurphy534@gmail.com>2022-05-16 13:56:52 -0400
commit416e459af261994ad702462812c29d55da8cb2d5 (patch)
tree96eaeda704398b95ddaf65fb2a105dd10419c04c /src/main/java/net/tylermurphy/hideAndSeek/game/util
parentMerge pull request #55 from bobby29831/1.4.3 (diff)
downloadkenshinshideandseek-416e459af261994ad702462812c29d55da8cb2d5.tar.gz
kenshinshideandseek-416e459af261994ad702462812c29d55da8cb2d5.tar.bz2
kenshinshideandseek-416e459af261994ad702462812c29d55da8cb2d5.zip
refactor: Jump Event, InventoryHandler, Relocate One function Utility Classes, Config Manager Getters Use Contains()
Diffstat (limited to '')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/game/PlayerLoader.java (renamed from src/main/java/net/tylermurphy/hideAndSeek/game/util/PlayerUtil.java)30
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/game/util/Packet.java56
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/game/util/Version.java45
3 files changed, 24 insertions, 107 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/util/PlayerUtil.java b/src/main/java/net/tylermurphy/hideAndSeek/game/PlayerLoader.java
index 59c7b73..0ce7ac7 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/util/PlayerUtil.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/PlayerLoader.java
@@ -1,10 +1,28 @@
-package net.tylermurphy.hideAndSeek.game.util;
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2022 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 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.game.Board;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
@@ -19,7 +37,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Config.lobbyPosition;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class PlayerUtil {
+public class PlayerLoader {
public static void loadHider(Player player, String gameWorld){
player.teleport(new Location(Bukkit.getWorld(gameWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
@@ -77,11 +95,11 @@ public class PlayerUtil {
for(PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}
- if (Version.atLeast("1.9")) {
+ if (Main.getInstance().supports(9)) {
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
if (attribute != null) player.setHealth(attribute.getValue());
for(Player temp : Main.getInstance().getBoard().getPlayers()) {
- Packet.setGlow(player, temp, false);
+ Main.getInstance().getGame().getGlow().setGlow(player, temp, false);
}
} else {
player.setHealth(player.getMaxHealth());
@@ -111,7 +129,7 @@ public class PlayerUtil {
player.removePotionEffect(effect.getType());
}
player.setFoodLevel(20);
- if (Version.atLeast("1.9")) {
+ if (Main.getInstance().supports(9)) {
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
if (attribute != null) player.setHealth(attribute.getValue());
} else {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/util/Packet.java b/src/main/java/net/tylermurphy/hideAndSeek/game/util/Packet.java
deleted file mode 100644
index 0fad539..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/util/Packet.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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;
-
-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 com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry;
-import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
-import org.bukkit.entity.Player;
-
-import java.lang.reflect.InvocationTargetException;
-
-public class Packet {
-
- private static final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
-
- public static void setGlow(Player player, Player target, boolean glowing) {
- PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
- packet.getIntegers().write(0, target.getEntityId());
- WrappedDataWatcher watcher = new WrappedDataWatcher();
- Serializer serializer = Registry.get(Byte.class);
- watcher.setEntity(target);
- if (glowing) {
- watcher.setObject(0, serializer, (byte) (0x40));
- } else {
- watcher.setObject(0, serializer, (byte) (0x0));
- }
- packet.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
- try {
- protocolManager.sendServerPacket(player, packet);
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/util/Version.java b/src/main/java/net/tylermurphy/hideAndSeek/game/util/Version.java
deleted file mode 100644
index e2dcfdd..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/util/Version.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package net.tylermurphy.hideAndSeek.game.util;
-
-import org.bukkit.Bukkit;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class Version {
-
- private static final Map<String,Boolean> CACHE = new HashMap<>();
-
- public static boolean atLeast(String testVersion) {
-
-
- if (CACHE.containsKey(testVersion)) return CACHE.get(testVersion);
-
- String[] serverCheckTemp = Bukkit.getBukkitVersion().substring(2,Bukkit.getBukkitVersion().indexOf('-')).split("\\.");
- int[] serverCheck = new int[serverCheckTemp.length];
- for(int i=0; i<serverCheck.length; i++) {
- serverCheck[i] = Integer.parseInt(serverCheckTemp[i]);
- }
-
- String[] customCheckTemp = testVersion.substring(2).split("\\.");
- int[] customCheck = new int[customCheckTemp.length];
- for(int i=0; i<customCheck.length; i++) {
- customCheck[i] = Integer.parseInt(customCheckTemp[i]);
- }
-
- boolean result = getResult(customCheck, serverCheck);
- CACHE.put(testVersion, result);
- return result;
- }
-
- private static boolean getResult(int[] customCheck, int[] serverCheck) {
- if (customCheck[0] > serverCheck[0]) return false;
- else if (customCheck[0] < serverCheck[0]) return true;
- else {
- if (customCheck.length == 1 && serverCheck.length == 1) return true;
- else if (customCheck.length == 2 && serverCheck.length == 2) {
- return customCheck[1] <= serverCheck[1];
- }
- else return serverCheck.length == 2;
- }
- }
-}