Dieser Commit ist enthalten in:
Ursprung
c09d1a9ba3
Commit
fa7f4ef00d
@ -23,12 +23,18 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
import de.steamwar.bausystem.linkage.Linked;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
@Linked(LinkageType.COMMAND)
|
||||
public class LockSchemCommand extends SWCommand {
|
||||
|
||||
@ -37,49 +43,18 @@ public class LockSchemCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(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;
|
||||
}
|
||||
|
||||
public void genericHelp(@Validator Player p, String... args) {
|
||||
sendHelp(p);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p, String owner, String schematicName) {
|
||||
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;
|
||||
}
|
||||
|
||||
public void genericCommand(@Validator Player p, @ErrorMessage("LOCK_SCHEM_NO_USER") SteamwarUser owner, @ErrorMessage("LOCK_SCHEM_NO_SCHEM") SchematicNode schematic) {
|
||||
if(schematic.isDir()) {
|
||||
BauSystem.MESSAGE.send("LOCK_SCHEM_DIR", p);
|
||||
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);
|
||||
}
|
||||
|
||||
@ -87,4 +62,33 @@ public class LockSchemCommand extends SWCommand {
|
||||
BauSystem.MESSAGE.sendPrefixless("COMMAND_HELP_HEAD", player, "Lock Schem");
|
||||
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);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren