mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 04:25:15 +01:00
Informing about lost ownership
Option to override existing ownerships Option to set range
This commit is contained in:
parent
122ee48197
commit
2c5602ab8b
@ -66,7 +66,7 @@ public class GeneralConfigManager {
|
|||||||
SoundTitleChangeSound, ServerAccountName, ServertaxesAccountName, localeString = "";
|
SoundTitleChangeSound, ServerAccountName, ServertaxesAccountName, localeString = "";
|
||||||
private String getSelectionTool, DecimalPlacesMoney, DecimalPlacesExp, DecimalPlacesPoints;
|
private String getSelectionTool, DecimalPlacesMoney, DecimalPlacesExp, DecimalPlacesPoints;
|
||||||
|
|
||||||
public int jobExpiryTime, BlockProtectionDays, FireworkPower, ShootTime,
|
public int jobExpiryTime, BlockProtectionDays, FireworkPower, ShootTime, blockOwnershipRange,
|
||||||
globalblocktimer, CowMilkingTimer, InfoUpdateInterval, JobsTopAmount, PlaceholdersPage, ConfirmExpiryTime,
|
globalblocktimer, CowMilkingTimer, InfoUpdateInterval, JobsTopAmount, PlaceholdersPage, ConfirmExpiryTime,
|
||||||
SegmentCount, BossBarTimer, AutoJobJoinDelay, DBCleaningJobsLvl, DBCleaningUsersDays, BlastFurnacesMaxDefault, SmokersMaxDefault,
|
SegmentCount, BossBarTimer, AutoJobJoinDelay, DBCleaningJobsLvl, DBCleaningUsersDays, BlastFurnacesMaxDefault, SmokersMaxDefault,
|
||||||
levelLossPercentageFromMax, levelLossPercentage, SoundLevelupVolume, SoundLevelupPitch, SoundTitleChangeVolume,
|
levelLossPercentageFromMax, levelLossPercentage, SoundLevelupVolume, SoundLevelupPitch, SoundTitleChangeVolume,
|
||||||
@ -96,7 +96,7 @@ public class GeneralConfigManager {
|
|||||||
EmptyServerAccountActionBar, ActionBarsMessageByDefault, aBarSilentMode, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment,
|
EmptyServerAccountActionBar, ActionBarsMessageByDefault, aBarSilentMode, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment,
|
||||||
JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, ShowActionNames, hideItemAttributes,
|
JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, ShowActionNames, hideItemAttributes,
|
||||||
DisableJoiningJobThroughGui, FireworkLevelupUse, UseRandom, UsePerPermissionForLeaving,
|
DisableJoiningJobThroughGui, FireworkLevelupUse, UseRandom, UsePerPermissionForLeaving,
|
||||||
EnableConfirmation, jobsInfoOpensBrowse, MonsterDamageUse, useMaxPaymentCurve,
|
EnableConfirmation, jobsInfoOpensBrowse, MonsterDamageUse, useMaxPaymentCurve, blockOwnershipTakeOver,
|
||||||
hideJobsInfoWithoutPermission, UseTaxes, TransferToServerAccount, TakeFromPlayersPayment, AutoJobJoinUse, AllowDelevel, RomanNumbers,
|
hideJobsInfoWithoutPermission, UseTaxes, TransferToServerAccount, TakeFromPlayersPayment, AutoJobJoinUse, AllowDelevel, RomanNumbers,
|
||||||
BossBarEnabled = false, BossBarShowOnEachAction = false, BossBarsMessageByDefault = false, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse,
|
BossBarEnabled = false, BossBarShowOnEachAction = false, BossBarsMessageByDefault = false, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse,
|
||||||
DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled,
|
DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled,
|
||||||
@ -1038,6 +1038,13 @@ public class GeneralConfigManager {
|
|||||||
tmat = CMIMaterial.get(c.get("JobsGUI.Filler.Material", "GREEN_STAINED_GLASS_PANE"));
|
tmat = CMIMaterial.get(c.get("JobsGUI.Filler.Material", "GREEN_STAINED_GLASS_PANE"));
|
||||||
guiFiller = (tmat == CMIMaterial.NONE ? CMIMaterial.GREEN_STAINED_GLASS_PANE : tmat);
|
guiFiller = (tmat == CMIMaterial.NONE ? CMIMaterial.GREEN_STAINED_GLASS_PANE : tmat);
|
||||||
|
|
||||||
|
c.addComment("BlockOwnership.Range", "Set to 0 or lower if you want to disable this. Setting to positive number will mean that player needs to be in this range from owner block to get paid");
|
||||||
|
blockOwnershipRange = c.get("BlockOwnership.Range", 0);
|
||||||
|
|
||||||
|
c.addComment("BlockOwnership.TakeOver", "When enabled by interacting with furncae ownership will get transfered to new player",
|
||||||
|
"If set to false then furnace will belong to player who interacted with it first until its ownership is removed");
|
||||||
|
blockOwnershipTakeOver = c.get("BlockOwnership.TakeOver", false);
|
||||||
|
|
||||||
c.save();
|
c.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,6 +478,7 @@ public class LanguageManager {
|
|||||||
c.get("command.clearownership.help.args", "[playername]");
|
c.get("command.clearownership.help.args", "[playername]");
|
||||||
Jobs.getGCManager().getCommandArgs().put("clearownership", Arrays.asList("[playername]"));
|
Jobs.getGCManager().getCommandArgs().put("clearownership", Arrays.asList("[playername]"));
|
||||||
c.get("command.clearownership.output.cleared", "&2Removed &7[furnaces] &2furnaces, &7[brewing] &2brewing stands, &7[smoker]&2 smokers and &7[blast]&2 blast furnaces.");
|
c.get("command.clearownership.output.cleared", "&2Removed &7[furnaces] &2furnaces, &7[brewing] &2brewing stands, &7[smoker]&2 smokers and &7[blast]&2 blast furnaces.");
|
||||||
|
c.get("command.clearownership.output.lost", "&cLost ownership of &7[type] &cat [location]");
|
||||||
|
|
||||||
c.get("command.skipquest.help.info", "Skip defined quest and get new one");
|
c.get("command.skipquest.help.info", "Skip defined quest and get new one");
|
||||||
c.get("command.skipquest.help.args", "[jobname] [questname] (playerName)");
|
c.get("command.skipquest.help.args", "[jobname] [questname] (playerName)");
|
||||||
|
@ -9,6 +9,7 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -23,7 +24,6 @@ import com.gamingmesh.jobs.stuff.blockLoc;
|
|||||||
|
|
||||||
import net.Zrips.CMILib.Container.CMILocation;
|
import net.Zrips.CMILib.Container.CMILocation;
|
||||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||||
import net.Zrips.CMILib.Logs.CMIDebug;
|
|
||||||
|
|
||||||
public class BlockOwnerShip {
|
public class BlockOwnerShip {
|
||||||
|
|
||||||
@ -91,13 +91,26 @@ public class BlockOwnerShip {
|
|||||||
return ownershipFeedback.invalid;
|
return ownershipFeedback.invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<String, blockLoc> oldRecords = getBlockOwnerShips().get(player.getUniqueId());
|
UUID ownerUUID = this.getOwnerByLocation(block.getLocation());
|
||||||
|
|
||||||
if (oldRecords != null) {
|
if (ownerUUID != null && ownerUUID.equals(player.getUniqueId()))
|
||||||
blockLoc existing = oldRecords.get(CMILocation.toString(block.getLocation(), ":", true, true));
|
return ownershipFeedback.old;
|
||||||
if (existing != null) {
|
|
||||||
return ownershipFeedback.old;
|
if (ownerUUID != null && !ownerUUID.equals(player.getUniqueId())) {
|
||||||
}
|
if (Jobs.getGCManager().blockOwnershipTakeOver) {
|
||||||
|
// Removing ownership to record new player
|
||||||
|
this.remove(ownerUUID, CMILocation.toString(block.getLocation(), ":", true, true));
|
||||||
|
block.removeMetadata(metadataName, plugin);
|
||||||
|
|
||||||
|
Player owningPlayer = Bukkit.getPlayer(ownerUUID);
|
||||||
|
|
||||||
|
if (owningPlayer != null && owningPlayer.isOnline()) {
|
||||||
|
owningPlayer.sendMessage(Jobs.getLanguage().getMessage("command.clearownership.output.lost", "[type]", CMIMaterial.get(type.toString()).getName(), "[location]", CMILocation.toString(block.getLocation(), ":",
|
||||||
|
true, true)));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else
|
||||||
|
return ownershipFeedback.notOwn;
|
||||||
}
|
}
|
||||||
|
|
||||||
int max = jPlayer.getMaxOwnerShipAllowed(type);
|
int max = jPlayer.getMaxOwnerShipAllowed(type);
|
||||||
@ -106,14 +119,9 @@ public class BlockOwnerShip {
|
|||||||
boolean owner = false;
|
boolean owner = false;
|
||||||
List<MetadataValue> data = getBlockMetadatas(block);
|
List<MetadataValue> data = getBlockMetadatas(block);
|
||||||
if (!data.isEmpty()) {
|
if (!data.isEmpty()) {
|
||||||
if (!data.get(0).asString().equals(jPlayer.getUniqueId().toString())) {
|
|
||||||
return ownershipFeedback.notOwn;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (have > max && max > 0) {
|
if (have > max && max > 0) {
|
||||||
remove(block);
|
remove(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
owner = true;
|
owner = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,26 +213,26 @@ public class BlockOwnerShip {
|
|||||||
|
|
||||||
return ls.size();
|
return ls.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int remove(UUID uuid, String location) {
|
public int remove(UUID uuid, String location) {
|
||||||
HashMap<String, blockLoc> ls = blockOwnerShips.get(uuid);
|
HashMap<String, blockLoc> ls = blockOwnerShips.get(uuid);
|
||||||
if (ls == null)
|
if (ls == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (Entry<String, blockLoc> one : new HashMap<String, blockLoc>(ls).entrySet()) {
|
for (Entry<String, blockLoc> one : new HashMap<String, blockLoc>(ls).entrySet()) {
|
||||||
|
|
||||||
if (!one.getKey().equalsIgnoreCase(location))
|
if (!one.getKey().equalsIgnoreCase(location))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
one.getValue().getBlock().removeMetadata(metadataName, plugin);
|
one.getValue().getBlock().removeMetadata(metadataName, plugin);
|
||||||
|
|
||||||
ls.remove(one.getKey());
|
ls.remove(one.getKey());
|
||||||
|
|
||||||
Map<String, UUID> oldRecord = ownerMapByLocation.get(one.getValue().getWorldName());
|
Map<String, UUID> oldRecord = ownerMapByLocation.get(one.getValue().getWorldName());
|
||||||
if (oldRecord != null)
|
if (oldRecord != null)
|
||||||
oldRecord.remove(one.getValue().toVectorString());
|
oldRecord.remove(one.getValue().toVectorString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +310,7 @@ public class BlockOwnerShip {
|
|||||||
Map<String, UUID> oldRecord = ownerMapByLocation.getOrDefault(bl.getWorldName(), new HashMap<String, UUID>());
|
Map<String, UUID> oldRecord = ownerMapByLocation.getOrDefault(bl.getWorldName(), new HashMap<String, UUID>());
|
||||||
oldRecord.put(bl.toVectorString(), uuid);
|
oldRecord.put(bl.toVectorString(), uuid);
|
||||||
ownerMapByLocation.put(bl.getWorldName(), oldRecord);
|
ownerMapByLocation.put(bl.getWorldName(), oldRecord);
|
||||||
|
|
||||||
total++;
|
total++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,7 +390,13 @@ public final class JobsPaymentListener implements Listener {
|
|||||||
|
|
||||||
Player player = jPlayer.getPlayer();
|
Player player = jPlayer.getPlayer();
|
||||||
|
|
||||||
if (player == null || !Jobs.getPermissionHandler().hasWorldPermission(player))
|
if (player == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Jobs.getGCManager().blockOwnershipRange > 0 && Util.getDistance(player.getLocation(), block.getLocation()) > Jobs.getGCManager().blockOwnershipRange)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!Jobs.getPermissionHandler().hasWorldPermission(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// check if player is riding
|
// check if player is riding
|
||||||
@ -1105,9 +1111,12 @@ public final class JobsPaymentListener implements Listener {
|
|||||||
if (player == null || !player.isOnline())
|
if (player == null || !player.isOnline())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
if (Jobs.getGCManager().blockOwnershipRange > 0 && Util.getDistance(player.getLocation(), block.getLocation()) > Jobs.getGCManager().blockOwnershipRange)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!Jobs.getPermissionHandler().hasWorldPermission(player))
|
||||||
|
return;
|
||||||
|
|
||||||
// check if player is riding
|
// check if player is riding
|
||||||
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
|
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
|
||||||
return;
|
return;
|
||||||
|
@ -16,6 +16,7 @@ import java.util.jar.JarFile;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -85,6 +86,17 @@ public final class Util {
|
|||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double getDistance(Location loc1, Location loc2) {
|
||||||
|
if (loc1 == null || loc2 == null || loc1.getWorld() != loc2.getWorld())
|
||||||
|
return Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return loc1.distance(loc2);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
return Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String getRealType(Entity entity) {
|
public static String getRealType(Entity entity) {
|
||||||
if (Version.isCurrentEqualOrHigher(Version.v1_11_R1)) {
|
if (Version.isCurrentEqualOrHigher(Version.v1_11_R1)) {
|
||||||
return entity.getType().name();
|
return entity.getType().name();
|
||||||
|
Loading…
Reference in New Issue
Block a user