mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-29 01:05:40 +01:00
Fixed withdraw GUI and parties glitching out when players are kicked
This commit is contained in:
parent
0e365c58c8
commit
e48f536572
@ -1,9 +1,7 @@
|
||||
package net.Indyuce.mmocore.api.eco;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import io.lumine.mythic.lib.api.event.PlayerLogoutEvent;
|
||||
import io.lumine.mythic.lib.api.util.SmartGive;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
||||
import net.Indyuce.mmocore.util.item.CurrencyItemBuilder;
|
||||
@ -16,10 +14,11 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.lumine.mythic.lib.api.util.SmartGive;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Withdraw implements Listener {
|
||||
private static final Set<UUID> withdrawing = new HashSet<>();
|
||||
@ -90,13 +89,18 @@ public class Withdraw implements Listener {
|
||||
|
||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> {
|
||||
MMOCore.plugin.economy.getEconomy().withdrawPlayer(player, worth);
|
||||
withdrawAlgorythm(worth);
|
||||
withdrawAlgorithm(worth);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
|
||||
ConfigMessage.fromKey("withdrew").addPlaceholders("worth", worth).send(player);
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void withdrawAlgorythm(int worth) {
|
||||
withdrawAlgorithm(worth);
|
||||
}
|
||||
|
||||
public void withdrawAlgorithm(int worth) {
|
||||
int note = worth / 10 * 10;
|
||||
int coins = worth - note;
|
||||
|
||||
@ -109,12 +113,8 @@ public class Withdraw implements Listener {
|
||||
smart.give(coinsItem);
|
||||
}
|
||||
|
||||
/*
|
||||
* extra safety
|
||||
*/
|
||||
@EventHandler
|
||||
public void c(PlayerQuitEvent event) {
|
||||
if (event.getPlayer().equals(player))
|
||||
close();
|
||||
}
|
||||
@EventHandler
|
||||
public void c(PlayerLogoutEvent event) {
|
||||
if (event.getPlayer().equals(player)) close();
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class WithdrawCommand extends RegisteredCommand {
|
||||
}
|
||||
|
||||
MMOCore.plugin.economy.getEconomy().withdrawPlayer(player, amount);
|
||||
request.withdrawAlgorythm(amount);
|
||||
request.withdrawAlgorithm(amount);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
|
||||
ConfigMessage.fromKey("withdrew", "worth", amount).send(player);
|
||||
return true;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmocore.party.provided;
|
||||
|
||||
import io.lumine.mythic.lib.api.event.PlayerLogoutEvent;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
||||
import net.Indyuce.mmocore.api.event.social.PartyChatEvent;
|
||||
@ -10,7 +11,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class PartyListener implements Listener {
|
||||
private final MMOCorePartyModule module;
|
||||
@ -42,10 +42,9 @@ public class PartyListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void leavePartyOnQuit(PlayerQuitEvent event) {
|
||||
public void leavePartyOnQuit(PlayerLogoutEvent event) {
|
||||
final PlayerData playerData = PlayerData.get(event.getPlayer());
|
||||
final AbstractParty party = playerData.getParty();
|
||||
if (party != null)
|
||||
((Party) party).removeMember(playerData);
|
||||
if (party != null) ((Party) party).removeMember(playerData);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user