mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 09:59:49 -05:00
Implement missed item name features and event
Former-commit-id: b36977fcb5213c2eb45df91d00eaf2e667cd8bd2
This commit is contained in:
1 parent
3ea23e02db
commit
3671cf09da
2 files changed
+35
-15
No files matched your search
@@ -25,12 +25,8 @@ import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
@@ -42,8 +38,15 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.event.ShopDisplayItemSpawnEvent;
|
||||
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.atomic.AtomicInteger;
|
||||
|
||||
public class VirtualDisplayItem extends DisplayItem {
|
||||
|
||||
|
||||
@@ -157,6 +160,12 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
//List<DataWatcher$Item> Type are more complex
|
||||
//Create a DataWatcher
|
||||
WrappedDataWatcher wpw = new WrappedDataWatcher();
|
||||
//https://wiki.vg/index.php?title=Entity_metadata#Entity
|
||||
if (plugin.getConfig().getBoolean("shop.display-item-use-name")) {
|
||||
wpw.setObject(2,WrappedDataWatcher.Registry.getChatComponentSerializer(true),Optional.of(WrappedChatComponent.fromText(Util.getItemStackName(shop.getItem())).getHandle()));
|
||||
wpw.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(3,WrappedDataWatcher.Registry.get(Boolean.class)),true);
|
||||
}
|
||||
|
||||
//Must in the certain slot:https://wiki.vg/Entity_metadata#Item
|
||||
//For 1.13 is 6, and 1.14+ is 7
|
||||
switch (version) {
|
||||
@@ -276,6 +285,13 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
|
||||
@Override
|
||||
public void spawn() {
|
||||
ShopDisplayItemSpawnEvent shopDisplayItemSpawnEvent = new ShopDisplayItemSpawnEvent(shop, originalItemStack, DisplayType.VIRTUALITEM);
|
||||
Bukkit.getPluginManager().callEvent(shopDisplayItemSpawnEvent);
|
||||
if (shopDisplayItemSpawnEvent.isCancelled()) {
|
||||
Util.debugLog(
|
||||
"Canceled the displayItem spawning because a plugin setCancelled the spawning event, usually this is a QuickShop Add on");
|
||||
return;
|
||||
}
|
||||
load();
|
||||
sendFakeItemToAll();
|
||||
isDisplay = true;
|
||||
|
||||
@@ -24,16 +24,6 @@ import io.sentry.SentryClientFactory;
|
||||
import io.sentry.context.Context;
|
||||
import io.sentry.event.BreadcrumbBuilder;
|
||||
import io.sentry.event.UserBuilder;
|
||||
import java.io.IOException;
|
||||
import java.net.ProtocolException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Filter;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.InvalidPluginException;
|
||||
@@ -45,6 +35,17 @@ import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.util.paste.Paste;
|
||||
import org.maxgamer.quickshop.watcher.UpdateWatcher;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ProtocolException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Filter;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Auto report errors to qs's sentry.
|
||||
*/
|
||||
@@ -344,6 +345,9 @@ public class SentryErrorReporter {
|
||||
if (level != Level.WARNING && level != Level.SEVERE) {
|
||||
return true;
|
||||
}
|
||||
if(record.getThrown()==null){
|
||||
return true;
|
||||
}
|
||||
if (Util.isDevMode()) {
|
||||
sendError(record.getThrown(), record.getMessage());
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user