mirror of
https://e.coding.net/circlecloud/QuickShop.git
synced 2024-11-25 02:28:54 +00:00
fix: 虚拟悬浮物兼容
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
b90049aad7
commit
36dd2ac988
@ -429,7 +429,7 @@ public class QuickShopCommands implements Executor, HelpParse {
|
||||
final double dxz = Math.sqrt(Math.pow(dx, 2) + Math.pow(dz, 2));
|
||||
final float pitch = (float) -Math.atan(dy / dxz);
|
||||
// Set values, convert to degrees
|
||||
// Minecraft yaw (vertical) angles are inverted (negative)
|
||||
// ServerInfo yaw (vertical) angles are inverted (negative)
|
||||
loc.setYaw(-loc.getYaw() * 180f / (float) Math.PI + 360);
|
||||
// But pitch angles are normal
|
||||
loc.setPitch(pitch * 180f / (float) Math.PI);
|
||||
|
@ -1,14 +1,19 @@
|
||||
package org.maxgamer.QuickShop.Config;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.maxgamer.QuickShop.QuickShop;
|
||||
import org.maxgamer.QuickShop.Shop.Item.FakeItem_17_18;
|
||||
import org.maxgamer.QuickShop.Shop.Item.FakeItem_19_110;
|
||||
import org.maxgamer.QuickShop.Shop.Item.FakeItem_19_111;
|
||||
|
||||
import pw.yumc.YumCore.bukkit.Log;
|
||||
import pw.yumc.YumCore.config.FileConfig;
|
||||
@ -89,14 +94,16 @@ public class ConfigManager {
|
||||
if (config.getBoolean("fakeitem", true)) {
|
||||
try {
|
||||
plugin.getLogger().info("启用虚拟悬浮物 尝试启动中...");
|
||||
FakeItem_19_110.register(plugin);
|
||||
plugin.getLogger().info("虚拟悬浮物功能测试正常(1.8-1.10.2)...");
|
||||
FakeItem_19_111.register(plugin);
|
||||
new FakeItem_19_111(new Location(Bukkit.getWorlds().get(0), 0, 0, 0), new ItemStack(Material.STONE)).spawn();
|
||||
plugin.getLogger().info("虚拟悬浮物功能测试正常(1.9-1.11.2)...");
|
||||
fakeItem = true;
|
||||
} catch (final Throwable e) {
|
||||
Log.d(e);
|
||||
try {
|
||||
FakeItem_17_18.register(plugin);
|
||||
plugin.getLogger().info("虚拟悬浮物功能测试正常(1.7)...");
|
||||
new FakeItem_17_18(new Location(Bukkit.getWorlds().get(0), 0, 0, 0), new ItemStack(Material.STONE)).spawn();
|
||||
plugin.getLogger().info("虚拟悬浮物功能测试正常(1.7-1.8)...");
|
||||
fakeItem = true;
|
||||
} catch (final Throwable e2) {
|
||||
plugin.getLogger().warning("+=========================================");
|
||||
|
@ -1,5 +1,8 @@
|
||||
package org.maxgamer.QuickShop.Listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -16,9 +19,6 @@ import org.maxgamer.QuickShop.Shop.Shop;
|
||||
import org.maxgamer.QuickShop.Util.MsgUtil;
|
||||
import org.maxgamer.QuickShop.Util.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LockListener implements Listener {
|
||||
private final QuickShop plugin;
|
||||
|
||||
@ -63,7 +63,7 @@ public class LockListener implements Listener {
|
||||
Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||
// Make sure they're not using the non-shop half of a double chest.
|
||||
if (!hasSecondHalf(shop, b)) { return; }
|
||||
if (!shop.getOwner().equals(p.getName())) {
|
||||
if (shop != null && !shop.getOwner().equals(p.getName())) {
|
||||
if (p.hasPermission("quickshop.other.open")) {
|
||||
p.sendMessage(MsgUtil.p("bypassing-lock"));
|
||||
return;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package org.maxgamer.QuickShop.Listeners;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -25,8 +27,6 @@ import org.maxgamer.QuickShop.Shop.ShopType;
|
||||
import org.maxgamer.QuickShop.Util.MsgUtil;
|
||||
import org.maxgamer.QuickShop.Util.Util;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
private final QuickShop plugin;
|
||||
|
||||
@ -34,19 +34,15 @@ public class PlayerListener implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles players left clicking a chest. Left click a NORMAL chest with
|
||||
* item : Send creation menu Left click a SHOP chest : Send purchase menu
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onClick(final PlayerInteractEvent e) {
|
||||
final Block b = e.getClickedBlock();
|
||||
final Player p = e.getPlayer();
|
||||
if (e.getAction() != Action.LEFT_CLICK_BLOCK || (e.getMaterial() == plugin.getConfigManager().getSuperItem() && (b.getType() == Material.WALL_SIGN || p.getGameMode() == GameMode.CREATIVE))) {
|
||||
return;
|
||||
}
|
||||
if (e.getAction() != Action.LEFT_CLICK_BLOCK || p.getGameMode() == GameMode.CREATIVE) { return; }
|
||||
final Location loc = b.getLocation();
|
||||
final ItemStack item = e.getItem();
|
||||
// Get the shop
|
||||
@ -151,13 +147,9 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onSuperItemClick(final PlayerInteractEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
if (p.getGameMode() != GameMode.SURVIVAL || e.getMaterial() != plugin.getConfigManager().getSuperItem()) {
|
||||
return;
|
||||
}
|
||||
if (p.getGameMode() != GameMode.SURVIVAL || e.getMaterial() != plugin.getConfigManager().getSuperItem()) { return; }
|
||||
final Block b = e.getClickedBlock();
|
||||
if (b == null || b.getType() == null) {
|
||||
return;
|
||||
}
|
||||
if (b == null || b.getType() == null) { return; }
|
||||
// If that wasn't a shop, search nearby shops
|
||||
if (b.getType() == Material.WALL_SIGN) {
|
||||
final Block attached = Util.getAttached(b);
|
||||
|
@ -22,9 +22,9 @@ public abstract class DisplayItem {
|
||||
if (plugin.getConfigManager().isFakeItem()) {
|
||||
try {
|
||||
if (Integer.parseInt(ver.split("_")[1]) > 8) {
|
||||
return new FakeItem_19_110(shop, shop.getItem());
|
||||
return new FakeItem_19_111(shop.getLocation(), shop.getItem());
|
||||
} else {
|
||||
return new FakeItem_17_18(shop, shop.getItem());
|
||||
return new FakeItem_17_18(shop.getLocation(), shop.getItem());
|
||||
}
|
||||
} catch (final Throwable e) {
|
||||
Log.d(e);
|
||||
|
@ -1,7 +1,11 @@
|
||||
package org.maxgamer.QuickShop.Shop.Item;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@ -11,7 +15,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.maxgamer.QuickShop.Shop.ContainerShop;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
@ -37,13 +40,12 @@ public abstract class FakeItem extends DisplayItem {
|
||||
protected final UUID uuid;
|
||||
protected boolean created = false;
|
||||
|
||||
public FakeItem(final ContainerShop containerShop, final ItemStack item) {
|
||||
public FakeItem(Location loc, final ItemStack item) {
|
||||
this.itemStack = item;
|
||||
this.location = containerShop.getLocation().clone().add(0.5, 1, 0.5);
|
||||
this.location = loc.clone().add(0.5, 1, 0.5);
|
||||
this.eid = getFakeEntityId();
|
||||
this.uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
public static boolean isRegistered() {
|
||||
return registered;
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package org.maxgamer.QuickShop.Shop.Item;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.maxgamer.QuickShop.Shop.ContainerShop;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
@ -20,8 +20,8 @@ import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
*/
|
||||
public class FakeItem_17_18 extends FakeItem {
|
||||
|
||||
public FakeItem_17_18(final ContainerShop containerShop, final ItemStack item) {
|
||||
super(containerShop, item);
|
||||
public FakeItem_17_18(Location loc, final ItemStack item) {
|
||||
super(loc, item);
|
||||
}
|
||||
|
||||
private static int getNormalizedDistance(final double value) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.maxgamer.QuickShop.Shop.Item;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.maxgamer.QuickShop.Shop.ContainerShop;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
@ -18,10 +18,10 @@ import com.google.common.base.Optional;
|
||||
* @author 橙子(chengzi)
|
||||
* @version 1.1.0
|
||||
*/
|
||||
public class FakeItem_19_110 extends FakeItem {
|
||||
public class FakeItem_19_111 extends FakeItem {
|
||||
|
||||
public FakeItem_19_110(final ContainerShop containerShop, final ItemStack item) {
|
||||
super(containerShop, item);
|
||||
public FakeItem_19_111(Location loc, final ItemStack item) {
|
||||
super(loc, item);
|
||||
}
|
||||
|
||||
@Override
|
Loading…
Reference in New Issue
Block a user