Skip to content

Commit

Permalink
Fix #11
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragonisser committed Jan 17, 2021
1 parent bf51310 commit 5d4b933
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void onEntityxplode(EntityExplodeEvent event) {

private boolean containsTowerType(BlockData blockData) {
for(TowerType type : TowerType.values()) {
if(Bukkit.createBlockData(type.getTowerRessource()).equals(blockData)) {
if(Bukkit.createBlockData(type.getResourceBlockData()).equals(blockData)) {
return true;
}
}
Expand Down
35 changes: 35 additions & 0 deletions src/de/prwh/ressourcetowers/main/commands/CommandHelper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.prwh.ressourcetowers.main.commands;

import java.util.ArrayList;
import java.util.List;

import org.bukkit.command.Command;
Expand All @@ -10,6 +11,7 @@

import de.prwh.ressourcetowers.main.RTMain;
import de.prwh.ressourcetowers.towers.TowerHelper;
import de.prwh.ressourcetowers.towers.TowerInfo.TowerType;

public class CommandHelper implements CommandExecutor, TabCompleter {

Expand Down Expand Up @@ -67,6 +69,39 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
List<String> autoComplete = new ArrayList<String>();

if (command.getName().equalsIgnoreCase("rt")) {
if(args.length == 1) {
autoComplete.clear();
autoComplete.add("add");
autoComplete.add("remove");
autoComplete.add("spawn");
autoComplete.add("list");
autoComplete.add("reload");

return autoComplete;
} else if(args.length == 2) {
autoComplete.clear();
if(args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("spawn")) {
for(TowerType type : TowerType.values()) {
autoComplete.add(type.getResourceName());
}
return autoComplete;
}
if(args[0].equalsIgnoreCase("remove")) {
autoComplete.add("all");
return autoComplete;
}
} else if(args.length == 3) {
autoComplete.clear();
if(args[0].equalsIgnoreCase("spawn")) {
autoComplete.add("true");
autoComplete.add("false");
return autoComplete;
}
}
}
return null;
}

Expand Down
20 changes: 12 additions & 8 deletions src/de/prwh/ressourcetowers/towers/TowerInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,24 @@ public static enum TowerType {
EMERALD("Emerald", "minecraft:emerald_ore"), LAPIS("Lapis", "minecraft:lapis_ore"),
QUARTZ("Quartz", "minecraft:nether_quartz_ore");

private String towername;
private String ressource;
private String resourceName;
private String blockData;

public String getTowerName() {
return towername + "-tower";
return resourceName + "-tower";
}

public String getResourceName() {
return resourceName;
}

public String getTowerRessource() {
return ressource;
public String getResourceBlockData() {
return blockData;
}

private TowerType(String towername, String ressource) {
this.towername = towername;
this.ressource = ressource;
this.resourceName = towername;
this.blockData = ressource;
}
}

Expand All @@ -44,7 +48,7 @@ public TowerType getType() {
}

public String getRessource() {
return type.getTowerRessource();
return type.getResourceBlockData();
}

public String getTowername() {
Expand Down

0 comments on commit 5d4b933

Please sign in to comment.