From 9e8d382b2cb43b4c4935288de37d29c5a511a769 Mon Sep 17 00:00:00 2001 From: AlexM850 Date: Tue, 26 Nov 2013 22:59:02 -0600 Subject: [PATCH] Fix yaw + pitch --- .../mcsg/survivalgames/SettingsManager.java | 52 ++++++++++++++++--- .../mcsg/survivalgames/commands/SetSpawn.java | 2 +- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/mcsg/survivalgames/SettingsManager.java b/src/main/java/org/mcsg/survivalgames/SettingsManager.java index 4d5bebe..df76bb2 100644 --- a/src/main/java/org/mcsg/survivalgames/SettingsManager.java +++ b/src/main/java/org/mcsg/survivalgames/SettingsManager.java @@ -314,11 +314,14 @@ public void saveGameFlags(HashMap < String, Object > flags, int a) { } public Location getLobbySpawn() { - try{ - return new Location(Bukkit.getWorld(system.getString("sg-system.lobby.spawn.world")), - system.getInt("sg-system.lobby.spawn.x"), - system.getInt("sg-system.lobby.spawn.y"), - system.getInt("sg-system.lobby.spawn.z")); + try { + return new Location(Bukkit.getWorld( + system.getString("sg-system.lobby.spawn.world")), + system.getInt("sg-system.lobby.spawn.x"), + system.getInt("sg-system.lobby.spawn.y"), + system.getInt("sg-system.lobby.spawn.z"), + system.getInt("sg-system.lobby.spawn.yaw"), + system.getInt("sg-system.lobby.spawn.pitch")); }catch(Exception e){ return null; } @@ -328,21 +331,27 @@ public Location getSpawnPoint(int gameid, int spawnid) { return new Location(getGameWorld(gameid), spawns.getInt("spawns." + gameid + "." + spawnid + ".x"), spawns.getInt("spawns." + gameid + "." + spawnid + ".y"), - spawns.getInt("spawns." + gameid + "." + spawnid + ".z")); + spawns.getInt("spawns." + gameid + "." + spawnid + ".z"), + spawns.getInt("spawns." + gameid + "." + spawnid + ".yaw"), + spawns.getInt("spawns." + gameid + "." + spawnid + ".pitch")); } - + public void setLobbySpawn(Location l) { system.set("sg-system.lobby.spawn.world", l.getWorld().getName()); system.set("sg-system.lobby.spawn.x", l.getBlockX()); system.set("sg-system.lobby.spawn.y", l.getBlockY()); system.set("sg-system.lobby.spawn.z", l.getBlockZ()); + system.set("sg-system.lobby.spawn.yaw", l.getYaw()); + system.set("sg-system.lobby.spawn.pitch", l.getPitch()); } - public void setSpawn(int gameid, int spawnid, Vector v) { + public void setSpawn(int gameid, int spawnid, Vector v, float yaw, float pitch) { spawns.set("spawns." + gameid + "." + spawnid + ".x", v.getBlockX()); spawns.set("spawns." + gameid + "." + spawnid + ".y", v.getBlockY()); spawns.set("spawns." + gameid + "." + spawnid + ".z", v.getBlockZ()); + spawns.set("spawns." + gameid + "." + spawnid + ".yaw", yaw); + spawns.set("spawns." + gameid + "." + spawnid + ".pitch", pitch); if (spawnid > spawns.getInt("spawns." + gameid + ".count")) { spawns.set("spawns." + gameid + ".count", spawnid); } @@ -387,4 +396,31 @@ public void loadFile(String file){ } } + public boolean modifyList(String type, Location loc, int pos) { + FileConfiguration cfg = SettingsManager.getInstance().getSystemConfig(); + List objs = cfg.getStringList(type); + String conStr = loc.getWorld().getName() + ";" + + loc.getX() + ";" + + loc.getY() + ";" + + loc.getZ() + ";" + + loc.getYaw() + ";" + + loc.getPitch(); + for (String str : objs) { + if (str.startsWith(conStr)) { + if (pos == 0) { + objs.remove(str); + cfg.set(type, objs); + getInstance().saveConfig(); + return true; + } else { + return false; + } + } + } + if (pos == 0) { return false; } + objs.add(conStr + ";" + pos); + cfg.set(type, objs); + getInstance().saveConfig(); + return true; + } } \ No newline at end of file diff --git a/src/main/java/org/mcsg/survivalgames/commands/SetSpawn.java b/src/main/java/org/mcsg/survivalgames/commands/SetSpawn.java index 91e9a12..cdfe556 100644 --- a/src/main/java/org/mcsg/survivalgames/commands/SetSpawn.java +++ b/src/main/java/org/mcsg/survivalgames/commands/SetSpawn.java @@ -65,7 +65,7 @@ public boolean onCommand(Player player, String[] args) { MessageManager.getInstance().sendMessage(MessageManager.PrefixType.ERROR, "error.notinside", player); return true; } - SettingsManager.getInstance().setSpawn(game, i, l.toVector()); + SettingsManager.getInstance().setSpawn(game, i, l.toVector(), l.getYaw(), l.getPitch()); MessageManager.getInstance().sendFMessage(MessageManager.PrefixType.INFO, "info.spawnset", player, "num-" + i, "arena-" + game); return true; }