TF-PlotSquared/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java

91 lines
4.1 KiB
Java
Raw Normal View History

2014-11-08 20:27:09 +01:00
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// 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, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
2014-10-02 17:38:31 +02:00
2014-11-08 20:27:09 +01:00
package com.intellectualcrafters.plot.commands;
2014-10-02 17:38:31 +02:00
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
2014-11-08 20:27:09 +01:00
import org.bukkit.entity.Player;
2014-10-02 17:38:31 +02:00
2014-11-09 12:51:17 +01:00
@SuppressWarnings({"unused", "deprecated", "javadoc"})
2014-10-02 17:38:31 +02:00
public class Rate extends SubCommand {
2014-11-05 14:42:08 +11:00
/*
* String cmd, String permission, String description, String usage, String
* alias, CommandCategory category
*/
2014-10-02 17:38:31 +02:00
2014-11-05 14:42:08 +11:00
public Rate() {
super("rate", "plots.rate", "Rate the plot", "rate {0-10}", "rt", CommandCategory.ACTIONS, true);
}
2014-10-02 17:38:31 +02:00
2014-11-05 14:42:08 +11:00
@Override
public boolean execute(final Player plr, final String... args) {
if (args.length < 1) {
sendMessage(plr, C.RATING_NOT_VALID);
return true;
}
if (!PlayerFunctions.isInPlot(plr)) {
sendMessage(plr, C.NOT_IN_PLOT);
return true;
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (!plot.hasOwner()) {
sendMessage(plr, C.RATING_NOT_OWNED);
return true;
}
if (plot.getOwner().equals(plr.getUniqueId())) {
sendMessage(plr, C.RATING_NOT_YOUR_OWN);
return true;
}
final String arg = args[0];
boolean o = false;
for (final char c : arg.toCharArray()) {
if (!Character.isDigit(c)) {
o = true;
break;
}
}
int rating = 0;
if (!o) {
rating = Integer.parseInt(arg);
}
if (o || ((rating < 0) || (rating > 10))) {
sendMessage(plr, C.RATING_NOT_VALID);
return true;
}
// TODO implement check for already rated
final boolean rated = false;
if (rated) {
sendMessage(plr, C.RATING_ALREADY_EXISTS, plot.getId().toString());
}
// TODO actually do something...
final boolean success = false;
if (success) {
sendMessage(plr, C.RATING_APPLIED, plot.getId().toString());
2014-11-08 20:27:09 +01:00
} else {
2014-11-05 14:42:08 +11:00
sendMessage(plr, C.COMMAND_WENT_WRONG);
}
return true;
}
2014-10-02 17:38:31 +02:00
}