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 double dxz = Math.sqrt(Math.pow(dx, 2) + Math.pow(dz, 2));
|
||||||
final float pitch = (float) -Math.atan(dy / dxz);
|
final float pitch = (float) -Math.atan(dy / dxz);
|
||||||
// Set values, convert to degrees
|
// 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);
|
loc.setYaw(-loc.getYaw() * 180f / (float) Math.PI + 360);
|
||||||
// But pitch angles are normal
|
// But pitch angles are normal
|
||||||
loc.setPitch(pitch * 180f / (float) Math.PI);
|
loc.setPitch(pitch * 180f / (float) Math.PI);
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
package org.maxgamer.QuickShop.Config;
|
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.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.maxgamer.QuickShop.QuickShop;
|
import org.maxgamer.QuickShop.QuickShop;
|
||||||
import org.maxgamer.QuickShop.Shop.Item.FakeItem_17_18;
|
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.bukkit.Log;
|
||||||
import pw.yumc.YumCore.config.FileConfig;
|
import pw.yumc.YumCore.config.FileConfig;
|
||||||
@ -89,14 +94,16 @@ public class ConfigManager {
|
|||||||
if (config.getBoolean("fakeitem", true)) {
|
if (config.getBoolean("fakeitem", true)) {
|
||||||
try {
|
try {
|
||||||
plugin.getLogger().info("启用虚拟悬浮物 尝试启动中...");
|
plugin.getLogger().info("启用虚拟悬浮物 尝试启动中...");
|
||||||
FakeItem_19_110.register(plugin);
|
FakeItem_19_111.register(plugin);
|
||||||
plugin.getLogger().info("虚拟悬浮物功能测试正常(1.8-1.10.2)...");
|
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;
|
fakeItem = true;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
Log.d(e);
|
Log.d(e);
|
||||||
try {
|
try {
|
||||||
FakeItem_17_18.register(plugin);
|
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;
|
fakeItem = true;
|
||||||
} catch (final Throwable e2) {
|
} catch (final Throwable e2) {
|
||||||
plugin.getLogger().warning("+=========================================");
|
plugin.getLogger().warning("+=========================================");
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package org.maxgamer.QuickShop.Listeners;
|
package org.maxgamer.QuickShop.Listeners;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
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.MsgUtil;
|
||||||
import org.maxgamer.QuickShop.Util.Util;
|
import org.maxgamer.QuickShop.Util.Util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class LockListener implements Listener {
|
public class LockListener implements Listener {
|
||||||
private final QuickShop plugin;
|
private final QuickShop plugin;
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ public class LockListener implements Listener {
|
|||||||
Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
Shop shop = plugin.getShopManager().getShop(b.getLocation());
|
||||||
// Make sure they're not using the non-shop half of a double chest.
|
// Make sure they're not using the non-shop half of a double chest.
|
||||||
if (!hasSecondHalf(shop, b)) { return; }
|
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")) {
|
if (p.hasPermission("quickshop.other.open")) {
|
||||||
p.sendMessage(MsgUtil.p("bypassing-lock"));
|
p.sendMessage(MsgUtil.p("bypassing-lock"));
|
||||||
return;
|
return;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package org.maxgamer.QuickShop.Listeners;
|
package org.maxgamer.QuickShop.Listeners;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
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.MsgUtil;
|
||||||
import org.maxgamer.QuickShop.Util.Util;
|
import org.maxgamer.QuickShop.Util.Util;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
private final QuickShop plugin;
|
private final QuickShop plugin;
|
||||||
|
|
||||||
@ -34,19 +34,15 @@ public class PlayerListener implements Listener {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles players left clicking a chest. Left click a NORMAL chest with
|
* Handles players left clicking a chest. Left click a NORMAL chest with
|
||||||
* item : Send creation menu Left click a SHOP chest : Send purchase menu
|
* item : Send creation menu Left click a SHOP chest : Send purchase menu
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onClick(final PlayerInteractEvent e) {
|
public void onClick(final PlayerInteractEvent e) {
|
||||||
final Block b = e.getClickedBlock();
|
final Block b = e.getClickedBlock();
|
||||||
final Player p = e.getPlayer();
|
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))) {
|
if (e.getAction() != Action.LEFT_CLICK_BLOCK || p.getGameMode() == GameMode.CREATIVE) { return; }
|
||||||
return;
|
|
||||||
}
|
|
||||||
final Location loc = b.getLocation();
|
final Location loc = b.getLocation();
|
||||||
final ItemStack item = e.getItem();
|
final ItemStack item = e.getItem();
|
||||||
// Get the shop
|
// Get the shop
|
||||||
@ -151,13 +147,9 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onSuperItemClick(final PlayerInteractEvent e) {
|
public void onSuperItemClick(final PlayerInteractEvent e) {
|
||||||
final Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
if (p.getGameMode() != GameMode.SURVIVAL || e.getMaterial() != plugin.getConfigManager().getSuperItem()) {
|
if (p.getGameMode() != GameMode.SURVIVAL || e.getMaterial() != plugin.getConfigManager().getSuperItem()) { return; }
|
||||||
return;
|
|
||||||
}
|
|
||||||
final Block b = e.getClickedBlock();
|
final Block b = e.getClickedBlock();
|
||||||
if (b == null || b.getType() == null) {
|
if (b == null || b.getType() == null) { return; }
|
||||||
return;
|
|
||||||
}
|
|
||||||
// If that wasn't a shop, search nearby shops
|
// If that wasn't a shop, search nearby shops
|
||||||
if (b.getType() == Material.WALL_SIGN) {
|
if (b.getType() == Material.WALL_SIGN) {
|
||||||
final Block attached = Util.getAttached(b);
|
final Block attached = Util.getAttached(b);
|
||||||
|
@ -22,9 +22,9 @@ public abstract class DisplayItem {
|
|||||||
if (plugin.getConfigManager().isFakeItem()) {
|
if (plugin.getConfigManager().isFakeItem()) {
|
||||||
try {
|
try {
|
||||||
if (Integer.parseInt(ver.split("_")[1]) > 8) {
|
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 {
|
} else {
|
||||||
return new FakeItem_17_18(shop, shop.getItem());
|
return new FakeItem_17_18(shop.getLocation(), shop.getItem());
|
||||||
}
|
}
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
Log.d(e);
|
Log.d(e);
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package org.maxgamer.QuickShop.Shop.Item;
|
package org.maxgamer.QuickShop.Shop.Item;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
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.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
@ -11,7 +15,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.maxgamer.QuickShop.Shop.ContainerShop;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
@ -37,13 +40,12 @@ public abstract class FakeItem extends DisplayItem {
|
|||||||
protected final UUID uuid;
|
protected final UUID uuid;
|
||||||
protected boolean created = false;
|
protected boolean created = false;
|
||||||
|
|
||||||
public FakeItem(final ContainerShop containerShop, final ItemStack item) {
|
public FakeItem(Location loc, final ItemStack item) {
|
||||||
this.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.eid = getFakeEntityId();
|
||||||
this.uuid = UUID.randomUUID();
|
this.uuid = UUID.randomUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRegistered() {
|
public static boolean isRegistered() {
|
||||||
return registered;
|
return registered;
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package org.maxgamer.QuickShop.Shop.Item;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.maxgamer.QuickShop.Shop.ContainerShop;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
@ -20,8 +20,8 @@ import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
|||||||
*/
|
*/
|
||||||
public class FakeItem_17_18 extends FakeItem {
|
public class FakeItem_17_18 extends FakeItem {
|
||||||
|
|
||||||
public FakeItem_17_18(final ContainerShop containerShop, final ItemStack item) {
|
public FakeItem_17_18(Location loc, final ItemStack item) {
|
||||||
super(containerShop, item);
|
super(loc, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getNormalizedDistance(final double value) {
|
private static int getNormalizedDistance(final double value) {
|
||||||
|
@ -1,50 +1,50 @@
|
|||||||
package org.maxgamer.QuickShop.Shop.Item;
|
package org.maxgamer.QuickShop.Shop.Item;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.Location;
|
||||||
import org.maxgamer.QuickShop.Shop.ContainerShop;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minecraft 虚拟悬浮物品工具类
|
* Minecraft 虚拟悬浮物品工具类
|
||||||
* 需要depend ProtocolLib 4.x
|
* 需要depend ProtocolLib 4.x
|
||||||
*
|
*
|
||||||
* @author 橙子(chengzi)
|
* @author 橙子(chengzi)
|
||||||
* @version 1.1.0
|
* @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) {
|
public FakeItem_19_111(Location loc, final ItemStack item) {
|
||||||
super(containerShop, item);
|
super(loc, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PacketContainer getMetadataPacket() {
|
protected PacketContainer getMetadataPacket() {
|
||||||
final PacketContainer fakePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_METADATA);
|
final PacketContainer fakePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_METADATA);
|
||||||
fakePacket.getIntegers().write(0, eid);
|
fakePacket.getIntegers().write(0, eid);
|
||||||
final WrappedDataWatcher wr = new WrappedDataWatcher();
|
final WrappedDataWatcher wr = new WrappedDataWatcher();
|
||||||
final Serializer serializer = WrappedDataWatcher.Registry.getItemStackSerializer(true);
|
final Serializer serializer = WrappedDataWatcher.Registry.getItemStackSerializer(true);
|
||||||
final WrappedDataWatcherObject object = new WrappedDataWatcher.WrappedDataWatcherObject(6, serializer);
|
final WrappedDataWatcherObject object = new WrappedDataWatcher.WrappedDataWatcherObject(6, serializer);
|
||||||
wr.setObject(object, Optional.of(itemStack));
|
wr.setObject(object, Optional.of(itemStack));
|
||||||
fakePacket.getWatchableCollectionModifier().write(0, wr.getWatchableObjects());
|
fakePacket.getWatchableCollectionModifier().write(0, wr.getWatchableObjects());
|
||||||
return fakePacket;
|
return fakePacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PacketContainer getSpawnPacket() {
|
protected PacketContainer getSpawnPacket() {
|
||||||
final PacketContainer fakePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY);
|
final PacketContainer fakePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY);
|
||||||
fakePacket.getIntegers().write(0, eid);
|
fakePacket.getIntegers().write(0, eid);
|
||||||
fakePacket.getModifier().write(1, uuid);
|
fakePacket.getModifier().write(1, uuid);
|
||||||
fakePacket.getDoubles().write(0, location.getX());
|
fakePacket.getDoubles().write(0, location.getX());
|
||||||
fakePacket.getDoubles().write(1, location.getY());
|
fakePacket.getDoubles().write(1, location.getY());
|
||||||
fakePacket.getDoubles().write(2, location.getZ());
|
fakePacket.getDoubles().write(2, location.getZ());
|
||||||
fakePacket.getIntegers().write(6, 2);
|
fakePacket.getIntegers().write(6, 2);
|
||||||
return fakePacket;
|
return fakePacket;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user