mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-26 18:39:44 -05:00
Closed #805, Impl the ability to toggle the display per shop
This commit is contained in:
1 parent
5866103f73
commit
c7b5c8e8ce
5 files changed
+105
-7
No files matched your search
@@ -321,6 +321,11 @@ public class CommandManager implements TabCompleter, CommandExecutor {
|
||||
.permission("quickshop.taxaccount")
|
||||
.executor(new SubCommand_TaxAccount(plugin))
|
||||
.build());
|
||||
registerCmd(CommandContainer.builder()
|
||||
.prefix("toggledisplay")
|
||||
.permission("quickshop.toggledisplay")
|
||||
.executor(new SubCommand_ToggleDisplay(plugin))
|
||||
.build());
|
||||
// registerCmd(CommandContainer.builder()
|
||||
// .prefix("backup")
|
||||
// .permission("quickshop.backup")
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is SubCommand_Currency.java
|
||||
* Copyright (C) PotatoCraft Studio and contributors
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.maxgamer.quickshop.command.subcommand;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class SubCommand_ToggleDisplay implements CommandHandler<Player> {
|
||||
|
||||
private final QuickShop plugin;
|
||||
|
||||
@Override
|
||||
public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
BlockIterator bIt = new BlockIterator(sender, 10);
|
||||
|
||||
while (bIt.hasNext()) {
|
||||
final Block b = bIt.next();
|
||||
final Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
|
||||
|
||||
if (shop != null) {
|
||||
if (shop.getModerator().isModerator(sender.getUniqueId()) || QuickShop.getPermissionManager().hasPermission(sender, "quickshop.other.toggledisplay")) {
|
||||
if(shop.isDisableDisplay()){
|
||||
shop.setDisableDisplay(false);
|
||||
plugin.text().of(sender,"display-turn-on").send();
|
||||
}else{
|
||||
shop.setDisableDisplay(true);
|
||||
plugin.text().of(sender,"display-turn-off").send();
|
||||
}
|
||||
} else {
|
||||
plugin.text().of(sender, "not-managed-shop").send();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> onTabComplete(
|
||||
@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -200,6 +200,7 @@ public class ContainerShop implements Shop {
|
||||
this.disableDisplay = disabled;
|
||||
setDirty();
|
||||
update();
|
||||
checkDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -221,7 +222,7 @@ public class ContainerShop implements Shop {
|
||||
|
||||
private void initDisplayItem() {
|
||||
Util.ensureThread(false);
|
||||
if (plugin.isDisplay()) {
|
||||
if (plugin.isDisplay() && !isDisableDisplay()) {
|
||||
switch (DisplayItem.getNowUsing()) {
|
||||
case REALITEM:
|
||||
this.displayItem = new RealDisplayItem(this);
|
||||
@@ -354,8 +355,13 @@ public class ContainerShop implements Shop {
|
||||
@Override
|
||||
public void checkDisplay() {
|
||||
Util.ensureThread(false);
|
||||
if (!plugin.isDisplay() || !this.isLoaded || this
|
||||
.isDeleted()) { // FIXME: Reinit scheduler on reloading config
|
||||
if (!plugin.isDisplay() || this.disableDisplay || !this.isLoaded || this.isDeleted()) { // FIXME: Reinit scheduler on reloading config
|
||||
if(this.displayItem != null){
|
||||
if(this.displayItem.isSpawned()){
|
||||
this.displayItem.remove();
|
||||
}
|
||||
this.displayItem = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -527,9 +533,11 @@ public class ContainerShop implements Shop {
|
||||
}
|
||||
if (inventoryPreview != null) {
|
||||
inventoryPreview.close();
|
||||
inventoryPreview = null;
|
||||
}
|
||||
if (this.displayItem != null) {
|
||||
this.displayItem.remove();
|
||||
this.displayItem = null;
|
||||
}
|
||||
update();
|
||||
this.isLoaded = false;
|
||||
|
||||
@@ -177,7 +177,8 @@
|
||||
"unban": "&eUnbans a player from the shop",
|
||||
"freeze": "&eDisable or Enable shop trading",
|
||||
"lock": "&eSwitch the shop's lock status",
|
||||
"taxaccount": "&eSet the tax account that shop using"
|
||||
"taxaccount": "&eSet the tax account that shop using",
|
||||
"toggledisplay": "&eToggle the shop display item status"
|
||||
},
|
||||
"disabled": "&cThis command is disabled: &e{0}",
|
||||
"feature-not-enabled": "This feature is not enabled in the config file."
|
||||
@@ -337,5 +338,7 @@
|
||||
"client-language-unsupported": "&eQuickShop doesn't support your client language, we're fallback to {0} locale now.",
|
||||
"taxaccount-set": "&aThis shop's tax account has been set to &e{0}",
|
||||
"taxaccount-unset": "&aThis shop's tax account now following server global setting.",
|
||||
"taxaccount-invalid": "&cTarget account not invalid, please enter a valid player name or uuid(with dashes)."
|
||||
"taxaccount-invalid": "&cTarget account not invalid, please enter a valid player name or uuid(with dashes).",
|
||||
"display-turn-on": "&aSuccessfully turn on the shop display.",
|
||||
"display-turn-off": "&aSuccessfully turn off the shop display."
|
||||
}
|
||||
@@ -63,6 +63,7 @@ permissions:
|
||||
quickshop.preview: true
|
||||
quickshop.currency: true
|
||||
quickshop.taxaccount: true
|
||||
quickshop.toggledisplay: true
|
||||
quickshop.moderator:
|
||||
description: The permission that provide all moderator need have permissions
|
||||
default: op
|
||||
@@ -76,6 +77,9 @@ permissions:
|
||||
quickshop.other.changeitem: true
|
||||
quickshop.other.changeamount: true
|
||||
quickshop.other.staff: true
|
||||
quickshop.other.currency: true
|
||||
quickshop.other.taxaccount: true
|
||||
quickshop.other.toggledisplay: true
|
||||
quickshop.create.sell:
|
||||
description: Allows a player to sell from a shop.
|
||||
default: op
|
||||
@@ -212,6 +216,11 @@ permissions:
|
||||
description: Permission to use /qs taxaccount
|
||||
default: op
|
||||
quickshop.other.taxaccount:
|
||||
description: Permission to use /qs taxaccount
|
||||
description: Permission to use /qs taxaccount on others shops
|
||||
default: op
|
||||
quickshop.toggledisplay:
|
||||
description: Permission to use /qs toggledisplay
|
||||
default: op
|
||||
quickshop.other.toggledisplay:
|
||||
description: Permission to use /qs toggledisplay on others shops
|
||||
default: op
|
||||
|
||||
Reference in new issue
Block a user