beta 6
This commit is contained in:
parent
f1379a9475
commit
9d3cf79879
7 changed files with 105 additions and 4 deletions
|
@ -52,6 +52,8 @@ public class Store {
|
|||
public static boolean
|
||||
nametagsVisible,
|
||||
permissionsRequired,
|
||||
manualJoin,
|
||||
lobbyStarted = false,
|
||||
unbreakableArmorstands,
|
||||
unbreakablePaintings,
|
||||
unbreakableItemframes,
|
||||
|
@ -102,6 +104,7 @@ public class Store {
|
|||
getConfig().addDefault("prefix.warning", "&cWarning > &f");
|
||||
getConfig().addDefault("nametagsVisible", false);
|
||||
getConfig().addDefault("permissionsRequired", true);
|
||||
getConfig().addDefault("manualJoin", true);
|
||||
getConfig().addDefault("blockSettings.unbreakable.painting", false);
|
||||
getConfig().addDefault("blockSettings.unbreakable.armorstand", false);
|
||||
getConfig().addDefault("blockSettings.unbreakable.itemframe", false);
|
||||
|
@ -147,6 +150,7 @@ public class Store {
|
|||
//Other
|
||||
nametagsVisible = getConfig().getBoolean("nametagsVisible");
|
||||
permissionsRequired = getConfig().getBoolean("permissionsRequired");
|
||||
manualJoin = getConfig().getBoolean("manualJoin");
|
||||
unbreakablePaintings = getConfig().getBoolean("blockSettings.unbreakable.painting");
|
||||
unbreakableArmorstands = getConfig().getBoolean("blockSettings.unbreakable.armorstand");
|
||||
unbreakableItemframes = getConfig().getBoolean("blockSettings.unbreakable.itemframe");
|
||||
|
|
|
@ -40,6 +40,7 @@ public class EventListener implements Listener {
|
|||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if(status.equals("Playing") || status.equals("Starting")) {
|
||||
if(manualJoin && !Functions.playerInProtectedWorld(event.getPlayer())) return;
|
||||
Spectator.add(event.getPlayer().getName());
|
||||
SpectatorTeam.addEntry(event.getPlayer().getName());
|
||||
event.getPlayer().sendMessage(messagePrefix + "You have joined mid game, and thus have been placed on the spectator team.");
|
||||
|
@ -50,6 +51,12 @@ public class EventListener implements Listener {
|
|||
}
|
||||
event.getPlayer().teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
||||
} else if(status.equals("Setup") || status.equals("Standby")) {
|
||||
if (manualJoin) {
|
||||
if(event.getPlayer().getWorld().getName().equals("hideandseek_"+spawnWorld)){
|
||||
event.getPlayer().teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
Hider.add(event.getPlayer().getName());
|
||||
HiderTeam.addEntry(event.getPlayer().getName());
|
||||
event.getPlayer().setGameMode(GameMode.ADVENTURE);
|
||||
|
@ -85,6 +92,7 @@ public class EventListener implements Listener {
|
|||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if(event.getEntity() instanceof Player) {
|
||||
if(!Functions.playerInProtectedWorld((Player) event.getEntity())) return;
|
||||
if(!status.equals("Playing")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -119,6 +127,7 @@ public class EventListener implements Listener {
|
|||
if(event.getEntity() instanceof ArmorStand) {
|
||||
if(unbreakableArmorstands) {
|
||||
if(event.getDamager() instanceof Player) {
|
||||
if(!Functions.playerInProtectedWorld((Player) event.getDamager())) return;
|
||||
Player player = (Player) event.getDamager();
|
||||
if(status.equals("Playing") || status.equals("Starting") || !player.hasPermission("hideandseek.blockbypass")) {
|
||||
System.out.println('t');
|
||||
|
@ -133,6 +142,7 @@ public class EventListener implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
if(!Functions.playerInProtectedWorld((Player) event.getPlayer())) return;
|
||||
if(!interactableArmorstands) {
|
||||
if(event.getRightClicked() instanceof ArmorStand) {
|
||||
if(status.equals("Playing") || status.equals("Starting") || !event.getPlayer().hasPermission("hideandseek.blockbypass")) {
|
||||
|
@ -141,6 +151,7 @@ public class EventListener implements Listener {
|
|||
}
|
||||
}
|
||||
if(!interactableItemframes) {
|
||||
if(!Functions.playerInProtectedWorld((Player) event.getPlayer())) return;
|
||||
if(event.getRightClicked() instanceof ItemFrame) {
|
||||
if(status.equals("Playing") || status.equals("Starting") || !event.getPlayer().hasPermission("hideandseek.blockbypass")) {
|
||||
event.setCancelled(true);
|
||||
|
@ -151,6 +162,7 @@ public class EventListener implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void onPlayerInteractBlock(PlayerInteractEvent event) {
|
||||
if(!Functions.playerInProtectedWorld((Player) event.getPlayer())) return;
|
||||
if(!interactableDoors) {
|
||||
if(
|
||||
event.getClickedBlock().getType() == Material.ACACIA_DOOR ||
|
||||
|
@ -208,6 +220,7 @@ public class EventListener implements Listener {
|
|||
if(event.getEntity() instanceof ItemFrame) {
|
||||
if(unbreakableItemframes) {
|
||||
if(event.getRemover() instanceof Player) {
|
||||
if(!Functions.playerInProtectedWorld((Player) event.getRemover())) return;
|
||||
Player player = (Player) event.getRemover();
|
||||
if(status.equals("Playing") || status.equals("Starting") || !player.hasPermission("hideandseek.blockbypass")) {
|
||||
event.setCancelled(true);
|
||||
|
@ -221,6 +234,7 @@ public class EventListener implements Listener {
|
|||
if(event.getEntity() instanceof Painting) {
|
||||
if(unbreakableArmorstands) {
|
||||
if(event.getRemover() instanceof Player) {
|
||||
if(!Functions.playerInProtectedWorld((Player) event.getRemover())) return;
|
||||
Player player = (Player) event.getRemover();
|
||||
if(status.equals("Playing") || status.equals("Starting") || !player.hasPermission("hideandseek.blockbypass")) {
|
||||
event.setCancelled(true);
|
||||
|
@ -238,6 +252,7 @@ public class EventListener implements Listener {
|
|||
if(event.getEntity() instanceof Snowball) {
|
||||
Snowball snowball = (Snowball) event.getEntity();
|
||||
if(snowball.getShooter() instanceof Player) {
|
||||
if(!Functions.playerInProtectedWorld((Player) snowball.getShooter())) return;
|
||||
Player player = (Player) snowball.getShooter();
|
||||
if(Hider.contains(player.getName())) {
|
||||
Main.glow.onProjectilve();
|
||||
|
@ -250,18 +265,28 @@ public class EventListener implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if(event.getEntity() instanceof Player) {
|
||||
if(playerList.containsKey(event.getEntity().getName())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRegainHealth(EntityRegainHealthEvent event) {
|
||||
if(event.getRegainReason() == RegainReason.SATIATED || event.getRegainReason() == RegainReason.REGEN)
|
||||
if(event.getRegainReason() == RegainReason.SATIATED || event.getRegainReason() == RegainReason.REGEN) {
|
||||
if(event.getEntity() instanceof Player) {
|
||||
if(playerList.containsKey(event.getEntity().getName())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerCommandPreProccess(PlayerCommandPreprocessEvent event) {
|
||||
if(status.equals("Setup") || status.equals("Standby")) return;
|
||||
if(!playerList.containsKey(event.getPlayer().getName())) return;
|
||||
String handle = event.getMessage().split(" ")[0].substring(1);
|
||||
for(String blocked : blockedCommands) {
|
||||
if(handle.equalsIgnoreCase(blocked) || handle.equalsIgnoreCase("minecraft:"+blocked)) {
|
||||
|
|
51
src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
Normal file
51
src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
package net.tylermurphy.hideAndSeek.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
||||
|
||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
||||
|
||||
public class Join implements ICommand {
|
||||
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!manualJoin) {
|
||||
sender.sendMessage(errorPrefix + "Manual join isnt enabled in this server");
|
||||
return;
|
||||
}
|
||||
if(!status.equals("Standby")) {
|
||||
sender.sendMessage(errorPrefix + "Game is currently in session");
|
||||
return;
|
||||
}
|
||||
if(!lobbyStarted) {
|
||||
sender.sendMessage(errorPrefix + "There is currently no lobby in session");
|
||||
return;
|
||||
}
|
||||
Player player = Bukkit.getServer().getPlayer(sender.getName());
|
||||
if(player == null) {
|
||||
sender.sendMessage(errorPrefix + "An internal error has occured");
|
||||
return;
|
||||
}
|
||||
playerList.put(player.getName(), player);
|
||||
Hider.add(player.getName());
|
||||
HiderTeam.addEntry(player.getName());
|
||||
player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
||||
Bukkit.broadcastMessage(messagePrefix + sender.getName() + " has joined the game lobby");
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getUsage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package net.tylermurphy.hideAndSeek.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.tylermurphy.hideAndSeek.Store;
|
||||
import net.tylermurphy.hideAndSeek.util.Functions;
|
||||
|
@ -8,14 +10,25 @@ import net.tylermurphy.hideAndSeek.util.ICommand;
|
|||
|
||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Reload implements ICommand {
|
||||
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!status.equals("Standby")) {
|
||||
sender.sendMessage(errorPrefix + "Game is currently in session");
|
||||
return;
|
||||
}
|
||||
Store.loadConfig();
|
||||
try {
|
||||
Functions.loadScoreboard();
|
||||
} catch(Exception e) {}
|
||||
sender.sendMessage(messagePrefix + "Reloaded the config");
|
||||
playerList = new HashMap<String,Player>();
|
||||
if(!manualJoin) {
|
||||
for(Player p : Bukkit.getOnlinePlayers())
|
||||
playerList.put(p.getName(), p);
|
||||
}
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
|
|
|
@ -21,6 +21,10 @@ import net.tylermurphy.hideAndSeek.util.ICommand;
|
|||
public class SaveMap implements ICommand {
|
||||
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!status.equals("Standby")) {
|
||||
sender.sendMessage(errorPrefix + "Game is currently in session");
|
||||
return;
|
||||
}
|
||||
if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) {
|
||||
sender.sendMessage(errorPrefix + "Please set spawn location first");
|
||||
return;
|
||||
|
|
|
@ -69,7 +69,7 @@ public class Start implements ICommand {
|
|||
}
|
||||
Seeker.add(seeker.getName());
|
||||
SeekerTeam.addEntry(seeker.getName());
|
||||
|
||||
currentWorldborderSize = worldborderSize;
|
||||
for(Player player : playerList.values()) {
|
||||
player.getInventory().clear();
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
|
|
|
@ -157,4 +157,8 @@ public class Functions {
|
|||
board = mainBoard;
|
||||
}
|
||||
|
||||
public static boolean playerInProtectedWorld(Player p) {
|
||||
return p.getWorld().getName().equals("hideandseek_"+spawnWorld) || p.getWorld().getName().equals(spawnWorld);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue