fixed snowball, changed config, added blocked commands, bug fixes i guess
This commit is contained in:
parent
e45c39faf0
commit
d331302e3d
15 changed files with 249 additions and 72 deletions
2
pom.xml
2
pom.xml
|
@ -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>
|
<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>net.tylermurphy</groupId>
|
||||||
<artifactId>HideAndSeek</artifactId>
|
<artifactId>HideAndSeek</artifactId>
|
||||||
<version>1.2.0</version>
|
<version>1.3.0</version>
|
||||||
<name>Hide and Seek Plugin</name>
|
<name>Hide and Seek Plugin</name>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
67
src/main/java/Store.java
Normal file
67
src/main/java/Store.java
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
import org.bukkit.scoreboard.Team;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
|
||||||
|
public class Store {
|
||||||
|
|
||||||
|
public static Map<String,Player> playerList = new HashMap<String,Player>();
|
||||||
|
|
||||||
|
public static Scoreboard board;
|
||||||
|
public static Team Hider,Seeker,Spectator;
|
||||||
|
|
||||||
|
public static String status = "Setup";
|
||||||
|
|
||||||
|
public static String messagePrefix = String.format("%sHide and Seek > %s", ChatColor.BLUE, ChatColor.WHITE);
|
||||||
|
public static String errorPrefix = String.format("%sError > %s", ChatColor.RED, ChatColor.WHITE);
|
||||||
|
|
||||||
|
public static Vector spawnPosition;
|
||||||
|
|
||||||
|
public static Vector worldborderPosition;
|
||||||
|
public static int worldborderSize,worldborderDelay,currentWorldborderSize;
|
||||||
|
public static boolean worldborderEnabled = false, decreaseBorder = false;
|
||||||
|
|
||||||
|
public static List<String> blockedCommands;
|
||||||
|
|
||||||
|
public static String tauntPlayer = "";
|
||||||
|
|
||||||
|
public static int glowTime = 0;
|
||||||
|
|
||||||
|
public static int gameId = 0;
|
||||||
|
|
||||||
|
public static FileConfiguration getConfig() {
|
||||||
|
return Main.plugin.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void saveConfig() {
|
||||||
|
Main.plugin.saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadConfig() {
|
||||||
|
ConfigurationSection spawnConfig = getConfig().getConfigurationSection("spawn");
|
||||||
|
if(spawnConfig == null) spawnConfig = getConfig().createSection("spawn");
|
||||||
|
spawnPosition = new Vector(spawnConfig.getDouble("x", 0), spawnConfig.getDouble("y", 0), spawnConfig.getDouble("z", 0));
|
||||||
|
getConfig().createSection("spawn", spawnConfig.getValues(true));
|
||||||
|
ConfigurationSection worldBorderConfig = getConfig().getConfigurationSection("worldBorder");
|
||||||
|
if(worldBorderConfig == null) worldBorderConfig = getConfig().createSection("worldBorder");
|
||||||
|
worldborderPosition = new Vector(worldBorderConfig.getInt("x", 0), 0, worldBorderConfig.getInt("z", 0));
|
||||||
|
worldborderSize = worldBorderConfig.getInt("x", 500);
|
||||||
|
worldborderEnabled = worldBorderConfig.getBoolean("enabled", false);
|
||||||
|
getConfig().createSection("worldBorder", worldBorderConfig.getValues(true));
|
||||||
|
getConfig().addDefault("blockedCommands", new ArrayList<String>());
|
||||||
|
blockedCommands = getConfig().getStringList("blockedCommands");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
package net.tylermurphy.hideAndSeek;
|
package net.tylermurphy.hideAndSeek;
|
||||||
|
|
||||||
|
import static net.tylermurphy.hideAndSeek.Store.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -8,16 +10,9 @@ import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.commands.About;
|
import net.tylermurphy.hideAndSeek.commands.*;
|
||||||
import net.tylermurphy.hideAndSeek.commands.Help;
|
|
||||||
import net.tylermurphy.hideAndSeek.commands.SetBorder;
|
|
||||||
import net.tylermurphy.hideAndSeek.commands.SetSpawnLocation;
|
|
||||||
import net.tylermurphy.hideAndSeek.commands.Start;
|
|
||||||
import net.tylermurphy.hideAndSeek.commands.Stop;
|
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
import net.tylermurphy.hideAndSeek.util.ICommand;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
|
||||||
|
|
||||||
public class CommandHandler {
|
public class CommandHandler {
|
||||||
|
|
||||||
public static Map<String,ICommand> COMMAND_REGISTER = new LinkedHashMap<String,ICommand>();
|
public static Map<String,ICommand> COMMAND_REGISTER = new LinkedHashMap<String,ICommand>();
|
||||||
|
@ -35,6 +30,7 @@ public class CommandHandler {
|
||||||
registerCommand(new Stop());
|
registerCommand(new Stop());
|
||||||
registerCommand(new SetSpawnLocation());
|
registerCommand(new SetSpawnLocation());
|
||||||
registerCommand(new SetBorder());
|
registerCommand(new SetBorder());
|
||||||
|
registerCommand(new Reload());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handleCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public static boolean handleCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.events.EventListener;
|
import net.tylermurphy.hideAndSeek.events.EventListener;
|
||||||
import net.tylermurphy.hideAndSeek.events.EventTick;
|
import net.tylermurphy.hideAndSeek.events.EventTick;
|
||||||
|
@ -31,18 +30,7 @@ public class Main extends JavaPlugin implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init Configuration
|
// Init Configuration
|
||||||
Vector spawnPositionVector = getConfig().getVector("spawnPosition");
|
Store.loadConfig();
|
||||||
if(spawnPositionVector != null) {
|
|
||||||
spawnPosition = spawnPositionVector;
|
|
||||||
status = "Standby";
|
|
||||||
}
|
|
||||||
Vector worldborderPositionVector = getConfig().getVector("borderPosition");
|
|
||||||
if(worldborderPositionVector != null) {
|
|
||||||
worldborderPosition = worldborderPositionVector;
|
|
||||||
worldborderSize = getConfig().getInt("borderSize");
|
|
||||||
worldborderDelay = getConfig().getInt("borderDelay");
|
|
||||||
}
|
|
||||||
worldborderEnabled = getConfig().getBoolean("borderEnabled");
|
|
||||||
|
|
||||||
// Register Commands
|
// Register Commands
|
||||||
CommandHandler.registerCommands();
|
CommandHandler.registerCommands();
|
||||||
|
@ -60,10 +48,6 @@ public class Main extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
|
||||||
saveConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
return CommandHandler.handleCommand(sender, cmd, label, args);
|
return CommandHandler.handleCommand(sender, cmd, label, args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package net.tylermurphy.hideAndSeek;
|
package net.tylermurphy.hideAndSeek;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
@ -19,15 +22,19 @@ public class Store {
|
||||||
|
|
||||||
public static String status = "Setup";
|
public static String status = "Setup";
|
||||||
|
|
||||||
public static String messagePrefix = String.format("%sHide and Seek > %s", ChatColor.BLUE, ChatColor.WHITE);
|
public static String messagePrefix,errorPrefix,tauntPrefix,worldborderPrefix,abortPrefix,gameoverPrefix;
|
||||||
public static String errorPrefix = String.format("%sError > %s", ChatColor.RED, ChatColor.WHITE);
|
|
||||||
|
|
||||||
public static Vector spawnPosition;
|
public static Vector spawnPosition;
|
||||||
|
public static String spawnWorld;
|
||||||
|
|
||||||
public static Vector worldborderPosition;
|
public static Vector worldborderPosition;
|
||||||
public static int worldborderSize,worldborderDelay,currentWorldborderSize;
|
public static int worldborderSize,worldborderDelay,currentWorldborderSize;
|
||||||
public static boolean worldborderEnabled = false, decreaseBorder = false;
|
public static boolean worldborderEnabled = false, decreaseBorder = false;
|
||||||
|
|
||||||
|
public static List<String> blockedCommands;
|
||||||
|
|
||||||
|
public static boolean nametagsVisible;
|
||||||
|
|
||||||
public static String tauntPlayer = "";
|
public static String tauntPlayer = "";
|
||||||
|
|
||||||
public static int glowTime = 0;
|
public static int glowTime = 0;
|
||||||
|
@ -42,4 +49,73 @@ public class Store {
|
||||||
Main.plugin.saveConfig();
|
Main.plugin.saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void loadConfig() {
|
||||||
|
|
||||||
|
Main.plugin.reloadConfig();
|
||||||
|
|
||||||
|
getConfig().addDefault("spawn.x", 0);
|
||||||
|
getConfig().addDefault("spawn.y", 0);
|
||||||
|
getConfig().addDefault("spawn.z", 0);
|
||||||
|
getConfig().addDefault("spawn.world", "world");
|
||||||
|
getConfig().addDefault("worldBorder.x", 0);
|
||||||
|
getConfig().addDefault("worldBorder.z", 0);
|
||||||
|
getConfig().addDefault("worldBorder.delay", 10);
|
||||||
|
getConfig().addDefault("worldBorder.size", 500);
|
||||||
|
getConfig().addDefault("worldBorder.enabled", false);
|
||||||
|
getConfig().addDefault("blockedCommands", Arrays.asList("tp","kill","gamemode","effect","clear"));
|
||||||
|
getConfig().addDefault("prefix.default", "&9Hide and Seek > &f");
|
||||||
|
getConfig().addDefault("prefix.error", "&cError > &f");
|
||||||
|
getConfig().addDefault("prefix.taunt", "&eTaunt > &f");
|
||||||
|
getConfig().addDefault("prefix.border", "&cWorld Border > &f");
|
||||||
|
getConfig().addDefault("prefix.abort", "&cAbort > &f");
|
||||||
|
getConfig().addDefault("prefix.gameover", "&aGame Over > &f");
|
||||||
|
getConfig().addDefault("nametagsVisible", false);
|
||||||
|
|
||||||
|
spawnPosition = new Vector(
|
||||||
|
getConfig().getDouble("spawn.x"),
|
||||||
|
getConfig().getDouble("spawn.y"),
|
||||||
|
getConfig().getDouble("spawn.z")
|
||||||
|
);
|
||||||
|
spawnWorld = getConfig().getString("spawn.world");
|
||||||
|
|
||||||
|
worldborderPosition = new Vector(
|
||||||
|
getConfig().getInt("worldBorder.x"),
|
||||||
|
0,
|
||||||
|
getConfig().getInt("worldBorder.z")
|
||||||
|
);
|
||||||
|
worldborderSize = getConfig().getInt("worldBorder.size");
|
||||||
|
worldborderDelay = getConfig().getInt("worldBorder.delay");
|
||||||
|
worldborderEnabled = getConfig().getBoolean("worldBorder.enabled");
|
||||||
|
|
||||||
|
blockedCommands = getConfig().getStringList("blockedCommands");
|
||||||
|
|
||||||
|
messagePrefix = getConfig().getString("prefix.default").replace("&", "§");
|
||||||
|
errorPrefix = getConfig().getString("prefix.error").replace("&", "§");
|
||||||
|
tauntPrefix = getConfig().getString("prefix.taunt").replace("&", "§");
|
||||||
|
worldborderPrefix = getConfig().getString("prefix.border").replace("&", "§");
|
||||||
|
abortPrefix = getConfig().getString("prefix.abort").replace("&", "§");
|
||||||
|
gameoverPrefix = getConfig().getString("prefix.gameover").replace("&", "§");
|
||||||
|
|
||||||
|
nametagsVisible = getConfig().getBoolean("nametagsVisible");
|
||||||
|
|
||||||
|
getConfig().options().copyDefaults(true);
|
||||||
|
saveConfig();
|
||||||
|
|
||||||
|
if(spawnPosition.getBlockX() != 0 || spawnPosition.getBlockY() != 0 || spawnPosition.getBlockZ() != 0) {
|
||||||
|
status = "Standby";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addToSection(String sectionName, Map<String,Object> values) {
|
||||||
|
ConfigurationSection section = getConfig().getConfigurationSection(sectionName);
|
||||||
|
if(section == null) section = getConfig().createSection(sectionName);
|
||||||
|
Map<String,Object> sectionValues = section.getValues(true);
|
||||||
|
for(Entry<String, Object> entry : values.entrySet()) {
|
||||||
|
sectionValues.put(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
getConfig().createSection(sectionName, sectionValues);
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ public class About implements ICommand {
|
||||||
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
sender.sendMessage(
|
sender.sendMessage(
|
||||||
String.format("%s%sHide and Seek %s(1.2.0%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
|
String.format("%s%sHide and Seek %s(1.3.0%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
|
||||||
String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
|
String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
|
||||||
String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
|
String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package net.tylermurphy.hideAndSeek.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import net.tylermurphy.hideAndSeek.Store;
|
||||||
|
import net.tylermurphy.hideAndSeek.util.ICommand;
|
||||||
|
|
||||||
|
import static net.tylermurphy.hideAndSeek.Store.*;
|
||||||
|
|
||||||
|
public class Reload implements ICommand {
|
||||||
|
|
||||||
|
public void execute(CommandSender sender, String[] args) {
|
||||||
|
Store.loadConfig();
|
||||||
|
sender.sendMessage(messagePrefix + "Reloaded the config");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return "reload";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsage() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return "Reloads the config";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,10 @@
|
||||||
package net.tylermurphy.hideAndSeek.commands;
|
package net.tylermurphy.hideAndSeek.commands;
|
||||||
|
|
||||||
|
import static net.tylermurphy.hideAndSeek.Store.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
@ -7,8 +12,6 @@ import org.bukkit.util.Vector;
|
||||||
import net.tylermurphy.hideAndSeek.util.Functions;
|
import net.tylermurphy.hideAndSeek.util.Functions;
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
import net.tylermurphy.hideAndSeek.util.ICommand;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
|
||||||
|
|
||||||
public class SetBorder implements ICommand {
|
public class SetBorder implements ICommand {
|
||||||
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
|
@ -21,8 +24,10 @@ public class SetBorder implements ICommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(args.length < 2) {
|
if(args.length < 2) {
|
||||||
getConfig().set("borderEnabled", false);
|
|
||||||
worldborderEnabled = false;
|
worldborderEnabled = false;
|
||||||
|
Map<String, Object> temp = new HashMap<String,Object>();
|
||||||
|
temp.put("enabled", false);
|
||||||
|
addToSection("worldBorder",temp);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
sender.sendMessage(messagePrefix + "Disabled worldborder.");
|
sender.sendMessage(messagePrefix + "Disabled worldborder.");
|
||||||
Functions.resetWorldborder();
|
Functions.resetWorldborder();
|
||||||
|
@ -53,12 +58,15 @@ public class SetBorder implements ICommand {
|
||||||
worldborderPosition = newWorldborderPosition;
|
worldborderPosition = newWorldborderPosition;
|
||||||
worldborderSize = num;
|
worldborderSize = num;
|
||||||
worldborderDelay = delay;
|
worldborderDelay = delay;
|
||||||
sender.sendMessage(messagePrefix + "Set border center to current location, size to "+num+", and delay to "+delay);
|
|
||||||
getConfig().set("borderPosition", newWorldborderPosition);
|
|
||||||
getConfig().set("borderSize", num);
|
|
||||||
getConfig().set("borderDelay", delay);
|
|
||||||
getConfig().set("borderEnabled", false);
|
|
||||||
worldborderEnabled = true;
|
worldborderEnabled = true;
|
||||||
|
Map<String, Object> temp = new HashMap<String,Object>();
|
||||||
|
temp.put("x", worldborderPosition.getBlockX());
|
||||||
|
temp.put("z", worldborderPosition.getBlockZ());
|
||||||
|
temp.put("delay", worldborderDelay);
|
||||||
|
temp.put("size", worldborderSize);
|
||||||
|
temp.put("enabled", true);
|
||||||
|
addToSection("worldBorder",temp);
|
||||||
|
sender.sendMessage(messagePrefix + "Set border center to current location, size to "+num+", and delay to "+delay);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
Functions.resetWorldborder();
|
Functions.resetWorldborder();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
package net.tylermurphy.hideAndSeek.commands;
|
package net.tylermurphy.hideAndSeek.commands;
|
||||||
|
|
||||||
|
import static net.tylermurphy.hideAndSeek.Store.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
import net.tylermurphy.hideAndSeek.util.ICommand;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
|
||||||
|
|
||||||
public class SetSpawnLocation implements ICommand {
|
public class SetSpawnLocation implements ICommand {
|
||||||
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
|
@ -23,10 +26,13 @@ public class SetSpawnLocation implements ICommand {
|
||||||
spawnPosition = newSpawnPosition;
|
spawnPosition = newSpawnPosition;
|
||||||
status = "Standby";
|
status = "Standby";
|
||||||
sender.sendMessage(messagePrefix + "Set spawn position to current location");
|
sender.sendMessage(messagePrefix + "Set spawn position to current location");
|
||||||
getConfig().set("spawnPosition", newSpawnPosition);
|
Map<String, Object> temp = new HashMap<String,Object>();
|
||||||
|
temp.put("x", spawnPosition.getX());
|
||||||
|
temp.put("y", spawnPosition.getY());
|
||||||
|
temp.put("z", spawnPosition.getZ());
|
||||||
|
temp.put("world", player.getLocation().getWorld().getName());
|
||||||
|
addToSection("spawn",temp);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
// Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("setworldspawn %s %s %s", player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
|
|
||||||
// Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("spawnpoint @a %s %s %s", player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class Start implements ICommand {
|
||||||
for(Player player : playerList.values()) {
|
for(Player player : playerList.values()) {
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
player.setGameMode(GameMode.ADVENTURE);
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
player.teleport(new Location(player.getWorld(), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
||||||
for(PotionEffect effect : player.getActivePotionEffects()){
|
for(PotionEffect effect : player.getActivePotionEffects()){
|
||||||
player.removePotionEffect(effect.getType());
|
player.removePotionEffect(effect.getType());
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class Stop implements ICommand {
|
||||||
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(status.equals("Starting") || status.equals("Playing")) {
|
if(status.equals("Starting") || status.equals("Playing")) {
|
||||||
Bukkit.broadcastMessage(messagePrefix + "Game has been force stopped.");
|
Bukkit.broadcastMessage(abortPrefix + "Game has been force stopped.");
|
||||||
onStop();
|
onStop();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -38,7 +38,7 @@ public class Stop implements ICommand {
|
||||||
player.setGameMode(GameMode.ADVENTURE);
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
Hider.addEntry(player.getName());
|
Hider.addEntry(player.getName());
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
player.teleport(new Location(player.getWorld(), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
||||||
for(PotionEffect effect : player.getActivePotionEffects()){
|
for(PotionEffect effect : player.getActivePotionEffects()){
|
||||||
player.removePotionEffect(effect.getType());
|
player.removePotionEffect(effect.getType());
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
@ -37,7 +38,7 @@ public class EventListener implements Listener {
|
||||||
for(PotionEffect effect : event.getPlayer().getActivePotionEffects()){
|
for(PotionEffect effect : event.getPlayer().getActivePotionEffects()){
|
||||||
event.getPlayer().removePotionEffect(effect.getType());
|
event.getPlayer().removePotionEffect(effect.getType());
|
||||||
}
|
}
|
||||||
event.getPlayer().teleport(new Location(event.getPlayer().getWorld(), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
event.getPlayer().teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
||||||
} else if(status.equals("Setup") || status.equals("Standby")) {
|
} else if(status.equals("Setup") || status.equals("Standby")) {
|
||||||
Hider.addEntry(event.getPlayer().getName());
|
Hider.addEntry(event.getPlayer().getName());
|
||||||
}
|
}
|
||||||
|
@ -64,10 +65,10 @@ public class EventListener implements Listener {
|
||||||
if(spawnPosition == null) return;
|
if(spawnPosition == null) return;
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||||
player.teleport(new Location(player.getWorld(), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
|
player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
|
||||||
Functions.playSound(player, Sound.ENTITY_PLAYER_DEATH, 1, 1);
|
Functions.playSound(player, Sound.ENTITY_PLAYER_DEATH, 1, 1);
|
||||||
if(Hider.hasEntry(event.getEntity().getName())) {
|
if(Hider.hasEntry(event.getEntity().getName())) {
|
||||||
Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has died and become a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE));
|
Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has died and became a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE));
|
||||||
}
|
}
|
||||||
if(Seeker.hasEntry(event.getEntity().getName())) {
|
if(Seeker.hasEntry(event.getEntity().getName())) {
|
||||||
Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has been beat by a hider", ChatColor.RED, event.getEntity().getName(), ChatColor.WHITE));
|
Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has been beat by a hider", ChatColor.RED, event.getEntity().getName(), ChatColor.WHITE));
|
||||||
|
@ -112,4 +113,17 @@ public class EventListener implements Listener {
|
||||||
if(event.getRegainReason() == RegainReason.SATIATED || event.getRegainReason() == RegainReason.REGEN)
|
if(event.getRegainReason() == RegainReason.SATIATED || event.getRegainReason() == RegainReason.REGEN)
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerCommandPreProccess(PlayerCommandPreprocessEvent event) {
|
||||||
|
if(status.equals("Setup") || status.equals("Standby")) return;
|
||||||
|
String handle = event.getMessage().split(" ")[0].substring(1);
|
||||||
|
for(String blocked : blockedCommands) {
|
||||||
|
if(handle.equalsIgnoreCase(blocked) || handle.equalsIgnoreCase("minecraft:"+blocked)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().sendMessage(errorPrefix + "This command is blocked during gameplay!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package net.tylermurphy.hideAndSeek.events;
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Store.*;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.FireworkEffect;
|
import org.bukkit.FireworkEffect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
@ -41,11 +40,11 @@ public class EventTick {
|
||||||
tick ++;
|
tick ++;
|
||||||
|
|
||||||
if(( status.equals("Starting") || status.equals("Playing") ) && Hider.getSize() < 1) {
|
if(( status.equals("Starting") || status.equals("Playing") ) && Hider.getSize() < 1) {
|
||||||
Bukkit.broadcastMessage(messagePrefix + "Game over! All hiders have been found.");
|
Bukkit.broadcastMessage(gameoverPrefix + "All hiders have been found.");
|
||||||
Stop.onStop();
|
Stop.onStop();
|
||||||
}
|
}
|
||||||
if(( status.equals("Starting") || status.equals("Playing") ) && Seeker.getSize() < 1) {
|
if(( status.equals("Starting") || status.equals("Playing") ) && Seeker.getSize() < 1) {
|
||||||
Bukkit.broadcastMessage(messagePrefix + "Game has ended as all seekers have quit.");
|
Bukkit.broadcastMessage(abortPrefix + "All seekers have quit.");
|
||||||
Stop.onStop();
|
Stop.onStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +53,7 @@ public class EventTick {
|
||||||
for(String playerName : Seeker.getEntries()) {
|
for(String playerName : Seeker.getEntries()) {
|
||||||
Player player = playerList.get(playerName);
|
Player player = playerList.get(playerName);
|
||||||
if(player != null) {
|
if(player != null) {
|
||||||
player.teleport(new Location(player.getWorld(), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +82,7 @@ public class EventTick {
|
||||||
.withTrail()
|
.withTrail()
|
||||||
.build());
|
.build());
|
||||||
fw.setFireworkMeta(fwm);
|
fw.setFireworkMeta(fwm);
|
||||||
Bukkit.getServer().broadcastMessage(ChatColor.YELLOW + "Taunt >" + ChatColor.WHITE + " Taunt has been activated");
|
Bukkit.getServer().broadcastMessage(tauntPrefix + " Taunt has been activated");
|
||||||
}
|
}
|
||||||
tauntPlayer = "";
|
tauntPlayer = "";
|
||||||
}
|
}
|
||||||
|
@ -98,6 +97,9 @@ public class EventTick {
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 1000000, 1, false, false));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 1000000, 1, false, false));
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 10, false, false));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 10, false, false));
|
||||||
}
|
}
|
||||||
|
for(Player temp : playerList.values()) {
|
||||||
|
Functions.setGlow(player, temp, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for(String playerName : Hider.getEntries()) {
|
for(String playerName : Hider.getEntries()) {
|
||||||
Player player = playerList.get(playerName);
|
Player player = playerList.get(playerName);
|
||||||
|
|
|
@ -1,18 +1,6 @@
|
||||||
package net.tylermurphy.hideAndSeek.util;
|
package net.tylermurphy.hideAndSeek.util;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.Hider;
|
import static net.tylermurphy.hideAndSeek.Store.*;
|
||||||
import static net.tylermurphy.hideAndSeek.Store.Seeker;
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.Spectator;
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.board;
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.currentWorldborderSize;
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.decreaseBorder;
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.gameId;
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.playerList;
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.tauntPlayer;
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.worldborderDelay;
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.worldborderEnabled;
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.worldborderPosition;
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.worldborderSize;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -102,6 +90,7 @@ public class Functions {
|
||||||
snowballLore.add("Last 30s, all hiders can see it");
|
snowballLore.add("Last 30s, all hiders can see it");
|
||||||
snowballLore.add("Time stacks on multi use");
|
snowballLore.add("Time stacks on multi use");
|
||||||
snowballMeta.setLore(snowballLore);
|
snowballMeta.setLore(snowballLore);
|
||||||
|
snowball.setItemMeta(snowballMeta);
|
||||||
player.getInventory().addItem(snowball);
|
player.getInventory().addItem(snowball);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,12 +124,18 @@ public class Functions {
|
||||||
try { mainBoard.registerNewTeam("Seeker");} catch(Exception e) {}
|
try { mainBoard.registerNewTeam("Seeker");} catch(Exception e) {}
|
||||||
Seeker = mainBoard.getTeam("Seeker");
|
Seeker = mainBoard.getTeam("Seeker");
|
||||||
Seeker.setColor(ChatColor.RED);
|
Seeker.setColor(ChatColor.RED);
|
||||||
|
if(nametagsVisible)
|
||||||
|
Seeker.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OTHER_TEAMS);
|
||||||
|
else
|
||||||
Seeker.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
|
Seeker.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
|
||||||
Seeker.setAllowFriendlyFire(false);
|
Seeker.setAllowFriendlyFire(false);
|
||||||
|
|
||||||
try { mainBoard.registerNewTeam("Hider");} catch(Exception e) {}
|
try { mainBoard.registerNewTeam("Hider");} catch(Exception e) {}
|
||||||
Hider = mainBoard.getTeam("Hider");
|
Hider = mainBoard.getTeam("Hider");
|
||||||
Hider.setColor(ChatColor.GOLD);
|
Hider.setColor(ChatColor.GOLD);
|
||||||
|
if(nametagsVisible)
|
||||||
|
Hider.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OWN_TEAM);
|
||||||
|
else
|
||||||
Hider.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
|
Hider.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
|
||||||
Hider.setAllowFriendlyFire(false);
|
Hider.setAllowFriendlyFire(false);
|
||||||
|
|
||||||
|
@ -215,7 +210,7 @@ public class Functions {
|
||||||
}
|
}
|
||||||
if(taunted != null) {
|
if(taunted != null) {
|
||||||
taunted.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Oh no! You have been chosed to be taunted.");
|
taunted.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Oh no! You have been chosed to be taunted.");
|
||||||
Bukkit.getServer().broadcastMessage(ChatColor.YELLOW + "Taunt >" + ChatColor.WHITE + " A random hider will be taunted in the next 30s");
|
Bukkit.getServer().broadcastMessage(tauntPrefix + " A random hider will be taunted in the next 30s");
|
||||||
try { Thread.sleep(1000*30); } catch (InterruptedException e) {}
|
try { Thread.sleep(1000*30); } catch (InterruptedException e) {}
|
||||||
if(gameId != temp) break;
|
if(gameId != temp) break;
|
||||||
tauntPlayer = taunted.getName();
|
tauntPlayer = taunted.getName();
|
||||||
|
@ -236,7 +231,7 @@ public class Functions {
|
||||||
try { Thread.sleep(1000*60*worldborderDelay); } catch (InterruptedException e) {}
|
try { Thread.sleep(1000*60*worldborderDelay); } catch (InterruptedException e) {}
|
||||||
if(gameId != temp) break;
|
if(gameId != temp) break;
|
||||||
if(currentWorldborderSize-100 > 100) {
|
if(currentWorldborderSize-100 > 100) {
|
||||||
Bukkit.getServer().broadcastMessage(ChatColor.RED + "World Border> " + ChatColor.WHITE + "Worldborder decreacing by 100 blocks over the next 30s");
|
Bukkit.getServer().broadcastMessage(worldborderPrefix + "Worldborder decreacing by 100 blocks over the next 30s");
|
||||||
currentWorldborderSize -= 100;
|
currentWorldborderSize -= 100;
|
||||||
decreaseBorder = true;
|
decreaseBorder = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: HideAndSeek
|
name: HideAndSeek
|
||||||
main: net.tylermurphy.hideAndSeek.Main
|
main: net.tylermurphy.hideAndSeek.Main
|
||||||
version: 1.2.0
|
version: 1.3.0
|
||||||
author: KenshinEto
|
author: KenshinEto
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
api-version: 1.17
|
api-version: 1.17
|
||||||
|
|
Loading…
Reference in a new issue