1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-30 21:07:48 +01:00

Lets inform only once for disabled payments until relog

This commit is contained in:
Zrips 2022-05-25 17:25:34 +03:00
parent 0fab191980
commit c3ef100910
2 changed files with 34 additions and 6 deletions

View File

@ -23,9 +23,11 @@ import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import org.bukkit.OfflinePlayer;
@ -94,6 +96,8 @@ public class JobsPlayer {
private PlayerPoints pointsData = new PlayerPoints();
private Set<String> blockOwnerShipInform = null;
public JobsPlayer(OfflinePlayer player) {
this.userName = player.getName() == null ? "Unknown" : player.getName();
this.playerUUID = player.getUniqueId();
@ -892,6 +896,7 @@ public class JobsPlayer {
public void onDisconnect() {
clearBossMaps();
isOnline = false;
blockOwnerShipInform = null;
Jobs.getPlayerManager().addPlayerToCache(this);
}
@ -1428,4 +1433,16 @@ public class JobsPlayer {
map.put(job, cal.getTimeInMillis());
leftTimes.put(uuid, map);
}
public boolean hasBlockOwnerShipInform(String location) {
if (blockOwnerShipInform == null)
return false;
return blockOwnerShipInform.contains(location);
}
public void addBlockOwnerShipInform(String location) {
if (blockOwnerShipInform == null)
blockOwnerShipInform = new HashSet<String>();
this.blockOwnerShipInform.add(location);
}
}

View File

@ -1114,9 +1114,16 @@ public final class JobsPaymentListener implements Listener {
if (player == null || !player.isOnline())
return;
CMIMessages.sendMessage(player, Jobs.getLanguage().getMessage("general.error.blockDisabled",
"[type]", CMIMaterial.get(finalBlock).getName(),
"[location]", LC.Location_Full.getLocale(finalBlock.getLocation())));
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
String lc = CMILocation.toString(finalBlock.getLocation());
if (!jPlayer.hasBlockOwnerShipInform(lc)) {
CMIMessages.sendMessage(player, Jobs.getLanguage().getMessage("general.error.blockDisabled",
"[type]", CMIMaterial.get(finalBlock).getName(),
"[location]", LC.Location_Full.getLocale(finalBlock.getLocation())));
jPlayer.addBlockOwnerShipInform(lc);
}
}
});
@ -1141,9 +1148,13 @@ public final class JobsPaymentListener implements Listener {
if (player == null || !player.isOnline())
return;
CMIMessages.sendMessage(player, Jobs.getLanguage().getMessage("general.error.blockDisabled",
"[type]", CMIMaterial.get(stand.getBlock()).getName(),
"[location]", LC.Location_Full.getLocale(stand.getLocation())));
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
String lc = CMILocation.toString(stand.getLocation());
if (!jPlayer.hasBlockOwnerShipInform(lc)) {
CMIMessages.sendMessage(player, Jobs.getLanguage().getMessage("general.error.blockDisabled",
"[type]", CMIMaterial.get(stand.getBlock()).getName(),
"[location]", LC.Location_Full.getLocale(stand.getLocation())));
}
}
});
}