Skip to content

Commit

Permalink
v3.7.56
Browse files Browse the repository at this point in the history
  • Loading branch information
ZombieStriker authored Apr 20, 2018
1 parent 975109d commit bf196e4
Show file tree
Hide file tree
Showing 11 changed files with 822 additions and 919 deletions.
13 changes: 11 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
3.5.53
3.7.56
Added support for nether ports for the main overworld
Fixed problem where some worlds would cancel nether portals
Fixed issue where, one some occasions, the config file would reset itself
Moved all player files to their own YML files so the main file will never get corrupted by a player

3.7.54
Fixed setting

3.7.53
Added ability to disable per-world-inventories

3.5.52
3.7.52
Fixed timings. Should prevent item duplication

3.7.51
Expand Down
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
main: me.zombie_striker.lobbyapi.Main
version: 3.7.53
version: 3.7.56
name: LobbyAPI
commands:
Lobby:
Expand Down
6 changes: 4 additions & 2 deletions src/me/zombie_striker/lobbyapi/LobbyAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ public static LobbyWorld registerWorldFromConfig(World world, Location spawn,
setWorldMaterial(world, worldMaterial);
return lw;
}

/**
* USED ONLY IF LOADING WORLDS FROM LOBBYAPI CONFIG
*
Expand All @@ -379,11 +378,13 @@ public static LobbyWorld registerWorldFromConfig(World world, Location spawn,
@Deprecated
public static LobbyWorld registerWorldFromConfig(World world, Location spawn,
String saveLetter, String worldDescription, Integer woolColor,
int menuSlot, GameMode gamemode) {
int menuSlot, GameMode gamemode,boolean hidden) {
LobbyWorld lw = new LobbyWorld(true, world.getName(), menuSlot, 1,
Short.parseShort(woolColor + ""), spawn, saveLetter, gamemode);
addLobbyWorld(lw);
addWorldDescriptionLine(world, worldDescription);
if(hidden)
hideWorld(world, true);
return lw;
}

Expand Down Expand Up @@ -466,6 +467,7 @@ public static LobbyServer getServer(String name) {
* @param name
* @return
*/
@SuppressWarnings("unlikely-arg-type")
public static boolean removeBungeeServer(String name) {
return ml.getBWorlds().remove(name);

Expand Down
92 changes: 62 additions & 30 deletions src/me/zombie_striker/lobbyapi/LobbyCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
int slot = Integer.parseInt(args[1]);
Material m = Material.SPONGE;
short data = 0;
try{
m= Material.matchMaterial(args[2]);
}catch(Exception e) {
try {
m = Material.matchMaterial(args[2]);
} catch (Exception e) {
String[] vals = args[2].split(":");
m=Material.getMaterial(Integer.parseInt(vals[0]));
if(vals.length>1) {
data = Short.parseShort(vals[1]);
m = Material.getMaterial(Integer.parseInt(vals[0]));
if (vals.length > 1) {
data = Short.parseShort(vals[1]);
}
}
StringBuilder display = new StringBuilder();
Expand All @@ -300,7 +300,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
return true;
}

LobbyDecor decor = new LobbyDecor(slot, slot + "", ChatColor.translateAlternateColorCodes('&',display.toString()));
LobbyDecor decor = new LobbyDecor(slot, slot + "",
ChatColor.translateAlternateColorCodes('&', display.toString()));
decor.setMaterial(m);
decor.setData(data);
this.m.getConfig().set("Decor." + decor.getSaveName() + ".displayname", decor.getDisplayname());
Expand Down Expand Up @@ -331,7 +332,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
d = decor;
break;
}
if(d!=null) {
if (d != null) {
m.decor.remove(d);
return true;
}
Expand Down Expand Up @@ -548,30 +549,44 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
l.setYaw(((Player) sender).getLocation().getYaw());
l.setPitch(((Player) sender).getLocation().getPitch());
}
LobbyAPI.registerWorldFromConfig(wo, l, savename, wo.getName(), color, i, GameMode.SURVIVAL);
LobbyAPI.registerWorldFromConfig(wo, l, savename, wo.getName(), color, i, GameMode.SURVIVAL,
false);
String fi = wo.getName();
if (m.getConfig().contains("Worlds." + fi)) {
sender.sendMessage(prefix
+ " The config already has registered this world, even though LobbyAPI has not. This should not happen, but if it did, report this to Zombie_Striker on the bukkitdev page: https://dev.bukkit.org/projects/lobbyapi");
return false;
}
m.getConfig().set("Worlds." + fi + ".name", wo.getName());
m.getConfig().set("Worlds." + fi + ".displayname", wo.getName());
m.getConfig().set("Worlds." + fi + ".spawnLoc.x", l.getX());
m.getConfig().set("Worlds." + fi + ".spawnLoc.y", l.getY());
m.getConfig().set("Worlds." + fi + ".spawnLoc.z", l.getZ());
m.getConfig().set("Worlds." + fi + ".spawnLoc.yaw", l.getYaw());
m.getConfig().set("Worlds." + fi + ".spawnLoc.pitch", l.getPitch());
m.getConfig().set("Worlds." + fi + ".spawnLoc.w", l.getWorld().getName());
m.getConfig().set("Worlds." + fi + ".weatherstate", WeatherState.NORMAL.name());
m.getConfig().set("Worlds." + fi + ".i", i);
m.getConfig().set("Worlds." + fi + ".save", savename);
m.getConfig().set("Worlds." + fi + ".desc", "");
m.getConfig().set("Worlds." + fi + ".gamemode", GameMode.SURVIVAL.name());
m.getConfig().set("Worlds." + fi + ".color", color);
m.saveConfig();
saveWorld(fi, savename, wo, l, color, i, false);
sender.sendMessage(prefix + "Added world \"" + wo.getName() + "\" with a slot of " + i
+ ": Spawn at " + x + " " + y + " " + z + ".");
if (Bukkit.getWorlds().get(0).equals(wo)) {
// If the wo is the main world
sender.sendMessage(prefix
+ "Since this world is the main world, the nether and end world will be registered and linked to this world if they have not been registered already.");

World nether = Bukkit.getWorld("world_nether");
World end = Bukkit.getWorld("world_the_end");
if (nether == null) {
Bukkit.createWorld(new WorldCreator("world_nether"));
nether = Bukkit.getWorld("world_nether");
}
if (end == null) {
Bukkit.createWorld(new WorldCreator("world_the_end"));
end = Bukkit.getWorld("world_the_end");
}
if (LobbyAPI.getLobbyWorld(nether) == null) {
LobbyAPI.registerWorldFromConfig(nether, nether.getSpawnLocation(), savename,
nether.getName(), color, i, GameMode.SURVIVAL, true);
saveWorld(nether.getName(), savename, nether, nether.getSpawnLocation(), color, 51,
true);
}
if (LobbyAPI.getLobbyWorld(end) == null) {
LobbyAPI.registerWorldFromConfig(end, end.getSpawnLocation(), savename, end.getName(),
color, i, GameMode.SURVIVAL, true);
saveWorld(end.getName(), savename, end, end.getSpawnLocation(), color, 50, true);
}
}
m.loadLocalWorlds();
}
} else {
Expand Down Expand Up @@ -690,8 +705,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
} else {
sender.sendMessage(
prefix + " Usage: /lobbyAPI addJoiningCommand [World] [The command [can include spaces]]");
sender.sendMessage(
prefix + " Use %player% to get the player's name.");
sender.sendMessage(prefix + " Use %player% to get the player's name.");
}
} else if (args[0].equalsIgnoreCase("removeJoiningCommand")) {
if (args.length >= 3) {
Expand Down Expand Up @@ -1094,7 +1108,6 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
m.inventory = m.getServer().createInventory(null, m.inventorySize,
ChatColor.GOLD + "LobbyAPI " + ChatColor.WHITE + "- World selector");


for (LobbyWorld wo : m.worlds) {
if (wo != null) {
if (wo.isHidden())
Expand Down Expand Up @@ -1138,9 +1151,9 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
}
for (LobbyDecor d : m.decor) {
Material mk = d.getMaterial();
if(mk==null ||mk==Material.AIR)
mk=Material.BARRIER;
if (mk == null || mk == Material.AIR)
mk = Material.BARRIER;

ItemStack material = new ItemStack(mk);
material.setAmount(d.getAmount());
material.setDurability(d.getData());
Expand Down Expand Up @@ -1211,4 +1224,23 @@ public void addUsages() {
usages.put("removeDecor", "Removes a decor item.");
}

public void saveWorld(String fi, String savename, World wo, Location l, int color, int i, boolean hidden) {
m.getConfig().set("Worlds." + wo.getName() + ".name", wo.getName());
m.getConfig().set("Worlds." + wo.getName() + ".displayname", wo.getName());
m.getConfig().set("Worlds." + wo.getName() + ".spawnLoc.x", l.getX());
m.getConfig().set("Worlds." + wo.getName() + ".spawnLoc.y", l.getY());
m.getConfig().set("Worlds." + wo.getName() + ".spawnLoc.z", l.getZ());
m.getConfig().set("Worlds." + wo.getName() + ".spawnLoc.yaw", l.getYaw());
m.getConfig().set("Worlds." + wo.getName() + ".spawnLoc.pitch", l.getPitch());
m.getConfig().set("Worlds." + wo.getName() + ".spawnLoc.w", l.getWorld().getName());
m.getConfig().set("Worlds." + wo.getName() + ".weatherstate", WeatherState.NORMAL.name());
m.getConfig().set("Worlds." + wo.getName() + ".i", i);
m.getConfig().set("Worlds." + wo.getName() + ".save", savename);
m.getConfig().set("Worlds." + wo.getName() + ".desc", "");
m.getConfig().set("Worlds." + wo.getName() + ".gamemode", GameMode.SURVIVAL.name());
m.getConfig().set("Worlds." + wo.getName() + ".color", color);
m.getConfig().set("Worlds." + wo.getName() + "." + ConfigKeys.isHidden.s, hidden);
m.saveConfig();
}

}
2 changes: 1 addition & 1 deletion src/me/zombie_striker/lobbyapi/LobbyDecor.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class LobbyDecor {
private int ID;

private int amount=1;
private short color;
//private short color;
private Material material = Material.WOOL;
private short data = 0;

Expand Down
2 changes: 2 additions & 0 deletions src/me/zombie_striker/lobbyapi/LobbyWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ public LobbyWorld(boolean loadedFC, String worldname, int ID, int amount,
this.spawn = spawn;
this.saveName = saveName;
this.gamemode = gm;

this.canUsePortal = ((mainWorld!=null&&Bukkit.getWorlds().get(0).equals(mainWorld))||worldname.equals("world_nether"));
}

public enum WeatherState{
Expand Down
Loading

0 comments on commit bf196e4

Please sign in to comment.