Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug with bad stack traces when no entities are found
- Loading branch information
Showing
2 changed files
with
75 additions
and
15 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
1.13CommandAPI/src/io/github/jorelali/commandapi/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,48 @@ | ||
package io.github.jorelali.commandapi; | ||
|
||
import java.util.Collection; | ||
import java.util.LinkedHashMap; | ||
|
||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import io.github.jorelali.commandapi.api.CommandAPI; | ||
import io.github.jorelali.commandapi.api.arguments.Argument; | ||
import io.github.jorelali.commandapi.api.arguments.EntitySelectorArgument; | ||
import io.github.jorelali.commandapi.api.arguments.EntitySelectorArgument.EntitySelector; | ||
|
||
public class Main extends JavaPlugin { | ||
|
||
@Override | ||
public void onEnable() { | ||
//Nothing required here, just need | ||
//to state that this is a plugin so | ||
//other plugins can depend on it | ||
|
||
LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>(); | ||
arguments.put("player", new EntitySelectorArgument(EntitySelector.ONE_PLAYER)); | ||
CommandAPI.getInstance().register("apioneplayer", arguments, (sender, args) -> { | ||
((Player) args[0]).sendMessage("hello"); | ||
}); | ||
|
||
arguments = new LinkedHashMap<>(); | ||
arguments.put("players", new EntitySelectorArgument(EntitySelector.MANY_PLAYERS)); | ||
CommandAPI.getInstance().register("apimanyplayers", arguments, (sender, args) -> { | ||
((Collection<Player>) args[0]).forEach(p -> p.sendMessage("hi")); | ||
}); | ||
|
||
arguments = new LinkedHashMap<>(); | ||
arguments.put("entity", new EntitySelectorArgument(EntitySelector.ONE_ENTITY)); | ||
CommandAPI.getInstance().register("apioneentity", arguments, (sender, args) -> { | ||
((Entity) args[0]).remove(); | ||
}); | ||
|
||
arguments = new LinkedHashMap<>(); | ||
arguments.put("entities", new EntitySelectorArgument(EntitySelector.MANY_ENTITIES)); | ||
CommandAPI.getInstance().register("apimanyentities", arguments, (sender, args) -> { | ||
((Collection<Entity>) args[0]).forEach(e -> e.remove()); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters