Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix yaw + pitch #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 44 additions & 8 deletions src/main/java/org/mcsg/survivalgames/SettingsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -387,4 +396,31 @@ public void loadFile(String file){
}

}
public boolean modifyList(String type, Location loc, int pos) {
FileConfiguration cfg = SettingsManager.getInstance().getSystemConfig();
List<String> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down