SteamWar/BauSystem2.0
Archiviert
12
0

Commits vergleichen

...
Dieses Repository wurde am 2024-08-05 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.

1 Commits

Autor SHA1 Nachricht Datum
Chaoscaot
fa7f4ef00d Add Lockschem TabComplete
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-09-18 21:04:47 +02:00

Datei anzeigen

@ -23,12 +23,18 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.command.TypeValidator;
import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType; import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup; import de.steamwar.sql.UserGroup;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Collection;
import java.util.Collections;
@Linked(LinkageType.COMMAND) @Linked(LinkageType.COMMAND)
public class LockSchemCommand extends SWCommand { public class LockSchemCommand extends SWCommand {
@ -37,49 +43,18 @@ public class LockSchemCommand extends SWCommand {
} }
@Register(help = true) @Register(help = true)
public void genericHelp(Player p, String... args) { public void genericHelp(@Validator Player p, String... args) {
SteamwarUser steamwarUser = SteamwarUser.get(p.getUniqueId());
UserGroup userGroup = steamwarUser.getUserGroup();
if (userGroup != UserGroup.Admin &&
userGroup != UserGroup.Developer &&
userGroup != UserGroup.Moderator &&
userGroup != UserGroup.Supporter) {
return;
}
sendHelp(p); sendHelp(p);
} }
@Register @Register
public void genericCommand(Player p, String owner, String schematicName) { public void genericCommand(@Validator Player p, @ErrorMessage("LOCK_SCHEM_NO_USER") SteamwarUser owner, @ErrorMessage("LOCK_SCHEM_NO_SCHEM") SchematicNode schematic) {
SteamwarUser steamwarUser = SteamwarUser.get(p.getUniqueId());
UserGroup userGroup = steamwarUser.getUserGroup();
if (userGroup != UserGroup.Admin &&
userGroup != UserGroup.Developer &&
userGroup != UserGroup.Moderator &&
userGroup != UserGroup.Supporter) {
return;
}
SteamwarUser schemOwner = SteamwarUser.get(owner);
if (schemOwner == null) {
BauSystem.MESSAGE.send("LOCK_SCHEM_NO_USER", p);
return;
}
SchematicNode schematic = SchematicNode.getNodeFromPath(schemOwner, schematicName);
if (schematic == null) {
BauSystem.MESSAGE.send("LOCK_SCHEM_NO_SCHEM", p);
return;
}
if(schematic.isDir()) { if(schematic.isDir()) {
BauSystem.MESSAGE.send("LOCK_SCHEM_DIR", p); BauSystem.MESSAGE.send("LOCK_SCHEM_DIR", p);
return; return;
} }
BauSystem.MESSAGE.send("LOCK_SCHEM_LOCKED", p, schematic.getName(), schemOwner.getUserName(), schematic.getSchemtype().name()); BauSystem.MESSAGE.send("LOCK_SCHEM_LOCKED", p, schematic.getName(), owner.getUserName(), schematic.getSchemtype().name());
schematic.setSchemtype(SchematicType.Normal); schematic.setSchemtype(SchematicType.Normal);
} }
@ -87,4 +62,33 @@ public class LockSchemCommand extends SWCommand {
BauSystem.MESSAGE.sendPrefixless("COMMAND_HELP_HEAD", player, "Lock Schem"); BauSystem.MESSAGE.sendPrefixless("COMMAND_HELP_HEAD", player, "Lock Schem");
BauSystem.MESSAGE.sendPrefixless("LOCK_SCHEM_HELP", player); BauSystem.MESSAGE.sendPrefixless("LOCK_SCHEM_HELP", player);
} }
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> permission() {
return (commandSender, player, messageSender) -> {
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
UserGroup userGroup = steamwarUser.getUserGroup();
return userGroup.isCheckSchematics();
};
}
@ClassMapper(value = SchematicNode.class, local = true)
public TypeMapper<SchematicNode> getMapper() {
return new TypeMapper<SchematicNode>() {
@Override
public Collection<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
SteamwarUser owner = SteamwarUser.get(strings[1]);
if(owner == null) return Collections.emptyList();
return SchematicNode.getNodeTabcomplete(owner, s);
}
@Override
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
SteamwarUser owner = SteamwarUser.get(previousArguments[1]);
if(owner == null) return null;
return SchematicNode.getNodeFromPath(owner, s);
}
};
}
} }