Merge remote-tracking branch 'origin/master'

This commit is contained in:
nossr50 2023-04-07 17:00:13 -07:00
commit 921a0228db
5 changed files with 61 additions and 47 deletions

View File

@ -200,15 +200,19 @@ public class PartyCommand implements TabExecutor {
if (matches.size() == 0) { if (matches.size() == 0) {
Player player = (Player) sender; Player player = (Player) sender;
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//Not Loaded //Not Loaded
if(UserManager.getPlayer(player) == null) if(mcMMOPlayer == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return ImmutableList.of(); return ImmutableList.of();
} }
Party party = UserManager.getPlayer(player).getParty(); if (mcMMOPlayer.getParty() == null)
return ImmutableList.of();
final Party party = mcMMOPlayer.getParty();
playerNames = party.getOnlinePlayerNames(player); playerNames = party.getOnlinePlayerNames(player);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size())); return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size()));

View File

@ -25,7 +25,7 @@ public class PartyRenameCommand implements CommandExecutor {
Party playerParty = mcMMOPlayer.getParty(); Party playerParty = mcMMOPlayer.getParty();
String oldPartyName = playerParty.getName(); String oldPartyName = playerParty.getName();
String newPartyName = args[1]; String newPartyName = args[1].replace(".", "");
// This is to prevent party leaders from spamming other players with the rename message // This is to prevent party leaders from spamming other players with the rename message
if (oldPartyName.equalsIgnoreCase(newPartyName)) { if (oldPartyName.equalsIgnoreCase(newPartyName)) {

View File

@ -450,6 +450,9 @@ public class PlayerListener implements Listener {
case CAUGHT_FISH: case CAUGHT_FISH:
if(caught instanceof Item) { if(caught instanceof Item) {
if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) { if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) {
fishingManager.processExploiting(event.getHook().getLocation().toVector());
if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) { if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) {
player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange())); player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
event.setExpToDrop(0); event.setExpToDrop(0);

View File

@ -28,6 +28,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
public final class PartyManager { public final class PartyManager {
private static final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml"; private static final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
@ -609,34 +610,38 @@ public final class PartyManager {
ArrayList<Party> hasAlly = new ArrayList<>(); ArrayList<Party> hasAlly = new ArrayList<>();
for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) { for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
Party party = new Party(partyName); try {
Party party = new Party(partyName);
String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]"); String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]");
party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1])); party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1]));
party.setPassword(partiesFile.getString(partyName + ".Password")); party.setPassword(partiesFile.getString(partyName + ".Password"));
party.setLocked(partiesFile.getBoolean(partyName + ".Locked")); party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
party.setLevel(partiesFile.getInt(partyName + ".Level")); party.setLevel(partiesFile.getInt(partyName + ".Level"));
party.setXp(partiesFile.getInt(partyName + ".Xp")); party.setXp(partiesFile.getInt(partyName + ".Xp"));
if (partiesFile.getString(partyName + ".Ally") != null) { if (partiesFile.getString(partyName + ".Ally") != null) {
hasAlly.add(party); hasAlly.add(party);
}
party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
for (ItemShareType itemShareType : ItemShareType.values()) {
party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true));
}
LinkedHashMap<UUID, String> members = party.getMembers();
for (String memberEntry : partiesFile.getStringList(partyName + ".Members")) {
String[] memberSplit = memberEntry.split("[|]");
members.put(UUID.fromString(memberSplit[0]), memberSplit[1]);
}
parties.add(party);
} catch (Exception e) {
mcMMO.p.getLogger().log(Level.WARNING, "An exception occurred while loading a party with name '" + partyName + "'. Skipped loading party.", e);
} }
party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
for (ItemShareType itemShareType : ItemShareType.values()) {
party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true));
}
LinkedHashMap<UUID, String> members = party.getMembers();
for (String memberEntry : partiesFile.getStringList(partyName + ".Members")) {
String[] memberSplit = memberEntry.split("[|]");
members.put(UUID.fromString(memberSplit[0]), memberSplit[1]);
}
parties.add(party);
} }
mcMMO.p.debug("Loaded (" + parties.size() + ") Parties..."); mcMMO.p.debug("Loaded (" + parties.size() + ") Parties...");

View File

@ -51,6 +51,7 @@ public class FishingManager extends SkillManager {
private long lastWarnedExhaust = 0L; private long lastWarnedExhaust = 0L;
private FishHook fishHookReference; private FishHook fishHookReference;
private BoundingBox lastFishingBoundingBox; private BoundingBox lastFishingBoundingBox;
private boolean sameTarget;
private Item fishingCatch; private Item fishingCatch;
private Location hookLocation; private Location hookLocation;
private int fishCaughtCounter = 1; private int fishCaughtCounter = 1;
@ -125,6 +126,25 @@ public class FishingManager extends SkillManager {
return hasFished; return hasFished;
} }
public void processExploiting(Vector centerOfCastVector) {
BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector);
this.sameTarget = lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(newCastBoundingBox);
if (this.sameTarget) {
fishCaughtCounter++;
}
else {
fishCaughtCounter = 1;
}
//If the new bounding box does not intersect with the old one, then update our bounding box reference
if (!this.sameTarget) lastFishingBoundingBox = newCastBoundingBox;
if (fishCaughtCounter + 1 == ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit()) {
getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
}
}
public boolean isExploitingFishing(Vector centerOfCastVector) { public boolean isExploitingFishing(Vector centerOfCastVector) {
/*Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100); /*Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100);
@ -133,25 +153,7 @@ public class FishingManager extends SkillManager {
return false; return false;
}*/ }*/
BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector); return this.sameTarget && fishCaughtCounter >= ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit();
boolean sameTarget = lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(newCastBoundingBox);
if(sameTarget)
fishCaughtCounter++;
else
fishCaughtCounter = 1;
if(fishCaughtCounter + 1 == ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit())
{
getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
}
//If the new bounding box does not intersect with the old one, then update our bounding box reference
if(!sameTarget)
lastFishingBoundingBox = newCastBoundingBox;
return sameTarget && fishCaughtCounter >= ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit();
} }
public static BoundingBox makeBoundingBox(Vector centerOfCastVector) { public static BoundingBox makeBoundingBox(Vector centerOfCastVector) {