Skip to content

Commit

Permalink
Ready to start testing for release 3.12
Browse files Browse the repository at this point in the history
Closes #187
Closes #186
  • Loading branch information
JustBru00 committed Dec 31, 2023
1 parent 1253985 commit e7a8014
Show file tree
Hide file tree
Showing 7 changed files with 330 additions and 2 deletions.
43 changes: 41 additions & 2 deletions src/com/gmail/justbru00/epic/rename/main/v3/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
import com.gmail.justbru00.epic.rename.exploit_prevention.ExploitPreventionListener;
import com.gmail.justbru00.epic.rename.listeners.v3.OnJoin;
import com.gmail.justbru00.epic.rename.main.v3.bstats.BStats;
import com.gmail.justbru00.epic.rename.tabcompleters.EpicRenameTabCompleter;
import com.gmail.justbru00.epic.rename.tabcompleters.ExportTabCompleter;
import com.gmail.justbru00.epic.rename.tabcompleters.GenericNoArgsTabCompleter;
import com.gmail.justbru00.epic.rename.tabcompleters.GenericOneArgTabCompleter;
import com.gmail.justbru00.epic.rename.tabcompleters.GenericTwoArgTabCompleter;
import com.gmail.justbru00.epic.rename.tabcompleters.ImportTabCompleter;
import com.gmail.justbru00.epic.rename.utils.v3.Debug;
import com.gmail.justbru00.epic.rename.utils.v3.Messager;
import com.gmail.justbru00.epic.rename.utils.v3.PluginFile;
Expand Down Expand Up @@ -138,24 +144,57 @@ public void onEnable() {
pm.registerEvents(new OnJoin(), this);
pm.registerEvents(new ExploitPreventionListener(), this);

// Command Executors
// Command Executors and Tab Completers
getCommand("rename").setExecutor(new Rename());
getCommand("rename").setTabCompleter(new GenericOneArgTabCompleter("rename", "<name>"));

getCommand("epicrename").setExecutor(new EpicRename());
getCommand("epicrename").setTabCompleter(new EpicRenameTabCompleter());

getCommand("lore").setExecutor(new Lore());
getCommand("lore").setTabCompleter(new GenericOneArgTabCompleter("lore", "<loreText>"));

getCommand("setloreline").setExecutor(new SetLoreLine());
getCommand("setloreline").setTabCompleter(new GenericTwoArgTabCompleter("setloreline", "<lineNumber>", "<loreText>"));

getCommand("removeloreline").setExecutor(new RemoveLoreLine());
getCommand("removeloreline").setTabCompleter(new GenericOneArgTabCompleter("removeloreline", "<lineNumber>"));

getCommand("insertloreline").setExecutor(new InsertLoreLine());
getCommand("insertloreline").setTabCompleter(new GenericTwoArgTabCompleter("insertloreline", "<beforeLineNumber>", "<loreText>"));

getCommand("glow").setExecutor(new Glow());
getCommand("glow").setTabCompleter(new GenericNoArgsTabCompleter("glow"));

getCommand("removeglow").setExecutor(new RemoveGlow());
getCommand("import").setExecutor(new Import());;
getCommand("removeglow").setTabCompleter(new GenericNoArgsTabCompleter("removeglow"));

getCommand("import").setExecutor(new Import());
getCommand("import").setTabCompleter(new ImportTabCompleter());

getCommand("export").setExecutor(new Export());
getCommand("export").setTabCompleter(new ExportTabCompleter());

getCommand("removename").setExecutor(new RemoveName());
getCommand("removename").setTabCompleter(new GenericNoArgsTabCompleter("removename"));

getCommand("removelore").setExecutor(new RemoveLore());
getCommand("removelore").setTabCompleter(new GenericNoArgsTabCompleter("removelore"));

getCommand("hideenchantments").setExecutor(new HideEnchantments());
getCommand("hideenchantments").setTabCompleter(new GenericNoArgsTabCompleter("hideenchantments"));

getCommand("unhideenchantments").setExecutor(new UnHideEnchantments());
getCommand("unhideenchantments").setTabCompleter(new GenericNoArgsTabCompleter("unhideenchantments"));

getCommand("addloreline").setExecutor(new AddLoreLine());
getCommand("addloreline").setTabCompleter(new GenericOneArgTabCompleter("addloreline", "<loreText>"));

getCommand("editname").setExecutor(new EditName());
getCommand("editname").setTabCompleter(new GenericNoArgsTabCompleter("editname"));

getCommand("editlore").setExecutor(new EditLore());
getCommand("editlore").setTabCompleter(new GenericNoArgsTabCompleter("editlore"));

// Start bstats
BStats bstats = new BStats(this, BSTATS_PLUGIN_ID);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.gmail.justbru00.epic.rename.tabcompleters;

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

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;

public class EpicRenameTabCompleter implements TabCompleter {

private ArrayList<String> epicrenameFirstArgumentList = new ArrayList<String>();
private ArrayList<String> empty = new ArrayList<String>();

public EpicRenameTabCompleter() {
epicrenameFirstArgumentList.add("help");
epicrenameFirstArgumentList.add("license");
epicrenameFirstArgumentList.add("reload");
epicrenameFirstArgumentList.add("debug");
epicrenameFirstArgumentList.add("version");
}

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

if (!command.getName().equalsIgnoreCase("epicrename")) {
return null;
}

if (args.length == 1) {
if (!args[0].equals("")) {
ArrayList<String> completion = new ArrayList<String>();

for (String first : epicrenameFirstArgumentList) {
if (first.toLowerCase().startsWith(args[0].toLowerCase())) {
completion.add(first);
}
}

return completion;
} else {
return epicrenameFirstArgumentList;
}
}

return empty;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.gmail.justbru00.epic.rename.tabcompleters;

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

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;

public class ExportTabCompleter implements TabCompleter {

private ArrayList<String> exportFirstArgumentList = new ArrayList<String>();
private ArrayList<String> empty = new ArrayList<String>();

public ExportTabCompleter() {
exportFirstArgumentList.add("hand");
exportFirstArgumentList.add("inventory");
}

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if (!command.getName().equalsIgnoreCase("export")) {
return null;
}

if (args.length == 1) {
if (!args[0].equals("")) {
ArrayList<String> completion = new ArrayList<String>();

for (String first : exportFirstArgumentList) {
if (first.toLowerCase().startsWith(args[0].toLowerCase())) {
completion.add(first);
}
}

return completion;
} else {
return exportFirstArgumentList;
}
}

return empty;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.gmail.justbru00.epic.rename.tabcompleters;

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

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;

public class GenericNoArgsTabCompleter implements TabCompleter {

private ArrayList<String> empty = new ArrayList<String>();
private String commandName;

public GenericNoArgsTabCompleter(String _commandName) {
commandName = _commandName;
}

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if (!command.getName().equalsIgnoreCase(commandName)) {
return null;
}

return empty;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.gmail.justbru00.epic.rename.tabcompleters;

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

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;

public class GenericOneArgTabCompleter implements TabCompleter {

private ArrayList<String> empty = new ArrayList<String>();
private ArrayList<String> firstArgument = new ArrayList<String>();
private String commandName;

public GenericOneArgTabCompleter(String _commandName, String _firstArgument) {
firstArgument.add(_firstArgument);
commandName = _commandName;
}

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if (!command.getName().equalsIgnoreCase(commandName)) {
return null;
}

if (args.length == 1) {
if (args[0].equals("")) {
return firstArgument;
}
}

return empty;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.gmail.justbru00.epic.rename.tabcompleters;

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

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;

public class GenericTwoArgTabCompleter implements TabCompleter {

private ArrayList<String> empty = new ArrayList<String>();
private ArrayList<String> firstArgument = new ArrayList<String>();
private ArrayList<String> secondArgument = new ArrayList<String>();
private String commandName;

public GenericTwoArgTabCompleter(String _commandName, String _firstArgument, String _secondArgument) {
firstArgument.add(_firstArgument);
secondArgument.add(_secondArgument);
commandName = _commandName;
}

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if (!command.getName().equalsIgnoreCase(commandName)) {
return null;
}

if (args.length == 1) {
if (args[0].equals("")) {
return firstArgument;
}
}

if (args.length == 2) {
if (args[1].equals("")) {
return secondArgument;
}
}

return empty;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package com.gmail.justbru00.epic.rename.tabcompleters;

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

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;

public class ImportTabCompleter implements TabCompleter {

private ArrayList<String> importFirstArgumentList = new ArrayList<String>();
private ArrayList<String> importHandInventorySecondArgumentList = new ArrayList<String>();
private ArrayList<String> importRawSecondArgumentList = new ArrayList<String>();
private ArrayList<String> empty = new ArrayList<String>();

public ImportTabCompleter() {
importFirstArgumentList.add("hand");
importFirstArgumentList.add("inventory");
importFirstArgumentList.add("raw");

importHandInventorySecondArgumentList.add("<webUrl>");

importRawSecondArgumentList.add("<rawYAML>");
}

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if (!command.getName().equalsIgnoreCase("import")) {
return null;
}

if (args.length == 1) {
if (!args[0].equals("")) {
ArrayList<String> completion = new ArrayList<String>();

for (String first : importFirstArgumentList) {
if (first.toLowerCase().startsWith(args[0].toLowerCase())) {
completion.add(first);
}
}

return completion;
} else {
return importFirstArgumentList;
}
} else if (args.length == 2) {
if (!args[1].equals("")) {
if (args[0].toLowerCase().equals("hand") || args[0].toLowerCase().equals("inventory")) {
ArrayList<String> completion = new ArrayList<String>();

for (String second : importHandInventorySecondArgumentList) {
if (second.toLowerCase().startsWith(args[1].toLowerCase())) {
completion.add(second);
}
}

return completion;
} else if (args[0].toLowerCase().equals("raw")) {
ArrayList<String> completion = new ArrayList<String>();

for (String second : importRawSecondArgumentList) {
if (second.toLowerCase().startsWith(args[1].toLowerCase())) {
completion.add(second);
}
}

return completion;
} else {
return empty;
}
} else {
// No text in second argument yet
if (args[0].toLowerCase().equals("hand") || args[0].toLowerCase().equals("inventory")) {
return importHandInventorySecondArgumentList;
} else if (args[0].toLowerCase().equals("raw")) {
return importRawSecondArgumentList;
} else {
return empty;
}
}
}

return empty;
}

}

0 comments on commit e7a8014

Please sign in to comment.