Skip to content

Commit

Permalink
Release/v5.3 (#1779)
Browse files Browse the repository at this point in the history
Co-authored-by: Ren Binden <ren.binden@gmail.com>
Co-authored-by: Donut <86391164+Chocolate1Donut@users.noreply.github.com>
Co-authored-by: Tems <79542785+Tems-py@users.noreply.github.com>
Co-authored-by: Will <87247824+MestreWilll@users.noreply.github.com>
Co-authored-by: MestreWilll <WillXOkumura@hotmail.com>
  • Loading branch information
6 people authored Jan 19, 2024
1 parent 03174cc commit 83e2aaf
Show file tree
Hide file tree
Showing 21 changed files with 1,227 additions and 60 deletions.
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ubuntu

# Install dependencies
RUN apt-get update
RUN apt-get install -y git \
openjdk-17-jdk \
openjdk-17-jre \
wget

# Create server directory
WORKDIR /testmcserver

# Build server
RUN wget -O BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
RUN git config --global --unset core.autocrlf || :
RUN java -jar BuildTools.jar --rev 1.20.4
RUN echo "eula=true" > eula.txt
RUN mkdir plugins

# Build plugin
COPY . .
RUN ./gradlew build
RUN cp build/libs/*-all.jar plugins

# Run server
EXPOSE 25565
ENTRYPOINT java -jar spigot-1.20.4.jar
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ 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 |
| MestreWilll | Contributed Brazilian Portueguese translation |

### Translators
| Name | Language(s) |
Expand All @@ -103,6 +105,7 @@ Alternatively, you can use the External API, the documentation for which can be
| JustGllenn | Dutch |
| TDL | Dutch |
| [n0virus](https://www.youtube.com/c/n0virus) | Dutch |
| MestreWilll | Brazilian Portuguese |

I created this plugin because I wanted to use the original [Factions](https://www.spigotmc.org/resources/factions.1900/) plugin for an upcoming server of mine, but it wasn't updated for the version of minecraft I was going to be using. I decided to take inspiration from the concept of factions - groups of players that can claim land - and create my own factions plugin.

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"

def repoUsername = ""
def repoPassword = ""
Expand Down
7 changes: 7 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
testmcserver:
build: .
image: mf-test-mc-server
container_name: mf-test-mc-server
ports:
- "25565:25565"
16 changes: 11 additions & 5 deletions src/main/kotlin/com/dansplugins/factionsystem/MedievalFactions.kt
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 @@ -182,6 +183,11 @@ class MedievalFactions : JavaPlugin() {

val gson = Gson()
val playerRepository: MfPlayerRepository = JooqMfPlayerRepository(this, dsl)
val dynmapService = if (server.pluginManager.getPlugin("dynmap") != null && config.getBoolean("dynmap.enableDynmapIntegration")) {
MfDynmapService(this)
} else {
null
}
val factionRepository: MfFactionRepository = JooqMfFactionRepository(this, dsl, gson)
val lawRepository: MfLawRepository = JooqMfLawRepository(dsl)
val factionRelationshipRepository: MfFactionRelationshipRepository = JooqMfFactionRelationshipRepository(dsl)
Expand All @@ -207,11 +213,6 @@ class MedievalFactions : JavaPlugin() {
val duelService = MfDuelService(this, duelRepository, duelInviteRepository)
val potionService = MfPotionService(this)
val teleportService = MfTeleportService(this)
val dynmapService = if (server.pluginManager.getPlugin("dynmap") != null && config.getBoolean("dynmap.enableDynmapIntegration")) {
MfDynmapService(this)
} else {
null
}

services = Services(
playerService,
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 @@ -23,6 +23,7 @@ import kotlin.math.floor
class MfFactionClaimFillCommand(private val plugin: MedievalFactions) : CommandExecutor, TabCompleter {

private val decimalFormat = DecimalFormat("0", DecimalFormatSymbols.getInstance(plugin.language.locale))
private val claimFillMaxChunks = plugin.config.getInt("factions.claimFillMaxChunks", -1)

override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
if (!sender.hasPermission("mf.claim.fill") && !sender.hasPermission("mf.claimfill")) {
Expand Down Expand Up @@ -64,7 +65,13 @@ class MfFactionClaimFillCommand(private val plugin: MedievalFactions) : CommandE
plugin.server.scheduler.runTaskAsynchronously(
plugin,
Runnable saveChunks@{
val chunks = fill(senderWorldId, senderChunkX, senderChunkZ, faction)
val chunks: Set<MfChunkPosition>?
try {
chunks = fill(senderWorldId, senderChunkX, senderChunkZ, faction)
} catch (e: ClaimFillLimitReachedException) {
sender.sendMessage("$RED${plugin.language["CommandFactionClaimFillTooManyChunks", claimFillMaxChunks.toString()]}")
return@saveChunks
}
if (chunks == null) {
sender.sendMessage("$RED${plugin.language["CommandFactionClaimFillNotEnoughPower"]}")
return@saveChunks
Expand Down Expand Up @@ -116,6 +123,9 @@ class MfFactionClaimFillCommand(private val plugin: MedievalFactions) : CommandE
if (chunksToFill.contains(MfChunkPosition(worldId, startChunkX, startChunkZ))) return chunksToFill
val newChunks = mutableSetOf(*chunksToFill.toTypedArray(), MfChunkPosition(worldId, startChunkX, startChunkZ))
if (newChunks.size + claimService.getClaims(faction.id).size > faction.power) return null
if (claimFillMaxChunks > 0 && newChunks.size > claimFillMaxChunks) {
throw ClaimFillLimitReachedException()
}
val westChunks = fill(worldId, startChunkX - 1, startChunkZ, faction, newChunks) ?: return null
newChunks += westChunks
val eastChunks = fill(worldId, startChunkX + 1, startChunkZ, faction, newChunks) ?: return null
Expand All @@ -133,4 +143,6 @@ class MfFactionClaimFillCommand(private val plugin: MedievalFactions) : CommandE
label: String,
args: Array<out String>
) = emptyList<String>()

class ClaimFillLimitReachedException : Exception()
}
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
Loading

0 comments on commit 83e2aaf

Please sign in to comment.