mirror of
https://github.com/EpicEricEE/ShopChest.git
synced 2024-11-27 04:55:34 +01:00
Bug fixes and better shop protection
- Fixed Update Checker after reload - Fixed Update Checker on Minecraft 1.9 - Hoppers shouldn't suck items out of a shop's chest (configurable) - Hoppers shouldn't pickup a shop's floating item - Shops shouldn't get destroyed by an explosion (configurable)
This commit is contained in:
parent
103c96bc2f
commit
6d747f6fea
@ -41,6 +41,12 @@ main-command-name: "shop"
|
||||
# Value MUST be a number (e.g. 1, 1.5, 2.75, ...)
|
||||
maximal-distance: 1.75
|
||||
|
||||
# Set whether the shops' chest should be protected by hoppers
|
||||
hopper-protection: true
|
||||
|
||||
# Set whether the shops' chest should be protected by explosions
|
||||
explosion-protection: true
|
||||
|
||||
# Set the currency symbol after price values
|
||||
currency-symbol: $
|
||||
|
||||
@ -233,7 +239,6 @@ messages:
|
||||
update:
|
||||
|
||||
# Set the message when an update is available.
|
||||
# Unfortunately only the last colored part of the text (if you have multiple colors) becomes clickable (default: only '&chere' is clickable).
|
||||
# Usable regex: %VERSION%
|
||||
update-available: "&l&6Version &c%VERSION% &6of &cShopChest &6is available &chere."
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
name: ShopChest
|
||||
main: de.epiceric.shopchest.ShopChest
|
||||
version: 1.6.0.1
|
||||
version: 1.7.0
|
||||
author: EpicEric
|
||||
website: https://www.spigotmc.org/resources/shopchest.11431/
|
||||
depend: [Vault]
|
||||
|
@ -14,8 +14,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
import de.epiceric.shopchest.interfaces.JsonBuilder;
|
||||
import de.epiceric.shopchest.interfaces.JsonBuilder.ClickAction;
|
||||
import de.epiceric.shopchest.interfaces.JsonBuilder.HoverAction;
|
||||
import de.epiceric.shopchest.interfaces.Utils;
|
||||
import de.epiceric.shopchest.interfaces.jsonbuilder.*;
|
||||
import de.epiceric.shopchest.utils.ClickType;
|
||||
@ -179,10 +177,10 @@ public class Commands extends BukkitCommand {
|
||||
|
||||
JsonBuilder jb;
|
||||
switch (Utils.getVersion(plugin.getServer())) {
|
||||
case "v1_8_R1": jb = new JsonBuilder_1_8_R1(Config.update_available(ShopChest.latestVersion)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink); break;
|
||||
case "v1_8_R2": jb = new JsonBuilder_1_8_R2(Config.update_available(ShopChest.latestVersion)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink); break;
|
||||
case "v1_8_R3": jb = new JsonBuilder_1_8_R3(Config.update_available(ShopChest.latestVersion)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink); break;
|
||||
case "v1_9_R1": jb = new JsonBuilder_1_9_R1(Config.update_available(ShopChest.latestVersion)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink); break;
|
||||
case "v1_8_R1": jb = new JsonBuilder_1_8_R1(Config.update_available(ShopChest.latestVersion)); break;
|
||||
case "v1_8_R2": jb = new JsonBuilder_1_8_R2(Config.update_available(ShopChest.latestVersion)); break;
|
||||
case "v1_8_R3": jb = new JsonBuilder_1_8_R3(Config.update_available(ShopChest.latestVersion)); break;
|
||||
case "v1_9_R1": jb = new JsonBuilder_1_9_R1(Config.update_available(ShopChest.latestVersion)); break;
|
||||
default: return;
|
||||
}
|
||||
jb.sendJson(player);
|
||||
|
@ -31,8 +31,6 @@ import de.epiceric.shopchest.interfaces.utils.*;
|
||||
import de.epiceric.shopchest.shop.Shop;
|
||||
import de.epiceric.shopchest.sql.SQLite;
|
||||
import de.epiceric.shopchest.interfaces.JsonBuilder;
|
||||
import de.epiceric.shopchest.interfaces.JsonBuilder.ClickAction;
|
||||
import de.epiceric.shopchest.interfaces.JsonBuilder.HoverAction;
|
||||
import de.epiceric.shopchest.interfaces.jsonbuilder.*;
|
||||
import de.epiceric.shopchest.utils.Metrics;
|
||||
import de.epiceric.shopchest.utils.Metrics.Graph;
|
||||
@ -45,6 +43,7 @@ import net.milkbowl.vault.permission.Permission;
|
||||
public class ShopChest extends JavaPlugin{
|
||||
|
||||
private static ShopChest instance;
|
||||
private static UpdateChecker uc;
|
||||
|
||||
public static Statement statement;
|
||||
public static Logger logger;
|
||||
@ -174,7 +173,7 @@ public class ShopChest extends JavaPlugin{
|
||||
instance = this;
|
||||
|
||||
|
||||
UpdateChecker uc = new UpdateChecker(this, getDescription().getWebsite());
|
||||
if (uc == null) uc = new UpdateChecker(this, getDescription().getWebsite());
|
||||
logger.info("Checking for Updates");
|
||||
if(uc.updateNeeded()) {
|
||||
latestVersion = uc.getVersion();
|
||||
@ -191,10 +190,10 @@ public class ShopChest extends JavaPlugin{
|
||||
if (p.isOp() || perm.has(p, "shopchest.notification.update")) {
|
||||
JsonBuilder jb;
|
||||
switch (Utils.getVersion(getServer())) {
|
||||
case "v1_8_R1": jb = new JsonBuilder_1_8_R1(Config.update_available(latestVersion)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, downloadLink); break;
|
||||
case "v1_8_R2": jb = new JsonBuilder_1_8_R2(Config.update_available(latestVersion)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, downloadLink); break;
|
||||
case "v1_8_R3": jb = new JsonBuilder_1_8_R3(Config.update_available(latestVersion)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, downloadLink); break;
|
||||
case "v1_9_R1": jb = new JsonBuilder_1_9_R1(Config.update_available(latestVersion)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, downloadLink); break;
|
||||
case "v1_8_R1": jb = new JsonBuilder_1_8_R1(Config.update_available(latestVersion)); break;
|
||||
case "v1_8_R2": jb = new JsonBuilder_1_8_R2(Config.update_available(latestVersion)); break;
|
||||
case "v1_8_R3": jb = new JsonBuilder_1_8_R3(Config.update_available(latestVersion)); break;
|
||||
case "v1_9_R1": jb = new JsonBuilder_1_9_R1(Config.update_available(latestVersion)); break;
|
||||
default: return;
|
||||
}
|
||||
jb.sendJson(p);
|
||||
|
@ -18,6 +18,9 @@ public class Config {
|
||||
public static List<String> blacklist() {return (plugin.getConfig().getStringList("blacklist") == null) ? new ArrayList<String>() : plugin.getConfig().getStringList("blacklist");};
|
||||
|
||||
public static boolean buy_greater_or_equal_sell() {return plugin.getConfig().getBoolean("buy-greater-or-equal-sell");}
|
||||
public static boolean hopper_protection() {return plugin.getConfig().getBoolean("hopper-protection");}
|
||||
public static boolean explosion_protection() {return plugin.getConfig().getBoolean("explosion-protection)");}
|
||||
|
||||
public static double maximal_distance() {return plugin.getConfig().getDouble("maximal-distance");}
|
||||
public static int default_limit() {return plugin.getConfig().getInt("shop-limits.default");}
|
||||
|
||||
|
@ -10,8 +10,6 @@ import de.epiceric.shopchest.config.Config;
|
||||
import de.epiceric.shopchest.interfaces.Utils;
|
||||
import de.epiceric.shopchest.interfaces.jsonbuilder.*;
|
||||
import de.epiceric.shopchest.interfaces.JsonBuilder;
|
||||
import de.epiceric.shopchest.interfaces.JsonBuilder.ClickAction;
|
||||
import de.epiceric.shopchest.interfaces.JsonBuilder.HoverAction;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
public class NotifyUpdate implements Listener {
|
||||
@ -30,10 +28,10 @@ public class NotifyUpdate implements Listener {
|
||||
JsonBuilder jb;
|
||||
|
||||
switch (Utils.getVersion(ShopChest.getInstance().getServer())) {
|
||||
case "v1_8_R1": jb = new JsonBuilder_1_8_R1(Config.update_available(ShopChest.latestVersion)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink); break;
|
||||
case "v1_8_R2": jb = new JsonBuilder_1_8_R2(Config.update_available(ShopChest.latestVersion)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink); break;
|
||||
case "v1_8_R3": jb = new JsonBuilder_1_8_R3(Config.update_available(ShopChest.latestVersion)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink); break;
|
||||
case "v1_9_R1": jb = new JsonBuilder_1_9_R1(Config.update_available(ShopChest.latestVersion)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink); break;
|
||||
case "v1_8_R1": jb = new JsonBuilder_1_8_R1(Config.update_available(ShopChest.latestVersion)); break;
|
||||
case "v1_8_R2": jb = new JsonBuilder_1_8_R2(Config.update_available(ShopChest.latestVersion)); break;
|
||||
case "v1_8_R3": jb = new JsonBuilder_1_8_R3(Config.update_available(ShopChest.latestVersion)); break;
|
||||
case "v1_9_R1": jb = new JsonBuilder_1_9_R1(Config.update_available(ShopChest.latestVersion)); break;
|
||||
default: return;
|
||||
}
|
||||
jb.sendJson(p);
|
||||
|
@ -1,13 +1,20 @@
|
||||
package de.epiceric.shopchest.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
@ -27,6 +34,30 @@ public class ProtectChest implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockExplode(BlockExplodeEvent e) {
|
||||
if (Config.explosion_protection()) {
|
||||
ArrayList<Block> bl = new ArrayList<>(e.blockList());
|
||||
for (Block b : bl) {
|
||||
if (b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST)) {
|
||||
if (ShopUtils.isShop(b.getLocation())) e.blockList().remove(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent e) {
|
||||
if (Config.explosion_protection()) {
|
||||
ArrayList<Block> bl = new ArrayList<>(e.blockList());
|
||||
for (Block b : bl) {
|
||||
if (b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST)) {
|
||||
if (ShopUtils.isShop(b.getLocation())) e.blockList().remove(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent e) {
|
||||
Block b = e.getBlockPlaced();
|
||||
@ -70,4 +101,26 @@ public class ProtectChest implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onItemMove(InventoryMoveItemEvent e) {
|
||||
if (Config.hopper_protection()) {
|
||||
if ((e.getSource().getType().equals(InventoryType.CHEST)) && (!e.getInitiator().getType().equals(InventoryType.PLAYER))) {
|
||||
|
||||
if (e.getSource().getHolder() instanceof DoubleChest) {
|
||||
DoubleChest dc = (DoubleChest) e.getSource().getHolder();
|
||||
Chest r = (Chest) dc.getRightSide();
|
||||
Chest l = (Chest) dc.getLeftSide();
|
||||
|
||||
if (ShopUtils.isShop(r.getLocation()) || ShopUtils.isShop(l.getLocation())) e.setCancelled(true);
|
||||
|
||||
} else if (e.getSource().getHolder() instanceof Chest) {
|
||||
Chest c = (Chest) e.getSource().getHolder();
|
||||
|
||||
if (ShopUtils.isShop(c.getLocation())) e.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ItemDespawnEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
|
||||
public class RegenerateShopItem implements Listener {
|
||||
@ -23,4 +25,11 @@ public class RegenerateShopItem implements Listener {
|
||||
if (e.getItem().hasMetadata("shopItem")) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onItemPickup(InventoryPickupItemEvent e) {
|
||||
if (e.getInventory().getType().equals(InventoryType.HOPPER)) {
|
||||
if (e.getItem().hasMetadata("shopItem")) e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
import de.epiceric.shopchest.interfaces.JsonBuilder;
|
||||
import net.minecraft.server.v1_8_R1.ChatSerializer;
|
||||
import net.minecraft.server.v1_8_R1.PacketPlayOutChat;
|
||||
@ -30,7 +32,7 @@ public class JsonBuilder_1_8_R1 implements JsonBuilder {
|
||||
String regex = "[&§]{1}([a-fA-Fl-oL-O0-9]){1}";
|
||||
text = text.replaceAll(regex, "§$1");
|
||||
if(!Pattern.compile(regex).matcher(text).find()) {
|
||||
withText(text);
|
||||
withText(text).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
|
||||
return this;
|
||||
}
|
||||
String[] words = text.split(regex);
|
||||
@ -39,7 +41,7 @@ public class JsonBuilder_1_8_R1 implements JsonBuilder {
|
||||
for(String word : words) {
|
||||
try {
|
||||
if(index != words[0].length())
|
||||
withText(word).withColor("§"+text.charAt(index - 1));
|
||||
withText(word).withColor("§"+text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
|
||||
} catch(Exception e){}
|
||||
index += word.length() + 2;
|
||||
}
|
||||
@ -48,14 +50,14 @@ public class JsonBuilder_1_8_R1 implements JsonBuilder {
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_8_R1 withText(String text) {
|
||||
extras.add("{text:\"" + text + "\"}");
|
||||
extras.add("{\"text\":\"" + text + "\"}");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_8_R1 withColor(ChatColor color) {
|
||||
String c = color.name().toLowerCase();
|
||||
addSegment(color.isColor() ? "color:" + c : c + ":true");
|
||||
addSegment(color.isColor() ? "\"color\":\"" + c + "\"" : "\"" + c + "\"" + ":true");
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -68,15 +70,15 @@ public class JsonBuilder_1_8_R1 implements JsonBuilder {
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_8_R1 withClickEvent(ClickAction action, String value) {
|
||||
addSegment("clickEvent:{action:" + action.toString().toLowerCase()
|
||||
+ ",value:\"" + value + "\"}");
|
||||
addSegment("\"clickEvent\":{\"action\":\"" + action.toString().toLowerCase()
|
||||
+ "\",\"value\":\"" + value + "\"}");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_8_R1 withHoverEvent(HoverAction action, String value) {
|
||||
addSegment("hoverEvent:{action:" + action.toString().toLowerCase()
|
||||
+ ",value:\"" + value + "\"}");
|
||||
addSegment("\"hoverEvent\":{\"action\":\"" + action.toString().toLowerCase()
|
||||
+ "\",\"value\":\"" + value + "\"}");
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -90,8 +92,8 @@ public class JsonBuilder_1_8_R1 implements JsonBuilder {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if(extras.size() <= 1) return extras.size() == 0 ? "{text:\"\"}" : extras.get(0);
|
||||
String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",extra:[";
|
||||
if(extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0);
|
||||
String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":[";
|
||||
extras.remove(0);;
|
||||
for (String extra : extras)
|
||||
text = text + extra + ",";
|
||||
|
@ -8,6 +8,8 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
import de.epiceric.shopchest.interfaces.JsonBuilder;
|
||||
import net.minecraft.server.v1_8_R2.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.server.v1_8_R2.PacketPlayOutChat;
|
||||
@ -30,7 +32,7 @@ public class JsonBuilder_1_8_R2 implements JsonBuilder {
|
||||
String regex = "[&§]{1}([a-fA-Fl-oL-O0-9]){1}";
|
||||
text = text.replaceAll(regex, "§$1");
|
||||
if(!Pattern.compile(regex).matcher(text).find()) {
|
||||
withText(text);
|
||||
withText(text).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
|
||||
return this;
|
||||
}
|
||||
String[] words = text.split(regex);
|
||||
@ -39,7 +41,7 @@ public class JsonBuilder_1_8_R2 implements JsonBuilder {
|
||||
for(String word : words) {
|
||||
try {
|
||||
if(index != words[0].length())
|
||||
withText(word).withColor("§"+text.charAt(index - 1));
|
||||
withText(word).withColor("§"+text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
|
||||
} catch(Exception e){}
|
||||
index += word.length() + 2;
|
||||
}
|
||||
@ -48,14 +50,14 @@ public class JsonBuilder_1_8_R2 implements JsonBuilder {
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_8_R2 withText(String text) {
|
||||
extras.add("{text:\"" + text + "\"}");
|
||||
extras.add("{\"text\":\"" + text + "\"}");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_8_R2 withColor(ChatColor color) {
|
||||
String c = color.name().toLowerCase();
|
||||
addSegment(color.isColor() ? "color:" + c : c + ":true");
|
||||
addSegment(color.isColor() ? "\"color\":\"" + c + "\"" : "\"" + c + "\"" + ":true");
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -68,15 +70,15 @@ public class JsonBuilder_1_8_R2 implements JsonBuilder {
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_8_R2 withClickEvent(ClickAction action, String value) {
|
||||
addSegment("clickEvent:{action:" + action.toString().toLowerCase()
|
||||
+ ",value:\"" + value + "\"}");
|
||||
addSegment("\"clickEvent\":{\"action\":\"" + action.toString().toLowerCase()
|
||||
+ "\",\"value\":\"" + value + "\"}");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_8_R2 withHoverEvent(HoverAction action, String value) {
|
||||
addSegment("hoverEvent:{action:" + action.toString().toLowerCase()
|
||||
+ ",value:\"" + value + "\"}");
|
||||
addSegment("\"hoverEvent\":{\"action\":\"" + action.toString().toLowerCase()
|
||||
+ "\",\"value\":\"" + value + "\"}");
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -90,8 +92,8 @@ public class JsonBuilder_1_8_R2 implements JsonBuilder {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if(extras.size() <= 1) return extras.size() == 0 ? "{text:\"\"}" : extras.get(0);
|
||||
String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",extra:[";
|
||||
if(extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0);
|
||||
String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":[";
|
||||
extras.remove(0);;
|
||||
for (String extra : extras)
|
||||
text = text + extra + ",";
|
||||
|
@ -8,6 +8,8 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
import de.epiceric.shopchest.interfaces.JsonBuilder;
|
||||
import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
||||
@ -30,7 +32,7 @@ public class JsonBuilder_1_8_R3 implements JsonBuilder {
|
||||
String regex = "[&§]{1}([a-fA-Fl-oL-O0-9]){1}";
|
||||
text = text.replaceAll(regex, "§$1");
|
||||
if(!Pattern.compile(regex).matcher(text).find()) {
|
||||
withText(text);
|
||||
withText(text).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
|
||||
return this;
|
||||
}
|
||||
String[] words = text.split(regex);
|
||||
@ -39,7 +41,7 @@ public class JsonBuilder_1_8_R3 implements JsonBuilder {
|
||||
for(String word : words) {
|
||||
try {
|
||||
if(index != words[0].length())
|
||||
withText(word).withColor("§"+text.charAt(index - 1));
|
||||
withText(word).withColor("§"+text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
|
||||
} catch(Exception e){}
|
||||
index += word.length() + 2;
|
||||
}
|
||||
@ -48,14 +50,14 @@ public class JsonBuilder_1_8_R3 implements JsonBuilder {
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_8_R3 withText(String text) {
|
||||
extras.add("{text:\"" + text + "\"}");
|
||||
extras.add("{\"text\":\"" + text + "\"}");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_8_R3 withColor(ChatColor color) {
|
||||
String c = color.name().toLowerCase();
|
||||
addSegment(color.isColor() ? "color:" + c : c + ":true");
|
||||
addSegment(color.isColor() ? "\"color\":\"" + c + "\"" : "\"" + c + "\"" + ":true");
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -68,15 +70,15 @@ public class JsonBuilder_1_8_R3 implements JsonBuilder {
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_8_R3 withClickEvent(ClickAction action, String value) {
|
||||
addSegment("clickEvent:{action:" + action.toString().toLowerCase()
|
||||
+ ",value:\"" + value + "\"}");
|
||||
addSegment("\"clickEvent\":{\"action\":\"" + action.toString().toLowerCase()
|
||||
+ "\",\"value\":\"" + value + "\"}");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_8_R3 withHoverEvent(HoverAction action, String value) {
|
||||
addSegment("hoverEvent:{action:" + action.toString().toLowerCase()
|
||||
+ ",value:\"" + value + "\"}");
|
||||
addSegment("\"hoverEvent\":{\"action\":\"" + action.toString().toLowerCase()
|
||||
+ "\",\"value\":\"" + value + "\"}");
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -90,8 +92,8 @@ public class JsonBuilder_1_8_R3 implements JsonBuilder {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if(extras.size() <= 1) return extras.size() == 0 ? "{text:\"\"}" : extras.get(0);
|
||||
String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",extra:[";
|
||||
if(extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0);
|
||||
String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":[";
|
||||
extras.remove(0);;
|
||||
for (String extra : extras)
|
||||
text = text + extra + ",";
|
||||
|
@ -8,6 +8,8 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
import de.epiceric.shopchest.interfaces.JsonBuilder;
|
||||
import net.minecraft.server.v1_9_R1.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.server.v1_9_R1.PacketPlayOutChat;
|
||||
@ -30,7 +32,7 @@ public class JsonBuilder_1_9_R1 implements JsonBuilder {
|
||||
String regex = "[&§]{1}([a-fA-Fl-oL-O0-9]){1}";
|
||||
text = text.replaceAll(regex, "§$1");
|
||||
if(!Pattern.compile(regex).matcher(text).find()) {
|
||||
withText(text);
|
||||
withText(text).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
|
||||
return this;
|
||||
}
|
||||
String[] words = text.split(regex);
|
||||
@ -39,7 +41,7 @@ public class JsonBuilder_1_9_R1 implements JsonBuilder {
|
||||
for(String word : words) {
|
||||
try {
|
||||
if(index != words[0].length())
|
||||
withText(word).withColor("§"+text.charAt(index - 1));
|
||||
withText(word).withColor("§"+text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, Config.click_to_download()).withClickEvent(ClickAction.OPEN_URL, ShopChest.downloadLink);
|
||||
} catch(Exception e){}
|
||||
index += word.length() + 2;
|
||||
}
|
||||
@ -48,14 +50,14 @@ public class JsonBuilder_1_9_R1 implements JsonBuilder {
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_9_R1 withText(String text) {
|
||||
extras.add("{text:\"" + text + "\"}");
|
||||
extras.add("{\"text\":\"" + text + "\"}");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_9_R1 withColor(ChatColor color) {
|
||||
String c = color.name().toLowerCase();
|
||||
addSegment(color.isColor() ? "color:" + c : c + ":true");
|
||||
addSegment(color.isColor() ? "\"color\":\"" + c + "\"" : "\"" + c + "\"" + ":true");
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -68,15 +70,15 @@ public class JsonBuilder_1_9_R1 implements JsonBuilder {
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_9_R1 withClickEvent(ClickAction action, String value) {
|
||||
addSegment("clickEvent:{action:" + action.toString().toLowerCase()
|
||||
+ ",value:\"" + value + "\"}");
|
||||
addSegment("\"clickEvent\":{\"action\":\"" + action.toString().toLowerCase()
|
||||
+ "\",\"value\":\"" + value + "\"}");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonBuilder_1_9_R1 withHoverEvent(HoverAction action, String value) {
|
||||
addSegment("hoverEvent:{action:" + action.toString().toLowerCase()
|
||||
+ ",value:\"" + value + "\"}");
|
||||
addSegment("\"hoverEvent\":{\"action\":\"" + action.toString().toLowerCase()
|
||||
+ "\",\"value\":\"" + value + "\"}");
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -90,8 +92,8 @@ public class JsonBuilder_1_9_R1 implements JsonBuilder {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if(extras.size() <= 1) return extras.size() == 0 ? "{text:\"\"}" : extras.get(0);
|
||||
String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",extra:[";
|
||||
if(extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0);
|
||||
String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":[";
|
||||
extras.remove(0);;
|
||||
for (String extra : extras)
|
||||
text = text + extra + ",";
|
||||
|
@ -8,7 +8,6 @@ import java.util.UUID;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
@ -104,16 +103,6 @@ public class ShopUtils {
|
||||
|
||||
}
|
||||
|
||||
public static String getConfigTitle(Location location) {
|
||||
World w = location.getWorld();
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
|
||||
return w.getName() + "_" + String.valueOf(x) + "_" + String.valueOf(y) + "_" + String.valueOf(z);
|
||||
}
|
||||
|
||||
|
||||
public static int getShopLimit(Player p) {
|
||||
int limit = Config.default_limit();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user