Skip to content

Commit

Permalink
Update v1.2.0-SNAPSHOT
Browse files Browse the repository at this point in the history
  • Loading branch information
Klnsyf-Sun committed Jul 9, 2018
1 parent 8515736 commit 072e8df
Show file tree
Hide file tree
Showing 33 changed files with 248 additions and 296 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Project [Battle Royale]
![Battle Royale](https://klnsyf-sun.github.io/img/Battle-Royale.png)
A `Minecraft` server plugin.
Latest Version: [*v1.1.0*](https://github.com/Klnsyf-Sun/Battle-Royale/releases)
Latest Version: [*v1.2.0-SNAPSHOT*](https://github.com/Klnsyf-Sun/Battle-Royale/releases/tag/v1.1.0)
Recommended Version: [*v1.1.0*](https://github.com/Klnsyf-Sun/Battle-Royale/releases/tag/v1.1.0)

> *[New]* **Project [\[Battle Royale Kit\]](https://github.com/Klnsyf-Sun/Battle-Royale-Kit)**: Provides **kits** with special **supplies**, **potion effects**, and **abilities** for **[Battle Royale]**.
145 changes: 70 additions & 75 deletions src/main/java/com/klnsyf/battleroyale/commands/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.klnsyf.battleroyale.events.PlayerRequestBattlefieldBookEvent;
import com.klnsyf.battleroyale.messages.MessageKey;
import com.klnsyf.battleroyale.messages.Messages;
import com.klnsyf.battleroyale.utils.ExistenceChecker;

public class Commands implements CommandExecutor {
private final Server server = BattleRoyale.server;
Expand Down Expand Up @@ -58,7 +59,10 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
if (!sub.command().equalsIgnoreCase(args[0])) {
continue;
}

if (!sender.hasPermission(sub.premission())) {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcYou do not have permission to use this command");
continue;
}
try {
method.invoke(this, sender, args);
} catch (IllegalAccessException e) {
Expand All @@ -78,134 +82,125 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String

@SubCommand(command = "preset", premission = "battleroyale.preset", arg = "[worldName] [ConfigName] [maxPlayer] [autoStart]", des = "Preset a battlefield")
public void preset(CommandSender sender, String[] args) {
if (sender.hasPermission("battleroyale.preset")) {
if (args.length == 1) {
if (sender instanceof Player) {
server.getPluginManager()
.callEvent(new BattlefieldPresetEvent(sender, ((Player) sender).getWorld().getName()));
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcRequired argument: ¡ìbworldName");
}
} else if (args.length == 2) {
if (args.length == 1) {
if (sender instanceof Player) {
server.getPluginManager()
.callEvent(new BattlefieldPresetEvent(((Player) sender).getWorld()));
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcRequired argument: ¡ìbworldName");
}
} else if (args.length == 2) {
if (ExistenceChecker.worldExist(args[1])) {
server.getPluginManager().callEvent(
new BattlefieldPresetEvent(sender, args[1]));
} else if (args.length == 3) {
new BattlefieldPresetEvent(server.getWorld(args[1])));
}
} else if (args.length == 3) {
if (ExistenceChecker.worldExist(args[1]) && ExistenceChecker.configExist(args[2])) {
server.getPluginManager().callEvent(
new BattlefieldPresetEvent(sender, args[1], args[2]));
} else if (args.length == 4) {
if (args[3].matches("\\d+")) {
new BattlefieldPresetEvent(server.getWorld(args[1]), YamlConfiguration.loadConfiguration(
new File(BattleRoyale.dataFolder.getPath() + "\\configuration\\" + args[2] + ".yml"))));
}
} else if (args.length == 4) {
if (args[3].matches("\\d+")) {
if (ExistenceChecker.worldExist(args[1]) && ExistenceChecker.configExist(args[2])) {
server.getPluginManager().callEvent(
new BattlefieldPresetEvent(sender, args[1], args[2], Integer.valueOf(args[3])));
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcInvaild argument: ¡ìb" + args[3] + " ¡ìcis not a number");
new BattlefieldPresetEvent(server.getWorld(args[1]), YamlConfiguration.loadConfiguration(
new File(BattleRoyale.dataFolder.getPath() + "\\configuration\\" + args[2] + ".yml")),
Integer.valueOf(args[3])));
}
} else if (args.length == 5) {
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcInvaild argument: ¡ìb" + args[3] + " ¡ìcis not a number");
}
} else if (args.length == 5) {
if (ExistenceChecker.worldExist(args[1]) && ExistenceChecker.configExist(args[2]) && args[3].matches("\\d+")) {
server.getPluginManager().callEvent(
new BattlefieldPresetEvent(sender, args[1], args[2], Integer.valueOf(args[3]),
new BattlefieldPresetEvent(server.getWorld(args[1]), YamlConfiguration.loadConfiguration(
new File(BattleRoyale.dataFolder.getPath() + "\\configuration\\" + args[2] + ".yml")),
Integer.valueOf(args[3]),
Boolean.valueOf(args[4])));
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcInvaild argument: ¡ìb" + args[5]);
}
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcYou do not have permission to use this command");
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcInvaild argument: ¡ìb" + args[5]);
}
}

@SubCommand(command = "join", premission = "battleroyale.join", arg = "[worldName]", des = "Join into preseted battlefield")
public void join(CommandSender sender, String[] args) {
if (sender.hasPermission("battleroyale.join")) {
if (sender instanceof Player) {
if (args.length == 1) {
server.getPluginManager().callEvent(new PlayerRequestBattlefieldBookEvent((Player) sender));
} else if (args.length == 2) {
if (sender instanceof Player) {
if (args.length == 1) {
server.getPluginManager().callEvent(new PlayerRequestBattlefieldBookEvent((Player) sender));
} else if (args.length == 2) {
if (ExistenceChecker.worldExist(args[1]) && ExistenceChecker.worldPreset(server.getWorld(args[1]))) {
server.getPluginManager()
.callEvent(new PlayerJoinBattlefieldEvent((Player) sender, args[1]));
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcInvaild amount of arguments");
.callEvent(new PlayerJoinBattlefieldEvent((Player) sender, server.getWorld(args[1])));
}
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcOnly Player can use this command");
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcInvaild amount of arguments");
}
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcYou do not have permission to use this command");
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcOnly Player can use this command");
}
}

@SubCommand(command = "quit", premission = "battleroyale.quit")
public void quit(CommandSender sender, String[] args) {
if (sender.hasPermission("battleroyale.quit")) {
if (sender instanceof Player) {
server.getPluginManager().callEvent(new PlayerQuitBattlefieldEvent((Player) sender));
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcOnly Player can use this command");
}
if (sender instanceof Player) {
server.getPluginManager().callEvent(new PlayerQuitBattlefieldEvent((Player) sender));
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcYou do not have permission to use this command");
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcOnly Player can use this command");
}
}

@SubCommand(command = "start", premission = "battleroyale.start", arg = "[worldName]", des = "Game Start!")
public void start(CommandSender sender, String[] args) {
if (sender.hasPermission("battleroyale.start")) {
if (args.length == 2) {
if (args.length == 2) {
if (ExistenceChecker.worldExist(args[1]) && ExistenceChecker.worldPreset(server.getWorld(args[1]))) {
server.getPluginManager()
.callEvent(new BattleLoadEvent(sender, args[1]));
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcInvaild amount of arguments");
.callEvent(new BattleLoadEvent(server.getWorld(args[1])));
}
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcYou do not have permission to use this command");
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcInvaild amount of arguments");
}
}

@SubCommand(command = "reset", premission = "battleroyale.reset", arg = "[worldName]", des = "Reset a battlefield")
public void end(CommandSender sender, String[] args) {
if (sender.hasPermission("battleroyale.reset")) {
if (args.length == 2) {
if (args.length == 2) {
if (ExistenceChecker.worldExist(args[1]) && ExistenceChecker.worldPreset(server.getWorld(args[1]))) {
server.getPluginManager()
.callEvent(new BattleEndEvent(sender, server.getWorld(args[1]), null));
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcInvaild amount of arguments");
.callEvent(new BattleEndEvent(server.getWorld(args[1]), null));
}
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcYou do not have permission to use this command");
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcInvaild amount of arguments");
}
}

@SubCommand(command = "admin", premission = "battleroyale.admin", des = "Open Admin Board")
public void admin(CommandSender sender, String[] args) {
if (sender.hasPermission("battleroyale.admin")) {
if (args.length == 1) {
server.getPluginManager()
.callEvent(new PlayerOpenAdminBoardEvent((Player) sender));
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcInvaild amount of arguments");
}
if (args.length == 1) {
server.getPluginManager()
.callEvent(new PlayerOpenAdminBoardEvent((Player) sender));
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcYou do not have permission to use this command");
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcInvaild amount of arguments");
}
}

@SubCommand(command = "check", premission = "battleroyale.check", arg = "[fileName]", des = "Check File Integrity")
public void check(CommandSender sender, String[] args) {
if (sender.hasPermission("battleroyale.check")) {
if (args.length == 2) {
File file = new File(
BattleRoyale.dataFolder.getPath() + "\\configuration\\" + args[1] + ".yml");
if (!file.exists()) {
sender.sendMessage(prefix + Messages
.getMessage(MessageKey.BATTLEFIELD_PRESET_UNDEFINDED_CONFIGURATIONFILE, args[1]));
} else {
new YamlConfiguration();
YamlConfiguration configurationFile = YamlConfiguration.loadConfiguration(file);
int checker = new ConfigurationChecker().configuationChecker(configurationFile, false);
sender.sendMessage(prefix + "¡ìaFile integrity check completed with ¡ìb" + checker + "¡ìa ERROR(s)");
}
if (args.length == 2) {
File file = new File(
BattleRoyale.dataFolder.getPath() + "\\configuration\\" + args[1] + ".yml");
if (!file.exists()) {
sender.sendMessage(prefix + Messages
.getMessage(MessageKey.BATTLEFIELD_PRESET_UNDEFINDED_CONFIGURATIONFILE, args[1]));
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcInvaild amount of arguments");
new YamlConfiguration();
YamlConfiguration configurationFile = YamlConfiguration.loadConfiguration(file);
int checker = new ConfigurationChecker().configuationChecker(configurationFile, false);
sender.sendMessage(prefix + "¡ìaFile integrity check completed with ¡ìb" + checker + "¡ìa ERROR(s)");
}
} else {
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcYou do not have permission to use this command");
sender.sendMessage("[¡ì6Battle Royale¡ìr] ¡ìcInvaild amount of arguments");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.klnsyf.battleroyale.events;

import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
Expand All @@ -10,13 +9,10 @@
public class BattleEndEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private final CommandSender sender;
private final World world;
private final Player winner;

public BattleEndEvent(CommandSender sender, World world, Player winner) {
super(false);
this.sender = sender;
public BattleEndEvent(World world, Player winner) {
this.world = world;
this.winner = winner;
}
Expand All @@ -40,10 +36,6 @@ public static HandlerList getHandlerList() {
return handlers;
}

public CommandSender getSender() {
return sender;
}

public World getWorld() {
return world;
}
Expand Down
19 changes: 6 additions & 13 deletions src/main/java/com/klnsyf/battleroyale/events/BattleLoadEvent.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package com.klnsyf.battleroyale.events;

import org.bukkit.command.CommandSender;
import org.bukkit.World;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

public class BattleLoadEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private final CommandSender sender;
private final String worldName;
private final World world;

public BattleLoadEvent(CommandSender sender, String worldName) {
super(false);
this.sender = sender;
this.worldName = worldName;
public BattleLoadEvent(World world) {
this.world = world;
}

@Override
Expand All @@ -36,12 +33,8 @@ public static HandlerList getHandlerList() {
return handlers;
}

public CommandSender getSender() {
return sender;
}

public String getWorldName() {
return worldName;
public World getWorld() {
return world;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class BattleStartEvent extends Event implements Cancellable {
private final World world;

public BattleStartEvent(World world) {
super(false);
this.world = world;
}

Expand Down
Loading

0 comments on commit 072e8df

Please sign in to comment.