Skip to content

Commit

Permalink
Add override annotations to be neat
Browse files Browse the repository at this point in the history
  • Loading branch information
cjburkey01 committed Apr 16, 2019
1 parent cb07445 commit bc4ddbe
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 30 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/cjburkey/claimchunk/ClaimChunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ public final class ClaimChunk extends JavaPlugin {
private ChunkHandler chunkHandler;
private PlayerHandler playerHandler;

public void onLoad() {
public ClaimChunk() {
instance = this;
}

@Override
public void onEnable() {
Utils.log("Spigot version: %s", getServer().getBukkitVersion());

Expand Down Expand Up @@ -128,6 +129,7 @@ private void handleAutoUnclaim() {
}
}

@Override
public void onDisable() {
try {
chunkHandler.writeToDisk();
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/cjburkey/claimchunk/Econ.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public double getMoney(UUID player) {
* @param cost The cost of the purchase.
* @return Whether or not the transaction was successful.
*/
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean buy(UUID ply, double cost) {
if (getMoney(ply) >= cost) {
takeMoney(ply, cost);
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/com/cjburkey/claimchunk/chunk/Access.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@
@Deprecated
public class Access implements Serializable {

@Deprecated
private static final long serialVersionUID = -4542563965031986866L;

@Deprecated
private final UUID owner;
@Deprecated
private final UUID allowed;

@Deprecated
Expand All @@ -41,12 +38,12 @@ public UUID getAcessee() {
return allowed;
}

@Deprecated
@Override
public String toString() {
return owner.toString() + ';' + allowed.toString();
}

@Deprecated
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
Expand All @@ -55,7 +52,7 @@ public int hashCode() {
return result;
}

@Deprecated
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/cjburkey/claimchunk/chunk/ChunkPos.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ public void outlineChunk(Player showTo, int timeToShow) {
}
}

@Override
public String toString() {
return world + "," + x + "," + z;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
Expand All @@ -86,6 +88,7 @@ public int hashCode() {
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/cjburkey/claimchunk/chunk/DataChunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public class DataChunk {
public final ChunkPos chunk;
public final UUID player;

public DataChunk(ChunkPos chunk, UUID player) {
DataChunk(ChunkPos chunk, UUID player) {
this.chunk = chunk;
this.player = player;
}

}
}
33 changes: 13 additions & 20 deletions src/main/java/com/cjburkey/claimchunk/cmd/Argument.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.cjburkey.claimchunk.cmd;

import java.util.Objects;

public class Argument {

private String arg;
Expand All @@ -19,32 +21,23 @@ public TabCompletion getCompletion() {
return tab;
}

@Override
public String toString() {
return arg;
}

public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((arg == null) ? 0 : arg.hashCode());
result = prime * result + ((tab == null) ? 0 : tab.hashCode());
return result;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Argument argument = (Argument) o;
return Objects.equals(arg, argument.arg) &&
tab == argument.tab;
}

public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Argument other = (Argument) obj;
if (arg == null) {
if (other.arg != null)
return false;
} else if (!arg.equals(other.arg))
return false;
return tab == other.tab;
@Override
public int hashCode() {
return Objects.hash(arg, tab);
}

public enum TabCompletion {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

public class AutoTabCompletion implements TabCompleter {

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if (args.length < 1) {
return getCommands("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public ICommand getCommand(String name) {
return null;
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
runCommands(sender, args);
return true;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/cjburkey/claimchunk/cmds/CmdAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@

public class CmdAccess implements ICommand {

@Override
public String getCommand() {
return "access";
}

@Override
public String getDescription() {
return "Toggle access for [player] in your claimed territory or list players that have access to your chunks.";
}

@Override
public Argument[] getPermittedArguments() {
return new Argument[] {new Argument("player", Argument.TabCompletion.OFFLINE_PLAYER)};
}

@Override
public int getRequiredArguments() {
return 0;
}

@Override
public boolean onCall(Player executor, String[] args) {
if (args.length == 0) MainHandler.listAccessors(executor);
else MainHandler.accessChunk(executor, args[0].split(","));
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/cjburkey/claimchunk/cmds/CmdAuto.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,27 @@

public class CmdAuto implements ICommand {

@Override
public String getCommand() {
return "auto";
}

@Override
public String getDescription() {
return "Automatically claim chunks when you enter.";
}

@Override
public Argument[] getPermittedArguments() {
return new Argument[] {};
}

@Override
public int getRequiredArguments() {
return 0;
}

@Override
public boolean onCall(Player executor, String[] args) {
if (!executor.hasPermission("claimchunk.auto")) {
Utils.toPlayer(executor, false, Config.getColor("errorColor"), Utils.getMsg("autoNoPerm"));
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/cjburkey/claimchunk/cmds/CmdClaim.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@

public class CmdClaim implements ICommand {

@Override
public String getCommand() {
return "claim";
}

@Override
public String getDescription() {
return "Claim the chunk you're standing in.";
}

@Override
public Argument[] getPermittedArguments() {
return new Argument[] {};
}

@Override
public int getRequiredArguments() {
return 0;
}

@Override
public boolean onCall(Player executor, String[] args) {
MainHandler.claimChunk(executor, executor.getLocation().getChunk());
return true;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/cjburkey/claimchunk/cmds/CmdHelp.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,27 @@

public class CmdHelp implements ICommand {

@Override
public String getCommand() {
return "help";
}

@Override
public String getDescription() {
return "Display ClaimChunk help (for [command], if supplied)";
}

@Override
public Argument[] getPermittedArguments() {
return new Argument[] {new Argument("command", Argument.TabCompletion.COMMAND)};
}

@Override
public int getRequiredArguments() {
return 0;
}

@Override
public boolean onCall(Player executor, String[] args) {
if (args.length == 0) {
Utils.msg(executor, Config.getColor("infoColor") + "&l---[ ClaimChunk Help ] ---");
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/cjburkey/claimchunk/cmds/CmdName.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,27 @@

public class CmdName implements ICommand {

@Override
public String getCommand() {
return "name";
}

@Override
public String getDescription() {
return "Change the name that appears when someone enters your land.";
}

@Override
public Argument[] getPermittedArguments() {
return new Argument[] {new Argument("newName", Argument.TabCompletion.NONE)};
}

@Override
public int getRequiredArguments() {
return 0;
}

@Override
public boolean onCall(Player executor, String[] args) {
PlayerHandler nh = ClaimChunk.getInstance().getPlayerHandler();
try {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/cjburkey/claimchunk/cmds/CmdReload.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,27 @@

public class CmdReload implements ICommand {

@Override
public String getCommand() {
return "reload";
}

@Override
public String getDescription() {
return "Reload the config for ClaimChunk";
}

@Override
public Argument[] getPermittedArguments() {
return new Argument[0];
}

@Override
public int getRequiredArguments() {
return 0;
}

@Override
public boolean onCall(Player executor, String[] args) {
if (!executor.hasPermission("claimchunk.admin")) {
Utils.toPlayer(executor, false, ChatColor.RED, Config.getString("messages", "reloadNoPerm"));
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/cjburkey/claimchunk/cmds/CmdShow.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@

public class CmdShow implements ICommand {

@Override
public String getCommand() {
return "show";
}

@Override
public String getDescription() {
return "Outline the chunk you're standing in with particles.";
}

@Override
public Argument[] getPermittedArguments() {
return new Argument[] {new Argument("seconds", Argument.TabCompletion.NONE)};
}

@Override
public int getRequiredArguments() {
return 0;
}

@Override
public boolean onCall(Player executor, String[] args) {
ChunkPos p = new ChunkPos(executor.getLocation().getChunk());
int time = 5;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/cjburkey/claimchunk/cmds/CmdUnclaim.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@

public class CmdUnclaim implements ICommand {

@Override
public String getCommand() {
return "unclaim";
}

@Override
public String getDescription() {
return "Unclaim the chunk you're standing in.";
}

@Override
public Argument[] getPermittedArguments() {
return new Argument[] {};
}

@Override
public int getRequiredArguments() {
return 0;
}

@Override
public boolean onCall(Player executor, String[] args) {
MainHandler.unclaimChunk(executor);
return true;
Expand Down
Loading

0 comments on commit bc4ddbe

Please sign in to comment.