com.plotsquared.core.command.Dislike Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of PlotSquared-Core Show documentation
Show all versions of PlotSquared-Core Show documentation
PlotSquared, a land and world management plugin for Minecraft.
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2014 - 2022 IntellectualSites
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
@CommandDeclaration(command = "dislike",
permission = "plots.dislike",
usage = "/plot dislike [next|purge]",
category = CommandCategory.INFO,
requiredType = RequiredType.PLAYER)
public class Dislike extends SubCommand {
private final Like like;
@Inject
public Dislike(final @NonNull Like like) {
this.like = like;
}
@Override
public boolean onCommand(PlotPlayer> player, String[] args) {
return this.like.handleLike(player, args, false);
}
@Override
public Collection tab(final PlotPlayer> player, final String[] args, final boolean space) {
if (args.length == 1) {
final List completions = new LinkedList<>();
if (Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_PURGE_RATINGS)) {
completions.add("purge");
}
final List commands = completions.stream().filter(completion -> completion
.toLowerCase()
.startsWith(args[0].toLowerCase()))
.map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.INFO) {
}).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, Permission.PERMISSION_RATE) && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList()));
}
return commands;
}
return TabCompletions.completePlayers(player, String.join(",", args).trim(), Collections.emptyList());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy