Skip to content

Commit

Permalink
Version 1.0.4 (Stable version)
Browse files Browse the repository at this point in the history
  • Loading branch information
Misat11 committed Jan 12, 2017
1 parent 8973c42 commit 9d0494c
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 124 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>misat11.za</groupId>
<artifactId>ZombieApocalypse</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>

<repositories>
<repository>
Expand Down
239 changes: 130 additions & 109 deletions src/main/java/misat11/za/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Main extends JavaPlugin {

public void onEnable() {
instance = this;
version = "1.0.0";
version = "1.0.4";

createFiles();

Expand All @@ -57,6 +57,10 @@ public void onEnable() {
if (this.getConfig().isSet("help_gift") == false) {
this.getConfig().set("help_gift", "Get daily gift to you");
}
if (this.getConfig().isSet("help_phaseinfo") == false) {
this.getConfig().set("help_phaseinfo",
"Display actual phase, countdown to end of phase and day after phase");
}
if (this.getConfig().isSet("help_setpos1") == false) {
this.getConfig().set("help_setpos1", "Admin Command: set arena pos 1");
}
Expand Down Expand Up @@ -129,6 +133,17 @@ public void onEnable() {
if (this.getConfig().isSet("message_prefix") == false) {
this.getConfig().set("message_prefix", "[ZA]");
}
if (this.getConfig().isSet("message_phase_night") == false) {
this.getConfig().set("message_phase_night",
"It's night of phase %phase%. Remaining until the end: %countdown%");
}
if (this.getConfig().isSet("message_phase_day") == false) {
this.getConfig().set("message_phase_day",
"It's day after phase %phase%. Remaining until the end: %countdown%");
}
if (this.getConfig().isSet("message_have_points") == false) {
this.getConfig().set("message_have_points", "You have %points% points.");
}
if (this.getConfig().isSet("message_gift_got") == false) {
this.getConfig().set("message_gift_got", "You got your Daily gift: %gift%");
}
Expand Down Expand Up @@ -211,29 +226,92 @@ public void onEnable() {
public void run() {
if (getConfig().getBoolean("enabled") == true) {
World zaworld = Bukkit.getWorld(getConfig().getString("world"));
if (getSaveConfig().isSet("SERVER.ARENA") == false) {
getSaveConfig().set("SERVER.ARENA.phase", 0);
getSaveConfig().set("SERVER.ARENA.time", "day");
getSaveConfig().set("SERVER.ARENA.countdown", 60);
try {
getSaveConfig().save(savef);
} catch (IOException e) {
e.printStackTrace();
if (zaworld.getPlayers().size() > 0) {
if (getSaveConfig().isSet("SERVER.ARENA") == false) {
getSaveConfig().set("SERVER.ARENA.phase", 0);
getSaveConfig().set("SERVER.ARENA.time", "day");
getSaveConfig().set("SERVER.ARENA.countdown", 60);
try {
getSaveConfig().save(savef);
} catch (IOException e) {
e.printStackTrace();
}
}
}
if (getSaveConfig().getString("SERVER.ARENA.time") == "day") {
getSaveConfig().set("SERVER.ARENA.countdown",
getSaveConfig().getInt("SERVER.ARENA.countdown") - 1);
zaworld.setTime(0);
if (getSaveConfig().getInt("SERVER.ARENA.countdown") == 0) {
if (getConfig().getBoolean("spawn_giant") == true) {
if (getSaveConfig().getInt("SERVER.ARENA.phase") != 5) {
getSaveConfig().set("SERVER.ARENA.phase",
getSaveConfig().getInt("SERVER.ARENA.phase") + 1);
if (getSaveConfig().getString("SERVER.ARENA.time") == "day") {
getSaveConfig().set("SERVER.ARENA.countdown",
getSaveConfig().getInt("SERVER.ARENA.countdown") - 1);
zaworld.setTime(0);
if (getSaveConfig().getInt("SERVER.ARENA.countdown") < 1) {
if (getConfig().getBoolean("spawn_giant") == true) {
if (getSaveConfig().getInt("SERVER.ARENA.phase") != 5) {
getSaveConfig().set("SERVER.ARENA.phase",
getSaveConfig().getInt("SERVER.ARENA.phase") + 1);
}
if (getSaveConfig().getInt("SERVER.ARENA.phase") == 5) {
Bukkit.broadcastMessage(getConfig().getString("message_prefix") + " "
+ getConfig().getString("message_giant_spawned"));
int x = Main.instance.getConfig().getInt("giant_x");
int y = Main.instance.getConfig().getInt("giant_y");
int z = Main.instance.getConfig().getInt("giant_z");
int yaw = Main.instance.getConfig().getInt("giant_yaw");
int pitch = Main.instance.getConfig().getInt("giant_pitch");
Location location = new Location(zaworld, x, y, z, yaw, pitch);
Bukkit.getWorld(getConfig().getString("world")).spawnEntity(location,
EntityType.GIANT);
getSaveConfig().set("SERVER.ARENA.time", "night");
getSaveConfig().set("SERVER.ARENA.countdown", 1800);
} else {
getSaveConfig().set("SERVER.ARENA.time", "night");
getSaveConfig().set("SERVER.ARENA.countdown", 300);
}
} else {
getSaveConfig().set("SERVER.ARENA.time", "night");
getSaveConfig().set("SERVER.ARENA.countdown", 300);
}
int x = Main.instance.getConfig().getInt("spawn_x");
int y = Main.instance.getConfig().getInt("spawn_y");
int z = Main.instance.getConfig().getInt("spawn_z");
int yaw = Main.instance.getConfig().getInt("spawn_yaw");
int pitch = Main.instance.getConfig().getInt("spawn_pitch");
Location location = new Location(zaworld, x, y, z, yaw, pitch);
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.getWorld().equals(zaworld)) {
p.teleport(location);
}
}
Bukkit.broadcastMessage(getConfig().getString("message_prefix") + " "
+ getConfig().getString("message_phase_start").replace("%number%",
Integer.toString(getSaveConfig().getInt("SERVER.ARENA.phase"))));
}
} else {
getSaveConfig().set("SERVER.ARENA.countdown",
getSaveConfig().getInt("SERVER.ARENA.countdown") - 1);
zaworld.setTime(20000);
if (getSaveConfig().getInt("SERVER.ARENA.countdown")
% getConfig().getInt("zombies_spawn_countdown") < 1) {
int zombie_x = (int) (Math.random() * (Math
.abs(getConfig().getInt("arena_pos1_x") - getConfig().getInt("arena_pos2_x"))))
+ Math.min(getConfig().getInt("arena_pos1_x"),
getConfig().getInt("arena_pos2_x"));
int zombie_z = (int) (Math.random() * (Math
.abs(getConfig().getInt("arena_pos1_z") - getConfig().getInt("arena_pos2_z"))))
+ Math.min(getConfig().getInt("arena_pos1_z"),
getConfig().getInt("arena_pos2_z"));
int zombie_y = (int) zaworld.getHighestBlockYAt(zombie_x, zombie_z);
Location zombie_location = new Location(zaworld, zombie_x, zombie_y, zombie_z);
Bukkit.getWorld(getConfig().getString("world")).spawnEntity(zombie_location,
EntityType.ZOMBIE);
}
if (getSaveConfig().getInt("SERVER.ARENA.phase") > 4
&& getConfig().getBoolean("spawn_giant") == true) {
int total = 0;
for (LivingEntity f : zaworld.getLivingEntities()) {
if (f instanceof Giant) {
total++;
continue;
}
}
if (getSaveConfig().getInt("SERVER.ARENA.phase") == 5) {
Bukkit.broadcastMessage(getConfig().getString("message_prefix") + " "
+ getConfig().getString("message_giant_spawned"));
if (total < 1) {
int x = Main.instance.getConfig().getInt("giant_x");
int y = Main.instance.getConfig().getInt("giant_y");
int z = Main.instance.getConfig().getInt("giant_z");
Expand All @@ -242,101 +320,44 @@ public void run() {
Location location = new Location(zaworld, x, y, z, yaw, pitch);
Bukkit.getWorld(getConfig().getString("world")).spawnEntity(location,
EntityType.GIANT);
getSaveConfig().set("SERVER.ARENA.time", "night");
getSaveConfig().set("SERVER.ARENA.countdown", 1800);
} else {
getSaveConfig().set("SERVER.ARENA.time", "night");
getSaveConfig().set("SERVER.ARENA.countdown", 300);
}
} else {
getSaveConfig().set("SERVER.ARENA.time", "night");
getSaveConfig().set("SERVER.ARENA.countdown", 300);
}
int x = Main.instance.getConfig().getInt("spawn_x");
int y = Main.instance.getConfig().getInt("spawn_y");
int z = Main.instance.getConfig().getInt("spawn_z");
int yaw = Main.instance.getConfig().getInt("spawn_yaw");
int pitch = Main.instance.getConfig().getInt("spawn_pitch");
Location location = new Location(zaworld, x, y, z, yaw, pitch);
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.getWorld().equals(zaworld)) {
p.teleport(location);
}
}
Bukkit.broadcastMessage(getConfig().getString("message_prefix") + " "
+ getConfig().getString("message_phase_start").replace("%number%",
Integer.toString(getSaveConfig().getInt("SERVER.ARENA.phase"))));
}
} else {
getSaveConfig().set("SERVER.ARENA.countdown",
getSaveConfig().getInt("SERVER.ARENA.countdown") - 1);
zaworld.setTime(20000);
if (getSaveConfig().getInt("SERVER.ARENA.countdown")
% getConfig().getInt("zombies_spawn_countdown") == 0) {
int zombie_x = (int) (Math.random() * (Math
.abs(getConfig().getInt("arena_pos1_x") - getConfig().getInt("arena_pos2_x"))))
+ Math.min(getConfig().getInt("arena_pos1_x"), getConfig().getInt("arena_pos2_x"));
int zombie_z = (int) (Math.random() * (Math
.abs(getConfig().getInt("arena_pos1_z") - getConfig().getInt("arena_pos2_z"))))
+ Math.min(getConfig().getInt("arena_pos1_z"), getConfig().getInt("arena_pos2_z"));
int zombie_y = (int) zaworld.getHighestBlockYAt(zombie_x, zombie_z);
Location zombie_location = new Location(zaworld, zombie_x, zombie_y, zombie_z);
Bukkit.getWorld(getConfig().getString("world")).spawnEntity(zombie_location,
EntityType.ZOMBIE);
}
if (getSaveConfig().getInt("SERVER.ARENA.phase") > 4
&& getConfig().getBoolean("spawn_giant") == true) {
int total = 0;
for (LivingEntity f : zaworld.getLivingEntities()) {
if (f instanceof Giant) {
total++;
continue;
}
}
if (total < 1) {
int x = Main.instance.getConfig().getInt("giant_x");
int y = Main.instance.getConfig().getInt("giant_y");
int z = Main.instance.getConfig().getInt("giant_z");
int yaw = Main.instance.getConfig().getInt("giant_yaw");
int pitch = Main.instance.getConfig().getInt("giant_pitch");
Location location = new Location(zaworld, x, y, z, yaw, pitch);
Bukkit.getWorld(getConfig().getString("world")).spawnEntity(location, EntityType.GIANT);
}
}
if (getSaveConfig().getInt("SERVER.ARENA.countdown") == 0) {
getSaveConfig().set("SERVER.ARENA.time", "day");
getSaveConfig().set("SERVER.ARENA.countdown", 60);
int x = Main.instance.getConfig().getInt("spawn_x");
int y = Main.instance.getConfig().getInt("spawn_y");
int z = Main.instance.getConfig().getInt("spawn_z");
int yaw = Main.instance.getConfig().getInt("spawn_yaw");
int pitch = Main.instance.getConfig().getInt("spawn_pitch");
Location location = new Location(zaworld, x, y, z, yaw, pitch);
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.getWorld().equals(zaworld)) {
p.teleport(location);
}
}
Bukkit.broadcastMessage(getConfig().getString("message_prefix") + " "
+ getConfig().getString("message_starting").replace("%time%",
"1 " + getConfig().getString("message_minute")));
if (getConfig().getBoolean("spawn_giant") == true && getSaveConfig().getInt("SERVER.ARENA.phase") == 5){
getSaveConfig().set("SERVER.ARENA.phase", 0);
if (getSaveConfig().getInt("SERVER.ARENA.countdown") < 1) {
getSaveConfig().set("SERVER.ARENA.time", "day");
getSaveConfig().set("SERVER.ARENA.countdown", 60);
for (LivingEntity f : zaworld.getLivingEntities()) {
if (f instanceof Giant) {
f.remove();
continue;
int x = Main.instance.getConfig().getInt("spawn_x");
int y = Main.instance.getConfig().getInt("spawn_y");
int z = Main.instance.getConfig().getInt("spawn_z");
int yaw = Main.instance.getConfig().getInt("spawn_yaw");
int pitch = Main.instance.getConfig().getInt("spawn_pitch");
Location location = new Location(zaworld, x, y, z, yaw, pitch);
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.getWorld().equals(zaworld)) {
p.teleport(location);
}
}
Bukkit.broadcastMessage(getConfig().getString("message_prefix") + " "
+ getConfig().getString("message_starting").replace("%time%",
"1 " + getConfig().getString("message_minute")));
if (getConfig().getBoolean("spawn_giant") == true
&& getSaveConfig().getInt("SERVER.ARENA.phase") == 5) {
getSaveConfig().set("SERVER.ARENA.phase", 0);
getSaveConfig().set("SERVER.ARENA.time", "day");
getSaveConfig().set("SERVER.ARENA.countdown", 60);
for (LivingEntity f : zaworld.getLivingEntities()) {
if (f instanceof Giant) {
f.remove();
continue;
}
}
}
}
}
}
try {
getSaveConfig().save(savef);
} catch (IOException e) {
e.printStackTrace();
try {
getSaveConfig().save(savef);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Expand Down
44 changes: 32 additions & 12 deletions src/main/java/misat11/za/commands/ZaCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
if (Main.instance.getConfig().getBoolean("enabled") == true) {
if (player.getWorld() == zaworld) {
String time = new SimpleDateFormat("yyyyMMdd").format(Calendar.getInstance().getTime());
Bukkit.getLogger().info(time);
Bukkit.getLogger()
.info(Main.instance.getSaveConfig().getString(player.getName() + ".play.gift"));
if (Main.instance.getSaveConfig().getString(player.getName() + ".play.gift") == time) {
sender.sendMessage(Main.instance.getConfig().getString("message_gift_already_have"));
} else {
Expand Down Expand Up @@ -100,9 +103,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
e.printStackTrace();
}
}
sender.sendMessage("You have"
+ Integer.toString(Main.instance.getSaveConfig().getInt(player.getName() + ".play.points"))
+ "points.");
sender.sendMessage(Main.instance.getConfig().getString("message_have_points").replace("%points%",
Integer.toString(Main.instance.getSaveConfig().getInt(player.getName() + ".play.points"))));
} else if (args[0].equalsIgnoreCase("list")) {
String players = "";
int playerscount = 0;
Expand Down Expand Up @@ -173,13 +175,32 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
}
}
}
} else if (args[0].equalsIgnoreCase("phaseinfo")) {
if (Main.instance.getConfig().getBoolean("enabled") == true) {
if (Main.instance.getSaveConfig().getString("SERVER.ARENA.time") == "day") {
sender.sendMessage(Main.instance.getConfig().getString("message_phase_day")
.replace("%phase%",
Integer.toString(
Main.instance.getSaveConfig().getInt("SERVER.ARENA.phase")))
.replace("%countdown%", Integer
.toString(Main.instance.getSaveConfig().getInt("SERVER.ARENA.countdown"))));
} else {
sender.sendMessage(Main.instance.getConfig().getString("message_phase_night")
.replace("%phase%",
Integer.toString(
Main.instance.getSaveConfig().getInt("SERVER.ARENA.phase")))
.replace("%countdown%", Integer
.toString(Main.instance.getSaveConfig().getInt("SERVER.ARENA.countdown"))));
}
}
// TODO In version 1.1.0
// } else if (args[0].equalsIgnoreCase("shop")){

// ADMIN COMMANDS
} else if (args[0].equalsIgnoreCase("setspawnloc")) {
if (player.hasPermission("misat11.za.admin")) {
Location playerloc = player.getLocation();
Main.instance.getConfig().set("world", playerloc.getWorld().getName());
Main.instance.getConfig().set("spawn_x", playerloc.getBlockX());
Main.instance.getConfig().set("spawn_y", playerloc.getBlockY());
Main.instance.getConfig().set("spawn_z", playerloc.getBlockZ());
Expand All @@ -190,7 +211,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
} catch (IOException e) {
e.printStackTrace();
}
sender.sendMessage("Spawn of Arena set.");
sender.sendMessage(
"Spawn of Arena set. World of arena set to: " + playerloc.getWorld().getName());
} else {
sender.sendMessage("You have not any permissions!");
}
Expand Down Expand Up @@ -276,6 +298,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String

} else {
sender.sendMessage("ZombieApocalypse V" + Main.version + " by Misat11");
sender.sendMessage("/za phaseinfo - " + Main.instance.getConfig().getString("help_phaseinfo"));
sender.sendMessage("/za spectate - " + Main.instance.getConfig().getString("help_spectate"));
sender.sendMessage("/za gift - " + Main.instance.getConfig().getString("help_gift"));
sender.sendMessage("/za points - " + Main.instance.getConfig().getString("help_points"));
Expand All @@ -286,13 +309,12 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
sender.sendMessage("/za enablegame - " + Main.instance.getConfig().getString("help_enablegame"));
sender.sendMessage(
"/za enablegiantgame - " + Main.instance.getConfig().getString("help_enablegiantgame"));
sender.sendMessage(
"/za setpos1 - " + Main.instance.getConfig().getString("help_setpos1"));
sender.sendMessage(
"/za setpos2 - " + Main.instance.getConfig().getString("help_setpos2"));
sender.sendMessage("/za setpos1 - " + Main.instance.getConfig().getString("help_setpos1"));
sender.sendMessage("/za setpos2 - " + Main.instance.getConfig().getString("help_setpos2"));
}
} else {
sender.sendMessage("ZombieApocalypse V" + Main.version + " by Misat11");
sender.sendMessage("/za phaseinfo - " + Main.instance.getConfig().getString("help_phaseinfo"));
sender.sendMessage("/za spectate - " + Main.instance.getConfig().getString("help_spectate"));
sender.sendMessage("/za gift - " + Main.instance.getConfig().getString("help_gift"));
sender.sendMessage("/za points - " + Main.instance.getConfig().getString("help_points"));
Expand All @@ -303,10 +325,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
sender.sendMessage("/za enablegame - " + Main.instance.getConfig().getString("help_enablegame"));
sender.sendMessage(
"/za enablegiantgame - " + Main.instance.getConfig().getString("help_enablegiantgame"));
sender.sendMessage(
"/za setpos1 - " + Main.instance.getConfig().getString("help_setpos1"));
sender.sendMessage(
"/za setpos2 - " + Main.instance.getConfig().getString("help_setpos2"));
sender.sendMessage("/za setpos1 - " + Main.instance.getConfig().getString("help_setpos1"));
sender.sendMessage("/za setpos2 - " + Main.instance.getConfig().getString("help_setpos2"));
}
} else {
sender.sendMessage("It's only for players!");
Expand Down
Loading

0 comments on commit 9d0494c

Please sign in to comment.