SteamWar/SpigotCore
Archiviert
13
0

Remove TestCommand.java

Dieser Commit ist enthalten in:
yoyosource 2021-03-31 14:45:47 +02:00
Ursprung a33c8a3a1e
Commit b6aa9d760c

Datei anzeigen

@ -1,82 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.acommand;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class TestCommand extends SWCommand {
public TestCommand() {
// Register this command as 'test'
super("test");
}
// One Help Command, the first Parameter should be some kind of CommandSender
// The second argument can only be a varArgs string of what arguments were tried to map
@Register(help = true)
public void testHelp(Player player, String... args) {
player.sendMessage("This is your help message");
}
// One Command, the first Parameter should be some kind of CommandSender
@Register
public void test(Player player) {
}
// Another Command, subCommands can be implemented with the Register Annotation,
// you can use custom Mappers by putting a Mapper Annotation on a Parameter
@Register({"two"})
public void testTwo(Player player, int i, @Mapper("solidMaterial") Material material) {
}
// Add Custom Mapper when this command is registered, all Mapper of you class will be
// created first and than the Commands. Do not use this mapper outside your class, as
// it can only create failures. Use on your own risk. Definition order should be considered.
@Mapper("solidMaterial")
public TypeMapper<Material> materialTypeMapper() {
List<String> tabCompletes = Arrays.stream(Material.values())
.filter(Material::isSolid)
.map(Material::name)
.map(String::toLowerCase)
.collect(Collectors.toList());
return new TypeMapper<Material>() {
@Override
public Material map(String[] previous, String s) {
return Material.valueOf(s.toUpperCase());
}
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] previous, String s) {
return tabCompletes;
}
};
}
}