mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-29 05:26:12 +01:00
Try to create an account when creating shop for other players
This commit is contained in:
parent
4172d8d484
commit
07a22fa534
@ -1,10 +1,10 @@
|
||||
package com.Acrobot.ChestShop.Listeners.PreShopCreation;
|
||||
|
||||
import com.Acrobot.ChestShop.ChestShop;
|
||||
import com.Acrobot.ChestShop.Database.Account;
|
||||
import com.Acrobot.ChestShop.Events.AccountQueryEvent;
|
||||
import com.Acrobot.ChestShop.Events.PreShopCreationEvent;
|
||||
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -41,8 +41,20 @@ public class NameChecker implements Listener {
|
||||
account = NameManager.getOrCreateAccount(player);
|
||||
} else {
|
||||
AccountQueryEvent accountQueryEvent = new AccountQueryEvent(name);
|
||||
Bukkit.getPluginManager().callEvent(accountQueryEvent);
|
||||
ChestShop.callEvent(accountQueryEvent);
|
||||
account = accountQueryEvent.getAccount();
|
||||
if (account == null) {
|
||||
Player otherPlayer = ChestShop.getBukkitServer().getPlayer(name);
|
||||
try {
|
||||
if (otherPlayer != null) {
|
||||
account = NameManager.getOrCreateAccount(otherPlayer);
|
||||
} else {
|
||||
account = NameManager.getOrCreateAccount(ChestShop.getBukkitServer().getOfflinePlayer(name));
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
event.getPlayer().sendMessage(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user