mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 12:35:15 +01:00
Added toggle command for titles
This commit is contained in:
parent
7aebd7da8e
commit
93a40653c0
@ -72,6 +72,7 @@ import com.intellectualcrafters.plot.commands.Swap;
|
|||||||
import com.intellectualcrafters.plot.commands.TP;
|
import com.intellectualcrafters.plot.commands.TP;
|
||||||
import com.intellectualcrafters.plot.commands.Target;
|
import com.intellectualcrafters.plot.commands.Target;
|
||||||
import com.intellectualcrafters.plot.commands.Template;
|
import com.intellectualcrafters.plot.commands.Template;
|
||||||
|
import com.intellectualcrafters.plot.commands.Toggle;
|
||||||
import com.intellectualcrafters.plot.commands.Trim;
|
import com.intellectualcrafters.plot.commands.Trim;
|
||||||
import com.intellectualcrafters.plot.commands.Trust;
|
import com.intellectualcrafters.plot.commands.Trust;
|
||||||
import com.intellectualcrafters.plot.commands.Unclaim;
|
import com.intellectualcrafters.plot.commands.Unclaim;
|
||||||
@ -250,6 +251,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
MainCommand.subCommands.add(new Visit());
|
MainCommand.subCommands.add(new Visit());
|
||||||
MainCommand.subCommands.add(new TP());
|
MainCommand.subCommands.add(new TP());
|
||||||
MainCommand.subCommands.add(new Set());
|
MainCommand.subCommands.add(new Set());
|
||||||
|
MainCommand.subCommands.add(new Toggle());
|
||||||
MainCommand.subCommands.add(new Clear());
|
MainCommand.subCommands.add(new Clear());
|
||||||
MainCommand.subCommands.add(new Delete());
|
MainCommand.subCommands.add(new Delete());
|
||||||
MainCommand.subCommands.add(new SetOwner());
|
MainCommand.subCommands.add(new SetOwner());
|
||||||
|
@ -43,6 +43,8 @@ public enum Command {
|
|||||||
UNTRUST("untrust", "ut"),
|
UNTRUST("untrust", "ut"),
|
||||||
UNDENY("undeny", "ud"),
|
UNDENY("undeny", "ud"),
|
||||||
|
|
||||||
|
TOGGLE("toggle", "attribute"),
|
||||||
|
|
||||||
MOVE("move"),
|
MOVE("move"),
|
||||||
FLAG("flag", "f"),
|
FLAG("flag", "f"),
|
||||||
TARGET("target"),
|
TARGET("target"),
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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 /
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
|
public class Toggle extends SubCommand {
|
||||||
|
public Toggle() {
|
||||||
|
super(Command.TOGGLE, "Toggle per user settings", "toggle <setting>", CommandCategory.ACTIONS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void noArgs(PlotPlayer player) {
|
||||||
|
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot toggle <setting>");
|
||||||
|
MainUtil.sendMessage(player, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + "titles");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(final PlotPlayer player, final String... args) {
|
||||||
|
if (args.length == 0) {
|
||||||
|
noArgs(player);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch (args[0].toLowerCase()) {
|
||||||
|
case "titles": {
|
||||||
|
if (toggle(player, "disabletitles")) {
|
||||||
|
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, args[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, args[0]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean toggle(PlotPlayer player, String key) {
|
||||||
|
if (player.getAttribute(key)) {
|
||||||
|
player.removeAttribute(key);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.setAttribute(key);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -143,6 +143,11 @@ public enum C {
|
|||||||
PASTE_FAILED("$2Failed to paste the selection. Reason: $2%s", "Clipboard"),
|
PASTE_FAILED("$2Failed to paste the selection. Reason: $2%s", "Clipboard"),
|
||||||
NO_CLIPBOARD("$2You don't have a selection in your clipboard", "Clipboard"),
|
NO_CLIPBOARD("$2You don't have a selection in your clipboard", "Clipboard"),
|
||||||
CLIPBOARD_INFO("$2Current Selection - Plot ID: $1%id$2, Width: $1%width$2, Total Blocks: $1%total$2", "Clipboard"),
|
CLIPBOARD_INFO("$2Current Selection - Plot ID: $1%id$2, Width: $1%width$2, Total Blocks: $1%total$2", "Clipboard"),
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
TOGGLE_ENABLED("$2Enabled setting: %s", "Toggle"),
|
||||||
|
TOGGLE_DISABLED("$2Disabled setting: %s", "Toggle"),
|
||||||
/*
|
/*
|
||||||
* Ratings
|
* Ratings
|
||||||
*/
|
*/
|
||||||
|
@ -157,18 +157,18 @@ public class BukkitPlayer implements PlotPlayer {
|
|||||||
@Override
|
@Override
|
||||||
public void setAttribute(String key) {
|
public void setAttribute(String key) {
|
||||||
key = "plotsquared_user_attributes." + key;
|
key = "plotsquared_user_attributes." + key;
|
||||||
Permission perm = Bukkit.getServer().getPluginManager().getPermission(key);
|
|
||||||
if (perm == null) {
|
|
||||||
perm = new Permission(key, PermissionDefault.FALSE);
|
|
||||||
Bukkit.getServer().getPluginManager().addPermission(perm);
|
|
||||||
Bukkit.getServer().getPluginManager().recalculatePermissionDefaults(perm);
|
|
||||||
}
|
|
||||||
EconHandler.manager.setPermission(this, key, true);
|
EconHandler.manager.setPermission(this, key, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getAttribute(String key) {
|
public boolean getAttribute(String key) {
|
||||||
key = "plotsquared_user_attributes." + key;
|
key = "plotsquared_user_attributes." + key;
|
||||||
|
Permission perm = Bukkit.getServer().getPluginManager().getPermission(key);
|
||||||
|
if (perm == null) {
|
||||||
|
perm = new Permission(key, PermissionDefault.FALSE);
|
||||||
|
Bukkit.getServer().getPluginManager().addPermission(perm);
|
||||||
|
Bukkit.getServer().getPluginManager().recalculatePermissionDefaults(perm);
|
||||||
|
}
|
||||||
return player.hasPermission(key);
|
return player.hasPermission(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user