Skip to content

Commit 0aa61b2

Browse files
committed
Shop register check
1 parent 074e6a4 commit 0aa61b2

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.maxgamer.quickshop.event;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
import org.bukkit.entity.Player;
7+
8+
@EqualsAndHashCode(callSuper = true)
9+
@AllArgsConstructor
10+
@Data
11+
public class QSHandleChatEvent extends AbstractQSEvent{
12+
private Player sender;
13+
private String message;
14+
}

src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,12 @@ public void onLoad() {
932932
Util.debugLog("Dupe load request, canceled.");
933933
return;
934934
}
935+
Map<Location, Shop> shopsInChunk = plugin.getShopManager().getShops(getLocation().getChunk());
936+
937+
if(shopsInChunk == null || shopsInChunk.isEmpty() || !shopsInChunk.containsValue(this)){
938+
throw new IllegalStateException("Shop must register into ShopManager before loading.");
939+
}
940+
935941
ShopLoadEvent shopLoadEvent = new ShopLoadEvent(this);
936942
if (Util.fireCancellableEvent(shopLoadEvent)) {
937943
return;

src/main/java/org/maxgamer/quickshop/shop/ShopManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,12 @@ public void handleChat(@NotNull Player p, @NotNull String msg, boolean bypassPro
485485
}
486486
String message = net.md_5.bungee.api.ChatColor.stripColor(msg);
487487
message = ChatColor.stripColor(message);
488+
QSHandleChatEvent qsHandleChatEvent = new QSHandleChatEvent(p,msg);
489+
qsHandleChatEvent.callEvent();
490+
message = qsHandleChatEvent.getMessage();
488491
// Use from the main thread, because Bukkit hates life
489492
String finalMessage = message;
493+
490494
Util.mainThreadRun(() -> {
491495
Map<UUID, Info> actions = getActions();
492496
// They wanted to do something.

0 commit comments

Comments
 (0)