mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Working on plot commenting... Can you do the DB stuff?
This commit is contained in:
parent
6a050f5287
commit
cfbf0086fa
@ -16,6 +16,10 @@ import org.bukkit.ChatColor;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public enum C {
|
public enum C {
|
||||||
|
/*
|
||||||
|
* Comment
|
||||||
|
*/
|
||||||
|
COMMENT_SYNTAX("&cUse /plot comment <everyone|trusted|helper|owner|admin> <comment>"),
|
||||||
/*
|
/*
|
||||||
* Console
|
* Console
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
|
public class PlotComment {
|
||||||
|
public final String comment;
|
||||||
|
public final int tier;
|
||||||
|
public final String senderName;
|
||||||
|
|
||||||
|
public PlotComment(String comment, String senderName, int tier) {
|
||||||
|
this.comment = comment;
|
||||||
|
this.tier = tier;
|
||||||
|
this.senderName = senderName;
|
||||||
|
}
|
||||||
|
}
|
@ -105,7 +105,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
public static WorldGuardListener worldGuardListener = null;
|
public static WorldGuardListener worldGuardListener = null;
|
||||||
|
|
||||||
public static Economy economy;
|
public static Economy economy;
|
||||||
public static boolean useEconomy;
|
public static boolean useEconomy = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* !!WorldGeneration!!
|
* !!WorldGeneration!!
|
||||||
@ -705,7 +705,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
checkExpired(PlotMain.getMain(), true);
|
checkExpired(PlotMain.getMain(), true);
|
||||||
checkForExpiredPlots();
|
checkForExpiredPlots();
|
||||||
}
|
}
|
||||||
if (getServer().getPluginManager().getPlugin("Vault") != null) {
|
if (getServer().getPluginManager().getPlugin("Vault") != null && getServer().getPluginManager().getPlugin("Vault").isEnabled()) {
|
||||||
RegisteredServiceProvider<Economy> economyProvider =
|
RegisteredServiceProvider<Economy> economyProvider =
|
||||||
getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||||
if (economyProvider != null) {
|
if (economyProvider != null) {
|
||||||
|
@ -10,6 +10,7 @@ package com.intellectualcrafters.plot;
|
|||||||
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -33,6 +34,7 @@ public class PlotSettings {
|
|||||||
*/
|
*/
|
||||||
private Biome biome;
|
private Biome biome;
|
||||||
|
|
||||||
|
private ArrayList<PlotComment> comments;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -165,4 +167,17 @@ public class PlotSettings {
|
|||||||
public String getLeaveMessage() {
|
public String getLeaveMessage() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
public ArrayList<PlotComment> getComments() {
|
||||||
|
if (this.comments == null) {
|
||||||
|
return new ArrayList<PlotComment>();
|
||||||
|
}
|
||||||
|
return this.comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addComment(PlotComment comment) {
|
||||||
|
if (this.comments == null) {
|
||||||
|
this.comments = new ArrayList<PlotComment>();
|
||||||
|
}
|
||||||
|
this.comments.add(comment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,14 @@ public enum Command {
|
|||||||
// - /plot rate <number out of 10>
|
// - /plot rate <number out of 10>
|
||||||
// - /plot list <some parameter to list the most popular, and highest rated
|
// - /plot list <some parameter to list the most popular, and highest rated
|
||||||
// plots>
|
// plots>
|
||||||
|
INBOX("inbox"),
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
COMMENT("comment", "msg"),
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
TRUSTED("trusted", "trust"),
|
TRUSTED("trusted", "trust"),
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
|
||||||
|
* and/or monetize any of our intellectual property. IntellectualCrafters is not
|
||||||
|
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||||
|
*
|
||||||
|
* >> File = Clear.java >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.*;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Citymonstret on 2014-08-01.
|
||||||
|
*/
|
||||||
|
public class Comment extends SubCommand {
|
||||||
|
|
||||||
|
public Comment() {
|
||||||
|
super(Command.COMMENT, "Comment on a plot", "comment", CommandCategory.ACTIONS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(Player plr, String... args) {
|
||||||
|
if (!PlayerFunctions.isInPlot(plr)) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
|
if (!plot.hasOwner()) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> recipients = Arrays.asList(new String[] {"admin", "owner", "helper", "trusted", "everyone" });
|
||||||
|
|
||||||
|
if (args.length==2 && recipients.contains(args[0].toLowerCase())) {
|
||||||
|
|
||||||
|
if (PlotMain.hasPermission(plr, "plots.comment."+args[0].toLowerCase())) {
|
||||||
|
String text = StringUtils.join(Arrays.copyOfRange(args, 1, args.length), " ");
|
||||||
|
PlotComment comment = new PlotComment(text, plr.getName(), recipients.indexOf(args[0].toLowerCase()));
|
||||||
|
plot.settings.addComment(comment);
|
||||||
|
|
||||||
|
DBFunc.addComment(...) // Can you do this?
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.comment."+args[0].toLowerCase());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlayerFunctions.sendMessage(plr, C.COMMENT_SYNTAX);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -24,7 +24,7 @@ public class Copy extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(Player plr, String... args) {
|
public boolean execute(Player plr, String... args) {
|
||||||
if (!PlayerFunctions.isInPlot(plr)) {
|
if (!PlayerFunctions.isInPlot(plr)) {
|
||||||
PlayerFunctions.sendMessage(plr, "You're not in a plot.");
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
|
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
|
||||||
|
* and/or monetize any of our intellectual property. IntellectualCrafters is not
|
||||||
|
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||||
|
*
|
||||||
|
* >> File = Clear.java >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.*;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Citymonstret on 2014-08-01.
|
||||||
|
*/
|
||||||
|
public class Inbox extends SubCommand {
|
||||||
|
|
||||||
|
public Inbox() {
|
||||||
|
super(Command.INBOX, "Comment on a plot", "comment", CommandCategory.ACTIONS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(Player plr, String... args) {
|
||||||
|
if (!PlayerFunctions.isInPlot(plr)) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
|
if (!plot.hasOwner()) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer tier = null;
|
||||||
|
UUID uuid = plr.getUniqueId();
|
||||||
|
if (PlotMain.hasPermission(plr, "plots.admin")) {
|
||||||
|
tier = 0;
|
||||||
|
}
|
||||||
|
else if (plot.owner == uuid) {
|
||||||
|
tier = 1;
|
||||||
|
}
|
||||||
|
else if (plot.helpers.contains(uuid)) {
|
||||||
|
tier = 2;
|
||||||
|
}
|
||||||
|
else if (plot.trusted.contains(uuid)) {
|
||||||
|
tier = 3;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tier = 4;
|
||||||
|
}
|
||||||
|
ArrayList<PlotComment> comments = plot.settings.getComments();
|
||||||
|
List<String> recipients = Arrays.asList(new String[] {"admin", "owner", "helper", "trusted", "everyone" });
|
||||||
|
|
||||||
|
int counter = 0;
|
||||||
|
StringBuilder message = new StringBuilder();
|
||||||
|
String prefix = "";
|
||||||
|
for (PlotComment comment : comments) {
|
||||||
|
if (comment.tier>=tier) {
|
||||||
|
message.append(prefix + "&6[&c" + recipients.get(tier) + "&6] &7"+comment.senderName+"&f: "+comment.comment);
|
||||||
|
prefix = "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (counter==0) {
|
||||||
|
PlayerFunctions.sendMessage(plr, "&cNo messages.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PlayerFunctions.sendMessage(plr, message.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -16,7 +16,7 @@ public class Paste extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(Player plr, String... args) {
|
public boolean execute(Player plr, String... args) {
|
||||||
if (!PlayerFunctions.isInPlot(plr)) {
|
if (!PlayerFunctions.isInPlot(plr)) {
|
||||||
PlayerFunctions.sendMessage(plr, "You're not in a plot.");
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
|
Loading…
Reference in New Issue
Block a user