Skip to content

Commit

Permalink
3.68
Browse files Browse the repository at this point in the history
  • Loading branch information
Trophonix committed May 16, 2020
1 parent 5a765c1 commit d0dfbcf
Show file tree
Hide file tree
Showing 43 changed files with 3,078 additions and 2,304 deletions.
17 changes: 16 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.trophonix</groupId>
<artifactId>TradePlus</artifactId>
<version>3.67</version>
<version>3.68</version>

<properties>
<res>${project.basedir}/res/</res>
Expand Down Expand Up @@ -52,6 +52,11 @@
<id>aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>

<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -164,6 +169,12 @@
<version>1.6.3-RC</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.codemc.worldguardwrapper</groupId>
<artifactId>worldguardwrapper</artifactId>
<version>1.1.6-SNAPSHOT</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -222,6 +233,10 @@
<pattern>net.wesjd.anvilgui</pattern>
<shadedPattern>com.trophonix.tradeplus.shaded.anvilgui</shadedPattern>
</relocation>
<relocation>
<pattern>org.codemc.worldguardwrapper</pattern>
<shadedPattern>com.trophonix.tradeplus.shaded.worldguardwrapper</shadedPattern>
</relocation>
</relocations>
<minimizeJar>true</minimizeJar>
</configuration>
Expand Down
Binary file added res/._Factions.jar
Binary file not shown.
Binary file added res/Factions.jar
Binary file not shown.
588 changes: 420 additions & 168 deletions src/main/java/com/trophonix/tradeplus/TradePlus.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ public boolean isAlias(String command) {
public List<String> onTabComplete(CommandSender sender, String[] args, String full) {
return Collections.emptyList();
}

}
51 changes: 27 additions & 24 deletions src/main/java/com/trophonix/tradeplus/commands/CommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@
import org.bukkit.command.CommandSender;
import org.bukkit.event.Cancellable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.server.RemoteServerCommandEvent;
import org.bukkit.event.server.ServerCommandEvent;

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

public class CommandHandler implements Listener, CommandExecutor {

@Getter
private List<Command> commands = new ArrayList<>();
@Getter private List<Command> commands = new ArrayList<>();

public CommandHandler(TradePlus pl, boolean compatMode) {
if (!compatMode) pl.getServer().getPluginManager().registerEvents(this, pl);
try {
Class.forName("org.bukkit.event.server.TabCompleteEvent");
Bukkit.getPluginManager().registerEvents(new CommandHandler.TabCompleter() {
@Override public List<String> getCompletions(CommandSender sender, String cmd, String[] args, String buffer) {
Command command = commands.stream()
.filter(c -> c.isAlias(cmd))
.findFirst().orElse(null);
return command != null ? command.onTabComplete(sender, args, buffer)
: null;
}
}, pl);
} catch (ClassNotFoundException ignored) { }
Bukkit.getPluginManager()
.registerEvents(
new CommandHandler.TabCompleter() {
@Override
public List<String> getCompletions(
CommandSender sender, String cmd, String[] args, String buffer) {
Command command =
commands.stream().filter(c -> c.isAlias(cmd)).findFirst().orElse(null);
return command != null ? command.onTabComplete(sender, args, buffer) : null;
}
},
pl);
} catch (ClassNotFoundException ignored) {
}
}

public void add(Command command) {
Expand All @@ -47,7 +47,8 @@ public void clear() {
}

@Override
public boolean onCommand(CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
public boolean onCommand(
CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
String[] cmd = new String[args.length + 1];
cmd[0] = label;
System.arraycopy(args, 0, cmd, 1, args.length);
Expand All @@ -73,10 +74,12 @@ private void testAndRun(Cancellable event, CommandSender sender, String[] cmd) {
System.arraycopy(cmd, 1, args, 0, cmd.length - 1);
commands.stream()
.filter(command -> command.isAlias(cmd[0]))
.findFirst().ifPresent(command -> {
command.onCommand(sender, args);
if (event != null) event.setCancelled(true);
});
.findFirst()
.ifPresent(
command -> {
command.onCommand(sender, args);
if (event != null) event.setCancelled(true);
});
}
}

Expand All @@ -88,13 +91,13 @@ public void onTabComplete(org.bukkit.event.server.TabCompleteEvent event) {
if (cmd.length > 0) {
String[] args = new String[cmd.length - 1];
System.arraycopy(cmd, 1, args, 0, cmd.length - 1);
List<String> completions = getCompletions(event.getSender(), cmd[0], args, event.getBuffer());
List<String> completions =
getCompletions(event.getSender(), cmd[0], args, event.getBuffer());
if (completions != null) event.setCompletions(completions);
}
}

protected abstract List<String> getCompletions(CommandSender sender, String command, String[] args, String buffer);

protected abstract List<String> getCompletions(
CommandSender sender, String command, String[] args, String buffer);
}

}
Loading

0 comments on commit d0dfbcf

Please sign in to comment.