diff options
author | Tyler Murphy <tylermurphy534@gmail.com> | 2021-12-20 18:22:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-20 18:22:23 -0500 |
commit | 2ab0b2bbb604db246dcc46209ef780ba44d7aa69 (patch) | |
tree | d2513dbf0e511d66aaa8361e330ccb8bdf086bea /src/main/java/net/tylermurphy/hideAndSeek/util/Util.java | |
parent | 1.3.0 full release (diff) | |
parent | Add Workflows (diff) | |
download | kenshinshideandseek-2ab0b2bbb604db246dcc46209ef780ba44d7aa69.tar.gz kenshinshideandseek-2ab0b2bbb604db246dcc46209ef780ba44d7aa69.tar.bz2 kenshinshideandseek-2ab0b2bbb604db246dcc46209ef780ba44d7aa69.zip |
Merge pull request #12 from tylermurphy534/1.3.1
1.3.1
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/util/Util.java')
-rw-r--r-- | src/main/java/net/tylermurphy/hideAndSeek/util/Util.java | 70 |
1 files changed, 49 insertions, 21 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java b/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java index 028b217..c24936b 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java @@ -2,13 +2,27 @@ package net.tylermurphy.hideAndSeek.util; import static net.tylermurphy.hideAndSeek.configuration.Config.*; -import java.io.File; +import java.io.*; +import java.util.ArrayList; +import java.util.List; +import net.md_5.bungee.api.ChatColor; +import net.tylermurphy.hideAndSeek.configuration.Items; +import net.tylermurphy.hideAndSeek.configuration.LocalizationString; import org.bukkit.Bukkit; -import org.bukkit.WorldCreator; +import org.bukkit.Material; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import net.tylermurphy.hideAndSeek.Main; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionData; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.potion.PotionType; public class Util { @@ -24,27 +38,10 @@ public class Util { if(exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) return false; File destenation = new File(Main.root+File.separator+"hideandseek_"+spawnWorld); if(!destenation.exists()) return false; + if(saveMinX == 0 || saveMinZ == 0 || saveMaxX == 0 || saveMaxZ == 0) return false; return true; } - public static void unloadMap(String mapname){ - if(Bukkit.getServer().unloadWorld(Bukkit.getServer().getWorld(mapname), false)){ - Main.plugin.getLogger().info("Successfully unloaded " + mapname); - }else{ - Main.plugin.getLogger().severe("COULD NOT UNLOAD " + mapname); - } - } - - public static void loadMap(String mapname){ - Bukkit.getServer().createWorld(new WorldCreator(mapname)); - Bukkit.getServer().getWorld("hideandseek_"+spawnWorld).setAutoSave(false); - } - - public static void rollback(String mapname){ - unloadMap(mapname); - loadMap(mapname); - } - public static void sendDelayedMessage(String message, int gameId, int delay) { Bukkit.getScheduler().runTaskLaterAsynchronously(Main.plugin, new Runnable() { public void run() { @@ -53,5 +50,36 @@ public class Util { } }, delay); } - + + public static void resetPlayer(Player player) { + player.getInventory().clear(); + for (PotionEffect effect : player.getActivePotionEffects()) { + player.removePotionEffect(effect.getType()); + } + if (Main.plugin.board.isSeeker(player)) { + if(pvpEnabled) + for(ItemStack item : Items.SEEKER_ITEMS) + player.getInventory().addItem(item); + for(PotionEffect effect : Items.SEEKER_EFFECTS) + player.addPotionEffect(effect); + } else if (Main.plugin.board.isHider(player)) { + if(pvpEnabled) + for(ItemStack item : Items.HIDER_ITEMS) + player.getInventory().addItem(item); + for(PotionEffect effect : Items.HIDER_EFFECTS) + player.addPotionEffect(effect); + if(glowEnabled) { + ItemStack snowball = new ItemStack(Material.SNOWBALL, 1); + ItemMeta snowballMeta = snowball.getItemMeta(); + snowballMeta.setDisplayName("Glow Powerup"); + List<String> snowballLore = new ArrayList<String>(); + snowballLore.add("Throw to make all seekers glow"); + snowballLore.add("Last 30s, all hiders can see it"); + snowballLore.add("Time stacks on multi use"); + snowballMeta.setLore(snowballLore); + snowball.setItemMeta(snowballMeta); + player.getInventory().addItem(snowball); + } + } + } }
\ No newline at end of file |