Skip to content

Commit bd86de0

Browse files
committed
Migrate: OutboundToDiscordEvents [ci skip]
1 parent 6747b31 commit bd86de0

19 files changed

+137
-189
lines changed

V1_20/pom.xml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
<artifactId>MultiChatDiscordSrvAddon-V1_20</artifactId>
3434

3535
<repositories>
36+
<repository>
37+
<id>spigotmc-repo</id>
38+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
39+
</repository>
3640
<repository>
3741
<id>dmulloy2-repo</id>
3842
<url>https://repo.dmulloy2.net/repository/public/</url>
@@ -46,10 +50,6 @@
4650
<name>Pineta</name>
4751
<url>https://repo.pinodev.it/releases</url>
4852
</repository>
49-
<repository>
50-
<id>spigotmc-repo</id>
51-
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
52-
</repository>
5353
<repository>
5454
<id>sonatype</id>
5555
<url>https://oss.sonatype.org/content/groups/public/</url>
@@ -98,12 +98,6 @@
9898
<version>1.20.1-R0.1-SNAPSHOT</version>
9999
<scope>provided</scope>
100100
</dependency>
101-
<dependency>
102-
<groupId>it.pino.zelchat</groupId>
103-
<artifactId>api</artifactId>
104-
<version>2.0.0</version>
105-
<scope>provided</scope>
106-
</dependency>
107101
<dependency>
108102
<groupId>com.loohp</groupId>
109103
<artifactId>MultiChatDiscordSrvAddon-Abstraction</artifactId>

common/src/main/java/com/loohp/multichatdiscordsrvaddon/Commands.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,17 @@
2020

2121
package com.loohp.multichatdiscordsrvaddon;
2222

23+
import com.loohp.multichatdiscordsrvaddon.utils.*;
2324
import net.kyori.adventure.text.Component;
2425
import net.kyori.adventure.text.event.HoverEvent;
2526
import net.kyori.adventure.text.format.NamedTextColor;
26-
import com.loohp.multichatdiscordsrvaddon.utils.ChatColorUtils;
27-
import com.loohp.multichatdiscordsrvaddon.utils.ComponentStyling;
28-
import com.loohp.multichatdiscordsrvaddon.utils.LanguageUtils;
2927
import com.loohp.multichatdiscordsrvaddon.api.events.InteractiveChatDiscordSRVConfigReloadEvent;
3028
import com.loohp.multichatdiscordsrvaddon.listeners.InboundToGameEvents;
3129
import com.loohp.multichatdiscordsrvaddon.listeners.InboundToGameEvents.DiscordAttachmentData;
3230
import com.loohp.multichatdiscordsrvaddon.registry.ResourceRegistry;
3331
import com.loohp.multichatdiscordsrvaddon.resources.ResourcePackInfo;
3432
import com.loohp.multichatdiscordsrvaddon.updater.Updater;
3533
import com.loohp.multichatdiscordsrvaddon.updater.Updater.UpdaterResponse;
36-
import com.loohp.multichatdiscordsrvaddon.utils.ResourcePackInfoUtils;
37-
import com.loohp.multichatdiscordsrvaddon.utils.TranslationKeyUtils;
3834
import com.loohp.multichatdiscordsrvaddon.wrappers.GraphicsToPacketMapWrapper;
3935
import net.md_5.bungee.api.ChatColor;
4036
import org.bukkit.Bukkit;
@@ -66,7 +62,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
6662

6763
if (args[0].equalsIgnoreCase("status")) {
6864
if (sender.hasPermission("interactivechatdiscordsrv.status")) {
69-
sender.sendMessage(InteractiveChatDiscordSrvAddon.plugin.defaultResourceHashLang.replaceFirst("%s", InteractiveChatDiscordSrvAddon.plugin.defaultResourceHash + " (" + InteractiveChat.exactMinecraftVersion + ")"));
65+
sender.sendMessage(InteractiveChatDiscordSrvAddon.plugin.defaultResourceHashLang.replaceFirst("%s", InteractiveChatDiscordSrvAddon.plugin.defaultResourceHash + " (" + VersionManager.exactMinecraftVersion + ")"));
7066
sender.sendMessage(InteractiveChatDiscordSrvAddon.plugin.loadedResourcesLang);
7167
for (ResourcePackInfo info : InteractiveChatDiscordSrvAddon.plugin.getResourceManager().getResourcePackInfo()) {
7268
Component name = ResourcePackInfoUtils.resolveName(info);

common/src/main/java/com/loohp/multichatdiscordsrvaddon/InteractiveChatDiscordSrvAddon.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ public class InteractiveChatDiscordSrvAddon extends JavaPlugin implements Listen
150150
public boolean itemUseTooltipImageOnBaseItem = false;
151151
public boolean itemAltAir = true;
152152
public String itemTitle = "%player_name%'s Item";
153+
public String inventoryTitle = "%player_name%'s Inventory";
154+
public String enderTitle;
153155
public long itemDisplayTimeout = 300000;
154156
public boolean hideLodestoneCompassPos = true;
155157
public boolean invShowLevel = true;
@@ -283,8 +285,8 @@ public class InteractiveChatDiscordSrvAddon extends JavaPlugin implements Listen
283285
public static ICPlaceholder enderChestPlaceholder = null;
284286
public ItemStack invFrame1 = null;
285287
public ItemStack invFrame2 = null;
286-
public static ItemStack itemFrame1;
287-
public static ItemStack itemFrame2;
288+
public ItemStack itemFrame1;
289+
public ItemStack itemFrame2;
288290
public static Map<UUID, ICPlaceholder> placeholderList = new LinkedHashMap<>();
289291

290292
public int itemTagMaxLength = 32767;
@@ -306,6 +308,7 @@ public class InteractiveChatDiscordSrvAddon extends JavaPlugin implements Listen
306308
private ResourceManager resourceManager;
307309
public ModelRenderer modelRenderer;
308310
public ExecutorService mediaReadingService;
311+
public static PlaceholderCooldownManager placeholderCooldownManager;
309312

310313
protected Map<String, byte[]> extras = new ConcurrentHashMap<>();
311314

@@ -358,6 +361,8 @@ public void onEnable() {
358361
DiscordSRV.api.subscribe(new OutboundToDiscordEvents());
359362
DiscordSRV.api.subscribe(new InboundToGameEvents());
360363

364+
placeholderCooldownManager = new PlaceholderCooldownManager();
365+
361366
getServer().getPluginManager().registerEvents(this, this);
362367
getServer().getPluginManager().registerEvents(new InboundToGameEvents(), this);
363368
getServer().getPluginManager().registerEvents(new OutboundToDiscordEvents(), this);
@@ -515,7 +520,9 @@ public void reloadConfig() {
515520

516521
itemUseTooltipImageOnBaseItem = config.getConfiguration().getBoolean("InventoryImage.Item.UseTooltipImageOnBaseItem");
517522
itemAltAir = config.getConfiguration().getBoolean("InventoryImage.Item.AlternateAirTexture");
518-
itemTitle = ChatColorUtils.translateAlternateColorCodes('&', config.getConfiguration().getString("InventoryImage.Item.InventoryTitle"));
523+
itemTitle = ChatColorUtils.translateAlternateColorCodes('&', config.getConfiguration().getString("InventoryImage.Item.ItemTitle"));
524+
inventoryTitle = ChatColorUtils.translateAlternateColorCodes('&', config.getConfiguration().getString("InventoryImage.Inventory.InventoryTitle"));
525+
enderTitle = ChatColorUtils.translateAlternateColorCodes('&', config.getConfiguration().getString("InventoryImage.EnderChest.Text"));
519526
itemDisplayTimeout = config.getConfiguration().getLong("Settings.Timeout") * 60 * 1000;
520527
hideLodestoneCompassPos = config.getConfiguration().getBoolean("Settings.HideLodestoneCompassPos");
521528

@@ -708,6 +715,9 @@ public void reloadConfig() {
708715
invFrame1 = new ItemStack(Material.valueOf(getConfig().getString("InventoryImage.Inventory.Frame.Primary")), 1);
709716
invFrame2 = new ItemStack(Material.valueOf(getConfig().getString("InventoryImage.Inventory.Frame.Secondary")), 1);
710717

718+
itemFrame1 = new ItemStack(Material.valueOf(getConfig().getString("InventoryImage.Item.Frame.Primary")), 1);
719+
itemFrame2 = new ItemStack(Material.valueOf(getConfig().getString("InventoryImage.Item.Frame.Secondary")), 1);
720+
711721
universalCooldown = config.getConfiguration().getLong("Settings.UniversalCooldown") * 1000;
712722

713723
FontTextureResource.setCacheTime(cacheTimeout);

common/src/main/java/com/loohp/multichatdiscordsrvaddon/api/events/PlaceholderEvent.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
package com.loohp.multichatdiscordsrvaddon.api.events;
2222

23-
import com.loohp.interactivechat.objectholders.ICPlayer;
2423
import net.kyori.adventure.text.Component;
2524
import org.bukkit.Bukkit;
2625
import org.bukkit.entity.Player;

common/src/main/java/com/loohp/multichatdiscordsrvaddon/graphics/ImageGeneration.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.loohp.blockmodelrenderer.blending.BlendingModes;
2424
import com.loohp.blockmodelrenderer.utils.ColorUtils;
2525
import com.cryptomorin.xseries.XMaterial;
26+
import com.loohp.multichatdiscordsrvaddon.objectholders.*;
2627
import com.loohp.multichatdiscordsrvaddon.utils.MCVersion;
2728
import com.loohp.multichatdiscordsrvaddon.utils.VersionManager;
2829
import com.loohp.multichatdiscordsrvaddon.utils.*;
@@ -36,18 +37,9 @@
3637
import org.json.simple.JSONArray;
3738
import org.json.simple.JSONObject;
3839
import org.json.simple.parser.JSONParser;
39-
import com.loohp.multichatdiscordsrvaddon.objectholders.ICMaterial;
40-
import com.loohp.multichatdiscordsrvaddon.objectholders.ValuePairs;
41-
import com.loohp.multichatdiscordsrvaddon.objectholders.ValueTrios;
4240
import com.loohp.multichatdiscordsrvaddon.InteractiveChatDiscordSrvAddon;
4341
import com.loohp.multichatdiscordsrvaddon.debug.Debug;
4442
import com.loohp.multichatdiscordsrvaddon.nms.NMS;
45-
import com.loohp.multichatdiscordsrvaddon.objectholders.AdvancementType;
46-
import com.loohp.multichatdiscordsrvaddon.objectholders.CustomModelData;
47-
import com.loohp.multichatdiscordsrvaddon.objectholders.PaintingVariant;
48-
import com.loohp.multichatdiscordsrvaddon.objectholders.SteppedIntegerRange;
49-
import com.loohp.multichatdiscordsrvaddon.objectholders.TintColorProvider;
50-
import com.loohp.multichatdiscordsrvaddon.objectholders.ToolTipComponent;
5143
import com.loohp.multichatdiscordsrvaddon.objectholders.ToolTipComponent.ToolTipType;
5244
import com.loohp.multichatdiscordsrvaddon.registry.ResourceRegistry;
5345
import com.loohp.multichatdiscordsrvaddon.resources.CacheObject;
@@ -260,7 +252,7 @@ public static BufferedImage getInventoryImage(Inventory inventory, Component tit
260252
InteractiveChatDiscordSrvAddon.plugin.inventoryImageCounter.incrementAndGet();
261253
Debug.debug("ImageGeneration creating inventory image of " + player.getName());
262254

263-
String key = INVENTORY_CACHE_KEY + HashUtils.createSha1(title == null ? "Inventory" : InteractiveChatComponentSerializer.gson().serialize(title), inventory);
255+
String key = INVENTORY_CACHE_KEY + HashUtils.createSha1(title == null ? "Inventory" : AbstractInteractiveChatComponentSerializer.gson().serialize(title), inventory);
264256
if (!inventory.contains(XMaterial.COMPASS.parseMaterial()) && !inventory.contains(XMaterial.CLOCK.parseMaterial()) && Arrays.stream(inventory.getContents()).noneMatch(each -> each != null && !CustomModelData.isEmpty(NMS.getInstance().getCustomModelData(each)))) {
265257
CacheObject<?> cache = resourceManager.get().getResourceRegistry(ICacheManager.IDENTIFIER, ICacheManager.class).getCache(key);
266258
if (cache != null) {
@@ -327,7 +319,8 @@ public static BufferedImage getPlayerInventoryImage(Inventory inventory, ItemSta
327319
}
328320
}
329321

330-
String key = PLAYER_INVENTORY_CACHE_KEY + HashUtils.createSha1(PlayerUtils.isRightHanded(player), PlayerUtils.getSelectedItemSlot(player), 0, player.getUniqueId().toString(), inventory) + ImageUtils.hash(background);
322+
OfflinePlayerData offlinePlayerData = PlayerUtils.getData(player);
323+
String key = PLAYER_INVENTORY_CACHE_KEY + HashUtils.createSha1(PlayerUtils.isRightHanded(player), offlinePlayerData.getSelectedSlot(), 0, player.getUniqueId().toString(), inventory) + ImageUtils.hash(background);
331324
if (!inventory.contains(XMaterial.COMPASS.parseMaterial()) && !inventory.contains(XMaterial.CLOCK.parseMaterial()) && Arrays.stream(inventory.getContents()).noneMatch(each -> each != null && !CustomModelData.isEmpty(NMS.getInstance().getCustomModelData(each)))) {
332325
CacheObject<?> cache = resourceManager.get().getResourceRegistry(ICacheManager.IDENTIFIER, ICacheManager.class).getCache(key);
333326
if (cache != null) {

0 commit comments

Comments
 (0)