mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-17 06:05:55 -05:00
Merge remote-tracking branch 'origin/master' into mockbukkit
# Conflicts: # src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java
This commit is contained in:
commit
8a1d7049ff
32 files changed
+1315
-1404
No files matched your search
@@ -27,16 +27,16 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Cache {
|
||||
private final QuickShop plugin;
|
||||
private final com.github.benmanes.caffeine.cache.Cache<Location, WeakReference<Shop>> accessCaching = Caffeine
|
||||
private final com.github.benmanes.caffeine.cache.Cache<Location, Shop> accessCaching = Caffeine
|
||||
.newBuilder()
|
||||
.initialCapacity(10000)
|
||||
.expireAfterAccess(120, TimeUnit.MINUTES)
|
||||
.recordStats()
|
||||
.weakValues()
|
||||
.build();
|
||||
|
||||
public Cache(QuickShop plugin) {
|
||||
@@ -57,7 +57,7 @@ public class Cache {
|
||||
*/
|
||||
@Nullable
|
||||
public Shop getCaching(@NotNull Location location, boolean includeAttached) {
|
||||
WeakReference<Shop> result = accessCaching.get(location, update -> {
|
||||
Shop result = accessCaching.get(location, update -> {
|
||||
Shop shop; //Because we need the data from Caffeine, so we cannot direct return WeakReference directly
|
||||
//Cause we will see 100% load success data :(
|
||||
if (includeAttached) {
|
||||
@@ -65,17 +65,9 @@ public class Cache {
|
||||
} else {
|
||||
shop = plugin.getShopManager().getShop(update);
|
||||
}
|
||||
if (shop == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new WeakReference<>(shop);
|
||||
}
|
||||
return shop;
|
||||
});
|
||||
if (result == null) {
|
||||
return null;
|
||||
} else {
|
||||
return result.get();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,6 +81,6 @@ public class Cache {
|
||||
accessCaching.invalidate(location);
|
||||
return;
|
||||
}
|
||||
accessCaching.put(location, new WeakReference<>(shop));
|
||||
accessCaching.put(location, shop);
|
||||
}
|
||||
}
|
||||
@@ -416,7 +416,7 @@ public class QuickShop extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RESERVE: //TODO: Remove Reserve supporting
|
||||
case RESERVE:
|
||||
core = new Economy_Reserve(this);
|
||||
Util.debugLog("Now using the Reserve economy system.");
|
||||
break;
|
||||
@@ -425,7 +425,7 @@ public class QuickShop extends JavaPlugin {
|
||||
Util.debugLog("Now using the GemsEconomy economy system.");
|
||||
break;
|
||||
case TNE:
|
||||
core = new Economy_TNE(this); //TODO: Unstable
|
||||
core = new Economy_TNE(this);
|
||||
Util.debugLog("Now using the TNE economy system.");
|
||||
break;
|
||||
// case MIXED:
|
||||
@@ -524,10 +524,10 @@ public class QuickShop extends JavaPlugin {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
getDataFolder().mkdirs();
|
||||
// replaceLogger();
|
||||
if (getConfig().getBoolean("debug.adventure", false)) {
|
||||
System.setProperty("net.kyori.adventure.debug", "true");
|
||||
getLogger().warning("Adventure debug flag was set! You can disable this anytime in config by set `debug.adventure` to false.");
|
||||
}
|
||||
// if (getConfig().getBoolean("debug.adventure", false)) {
|
||||
// System.setProperty("net.kyori.adventure.debug", "true");
|
||||
// getLogger().warning("Adventure debug flag was set! You can disable this anytime in config by set `debug.adventure` to false.");
|
||||
// }
|
||||
this.bootError = null;
|
||||
getLogger().info("Loading up integration modules.");
|
||||
this.integrationHelper = new IntegrationHelper(this);
|
||||
@@ -808,7 +808,7 @@ public class QuickShop extends JavaPlugin {
|
||||
Bukkit.getPluginManager().registerEvents(internalListener, this);
|
||||
if (isDisplay() && DisplayItem.getNowUsing() != DisplayType.VIRTUALITEM) {
|
||||
displayWatcher = new DisplayWatcher(this);
|
||||
new DisplayBugFixListener(this).register();
|
||||
// new DisplayBugFixListener(this).register();
|
||||
new DisplayProtectionListener(this, this.shopCache).register();
|
||||
if (Bukkit.getPluginManager().getPlugin("ClearLag") != null) {
|
||||
new ClearLaggListener(this).register();
|
||||
@@ -1723,7 +1723,13 @@ public class QuickShop extends JavaPlugin {
|
||||
getConfig().set("plugin.BKCommonLib", true);
|
||||
getConfig().set("config-version", ++selectedVersion);
|
||||
}
|
||||
|
||||
if (selectedVersion == 125) {
|
||||
getConfig().set("integration.superiorskyblock.enable", false);
|
||||
getConfig().set("integration.superiorskyblock.owner-create-only", false);
|
||||
getConfig().set("integration.superiorskyblock.delete-shop-on-member-leave", true);
|
||||
getConfig().set("shop.interact.swap-click-behavior", false);
|
||||
getConfig().set("config-version", ++selectedVersion);
|
||||
}
|
||||
|
||||
if (getConfig().getInt("matcher.work-type") != 0 && GameVersion.get(ReflectFactory.getServerVersion()).name().contains("1_16")) {
|
||||
getLogger().warning("You are not using QS Matcher, it may meeting item comparing issue mentioned there: https://hub.spigotmc.org/jira/browse/SPIGOT-5063");
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package org.maxgamer.quickshop.chat;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.chat.platform.minedown.AdventureQuickChat;
|
||||
import org.maxgamer.quickshop.chat.platform.minedown.BungeeQuickChat;
|
||||
|
||||
public enum QuickChatType {
|
||||
@@ -28,8 +27,8 @@ public enum QuickChatType {
|
||||
* BUNGEECHAT = Use the chat lib that Spigot offered.
|
||||
* ADVENTURE = Use the chat lib Adventure, it can resolve player disconnected issue but have no message output bug.
|
||||
*/
|
||||
BUNGEECHAT(0),
|
||||
ADVENTURE(1);
|
||||
BUNGEECHAT(0);
|
||||
//ADVENTURE(1);
|
||||
|
||||
private final int id;
|
||||
|
||||
@@ -51,17 +50,17 @@ public enum QuickChatType {
|
||||
}
|
||||
|
||||
public static QuickChat createById(int id) {
|
||||
QuickChatType type = fromID(id);
|
||||
if (type == QuickChatType.ADVENTURE) {
|
||||
return new AdventureQuickChat();
|
||||
}
|
||||
// QuickChatType type = fromID(id);
|
||||
// if (type == QuickChatType.ADVENTURE) {
|
||||
// return new AdventureQuickChat();
|
||||
// }
|
||||
return new BungeeQuickChat();
|
||||
}
|
||||
|
||||
public static QuickChat createByType(QuickChatType type) {
|
||||
if (type == QuickChatType.ADVENTURE) {
|
||||
return new AdventureQuickChat();
|
||||
}
|
||||
// if (type == QuickChatType.ADVENTURE) {
|
||||
// return new AdventureQuickChat();
|
||||
// }
|
||||
return new BungeeQuickChat();
|
||||
}
|
||||
|
||||
|
||||
+127
-128
@@ -1,128 +1,127 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is AdventureQuickChat.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.chat.platform.minedown;
|
||||
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.nbt.api.BinaryTagHolder;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.chat.QuickChat;
|
||||
import org.maxgamer.quickshop.chat.QuickComponent;
|
||||
import org.maxgamer.quickshop.chat.QuickComponentImpl;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.ItemNMS;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class AdventureQuickChat implements QuickChat {
|
||||
private final QuickShop plugin = QuickShop.getInstance();
|
||||
private final BukkitAudiences audiences = BukkitAudiences.create(QuickShop.getInstance());
|
||||
|
||||
@Override
|
||||
public void send(@NotNull CommandSender receiver, @Nullable String message) {
|
||||
if (StringUtils.isEmpty(message)) {
|
||||
return;
|
||||
}
|
||||
audiences.sender(receiver).sendMessage(LegacyComponentSerializer.legacySection().deserialize(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(@NotNull CommandSender receiver, @Nullable QuickComponent component) {
|
||||
if (component == null) {
|
||||
return;
|
||||
}
|
||||
if ((component.get() instanceof ComponentLike)) {
|
||||
audiences.sender(receiver).sendMessage(Identity.nil(), (ComponentLike) component.get());
|
||||
return;
|
||||
}
|
||||
Util.debugLog("Illegal component " + component.get().getClass().getName() + " sending to " + this.getClass().getName() + " processor, rejected.");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendItemHologramChat(@NotNull Player player, @NotNull String left, @NotNull ItemStack itemStack, @NotNull String right) {
|
||||
audiences.player(player).sendMessage((Component) getItemTextComponent(itemStack, player, left + Util.getItemStackName(itemStack) + right).get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull QuickComponent getItemHologramChat(@NotNull Shop shop, @NotNull ItemStack itemStack, @NotNull Player player, @NotNull String message) {
|
||||
Component component = (Component) getItemTextComponent(itemStack, player, message).get();
|
||||
if (QuickShop.getPermissionManager().hasPermission(player, "quickshop.preview")) {
|
||||
component = component.clickEvent(ClickEvent.runCommand(MsgUtil.fillArgs(
|
||||
"/qs silentpreview {0}",
|
||||
shop.getRuntimeRandomUniqueId().toString())));
|
||||
}
|
||||
return new QuickComponentImpl(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull QuickComponent getItemTextComponent(@NotNull ItemStack itemStack, @NotNull Player player, @NotNull String normalText) {
|
||||
TextComponent errorComponent = Component.text(MsgUtil.getMessage("menu.item-holochat-error", player));
|
||||
try {
|
||||
String json = ItemNMS.saveJsonfromNMS(itemStack);
|
||||
if (json != null) {
|
||||
return new QuickComponentImpl(Component
|
||||
.text(normalText + " " + MsgUtil.getMessage("menu.preview", player))
|
||||
.hoverEvent(HoverEvent.showItem(Key.key(itemStack.getType().getKey().toString())
|
||||
, itemStack.getAmount(), BinaryTagHolder.of(json))));
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Failed to saving item to json for holochat", throwable);
|
||||
}
|
||||
return new QuickComponentImpl(errorComponent);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendExecutableChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command) {
|
||||
TextComponent component = Component.text(MsgUtil.getMessage("tableformat.left_begin", receiver) + message)
|
||||
.color(NamedTextColor.DARK_PURPLE)
|
||||
.clickEvent(ClickEvent.runCommand(command))
|
||||
.hoverEvent(HoverEvent.showText(Component.text(hoverText)));
|
||||
|
||||
audiences.sender(receiver).sendMessage(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSuggestedChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command) {
|
||||
TextComponent component = Component.text(MsgUtil.getMessage("tableformat.left_begin", receiver) + message)
|
||||
.color(NamedTextColor.DARK_PURPLE)
|
||||
.clickEvent(ClickEvent.suggestCommand(command))
|
||||
.hoverEvent(HoverEvent.showText(Component.text(hoverText)));
|
||||
audiences.sender(receiver).sendMessage(component);
|
||||
}
|
||||
|
||||
}
|
||||
///*
|
||||
// * This file is a part of project QuickShop, the name is AdventureQuickChat.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.chat.platform.minedown;
|
||||
//
|
||||
//import net.kyori.adventure.identity.Identity;
|
||||
//import net.kyori.adventure.key.Key;
|
||||
//import net.kyori.adventure.nbt.api.BinaryTagHolder;
|
||||
//import net.kyori.adventure.text.Component;
|
||||
//import net.kyori.adventure.text.ComponentLike;
|
||||
//import net.kyori.adventure.text.TextComponent;
|
||||
//import net.kyori.adventure.text.event.ClickEvent;
|
||||
//import net.kyori.adventure.text.event.HoverEvent;
|
||||
//import net.kyori.adventure.text.format.NamedTextColor;
|
||||
//import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
//import org.apache.commons.lang.StringUtils;
|
||||
//import org.bukkit.command.CommandSender;
|
||||
//import org.bukkit.entity.Player;
|
||||
//import org.bukkit.inventory.ItemStack;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//import org.maxgamer.quickshop.QuickShop;
|
||||
//import org.maxgamer.quickshop.chat.QuickChat;
|
||||
//import org.maxgamer.quickshop.chat.QuickComponent;
|
||||
//import org.maxgamer.quickshop.chat.QuickComponentImpl;
|
||||
//import org.maxgamer.quickshop.shop.Shop;
|
||||
//import org.maxgamer.quickshop.util.ItemNMS;
|
||||
//import org.maxgamer.quickshop.util.MsgUtil;
|
||||
//import org.maxgamer.quickshop.util.Util;
|
||||
//
|
||||
//import java.util.logging.Level;
|
||||
//
|
||||
//public class AdventureQuickChat implements QuickChat {
|
||||
// private final QuickShop plugin = QuickShop.getInstance();
|
||||
// private final BukkitAudiences audiences = BukkitAudiences.create(QuickShop.getInstance());
|
||||
//
|
||||
// @Override
|
||||
// public void send(@NotNull CommandSender receiver, @Nullable String message) {
|
||||
// if (StringUtils.isEmpty(message)) {
|
||||
// return;
|
||||
// }
|
||||
// audiences.sender(receiver).sendMessage(LegacyComponentSerializer.legacySection().deserialize(message));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void send(@NotNull CommandSender receiver, @Nullable QuickComponent component) {
|
||||
// if (component == null) {
|
||||
// return;
|
||||
// }
|
||||
// if ((component.get() instanceof ComponentLike)) {
|
||||
// audiences.sender(receiver).sendMessage(Identity.nil(), (ComponentLike) component.get());
|
||||
// return;
|
||||
// }
|
||||
// Util.debugLog("Illegal component " + component.get().getClass().getName() + " sending to " + this.getClass().getName() + " processor, rejected.");
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void sendItemHologramChat(@NotNull Player player, @NotNull String left, @NotNull ItemStack itemStack, @NotNull String right) {
|
||||
// audiences.player(player).sendMessage((Component) getItemTextComponent(itemStack, player, left + Util.getItemStackName(itemStack) + right).get());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull QuickComponent getItemHologramChat(@NotNull Shop shop, @NotNull ItemStack itemStack, @NotNull Player player, @NotNull String message) {
|
||||
// Component component = (Component) getItemTextComponent(itemStack, player, message).get();
|
||||
// if (QuickShop.getPermissionManager().hasPermission(player, "quickshop.preview")) {
|
||||
// component = component.clickEvent(ClickEvent.runCommand(MsgUtil.fillArgs(
|
||||
// "/qs silentpreview {0}",
|
||||
// shop.getRuntimeRandomUniqueId().toString())));
|
||||
// }
|
||||
// return new QuickComponentImpl(component);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull QuickComponent getItemTextComponent(@NotNull ItemStack itemStack, @NotNull Player player, @NotNull String normalText) {
|
||||
// TextComponent errorComponent = Component.text(MsgUtil.getMessage("menu.item-holochat-error", player));
|
||||
// try {
|
||||
// String json = ItemNMS.saveJsonfromNMS(itemStack);
|
||||
// if (json != null) {
|
||||
// return new QuickComponentImpl(Component
|
||||
// .text(normalText + " " + MsgUtil.getMessage("menu.preview", player))
|
||||
// .hoverEvent(HoverEvent.showItem(Key.key(itemStack.getType().getKey().toString())
|
||||
// , itemStack.getAmount(), BinaryTagHolder.of(json))));
|
||||
// }
|
||||
// } catch (Throwable throwable) {
|
||||
// plugin.getLogger().log(Level.SEVERE, "Failed to saving item to json for holochat", throwable);
|
||||
// }
|
||||
// return new QuickComponentImpl(errorComponent);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void sendExecutableChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command) {
|
||||
// TextComponent component = Component.text(MsgUtil.getMessage("tableformat.left_begin", receiver) + message)
|
||||
// .color(NamedTextColor.DARK_PURPLE)
|
||||
// .clickEvent(ClickEvent.runCommand(command))
|
||||
// .hoverEvent(HoverEvent.showText(Component.text(hoverText)));
|
||||
//
|
||||
// audiences.sender(receiver).sendMessage(component);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void sendSuggestedChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command) {
|
||||
// TextComponent component = Component.text(MsgUtil.getMessage("tableformat.left_begin", receiver) + message)
|
||||
// .color(NamedTextColor.DARK_PURPLE)
|
||||
// .clickEvent(ClickEvent.suggestCommand(command))
|
||||
// .hoverEvent(HoverEvent.showText(Component.text(hoverText)));
|
||||
// audiences.sender(receiver).sendMessage(component);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -100,7 +100,16 @@ public class SubCommand_Create implements CommandProcesser {
|
||||
MsgUtil.sendMessage(sender, MsgUtil.getMessage("item-not-exist", sender, cmdArg[1]));
|
||||
return;
|
||||
}
|
||||
item = new ItemStack(material, 1);
|
||||
if (cmdArg.length > 2 && QuickShop.getPermissionManager().hasPermission(sender, "quicshop.create.stack") && plugin.isAllowStack()) {
|
||||
try {
|
||||
int amount = Integer.parseInt(cmdArg[2]);
|
||||
item = new ItemStack(material, amount);
|
||||
} catch (NumberFormatException e) {
|
||||
item = new ItemStack(material, 1);
|
||||
}
|
||||
} else {
|
||||
item = new ItemStack(material, 1);
|
||||
}
|
||||
}
|
||||
Util.debugLog("Pending task for material: " + item.toString());
|
||||
|
||||
@@ -169,6 +178,9 @@ public class SubCommand_Create implements CommandProcesser {
|
||||
if (cmdArg.length == 2) {
|
||||
return Collections.singletonList(MsgUtil.getMessage("tabcomplete.item", sender));
|
||||
}
|
||||
if (cmdArg.length == 3) {
|
||||
return Collections.singletonList(MsgUtil.getMessage("tabcomplete.amount", sender));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,7 @@ import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* @author creatorfromhell
|
||||
* @deprecated Reserve no-longer active after Minecraft 1.14.
|
||||
*/
|
||||
@Deprecated
|
||||
public class Economy_Reserve implements EconomyCore {
|
||||
|
||||
private static final String errorMsg =
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ShopTaxEvent extends QSEvent {
|
||||
/**
|
||||
* Sets the new tax in purchase
|
||||
*
|
||||
* @return new tax
|
||||
* @param tax New tax
|
||||
*/
|
||||
public void setTax(double tax) {
|
||||
this.tax = tax;
|
||||
|
||||
@@ -1,265 +1,265 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is FileEnvelope.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.fileportlek.old;
|
||||
|
||||
import lombok.ToString;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.mock.MckFileConfiguration;
|
||||
import org.maxgamer.quickshop.util.Copied;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
import org.maxgamer.quickshop.util.location.LocationOf;
|
||||
import org.maxgamer.quickshop.util.location.StringOf;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
@ToString
|
||||
public abstract class FileEnvelope implements IFile {
|
||||
|
||||
@NotNull
|
||||
protected final File file;
|
||||
|
||||
protected final boolean loadDefault;
|
||||
|
||||
@NotNull
|
||||
protected final Plugin plugin;
|
||||
@NotNull
|
||||
protected final String resourcePath;
|
||||
@NotNull
|
||||
private final Copied copied;
|
||||
@NotNull
|
||||
protected FileConfiguration fileConfiguration = new MckFileConfiguration();
|
||||
|
||||
public FileEnvelope(@NotNull Plugin plugin, @NotNull File file, @NotNull String resourcePath, boolean loadDefault) {
|
||||
this.plugin = plugin;
|
||||
this.file = file;
|
||||
this.copied = new Copied(file);
|
||||
this.resourcePath = resourcePath;
|
||||
this.loadDefault = loadDefault;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
if (file.exists()) {
|
||||
reload();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final File parent = file.getParentFile();
|
||||
|
||||
if (parent != null) {
|
||||
parent.mkdirs();
|
||||
}
|
||||
|
||||
file.createNewFile();
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
|
||||
if (loadDefault) {
|
||||
copied.accept(getInputStream());
|
||||
}
|
||||
|
||||
reload();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return Objects.requireNonNull(plugin.getResource(resourcePath));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
try {
|
||||
if (fileConfiguration instanceof MckFileConfiguration) {
|
||||
reload();
|
||||
}
|
||||
fileConfiguration.save(file);
|
||||
} catch (Exception exception) {
|
||||
throw new IllegalStateException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String saveToString() {
|
||||
return fileConfiguration.saveToString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFromString(@NotNull String data) throws InvalidConfigurationException {
|
||||
fileConfiguration.loadFromString(data);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object get(@NotNull String path) {
|
||||
return fileConfiguration.get(path);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object get(@NotNull String path, @Nullable Object fallback) {
|
||||
final Object object = fileConfiguration.get(path, fallback);
|
||||
|
||||
if (object == null) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getOrSet(@NotNull String path, @NotNull T fallback) {
|
||||
final T object = (T) fileConfiguration.get(path, null);
|
||||
|
||||
if (object != null) {
|
||||
return object;
|
||||
}
|
||||
|
||||
set(path, fallback);
|
||||
|
||||
return fallback;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Location getLocation(@NotNull String path) {
|
||||
return new LocationOf(getString(path).orElse("")).value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(@NotNull String path, @NotNull Location location) {
|
||||
set(path, new StringOf(location).asString());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack getCustomItemStack(@NotNull String path) {
|
||||
try {
|
||||
ItemStack deserialize = Util.deserialize(path);
|
||||
if (deserialize != null) {
|
||||
return deserialize;
|
||||
}
|
||||
return new ItemStack(Material.AIR);
|
||||
} catch (Exception exception) {
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomItemStack(@NotNull String path, @NotNull ItemStack itemStack) {
|
||||
fileConfiguration.set(path, Util.serialize(itemStack));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Optional<String> getString(@NotNull String path) {
|
||||
return Optional.ofNullable(fileConfiguration.getString(path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(@NotNull String path, @Nullable Object object) {
|
||||
fileConfiguration.set(path, object);
|
||||
save();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> getStringList(@NotNull String path) {
|
||||
return fileConfiguration.getStringList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(@NotNull String path) {
|
||||
return fileConfiguration.getInt(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(@NotNull String path) {
|
||||
return fileConfiguration.getDouble(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(@NotNull String path) {
|
||||
return fileConfiguration.getLong(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getByte(@NotNull String path) {
|
||||
return (byte) fileConfiguration.getInt(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(@NotNull String path) {
|
||||
return (short) fileConfiguration.getInt(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(@NotNull String path) {
|
||||
return fileConfiguration.getBoolean(path);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ConfigurationSection createSection(@NotNull String path) {
|
||||
final ConfigurationSection configurationSection = fileConfiguration.createSection(path);
|
||||
|
||||
save();
|
||||
|
||||
return configurationSection;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ConfigurationSection getSection(@NotNull String path) {
|
||||
final ConfigurationSection configurationSection = fileConfiguration.getConfigurationSection(path);
|
||||
|
||||
return configurationSection == null ? new MckFileConfiguration() : configurationSection;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ConfigurationSection getOrCreateSection(@NotNull String path) {
|
||||
ConfigurationSection section = getSection(path);
|
||||
|
||||
if (section instanceof MckFileConfiguration) {
|
||||
section = createSection(path);
|
||||
}
|
||||
|
||||
return section;
|
||||
}
|
||||
|
||||
}
|
||||
///*
|
||||
// * This file is a part of project QuickShop, the name is FileEnvelope.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.fileportlek.old;
|
||||
//
|
||||
//import lombok.ToString;
|
||||
//import org.bukkit.Location;
|
||||
//import org.bukkit.Material;
|
||||
//import org.bukkit.configuration.ConfigurationSection;
|
||||
//import org.bukkit.configuration.InvalidConfigurationException;
|
||||
//import org.bukkit.configuration.file.FileConfiguration;
|
||||
//import org.bukkit.inventory.ItemStack;
|
||||
//import org.bukkit.plugin.Plugin;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//import org.maxgamer.quickshop.mock.MckFileConfiguration;
|
||||
//import org.maxgamer.quickshop.util.Copied;
|
||||
//import org.maxgamer.quickshop.util.Util;
|
||||
//import org.maxgamer.quickshop.util.location.LocationOf;
|
||||
//import org.maxgamer.quickshop.util.location.StringOf;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.InputStream;
|
||||
//import java.util.List;
|
||||
//import java.util.Objects;
|
||||
//import java.util.Optional;
|
||||
//
|
||||
//@ToString
|
||||
//public abstract class FileEnvelope implements IFile {
|
||||
//
|
||||
// @NotNull
|
||||
// protected final File file;
|
||||
//
|
||||
// protected final boolean loadDefault;
|
||||
//
|
||||
// @NotNull
|
||||
// protected final Plugin plugin;
|
||||
// @NotNull
|
||||
// protected final String resourcePath;
|
||||
// @NotNull
|
||||
// private final Copied copied;
|
||||
// @NotNull
|
||||
// protected FileConfiguration fileConfiguration = new MckFileConfiguration();
|
||||
//
|
||||
// public FileEnvelope(@NotNull Plugin plugin, @NotNull File file, @NotNull String resourcePath, boolean loadDefault) {
|
||||
// this.plugin = plugin;
|
||||
// this.file = file;
|
||||
// this.copied = new Copied(file);
|
||||
// this.resourcePath = resourcePath;
|
||||
// this.loadDefault = loadDefault;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void create() {
|
||||
// if (file.exists()) {
|
||||
// reload();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// final File parent = file.getParentFile();
|
||||
//
|
||||
// if (parent != null) {
|
||||
// parent.mkdirs();
|
||||
// }
|
||||
//
|
||||
// file.createNewFile();
|
||||
// } catch (Exception exception) {
|
||||
// throw new RuntimeException(exception);
|
||||
// }
|
||||
//
|
||||
// if (loadDefault) {
|
||||
// copied.accept(getInputStream());
|
||||
// }
|
||||
//
|
||||
// reload();
|
||||
// }
|
||||
//
|
||||
// @NotNull
|
||||
// @Override
|
||||
// public InputStream getInputStream() {
|
||||
// return Objects.requireNonNull(plugin.getResource(resourcePath));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void save() {
|
||||
// try {
|
||||
// if (fileConfiguration instanceof MckFileConfiguration) {
|
||||
// reload();
|
||||
// }
|
||||
// fileConfiguration.save(file);
|
||||
// } catch (Exception exception) {
|
||||
// throw new IllegalStateException(exception);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @NotNull
|
||||
// @Override
|
||||
// public String saveToString() {
|
||||
// return fileConfiguration.saveToString();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void loadFromString(@NotNull String data) throws InvalidConfigurationException {
|
||||
// fileConfiguration.loadFromString(data);
|
||||
// }
|
||||
//
|
||||
// @Nullable
|
||||
// @Override
|
||||
// public Object get(@NotNull String path) {
|
||||
// return fileConfiguration.get(path);
|
||||
// }
|
||||
//
|
||||
// @Nullable
|
||||
// @Override
|
||||
// public Object get(@NotNull String path, @Nullable Object fallback) {
|
||||
// final Object object = fileConfiguration.get(path, fallback);
|
||||
//
|
||||
// if (object == null) {
|
||||
// return fallback;
|
||||
// }
|
||||
//
|
||||
// return object;
|
||||
// }
|
||||
//
|
||||
// @NotNull
|
||||
// @Override
|
||||
// @SuppressWarnings("unchecked")
|
||||
// public <T> T getOrSet(@NotNull String path, @NotNull T fallback) {
|
||||
// final T object = (T) fileConfiguration.get(path, null);
|
||||
//
|
||||
// if (object != null) {
|
||||
// return object;
|
||||
// }
|
||||
//
|
||||
// set(path, fallback);
|
||||
//
|
||||
// return fallback;
|
||||
// }
|
||||
//
|
||||
// @NotNull
|
||||
// @Override
|
||||
// public Location getLocation(@NotNull String path) {
|
||||
// return new LocationOf(getString(path).orElse("")).value();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setLocation(@NotNull String path, @NotNull Location location) {
|
||||
// set(path, new StringOf(location).asString());
|
||||
// }
|
||||
//
|
||||
// @NotNull
|
||||
// @Override
|
||||
// public ItemStack getCustomItemStack(@NotNull String path) {
|
||||
// try {
|
||||
// ItemStack deserialize = Util.deserialize(path);
|
||||
// if (deserialize != null) {
|
||||
// return deserialize;
|
||||
// }
|
||||
// return new ItemStack(Material.AIR);
|
||||
// } catch (Exception exception) {
|
||||
// return new ItemStack(Material.AIR);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setCustomItemStack(@NotNull String path, @NotNull ItemStack itemStack) {
|
||||
// fileConfiguration.set(path, Util.serialize(itemStack));
|
||||
// }
|
||||
//
|
||||
// @NotNull
|
||||
// @Override
|
||||
// public Optional<String> getString(@NotNull String path) {
|
||||
// return Optional.ofNullable(fileConfiguration.getString(path));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void set(@NotNull String path, @Nullable Object object) {
|
||||
// fileConfiguration.set(path, object);
|
||||
// save();
|
||||
// }
|
||||
//
|
||||
// @NotNull
|
||||
// @Override
|
||||
// public List<String> getStringList(@NotNull String path) {
|
||||
// return fileConfiguration.getStringList(path);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getInt(@NotNull String path) {
|
||||
// return fileConfiguration.getInt(path);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public double getDouble(@NotNull String path) {
|
||||
// return fileConfiguration.getDouble(path);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public long getLong(@NotNull String path) {
|
||||
// return fileConfiguration.getLong(path);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public byte getByte(@NotNull String path) {
|
||||
// return (byte) fileConfiguration.getInt(path);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public short getShort(@NotNull String path) {
|
||||
// return (short) fileConfiguration.getInt(path);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean getBoolean(@NotNull String path) {
|
||||
// return fileConfiguration.getBoolean(path);
|
||||
// }
|
||||
//
|
||||
// @NotNull
|
||||
// @Override
|
||||
// public ConfigurationSection createSection(@NotNull String path) {
|
||||
// final ConfigurationSection configurationSection = fileConfiguration.createSection(path);
|
||||
//
|
||||
// save();
|
||||
//
|
||||
// return configurationSection;
|
||||
// }
|
||||
//
|
||||
// @NotNull
|
||||
// @Override
|
||||
// public ConfigurationSection getSection(@NotNull String path) {
|
||||
// final ConfigurationSection configurationSection = fileConfiguration.getConfigurationSection(path);
|
||||
//
|
||||
// return configurationSection == null ? new MckFileConfiguration() : configurationSection;
|
||||
// }
|
||||
//
|
||||
// @NotNull
|
||||
// @Override
|
||||
// public ConfigurationSection getOrCreateSection(@NotNull String path) {
|
||||
// ConfigurationSection section = getSection(path);
|
||||
//
|
||||
// if (section instanceof MckFileConfiguration) {
|
||||
// section = createSection(path);
|
||||
// }
|
||||
//
|
||||
// return section;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -1,224 +1,224 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is IFile.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.fileportlek.old;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.mock.MckFileConfiguration;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface IFile {
|
||||
|
||||
/**
|
||||
* Creates yml file on the path
|
||||
*/
|
||||
void create();
|
||||
|
||||
@NotNull InputStream getInputStream();
|
||||
|
||||
/**
|
||||
* Reloads file
|
||||
*/
|
||||
void reload();
|
||||
|
||||
/**
|
||||
* Saves file
|
||||
*/
|
||||
void save();
|
||||
|
||||
/**
|
||||
* @return the string of the file
|
||||
*/
|
||||
@NotNull String saveToString();
|
||||
|
||||
/**
|
||||
* Loads from the data
|
||||
*
|
||||
* @param data the data
|
||||
* @throws InvalidConfigurationException if config is invalid
|
||||
*/
|
||||
void loadFromString(@NotNull String data) throws InvalidConfigurationException;
|
||||
|
||||
/**
|
||||
* Gets the object
|
||||
*
|
||||
* @param path object path to get
|
||||
* @return if path does not exist returns null
|
||||
*/
|
||||
@Nullable Object get(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the object with fallback
|
||||
*
|
||||
* @param path object path to get
|
||||
* @param fallback fallback object to get if path does not exist
|
||||
* @return if path does not exist returns fallback object
|
||||
*/
|
||||
@Nullable Object get(@NotNull String path, @Nullable Object fallback);
|
||||
|
||||
/**
|
||||
* Gets or sets the object
|
||||
*
|
||||
* @param path object path to get
|
||||
* @param fallback fallback object to get if path does not exist
|
||||
* @param <T> object type
|
||||
* @return if path does not exist returns and set the path with fallback object
|
||||
*/
|
||||
@NotNull <T> T getOrSet(@NotNull String path, @NotNull T fallback);
|
||||
|
||||
/**
|
||||
* Gets location
|
||||
*
|
||||
* @param path location path to get
|
||||
* @return {@link Location}
|
||||
*/
|
||||
@NotNull Location getLocation(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Sets location into the path
|
||||
*
|
||||
* @param path location path to set
|
||||
* @param location {@link Location}
|
||||
*/
|
||||
void setLocation(@NotNull String path, @NotNull Location location);
|
||||
|
||||
/**
|
||||
* Pattern:
|
||||
*
|
||||
* <p>path: (material): 'DIAMOND' [amount]: 1 [data]: 0 [display-name]: 'Diamond Sword'
|
||||
* [enchants]: DAMAGE_ALL: 10 FIRE_ASPECT: 2 [lore]: - 'Lore 1' - 'Lore 2'
|
||||
*
|
||||
* @param path itemstack path to get
|
||||
* @return {@link ItemStack}
|
||||
*/
|
||||
@NotNull ItemStack getCustomItemStack(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Sets custom itemstack to path
|
||||
*
|
||||
* @param path itemstack path to set
|
||||
* @param itemStack {@link ItemStack}
|
||||
*/
|
||||
void setCustomItemStack(@NotNull String path, @NotNull ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Gets string
|
||||
*
|
||||
* @param path string path to get
|
||||
* @return {@link String}
|
||||
*/
|
||||
@NotNull Optional<String> getString(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Sets object to path
|
||||
*
|
||||
* @param path object path to set
|
||||
* @param object {@link Object}
|
||||
*/
|
||||
void set(@NotNull String path, @Nullable Object object);
|
||||
|
||||
/**
|
||||
* Gets string list
|
||||
*
|
||||
* @param path string list path to get
|
||||
* @return string list
|
||||
*/
|
||||
@NotNull List<String> getStringList(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets int
|
||||
*
|
||||
* @param path integer path to get
|
||||
* @return {@link Integer}
|
||||
*/
|
||||
int getInt(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets double
|
||||
*
|
||||
* @param path double path to get
|
||||
* @return {@link Double}
|
||||
*/
|
||||
double getDouble(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets long
|
||||
*
|
||||
* @param path long path to get
|
||||
* @return {@link Integer}
|
||||
*/
|
||||
long getLong(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets byte
|
||||
*
|
||||
* @param path byte path to get
|
||||
* @return {@link Byte}
|
||||
*/
|
||||
byte getByte(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets short
|
||||
*
|
||||
* @param path short path to get
|
||||
* @return {@link Short}
|
||||
*/
|
||||
short getShort(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets boolean
|
||||
*
|
||||
* @param path boolean path to get
|
||||
* @return {@link Boolean}
|
||||
*/
|
||||
boolean getBoolean(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Creates configuration section into path
|
||||
*
|
||||
* @param path configuration section path to create
|
||||
* @return {@link ConfigurationSection}
|
||||
*/
|
||||
@NotNull ConfigurationSection createSection(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets configuration section from path
|
||||
*
|
||||
* @param path configurations section path to get
|
||||
* @return if there isn't section returns {@link MckFileConfiguration}
|
||||
*/
|
||||
@NotNull ConfigurationSection getSection(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets configuration section from path if there is no section It will create
|
||||
*
|
||||
* @param path configurations section path to get
|
||||
* @return {@link ConfigurationSection}
|
||||
*/
|
||||
@NotNull ConfigurationSection getOrCreateSection(@NotNull String path);
|
||||
|
||||
}
|
||||
///*
|
||||
// * This file is a part of project QuickShop, the name is IFile.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.fileportlek.old;
|
||||
//
|
||||
//import org.bukkit.Location;
|
||||
//import org.bukkit.configuration.ConfigurationSection;
|
||||
//import org.bukkit.configuration.InvalidConfigurationException;
|
||||
//import org.bukkit.inventory.ItemStack;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//import org.maxgamer.quickshop.mock.MckFileConfiguration;
|
||||
//
|
||||
//import java.io.InputStream;
|
||||
//import java.util.List;
|
||||
//import java.util.Optional;
|
||||
//
|
||||
//public interface IFile {
|
||||
//
|
||||
// /**
|
||||
// * Creates yml file on the path
|
||||
// */
|
||||
// void create();
|
||||
//
|
||||
// @NotNull InputStream getInputStream();
|
||||
//
|
||||
// /**
|
||||
// * Reloads file
|
||||
// */
|
||||
// void reload();
|
||||
//
|
||||
// /**
|
||||
// * Saves file
|
||||
// */
|
||||
// void save();
|
||||
//
|
||||
// /**
|
||||
// * @return the string of the file
|
||||
// */
|
||||
// @NotNull String saveToString();
|
||||
//
|
||||
// /**
|
||||
// * Loads from the data
|
||||
// *
|
||||
// * @param data the data
|
||||
// * @throws InvalidConfigurationException if config is invalid
|
||||
// */
|
||||
// void loadFromString(@NotNull String data) throws InvalidConfigurationException;
|
||||
//
|
||||
// /**
|
||||
// * Gets the object
|
||||
// *
|
||||
// * @param path object path to get
|
||||
// * @return if path does not exist returns null
|
||||
// */
|
||||
// @Nullable Object get(@NotNull String path);
|
||||
//
|
||||
// /**
|
||||
// * Gets the object with fallback
|
||||
// *
|
||||
// * @param path object path to get
|
||||
// * @param fallback fallback object to get if path does not exist
|
||||
// * @return if path does not exist returns fallback object
|
||||
// */
|
||||
// @Nullable Object get(@NotNull String path, @Nullable Object fallback);
|
||||
//
|
||||
// /**
|
||||
// * Gets or sets the object
|
||||
// *
|
||||
// * @param path object path to get
|
||||
// * @param fallback fallback object to get if path does not exist
|
||||
// * @param <T> object type
|
||||
// * @return if path does not exist returns and set the path with fallback object
|
||||
// */
|
||||
// @NotNull <T> T getOrSet(@NotNull String path, @NotNull T fallback);
|
||||
//
|
||||
// /**
|
||||
// * Gets location
|
||||
// *
|
||||
// * @param path location path to get
|
||||
// * @return {@link Location}
|
||||
// */
|
||||
// @NotNull Location getLocation(@NotNull String path);
|
||||
//
|
||||
// /**
|
||||
// * Sets location into the path
|
||||
// *
|
||||
// * @param path location path to set
|
||||
// * @param location {@link Location}
|
||||
// */
|
||||
// void setLocation(@NotNull String path, @NotNull Location location);
|
||||
//
|
||||
// /**
|
||||
// * Pattern:
|
||||
// *
|
||||
// * <p>path: (material): 'DIAMOND' [amount]: 1 [data]: 0 [display-name]: 'Diamond Sword'
|
||||
// * [enchants]: DAMAGE_ALL: 10 FIRE_ASPECT: 2 [lore]: - 'Lore 1' - 'Lore 2'
|
||||
// *
|
||||
// * @param path itemstack path to get
|
||||
// * @return {@link ItemStack}
|
||||
// */
|
||||
// @NotNull ItemStack getCustomItemStack(@NotNull String path);
|
||||
//
|
||||
// /**
|
||||
// * Sets custom itemstack to path
|
||||
// *
|
||||
// * @param path itemstack path to set
|
||||
// * @param itemStack {@link ItemStack}
|
||||
// */
|
||||
// void setCustomItemStack(@NotNull String path, @NotNull ItemStack itemStack);
|
||||
//
|
||||
// /**
|
||||
// * Gets string
|
||||
// *
|
||||
// * @param path string path to get
|
||||
// * @return {@link String}
|
||||
// */
|
||||
// @NotNull Optional<String> getString(@NotNull String path);
|
||||
//
|
||||
// /**
|
||||
// * Sets object to path
|
||||
// *
|
||||
// * @param path object path to set
|
||||
// * @param object {@link Object}
|
||||
// */
|
||||
// void set(@NotNull String path, @Nullable Object object);
|
||||
//
|
||||
// /**
|
||||
// * Gets string list
|
||||
// *
|
||||
// * @param path string list path to get
|
||||
// * @return string list
|
||||
// */
|
||||
// @NotNull List<String> getStringList(@NotNull String path);
|
||||
//
|
||||
// /**
|
||||
// * Gets int
|
||||
// *
|
||||
// * @param path integer path to get
|
||||
// * @return {@link Integer}
|
||||
// */
|
||||
// int getInt(@NotNull String path);
|
||||
//
|
||||
// /**
|
||||
// * Gets double
|
||||
// *
|
||||
// * @param path double path to get
|
||||
// * @return {@link Double}
|
||||
// */
|
||||
// double getDouble(@NotNull String path);
|
||||
//
|
||||
// /**
|
||||
// * Gets long
|
||||
// *
|
||||
// * @param path long path to get
|
||||
// * @return {@link Integer}
|
||||
// */
|
||||
// long getLong(@NotNull String path);
|
||||
//
|
||||
// /**
|
||||
// * Gets byte
|
||||
// *
|
||||
// * @param path byte path to get
|
||||
// * @return {@link Byte}
|
||||
// */
|
||||
// byte getByte(@NotNull String path);
|
||||
//
|
||||
// /**
|
||||
// * Gets short
|
||||
// *
|
||||
// * @param path short path to get
|
||||
// * @return {@link Short}
|
||||
// */
|
||||
// short getShort(@NotNull String path);
|
||||
//
|
||||
// /**
|
||||
// * Gets boolean
|
||||
// *
|
||||
// * @param path boolean path to get
|
||||
// * @return {@link Boolean}
|
||||
// */
|
||||
// boolean getBoolean(@NotNull String path);
|
||||
//
|
||||
// /**
|
||||
// * Creates configuration section into path
|
||||
// *
|
||||
// * @param path configuration section path to create
|
||||
// * @return {@link ConfigurationSection}
|
||||
// */
|
||||
// @NotNull ConfigurationSection createSection(@NotNull String path);
|
||||
//
|
||||
// /**
|
||||
// * Gets configuration section from path
|
||||
// *
|
||||
// * @param path configurations section path to get
|
||||
// * @return if there isn't section returns {@link MckFileConfiguration}
|
||||
// */
|
||||
// @NotNull ConfigurationSection getSection(@NotNull String path);
|
||||
//
|
||||
// /**
|
||||
// * Gets configuration section from path if there is no section It will create
|
||||
// *
|
||||
// * @param path configurations section path to get
|
||||
// * @return {@link ConfigurationSection}
|
||||
// */
|
||||
// @NotNull ConfigurationSection getOrCreateSection(@NotNull String path);
|
||||
//
|
||||
//}
|
||||
@@ -1,64 +1,64 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is JSONFile.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.fileportlek.old;
|
||||
|
||||
import com.dumptruckman.bukkit.configuration.json.JsonConfiguration;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class JSONFile extends FileEnvelope {
|
||||
|
||||
public JSONFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath, boolean loadDefault) {
|
||||
super(plugin, file, resourcePath.endsWith(".json") ? resourcePath : resourcePath + ".json", loadDefault);
|
||||
}
|
||||
|
||||
public JSONFile(@NotNull final Plugin plugin, @NotNull final String fileName) {
|
||||
this(plugin, "", fileName);
|
||||
}
|
||||
|
||||
public JSONFile(@NotNull final Plugin plugin, @NotNull final String resourcePath, @NotNull final String fileName) {
|
||||
this(plugin, new File(plugin.getDataFolder().getAbsolutePath() + (resourcePath.startsWith(File.separator) ? resourcePath : File.separator + resourcePath), fileName.endsWith(".json") ? fileName : fileName + ".json"), resourcePath.isEmpty() ? fileName : resourcePath.endsWith(File.separator) ? resourcePath + fileName : resourcePath + File.separator + fileName);
|
||||
}
|
||||
|
||||
public JSONFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath) {
|
||||
super(plugin, file, resourcePath.endsWith(".json") ? resourcePath : resourcePath + ".json", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
fileConfiguration = HumanReadableJsonConfiguration.loadConfiguration(file);
|
||||
if (loadDefault) {
|
||||
try {
|
||||
JsonConfiguration defaultConfig = new HumanReadableJsonConfiguration();
|
||||
defaultConfig.load(new InputStreamReader(getInputStream(), StandardCharsets.UTF_8));
|
||||
fileConfiguration.setDefaults(defaultConfig);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Could not load json file " + resourcePath, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file is a part of project QuickShop, the name is JSONFile.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.fileportlek.old;
|
||||
//
|
||||
//import com.dumptruckman.bukkit.configuration.json.JsonConfiguration;
|
||||
//import org.bukkit.configuration.InvalidConfigurationException;
|
||||
//import org.bukkit.plugin.Plugin;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.IOException;
|
||||
//import java.io.InputStreamReader;
|
||||
//import java.nio.charset.StandardCharsets;
|
||||
//import java.util.logging.Level;
|
||||
//
|
||||
//public class JSONFile extends FileEnvelope {
|
||||
//
|
||||
// public JSONFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath, boolean loadDefault) {
|
||||
// super(plugin, file, resourcePath.endsWith(".json") ? resourcePath : resourcePath + ".json", loadDefault);
|
||||
// }
|
||||
//
|
||||
// public JSONFile(@NotNull final Plugin plugin, @NotNull final String fileName) {
|
||||
// this(plugin, "", fileName);
|
||||
// }
|
||||
//
|
||||
// public JSONFile(@NotNull final Plugin plugin, @NotNull final String resourcePath, @NotNull final String fileName) {
|
||||
// this(plugin, new File(plugin.getDataFolder().getAbsolutePath() + (resourcePath.startsWith(File.separator) ? resourcePath : File.separator + resourcePath), fileName.endsWith(".json") ? fileName : fileName + ".json"), resourcePath.isEmpty() ? fileName : resourcePath.endsWith(File.separator) ? resourcePath + fileName : resourcePath + File.separator + fileName);
|
||||
// }
|
||||
//
|
||||
// public JSONFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath) {
|
||||
// super(plugin, file, resourcePath.endsWith(".json") ? resourcePath : resourcePath + ".json", true);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void reload() {
|
||||
// fileConfiguration = HumanReadableJsonConfiguration.loadConfiguration(file);
|
||||
// if (loadDefault) {
|
||||
// try {
|
||||
// JsonConfiguration defaultConfig = new HumanReadableJsonConfiguration();
|
||||
// defaultConfig.load(new InputStreamReader(getInputStream(), StandardCharsets.UTF_8));
|
||||
// fileConfiguration.setDefaults(defaultConfig);
|
||||
// } catch (IOException | InvalidConfigurationException e) {
|
||||
// plugin.getLogger().log(Level.SEVERE, "Could not load json file " + resourcePath, e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,55 +1,55 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is YAMLFile.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.fileportlek.old;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class YAMLFile extends FileEnvelope {
|
||||
|
||||
public YAMLFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath, boolean loadDefault) {
|
||||
super(plugin, file, resourcePath.endsWith(".yml") ? resourcePath : resourcePath + ".yml", loadDefault);
|
||||
}
|
||||
|
||||
public YAMLFile(@NotNull final Plugin plugin, @NotNull final String fileName) {
|
||||
this(plugin, "", fileName);
|
||||
}
|
||||
|
||||
public YAMLFile(@NotNull final Plugin plugin, @NotNull final String resourcePath, @NotNull final String fileName) {
|
||||
this(plugin, new File(plugin.getDataFolder().getAbsolutePath() + (resourcePath.startsWith(File.separator) ? resourcePath : File.separator + resourcePath), fileName.endsWith(".yml") ? fileName : fileName + ".yml"), resourcePath.isEmpty() ? fileName : resourcePath.endsWith(File.separator) ? resourcePath + fileName : resourcePath + File.separator + fileName);
|
||||
}
|
||||
|
||||
public YAMLFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath) {
|
||||
super(plugin, file, resourcePath.endsWith(".yml") ? resourcePath : resourcePath + ".yml", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
fileConfiguration = YamlConfiguration.loadConfiguration(file);
|
||||
if (loadDefault) {
|
||||
fileConfiguration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getInputStream())));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
///*
|
||||
// * This file is a part of project QuickShop, the name is YAMLFile.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.fileportlek.old;
|
||||
//
|
||||
//import org.bukkit.configuration.file.YamlConfiguration;
|
||||
//import org.bukkit.plugin.Plugin;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.InputStreamReader;
|
||||
//
|
||||
//public class YAMLFile extends FileEnvelope {
|
||||
//
|
||||
// public YAMLFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath, boolean loadDefault) {
|
||||
// super(plugin, file, resourcePath.endsWith(".yml") ? resourcePath : resourcePath + ".yml", loadDefault);
|
||||
// }
|
||||
//
|
||||
// public YAMLFile(@NotNull final Plugin plugin, @NotNull final String fileName) {
|
||||
// this(plugin, "", fileName);
|
||||
// }
|
||||
//
|
||||
// public YAMLFile(@NotNull final Plugin plugin, @NotNull final String resourcePath, @NotNull final String fileName) {
|
||||
// this(plugin, new File(plugin.getDataFolder().getAbsolutePath() + (resourcePath.startsWith(File.separator) ? resourcePath : File.separator + resourcePath), fileName.endsWith(".yml") ? fileName : fileName + ".yml"), resourcePath.isEmpty() ? fileName : resourcePath.endsWith(File.separator) ? resourcePath + fileName : resourcePath + File.separator + fileName);
|
||||
// }
|
||||
//
|
||||
// public YAMLFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath) {
|
||||
// super(plugin, file, resourcePath.endsWith(".yml") ? resourcePath : resourcePath + ".yml", true);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void reload() {
|
||||
// fileConfiguration = YamlConfiguration.loadConfiguration(file);
|
||||
// if (loadDefault) {
|
||||
// fileConfiguration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getInputStream())));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -25,12 +25,13 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.integration.Fabledskyblock.FabledIntegration;
|
||||
import org.maxgamer.quickshop.integration.fabledskyblock.FabledIntegration;
|
||||
import org.maxgamer.quickshop.integration.factionsuuid.FactionsUUIDIntegration;
|
||||
import org.maxgamer.quickshop.integration.griefprevention.GriefPreventionIntegration;
|
||||
import org.maxgamer.quickshop.integration.lands.LandsIntegration;
|
||||
import org.maxgamer.quickshop.integration.plotsquared.PlotSquaredIntegrationProxy;
|
||||
import org.maxgamer.quickshop.integration.residence.ResidenceIntegration;
|
||||
import org.maxgamer.quickshop.integration.superiorskyblock.SuperiorSkyblock2Integration;
|
||||
import org.maxgamer.quickshop.integration.towny.TownyIntegration;
|
||||
import org.maxgamer.quickshop.integration.worldguard.WorldGuardIntegration;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
@@ -54,6 +55,7 @@ public class IntegrationHelper extends QuickShopInstanceHolder {
|
||||
integratedPluginNameMap.put("Towny", TownyIntegration.class);
|
||||
integratedPluginNameMap.put("WorldGuard", WorldGuardIntegration.class);
|
||||
integratedPluginNameMap.put("FabledSkyblock", FabledIntegration.class);
|
||||
integratedPluginNameMap.put("SuperiorSkyblock", SuperiorSkyblock2Integration.class);
|
||||
}
|
||||
|
||||
private final Map<String, IntegratedPlugin> integrations = new HashMap<>(7);
|
||||
|
||||
+20
-1
@@ -1,4 +1,23 @@
|
||||
package org.maxgamer.quickshop.integration.Fabledskyblock;
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is FabledIntegration.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.integration.fabledskyblock;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is SuperiorSkyblock2Integration.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.integration.superiorskyblock;
|
||||
|
||||
import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI;
|
||||
import com.bgsoftware.superiorskyblock.api.events.IslandChunkResetEvent;
|
||||
import com.bgsoftware.superiorskyblock.api.events.IslandKickEvent;
|
||||
import com.bgsoftware.superiorskyblock.api.events.IslandQuitEvent;
|
||||
import com.bgsoftware.superiorskyblock.api.island.Island;
|
||||
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.integration.IntegrateStage;
|
||||
import org.maxgamer.quickshop.integration.IntegrationStage;
|
||||
import org.maxgamer.quickshop.integration.QSIntegratedPlugin;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@IntegrationStage(loadStage = IntegrateStage.onEnableAfter)
|
||||
public class SuperiorSkyblock2Integration extends QSIntegratedPlugin implements Listener {
|
||||
private final boolean onlyOwnerCanCreateShop;
|
||||
private final boolean deleteShopOnMemberLeave;
|
||||
|
||||
public SuperiorSkyblock2Integration(QuickShop plugin) {
|
||||
super(plugin);
|
||||
onlyOwnerCanCreateShop = plugin.getConfig().getBoolean("integration.superiorskyblock.owner-create-only");
|
||||
deleteShopOnMemberLeave = plugin.getConfig().getBoolean("integration.superiorskyblock.delete-shop-on-member-leave");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the integrated plugin name.
|
||||
* For example, Residence
|
||||
*
|
||||
* @return integrated plugin
|
||||
*/
|
||||
@Override
|
||||
public @NotNull String getName() {
|
||||
return "SuperiorSkyblock";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player can create shop here
|
||||
*
|
||||
* @param player the player want to create shop
|
||||
* @param location shop location
|
||||
* @return If you can create shop here
|
||||
*/
|
||||
@Override
|
||||
public boolean canCreateShopHere(@NotNull Player player, @NotNull Location location) {
|
||||
Island island = SuperiorSkyblockAPI.getIslandAt(location);
|
||||
SuperiorPlayer superiorPlayer = SuperiorSkyblockAPI.getPlayer(player);
|
||||
if (island == null) {
|
||||
return false;
|
||||
}
|
||||
if (onlyOwnerCanCreateShop) {
|
||||
return island.getOwner().equals(superiorPlayer);
|
||||
} else {
|
||||
if (island.getOwner().equals(superiorPlayer))
|
||||
return true;
|
||||
return island.isMember(superiorPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player can trade with shop here
|
||||
*
|
||||
* @param player the player want to trade with shop
|
||||
* @param location shop location
|
||||
* @return If you can trade with shop here
|
||||
*/
|
||||
@Override
|
||||
public boolean canTradeShopHere(@NotNull Player player, @NotNull Location location) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loading logic
|
||||
* Execute Stage defined by IntegrationStage
|
||||
*/
|
||||
@Override
|
||||
public void load() {
|
||||
if (plugin.getConfig().getBoolean("integration.superiorskyblock.delete-shop-on-member-leave")) {
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unloding logic
|
||||
* Will execute when Quickshop unloading
|
||||
*/
|
||||
@Override
|
||||
public void unload() {
|
||||
IslandQuitEvent.getHandlerList().unregister(this);
|
||||
IslandKickEvent.getHandlerList().unregister(this);
|
||||
IslandChunkResetEvent.getHandlerList().unregister(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void deleteShops(com.bgsoftware.superiorskyblock.api.events.IslandQuitEvent event) {
|
||||
event.getIsland().getAllChunks().forEach((chunk) -> {
|
||||
Map<Location, Shop> shops = plugin.getShopManager().getShops(chunk);
|
||||
if (shops != null && !shops.isEmpty()) {
|
||||
shops.forEach((location, shop) -> {
|
||||
if (shop.getOwner().equals(event.getPlayer().getUniqueId())) {
|
||||
plugin.log("[SuperiorSkyBlock2 Integration]Shop " + shop + " deleted caused by ShopOwnerQuitFromIsland");
|
||||
shop.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void deleteShops(com.bgsoftware.superiorskyblock.api.events.IslandKickEvent event) {
|
||||
event.getIsland().getAllChunks().forEach((chunk) -> {
|
||||
Map<Location, Shop> shops = plugin.getShopManager().getShops(chunk);
|
||||
if (shops != null && !shops.isEmpty()) {
|
||||
shops.forEach((location, shop) -> {
|
||||
if (shop.getOwner().equals(event.getTarget().getUniqueId())) {
|
||||
plugin.log("[SuperiorSkyBlock2 Integration]Shop " + shop + " deleted caused by ShopOwnerKickedFromIsland");
|
||||
shop.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void deleteShops(com.bgsoftware.superiorskyblock.api.events.IslandChunkResetEvent event) {
|
||||
Map<Location, Shop> shops = plugin.getShopManager().getShops(event.getWorld().getName(), event.getChunkX(), event.getChunkZ());
|
||||
if (shops != null && !shops.isEmpty()) {
|
||||
shops.forEach((location, shop) -> {
|
||||
plugin.log("[SuperiorSkyBlock2 Integration]Shop " + shop + " deleted caused by IslandChunkReset.");
|
||||
shop.delete();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is DisplayBugFixListener.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.listener;
|
||||
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockCanBuildEvent;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.shop.DisplayItem;
|
||||
import org.maxgamer.quickshop.shop.DisplayType;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
public class DisplayBugFixListener extends QSListener {
|
||||
public DisplayBugFixListener(QuickShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void canBuild(BlockCanBuildEvent e) {
|
||||
if (!plugin.isDisplay()
|
||||
|| DisplayItem.getNowUsing() != DisplayType.ARMORSTAND
|
||||
|| e.isBuildable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Collection<Entity> entities =
|
||||
e.getBlock().getWorld().getNearbyEntities(e.getBlock().getLocation(), 1.0, 1, 1.0);
|
||||
|
||||
for (final Entity entity : entities) {
|
||||
if (!(entity instanceof ArmorStand)
|
||||
|| !DisplayItem.checkIsGuardItemStack(((ArmorStand) entity).getItemInHand())) { //FIXME: Update this when drop 1.13 supports
|
||||
continue;
|
||||
}
|
||||
|
||||
e.setBuildable(true);
|
||||
Util.debugLog(
|
||||
"Re-set the allowed build flag here because it found the cause of the display-item blocking it before.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,12 +20,10 @@
|
||||
package org.maxgamer.quickshop.listener;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityPortalEvent;
|
||||
import org.bukkit.event.entity.ItemDespawnEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
@@ -81,20 +79,20 @@ public class DisplayProtectionListener extends ProtectionListenerBase {
|
||||
+ " , QuickShop already cancel it.");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void entity(EntityDamageEvent event) {
|
||||
if (!(event.getEntity() instanceof ArmorStand)) {
|
||||
return;
|
||||
}
|
||||
if (DisplayItem.getNowUsing() != DisplayType.ARMORSTAND) {
|
||||
return;
|
||||
}
|
||||
if (!DisplayItem.checkIsGuardItemStack(((ArmorStand) event.getEntity()).getItemInHand())) { //FIXME: Update this when drop 1.13 supports
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
//
|
||||
// @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
// public void entity(EntityDamageEvent event) {
|
||||
// if (!(event.getEntity() instanceof ArmorStand)) {
|
||||
// return;
|
||||
// }
|
||||
// if (DisplayItem.getNowUsing() != DisplayType.ARMORSTAND) {
|
||||
// return;
|
||||
// }
|
||||
// if (!DisplayItem.checkIsGuardItemStack(((ArmorStand) event.getEntity()).getItemInHand())) { //FIXME: Update this when drop 1.13 supports
|
||||
// return;
|
||||
// }
|
||||
// event.setCancelled(true);
|
||||
// }
|
||||
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
|
||||
+37
-41
@@ -25,7 +25,6 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -34,8 +33,6 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityInteractEvent;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
@@ -46,7 +43,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.Cache;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.shop.DisplayItem;
|
||||
import org.maxgamer.quickshop.shop.DisplayType;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
@@ -251,44 +247,44 @@ public class EnhanceDisplayProtectionListener extends ProtectionListenerBase imp
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void entity(EntityDeathEvent event) {
|
||||
if (DisplayItem.getNowUsing() != DisplayType.ARMORSTAND) {
|
||||
return;
|
||||
}
|
||||
if (!(event.getEntity() instanceof ArmorStand)) {
|
||||
return;
|
||||
}
|
||||
if (!DisplayItem.checkIsGuardItemStack(((ArmorStand) event.getEntity()).getItemInHand())) { //FIXME: Update this when drop 1.13 supports
|
||||
return;
|
||||
}
|
||||
event.setDroppedExp(0);
|
||||
event.getDrops().clear();
|
||||
}
|
||||
// @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
// public void entity(EntityDeathEvent event) {
|
||||
// if (DisplayItem.getNowUsing() != DisplayType.ARMORSTAND) {
|
||||
// return;
|
||||
// }
|
||||
// if (!(event.getEntity() instanceof ArmorStand)) {
|
||||
// return;
|
||||
// }
|
||||
// if (!DisplayItem.checkIsGuardItemStack(((ArmorStand) event.getEntity()).getItemInHand())) { //FIXME: Update this when drop 1.13 supports
|
||||
// return;
|
||||
// }
|
||||
// event.setDroppedExp(0);
|
||||
// event.getDrops().clear();
|
||||
// }
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void entity(EntityInteractEvent event) {
|
||||
if (DisplayItem.getNowUsing() != DisplayType.ARMORSTAND) {
|
||||
return;
|
||||
}
|
||||
if (!(event.getEntity() instanceof ArmorStand)) {
|
||||
return;
|
||||
}
|
||||
if (!DisplayItem.checkIsGuardItemStack(((ArmorStand) event.getEntity()).getItemInHand())) { //FIXME: Update this when drop 1.13 supports
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
final Entity entity = event.getEntity();
|
||||
if (entity instanceof InventoryHolder) {
|
||||
Util.inventoryCheck(((InventoryHolder) entity).getInventory());
|
||||
}
|
||||
sendAlert(
|
||||
"[DisplayGuard] Entity "
|
||||
+ event.getEntityType().name()
|
||||
+ " # "
|
||||
+ event.getEntity().getLocation()
|
||||
+ " trying interact the hold displayItem's entity.");
|
||||
}
|
||||
// @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
// public void entity(EntityInteractEvent event) {
|
||||
// if (DisplayItem.getNowUsing() != DisplayType.ARMORSTAND) {
|
||||
// return;
|
||||
// }
|
||||
// if (!(event.getEntity() instanceof ArmorStand)) {
|
||||
// return;
|
||||
// }
|
||||
// if (!DisplayItem.checkIsGuardItemStack(((ArmorStand) event.getEntity()).getItemInHand())) { //FIXME: Update this when drop 1.13 supports
|
||||
// return;
|
||||
// }
|
||||
// event.setCancelled(true);
|
||||
// final Entity entity = event.getEntity();
|
||||
// if (entity instanceof InventoryHolder) {
|
||||
// Util.inventoryCheck(((InventoryHolder) entity).getInventory());
|
||||
// }
|
||||
// sendAlert(
|
||||
// "[DisplayGuard] Entity "
|
||||
// + event.getEntityType().name()
|
||||
// + " # "
|
||||
// + event.getEntity().getLocation()
|
||||
// + " trying interact the hold displayItem's entity.");
|
||||
// }
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void inventory(InventoryClickEvent event) {
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
package org.maxgamer.quickshop.listener;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@@ -27,7 +29,7 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
@@ -49,11 +51,79 @@ import org.maxgamer.quickshop.util.Util;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class PlayerListener extends QSListener {
|
||||
private final Cache<Player, Long> dupeClickPrevent = Caffeine
|
||||
.newBuilder()
|
||||
.initialCapacity(10)
|
||||
.expireAfterAccess(1, TimeUnit.SECONDS)
|
||||
.weakKeys()
|
||||
.build();
|
||||
private boolean swapBehavior = false;
|
||||
|
||||
public PlayerListener(QuickShop plugin) {
|
||||
super(plugin);
|
||||
swapBehavior = plugin.getConfig().getBoolean("shop.interact.swap-click-behavior");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onClick(PlayerInteractEvent e) {
|
||||
if (e.getHand() != EquipmentSlot.HAND) {
|
||||
return;
|
||||
}
|
||||
final Block b = e.getClickedBlock();
|
||||
|
||||
// ----Adventure dupe click workaround start----
|
||||
if (e.getPlayer().getGameMode() == GameMode.ADVENTURE) {
|
||||
dupeClickPrevent.put(e.getPlayer(), System.currentTimeMillis());
|
||||
}
|
||||
// ----Adventure dupe click workaround end----
|
||||
if (!e.getAction().equals(Action.LEFT_CLICK_BLOCK) && b != null) {
|
||||
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||
if (!swapBehavior) {
|
||||
postControlPanel(e);
|
||||
} else {
|
||||
postTrade(e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!swapBehavior) {
|
||||
postTrade(e);
|
||||
} else {
|
||||
postControlPanel(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onAdventureClick(PlayerAnimationEvent event) {
|
||||
if (event.getPlayer().getGameMode() != GameMode.ADVENTURE) {
|
||||
return;
|
||||
}
|
||||
// ----Adventure dupe click workaround start----
|
||||
Long dupeTime = dupeClickPrevent.getIfPresent(event.getPlayer());
|
||||
if (dupeTime != null && dupeTime > System.currentTimeMillis() - 1000) {
|
||||
return;
|
||||
} else if (dupeTime != null) {
|
||||
dupeClickPrevent.invalidate(event.getPlayer());
|
||||
}
|
||||
// ----Adventure dupe click workaround end----
|
||||
Block focused = event.getPlayer().getTargetBlock(null, 5);
|
||||
PlayerInteractEvent interactEvent
|
||||
= new PlayerInteractEvent(event.getPlayer(),
|
||||
focused.getType() == Material.AIR ? Action.LEFT_CLICK_AIR : Action.LEFT_CLICK_BLOCK,
|
||||
event.getPlayer().getInventory().getItemInMainHand(),
|
||||
focused,
|
||||
event.getPlayer().getFacing().getOppositeFace());
|
||||
|
||||
if (!swapBehavior) {
|
||||
postTrade(interactEvent);
|
||||
} else {
|
||||
postControlPanel(interactEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void playClickSound(@NotNull Player player) {
|
||||
@@ -62,36 +132,36 @@ public class PlayerListener extends QSListener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onClick(PlayerInteractEvent e) {
|
||||
if (e.getHand() != EquipmentSlot.HAND) {
|
||||
return;
|
||||
}
|
||||
if (!e.getAction().equals(Action.LEFT_CLICK_BLOCK) && e.getClickedBlock() != null) {
|
||||
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && Util.isWallSign(e.getClickedBlock().getType())) {
|
||||
final Block block;
|
||||
if (Util.isWallSign(e.getClickedBlock().getType())) {
|
||||
block = Util.getAttached(e.getClickedBlock());
|
||||
} else {
|
||||
block = e.getClickedBlock();
|
||||
}
|
||||
Shop controlPanelShop = plugin.getShopManager().getShop(Objects.requireNonNull(block).getLocation());
|
||||
if (controlPanelShop != null && (controlPanelShop.getOwner().equals(e.getPlayer().getUniqueId()) || QuickShop.getPermissionManager().hasPermission(e.getPlayer(), "quickshop.other.control"))) {
|
||||
MsgUtil.sendControlPanelInfo(e.getPlayer(), Objects.requireNonNull(plugin.getShopManager().getShop(block.getLocation())));
|
||||
this.playClickSound(e.getPlayer());
|
||||
Objects.requireNonNull(plugin.getShopManager().getShop(block.getLocation())).setSignText();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
private void postControlPanel(PlayerInteractEvent e) {
|
||||
final Block b = e.getClickedBlock();
|
||||
final Player p = e.getPlayer();
|
||||
if (Util.isWallSign(b.getType())) {
|
||||
final Block block;
|
||||
if (Util.isWallSign(b.getType())) {
|
||||
block = Util.getAttached(b);
|
||||
} else {
|
||||
block = e.getClickedBlock();
|
||||
}
|
||||
Shop controlPanelShop = plugin.getShopManager().getShop(Objects.requireNonNull(block).getLocation());
|
||||
if (controlPanelShop != null && (controlPanelShop.getOwner().equals(p.getUniqueId()) || QuickShop.getPermissionManager().hasPermission(p, "quickshop.other.control"))) {
|
||||
MsgUtil.sendControlPanelInfo(p, Objects.requireNonNull(plugin.getShopManager().getShop(block.getLocation())));
|
||||
this.playClickSound(e.getPlayer());
|
||||
Objects.requireNonNull(plugin.getShopManager().getShop(block.getLocation())).setSignText();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private void postTrade(PlayerInteractEvent e) {
|
||||
final Block b = e.getClickedBlock();
|
||||
final Player p = e.getPlayer();
|
||||
if (b == null) {
|
||||
return;
|
||||
}
|
||||
if (!Util.canBeShop(b) && !Util.isWallSign(b.getType())) {
|
||||
return;
|
||||
}
|
||||
final Player p = e.getPlayer();
|
||||
|
||||
final Location loc = b.getLocation();
|
||||
final ItemStack item = e.getItem();
|
||||
// Get the shop
|
||||
@@ -177,13 +247,13 @@ public class PlayerListener extends QSListener {
|
||||
actions.put(p.getUniqueId(), info);
|
||||
}
|
||||
// Handles creating shops
|
||||
else if (e.useInteractedBlock() == Result.ALLOW
|
||||
else if (e.useInteractedBlock() == Event.Result.ALLOW
|
||||
&& shop == null
|
||||
&& item != null
|
||||
&& item.getType() != Material.AIR
|
||||
&& QuickShop.getPermissionManager().hasPermission(p, "quickshop.create.sell")
|
||||
&& p.getGameMode() != GameMode.CREATIVE) {
|
||||
if (e.useInteractedBlock() == Result.DENY
|
||||
if (e.useInteractedBlock() == Event.Result.DENY
|
||||
|| !InteractUtil.check(InteractUtil.Action.CREATE, p.isSneaking())
|
||||
|| plugin.getConfig().getBoolean("shop.disable-quick-create")
|
||||
|| !plugin.getShopManager().canBuildShop(p, b, e.getBlockFace())) {
|
||||
@@ -237,6 +307,11 @@ public class PlayerListener extends QSListener {
|
||||
}
|
||||
}
|
||||
|
||||
enum InteractAction {
|
||||
TRADE,
|
||||
CONTROL_PANEL
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onInventoryClose(InventoryCloseEvent e) {
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ public class BukkitPermsProvider implements PermissionProvider {
|
||||
* @return Debug Infos
|
||||
*/
|
||||
@Override
|
||||
public @NotNull PermissionInfomationContainer getDebugInfo(
|
||||
public @NotNull PermissionInformationContainer getDebugInfo(
|
||||
@NotNull CommandSender sender, @NotNull String permission) {
|
||||
return new PermissionInfomationContainer(sender, permission, null, null);
|
||||
return new PermissionInformationContainer(sender, permission, null, null);
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is PermissionInfomationContainer.java
|
||||
* This file is a part of project QuickShop, the name is PermissionInformationContainer.java
|
||||
* Copyright (C) PotatoCraft Studio and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class PermissionInfomationContainer {
|
||||
public class PermissionInformationContainer {
|
||||
@NotNull
|
||||
private CommandSender sender;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class PermissionManager {
|
||||
boolean result = provider.hasPermission(sender, permission);
|
||||
if (Util.isDevMode()) {
|
||||
try {
|
||||
PermissionInfomationContainer container = provider.getDebugInfo(sender, permission);
|
||||
PermissionInformationContainer container = provider.getDebugInfo(sender, permission);
|
||||
Util.debugLog("Permission Node: " + container.getPermission() + "; Result: " + result + "; Sender: " + container.getSender().getName());
|
||||
// Util.debugLog("Result: " + result);
|
||||
// Util.debugLog("Sender: " + container.getSender().getName());
|
||||
|
||||
@@ -48,7 +48,7 @@ public interface PermissionProvider {
|
||||
* @return Debug Infos
|
||||
*/
|
||||
@NotNull
|
||||
PermissionInfomationContainer getDebugInfo(
|
||||
PermissionInformationContainer getDebugInfo(
|
||||
@NotNull CommandSender sender, @NotNull String permission);
|
||||
|
||||
}
|
||||
@@ -71,13 +71,13 @@ public class VaultPermissionProvider implements PermissionProvider {
|
||||
* @return Debug Infos
|
||||
*/
|
||||
@Override
|
||||
public @NotNull PermissionInfomationContainer getDebugInfo(
|
||||
public @NotNull PermissionInformationContainer getDebugInfo(
|
||||
@NotNull CommandSender sender, @NotNull String permission) {
|
||||
if (sender instanceof Server) {
|
||||
return new PermissionInfomationContainer(sender, permission, null, "User is Console");
|
||||
return new PermissionInformationContainer(sender, permission, null, "User is Console");
|
||||
}
|
||||
OfflinePlayer offlinePlayer = (OfflinePlayer) sender;
|
||||
return new PermissionInfomationContainer(
|
||||
return new PermissionInformationContainer(
|
||||
sender, permission, api.getPrimaryGroup(null, offlinePlayer), null);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,335 +0,0 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is ArmorStandDisplayItem.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.shop;
|
||||
|
||||
import lombok.ToString;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.event.ShopDisplayItemDespawnEvent;
|
||||
import org.maxgamer.quickshop.event.ShopDisplayItemSpawnEvent;
|
||||
import org.maxgamer.quickshop.util.GameVersion;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.ReflectFactory;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@ToString
|
||||
@Deprecated
|
||||
|
||||
public class ArmorStandDisplayItem extends DisplayItem {
|
||||
|
||||
@Nullable
|
||||
private volatile ArmorStand armorStand;
|
||||
|
||||
/**
|
||||
* @deprecated This display type pending for removal in future
|
||||
*/
|
||||
ArmorStandDisplayItem(@NotNull Shop shop) {
|
||||
super(shop);
|
||||
}
|
||||
|
||||
private static boolean isTool(Material material) {
|
||||
String nlc = material.name().toLowerCase();
|
||||
return nlc.contains("sword") || nlc.contains("shovel") || nlc.contains("axe"); //TODO: Needs a better impl. Maybe NamespacedKey
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkDisplayIsMoved() {
|
||||
if (this.armorStand == null) {
|
||||
return false;
|
||||
}
|
||||
return !this.armorStand.getLocation().equals(getDisplayLocation());
|
||||
}
|
||||
|
||||
public Location getCenter(Location loc) {
|
||||
// This is always '+' instead of '-' even in negative pos
|
||||
return new Location(
|
||||
loc.getWorld(), loc.getBlockX() + .5, loc.getBlockY() + .5, loc.getBlockZ() + .5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkDisplayNeedRegen() {
|
||||
if (this.armorStand == null) {
|
||||
return false;
|
||||
}
|
||||
return !this.armorStand.isValid() || this.armorStand.isDead();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkIsShopEntity(@NotNull Entity entity) {
|
||||
if (!(entity instanceof ArmorStand)) {
|
||||
return false;
|
||||
}
|
||||
return DisplayItem.checkIsGuardItemStack(((ArmorStand) entity).getItemInHand()); //FIXME: Update this when drop 1.13 supports
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fixDisplayMoved() {
|
||||
Location location = this.getDisplayLocation();
|
||||
//if (this.armorStand != null) {
|
||||
if (location != null) {
|
||||
this.armorStand.teleport(location);
|
||||
} else {
|
||||
fixDisplayMovedOld();
|
||||
}
|
||||
// } else {
|
||||
// fixDisplayMovedOld();
|
||||
// }
|
||||
}
|
||||
|
||||
public void fixDisplayMovedOld() {
|
||||
for (Entity entity : Objects.requireNonNull(this.shop.getLocation().getWorld()).getEntities()) {
|
||||
if (!(entity instanceof ArmorStand)) {
|
||||
continue;
|
||||
}
|
||||
ArmorStand eArmorStand = (ArmorStand) entity;
|
||||
if (eArmorStand.getUniqueId().equals(Objects.requireNonNull(this.armorStand).getUniqueId())) {
|
||||
Util.debugLog(
|
||||
"Fixing moved ArmorStand displayItem "
|
||||
+ eArmorStand.getUniqueId()
|
||||
+ " at "
|
||||
+ eArmorStand.getLocation());
|
||||
eArmorStand.teleport(getDisplayLocation());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fixDisplayNeedRegen() {
|
||||
respawn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
if (this.armorStand == null) {
|
||||
Util.debugLog("Ignore the armorStand removing because the armorStand not spawned.");
|
||||
return;
|
||||
}
|
||||
this.armorStand.remove();
|
||||
this.armorStand = null;
|
||||
this.guardedIstack = null;
|
||||
ShopDisplayItemDespawnEvent shopDisplayItemDespawnEvent =
|
||||
new ShopDisplayItemDespawnEvent(this.shop, this.originalItemStack, DisplayType.ARMORSTAND);
|
||||
plugin.getServer().getPluginManager().callEvent(shopDisplayItemDespawnEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeDupe() {
|
||||
if (this.armorStand == null) {
|
||||
Util.debugLog("Warning: Trying to removeDupe for a null display shop.");
|
||||
return false;
|
||||
}
|
||||
boolean removed = false;
|
||||
for (Entity entity : armorStand.getNearbyEntities(1.5, 1.5, 1.5)) {
|
||||
if (entity.getType() != EntityType.ARMOR_STAND) {
|
||||
continue;
|
||||
}
|
||||
ArmorStand eArmorStand = (ArmorStand) entity;
|
||||
|
||||
if (!eArmorStand.getUniqueId().equals(this.armorStand.getUniqueId()) && DisplayItem.checkIsTargetShopDisplay(eArmorStand.getItemInHand(), this.shop)) {//FIXME: Update this when drop 1.13 supports
|
||||
Util.debugLog("Removing dupes ArmorEntity " + eArmorStand.getUniqueId() + " at " + eArmorStand.getLocation());
|
||||
entity.remove();
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void respawn() {
|
||||
remove();
|
||||
spawn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void safeGuard(@NotNull Entity entity) {
|
||||
if (!(entity instanceof ArmorStand)) {
|
||||
Util.debugLog(
|
||||
"Failed to safeGuard " + entity.getLocation() + ", cause target not a ArmorStand");
|
||||
return;
|
||||
}
|
||||
ArmorStand armorStand = (ArmorStand) entity;
|
||||
// Set item protect in the armorstand's hand
|
||||
this.guardedIstack = DisplayItem.createGuardItemStack(this.originalItemStack, this.shop);
|
||||
Objects.requireNonNull(armorStand.getEquipment()).setHelmet(guardedIstack);
|
||||
if (GameVersion.get(ReflectFactory.getServerVersion()).isPersistentStorageApiSupports()) {
|
||||
armorStand
|
||||
.getPersistentDataContainer()
|
||||
.set(
|
||||
new NamespacedKey(plugin, "displayMark"),
|
||||
DisplayItemPersistentDataType.INSTANCE,
|
||||
DisplayItem.createShopProtectionFlag(this.originalItemStack, shop));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawn() {
|
||||
if (shop.isDeleted() || !shop.isLoaded()) {
|
||||
return;
|
||||
}
|
||||
if (shop.getLocation().getWorld() == null) {
|
||||
Util.debugLog("Canceled the displayItem spawning because the location in the world is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (originalItemStack == null) {
|
||||
Util.debugLog("Canceled the displayItem spawning because the ItemStack is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (armorStand != null && armorStand.isValid() && !armorStand.isDead()) {
|
||||
Util.debugLog(
|
||||
"Warning: Spawning the armorStand for DisplayItem when there is already an existing armorStand may cause a duplicated armorStand!");
|
||||
MsgUtil.debugStackTrace(Thread.currentThread().getStackTrace());
|
||||
|
||||
ShopDisplayItemSpawnEvent shopDisplayItemSpawnEvent =
|
||||
new ShopDisplayItemSpawnEvent(shop, originalItemStack, DisplayType.ARMORSTAND);
|
||||
plugin.getServer().getPluginManager().callEvent(shopDisplayItemSpawnEvent);
|
||||
if (shopDisplayItemSpawnEvent.isCancelled()) {
|
||||
Util.debugLog(
|
||||
"Canceled the displayItem from spawning because a plugin setCancelled the spawning event, usually it is a QuickShop Add on");
|
||||
return;
|
||||
}
|
||||
|
||||
Location location = getDisplayLocation();
|
||||
this.armorStand =
|
||||
this.shop
|
||||
.getLocation()
|
||||
.getWorld()
|
||||
.spawn(
|
||||
location,
|
||||
ArmorStand.class,
|
||||
armorStand -> {
|
||||
// Set basic armorstand datas.
|
||||
armorStand.setGravity(false);
|
||||
armorStand.setVisible(false);
|
||||
armorStand.setMarker(true);
|
||||
armorStand.setCollidable(false);
|
||||
armorStand.setSmall(true);
|
||||
armorStand.setArms(false);
|
||||
armorStand.setBasePlate(false);
|
||||
armorStand.setSilent(true);
|
||||
armorStand.setAI(false);
|
||||
armorStand.setCanPickupItems(false);
|
||||
// Set pose (this is for hand while we use helmet)
|
||||
// setPoseForArmorStand();
|
||||
});
|
||||
// Set safeGuard
|
||||
Util.debugLog(
|
||||
"Spawned armor stand @ "
|
||||
+ this.armorStand.getLocation()
|
||||
+ " with UUID "
|
||||
+ this.armorStand.getUniqueId());
|
||||
safeGuard(this.armorStand); // Helmet must be set after spawning
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Entity getDisplay() {
|
||||
return this.armorStand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getDisplayLocation() {
|
||||
BlockFace containerBlockFace = BlockFace.NORTH; // Set default vaule
|
||||
if (this.shop.getLocation().getBlock().getBlockData() instanceof Directional) {
|
||||
containerBlockFace =
|
||||
((Directional) this.shop.getLocation().getBlock().getBlockData())
|
||||
.getFacing(); // Replace by container face.
|
||||
}
|
||||
// Fix specific block facing
|
||||
Material type = this.shop.getLocation().getBlock().getType();
|
||||
if (type.name().contains("ANVIL")
|
||||
|| type.name().contains("FENCE")
|
||||
|| type.name().contains("WALL")) {
|
||||
switch (containerBlockFace) {
|
||||
case SOUTH:
|
||||
containerBlockFace = BlockFace.WEST;
|
||||
break;
|
||||
case NORTH:
|
||||
containerBlockFace = BlockFace.EAST;
|
||||
case EAST:
|
||||
containerBlockFace = BlockFace.NORTH;
|
||||
case WEST:
|
||||
containerBlockFace = BlockFace.SOUTH;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Location asloc = getCenter(this.shop.getLocation());
|
||||
Util.debugLog("containerBlockFace " + containerBlockFace);
|
||||
if (this.originalItemStack.getType().isBlock()) {
|
||||
asloc.add(0, 0.5, 0);
|
||||
}
|
||||
switch (containerBlockFace) {
|
||||
case SOUTH:
|
||||
asloc.add(0, -0.5, 0);
|
||||
asloc.setYaw(0);
|
||||
Util.debugLog("Block face as SOUTH");
|
||||
break;
|
||||
case WEST:
|
||||
asloc.add(0, -0.5, 0);
|
||||
asloc.setYaw(90);
|
||||
Util.debugLog("Block face as WEST");
|
||||
break;
|
||||
case EAST:
|
||||
asloc.add(0, -0.5, 0);
|
||||
asloc.setYaw(-90);
|
||||
Util.debugLog("Block face as EAST");
|
||||
break;
|
||||
case NORTH:
|
||||
asloc.add(0, -0.5, 0);
|
||||
asloc.setYaw(180);
|
||||
Util.debugLog("Block face as NORTH");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return asloc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isSpawned() {
|
||||
return this.armorStand != null && this.armorStand.isValid();
|
||||
}
|
||||
|
||||
@Deprecated // no use, will be removed soon
|
||||
private void setPoseForArmorStand() {
|
||||
if (this.originalItemStack.getType().isBlock()) {
|
||||
Objects.requireNonNull(armorStand).setRightArmPose(new EulerAngle(-0.2, 0, 0));
|
||||
} else {
|
||||
Objects.requireNonNull(armorStand).setRightArmPose(new EulerAngle(-89.5, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,8 +22,6 @@ package org.maxgamer.quickshop.shop;
|
||||
import com.lishid.openinv.OpenInv;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -146,8 +144,7 @@ public class ContainerShop implements Shop {
|
||||
Util.debugLog("Shop item display is: " + meta.getDisplayName());
|
||||
//https://hub.spigotmc.org/jira/browse/SPIGOT-5964
|
||||
if (meta.getDisplayName().matches("\\{.*\\}")) {
|
||||
meta.setDisplayName(LegacyComponentSerializer.legacySection().serialize(
|
||||
GsonComponentSerializer.gson().deserialize(meta.getDisplayName())));
|
||||
meta.setDisplayName(meta.getDisplayName());
|
||||
//Correct both items
|
||||
item.setItemMeta(meta);
|
||||
this.item.setItemMeta(meta);
|
||||
@@ -169,21 +166,21 @@ public class ContainerShop implements Shop {
|
||||
switch (DisplayItem.getNowUsing()) {
|
||||
case UNKNOWN:
|
||||
Util.debugLog(
|
||||
"Failed to create a ContainerShop displayItem, the type is unknown, fallback to RealDisplayItem");
|
||||
"Failed to create a ContainerShop displayItem, the type is unknown, fallback to RealDisplayItem");
|
||||
this.displayItem = new RealDisplayItem(this);
|
||||
break;
|
||||
case REALITEM:
|
||||
this.displayItem = new RealDisplayItem(this);
|
||||
break;
|
||||
case ARMORSTAND:
|
||||
this.displayItem = new ArmorStandDisplayItem(this);
|
||||
break;
|
||||
// case ARMORSTAND:
|
||||
// this.displayItem = new ArmorStandDisplayItem(this);
|
||||
// break;
|
||||
case VIRTUALITEM:
|
||||
try {
|
||||
if (!GameVersion.get(ReflectFactory.getServerVersion())
|
||||
.isVirtualDisplaySupports()) {
|
||||
.isVirtualDisplaySupports()) {
|
||||
throw new IllegalStateException(
|
||||
"Version not supports Virtual DisplayItem.");
|
||||
"Version not supports Virtual DisplayItem.");
|
||||
}
|
||||
this.displayItem = new VirtualDisplayItem(this);
|
||||
|
||||
@@ -804,7 +801,7 @@ public class ContainerShop implements Shop {
|
||||
|
||||
checkDisplay();
|
||||
|
||||
if (!isLeftShop) {
|
||||
if (!isLeftShop && plugin.isDisplay()) {
|
||||
if (displayItem != null) {
|
||||
displayItem.remove();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public enum DisplayType {
|
||||
* */
|
||||
UNKNOWN(-1),
|
||||
REALITEM(0),
|
||||
ARMORSTAND(1),
|
||||
// ARMORSTAND(1),
|
||||
VIRTUALITEM(2);
|
||||
|
||||
private final int id;
|
||||
@@ -57,9 +57,9 @@ public enum DisplayType {
|
||||
if (displayItem instanceof RealDisplayItem) {
|
||||
return REALITEM;
|
||||
}
|
||||
if (displayItem instanceof ArmorStandDisplayItem) {
|
||||
return ARMORSTAND;
|
||||
}
|
||||
// if (displayItem instanceof ArmorStandDisplayItem) {
|
||||
// return ARMORSTAND;
|
||||
// }
|
||||
if (displayItem instanceof VirtualDisplayItem) {
|
||||
return VIRTUALITEM;
|
||||
}
|
||||
|
||||
@@ -27,4 +27,6 @@ public class ShopControlPanelImpl {
|
||||
public ShopControlPanelImpl(QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.injector.server.TemporaryPlayer;
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import org.bukkit.Chunk;
|
||||
@@ -34,7 +35,6 @@ import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.event.ShopDisplayItemSpawnEvent;
|
||||
@@ -42,9 +42,7 @@ import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class VirtualDisplayItem extends DisplayItem {
|
||||
@@ -63,7 +61,7 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
//The List which store packet sender
|
||||
private final Set<UUID> packetSenders = new ConcurrentSkipListSet<>();
|
||||
|
||||
private final Queue<Runnable> asyncPacketSendQueue = new ConcurrentLinkedQueue<>();
|
||||
// private final Queue<Runnable> asyncPacketSendQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
private volatile boolean isDisplay;
|
||||
|
||||
@@ -82,8 +80,6 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
//cache chunk x and z
|
||||
private ShopChunk chunkLocation;
|
||||
|
||||
@Nullable
|
||||
private BukkitTask asyncSendingTask;
|
||||
|
||||
|
||||
public VirtualDisplayItem(@NotNull Shop shop) throws RuntimeException {
|
||||
@@ -121,9 +117,10 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
switch (version) {
|
||||
case "v1_13_R1":
|
||||
case "v1_13_R2":
|
||||
fakeItemPacket.getIntegers().write(6, 2);
|
||||
//int data to mark
|
||||
fakeItemPacket.getIntegers().write(7, 1);
|
||||
fakeItemPacket.getIntegers()
|
||||
.write(6, 2)
|
||||
//int data to mark
|
||||
.write(7, 1);
|
||||
break;
|
||||
//int data to mark
|
||||
default:
|
||||
@@ -246,15 +243,6 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
}
|
||||
}
|
||||
|
||||
private void unload() {
|
||||
packetSenders.clear();
|
||||
if (packetAdapter != null) {
|
||||
protocolManager.getAsynchronousManager().unregisterAsyncHandler(packetAdapter);
|
||||
}
|
||||
if (asyncSendingTask != null && !asyncSendingTask.isCancelled()) {
|
||||
asyncSendingTask.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendPacket(@NotNull Player player, @NotNull PacketContainer packet) {
|
||||
try {
|
||||
@@ -330,45 +318,38 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (packetAdapter == null) {
|
||||
packetAdapter = new PacketAdapter(plugin, ListenerPriority.HIGH, PacketType.Play.Server.MAP_CHUNK) {
|
||||
@Override
|
||||
public void onPacketSending(@NotNull PacketEvent event) {
|
||||
//is really full chunk data
|
||||
boolean isFull = event.getPacket().getBooleans().read(0);
|
||||
if (!shop.isLoaded() || !isDisplay || !isFull || !Util.isLoaded(shop.getLocation()) || shop.isLeftShop()) {
|
||||
if (!shop.isLoaded() || !isDisplay || !isFull || shop.isLeftShop()) {
|
||||
return;
|
||||
}
|
||||
StructureModifier<Integer> integerStructureModifier = event.getPacket().getIntegers();
|
||||
//chunk x
|
||||
int x = event.getPacket().getIntegers().read(0);
|
||||
int x = integerStructureModifier.read(0);
|
||||
//chunk z
|
||||
int z = event.getPacket().getIntegers().read(1);
|
||||
asyncPacketSendQueue.offer(() -> {
|
||||
//lazy initialize
|
||||
if (chunkLocation == null) {
|
||||
World world = shop.getLocation().getWorld();
|
||||
Chunk chunk = null;
|
||||
try {
|
||||
//sync getting chunk
|
||||
chunk = plugin.getServer().getScheduler().callSyncMethod(plugin, () -> shop.getLocation().getChunk()).get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
throw new RuntimeException("An error occurred when getting chunk from the world", e);
|
||||
}
|
||||
chunkLocation = new ShopChunk(world.getName(), chunk.getX(), chunk.getZ());
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
if (player instanceof TemporaryPlayer) {
|
||||
return;
|
||||
}
|
||||
if (player == null || !player.isOnline()) {
|
||||
Util.debugLog("Cancelled packet sending cause player logged out when sending packets.");
|
||||
return;
|
||||
}
|
||||
if (chunkLocation.isSame(player.getWorld().getName(), x, z)) {
|
||||
packetSenders.add(player.getUniqueId());
|
||||
sendFakeItem(player);
|
||||
}
|
||||
});
|
||||
int z = integerStructureModifier.read(1);
|
||||
|
||||
if (chunkLocation == null) {
|
||||
World world = shop.getLocation().getWorld();
|
||||
Chunk chunk = shop.getLocation().getChunk();
|
||||
chunkLocation = new ShopChunk(world.getName(), chunk.getX(), chunk.getZ());
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
if (player instanceof TemporaryPlayer) {
|
||||
return;
|
||||
}
|
||||
if (player == null || !player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
if (chunkLocation.isSame(player.getWorld().getName(), x, z)) {
|
||||
packetSenders.add(player.getUniqueId());
|
||||
sendFakeItem(player);
|
||||
}
|
||||
// Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
||||
// if (chunkLocation == null) {
|
||||
// World world = shop.getLocation().getWorld();
|
||||
@@ -383,16 +364,24 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
}
|
||||
};
|
||||
}
|
||||
protocolManager.getAsynchronousManager().registerAsyncHandler(packetAdapter); //TODO: This may affects performance
|
||||
asyncSendingTask = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> {
|
||||
Runnable runnable = asyncPacketSendQueue.poll();
|
||||
while (runnable != null) {
|
||||
runnable.run();
|
||||
runnable = asyncPacketSendQueue.poll();
|
||||
}
|
||||
}, 0, 1);
|
||||
protocolManager.addPacketListener(packetAdapter); //TODO: This may affects performance
|
||||
// asyncSendingTask = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> {
|
||||
// Runnable runnable = asyncPacketSendQueue.poll();
|
||||
// while (runnable != null) {
|
||||
// runnable.run();
|
||||
// runnable = asyncPacketSendQueue.poll();
|
||||
// }
|
||||
// }, 0, 1);
|
||||
}
|
||||
|
||||
private void unload() {
|
||||
packetSenders.clear();
|
||||
if (packetAdapter != null) {
|
||||
protocolManager.removePacketListener(packetAdapter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void sendFakeItem(@NotNull Player player) {
|
||||
sendPacket(player, fakeItemPacket);
|
||||
sendPacket(player, fakeItemMetaPacket);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package org.maxgamer.quickshop.util;
|
||||
|
||||
import com.dumptruckman.bukkit.configuration.json.JsonConfiguration;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
@@ -45,8 +46,7 @@ import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.ServiceInjector;
|
||||
import org.maxgamer.quickshop.database.WarpedResultSet;
|
||||
import org.maxgamer.quickshop.event.ShopControlPanelOpenEvent;
|
||||
import org.maxgamer.quickshop.fileportlek.old.IFile;
|
||||
import org.maxgamer.quickshop.fileportlek.old.JSONFile;
|
||||
import org.maxgamer.quickshop.fileportlek.old.HumanReadableJsonConfiguration;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.language.game.GameLanguage;
|
||||
import org.maxgamer.quickshop.util.language.game.MojangGameLanguageImpl;
|
||||
@@ -75,10 +75,10 @@ public class MsgUtil {
|
||||
private static boolean inited;
|
||||
@Getter
|
||||
private static YamlConfiguration itemi18n;
|
||||
private static IFile messagei18n;
|
||||
private static JsonConfiguration messagei18n;
|
||||
@Getter
|
||||
private static YamlConfiguration potioni18n;
|
||||
private static IFile builtInLang;
|
||||
private static JsonConfiguration builtInLang;
|
||||
|
||||
private static DecimalFormat processFormat() {
|
||||
try {
|
||||
@@ -172,11 +172,11 @@ public class MsgUtil {
|
||||
public static String getMessageOfflinePlayer(
|
||||
@NotNull String loc, @Nullable OfflinePlayer player, @NotNull String... args) {
|
||||
try {
|
||||
Optional<String> raw = messagei18n.getString(loc);
|
||||
if (!raw.isPresent()) {
|
||||
String raw = messagei18n.getString(loc);
|
||||
if (raw == null) {
|
||||
return invaildMsg + ": " + loc;
|
||||
}
|
||||
String filled = fillArgs(raw.get(), args);
|
||||
String filled = fillArgs(raw, args);
|
||||
if (player != null) {
|
||||
if (plugin.getConfig().getBoolean("plugin.PlaceHolderAPI") && plugin.getPlaceHolderAPI() != null && plugin.getPlaceHolderAPI().isEnabled()) {
|
||||
filled = PlaceholderAPI.setPlaceholders(player, filled);
|
||||
@@ -228,16 +228,21 @@ public class MsgUtil {
|
||||
String languageCode = plugin.getConfig().getString("language", "en-US").replace("_", "-");
|
||||
|
||||
// Init message file instance
|
||||
IFile messageFile;
|
||||
JsonConfiguration messageFile;
|
||||
File extractedMessageFile = new File(plugin.getDataFolder(), "messages.json");
|
||||
String buildInMessageFilePath = "lang/" + languageCode + "/messages.json";
|
||||
if (plugin.getResource(buildInMessageFilePath) == null) {
|
||||
//Use default
|
||||
buildInMessageFilePath = "lang-original/messages.json";
|
||||
}
|
||||
messageFile = new JSONFile(plugin, extractedMessageFile, buildInMessageFilePath, true);
|
||||
messageFile.create();
|
||||
|
||||
if (!extractedMessageFile.exists()) {
|
||||
try {
|
||||
Files.copy(Objects.requireNonNull(plugin.getResource(buildInMessageFilePath)), extractedMessageFile.toPath());
|
||||
} catch (IOException ioException) {
|
||||
plugin.getLogger().log(Level.WARNING, "Cannot extract the messages.json file", ioException);
|
||||
}
|
||||
}
|
||||
messageFile = HumanReadableJsonConfiguration.loadConfiguration(extractedMessageFile);
|
||||
//Handle old message file and load it up
|
||||
File oldMsgFile = new File(plugin.getDataFolder(), "messages.yml");
|
||||
if (oldMsgFile.exists()) {
|
||||
@@ -248,7 +253,11 @@ public class MsgUtil {
|
||||
for (String key : oldMsgI18n.getKeys(true)) {
|
||||
messageFile.set(key, oldMsgI18n.get(key));
|
||||
}
|
||||
messageFile.save();
|
||||
try {
|
||||
messageFile.save(extractedMessageFile);
|
||||
} catch (IOException ioException) {
|
||||
ioException.printStackTrace();
|
||||
}
|
||||
try {
|
||||
Files.move(
|
||||
oldMsgFile.toPath(), new File(plugin.getDataFolder(), "messages.yml.bak").toPath());
|
||||
@@ -269,16 +278,23 @@ public class MsgUtil {
|
||||
}
|
||||
|
||||
//Init global instance
|
||||
File buildInLangFile = new File(Util.getCacheFolder(), "bulitin-messages.json");
|
||||
messagei18n = messageFile;
|
||||
builtInLang = new JSONFile(plugin, buildInMessageFilePath);
|
||||
|
||||
|
||||
try {
|
||||
if (buildInLangFile.exists()) {
|
||||
buildInLangFile.delete();
|
||||
}
|
||||
Files.copy(Objects.requireNonNull(plugin.getResource(buildInMessageFilePath)), buildInLangFile.toPath());
|
||||
} catch (IOException ioException) {
|
||||
Util.debugLog("Cannot load default built-in language file: " + ioException.getMessage());
|
||||
}
|
||||
builtInLang = HumanReadableJsonConfiguration.loadConfiguration(buildInLangFile);
|
||||
//Check the i18n language name and backup
|
||||
if (!messagei18n.getString("language-name").isPresent()) {
|
||||
if (StringUtils.isEmpty(messagei18n.getString("language-name"))) {
|
||||
setAndUpdate("language-name");
|
||||
}
|
||||
String messageCodeInFile = messagei18n.getString("language-name").get();
|
||||
if (!messageCodeInFile.equals(languageCode)) {
|
||||
String messageCodeInFile = messagei18n.getString("language-name");
|
||||
if (!Objects.equals(messageCodeInFile, languageCode)) {
|
||||
String backupFileName = "messages-bak-" + UUID.randomUUID().toString() + ".json";
|
||||
Util.debugLog("Language name " + messageCodeInFile + " not matched with " + languageCode + ", replacing with build-in files and renaming current file to " + backupFileName);
|
||||
plugin.getLogger().warning("Language name " + messageCodeInFile + " not matched with " + languageCode + ", replacing with build-in files and renaming current file to " + backupFileName);
|
||||
@@ -296,10 +312,10 @@ public class MsgUtil {
|
||||
|
||||
/* Set default language vesion and update messages.yml */
|
||||
int ver = 0;
|
||||
Optional<String> strVer = messagei18n.getString("language-version");
|
||||
if (strVer.isPresent()) {
|
||||
String strVer = messagei18n.getString("language-version");
|
||||
if (StringUtils.isNumeric(strVer)) {
|
||||
try {
|
||||
ver = Integer.parseInt(strVer.get());
|
||||
ver = Integer.parseInt(strVer);
|
||||
} catch (NumberFormatException ignore) {
|
||||
}
|
||||
}
|
||||
@@ -323,7 +339,11 @@ public class MsgUtil {
|
||||
}
|
||||
|
||||
/* Save the upgraded messages.yml */
|
||||
messagei18n.save();
|
||||
try {
|
||||
messagei18n.save(extractedMessageFile);
|
||||
} catch (IOException ioException) {
|
||||
ioException.printStackTrace();
|
||||
}
|
||||
plugin.getLogger().info("Completed to load plugin translations files.");
|
||||
}
|
||||
|
||||
@@ -708,13 +728,13 @@ public class MsgUtil {
|
||||
public static String getMessage(
|
||||
@NotNull String loc, @Nullable CommandSender player, @NotNull String... args) {
|
||||
try {
|
||||
final Optional<String> raw = messagei18n.getString(loc);
|
||||
if (!raw.isPresent()) {
|
||||
final String raw = messagei18n.getString(loc);
|
||||
if (raw == null) {
|
||||
Util.debugLog("ERR: MsgUtil cannot find the the phrase at " + loc + ", printing the all readed datas: " + messagei18n);
|
||||
|
||||
return invaildMsg + ": " + loc;
|
||||
}
|
||||
String filled = fillArgs(raw.get(), args);
|
||||
String filled = fillArgs(raw, args);
|
||||
if (player instanceof OfflinePlayer) {
|
||||
if (plugin.getPlaceHolderAPI() != null && plugin.getPlaceHolderAPI().isEnabled() && plugin.getConfig().getBoolean("plugin.PlaceHolderAPI")) {
|
||||
try {
|
||||
@@ -972,7 +992,7 @@ public class MsgUtil {
|
||||
return Util.prettifyText(potionString);
|
||||
}
|
||||
|
||||
public static IFile getI18nFile() {
|
||||
public static JsonConfiguration getI18nFile() {
|
||||
return messagei18n;
|
||||
}
|
||||
|
||||
@@ -1451,7 +1471,7 @@ public class MsgUtil {
|
||||
}
|
||||
for (String msg : messages) {
|
||||
try {
|
||||
if (msg == null || msg.isEmpty()) {
|
||||
if (StringUtils.isEmpty(msg)) {
|
||||
continue;
|
||||
}
|
||||
plugin.getQuickChat().send(sender, chatColor + msg);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package org.maxgamer.quickshop.util.envcheck;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
@@ -27,6 +28,8 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.shop.DisplayItem;
|
||||
import org.maxgamer.quickshop.shop.DisplayType;
|
||||
import org.maxgamer.quickshop.util.GameVersion;
|
||||
import org.maxgamer.quickshop.util.JsonUtil;
|
||||
import org.maxgamer.quickshop.util.ReflectFactory;
|
||||
@@ -404,4 +407,12 @@ public class EnvironmentChecker {
|
||||
}
|
||||
return new ResultContainer(CheckResult.PASSED, "Passed checks");
|
||||
}
|
||||
|
||||
@EnvCheckEntry(name = "PacketListenerAPI conflict Test", priority = 9)
|
||||
public ResultContainer plapiConflictTest() {
|
||||
if (plugin.isDisplay() && DisplayItem.getNowUsing() == DisplayType.VIRTUALITEM && Bukkit.getPluginManager().isPluginEnabled("ProtocolLib") && Bukkit.getPluginManager().isPluginEnabled("PacketListenerAPI")) {
|
||||
return new ResultContainer(CheckResult.WARNING, "Virtual DisplayItem may stop working on your server. We already know plugin [PacketListenerAPI] conflict with plugin [ProtocolLib] (that we required to sending fake items). If you display not showing, please uninstall [PacketListenerAPI]. And it's fine to keep them if nothing wrong.");
|
||||
}
|
||||
return new ResultContainer(CheckResult.PASSED, "Passed checks");
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,28 @@
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
|
||||
# READ ABOVE READ ABOVE READ ABOVE READ ABOVE READ ABOVE READ ABOVE READ ABOVE READ ABOVE READ ABOVE READ ABOVE
|
||||
# IF YOU WANT EDIT CONFIGURATION, THE FILE "config.yml" IS THE CORRECT FILE
|
||||
|
||||
#Do not touch if you not clear know about this
|
||||
config-version: 125
|
||||
config-version: 126
|
||||
|
||||
#Select the language you want to use, (e.g de), use only supported language codes from the list below.
|
||||
#If you use a not exist/not support language, plugin will move to use en_US to keep everything working.
|
||||
@@ -135,7 +153,7 @@ use-caching: true
|
||||
|
||||
#Control which one chat system QuickShop should to use.
|
||||
#0=BungeeChat (Spigot Defaults)
|
||||
#1=Adventure
|
||||
#1=Adventure (Removed In Current Version)
|
||||
chat-type: 0
|
||||
|
||||
#MySQL database settings.
|
||||
@@ -221,6 +239,8 @@ shop:
|
||||
sneak-to-create: false
|
||||
sneak-to-trade: false
|
||||
sneak-to-control: false
|
||||
#Swap left and right click behavior
|
||||
swap-click-behavior: false
|
||||
|
||||
#Should we automatically create the sign for the chest?
|
||||
auto-sign: true
|
||||
@@ -248,7 +268,6 @@ shop:
|
||||
display-check-time: 40
|
||||
|
||||
#Allow display show stacks effect when stack creation turned on
|
||||
#!WIP, DON'T TURN ON IT BEFORE WE FINISH IT!
|
||||
display-allow-stacks: false
|
||||
|
||||
#Use enhance display protect
|
||||
@@ -417,8 +436,6 @@ shop:
|
||||
remove-protection-trigger: true
|
||||
#Allow quickshop selling/buying multi items in once transaction.
|
||||
allow-stacks: false
|
||||
#Disallow player put items into shop container if that item not the shop item. WIP
|
||||
#deny-non-shop-items-to-shop-container: false
|
||||
#List of items that can't be sold in shops. Anyone with quickshop.bypass.<itemID> can bypass it
|
||||
blacklist:
|
||||
- Bedrock
|
||||
@@ -663,6 +680,13 @@ integration:
|
||||
warzone: false
|
||||
#Player must have flags in the faction:
|
||||
flags: [ ]
|
||||
#Superior Skyblock Integration
|
||||
superiorskyblock:
|
||||
enable: false
|
||||
#Does only island owner can create shops on island?
|
||||
owner-create-only: false
|
||||
#Delete shop when the shop owner kicked/quited from island
|
||||
delete-shop-on-member-leave: true
|
||||
#the protection that shop should check
|
||||
protect:
|
||||
explode: true
|
||||
@@ -684,8 +708,6 @@ debug:
|
||||
disable-debuglogger: false
|
||||
#logging stacktrace when deleting shop
|
||||
shop-deletion: false
|
||||
#Enable adventure debug flag
|
||||
adventure: false
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user