Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
dmccoystephenson committed Jan 6, 2024
2 parents 2920018 + aa06235 commit 3dd45ef
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 52 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Alternatively, you can use the External API, the documentation for which can be
| [Deej](https://github.com/Mr-Deej) | Added checks to several commands |
| VoChiDanh | Refactored parts the PersistentData class in an attempt to resolve java compatibility issues |
| Kyrenic | Implemented contiguous claims config option |
| [Tems](https://github.com/Tems-py) | Fixed claim protection issues |

### Translators
| Name | Language(s) |
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "com.dansplugins"
version = "5.2.0"
version = "5.3.0-SNAPSHOT"

def repoUsername = ""
def repoPassword = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import com.dansplugins.factionsystem.listener.EntityDamageListener
import com.dansplugins.factionsystem.listener.EntityExplodeListener
import com.dansplugins.factionsystem.listener.InventoryMoveItemListener
import com.dansplugins.factionsystem.listener.LingeringPotionSplashListener
import com.dansplugins.factionsystem.listener.PlayerBucketListener
import com.dansplugins.factionsystem.listener.PlayerDeathListener
import com.dansplugins.factionsystem.listener.PlayerInteractEntityListener
import com.dansplugins.factionsystem.listener.PlayerInteractListener
Expand Down Expand Up @@ -299,6 +300,10 @@ class MedievalFactions : JavaPlugin() {
MedievalFactionsPlaceholderExpansion(this).register()
}

if (config.getBoolean("dynmap.onlyRenderTerritoriesUponStartup")) {
logger.info(language["DynmapOnlyRenderTerritoriesUponStartupEnabled"])
}

if (dynmapService != null) {
factionService.factions.forEach { faction ->
dynmapService.scheduleUpdateClaims(faction)
Expand All @@ -320,6 +325,7 @@ class MedievalFactions : JavaPlugin() {
EntityExplodeListener(this),
InventoryMoveItemListener(this),
LingeringPotionSplashListener(this),
PlayerBucketListener(this),
PlayerDeathListener(this),
PlayerInteractListener(this),
PlayerJoinListener(this),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class MfClaimService(private val plugin: MedievalFactions, private val repositor
}
)
val dynmapService = plugin.services.dynmapService
if (dynmapService != null) {
if (dynmapService != null && !plugin.config.getBoolean("dynmap.onlyRenderTerritoriesUponStartup")) {
plugin.server.scheduler.runTask(
plugin,
Runnable {
Expand Down Expand Up @@ -167,7 +167,7 @@ class MfClaimService(private val plugin: MedievalFactions, private val repositor
if (dynmapService != null) {
val factionService = plugin.services.factionService
val faction = factionService.getFaction(claim.factionId)
if (faction != null) {
if (faction != null && !plugin.config.getBoolean("dynmap.onlyRenderTerritoriesUponStartup")) {
plugin.server.scheduler.runTask(
plugin,
Runnable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import com.dansplugins.factionsystem.command.faction.bonuspower.MfFactionBonusPo
import com.dansplugins.factionsystem.command.faction.breakalliance.MfFactionBreakAllianceCommand
import com.dansplugins.factionsystem.command.faction.bypass.MfFactionBypassCommand
import com.dansplugins.factionsystem.command.faction.chat.MfFactionChatCommand
import com.dansplugins.factionsystem.command.faction.claim.MfFactionClaimAutoCommand
import com.dansplugins.factionsystem.command.faction.claim.MfFactionClaimCheckCommand
import com.dansplugins.factionsystem.command.faction.claim.MfFactionClaimCommand
import com.dansplugins.factionsystem.command.faction.claim.MfFactionClaimFillCommand
import com.dansplugins.factionsystem.command.faction.create.MfFactionCreateCommand
import com.dansplugins.factionsystem.command.faction.declareindependence.MfFactionDeclareIndependenceCommand
import com.dansplugins.factionsystem.command.faction.declarewar.MfFactionDeclareWarCommand
Expand Down Expand Up @@ -44,7 +41,6 @@ import com.dansplugins.factionsystem.command.faction.vassalize.MfFactionVassaliz
import com.dansplugins.factionsystem.command.faction.who.MfFactionWhoCommand
import org.bukkit.ChatColor.AQUA
import org.bukkit.ChatColor.GRAY
import org.bukkit.ChatColor.RED
import org.bukkit.ChatColor.YELLOW
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
Expand Down Expand Up @@ -92,11 +88,6 @@ class MfFactionCommand(private val plugin: MedievalFactions) : CommandExecutor,
private val factionAddMemberCommand = MfFactionAddMemberCommand(plugin)
private val factionDevCommand = MfFactionDevCommand(plugin)

// Backwards compatibility:
private val factionClaimAutoCommand = MfFactionClaimAutoCommand(plugin)
private val factionClaimFillCommand = MfFactionClaimFillCommand(plugin)
private val factionClaimCheckCommand = MfFactionClaimCheckCommand(plugin)

private val helpAliases = listOf("help", plugin.language["CmdFactionHelp"])
private val createAliases = listOf("create", plugin.language["CmdFactionCreate"])
private val claimAliases = listOf("claim", plugin.language["CmdFactionClaim"])
Expand Down Expand Up @@ -136,11 +127,6 @@ class MfFactionCommand(private val plugin: MedievalFactions) : CommandExecutor,
private val addMemberAliases = listOf("addmember", plugin.language["CmdFactionAddMember"])
private val devAliases = if (plugin.config.getBoolean("dev.enableDevCommands")) listOf("dev") else emptyList()

// Backwards compatibility:
private val claimAutoAliases = listOf("autoclaim")
private val claimFillAliases = listOf("claimfill")
private val claimCheckAliases = listOf("checkclaim")

private val subcommands = helpAliases +
createAliases +
claimAliases +
Expand Down Expand Up @@ -178,11 +164,7 @@ class MfFactionCommand(private val plugin: MedievalFactions) : CommandExecutor,
bonusPowerAliases +
relationshipAliases +
addMemberAliases +
devAliases +
// Backwards compatibility aliases:
claimAutoAliases +
claimFillAliases +
claimCheckAliases
devAliases

override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
return when (args.firstOrNull()?.lowercase()) {
Expand Down Expand Up @@ -224,19 +206,6 @@ class MfFactionCommand(private val plugin: MedievalFactions) : CommandExecutor,
in relationshipAliases -> factionRelationshipCommand.onCommand(sender, command, label, args.drop(1).toTypedArray())
in addMemberAliases -> factionAddMemberCommand.onCommand(sender, command, label, args.drop(1).toTypedArray())
in devAliases -> factionDevCommand.onCommand(sender, command, label, args.drop(1).toTypedArray())
// Backwards compatibility:
in claimAutoAliases -> {
sender.sendMessage("${RED}${plugin.language["DeprecationWarningAutoclaim"]}")
false
}
in claimFillAliases -> {
sender.sendMessage("${RED}${plugin.language["DeprecationWarningFillclaim"]}")
false
}
in claimCheckAliases -> {
sender.sendMessage("${RED}${plugin.language["DeprecationWarningCheckclaim"]}")
false
}
else -> {
sender.sendMessage("$AQUA${plugin.language["MedievalFactionsTitle", plugin.description.version]}")
sender.sendMessage("$GRAY${plugin.language["DeveloperList", plugin.description.authors.joinToString()]}")
Expand Down Expand Up @@ -295,10 +264,6 @@ class MfFactionCommand(private val plugin: MedievalFactions) : CommandExecutor,
in relationshipAliases -> factionRelationshipCommand.onTabComplete(sender, command, label, args.drop(1).toTypedArray())
in addMemberAliases -> factionAddMemberCommand.onTabComplete(sender, command, label, args.drop(1).toTypedArray())
in devAliases -> factionDevCommand.onTabComplete(sender, command, label, args.drop(1).toTypedArray())
// Backwards compatibility:
in claimAutoAliases -> factionClaimAutoCommand.onTabComplete(sender, command, label, args.drop(1).toTypedArray())
in claimFillAliases -> factionClaimFillCommand.onTabComplete(sender, command, label, args.drop(1).toTypedArray())
in claimCheckAliases -> factionClaimCheckCommand.onTabComplete(sender, command, label, args.drop(1).toTypedArray())
else -> emptyList()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class MfFactionClaimCommand(private val plugin: MedievalFactions) : CommandExecu
private val fillAliases = listOf("fill", plugin.language["CmdFactionClaimFill"])
private val checkAliases = listOf("check", plugin.language["CmdFactionClaimCheck"])
private val circleAliases = listOf("circle", plugin.language["CmdFactionClaimCircle"])
// private val squareAliases = listOf("square", plugin.language["CmdFactionClaimSquare"])
// private val rectangleAliases = listOf("rectangle", plugin.language["CmdFactionClaimRectangle"])

private val subcommands = autoAliases + fillAliases + checkAliases + circleAliases

Expand All @@ -27,8 +25,6 @@ class MfFactionClaimCommand(private val plugin: MedievalFactions) : CommandExecu
in fillAliases -> factionClaimFillCommand.onCommand(sender, command, label, args.drop(1).toTypedArray())
in checkAliases -> factionClaimCheckCommand.onCommand(sender, command, label, args.drop(1).toTypedArray())
in circleAliases -> factionClaimCircleCommand.onCommand(sender, command, label, args.drop(1).toTypedArray())
// in squareAliases -> FactionClaimSquareCommand.onCommand(sender, command, label, args.drop(1).toTypedArray())
// in rectangleAliases -> FactionClaimRectangleCommand.onCommand(sender, command, label, args.drop(1).toTypedArray())
else -> {
return factionClaimCircleCommand.onCommand(sender, command, label, args)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class MfFactionService(private val plugin: MedievalFactions, private val reposit
val result = repository.upsert(factionToSave)
factionsById[result.id] = result
val dynmapService = plugin.services.dynmapService
if (dynmapService != null) {
if (dynmapService != null && !plugin.config.getBoolean("dynmap.onlyRenderTerritoriesUponStartup")) {
plugin.server.scheduler.runTask(
plugin,
Runnable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.dansplugins.factionsystem.listener
import com.dansplugins.factionsystem.MedievalFactions
import com.dansplugins.factionsystem.player.MfPlayer
import com.dansplugins.factionsystem.relationship.MfFactionRelationshipType
import org.bukkit.entity.Monster
import org.bukkit.entity.Player
import org.bukkit.entity.Projectile
import org.bukkit.event.EventHandler
Expand Down Expand Up @@ -32,6 +33,7 @@ class EntityDamageByEntityListener(private val plugin: MedievalFactions) : Liste
val damagedFaction = factionService.getFaction(claim.factionId) ?: return
if (!damagedFaction.flags[plugin.flags.enableMobProtection]) return
if (damagerFaction?.id == damagedFaction.id) return
if (damaged is Monster) return
event.isCancelled = true
return
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.dansplugins.factionsystem.listener
import com.dansplugins.factionsystem.MedievalFactions
import com.dansplugins.factionsystem.area.MfBlockPosition
import com.dansplugins.factionsystem.player.MfPlayer
import dev.forkhandles.result4k.onFailure
import org.bukkit.ChatColor
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerBucketEmptyEvent
import org.bukkit.event.player.PlayerBucketEvent
import org.bukkit.event.player.PlayerBucketFillEvent
import java.util.logging.Level

class PlayerBucketListener(private val plugin: MedievalFactions) : Listener {
fun handleProtection(event: PlayerBucketEvent) {
val gateService = plugin.services.gateService
val blockPosition = MfBlockPosition.fromBukkitBlock(event.block)
val gates = gateService.getGatesAt(blockPosition)
if (gates.isNotEmpty()) {
event.isCancelled = true
event.player.sendMessage("${ChatColor.RED}${plugin.language["CannotPlaceBlockInGate"]}")
return
}

val claimService = plugin.services.claimService
val claim = claimService.getClaim(event.block.chunk) ?: return
val factionService = plugin.services.factionService
val claimFaction = factionService.getFaction(claim.factionId) ?: return
val playerService = plugin.services.playerService
val mfPlayer = playerService.getPlayer(event.player)
if (mfPlayer == null) {
event.isCancelled = true
plugin.server.scheduler.runTaskAsynchronously(
plugin,
Runnable {
playerService.save(MfPlayer(plugin, event.player)).onFailure {
event.player.sendMessage("${ChatColor.RED}${plugin.language["BlockPlaceFailedToSavePlayer"]}")
plugin.logger.log(Level.SEVERE, "Failed to save player: ${it.reason.message}", it.reason.cause)
return@Runnable
}
}
)
return
}

if (!claimService.isInteractionAllowed(mfPlayer.id, claim)) {
if (mfPlayer.isBypassEnabled && event.player.hasPermission("mf.bypass")) {
event.player.sendMessage("${ChatColor.RED}${plugin.language["FactionTerritoryProtectionBypassed"]}")
} else {
event.isCancelled = true
event.player.sendMessage("${ChatColor.RED}${plugin.language["CannotBreakBlockInFactionTerritory", claimFaction.name]}")
}
}
}

@EventHandler
fun playerBuckeEmptytEvent(event: PlayerBucketEmptyEvent) {
handleProtection(event)
}

@EventHandler
fun playerBucketFillEvent(event: PlayerBucketFillEvent) {
handleProtection(event)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ class PlayerInteractListener(private val plugin: MedievalFactions) : Listener {
val claim = claimService.getClaim(clickedBlock.chunk) ?: return
val factionService = plugin.services.factionService
val claimFaction = factionService.getFaction(claim.factionId) ?: return
val item = event.item
if (item != null) {
if (item.type.isEdible && !clickedBlock.type.isInteractable) return
}
if (!claimService.isInteractionAllowed(mfPlayer.id, claim)) {
if (mfPlayer.isBypassEnabled && event.player.hasPermission("mf.bypass")) {
event.player.sendMessage("$RED${plugin.language["FactionTerritoryProtectionBypassed"]}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MfPlayerService(private val plugin: MedievalFactions, private val playerRe
if (dynmapService != null) {
val factionService = plugin.services.factionService
val faction = factionService.getFaction(result.id)
if (faction != null) {
if (faction != null && !plugin.config.getBoolean("dynmap.onlyRenderTerritoriesUponStartup")) {
plugin.server.scheduler.runTask(
plugin,
Runnable {
Expand All @@ -74,7 +74,7 @@ class MfPlayerService(private val plugin: MedievalFactions, private val playerRe
playerRepository.decreaseOfflinePlayerPower(onlinePlayerIds)
playersById.putAll(playerRepository.getPlayers().associateBy(MfPlayer::id))
val dynmapService = plugin.services.dynmapService
if (dynmapService != null) {
if (dynmapService != null && !plugin.config.getBoolean("dynmap.onlyRenderTerritoriesUponStartup")) {
val factionService = plugin.services.factionService
factionService.factions.forEach { faction ->
plugin.server.scheduler.runTask(
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@ duels:
notificationDistance: 64
dynmap:
enableDynmapIntegration: true
onlyRenderTerritoriesUponStartup: false
dev:
enableDevCommands: false
1 change: 1 addition & 0 deletions src/main/resources/lang/lang_de_DE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1074,3 +1074,4 @@ CommandFactionJoinFactionFull=Die Fraktion, der du beitreten m
CommandFactionAddMemberTargetFactionFull=Die Fraktion, zu der du diesen Spieler hinzufügen möchtest, ist voll.
PlayerInteractEntityFailedToSavePlayer=Der Spieler konnte nicht gespeichert werden.
PlayerInteractEntityCannotTradeWithVillager=Du kannst nicht mit diesem Dorfbewohner handeln.
DynmapOnlyRenderTerritoriesUponStartupEnabled=Die Konfigurationsoption ?dynmap.onlyRenderTerritoriesUponStartup? ist aktiviert. Gebiete werden nur beim Start gerendert.
4 changes: 1 addition & 3 deletions src/main/resources/lang/lang_en_GB.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1068,11 +1068,9 @@ CommandFactionInfoAlliesTitle=Allies:
CommandFactionInfoEnemiesTitle=Enemies:
BlockNotLocked=That block is not locked.
CommandFactionRoleSetPermissionCannotModifyRolePermissionToModifyOwnRolePermission=You cannot modify your role''s permission to modify your own role''s permissions.
DeprecationWarningAutoclaim=Command deprecated. Use /f claim auto instead.
DeprecationWarningFillclaim=Command deprecated. Use /f claim fill instead.
DeprecationWarningCheckclaim=Command deprecated. Use /f claim check instead.
CommandFactionInviteFactionFull=You cannot invite any more members to your faction.
CommandFactionJoinFactionFull=The faction you are trying to join is full.
CommandFactionAddMemberTargetFactionFull=The faction you are trying to add a member to is full.
PlayerInteractEntityFailedToSavePlayer=Failed to save player.
PlayerInteractEntityCannotTradeWithVillager=You cannot trade with this villager.
DynmapOnlyRenderTerritoriesUponStartupEnabled=The `dynmap.onlyRenderTerritoriesUponStartup` config option is enabled. Territories will only be rendered upon startup.
4 changes: 1 addition & 3 deletions src/main/resources/lang/lang_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1068,11 +1068,9 @@ CommandFactionInfoVassalsTitle=Vassals:
CommandFactionInfoAlliesTitle=Allies:
CommandFactionInfoEnemiesTitle=Enemies:
CommandFactionRoleSetPermissionCannotModifyRolePermissionToModifyOwnRolePermission=You cannot modify your role''s permission to modify your own role''s permissions.
DeprecationWarningAutoclaim=Command deprecated. Use /f claim auto instead.
DeprecationWarningFillclaim=Command deprecated. Use /f claim fill instead.
DeprecationWarningCheckclaim=Command deprecated. Use /f claim check instead.
CommandFactionInviteFactionFull=You cannot invite any more members to your faction.
CommandFactionJoinFactionFull=The faction you are trying to join is full.
CommandFactionAddMemberTargetFactionFull=The faction you are trying to add a member to is full.
PlayerInteractEntityFailedToSavePlayer=Failed to save player.
PlayerInteractEntityCannotTradeWithVillager=You cannot trade with this villager.
DynmapOnlyRenderTerritoriesUponStartupEnabled=The `dynmap.onlyRenderTerritoriesUponStartup` config option is enabled. Territories will only be rendered upon startup.
1 change: 1 addition & 0 deletions src/main/resources/lang/lang_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1076,3 +1076,4 @@ CommandFactionJoinFactionFull=La faction est pleine.
CommandFactionAddMemberTargetFactionFull=La faction est pleine.
PlayerInteractEntityFailedToSavePlayer=Impossible de sauvegarder le joueur.
PlayerInteractEntityCannotTradeWithVillager=Vous ne pouvez pas commercer avec ce villageois.
DynmapOnlyRenderTerritoriesUponStartupEnabled=L'option de configuration `dynmap.onlyRenderTerritoriesUponStartup` est activée. Les territoires ne seront rendus qu'au démarrage.

0 comments on commit 3dd45ef

Please sign in to comment.