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 /
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
package com.intellectualcrafters.plot.commands;
|
2014-11-05 04:42:08 +01:00
|
|
|
|
2015-01-13 17:38:15 +01:00
|
|
|
import com.intellectualcrafters.plot.config.C;
|
2015-07-03 04:11:41 +02:00
|
|
|
import com.intellectualcrafters.plot.flag.Flag;
|
|
|
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
2015-02-22 08:03:25 +01:00
|
|
|
import com.intellectualcrafters.plot.object.Location;
|
2015-01-13 17:38:15 +01:00
|
|
|
import com.intellectualcrafters.plot.object.Plot;
|
2015-07-03 04:11:41 +02:00
|
|
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
|
|
|
import com.intellectualcrafters.plot.object.PlotInventory;
|
|
|
|
import com.intellectualcrafters.plot.object.PlotItemStack;
|
2015-02-21 12:38:44 +01:00
|
|
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
2015-07-03 04:11:41 +02:00
|
|
|
import com.intellectualcrafters.plot.util.BlockManager;
|
2015-02-22 07:06:59 +01:00
|
|
|
import com.intellectualcrafters.plot.util.MainUtil;
|
2014-11-05 04:42:08 +01:00
|
|
|
|
2014-10-30 16:16:26 +01:00
|
|
|
public class MusicSubcommand extends SubCommand {
|
|
|
|
public MusicSubcommand() {
|
|
|
|
super("music", "plots.music", "Play music in plot", "music", "mus", CommandCategory.ACTIONS, true);
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2014-10-30 16:16:26 +01:00
|
|
|
@Override
|
2015-02-21 08:30:55 +01:00
|
|
|
public boolean execute(final PlotPlayer player, final String... args) {
|
2015-02-23 02:32:27 +01:00
|
|
|
final Location loc = player.getLocation();
|
2015-02-21 13:01:15 +01:00
|
|
|
final Plot plot = MainUtil.getPlot(loc);
|
2015-02-22 08:03:25 +01:00
|
|
|
if (plot == null) {
|
2015-02-22 08:26:17 +01:00
|
|
|
return !sendMessage(player, C.NOT_IN_PLOT);
|
2015-02-22 08:03:25 +01:00
|
|
|
}
|
2015-02-22 08:26:17 +01:00
|
|
|
if (!plot.isAdded(player.getUUID())) {
|
2014-10-30 16:16:26 +01:00
|
|
|
sendMessage(player, C.NO_PLOT_PERMS);
|
|
|
|
return true;
|
|
|
|
}
|
2015-07-25 09:09:47 +02:00
|
|
|
PlotInventory inv = new PlotInventory(player, 2, "Plot Jukebox") {
|
|
|
|
public boolean onClick(int index) {
|
|
|
|
PlotItemStack item = getItem(index);
|
|
|
|
if (item == null) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
int id = item.id == 7 ? 0 : item.id;
|
|
|
|
if (id == 0) {
|
|
|
|
FlagManager.removePlotFlag(plot, "music");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
FlagManager.addPlotFlag(plot, new Flag(FlagManager.getFlag("music"), id));
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
2015-07-03 04:11:41 +02:00
|
|
|
int index = 0;
|
|
|
|
for (int i = 2256; i < 2268; i++) {
|
|
|
|
String name = "&r&6" + BlockManager.manager.getClosestMatchingName(new PlotBlock((short) i, (byte) 0));
|
|
|
|
String[] lore = {"&r&aClick to play!"};
|
|
|
|
PlotItemStack item = new PlotItemStack(i, (byte) 0, 1, name, lore);
|
|
|
|
inv.setItem(index, item);
|
|
|
|
index++;
|
2014-10-30 16:16:26 +01:00
|
|
|
}
|
2015-07-05 12:51:34 +02:00
|
|
|
if (player.getMeta("music") != null) {
|
|
|
|
String name = "&r&6Cancel music";
|
|
|
|
String[] lore = {"&r&cClick to cancel!"};
|
|
|
|
inv.setItem(index, new PlotItemStack(7, (short) 0, 1, name, lore));
|
|
|
|
}
|
2015-07-03 04:11:41 +02:00
|
|
|
inv.openInventory();
|
2014-10-30 16:16:26 +01:00
|
|
|
return true;
|
|
|
|
}
|
2014-11-05 04:42:08 +01:00
|
|
|
}
|