Fixes POM, and moves things around
This commit is contained in:
parent
e3ef78f8f8
commit
bb0be8a3f0
@ -1,28 +1,36 @@
|
|||||||
## Affected Plugin
|
## Affected Plugin
|
||||||
|
|
||||||
<!-- In order to help you we need to know which plugin this issue is about. -->
|
<!-- In order to help you we need to know which plugin this issue is about. -->
|
||||||
<!-- The plugin always has the same version as MassiveCore. -->
|
<!-- The plugin always has the same version as MassiveCore. -->
|
||||||
<!-- All our plugins depend on MassiveCore, you did not forget to install it did you? -->
|
<!-- All our plugins depend on MassiveCore, you did not forget to install it did you? -->
|
||||||
<!-- Run the command "/massivecore version" to see the version you are running. -->
|
<!-- Run the command "/massivecore version" to see the version you are running. -->
|
||||||
|
|
||||||
- **Affected Plugin Name:** Factions
|
- **Affected Plugin Name:** Factions
|
||||||
- **Affected Plugin Version:** ???
|
- **Affected Plugin Version:** ???
|
||||||
|
|
||||||
## Describe your Environment
|
## Describe your Environment
|
||||||
|
|
||||||
<!-- Run the command "/version" to see the server version you are running. -->
|
<!-- Run the command "/version" to see the server version you are running. -->
|
||||||
|
|
||||||
- **Server Version:** ???
|
- **Server Version:** ???
|
||||||
|
|
||||||
## Steps to Reproduce this Bug
|
## Steps to Reproduce this Bug
|
||||||
|
|
||||||
<!-- Write a step by step description of how we can reproduce this bug. -->
|
<!-- Write a step by step description of how we can reproduce this bug. -->
|
||||||
<!-- As developers we need to know how to trigger the bug before we can fix it. -->
|
<!-- As developers we need to know how to trigger the bug before we can fix it. -->
|
||||||
|
|
||||||
1. First I did this.
|
1. First I did this.
|
||||||
2. Next I did that.
|
2. Next I did that.
|
||||||
3. Finally this happened.
|
3. Finally this happened.
|
||||||
|
|
||||||
## Observed Results
|
## Observed Results
|
||||||
|
|
||||||
<!-- Tell us what actually happened. -->
|
<!-- Tell us what actually happened. -->
|
||||||
<!-- Please describe as detailed as possible. -->
|
<!-- Please describe as detailed as possible. -->
|
||||||
<!-- Feel free to link to a screenshot posted on imgur.com. -->
|
<!-- Feel free to link to a screenshot posted on imgur.com. -->
|
||||||
<!-- Feel free to link to an error log posted on pastebin.com. -->
|
<!-- Feel free to link to an error log posted on pastebin.com. -->
|
||||||
|
|
||||||
## Expected Results
|
## Expected Results
|
||||||
|
|
||||||
<!-- Tell us what you expected to happen. -->
|
<!-- Tell us what you expected to happen. -->
|
||||||
<!-- This way we can better understand in what way this is an issue. -->
|
<!-- This way we can better understand in what way this is an issue. -->
|
||||||
|
461
plugin.yml
461
plugin.yml
@ -1,461 +0,0 @@
|
|||||||
main: ${project.groupId}.${project.name}
|
|
||||||
name: ${project.name}
|
|
||||||
version: ${project.version}
|
|
||||||
website: ${project.url}
|
|
||||||
description: ${project.description}
|
|
||||||
authors: [Madus, Cayorion, Ulumulu1510, MarkehMe, Brettflan]
|
|
||||||
depend: [MassiveCore]
|
|
||||||
softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, LocalAreaChat, LWC, ChatManager, AuthMe, Vault, WorldEdit, WorldGuard]
|
|
||||||
api-version: 1.13
|
|
||||||
permissions:
|
|
||||||
# -------------------------------------------- #
|
|
||||||
# THE REAL NODES
|
|
||||||
# -------------------------------------------- #
|
|
||||||
factions.access: {description: manage access, with the proper fperm, default: false}
|
|
||||||
factions.access.deny: {description: deny faction access, default: false}
|
|
||||||
factions.access.deny.one: {description: deny access in a single chunk, default: false}
|
|
||||||
factions.access.deny.fill: {description: deny access by filling, default: false}
|
|
||||||
factions.access.deny.square: {description: deny access by square and radius, default: false}
|
|
||||||
factions.access.deny.circle: {description: deny access by circle and radius, default: false}
|
|
||||||
factions.access.grant: {description: grant faction access, default: false}
|
|
||||||
factions.access.grant.one: {description: grant access in a single chunk, default: false}
|
|
||||||
factions.access.grant.fill: {description: grant access by filling, default: false}
|
|
||||||
factions.access.grant.square: {description: grant access by square and radius, default: false}
|
|
||||||
factions.access.grant.circle: {description: grant access by circle and radius, default: false}
|
|
||||||
factions.access.inspect: {description: inspect where someone has access, default: false}
|
|
||||||
factions.access.view: {description: view access, default: false}
|
|
||||||
factions.override: {description: enable override mode, default: false}
|
|
||||||
factions.basecommand: {description: use factions base command, default: false}
|
|
||||||
factions.chunkname: {description: set chunk name, default: false}
|
|
||||||
factions.claim: {description: claim faction territory, default: false}
|
|
||||||
factions.claim.one: {description: claim a single chunk, default: false}
|
|
||||||
factions.claim.auto: {description: claim as you walk around, default: false}
|
|
||||||
factions.claim.fill: {description: claim by filling, default: false}
|
|
||||||
factions.claim.square: {description: claim by square and radius, default: false}
|
|
||||||
factions.claim.circle: {description: claim by circle and radius, default: false}
|
|
||||||
factions.claim.all: {description: claim all faction land, default: false}
|
|
||||||
factions.create: {description: create new faction, default: false}
|
|
||||||
factions.description: {description: change faction description, default: false}
|
|
||||||
factions.disband: {description: disband faction, default: false}
|
|
||||||
factions.documentation: {description: show documentation, default: false}
|
|
||||||
factions.documentation.flags: {description: show flag documentation, default: false}
|
|
||||||
factions.documentation.power: {description: show power documentation, default: false}
|
|
||||||
factions.documentation.perms: {description: show perms documentation, default: false}
|
|
||||||
factions.documentation.ranks: {description: show rank documentation, default: false}
|
|
||||||
factions.documentation.tax: {description: show tax documentation, default: false}
|
|
||||||
factions.documentation.warps: {description: show warp documentation, default: false}
|
|
||||||
factions.expansions: {description: list expansions, default: false}
|
|
||||||
factions.faction: {description: show faction information, default: false}
|
|
||||||
factions.flag: {description: manage faction flags, default: false}
|
|
||||||
factions.flag.list: {description: list flags, default: false}
|
|
||||||
factions.flag.set: {description: set flags, default: false}
|
|
||||||
factions.flag.show: {description: show flags, default: false}
|
|
||||||
factions.fly: {description: faction fly, default: false}
|
|
||||||
factions.fly.other: {description: set faction fly for others, default: false}
|
|
||||||
factions.invite: {description: manage invites, default: false}
|
|
||||||
factions.invite.list: {description: list invited players, default: false}
|
|
||||||
factions.invite.list.other: {description: list invited players of another factions, default: false}
|
|
||||||
factions.invite.add: {description: invite player, default: false}
|
|
||||||
factions.invite.remove: {description: revoke an invite, default: false}
|
|
||||||
factions.join: {description: join faction, default: false}
|
|
||||||
factions.join.others: {description: have another player join faction, default: false}
|
|
||||||
factions.kick: {description: kick player from faction, default: false}
|
|
||||||
factions.leave: {description: leave your faction, default: false}
|
|
||||||
factions.list: {description: list all factions, default: false}
|
|
||||||
factions.map: {description: show territory map, default: false}
|
|
||||||
factions.money: {description: manage faction money, default: false}
|
|
||||||
factions.money.balance: {description: show faction money, default: false}
|
|
||||||
factions.money.balance.any: {description: show another factions money, default: false}
|
|
||||||
factions.money.deposit: {description: deposit to faction, default: false}
|
|
||||||
factions.money.f2f: {description: transfer f --> f, default: false}
|
|
||||||
factions.money.f2p: {description: transfer f --> p, default: false}
|
|
||||||
factions.money.p2f: {description: transfer p --> f, default: false}
|
|
||||||
factions.money.withdraw: {description: withdraw from faction, default: false}
|
|
||||||
factions.moneyconvert: {description: convert to the new money system, default: false}
|
|
||||||
factions.motd: {description: faction motd, default: false}
|
|
||||||
factions.open: {description: set if invitation is required to join, default: false}
|
|
||||||
factions.perm: {description: change faction permissions, default: false}
|
|
||||||
factions.perm.list: {description: list perms, default: false}
|
|
||||||
factions.perm.set: {description: set perms, default: false}
|
|
||||||
factions.perm.show: {description: show who has perm, default: false}
|
|
||||||
factions.perm.view: {description: view perms given to, default: false}
|
|
||||||
factions.perm.viewall: {description: view all perms held by, default: false}
|
|
||||||
factions.player: {description: show player information}
|
|
||||||
factions.powerboost: {description: manage powerboost, default: false}
|
|
||||||
factions.powerboost.faction: {description: manage faction powerboost, default: false}
|
|
||||||
factions.powerboost.faction.add: {description: add to faction powerboost, default: false}
|
|
||||||
factions.powerboost.faction.multiply: {description: multiply faction powerboost, default: false}
|
|
||||||
factions.powerboost.faction.set: {description: set faction powerboost, default: false}
|
|
||||||
factions.powerboost.faction.show: {description: show faction powerboost, default: false}
|
|
||||||
factions.powerboost.faction.take: {description: take faction powerboost, default: false}
|
|
||||||
factions.powerboost.player: {description: manage player powerboost, default: false}
|
|
||||||
factions.powerboost.player.add: {description: add to player powerboost, default: false}
|
|
||||||
factions.powerboost.player.multiply: {description: multiply player powerboost, default: false}
|
|
||||||
factions.powerboost.player.set: {description: set player powerboost, default: false}
|
|
||||||
factions.powerboost.player.show: {description: show player powerboost, default: false}
|
|
||||||
factions.powerboost.player.take: {description: take player powerboost, default: false}
|
|
||||||
factions.rank: {description: manage/show ranks, default: false}
|
|
||||||
factions.rank.show: {description: show rank, default: false}
|
|
||||||
factions.rank.set: {description: set rank, default: false}
|
|
||||||
factions.rank.list: {description: list ranks, default: false}
|
|
||||||
factions.rank.edit: {description: edit ranks, default: false}
|
|
||||||
factions.rank.edit.create: {description: create rank, default: false}
|
|
||||||
factions.rank.edit.name: {description: set rank name, default: false}
|
|
||||||
factions.rank.edit.prefix: {description: set rank prefix, default: false}
|
|
||||||
factions.rank.edit.priority: {description: set rank priority, default: false}
|
|
||||||
factions.rank.edit.delete: {description: delete rank, default: false}
|
|
||||||
factions.relation: {description: manage faction relations, default: false}
|
|
||||||
factions.relation.list: {description: list all factions with certain relation, default: false}
|
|
||||||
factions.relation.set: {description: set relation wish to another faction, default: false}
|
|
||||||
factions.relation.wishes: {description: list the relation wishes, default: false}
|
|
||||||
factions.seechunk: {description: see the chunk you stand in, default: false}
|
|
||||||
factions.seechunkold: {description: see the chunk you stand in, default: false}
|
|
||||||
factions.setpower: {description: set power, default: false}
|
|
||||||
factions.status: {description: show status, default: false}
|
|
||||||
factions.tax: {description: manage taxes, default: false}
|
|
||||||
factions.tax.faction: {description: show faction tax, default: false}
|
|
||||||
factions.tax.player: {description: show player tax, default: false}
|
|
||||||
factions.tax.run: {description: run a tax collection, default: false}
|
|
||||||
factions.tax.set: {description: set taxes, default: false}
|
|
||||||
factions.name: {description: set faction name, default: false}
|
|
||||||
factions.title: {description: set player title, default: false}
|
|
||||||
factions.title.color: {description: set player title with color, default: false}
|
|
||||||
factions.territorytitles: {description: toggle territory titles, default: false}
|
|
||||||
factions.top: {description: show faction top, default: false}
|
|
||||||
factions.unclaim: {description: unclaim faction territory, default: false}
|
|
||||||
factions.unclaim.one: {description: unclaim a single chunk, default: false}
|
|
||||||
factions.unclaim.auto: {description: unclaim as you walk around, default: false}
|
|
||||||
factions.unclaim.fill: {description: unclaim by filling, default: false}
|
|
||||||
factions.unclaim.square: {description: unclaim by square and radius, default: false}
|
|
||||||
factions.unclaim.circle: {description: unclaim by circle and radius, default: false}
|
|
||||||
factions.unclaim.all: {description: unclaim all faction land, default: false}
|
|
||||||
factions.vote: {description: vote in faction votes, default: false}
|
|
||||||
factions.vote.do: {description: do vote, default: false}
|
|
||||||
factions.vote.list: {description: list votes, default: false}
|
|
||||||
factions.vote.show: {description: show vote result, default: false}
|
|
||||||
factions.vote.create: {description: create a vote, default: false}
|
|
||||||
factions.vote.remove: {description: remove a vote, default: false}
|
|
||||||
factions.warp: {description: use warps, default: false}
|
|
||||||
factions.warp.go: {description: go to a warp, default: false}
|
|
||||||
factions.warp.list: {description: list warps, default: false}
|
|
||||||
factions.warp.add: {description: add new warp, default: false}
|
|
||||||
factions.warp.remove: {description: remove warp, default: false}
|
|
||||||
factions.unstuck: {description: teleport to nearest wilderness, default: false}
|
|
||||||
factions.config: {description: edit the factions config, default: false}
|
|
||||||
factions.clean: {description: clean the factions database, default: false}
|
|
||||||
factions.version: {description: see plugin version, default: false}
|
|
||||||
# -------------------------------------------- #
|
|
||||||
# STAR NOTATION
|
|
||||||
# -------------------------------------------- #
|
|
||||||
factions.*:
|
|
||||||
children:
|
|
||||||
factions.access: true
|
|
||||||
factions.access.deny: true
|
|
||||||
factions.access.deny.one: true
|
|
||||||
factions.access.deny.fill: true
|
|
||||||
factions.access.deny.square: true
|
|
||||||
factions.access.deny.circle: true
|
|
||||||
factions.access.grant: true
|
|
||||||
factions.access.grant.one: true
|
|
||||||
factions.access.grant.fill: true
|
|
||||||
factions.access.grant.square: true
|
|
||||||
factions.access.grant.circle: true
|
|
||||||
factions.access.inspect: true
|
|
||||||
factions.access.view: true
|
|
||||||
factions.override: true
|
|
||||||
factions.basecommand: true
|
|
||||||
factions.chunkname: true
|
|
||||||
factions.claim: true
|
|
||||||
factions.claim.one: true
|
|
||||||
factions.claim.auto: true
|
|
||||||
factions.claim.fill: true
|
|
||||||
factions.claim.square: true
|
|
||||||
factions.claim.circle: true
|
|
||||||
factions.claim.all: true
|
|
||||||
factions.create: true
|
|
||||||
factions.demote: true
|
|
||||||
factions.description: true
|
|
||||||
factions.disband: true
|
|
||||||
factions.documentation: true
|
|
||||||
factions.documentation.flags: true
|
|
||||||
factions.documentation.perms: true
|
|
||||||
factions.documentation.power: true
|
|
||||||
factions.documentation.ranks: true
|
|
||||||
factions.documentation.tax: true
|
|
||||||
factions.documentation.warps: true
|
|
||||||
factions.expansions: true
|
|
||||||
factions.faction: true
|
|
||||||
factions.flag: true
|
|
||||||
factions.flag.list: true
|
|
||||||
factions.flag.set: true
|
|
||||||
factions.flag.show: true
|
|
||||||
factions.fly: true
|
|
||||||
factions.fly.other: true
|
|
||||||
factions.home: true
|
|
||||||
factions.invite: true
|
|
||||||
factions.invite.list: true
|
|
||||||
factions.invite.list.other: true
|
|
||||||
factions.invite.add: true
|
|
||||||
factions.invite.remove: true
|
|
||||||
factions.join: true
|
|
||||||
factions.join.others: true
|
|
||||||
factions.kick: true
|
|
||||||
factions.leader: true
|
|
||||||
factions.leader.any: true
|
|
||||||
factions.leave: true
|
|
||||||
factions.list: true
|
|
||||||
factions.map: true
|
|
||||||
factions.money: true
|
|
||||||
factions.money.balance: true
|
|
||||||
factions.money.balance.any: true
|
|
||||||
factions.money.deposit: true
|
|
||||||
factions.money.f2f: true
|
|
||||||
factions.money.f2p: true
|
|
||||||
factions.money.p2f: true
|
|
||||||
factions.money.withdraw: true
|
|
||||||
factions.moneyconvert: true
|
|
||||||
factions.motd: true
|
|
||||||
factions.officer: true
|
|
||||||
factions.officer.any: true
|
|
||||||
factions.open: true
|
|
||||||
factions.perm: true
|
|
||||||
factions.perm.list: true
|
|
||||||
factions.perm.set: true
|
|
||||||
factions.perm.show: true
|
|
||||||
factions.perm.view: true
|
|
||||||
factions.perm.viewall: true
|
|
||||||
factions.player: true
|
|
||||||
factions.powerboost: true
|
|
||||||
factions.powerboost.faction: true
|
|
||||||
factions.powerboost.faction.add: true
|
|
||||||
factions.powerboost.faction.multiply: true
|
|
||||||
factions.powerboost.faction.set: true
|
|
||||||
factions.powerboost.faction.show: true
|
|
||||||
factions.powerboost.faction.take: true
|
|
||||||
factions.powerboost.player: true
|
|
||||||
factions.powerboost.player.add: true
|
|
||||||
factions.powerboost.player.multiply: true
|
|
||||||
factions.powerboost.player.set: true
|
|
||||||
factions.powerboost.player.show: true
|
|
||||||
factions.powerboost.player.take: true
|
|
||||||
factions.rank: true
|
|
||||||
factions.rank.show: true
|
|
||||||
factions.rank.set: true
|
|
||||||
factions.rank.list: true
|
|
||||||
factions.rank.edit: true
|
|
||||||
factions.rank.edit.create: true
|
|
||||||
factions.rank.edit.name: true
|
|
||||||
factions.rank.edit.prefix: true
|
|
||||||
factions.rank.edit.priority: true
|
|
||||||
factions.rank.edit.delete: true
|
|
||||||
factions.promote: true
|
|
||||||
factions.relation: true
|
|
||||||
factions.relation.list: true
|
|
||||||
factions.relation.set: true
|
|
||||||
factions.relation.wishes: true
|
|
||||||
factions.seechunk: true
|
|
||||||
factions.seechunkold: true
|
|
||||||
factions.sethome: true
|
|
||||||
factions.setpower: true
|
|
||||||
factions.status: true
|
|
||||||
factions.tax: true
|
|
||||||
factions.tax.faction: true
|
|
||||||
factions.tax.player: true
|
|
||||||
factions.tax.run: true
|
|
||||||
factions.tax.set: true
|
|
||||||
factions.name: true
|
|
||||||
factions.title: true
|
|
||||||
factions.title.color: true
|
|
||||||
factions.territorytitles: true
|
|
||||||
factions.top: true
|
|
||||||
factions.unclaim: true
|
|
||||||
factions.unclaim.one: true
|
|
||||||
factions.unclaim.auto: true
|
|
||||||
factions.unclaim.fill: true
|
|
||||||
factions.unclaim.square: true
|
|
||||||
factions.unclaim.circle: true
|
|
||||||
factions.unclaim.all: true
|
|
||||||
factions.unsethome: true
|
|
||||||
factions.unstuck: true
|
|
||||||
factions.vote: true
|
|
||||||
factions.vote.do: true
|
|
||||||
factions.vote.list: true
|
|
||||||
factions.vote.show: true
|
|
||||||
factions.vote.create: true
|
|
||||||
factions.vote.remove: true
|
|
||||||
factions.warp: true
|
|
||||||
factions.warp.go: true
|
|
||||||
factions.warp.list: true
|
|
||||||
factions.warp.add: true
|
|
||||||
factions.warp.remove: true
|
|
||||||
factions.config: true
|
|
||||||
factions.clean: true
|
|
||||||
factions.version: true
|
|
||||||
# -------------------------------------------- #
|
|
||||||
# KITS
|
|
||||||
# -------------------------------------------- #
|
|
||||||
factions.kit.op:
|
|
||||||
default: op
|
|
||||||
children:
|
|
||||||
factions.*: true
|
|
||||||
factions.kit.rank3:
|
|
||||||
default: false
|
|
||||||
children:
|
|
||||||
factions.kit.rank2: true
|
|
||||||
factions.moneyconvert: true
|
|
||||||
factions.config: true
|
|
||||||
factions.clean: true
|
|
||||||
factions.kit.rank2:
|
|
||||||
default: false
|
|
||||||
children:
|
|
||||||
factions.kit.rank1: true
|
|
||||||
factions.powerboost.faction.add: true
|
|
||||||
factions.powerboost.faction.multiply: true
|
|
||||||
factions.powerboost.faction.set: true
|
|
||||||
factions.powerboost.faction.take: true
|
|
||||||
factions.powerboost.player.add: true
|
|
||||||
factions.powerboost.player.multiply: true
|
|
||||||
factions.powerboost.player.set: true
|
|
||||||
factions.powerboost.player.take: true
|
|
||||||
factions.join.others: true
|
|
||||||
factions.leader.any: true
|
|
||||||
factions.officer.any: true
|
|
||||||
factions.access.any: true
|
|
||||||
factions.fly.other: true
|
|
||||||
factions.setpower: true
|
|
||||||
factions.kit.rank1:
|
|
||||||
default: false
|
|
||||||
children:
|
|
||||||
factions.kit.rank0: true
|
|
||||||
factions.override: true
|
|
||||||
factions.invite.list.other: true
|
|
||||||
factions.kit.rank0:
|
|
||||||
default: false
|
|
||||||
children:
|
|
||||||
factions.access: true
|
|
||||||
factions.access.deny: true
|
|
||||||
factions.access.deny.one: true
|
|
||||||
factions.access.deny.fill: true
|
|
||||||
factions.access.deny.square: true
|
|
||||||
factions.access.deny.circle: true
|
|
||||||
factions.access.grant: true
|
|
||||||
factions.access.grant.one: true
|
|
||||||
factions.access.grant.fill: true
|
|
||||||
factions.access.grant.square: true
|
|
||||||
factions.access.grant.circle: true
|
|
||||||
factions.access.inspect: true
|
|
||||||
factions.access.view: true
|
|
||||||
factions.basecommand: true
|
|
||||||
factions.chunkname: true
|
|
||||||
factions.claim: true
|
|
||||||
factions.claim.one: true
|
|
||||||
factions.claim.auto: true
|
|
||||||
factions.claim.fill: true
|
|
||||||
factions.claim.square: true
|
|
||||||
factions.claim.circle: true
|
|
||||||
factions.claim.all: true
|
|
||||||
factions.create: true
|
|
||||||
factions.demote: true
|
|
||||||
factions.description: true
|
|
||||||
factions.disband: true
|
|
||||||
factions.documentation: true
|
|
||||||
factions.documentation.flags: true
|
|
||||||
factions.documentation.perms: true
|
|
||||||
factions.documentation.power: true
|
|
||||||
factions.documentation.ranks: true
|
|
||||||
factions.documentation.warps: true
|
|
||||||
factions.expansions: true
|
|
||||||
factions.faction: true
|
|
||||||
factions.flag: true
|
|
||||||
factions.flag.list: true
|
|
||||||
factions.flag.set: true
|
|
||||||
factions.flag.show: true
|
|
||||||
factions.fly: true
|
|
||||||
factions.home: true
|
|
||||||
factions.invite: true
|
|
||||||
factions.invite.list: true
|
|
||||||
factions.invite.add: true
|
|
||||||
factions.invite.remove: true
|
|
||||||
factions.join: true
|
|
||||||
factions.kick: true
|
|
||||||
factions.leader: true
|
|
||||||
factions.leave: true
|
|
||||||
factions.list: true
|
|
||||||
factions.map: true
|
|
||||||
factions.money: true
|
|
||||||
factions.money.balance: true
|
|
||||||
factions.money.balance.any: true
|
|
||||||
factions.money.deposit: true
|
|
||||||
factions.money.f2f: true
|
|
||||||
factions.money.f2p: true
|
|
||||||
factions.money.p2f: true
|
|
||||||
factions.money.withdraw: true
|
|
||||||
factions.motd: true
|
|
||||||
factions.officer: true
|
|
||||||
factions.open: true
|
|
||||||
factions.perm: true
|
|
||||||
factions.perm.list: true
|
|
||||||
factions.perm.set: true
|
|
||||||
factions.perm.show: true
|
|
||||||
factions.perm.view: true
|
|
||||||
factions.perm.viewall: true
|
|
||||||
factions.player: true
|
|
||||||
factions.promote: true
|
|
||||||
factions.powerboost: true
|
|
||||||
factions.powerboost.faction: true
|
|
||||||
factions.powerboost.faction.show: true
|
|
||||||
factions.powerboost.player: true
|
|
||||||
factions.powerboost.player.show: true
|
|
||||||
factions.rank: true
|
|
||||||
factions.rank.show: true
|
|
||||||
factions.rank.set: true
|
|
||||||
factions.rank.list: true
|
|
||||||
factions.rank.edit: true
|
|
||||||
factions.rank.edit.create: true
|
|
||||||
factions.rank.edit.name: true
|
|
||||||
factions.rank.edit.prefix: true
|
|
||||||
factions.rank.edit.priority: true
|
|
||||||
factions.rank.edit.delete: true
|
|
||||||
factions.relation: true
|
|
||||||
factions.relation.list: true
|
|
||||||
factions.relation.set: true
|
|
||||||
factions.relation.wishes: true
|
|
||||||
factions.seechunk: true
|
|
||||||
factions.seechunkold: true
|
|
||||||
factions.sethome: true
|
|
||||||
factions.status: true
|
|
||||||
factions.tax: true
|
|
||||||
factions.tax.faction: true
|
|
||||||
factions.tax.player: true
|
|
||||||
factions.tax.run: true
|
|
||||||
factions.tax.set: true
|
|
||||||
factions.name: true
|
|
||||||
factions.title: true
|
|
||||||
factions.title.color: true
|
|
||||||
factions.territorytitles: true
|
|
||||||
factions.top: true
|
|
||||||
factions.unclaim: true
|
|
||||||
factions.unclaim.one: true
|
|
||||||
factions.unclaim.auto: true
|
|
||||||
factions.unclaim.fill: true
|
|
||||||
factions.unclaim.square: true
|
|
||||||
factions.unclaim.circle: true
|
|
||||||
factions.unclaim.all: true
|
|
||||||
factions.unsethome: true
|
|
||||||
factions.unstuck: true
|
|
||||||
factions.vote: true
|
|
||||||
factions.vote.do: true
|
|
||||||
factions.vote.list: true
|
|
||||||
factions.vote.show: true
|
|
||||||
factions.vote.create: true
|
|
||||||
factions.vote.remove: true
|
|
||||||
factions.warp: true
|
|
||||||
factions.warp.go: true
|
|
||||||
factions.warp.list: true
|
|
||||||
factions.warp.add: true
|
|
||||||
factions.warp.remove: true
|
|
||||||
factions.version: true
|
|
||||||
factions.kit.default:
|
|
||||||
default: true
|
|
||||||
children:
|
|
||||||
factions.kit.rank0: true
|
|
99
pom.xml
99
pom.xml
@ -1,23 +1,57 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<!-- Parent -->
|
<!-- Parent -->
|
||||||
<parent>
|
<!--<parent>
|
||||||
<groupId>com.massivecraft.massivesuper</groupId>
|
<groupId>com.massivecraft.massivesuper</groupId>
|
||||||
<artifactId>MassiveSuper</artifactId>
|
<artifactId>MassiveSuper</artifactId>
|
||||||
<version>3.3.3</version>
|
<version>3.3.3</version>
|
||||||
<relativePath>../MassiveSuper</relativePath>
|
<relativePath>../MassiveSuper</relativePath>
|
||||||
</parent>
|
</parent>-->
|
||||||
|
|
||||||
<!-- Basics -->
|
<!-- Basics -->
|
||||||
<groupId>com.massivecraft.factions</groupId>
|
<groupId>net.knarcraft</groupId>
|
||||||
<artifactId>Factions</artifactId>
|
<artifactId>Factions</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<!-- Info -->
|
<!-- Info -->
|
||||||
|
<url>https://git.knarcraft.net</url>
|
||||||
<name>${project.artifactId}</name>
|
<name>${project.artifactId}</name>
|
||||||
<description>${massiveColorInfo}${project.name} allows the players to team up and claim land as their own and start wars with other factions. This way we hope to inspire politics, intrigue, and team spirit. ${massiveDescriptionSuffix}</description>
|
<description>${project.name} allows the players to team up and claim land as their own and start wars with other
|
||||||
<url>${massiveBaseUrl}/factions</url>
|
factions. This way we hope to inspire politics, intrigue, and team spirit.
|
||||||
|
</description>
|
||||||
|
<!--<url>${massiveBaseUrl}/factions</url>-->
|
||||||
|
<version>3.3.3</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spigotmc-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>vault-repo</id>
|
||||||
|
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>engine-hub-repo</id>
|
||||||
|
<url>https://maven.enginehub.org/repo/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>dynmap</id>
|
||||||
|
<url>https://repo.mikeprimm.com/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>placeholderapi</id>
|
||||||
|
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
<!-- Dependencies -->
|
<!-- Dependencies -->
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -25,75 +59,98 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.19.1-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- MassiveCore -->
|
<!-- MassiveCore -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.massivecraft.massivecore</groupId>
|
<groupId>com.massivecraft.massivecore</groupId>
|
||||||
<artifactId>MassiveCore</artifactId>
|
<artifactId>MassiveCore</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>lib\MassiveCore.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- WorldEdit -->
|
<!-- WorldEdit -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q.worldedit</groupId>
|
<groupId>com.sk89q.worldedit</groupId>
|
||||||
<artifactId>worldedit-core</artifactId>
|
<artifactId>worldedit-core</artifactId>
|
||||||
|
<version>7.2.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q.worldedit</groupId>
|
<groupId>com.sk89q.worldedit</groupId>
|
||||||
<artifactId>worldedit-bukkit</artifactId>
|
<artifactId>worldedit-bukkit</artifactId>
|
||||||
|
<version>7.2.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- WorldGuard -->
|
<!-- WorldGuard -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q.worldguard</groupId>
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
<artifactId>worldguard-core</artifactId>
|
<artifactId>worldguard-core</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q.worldguard</groupId>
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
<artifactId>worldguard-bukkit</artifactId>
|
<artifactId>worldguard-bukkit</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Vault -->
|
<!-- Vault -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
<artifactId>Vault</artifactId>
|
<artifactId>VaultAPI</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- LWC -->
|
<!-- LWC -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.griefcraft</groupId>
|
<groupId>com.griefcraft</groupId>
|
||||||
<artifactId>lwc</artifactId>
|
<artifactId>lwc</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>lib\LWC.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- PlaceholderAPI -->
|
<!-- PlaceholderAPI -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.clip</groupId>
|
<groupId>me.clip</groupId>
|
||||||
<artifactId>placeholderapi</artifactId>
|
<artifactId>placeholderapi</artifactId>
|
||||||
|
<version>2.11.2</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- MineverseChat/VentureChat -->
|
<!-- MineverseChat/VentureChat -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mineverse.Aust1n46.chat</groupId>
|
<groupId>mineverse.Aust1n46.chat</groupId>
|
||||||
<artifactId>MineverseChat</artifactId>
|
<artifactId>VentureChat</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>lib\VentureChat.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Dynmap -->
|
<!-- Dynmap -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>us.dynmap</groupId>
|
<groupId>us.dynmap</groupId>
|
||||||
<artifactId>dynmap</artifactId>
|
<artifactId>dynmap-api</artifactId>
|
||||||
|
<version>3.1-beta-2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<!-- Build -->
|
<!-- Build -->
|
||||||
<build>
|
<build>
|
||||||
<!-- Resources -->
|
<defaultGoal>clean package install</defaultGoal>
|
||||||
<resources>
|
<resources>
|
||||||
<!-- Standard -->
|
|
||||||
<resource>
|
<resource>
|
||||||
<directory>${project.basedir}</directory>
|
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
|
<directory>${basedir}/src/main/resources</directory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>*.yml</include>
|
<include>*.yml</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
<!-- OpenSource -->
|
|
||||||
<resource>
|
|
||||||
<directory>${project.build.sourceDirectory}</directory>
|
|
||||||
<filtering>false</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.7.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>17</source>
|
||||||
|
<target>17</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
package com.massivecraft.factions;
|
|
||||||
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.Colorized;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public enum AccessStatus implements Colorized
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// ENUM
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
STANDARD(ChatColor.YELLOW, null),
|
|
||||||
ELEVATED(ChatColor.GREEN, true),
|
|
||||||
DECREASED(ChatColor.RED, false),
|
|
||||||
|
|
||||||
// END OF LIST
|
|
||||||
;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private final ChatColor color;
|
|
||||||
@Override public ChatColor getColor() { return this.color; }
|
|
||||||
|
|
||||||
private final Boolean access;
|
|
||||||
public Boolean hasAccess() { return access; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
AccessStatus(ChatColor color, Boolean access)
|
|
||||||
{
|
|
||||||
this.color = color;
|
|
||||||
this.access = access;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// MESSAGE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public String getStatusMessage()
|
|
||||||
{
|
|
||||||
ChatColor color = this.getColor();
|
|
||||||
String status = Txt.getNicedEnum(this).toLowerCase();
|
|
||||||
return Txt.parse("%sYou have %s access to this area.", color.toString(), status);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package com.massivecraft.factions;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.massivecore.util.extractor.Extractor;
|
|
||||||
|
|
||||||
public class ExtractorFactionAccountId implements Extractor
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static ExtractorFactionAccountId i = new ExtractorFactionAccountId();
|
|
||||||
public static ExtractorFactionAccountId get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE: EXTRACTOR
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object extract(Object o)
|
|
||||||
{
|
|
||||||
if (o instanceof Faction)
|
|
||||||
{
|
|
||||||
String factionId = ((Faction)o).getId();
|
|
||||||
if (factionId == null) return null;
|
|
||||||
return Factions.FACTION_MONEY_ACCOUNT_ID_PREFIX + factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,291 +0,0 @@
|
|||||||
package com.massivecraft.factions;
|
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.massivecraft.factions.adapter.BoardAdapter;
|
|
||||||
import com.massivecraft.factions.adapter.BoardMapAdapter;
|
|
||||||
import com.massivecraft.factions.adapter.TerritoryAccessAdapter;
|
|
||||||
import com.massivecraft.factions.chat.modifier.ChatModifierLc;
|
|
||||||
import com.massivecraft.factions.chat.modifier.ChatModifierLp;
|
|
||||||
import com.massivecraft.factions.chat.modifier.ChatModifierParse;
|
|
||||||
import com.massivecraft.factions.chat.modifier.ChatModifierRp;
|
|
||||||
import com.massivecraft.factions.chat.modifier.ChatModifierUc;
|
|
||||||
import com.massivecraft.factions.chat.modifier.ChatModifierUcf;
|
|
||||||
import com.massivecraft.factions.chat.tag.ChatTagName;
|
|
||||||
import com.massivecraft.factions.chat.tag.ChatTagNameforce;
|
|
||||||
import com.massivecraft.factions.chat.tag.ChatTagRelcolor;
|
|
||||||
import com.massivecraft.factions.chat.tag.ChatTagRole;
|
|
||||||
import com.massivecraft.factions.chat.tag.ChatTagRoleprefix;
|
|
||||||
import com.massivecraft.factions.chat.tag.ChatTagRoleprefixforce;
|
|
||||||
import com.massivecraft.factions.chat.tag.ChatTagTitle;
|
|
||||||
import com.massivecraft.factions.cmd.CmdFactions;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFactionChunkChangeType;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeRel;
|
|
||||||
import com.massivecraft.factions.engine.EngineCanCombatHappen;
|
|
||||||
import com.massivecraft.factions.engine.EngineChat;
|
|
||||||
import com.massivecraft.factions.engine.EngineChunkChange;
|
|
||||||
import com.massivecraft.factions.engine.EngineCleanInactivity;
|
|
||||||
import com.massivecraft.factions.engine.EngineDenyCommands;
|
|
||||||
import com.massivecraft.factions.engine.EngineDenyTeleport;
|
|
||||||
import com.massivecraft.factions.engine.EngineEcon;
|
|
||||||
import com.massivecraft.factions.engine.EngineExploit;
|
|
||||||
import com.massivecraft.factions.engine.EngineFlagEndergrief;
|
|
||||||
import com.massivecraft.factions.engine.EngineFlagExplosion;
|
|
||||||
import com.massivecraft.factions.engine.EngineFlagFireSpread;
|
|
||||||
import com.massivecraft.factions.engine.EngineFlagSpawn;
|
|
||||||
import com.massivecraft.factions.engine.EngineFlagZombiegrief;
|
|
||||||
import com.massivecraft.factions.engine.EngineFly;
|
|
||||||
import com.massivecraft.factions.engine.EngineLastActivity;
|
|
||||||
import com.massivecraft.factions.engine.EngineMotd;
|
|
||||||
import com.massivecraft.factions.engine.EngineMoveChunk;
|
|
||||||
import com.massivecraft.factions.engine.EnginePermBuild;
|
|
||||||
import com.massivecraft.factions.engine.EnginePlayerData;
|
|
||||||
import com.massivecraft.factions.engine.EnginePower;
|
|
||||||
import com.massivecraft.factions.engine.EngineSeeChunk;
|
|
||||||
import com.massivecraft.factions.engine.EngineShow;
|
|
||||||
import com.massivecraft.factions.engine.EngineTeleportHomeOnDeath;
|
|
||||||
import com.massivecraft.factions.engine.EngineTerritoryShield;
|
|
||||||
import com.massivecraft.factions.engine.EngineVisualizations;
|
|
||||||
import com.massivecraft.factions.entity.Board;
|
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
|
||||||
import com.massivecraft.factions.entity.FactionColl;
|
|
||||||
import com.massivecraft.factions.entity.MConfColl;
|
|
||||||
import com.massivecraft.factions.entity.MFlagColl;
|
|
||||||
import com.massivecraft.factions.entity.MPermColl;
|
|
||||||
import com.massivecraft.factions.entity.MPlayerColl;
|
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorFaction001Invitations;
|
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorFaction002Ranks;
|
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorFaction003Warps;
|
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorFaction004WarpsPerms;
|
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorMConf001EnumerationUtil;
|
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorMConf002CleanInactivity;
|
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorMConf003CleanInactivity;
|
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorMConf004Rank;
|
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorMConf005Warps;
|
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorMPerm001Warps;
|
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorMPerm002MoveStandard;
|
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorMPlayer001Ranks;
|
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorMPlayer002UsingAdminMode;
|
|
||||||
import com.massivecraft.factions.entity.migrator.MigratorTerritoryAccess001Restructure;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
|
|
||||||
import com.massivecraft.factions.integration.dynmap.IntegrationDynmap;
|
|
||||||
import com.massivecraft.factions.integration.lwc.IntegrationLwc;
|
|
||||||
import com.massivecraft.factions.integration.placeholderapi.IntegrationPlaceholderAPI;
|
|
||||||
import com.massivecraft.factions.integration.venturechat.IntegrationVentureChat;
|
|
||||||
import com.massivecraft.factions.integration.worldguard.IntegrationWorldGuard;
|
|
||||||
import com.massivecraft.factions.mixin.PowerMixin;
|
|
||||||
import com.massivecraft.factions.task.TaskFlagPermCreate;
|
|
||||||
import com.massivecraft.factions.task.TaskPlayerPowerUpdate;
|
|
||||||
import com.massivecraft.factions.task.TaskTax;
|
|
||||||
import com.massivecraft.massivecore.MassivePlugin;
|
|
||||||
import com.massivecraft.massivecore.command.type.RegistryType;
|
|
||||||
import com.massivecraft.massivecore.store.migrator.MigratorUtil;
|
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Factions extends MassivePlugin
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTANTS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public final static String FACTION_MONEY_ACCOUNT_ID_PREFIX = "faction-";
|
|
||||||
|
|
||||||
public final static String ID_NONE = "none";
|
|
||||||
public final static String ID_SAFEZONE = "safezone";
|
|
||||||
public final static String ID_WARZONE = "warzone";
|
|
||||||
|
|
||||||
public final static String NAME_NONE_DEFAULT = ChatColor.DARK_GREEN.toString() + "Wilderness";
|
|
||||||
public final static String NAME_SAFEZONE_DEFAULT = "SafeZone";
|
|
||||||
public final static String NAME_WARZONE_DEFAULT = "WarZone";
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static Factions i;
|
|
||||||
public static Factions get() { return i; }
|
|
||||||
public Factions() { Factions.i = this; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
// Mixins
|
|
||||||
@Deprecated public PowerMixin getPowerMixin() { return PowerMixin.get(); }
|
|
||||||
@Deprecated public void setPowerMixin(PowerMixin powerMixin) { PowerMixin.get().setInstance(powerMixin); }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnableInner()
|
|
||||||
{
|
|
||||||
// Register types
|
|
||||||
RegistryType.register(Rel.class, TypeRel.get());
|
|
||||||
RegistryType.register(EventFactionsChunkChangeType.class, TypeFactionChunkChangeType.get());
|
|
||||||
|
|
||||||
// Register Faction accountId Extractor
|
|
||||||
// TODO: Perhaps this should be placed in the econ integration somewhere?
|
|
||||||
MUtil.registerExtractor(String.class, "accountId", ExtractorFactionAccountId.get());
|
|
||||||
|
|
||||||
MigratorUtil.addJsonRepresentation(Board.class, Board.MAP_TYPE);
|
|
||||||
MigratorUtil.setTargetVersion(TerritoryAccess.class, 1);
|
|
||||||
|
|
||||||
// Activate
|
|
||||||
this.activateAuto();
|
|
||||||
this.activate(getClassesActiveChat());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// These are overriden because the reflection trick was buggy and didn't work on all systems
|
|
||||||
@Override
|
|
||||||
public List<Class<?>> getClassesActiveMigrators()
|
|
||||||
{
|
|
||||||
return MUtil.list(
|
|
||||||
MigratorFaction001Invitations.class,
|
|
||||||
MigratorFaction002Ranks.class,
|
|
||||||
MigratorFaction003Warps.class,
|
|
||||||
MigratorFaction004WarpsPerms.class,
|
|
||||||
MigratorMConf001EnumerationUtil.class,
|
|
||||||
MigratorMConf002CleanInactivity.class,
|
|
||||||
MigratorMConf003CleanInactivity.class,
|
|
||||||
MigratorMConf004Rank.class,
|
|
||||||
MigratorMConf005Warps.class,
|
|
||||||
MigratorMPerm001Warps.class,
|
|
||||||
MigratorMPerm002MoveStandard.class,
|
|
||||||
MigratorMPlayer001Ranks.class,
|
|
||||||
MigratorMPlayer002UsingAdminMode.class,
|
|
||||||
MigratorTerritoryAccess001Restructure.class
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Class<?>> getClassesActiveColls()
|
|
||||||
{
|
|
||||||
// MConf should always be activated first for all plugins. It's simply a standard. The config should have no dependencies.
|
|
||||||
// MFlag and MPerm are both dependency free.
|
|
||||||
// Next we activate Faction, MPlayer and Board. The order is carefully chosen based on foreign keys and indexing direction.
|
|
||||||
// MPlayer --> Faction
|
|
||||||
// We actually only have an index that we maintain for the MPlayer --> Faction one.
|
|
||||||
// The Board could currently be activated in any order but the current placement is an educated guess.
|
|
||||||
// In the future we might want to find all chunks from the faction or something similar.
|
|
||||||
// We also have the /f access system where the player can be granted specific access, possibly supporting the idea of such a reverse index.
|
|
||||||
return MUtil.list(
|
|
||||||
MConfColl.class,
|
|
||||||
MFlagColl.class,
|
|
||||||
MPermColl.class,
|
|
||||||
FactionColl.class,
|
|
||||||
MPlayerColl.class,
|
|
||||||
BoardColl.class
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Class<?>> getClassesActiveCommands()
|
|
||||||
{
|
|
||||||
return MUtil.list(
|
|
||||||
CmdFactions.class
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Class<?>> getClassesActiveIntegrations()
|
|
||||||
{
|
|
||||||
return MUtil.list(
|
|
||||||
IntegrationPlaceholderAPI.class,
|
|
||||||
IntegrationVentureChat.class,
|
|
||||||
IntegrationLwc.class,
|
|
||||||
IntegrationWorldGuard.class,
|
|
||||||
IntegrationDynmap.class
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Class<?>> getClassesActiveTasks()
|
|
||||||
{
|
|
||||||
return MUtil.list(
|
|
||||||
TaskTax.class,
|
|
||||||
TaskFlagPermCreate.class,
|
|
||||||
TaskPlayerPowerUpdate.class
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Class<?>> getClassesActiveEngines()
|
|
||||||
{
|
|
||||||
return MUtil.list(
|
|
||||||
EngineCanCombatHappen.class,
|
|
||||||
EngineChat.class,
|
|
||||||
EngineChunkChange.class,
|
|
||||||
EngineCleanInactivity.class,
|
|
||||||
EngineDenyCommands.class,
|
|
||||||
EngineDenyTeleport.class,
|
|
||||||
EngineExploit.class,
|
|
||||||
EngineFlagEndergrief.class,
|
|
||||||
EngineFlagExplosion.class,
|
|
||||||
EngineFlagFireSpread.class,
|
|
||||||
EngineFlagSpawn.class,
|
|
||||||
EngineFlagZombiegrief.class,
|
|
||||||
EngineFly.class,
|
|
||||||
EngineLastActivity.class,
|
|
||||||
EngineMotd.class,
|
|
||||||
EngineMoveChunk.class,
|
|
||||||
EnginePermBuild.class,
|
|
||||||
EnginePlayerData.class,
|
|
||||||
EnginePower.class,
|
|
||||||
EngineSeeChunk.class,
|
|
||||||
EngineShow.class,
|
|
||||||
EngineTeleportHomeOnDeath.class,
|
|
||||||
EngineTerritoryShield.class,
|
|
||||||
EngineVisualizations.class,
|
|
||||||
EngineEcon.class
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Class<?>> getClassesActiveMixins()
|
|
||||||
{
|
|
||||||
return MUtil.list(
|
|
||||||
PowerMixin.class
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Class<?>> getClassesActiveTests()
|
|
||||||
{
|
|
||||||
return MUtil.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Class<?>> getClassesActiveChat()
|
|
||||||
{
|
|
||||||
return MUtil.list(
|
|
||||||
ChatModifierLc.class,
|
|
||||||
ChatModifierLp.class,
|
|
||||||
ChatModifierParse.class,
|
|
||||||
ChatModifierRp.class,
|
|
||||||
ChatModifierUc.class,
|
|
||||||
ChatModifierUcf.class,
|
|
||||||
ChatTagName.class,
|
|
||||||
ChatTagNameforce.class,
|
|
||||||
ChatTagRelcolor.class,
|
|
||||||
ChatTagRole.class,
|
|
||||||
ChatTagRoleprefix.class,
|
|
||||||
ChatTagRoleprefixforce.class,
|
|
||||||
ChatTagTitle.class
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GsonBuilder getGsonBuilder()
|
|
||||||
{
|
|
||||||
return super.getGsonBuilder()
|
|
||||||
.registerTypeAdapter(TerritoryAccess.class, TerritoryAccessAdapter.get())
|
|
||||||
.registerTypeAdapter(Board.class, BoardAdapter.get())
|
|
||||||
.registerTypeAdapter(Board.MAP_TYPE, BoardMapAdapter.get())
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,168 +0,0 @@
|
|||||||
package com.massivecraft.factions;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.FactionColl;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.entity.MPlayerColl;
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveSet;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.WeakHashMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This Index class contains the MPlayer <--> Faction index.
|
|
||||||
*
|
|
||||||
* In the background it's powered by WeakHashMaps and all public methods are synchronized.
|
|
||||||
* That should increase thread safety but no thread safety is actually guarranteed.
|
|
||||||
* That is because the mplayer.getFaction() method is not threadsafe.
|
|
||||||
* TODO: Something to fix in the future perhaps?
|
|
||||||
*/
|
|
||||||
public class FactionsIndex
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static FactionsIndex i = new FactionsIndex();
|
|
||||||
public static FactionsIndex get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private final Map<MPlayer, Faction> mplayer2faction;
|
|
||||||
private final Map<Faction, Set<MPlayer>> faction2mplayers;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private FactionsIndex()
|
|
||||||
{
|
|
||||||
this.mplayer2faction = new WeakHashMap<>();
|
|
||||||
this.faction2mplayers = new WeakHashMapCreativeImpl();
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// IS CONNECTED
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private boolean isConnected(MPlayer mplayer, Faction faction)
|
|
||||||
{
|
|
||||||
if (mplayer == null) throw new NullPointerException("mplayer");
|
|
||||||
if (faction == null) throw new NullPointerException("faction");
|
|
||||||
|
|
||||||
return mplayer.getFaction() == faction;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// GET
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public synchronized Faction getFaction(MPlayer mplayer)
|
|
||||||
{
|
|
||||||
return this.mplayer2faction.get(mplayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized Set<MPlayer> getMPlayers(Faction faction)
|
|
||||||
{
|
|
||||||
return new MassiveSet<>(this.faction2mplayers.get(faction));
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// UPDATE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public synchronized void updateAll()
|
|
||||||
{
|
|
||||||
if (!MPlayerColl.get().isActive()) throw new IllegalStateException("The MPlayerColl is not yet fully activated.");
|
|
||||||
|
|
||||||
MPlayerColl.get().getAll().forEach(this::update);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void update(MPlayer mplayer)
|
|
||||||
{
|
|
||||||
if (mplayer == null) throw new NullPointerException("mplayer");
|
|
||||||
if (!FactionColl.get().isActive()) throw new IllegalStateException("The FactionColl is not yet fully activated.");
|
|
||||||
|
|
||||||
// TODO: This is not optimal but here we remove a player from the index when
|
|
||||||
// the mplayer object is deattached. Optimally it should be removed
|
|
||||||
// automatically because it is stored as a weak reference.
|
|
||||||
// But sometimes that doesn't happen so we do this instead.
|
|
||||||
// Is there a memory leak somewhere?
|
|
||||||
if (!mplayer.attached())
|
|
||||||
{
|
|
||||||
Faction factionIndexed = this.mplayer2faction.remove(mplayer);
|
|
||||||
if (factionIndexed != null)
|
|
||||||
{
|
|
||||||
faction2mplayers.get(factionIndexed).remove(mplayer);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Faction factionActual = mplayer.getFaction();
|
|
||||||
Faction factionIndexed = this.getFaction(mplayer);
|
|
||||||
|
|
||||||
Set<Faction> factions = new MassiveSet<>();
|
|
||||||
if (factionActual != null) factions.add(factionActual);
|
|
||||||
if (factionIndexed != null) factions.add(factionIndexed);
|
|
||||||
|
|
||||||
for (Faction faction : factions)
|
|
||||||
{
|
|
||||||
boolean connected = this.isConnected(mplayer, faction);
|
|
||||||
if (connected)
|
|
||||||
{
|
|
||||||
this.faction2mplayers.get(faction).add(mplayer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.faction2mplayers.get(faction).remove(mplayer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mplayer2faction.put(mplayer, factionActual);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void update(Faction faction)
|
|
||||||
{
|
|
||||||
if (faction == null) throw new NullPointerException("faction");
|
|
||||||
|
|
||||||
this.getMPlayers(faction).forEach(this::update);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// MAP
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static abstract class WeakHashMapCreative<K, V> extends java.util.WeakHashMap<K, V>
|
|
||||||
{
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public V get(Object key)
|
|
||||||
{
|
|
||||||
V ret = super.get(key);
|
|
||||||
|
|
||||||
if (ret == null)
|
|
||||||
{
|
|
||||||
ret = this.createValue();
|
|
||||||
this.put((K)key, ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract V createValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class WeakHashMapCreativeImpl extends WeakHashMapCreative<Faction, Set<MPlayer>>
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Set<MPlayer> createValue()
|
|
||||||
{
|
|
||||||
return Collections.newSetFromMap(new WeakHashMap<>());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
package com.massivecraft.factions;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.Identified;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.util.PermissionUtil;
|
|
||||||
import org.bukkit.permissions.Permissible;
|
|
||||||
|
|
||||||
public enum Perm implements Identified
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// ENUM
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
// All of these are referenced in the code
|
|
||||||
ACCESS_GRANT_ONE,
|
|
||||||
ACCESS_GRANT_FILL,
|
|
||||||
ACCESS_GRANT_SQUARE,
|
|
||||||
ACCESS_GRANT_CIRCLE,
|
|
||||||
ACCESS_DENY_ONE,
|
|
||||||
ACCESS_DENY_FILL,
|
|
||||||
ACCESS_DENY_SQUARE,
|
|
||||||
ACCESS_DENY_CIRCLE,
|
|
||||||
CLAIM_ONE,
|
|
||||||
CLAIM_AUTO,
|
|
||||||
CLAIM_FILL,
|
|
||||||
CLAIM_SQUARE,
|
|
||||||
CLAIM_CIRCLE,
|
|
||||||
CLAIM_ALL,
|
|
||||||
UNCLAIM_ONE,
|
|
||||||
UNCLAIM_AUTO,
|
|
||||||
UNCLAIM_FILL,
|
|
||||||
UNCLAIM_SQUARE,
|
|
||||||
UNCLAIM_CIRCLE,
|
|
||||||
UNCLAIM_ALL,
|
|
||||||
OVERRIDE,
|
|
||||||
FLY,
|
|
||||||
JOIN_OTHERS,
|
|
||||||
INVITE_LIST_OTHER,
|
|
||||||
TITLE_COLOR,
|
|
||||||
POWERBOOST_SET,
|
|
||||||
MONEY_BALANCE_ANY,
|
|
||||||
SETPOWER,
|
|
||||||
CONFIG,
|
|
||||||
VERSION,
|
|
||||||
|
|
||||||
// These are just here to tell the system that it is seechunk rather than see.chunk
|
|
||||||
SEECHUNK,
|
|
||||||
SEECHUNKOLD,
|
|
||||||
|
|
||||||
// END OF LIST
|
|
||||||
;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private final String id;
|
|
||||||
@Override public String getId() { return this.id; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
Perm()
|
|
||||||
{
|
|
||||||
this.id = PermissionUtil.createPermissionId(Factions.get(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// HAS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public boolean has(Permissible permissible, boolean verboose)
|
|
||||||
{
|
|
||||||
return PermissionUtil.hasPermission(permissible, this, verboose);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean has(Permissible permissible)
|
|
||||||
{
|
|
||||||
return PermissionUtil.hasPermission(permissible, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hasOrThrow(Permissible permissible) throws MassiveException
|
|
||||||
{
|
|
||||||
PermissionUtil.hasPermissionOrThrow(permissible, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package com.massivecraft.factions;
|
|
||||||
|
|
||||||
public interface PowerBoosted
|
|
||||||
{
|
|
||||||
double getPowerBoost();
|
|
||||||
void setPowerBoost(Double powerBoost);
|
|
||||||
}
|
|
@ -1,140 +0,0 @@
|
|||||||
package com.massivecraft.factions;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.massivecore.Colorized;
|
|
||||||
import com.massivecraft.massivecore.Named;
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveSet;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public enum Rel implements Colorized, Named, MPerm.MPermable
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// ENUM
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
ENEMY(
|
|
||||||
"an enemy", "enemies", "an enemy faction", "enemy factions",
|
|
||||||
"Enemy"
|
|
||||||
) { @Override public ChatColor getColor() { return MConf.get().colorEnemy; } },
|
|
||||||
|
|
||||||
NEUTRAL(
|
|
||||||
"someone neutral to you", "those neutral to you", "a neutral faction", "neutral factions",
|
|
||||||
"Neutral"
|
|
||||||
) { @Override public ChatColor getColor() { return MConf.get().colorNeutral; } },
|
|
||||||
|
|
||||||
TRUCE(
|
|
||||||
"someone in truce with you", "those in truce with you", "a faction in truce", "factions in truce",
|
|
||||||
"Truce"
|
|
||||||
) { @Override public ChatColor getColor() { return MConf.get().colorTruce; } },
|
|
||||||
|
|
||||||
ALLY(
|
|
||||||
"an ally", "allies", "an allied faction", "allied factions",
|
|
||||||
"Ally"
|
|
||||||
) { @Override public ChatColor getColor() { return MConf.get().colorAlly; } },
|
|
||||||
|
|
||||||
FACTION(
|
|
||||||
"your faction", "your faction", "your faction", "your faction",
|
|
||||||
"Faction"
|
|
||||||
) { @Override public ChatColor getColor() { return MConf.get().colorMember; } },
|
|
||||||
|
|
||||||
// END OF LIST
|
|
||||||
;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public int getValue() { return this.ordinal(); }
|
|
||||||
|
|
||||||
private final String descPlayerOne;
|
|
||||||
public String getDescPlayerOne() { return this.descPlayerOne; }
|
|
||||||
|
|
||||||
private final String descPlayerMany;
|
|
||||||
public String getDescPlayerMany() { return this.descPlayerMany; }
|
|
||||||
|
|
||||||
private final String descFactionOne;
|
|
||||||
public String getDescFactionOne() { return this.descFactionOne; }
|
|
||||||
|
|
||||||
private final String descFactionMany;
|
|
||||||
public String getDescFactionMany() { return this.descFactionMany; }
|
|
||||||
|
|
||||||
private final Set<String> names;
|
|
||||||
public Set<String> getNames() { return this.names; }
|
|
||||||
@Override public String getName() { return this.getNames().iterator().next(); }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
Rel(String descPlayerOne, String descPlayerMany, String descFactionOne, String descFactionMany, String... names)
|
|
||||||
{
|
|
||||||
this.descPlayerOne = descPlayerOne;
|
|
||||||
this.descPlayerMany = descPlayerMany;
|
|
||||||
this.descFactionOne = descFactionOne;
|
|
||||||
this.descFactionMany = descFactionMany;
|
|
||||||
this.names = Collections.unmodifiableSet(new MassiveSet<>(names));
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChatColor getColor()
|
|
||||||
{
|
|
||||||
return MConf.get().colorMember;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId()
|
|
||||||
{
|
|
||||||
return name();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName(Object senderObject)
|
|
||||||
{
|
|
||||||
return this.getColor() + this.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// UTIL
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public boolean isAtLeast(Rel rel)
|
|
||||||
{
|
|
||||||
return this.getValue() >= rel.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAtMost(Rel rel)
|
|
||||||
{
|
|
||||||
return this.getValue() <= rel.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLessThan(Rel rel)
|
|
||||||
{
|
|
||||||
return this.getValue() < rel.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMoreThan(Rel rel)
|
|
||||||
{
|
|
||||||
return this.getValue() > rel.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used for friendly fire.
|
|
||||||
public boolean isFriend()
|
|
||||||
{
|
|
||||||
return this.isAtLeast(TRUCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public String getPrefix()
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package com.massivecraft.factions;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
|
|
||||||
public interface RelationParticipator
|
|
||||||
{
|
|
||||||
String describeTo(RelationParticipator observer);
|
|
||||||
String describeTo(RelationParticipator observer, boolean ucfirst);
|
|
||||||
|
|
||||||
Rel getRelationTo(RelationParticipator observer);
|
|
||||||
Rel getRelationTo(RelationParticipator observer, boolean ignorePeaceful);
|
|
||||||
|
|
||||||
ChatColor getColorTo(RelationParticipator observer);
|
|
||||||
}
|
|
@ -1,184 +0,0 @@
|
|||||||
package com.massivecraft.factions;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPerm.MPermable;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.util.RelationUtil;
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveSet;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class TerritoryAccess
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS: RAW
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
// no default value, can't be null
|
|
||||||
private final String hostFactionId;
|
|
||||||
public String getHostFactionId() { return this.hostFactionId; }
|
|
||||||
|
|
||||||
// default is true
|
|
||||||
private final boolean hostFactionAllowed;
|
|
||||||
public boolean isHostFactionAllowed() { return this.hostFactionAllowed; }
|
|
||||||
|
|
||||||
// default is empty
|
|
||||||
private final Set<String> grantedIds;
|
|
||||||
public Set<String> getGrantedIds() { return this.grantedIds; }
|
|
||||||
|
|
||||||
// default is null
|
|
||||||
private final String chunkName;
|
|
||||||
public String getChunkName() { return this.chunkName; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS: VERSION
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public int version = 1;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS: DELTA
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
// The simple ones
|
|
||||||
public TerritoryAccess withHostFactionId(String hostFactionId) { return valueOf(hostFactionId, hostFactionAllowed, grantedIds, chunkName); }
|
|
||||||
public TerritoryAccess withHostFactionAllowed(Boolean hostFactionAllowed) { return valueOf(hostFactionId, hostFactionAllowed, grantedIds, chunkName); }
|
|
||||||
public TerritoryAccess withGrantedIds(Collection<String> grantedIds) { return valueOf(hostFactionId, hostFactionAllowed, grantedIds, chunkName); }
|
|
||||||
public TerritoryAccess withChunkName(String chunkName) { return valueOf(hostFactionId, hostFactionAllowed, grantedIds, chunkName); }
|
|
||||||
|
|
||||||
// The intermediate ones
|
|
||||||
public TerritoryAccess withGranted(MPermable mpermable, boolean with)
|
|
||||||
{
|
|
||||||
return withGrantedId(mpermable.getId(), with);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TerritoryAccess withGrantedId(String grantedId, boolean with)
|
|
||||||
{
|
|
||||||
if (this.getHostFactionId().equals(grantedId))
|
|
||||||
{
|
|
||||||
return valueOf(hostFactionId, with, grantedIds, chunkName);
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<String> grantedIds = new MassiveSet<>(this.getGrantedIds());
|
|
||||||
if (with)
|
|
||||||
{
|
|
||||||
grantedIds.add(grantedId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
grantedIds.remove(grantedId);
|
|
||||||
}
|
|
||||||
return valueOf(hostFactionId, hostFactionAllowed, grantedIds, chunkName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS: DIRECT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
// This method intentionally returns null if the Faction no longer exists.
|
|
||||||
// In Board we don't even return this TerritoryAccess if that is the case.
|
|
||||||
public Faction getHostFaction()
|
|
||||||
{
|
|
||||||
return Faction.get(this.getHostFactionId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<MPermable> getGranteds()
|
|
||||||
{
|
|
||||||
return MPerm.idsToMPermables(this.getGrantedIds());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// PRIVATE CONSTRUCTOR
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
// Strictly for GSON only
|
|
||||||
private TerritoryAccess()
|
|
||||||
{
|
|
||||||
this.hostFactionId = null;
|
|
||||||
this.hostFactionAllowed = true;
|
|
||||||
this.grantedIds = null;
|
|
||||||
this.chunkName = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TerritoryAccess(String hostFactionId, Boolean hostFactionAllowed, Collection<String> grantedIds, String chunkName)
|
|
||||||
{
|
|
||||||
if (hostFactionId == null) throw new NullPointerException("hostFactionId");
|
|
||||||
if (grantedIds == null) throw new NullPointerException("grantedIds");
|
|
||||||
this.hostFactionId = hostFactionId;
|
|
||||||
|
|
||||||
Set<String> grantedIdsInner = new MassiveSet<>();
|
|
||||||
grantedIdsInner.addAll(grantedIds);
|
|
||||||
if (grantedIdsInner.remove(hostFactionId))
|
|
||||||
{
|
|
||||||
hostFactionAllowed = true;
|
|
||||||
}
|
|
||||||
this.grantedIds = Collections.unmodifiableSet(grantedIdsInner);
|
|
||||||
|
|
||||||
this.hostFactionAllowed = (hostFactionAllowed == null || hostFactionAllowed);
|
|
||||||
|
|
||||||
this.chunkName = chunkName;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FACTORY: VALUE OF
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public static TerritoryAccess valueOf(String hostFactionId, Boolean hostFactionAllowed, Collection<String> grantedIds, String chunkName)
|
|
||||||
{
|
|
||||||
if (hostFactionId == null) throw new NullPointerException("hostFactionId");
|
|
||||||
if (grantedIds == null) throw new NullPointerException("grantedIds");
|
|
||||||
return new TerritoryAccess(hostFactionId, hostFactionAllowed, grantedIds, chunkName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TerritoryAccess valueOf(String hostFactionId)
|
|
||||||
{
|
|
||||||
if (hostFactionId == null) throw new NullPointerException("hostFactionId");
|
|
||||||
return valueOf(hostFactionId, null, Collections.emptySet(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE METHODS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public boolean isGranted(MPermable permable)
|
|
||||||
{
|
|
||||||
return isGranted(permable.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isGranted(String permableId)
|
|
||||||
{
|
|
||||||
if (permableId.equals(this.hostFactionId)) return this.isHostFactionAllowed();
|
|
||||||
return this.getGrantedIds().contains(permableId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// A "default" TerritoryAccess could be serialized as a simple string only.
|
|
||||||
// The host faction is still allowed (default) and no faction or player has been granted explicit access (default).
|
|
||||||
public boolean isDefault()
|
|
||||||
{
|
|
||||||
return this.isHostFactionAllowed() && this.getGrantedIds().isEmpty() && this.getChunkName() == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// ACCESS STATUS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public AccessStatus getTerritoryAccess(MPlayer mplayer)
|
|
||||||
{
|
|
||||||
if (isGranted(mplayer.getId())) return AccessStatus.ELEVATED;
|
|
||||||
if (isGranted(mplayer.getRank().getId())) return AccessStatus.ELEVATED;
|
|
||||||
|
|
||||||
if (this.getHostFactionId().equals(mplayer.getFaction().getId()))
|
|
||||||
{
|
|
||||||
if (this.isHostFactionAllowed()) return AccessStatus.STANDARD;
|
|
||||||
else return AccessStatus.DECREASED;
|
|
||||||
}
|
|
||||||
if (isGranted(mplayer.getFaction().getId())) return AccessStatus.ELEVATED;
|
|
||||||
if (isGranted(RelationUtil.getRelationOfThatToMe(mplayer, this.getHostFaction()).toString())) return AccessStatus.ELEVATED;
|
|
||||||
|
|
||||||
return AccessStatus.STANDARD;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
package com.massivecraft.factions.adapter;
|
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonDeserializer;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import com.google.gson.JsonSerializationContext;
|
|
||||||
import com.google.gson.JsonSerializer;
|
|
||||||
import com.massivecraft.factions.entity.Board;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
|
|
||||||
public class BoardAdapter implements JsonDeserializer<Board>, JsonSerializer<Board>
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static BoardAdapter i = new BoardAdapter();
|
|
||||||
public static BoardAdapter get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public Board deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
|
||||||
{
|
|
||||||
return new Board(context.deserialize(json, Board.MAP_TYPE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonElement serialize(Board src, Type typeOfSrc, JsonSerializationContext context)
|
|
||||||
{
|
|
||||||
return context.serialize(src.getMap(), Board.MAP_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
package com.massivecraft.factions.adapter;
|
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonDeserializer;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import com.google.gson.JsonSerializationContext;
|
|
||||||
import com.google.gson.JsonSerializer;
|
|
||||||
import com.massivecraft.factions.TerritoryAccess;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentSkipListMap;
|
|
||||||
|
|
||||||
public class BoardMapAdapter implements JsonDeserializer<Map<PS, TerritoryAccess>>, JsonSerializer<Map<PS, TerritoryAccess>>
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static BoardMapAdapter i = new BoardMapAdapter();
|
|
||||||
public static BoardMapAdapter get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<PS, TerritoryAccess> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
|
||||||
{
|
|
||||||
Map<PS, TerritoryAccess> ret = new ConcurrentSkipListMap<>();
|
|
||||||
|
|
||||||
JsonObject jsonObject = json.getAsJsonObject();
|
|
||||||
|
|
||||||
for (Entry<String, JsonElement> entry : jsonObject.entrySet())
|
|
||||||
{
|
|
||||||
String[] ChunkCoordParts = entry.getKey().split("[,\\s]+");
|
|
||||||
int chunkX = Integer.parseInt(ChunkCoordParts[0]);
|
|
||||||
int chunkZ = Integer.parseInt(ChunkCoordParts[1]);
|
|
||||||
PS chunk = PS.valueOf(chunkX, chunkZ);
|
|
||||||
|
|
||||||
TerritoryAccess territoryAccess = context.deserialize(entry.getValue(), TerritoryAccess.class);
|
|
||||||
|
|
||||||
ret.put(chunk, territoryAccess);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonElement serialize(Map<PS, TerritoryAccess> src, Type typeOfSrc, JsonSerializationContext context)
|
|
||||||
{
|
|
||||||
JsonObject ret = new JsonObject();
|
|
||||||
|
|
||||||
for (Entry<PS, TerritoryAccess> entry : src.entrySet())
|
|
||||||
{
|
|
||||||
PS ps = entry.getKey();
|
|
||||||
TerritoryAccess territoryAccess = entry.getValue();
|
|
||||||
|
|
||||||
ret.add(ps.getChunkX().toString() + "," + ps.getChunkZ().toString(), context.serialize(territoryAccess, TerritoryAccess.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,117 +0,0 @@
|
|||||||
package com.massivecraft.factions.adapter;
|
|
||||||
|
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonDeserializer;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import com.google.gson.JsonPrimitive;
|
|
||||||
import com.google.gson.JsonSerializationContext;
|
|
||||||
import com.google.gson.JsonSerializer;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import com.massivecraft.factions.TerritoryAccess;
|
|
||||||
import com.massivecraft.massivecore.store.migrator.MigratorUtil;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class TerritoryAccessAdapter implements JsonDeserializer<TerritoryAccess>, JsonSerializer<TerritoryAccess>
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTANTS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public static final String HOST_FACTION_ID = "hostFactionId";
|
|
||||||
public static final String HOST_FACTION_ALLOWED = "hostFactionAllowed";
|
|
||||||
public static final String GRANTED_IDS = "grantedIds";
|
|
||||||
public static final String CHUNK_NAME = "chunkName";
|
|
||||||
|
|
||||||
public static final Type SET_OF_STRING_TYPE = new TypeToken<Set<String>>(){}.getType();
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static TerritoryAccessAdapter i = new TerritoryAccessAdapter();
|
|
||||||
public static TerritoryAccessAdapter get() { return i; }
|
|
||||||
|
|
||||||
//----------------------------------------------//
|
|
||||||
// OVERRIDE
|
|
||||||
//----------------------------------------------//
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TerritoryAccess deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
|
||||||
{
|
|
||||||
// isDefault <=> simple hostFactionId string
|
|
||||||
if (json.isJsonPrimitive())
|
|
||||||
{
|
|
||||||
String hostFactionId = json.getAsString();
|
|
||||||
return TerritoryAccess.valueOf(hostFactionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise object
|
|
||||||
JsonObject obj = json.getAsJsonObject();
|
|
||||||
|
|
||||||
// Prepare variables
|
|
||||||
String hostFactionId = null;
|
|
||||||
Boolean hostFactionAllowed = null;
|
|
||||||
Set<String> grantedIds = Collections.emptySet();
|
|
||||||
String chunkName = null;
|
|
||||||
|
|
||||||
// Read variables (test old values first)
|
|
||||||
JsonElement element = null;
|
|
||||||
|
|
||||||
element = obj.get(HOST_FACTION_ID);
|
|
||||||
hostFactionId = element.getAsString();
|
|
||||||
|
|
||||||
element = obj.get(HOST_FACTION_ALLOWED);
|
|
||||||
if (element != null) hostFactionAllowed = element.getAsBoolean();
|
|
||||||
|
|
||||||
element = obj.get(GRANTED_IDS);
|
|
||||||
if (element != null) grantedIds = context.deserialize(element, SET_OF_STRING_TYPE);
|
|
||||||
|
|
||||||
element = obj.get(CHUNK_NAME);
|
|
||||||
if (element != null) chunkName = element.getAsString();
|
|
||||||
|
|
||||||
return TerritoryAccess.valueOf(hostFactionId, hostFactionAllowed, grantedIds, chunkName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonElement serialize(TerritoryAccess src, Type typeOfSrc, JsonSerializationContext context)
|
|
||||||
{
|
|
||||||
if (src == null) return null;
|
|
||||||
|
|
||||||
// isDefault <=> simple hostFactionId string
|
|
||||||
if (src.isDefault())
|
|
||||||
{
|
|
||||||
return new JsonPrimitive(src.getHostFactionId());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise object
|
|
||||||
JsonObject obj = new JsonObject();
|
|
||||||
|
|
||||||
obj.addProperty(HOST_FACTION_ID, src.getHostFactionId());
|
|
||||||
|
|
||||||
if (!src.isHostFactionAllowed())
|
|
||||||
{
|
|
||||||
obj.addProperty(HOST_FACTION_ALLOWED, src.isHostFactionAllowed());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!src.getGrantedIds().isEmpty())
|
|
||||||
{
|
|
||||||
obj.add(GRANTED_IDS, context.serialize(src.getGrantedIds(), SET_OF_STRING_TYPE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (src.getChunkName() != null)
|
|
||||||
{
|
|
||||||
obj.addProperty(CHUNK_NAME, src.getChunkName());
|
|
||||||
}
|
|
||||||
|
|
||||||
obj.add(MigratorUtil.VERSION_FIELD_NAME, new JsonPrimitive(src.version));
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.Active;
|
|
||||||
import com.massivecraft.massivecore.Identified;
|
|
||||||
import com.massivecraft.massivecore.MassivePlugin;
|
|
||||||
|
|
||||||
public abstract class ChatActive implements Active, Identified
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private MassivePlugin activePlugin;
|
|
||||||
|
|
||||||
private final String id;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public ChatActive(final String id)
|
|
||||||
{
|
|
||||||
this.id = id.toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE > IDENTIFIED
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId()
|
|
||||||
{
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE > ACTIVE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MassivePlugin setActivePlugin(MassivePlugin plugin)
|
|
||||||
{
|
|
||||||
this.activePlugin = plugin;
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MassivePlugin getActivePlugin()
|
|
||||||
{
|
|
||||||
return this.activePlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setActive(MassivePlugin plugin)
|
|
||||||
{
|
|
||||||
this.setActive(plugin != null);
|
|
||||||
this.setActivePlugin(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,116 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The ChatFormater is a system offered by factions for tag parsing.
|
|
||||||
*
|
|
||||||
* Note that every tag and modifier id must be lowercase.
|
|
||||||
* A tag with id "derp" is allowed but not with id "Derp". For that reason the tag {sender} will work but {Sender} wont.
|
|
||||||
*/
|
|
||||||
public class ChatFormatter
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTANTS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public final static String START = "{";
|
|
||||||
public final static String END = "}";
|
|
||||||
public final static String SEPARATOR = "|";
|
|
||||||
|
|
||||||
public final static String ESC_START = "\\"+START;
|
|
||||||
public final static String ESC_END = "\\"+END;
|
|
||||||
public final static String ESC_SEPARATOR = "\\"+SEPARATOR;
|
|
||||||
|
|
||||||
public final static Pattern pattern = Pattern.compile(ESC_START+"([^"+ESC_START+ESC_END+"]+)"+ESC_END);
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FORMAT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public static String format(String msg, CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
// We build the return value in this string buffer
|
|
||||||
StringBuffer ret = new StringBuffer();
|
|
||||||
|
|
||||||
// A matcher to match all the tags in the msg
|
|
||||||
Matcher matcher = pattern.matcher(msg);
|
|
||||||
|
|
||||||
// For each tag we find
|
|
||||||
while (matcher.find())
|
|
||||||
{
|
|
||||||
// The fullmatch is something like "{sender|lp|rp}"
|
|
||||||
String fullmatch = matcher.group(0);
|
|
||||||
|
|
||||||
// The submatch is something like "sender|lp|rp"
|
|
||||||
String submatch = matcher.group(1);
|
|
||||||
|
|
||||||
// The parts are something like ["sender", "lp", "rp"]
|
|
||||||
String[] parts = submatch.split(ESC_SEPARATOR);
|
|
||||||
|
|
||||||
// The modifier ids are something like ["lp", "rp"] and tagId something like "sender"
|
|
||||||
List<String> modifierIds = new ArrayList<>(Arrays.asList(parts));
|
|
||||||
String tagId = modifierIds.remove(0);
|
|
||||||
|
|
||||||
// Fetch tag for the id
|
|
||||||
ChatTag tag = ChatTag.getTag(tagId);
|
|
||||||
|
|
||||||
String replacement;
|
|
||||||
if (tag == null)
|
|
||||||
{
|
|
||||||
// No change if tag wasn't found
|
|
||||||
replacement = fullmatch;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
replacement = compute(tag, modifierIds, sender, recipient);
|
|
||||||
if (replacement == null)
|
|
||||||
{
|
|
||||||
// If a tag or modifier returns null it's the same as opting out.
|
|
||||||
replacement = fullmatch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
matcher.appendReplacement(ret, replacement);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append the rest
|
|
||||||
matcher.appendTail(ret);
|
|
||||||
|
|
||||||
// And finally we return the string value of the buffer we built
|
|
||||||
return ret.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// TAG COMPUTE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public static String compute(ChatTag tag, List<String> modifierIds, CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
String ret = tag.getReplacement(sender, recipient);
|
|
||||||
if (ret == null) return null;
|
|
||||||
|
|
||||||
for (String modifierId : modifierIds)
|
|
||||||
{
|
|
||||||
// Find the modifier or skip
|
|
||||||
ChatModifier modifier = ChatModifier.getModifier(modifierId);
|
|
||||||
if (modifier == null) continue;
|
|
||||||
|
|
||||||
// Modify and ignore change if null.
|
|
||||||
// Modifier can't get or return null.
|
|
||||||
String modified = modifier.getModified(ret, sender, recipient);
|
|
||||||
if (modified == null) continue;
|
|
||||||
|
|
||||||
ret = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveMap;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public abstract class ChatModifier extends ChatActive
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// MODIFIER REGISTER
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private final static Map<String, ChatModifier> idToModifier = new MassiveMap<>();
|
|
||||||
public static ChatModifier getModifier(String modifierId) { return idToModifier.get(modifierId); }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public ChatModifier(final String id)
|
|
||||||
{
|
|
||||||
super(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isActive()
|
|
||||||
{
|
|
||||||
return idToModifier.containsKey(this.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setActive(boolean active)
|
|
||||||
{
|
|
||||||
if (active)
|
|
||||||
{
|
|
||||||
idToModifier.put(this.getId(), this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
idToModifier.remove(this.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// ABSTRACT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public abstract String getModified(String subject, CommandSender sender, CommandSender recipient);
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveMap;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public abstract class ChatTag extends ChatActive
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// TAG REGISTER
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private final static Map<String, ChatTag> idToTag = new MassiveMap<>();
|
|
||||||
public static ChatTag getTag(String tagId) { return idToTag.get(tagId); }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public ChatTag(final String id)
|
|
||||||
{
|
|
||||||
super(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isActive()
|
|
||||||
{
|
|
||||||
return idToTag.containsKey(this.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setActive(boolean active)
|
|
||||||
{
|
|
||||||
if (active)
|
|
||||||
{
|
|
||||||
idToTag.put(this.getId(), this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
idToTag.remove(this.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// ABSTRACT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public abstract String getReplacement(CommandSender sender, CommandSender recipient);
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat.modifier;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.chat.ChatModifier;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class ChatModifierLc extends ChatModifier
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private ChatModifierLc() { super("lc"); }
|
|
||||||
private static ChatModifierLc i = new ChatModifierLc();
|
|
||||||
public static ChatModifierLc get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModified(String subject, CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
return subject.toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat.modifier;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.chat.ChatModifier;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
|
|
||||||
public class ChatModifierLp extends ChatModifier
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private ChatModifierLp() { super("lp"); }
|
|
||||||
private static ChatModifierLp i = new ChatModifierLp();
|
|
||||||
public static ChatModifierLp get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModified(String subject, CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
if (subject.equals("")) return subject;
|
|
||||||
return " "+subject;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat.modifier;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.chat.ChatModifier;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class ChatModifierParse extends ChatModifier
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private ChatModifierParse() { super("parse"); }
|
|
||||||
private static ChatModifierParse i = new ChatModifierParse();
|
|
||||||
public static ChatModifierParse get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModified(String subject, CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
return Txt.parse(subject);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat.modifier;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.chat.ChatModifier;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class ChatModifierRp extends ChatModifier
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private ChatModifierRp() { super("rp"); }
|
|
||||||
private static ChatModifierRp i = new ChatModifierRp();
|
|
||||||
public static ChatModifierRp get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModified(String subject, CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
if (subject.equals("")) return subject;
|
|
||||||
return subject+" ";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat.modifier;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.chat.ChatModifier;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class ChatModifierUc extends ChatModifier
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private ChatModifierUc() { super("uc"); }
|
|
||||||
private static ChatModifierUc i = new ChatModifierUc();
|
|
||||||
public static ChatModifierUc get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModified(String subject, CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
return subject.toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat.modifier;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.chat.ChatModifier;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class ChatModifierUcf extends ChatModifier
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private ChatModifierUcf() { super("ucf"); }
|
|
||||||
private static ChatModifierUcf i = new ChatModifierUcf();
|
|
||||||
public static ChatModifierUcf get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModified(String subject, CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
return Txt.upperCaseFirst(subject);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat.tag;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.chat.ChatTag;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class ChatTagName extends ChatTag
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private ChatTagName() { super("factions_name"); }
|
|
||||||
private static ChatTagName i = new ChatTagName();
|
|
||||||
public static ChatTagName get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getReplacement(CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
// Get entities
|
|
||||||
MPlayer usender = MPlayer.get(sender);
|
|
||||||
|
|
||||||
// No "force"
|
|
||||||
Faction faction = usender.getFaction();
|
|
||||||
if (faction.isNone()) return "";
|
|
||||||
|
|
||||||
return faction.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat.tag;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.chat.ChatTag;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class ChatTagNameforce extends ChatTag
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private ChatTagNameforce() { super("factions_nameforce"); }
|
|
||||||
private static ChatTagNameforce i = new ChatTagNameforce();
|
|
||||||
public static ChatTagNameforce get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getReplacement(CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
// Get entities
|
|
||||||
MPlayer usender = MPlayer.get(sender);
|
|
||||||
|
|
||||||
Faction faction = usender.getFaction();
|
|
||||||
return faction.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat.tag;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.chat.ChatTag;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class ChatTagRelcolor extends ChatTag
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private ChatTagRelcolor() { super("factions_relcolor"); }
|
|
||||||
private static ChatTagRelcolor i = new ChatTagRelcolor();
|
|
||||||
public static ChatTagRelcolor get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getReplacement(CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
// Opt out if no recipient
|
|
||||||
if (recipient == null) return null;
|
|
||||||
|
|
||||||
// Get entities
|
|
||||||
MPlayer usender = MPlayer.get(sender);
|
|
||||||
MPlayer urecipient = MPlayer.get(recipient);
|
|
||||||
|
|
||||||
return urecipient.getRelationTo(usender).getColor().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat.tag;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.chat.ChatTag;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class ChatTagRole extends ChatTag
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private ChatTagRole() { super("factions_role"); }
|
|
||||||
private static ChatTagRole i = new ChatTagRole();
|
|
||||||
public static ChatTagRole get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getReplacement(CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
// Get entities
|
|
||||||
MPlayer usender = MPlayer.get(sender);
|
|
||||||
|
|
||||||
return Txt.upperCaseFirst(usender.getRank().getName().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat.tag;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.chat.ChatTag;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class ChatTagRoleprefix extends ChatTag
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private ChatTagRoleprefix() { super("factions_roleprefix"); }
|
|
||||||
private static ChatTagRoleprefix i = new ChatTagRoleprefix();
|
|
||||||
public static ChatTagRoleprefix get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getReplacement(CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
// Get entities
|
|
||||||
MPlayer usender = MPlayer.get(sender);
|
|
||||||
|
|
||||||
// No "force"
|
|
||||||
Faction faction = usender.getFaction();
|
|
||||||
if (faction.isNone()) return "";
|
|
||||||
|
|
||||||
return usender.getRank().getPrefix();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat.tag;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.chat.ChatTag;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class ChatTagRoleprefixforce extends ChatTag
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private ChatTagRoleprefixforce() { super("factions_roleprefixforce"); }
|
|
||||||
private static ChatTagRoleprefixforce i = new ChatTagRoleprefixforce();
|
|
||||||
public static ChatTagRoleprefixforce get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getReplacement(CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
// Get entities
|
|
||||||
MPlayer usender = MPlayer.get(sender);
|
|
||||||
|
|
||||||
return usender.getRank().getPrefix();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package com.massivecraft.factions.chat.tag;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.chat.ChatTag;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class ChatTagTitle extends ChatTag
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private ChatTagTitle() { super("factions_title"); }
|
|
||||||
private static ChatTagTitle i = new ChatTagTitle();
|
|
||||||
public static ChatTagTitle get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getReplacement(CommandSender sender, CommandSender recipient)
|
|
||||||
{
|
|
||||||
// Get entities
|
|
||||||
MPlayer usender = MPlayer.get(sender);
|
|
||||||
|
|
||||||
if (!usender.hasTitle()) return "";
|
|
||||||
return usender.getTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,96 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.massivecore.command.MassiveCommandDeprecated;
|
|
||||||
import com.massivecraft.massivecore.command.MassiveCommandVersion;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CmdFactions extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static CmdFactions i = new CmdFactions();
|
|
||||||
public static CmdFactions get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsDocumentation cmdFactionsDocumentation = new CmdFactionsDocumentation();
|
|
||||||
public CmdFactionsList cmdFactionsList = new CmdFactionsList();
|
|
||||||
public CmdFactionsFaction cmdFactionsFaction = new CmdFactionsFaction();
|
|
||||||
public CmdFactionsPlayer cmdFactionsPlayer = new CmdFactionsPlayer();
|
|
||||||
public CmdFactionsStatus cmdFactionsStatus = new CmdFactionsStatus();
|
|
||||||
public CmdFactionsJoin cmdFactionsJoin = new CmdFactionsJoin();
|
|
||||||
public CmdFactionsLeave cmdFactionsLeave = new CmdFactionsLeave();
|
|
||||||
public CmdFactionsWarp cmdFactionsWarp = new CmdFactionsWarp();
|
|
||||||
public CmdFactionsHome cmdFactionsHome = new CmdFactionsHome();
|
|
||||||
public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome();
|
|
||||||
public CmdFactionsUnsethome cmdFactionsUnsethome = new CmdFactionsUnsethome();
|
|
||||||
public CmdFactionsVote cmdFactionsVote = new CmdFactionsVote();
|
|
||||||
public CmdFactionsMap cmdFactionsMap = new CmdFactionsMap();
|
|
||||||
public CmdFactionsCreate cmdFactionsCreate = new CmdFactionsCreate();
|
|
||||||
public CmdFactionsName cmdFactionsName = new CmdFactionsName();
|
|
||||||
public CmdFactionsDescription cmdFactionsDescription = new CmdFactionsDescription();
|
|
||||||
public CmdFactionsMotd cmdFactionsMotd = new CmdFactionsMotd();
|
|
||||||
public CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite();
|
|
||||||
public CmdFactionsKick cmdFactionsKick = new CmdFactionsKick();
|
|
||||||
public CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle();
|
|
||||||
public CmdFactionsRank cmdFactionsRank = new CmdFactionsRank();
|
|
||||||
public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
|
|
||||||
public CmdFactionsTop cmdFactionsTop = new CmdFactionsTop();
|
|
||||||
public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk();
|
|
||||||
public CmdFactionsSeeChunkOld cmdFactionsSeeChunkOld = new CmdFactionsSeeChunkOld();
|
|
||||||
public CmdFactionsTerritorytitles cmdFactionsTerritorytitles = new CmdFactionsTerritorytitles();
|
|
||||||
public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim();
|
|
||||||
public CmdFactionsUnclaim cmdFactionsUnclaim = new CmdFactionsUnclaim();
|
|
||||||
public CmdFactionsAccess cmdFactionsAccess = new CmdFactionsAccess();
|
|
||||||
public CmdFactionsChunkname cmdFactionsChunkname = new CmdFactionsChunkname();
|
|
||||||
public CmdFactionsRelation cmdFactionsRelation = new CmdFactionsRelation();
|
|
||||||
public CmdFactionsRelationOld cmdFactionsRelationOldAlly = new CmdFactionsRelationOld("ally");
|
|
||||||
public CmdFactionsRelationOld cmdFactionsRelationOldTruce = new CmdFactionsRelationOld("truce");
|
|
||||||
public CmdFactionsRelationOld cmdFactionsRelationOldNeutral = new CmdFactionsRelationOld("neutral");
|
|
||||||
public CmdFactionsRelationOld cmdFactionsRelationOldEnemy = new CmdFactionsRelationOld("enemy");
|
|
||||||
public CmdFactionsTax cmdFactionsTax = new CmdFactionsTax();
|
|
||||||
public CmdFactionsPerm cmdFactionsPerm = new CmdFactionsPerm();
|
|
||||||
public CmdFactionsFlag cmdFactionsFlag = new CmdFactionsFlag();
|
|
||||||
public CmdFactionsFly cmdFactionsFly = new CmdFactionsFly();
|
|
||||||
public CmdFactionsUnstuck cmdFactionsUnstuck = new CmdFactionsUnstuck();
|
|
||||||
public CmdFactionsOverride cmdFactionsOverride = new CmdFactionsOverride();
|
|
||||||
public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband();
|
|
||||||
public CmdFactionsPowerboost cmdFactionsPowerBoost = new CmdFactionsPowerboost();
|
|
||||||
public CmdFactionsSetpower cmdFactionsSetpower = new CmdFactionsSetpower();
|
|
||||||
public CmdFactionsMoneyconvert cmdFactionsMoneyconvert = new CmdFactionsMoneyconvert();
|
|
||||||
public CmdFactionsConfig cmdFactionsConfig = new CmdFactionsConfig();
|
|
||||||
public CmdFactionsClean cmdFactionsClean = new CmdFactionsClean();
|
|
||||||
public MassiveCommandVersion cmdFactionsVersion = new MassiveCommandVersion(Factions.get());
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactions()
|
|
||||||
{
|
|
||||||
// Old rank stuff
|
|
||||||
this.addChild(new CmdFactionsRankOld("demote"));
|
|
||||||
this.addChild(new CmdFactionsRankOld("promote"));
|
|
||||||
|
|
||||||
// Deprecated Commands
|
|
||||||
this.addChild(new MassiveCommandDeprecated(this.cmdFactionsRank, "leader", "owner", "officer", "moderator", "coleader"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getAliases()
|
|
||||||
{
|
|
||||||
return MConf.get().aliasesF;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
|
||||||
|
|
||||||
public class CmdFactionsAccess extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccessView cmdFactionsAccessView = new CmdFactionsAccessView();
|
|
||||||
public CmdFactionsAccessGrant cmdFactionsAccessGrant = new CmdFactionsAccessGrant();
|
|
||||||
public CmdFactionsAccessDeny cmdFactionsAccessDeny = new CmdFactionsAccessDeny();
|
|
||||||
public CmdFactionsAccessInspect cmdFactionsAccessInspect = new CmdFactionsAccessInspect();
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccess()
|
|
||||||
{
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(RequirementIsPlayer.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,104 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.TerritoryAccess;
|
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPerm.MPermable;
|
|
||||||
import com.massivecraft.factions.util.AsciiMap;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class CmdFactionsAccessAbstract extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public PS chunk;
|
|
||||||
public TerritoryAccess ta;
|
|
||||||
public Faction hostFaction;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccessAbstract()
|
|
||||||
{
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(RequirementIsPlayer.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void senderFields(boolean set)
|
|
||||||
{
|
|
||||||
super.senderFields(set);
|
|
||||||
|
|
||||||
if (set)
|
|
||||||
{
|
|
||||||
chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
|
||||||
ta = BoardColl.get().getTerritoryAccessAt(chunk);
|
|
||||||
hostFaction = ta.getHostFaction();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
chunk = null;
|
|
||||||
ta = null;
|
|
||||||
hostFaction = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendAccessInfo()
|
|
||||||
{
|
|
||||||
String chunkDesc = AsciiMap.getChunkDescWithName(chunk, ta);
|
|
||||||
Object title = "Access" + chunkDesc;
|
|
||||||
title = Txt.titleize(title);
|
|
||||||
message(title);
|
|
||||||
|
|
||||||
msg("<k>Host Faction: %s", hostFaction.describeTo(msender, true));
|
|
||||||
msg("<k>Host Faction Allowed: %s", ta.isHostFactionAllowed() ? Txt.parse("<lime>TRUE") : Txt.parse("<rose>FALSE"));
|
|
||||||
msg("<k>Granted to: %s", CmdFactionsPermShow.permablesToDisplayString(ta.getGranteds(), msender));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccess(Collection<PS> chunks, MPermable mpermable, boolean granted)
|
|
||||||
{
|
|
||||||
chunks.forEach(chunk -> setAccess(chunk, mpermable, granted));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccess(PS chunk, MPermable mpermable, boolean granted)
|
|
||||||
{
|
|
||||||
TerritoryAccess ta = BoardColl.get().getTerritoryAccessAt(chunk);
|
|
||||||
Faction faction = ta.getHostFaction();
|
|
||||||
|
|
||||||
|
|
||||||
String chunkDesc = AsciiMap.getChunkDescWithName(chunk, ta);
|
|
||||||
String grantedDenied = granted ? "granted" : "denied";
|
|
||||||
String mpermableDesc = mpermable.getDisplayName(msender);
|
|
||||||
|
|
||||||
if ( ! MPerm.getPermAccess().has(msender, faction, false))
|
|
||||||
{
|
|
||||||
msg("<b>You do not have permission to edit access%s<b>.", chunkDesc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ta.isGranted(mpermable) == granted)
|
|
||||||
{
|
|
||||||
msg("<b>Access%s <b>is already %s to %s<b>.", chunkDesc, grantedDenied, mpermableDesc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ta = ta.withGranted(mpermable, granted);
|
|
||||||
BoardColl.get().setTerritoryAccessAt(chunk, ta);
|
|
||||||
|
|
||||||
msg("<i>Access%s<i> is now %s to %s<i>.", chunkDesc, grantedDenied, mpermableDesc);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
|
||||||
|
|
||||||
public class CmdFactionsAccessDeny extends CmdFactionsAccessAbstract
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccessSetOne cmdFactionsAccessDenyOne = new CmdFactionsAccessSetOne(false);
|
|
||||||
public CmdFactionsAccessSetSquare cmdFactionsAccessDenySquare = new CmdFactionsAccessSetSquare(false);
|
|
||||||
public CmdFactionsAccessSetCircle cmdFactionsAccessDenyCircle = new CmdFactionsAccessSetCircle(false);
|
|
||||||
public CmdFactionsAccessSetFill cmdFactionsAccessDenyFill = new CmdFactionsAccessSetFill(false);
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccessDeny()
|
|
||||||
{
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(RequirementIsPlayer.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
|
||||||
|
|
||||||
public class CmdFactionsAccessGrant extends CmdFactionsAccessAbstract
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccessSetOne cmdFactionsAccessGrantOne = new CmdFactionsAccessSetOne(true);
|
|
||||||
public CmdFactionsAccessSetSquare cmdFactionsAccessGrantSquare = new CmdFactionsAccessSetSquare(true);
|
|
||||||
public CmdFactionsAccessSetCircle cmdFactionsAccessGrantCircle = new CmdFactionsAccessSetCircle(true);
|
|
||||||
public CmdFactionsAccessSetFill cmdFactionsAccessGrantFill = new CmdFactionsAccessSetFill(true);
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccessGrant()
|
|
||||||
{
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(RequirementIsPlayer.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,96 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPermable;
|
|
||||||
import com.massivecraft.factions.entity.Board;
|
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPerm.MPermable;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveMap;
|
|
||||||
import com.massivecraft.massivecore.mixin.MixinWorld;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
|
||||||
import com.massivecraft.massivecore.ps.PSFormatHumanSpace;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class CmdFactionsAccessInspect extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccessInspect()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeMPermable.get(), "rank/rel/player/faction");
|
|
||||||
this.addParameter(TypeFaction.get(), "faction", "your");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Parameter
|
|
||||||
Faction faction = this.readArgAt(1, msenderFaction);
|
|
||||||
MPermable mpermable = TypeMPermable.get(faction).read(this.argAt(0), sender);
|
|
||||||
|
|
||||||
String factionId = faction.getId();
|
|
||||||
|
|
||||||
// Check if they have access perms, unless they are checking for their own access
|
|
||||||
if (mpermable != msender && mpermable != msenderFaction && mpermable != msender.getRank())
|
|
||||||
{
|
|
||||||
if ( ! MPerm.getPermAccess().has(msender, faction, true)) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Turn into id->chunks
|
|
||||||
// And filter the ones that are empty
|
|
||||||
Map<String, Set<PS>> world2Chunks = new MassiveMap<>();
|
|
||||||
for (Board board : BoardColl.get().getAll())
|
|
||||||
{
|
|
||||||
String worldId = board.getId();
|
|
||||||
Set<PS> chunks = board.getMap().entrySet().stream()
|
|
||||||
.filter(e -> e.getValue().getHostFactionId().equals(factionId))
|
|
||||||
.filter(e -> e.getValue().isGranted(mpermable))
|
|
||||||
.map(Entry::getKey)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
if ( ! chunks.isEmpty()) world2Chunks.put(worldId, chunks);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world2Chunks.isEmpty())
|
|
||||||
{
|
|
||||||
msg("%s <i>has no special access in <reset>%s<i>.", mpermable.getDisplayName(msender), faction.describeTo(msender));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("%s <i>has special access in <reset>%s <i>in the following chunks:", mpermable.getDisplayName(msender), faction.describeTo(msender));
|
|
||||||
|
|
||||||
for (Entry<String, Set<PS>> entry : world2Chunks.entrySet())
|
|
||||||
{
|
|
||||||
String worldId = entry.getKey();
|
|
||||||
Set<PS> chunks = entry.getValue();
|
|
||||||
|
|
||||||
String worldName = MixinWorld.get().getWorldDisplayName(worldId);
|
|
||||||
|
|
||||||
// Remove world from chunks
|
|
||||||
List<String> chunkNames = chunks.stream()
|
|
||||||
.map(PS::getChunkCoords)
|
|
||||||
.map(PSFormatHumanSpace.get()::format)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
String chunkDesc = Txt.implodeCommaAnd(chunkNames, Txt.parse("<i>"));
|
|
||||||
|
|
||||||
msg("%s<i> (%d): <reset>%s", worldName, chunks.size(), chunkDesc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Perm;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
|
||||||
import com.massivecraft.massivecore.util.ChunkUtil;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
|
|
||||||
public class CmdFactionsAccessSetCircle extends CmdFactionsAccessSetXRadius
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccessSetCircle(boolean grant)
|
|
||||||
{
|
|
||||||
// Super
|
|
||||||
super(grant);
|
|
||||||
|
|
||||||
// Aliases
|
|
||||||
this.addAliases("circle");
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(RequirementIsPlayer.get());
|
|
||||||
Perm perm = grant ? Perm.ACCESS_GRANT_CIRCLE : Perm.ACCESS_DENY_CIRCLE;
|
|
||||||
this.addRequirements(RequirementHasPerm.get(perm));
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<PS> getChunks() throws MassiveException
|
|
||||||
{
|
|
||||||
// Common Startup
|
|
||||||
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
|
||||||
return ChunkUtil.getChunksCircle(chunk, this.getRadius());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Perm;
|
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
|
||||||
import com.massivecraft.massivecore.util.ChunkUtil;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
public class CmdFactionsAccessSetFill extends CmdFactionsAccessSetXSimple
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccessSetFill(boolean claim)
|
|
||||||
{
|
|
||||||
// Super
|
|
||||||
super(claim);
|
|
||||||
|
|
||||||
// Aliases
|
|
||||||
this.addAliases("fill");
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(RequirementIsPlayer.get());
|
|
||||||
Perm perm = claim ? Perm.ACCESS_GRANT_FILL : Perm.ACCESS_DENY_FILL;
|
|
||||||
this.addRequirements(RequirementHasPerm.get(perm));
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<PS> getChunks() throws MassiveException
|
|
||||||
{
|
|
||||||
// Common Startup
|
|
||||||
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
|
||||||
|
|
||||||
// What faction (aka color) resides there?
|
|
||||||
// NOTE: Wilderness/None is valid.
|
|
||||||
final Faction color = BoardColl.get().getFactionAt(chunk);
|
|
||||||
|
|
||||||
// Calculate
|
|
||||||
int max = MConf.get().setFillMax;
|
|
||||||
Predicate<PS> matcher = ps -> BoardColl.get().getFactionAt(ps) == color;
|
|
||||||
return ChunkUtil.getChunkArea(chunk, matcher, max);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Perm;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
|
|
||||||
public class CmdFactionsAccessSetOne extends CmdFactionsAccessSetXSimple
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccessSetOne(boolean claim)
|
|
||||||
{
|
|
||||||
// Super
|
|
||||||
super(claim);
|
|
||||||
|
|
||||||
// Aliases
|
|
||||||
this.addAliases("one");
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(RequirementIsPlayer.get());
|
|
||||||
Perm perm = claim ? Perm.ACCESS_GRANT_ONE : Perm.ACCESS_DENY_ONE;
|
|
||||||
this.addRequirements(RequirementHasPerm.get(perm));
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<PS> getChunks()
|
|
||||||
{
|
|
||||||
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
|
||||||
return Collections.singleton(chunk);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Perm;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
|
||||||
import com.massivecraft.massivecore.util.ChunkUtil;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
|
|
||||||
public class CmdFactionsAccessSetSquare extends CmdFactionsAccessSetXRadius
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccessSetSquare(boolean grant)
|
|
||||||
{
|
|
||||||
// Super
|
|
||||||
super(grant);
|
|
||||||
|
|
||||||
// Aliases
|
|
||||||
this.addAliases("square");
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(RequirementIsPlayer.get());
|
|
||||||
Perm perm = grant ? Perm.ACCESS_GRANT_SQUARE : Perm.ACCESS_DENY_SQUARE;
|
|
||||||
this.addRequirements(RequirementHasPerm.get(perm));
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<PS> getChunks() throws MassiveException
|
|
||||||
{
|
|
||||||
// Common Startup
|
|
||||||
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
|
||||||
return ChunkUtil.getChunksSquare(chunk, this.getRadius());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPermable;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MPerm.MPermable;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public abstract class CmdFactionsAccessSetX extends CmdFactionsAccessAbstract
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private boolean grant = true;
|
|
||||||
public boolean isGranting() { return this.grant; }
|
|
||||||
public void setGranting(boolean grant) { this.grant = grant; }
|
|
||||||
|
|
||||||
private int mpermableArgIndex = 0;
|
|
||||||
public int getMPermableArgIndex() { return this.mpermableArgIndex; }
|
|
||||||
public void setMPermableArgIndex(int mpermableArgIndex) { this.mpermableArgIndex = mpermableArgIndex; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccessSetX(boolean grant)
|
|
||||||
{
|
|
||||||
this.setGranting(grant);
|
|
||||||
this.setSetupEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Args
|
|
||||||
final MPermable mpermable = this.getMPermable(hostFaction);
|
|
||||||
|
|
||||||
final Set<PS> chunks = this.getChunks();
|
|
||||||
if (chunks == null) throw new NullPointerException("chunks");
|
|
||||||
|
|
||||||
// Apply / Inform
|
|
||||||
setAccess(chunks, mpermable, this.isGranting());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// ABSTRACT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public abstract Set<PS> getChunks() throws MassiveException;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// EXTRAS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public MPermable getMPermable(Faction faction) throws MassiveException
|
|
||||||
{
|
|
||||||
String arg = this.argAt(this.getMPermableArgIndex());
|
|
||||||
return TypeMPermable.get(faction).read(arg, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPermable;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class CmdFactionsAccessSetXRadius extends CmdFactionsAccessSetX
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccessSetXRadius(boolean claim)
|
|
||||||
{
|
|
||||||
// Super
|
|
||||||
super(claim);
|
|
||||||
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeInteger.get(), "radius");
|
|
||||||
|
|
||||||
this.addParameter(TypeMPermable.get(), "rank/rel/faction/player");
|
|
||||||
this.setMPermableArgIndex(1);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// EXTRAS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public Integer getRadius() throws MassiveException
|
|
||||||
{
|
|
||||||
int radius = this.readArgAt(0);
|
|
||||||
|
|
||||||
// Radius Claim Min
|
|
||||||
if (radius < 1)
|
|
||||||
{
|
|
||||||
throw new MassiveException().setMsg("<b>If you specify a radius, it must be at least 1.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Radius Claim Max
|
|
||||||
if (radius > MConf.get().setRadiusMax && ! msender.isOverriding())
|
|
||||||
{
|
|
||||||
throw new MassiveException().setMsg("<b>The maximum radius allowed is <h>%s<b>.", MConf.get().setRadiusMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
return radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPermable;
|
|
||||||
|
|
||||||
public abstract class CmdFactionsAccessSetXSimple extends CmdFactionsAccessSetX
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsAccessSetXSimple(boolean claim)
|
|
||||||
{
|
|
||||||
// Super
|
|
||||||
super(claim);
|
|
||||||
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeMPermable.get(), "rank/rel/player/faction");
|
|
||||||
this.setMPermableArgIndex(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
public class CmdFactionsAccessView extends CmdFactionsAccessAbstract
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform()
|
|
||||||
{
|
|
||||||
this.sendAccessInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.TerritoryAccess;
|
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.util.AsciiMap;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
|
||||||
import com.massivecraft.massivecore.command.type.TypeNullable;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeString;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
public class CmdFactionsChunkname extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsChunkname()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeNullable.get(TypeString.get()), "name", "read");
|
|
||||||
|
|
||||||
this.addRequirements(RequirementIsPlayer.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
|
||||||
TerritoryAccess ta = BoardColl.get().getTerritoryAccessAt(chunk);
|
|
||||||
|
|
||||||
if (!this.argIsSet(0))
|
|
||||||
{
|
|
||||||
String name = ta.getChunkName();
|
|
||||||
if (name == null)
|
|
||||||
{
|
|
||||||
msg("<i>This chunk has no name.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("<i>This chunk is called <h>%s<i>.", name);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// MPerm
|
|
||||||
if (!MPerm.getPermTerritory().has(msender, msenderFaction, true)) return;
|
|
||||||
|
|
||||||
// Args
|
|
||||||
String target = this.readArg();
|
|
||||||
if (target != null)
|
|
||||||
{
|
|
||||||
target = target.trim();
|
|
||||||
target = Txt.parse(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
String old = ta.getChunkName();
|
|
||||||
|
|
||||||
// NoChange
|
|
||||||
if (MUtil.equals(old, target))
|
|
||||||
{
|
|
||||||
if (old == null)
|
|
||||||
{
|
|
||||||
throw new MassiveException().addMsg("<b>This chunk already has no name.");
|
|
||||||
}
|
|
||||||
throw new MassiveException().addMsg("<b>The name for this chunk is already <h>%s<b>.", old);
|
|
||||||
}
|
|
||||||
|
|
||||||
ta = ta.withChunkName(target);
|
|
||||||
BoardColl.get().setTerritoryAccessAt(chunk, ta);
|
|
||||||
|
|
||||||
String chunkDesc = AsciiMap.getChunkDesc(chunk);
|
|
||||||
msg("<i>The chunk name%s<i> is now %s.", chunkDesc, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
public class CmdFactionsClaim extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsSetOne cmdFactionsClaimOne = new CmdFactionsSetOne(true);
|
|
||||||
public CmdFactionsSetAuto cmdFactionsClaimAuto = new CmdFactionsSetAuto(true);
|
|
||||||
public CmdFactionsSetFill cmdFactionsClaimFill = new CmdFactionsSetFill(true);
|
|
||||||
public CmdFactionsSetSquare cmdFactionsClaimSquare = new CmdFactionsSetSquare(true);
|
|
||||||
public CmdFactionsSetCircle cmdFactionsClaimCircle = new CmdFactionsSetCircle(true);
|
|
||||||
public CmdFactionsSetAll cmdFactionsClaimAll = new CmdFactionsSetAll(true);
|
|
||||||
|
|
||||||
}
|
|
@ -1,167 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Rel;
|
|
||||||
import com.massivecraft.factions.TerritoryAccess;
|
|
||||||
import com.massivecraft.factions.entity.Board;
|
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.FactionColl;
|
|
||||||
import com.massivecraft.factions.entity.Invitation;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.entity.MPlayerColl;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveSet;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
|
||||||
import com.massivecraft.massivecore.store.EntityInternalMap;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class CmdFactionsClean extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
Object message;
|
|
||||||
int count;
|
|
||||||
|
|
||||||
// Title
|
|
||||||
message = Txt.titleize("Factions Cleaner Results");
|
|
||||||
message(message);
|
|
||||||
|
|
||||||
// Yada
|
|
||||||
cleanMessage(this.cleanPlayer(), "player");
|
|
||||||
cleanMessage(this.cleanFactionInvites(), "faction invites");
|
|
||||||
cleanMessage(this.cleanFactionRelationWhishes(), "faction relation whishes");
|
|
||||||
cleanMessage(this.cleanBoardHost(), "chunk whole");
|
|
||||||
cleanMessage(this.cleanBoardGrant(), "chunk access");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CLEAN
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private void cleanMessage(int count, String name)
|
|
||||||
{
|
|
||||||
msg("<v>%d<k> %s", count, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int cleanPlayer()
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
for (MPlayer mplayer : MPlayerColl.get().getAll())
|
|
||||||
{
|
|
||||||
if (!mplayer.isFactionOrphan()) continue;
|
|
||||||
|
|
||||||
mplayer.resetFactionData();
|
|
||||||
ret += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int cleanFactionInvites()
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
for (Faction faction : FactionColl.get().getAll())
|
|
||||||
{
|
|
||||||
EntityInternalMap<Invitation> invitations = faction.getInvitations();
|
|
||||||
if (invitations.isEmpty()) continue;
|
|
||||||
|
|
||||||
ret += invitations.size();
|
|
||||||
Set<String> invitationIds = new MassiveSet<>(invitations.keySet());
|
|
||||||
for (String inviteId : invitationIds)
|
|
||||||
{
|
|
||||||
invitations.detachIdFixed(inviteId);
|
|
||||||
}
|
|
||||||
|
|
||||||
faction.changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int cleanFactionRelationWhishes()
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
for (Faction faction : FactionColl.get().getAll())
|
|
||||||
{
|
|
||||||
for (Iterator<Entry<String, Rel>> iterator = faction.getRelationWishes().entrySet().iterator(); iterator.hasNext();)
|
|
||||||
{
|
|
||||||
Entry<String, Rel> entry = iterator.next();
|
|
||||||
String factionId = entry.getKey();
|
|
||||||
if (FactionColl.get().containsId(factionId)) continue;
|
|
||||||
|
|
||||||
iterator.remove();
|
|
||||||
ret += 1;
|
|
||||||
faction.changed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int cleanBoardHost()
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
for (Board board : BoardColl.get().getAll())
|
|
||||||
{
|
|
||||||
for (Entry<PS, TerritoryAccess> entry : board.getMap().entrySet())
|
|
||||||
{
|
|
||||||
PS ps = entry.getKey();
|
|
||||||
TerritoryAccess territoryAccess = entry.getValue();
|
|
||||||
String factionId = territoryAccess.getHostFactionId();
|
|
||||||
|
|
||||||
if (FactionColl.get().containsId(factionId)) continue;
|
|
||||||
|
|
||||||
board.removeAt(ps);
|
|
||||||
ret += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int cleanBoardGrant()
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
for (Board board : BoardColl.get().getAll())
|
|
||||||
{
|
|
||||||
for (Entry<PS, TerritoryAccess> entry : board.getMap().entrySet())
|
|
||||||
{
|
|
||||||
PS ps = entry.getKey();
|
|
||||||
TerritoryAccess territoryAccess = entry.getValue();
|
|
||||||
boolean changed = false;
|
|
||||||
|
|
||||||
for (String grantedIds : territoryAccess.getGrantedIds())
|
|
||||||
{
|
|
||||||
if (MPerm.idToMPermableOptional(grantedIds).isPresent()) continue;
|
|
||||||
|
|
||||||
territoryAccess = territoryAccess.withGrantedId(grantedIds, false);
|
|
||||||
ret += 1;
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changed)
|
|
||||||
{
|
|
||||||
board.setTerritoryAccessAt(ps, territoryAccess);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.cmd.req.ReqHasntFaction;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFactionNameStrict;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.FactionColl;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsCreate;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsMembershipChange;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.mson.Mson;
|
|
||||||
import com.massivecraft.massivecore.store.MStore;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CmdFactionsCreate extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsCreate()
|
|
||||||
{
|
|
||||||
// Aliases
|
|
||||||
this.addAliases("new");
|
|
||||||
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeFactionNameStrict.get(), "name").setDesc("the name of your new faction");
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(ReqHasntFaction.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Args
|
|
||||||
String newName = this.readArg();
|
|
||||||
|
|
||||||
// Pre-Generate Id
|
|
||||||
String factionId = MStore.createId();
|
|
||||||
|
|
||||||
// Event
|
|
||||||
EventFactionsCreate createEvent = new EventFactionsCreate(sender, factionId, newName);
|
|
||||||
createEvent.run();
|
|
||||||
if (createEvent.isCancelled()) return;
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
Faction faction = FactionColl.get().create(factionId);
|
|
||||||
faction.setName(newName);
|
|
||||||
|
|
||||||
msender.setRank(faction.getLeaderRank());
|
|
||||||
msender.setFaction(faction);
|
|
||||||
|
|
||||||
EventFactionsMembershipChange joinEvent = new EventFactionsMembershipChange(sender, msender, faction, MembershipChangeReason.CREATE);
|
|
||||||
joinEvent.run();
|
|
||||||
// NOTE: join event cannot be cancelled or you'll have an empty faction
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
msg("<i>You created the faction %s", faction.getName(msender));
|
|
||||||
message(Mson.mson(mson("You should now: ").color(ChatColor.YELLOW), CmdFactions.get().cmdFactionsDescription.getTemplate()));
|
|
||||||
|
|
||||||
// Log
|
|
||||||
if (MConf.get().logFactionCreate)
|
|
||||||
{
|
|
||||||
Factions.get().log(msender.getName() + " created a new faction: " + newName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.req.ReqHasFaction;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsDescriptionChange;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeString;
|
|
||||||
import com.massivecraft.massivecore.mixin.MixinDisplayName;
|
|
||||||
|
|
||||||
public class CmdFactionsDescription extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsDescription()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeString.get(), "desc", true).setDesc("the new faction desciption");
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(ReqHasFaction.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Args
|
|
||||||
String newDescription = this.readArg();
|
|
||||||
|
|
||||||
// MPerm
|
|
||||||
if ( ! MPerm.getPermDesc().has(msender, msenderFaction, true)) return;
|
|
||||||
|
|
||||||
// Event
|
|
||||||
EventFactionsDescriptionChange event = new EventFactionsDescriptionChange(sender, msenderFaction, newDescription);
|
|
||||||
event.run();
|
|
||||||
if (event.isCancelled()) return;
|
|
||||||
newDescription = event.getNewDescription();
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
msenderFaction.setDescription(newDescription);
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
for (MPlayer follower : msenderFaction.getMPlayers())
|
|
||||||
{
|
|
||||||
follower.msg("<i>%s <i>set your faction description to:\n%s", MixinDisplayName.get().getDisplayName(sender, follower), msenderFaction.getDescriptionDesc());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.FactionColl;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.factions.entity.MFlag;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsDisband;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsMembershipChange;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeStringConfirmation;
|
|
||||||
import com.massivecraft.massivecore.util.ConfirmationUtil;
|
|
||||||
import com.massivecraft.massivecore.util.IdUtil;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
public class CmdFactionsDisband extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsDisband()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeFaction.get(), "faction");
|
|
||||||
this.addParameter(TypeStringConfirmation.get(), "confirmation", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Args
|
|
||||||
Faction faction = this.readArg();
|
|
||||||
String confirmationString = this.readArg(null);
|
|
||||||
|
|
||||||
if (MConf.get().requireConfirmationForFactionDisbanding) ConfirmationUtil.tryConfirm(this);
|
|
||||||
|
|
||||||
// MPerm
|
|
||||||
if ( ! MPerm.getPermDisband().has(msender, faction, true)) return;
|
|
||||||
|
|
||||||
// Verify
|
|
||||||
if (faction.getFlag(MFlag.getFlagPermanent()))
|
|
||||||
{
|
|
||||||
throw new MassiveException().addMsg("<i>This faction is designated as permanent, so you cannot disband it.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Event
|
|
||||||
EventFactionsDisband event = new EventFactionsDisband(me, faction);
|
|
||||||
event.run();
|
|
||||||
if (event.isCancelled()) return;
|
|
||||||
|
|
||||||
// Merged Apply and Inform
|
|
||||||
|
|
||||||
// Run event for each player in the faction
|
|
||||||
for (MPlayer mplayer : faction.getMPlayers())
|
|
||||||
{
|
|
||||||
EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, mplayer, FactionColl.get().getNone(), MembershipChangeReason.DISBAND);
|
|
||||||
membershipChangeEvent.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
for (MPlayer mplayer : faction.getMPlayersWhereOnline(true))
|
|
||||||
{
|
|
||||||
mplayer.msg("<h>%s<i> disbanded your faction.", msender.describeTo(mplayer));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msenderFaction != faction)
|
|
||||||
{
|
|
||||||
msender.msg("<i>You disbanded <h>%s<i>." , faction.describeTo(msender));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Log
|
|
||||||
if (MConf.get().logFactionDisband)
|
|
||||||
{
|
|
||||||
Factions.get().log(Txt.parse("<i>The faction <h>%s <i>(<h>%s<i>) was disbanded by <h>%s<i>.", faction.getName(), faction.getId(), msender.getDisplayName(IdUtil.getConsole())));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
faction.detach();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CmdFactionsDocumentation extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsDocumentation()
|
|
||||||
{
|
|
||||||
String web = Factions.get().getDescription().getWebsite();
|
|
||||||
this.setHelp(mson("More help can be found at ", mson(web).link(web).color(ChatColor.AQUA)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsDocumentationPower cmdFactionsDocumentationPower = new CmdFactionsDocumentationPower();
|
|
||||||
public CmdFactionsDocumentationRanks cmdFactionsDocumentationRanks = new CmdFactionsDocumentationRanks();
|
|
||||||
public CmdFactionsDocumentationWarps cmdFactionsDocumentationWarps = new CmdFactionsDocumentationWarps();
|
|
||||||
public CmdFactionsDocumentationFlags cmdFactionsDocumentationFlags = new CmdFactionsDocumentationFlags();
|
|
||||||
public CmdFactionsDocumentationPerms cmdFactionsDocumentationPerms = new CmdFactionsDocumentationPerms();
|
|
||||||
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.entity.MFlag;
|
|
||||||
import com.massivecraft.factions.entity.MFlagColl;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class CmdFactionsDocumentationFlags extends FactionsCommandDocumentation
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsDocumentationFlags()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
msgDoc("Flags are a way to give certain factions certain attributes " +
|
|
||||||
" such as disabling pvp or enabling friendly fire.");
|
|
||||||
msgDoc("To see all the flags type:");
|
|
||||||
message(CmdFactions.get().cmdFactionsFlag.cmdFactionsFlagList.getTemplate(false, true, sender));
|
|
||||||
|
|
||||||
List<String> flags = MFlagColl.get().getAll(MFlag::isEditable).stream().map(flag -> Txt.parse("<h>%s", flag.getName())).collect(Collectors.toList());
|
|
||||||
String str = Txt.implodeCommaAndDot(flags, Txt.parse("<i>"));
|
|
||||||
msgDoc("The flags you can edit for your faction are: %s", str);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
|
|
||||||
public class CmdFactionsDocumentationPerms extends FactionsCommandDocumentation
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsDocumentationPerms()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
msgDoc("Permissions decide who can do what in your faction. " +
|
|
||||||
"Permissions can be given to a rank, a player, a relation, " +
|
|
||||||
"everyone in another faction or everyone with a specific rank in another faction.");
|
|
||||||
msgDoc("Because perms can be given to all of these groups individually, it allows for extreme degrees of fine tuning.");
|
|
||||||
|
|
||||||
msgDoc("To list all permissions type:");
|
|
||||||
message(CmdFactions.get().cmdFactionsPerm.cmdFactionsPermList.getTemplate(false, true, sender));
|
|
||||||
|
|
||||||
msgDoc("To see who has a specific perm type:");
|
|
||||||
message(CmdFactions.get().cmdFactionsPerm.cmdFactionsPermShow.getTemplate(false, true, sender));
|
|
||||||
|
|
||||||
msgDoc("Per default permissions are only granted to ranks within your faction " +
|
|
||||||
"and a few perms are given to allies, but if you have changed it that will be displayed by the command above.");
|
|
||||||
msgDoc("When you create a new rank, you will have to set up their perms from scratch.");
|
|
||||||
|
|
||||||
msgDoc("If you want to know what permissions are specifically given to someone do:");
|
|
||||||
message(CmdFactions.get().cmdFactionsPerm.cmdFactionsPermView.getTemplate(false, true, sender));
|
|
||||||
|
|
||||||
msgDoc("To set perms do: ");
|
|
||||||
message(CmdFactions.get().cmdFactionsPerm.cmdFactionsPermSet.getTemplate(false, true, sender));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
|
|
||||||
public class CmdFactionsDocumentationPower extends FactionsCommandDocumentation
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsDocumentationPower()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
msgDoc("All players have an amount of power ranging from <h>%.2f <i>to <h>%.2f<i>.", MConf.get().powerMin, MConf.get().powerMax);
|
|
||||||
msgDoc("The power of a faction is equal to the combined power of all it's members.");
|
|
||||||
msgDoc("Your power is <h>%.2f<i>", msender.getPower());
|
|
||||||
msgDoc("Your faction's power is <h>%.2f<i>", msenderFaction.getPower());
|
|
||||||
msgDoc("The amount of chunks a faction can claim is the amount power it has.");
|
|
||||||
msgDoc("For every hour you are online you gain <h>%.2f <i>power.", MConf.get().powerPerHour);
|
|
||||||
msgDoc("Every time you die you power is decreased by <h>%.2f <i>.", MConf.get().powerPerDeath*-1);
|
|
||||||
if (!MConf.get().canLeaveWithNegativePower && MConf.get().powerMin < 0)
|
|
||||||
{
|
|
||||||
msgDoc("You can't leave a faction if your power is negative.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.entity.Rank;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.mson.Mson;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class CmdFactionsDocumentationRanks extends FactionsCommandDocumentation
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsDocumentationRanks()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
msgDoc("Ranks divide the faction into groups.");
|
|
||||||
|
|
||||||
List<Rank> ranks = msenderFaction.getRanks().getAll(Comparator.comparingInt(Rank::getPriority).reversed());
|
|
||||||
List<String> rankDesc = ranks.stream().map(r -> r.getDisplayName(msender)).collect(Collectors.toList());
|
|
||||||
msgDoc("Your faction has: <reset>%s", Txt.implodeCommaAndDot(rankDesc, Txt.parse("<i>")));
|
|
||||||
|
|
||||||
msgDoc("Ranks can have a prefix that will be prepended before any player name. Prefixes can be coloured.");
|
|
||||||
msgDoc("All ranks have a priority showed in parentheses after the name.");
|
|
||||||
|
|
||||||
Mson msonLeader = mson("The rank with the highest priority is deemed the “leader rank”" +
|
|
||||||
"(can be renamed) and only one person can have that rank")
|
|
||||||
.tooltip("For yor faction the leader rank is" + rankDesc.get(0))
|
|
||||||
.color(ChatColor.YELLOW);
|
|
||||||
messageDoc(msonLeader);
|
|
||||||
msgDoc("Whenever a new person joins the faction they will be assigned the rank with the lowest priority.");
|
|
||||||
msgDoc("Priorities are important because they determine who can do what." +
|
|
||||||
"For example: you can’t kick someone with the same or higher rank than yourself." +
|
|
||||||
"So if you have both Officers, and Co-leaders, do not fear officers kicking co-leaders or the co-leaders kicking each other." +
|
|
||||||
"They can’t. The same goes for changing ranks, titles and other similar things.");
|
|
||||||
|
|
||||||
msgDoc("To show, set or edit ranks do:");
|
|
||||||
message(CmdFactions.get().cmdFactionsRank.getTemplate(false, true, sender));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.req.ReqTaxEnabled;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.money.Money;
|
|
||||||
import com.massivecraft.massivecore.util.TimeDiffUtil;
|
|
||||||
import com.massivecraft.massivecore.util.TimeUnit;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
|
|
||||||
public class CmdFactionsDocumentationTax extends FactionsCommandDocumentation
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsDocumentationTax()
|
|
||||||
{
|
|
||||||
this.addRequirements(ReqTaxEnabled.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
LinkedHashMap<TimeUnit, Long> timeUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(MConf.get().taxTaskPeriodMillis, TimeUnit.getAll()), 3);
|
|
||||||
String periodString = TimeDiffUtil.formatedVerboose(timeUnitcounts);
|
|
||||||
|
|
||||||
msgDoc("<key>Taxation Period: <i>every %s<i>.", periodString);
|
|
||||||
|
|
||||||
long nextTaxationTime = MConf.get().taxTaskPeriodMillis + MConf.get().taxTaskPeriodMillis;
|
|
||||||
|
|
||||||
msgDoc("<key>Next Taxation: %s", Txt.getTimeDeltaDescriptionRelNow(nextTaxationTime));
|
|
||||||
|
|
||||||
String minTax = Money.format(MConf.get().taxPlayerMinimum);
|
|
||||||
String maxTax = Money.format(MConf.get().taxPlayerMaximum);
|
|
||||||
msgDoc("<i>Taxes for players can be set between <reset>%s <i>and <reset>%s<i>.", minTax, maxTax);
|
|
||||||
|
|
||||||
double tax = msenderFaction.getTaxForPlayer(msender);
|
|
||||||
if (tax > 0)
|
|
||||||
{
|
|
||||||
msgDoc("<i>You pay <reset>%s <i>in taxes.", Money.format(tax));
|
|
||||||
}
|
|
||||||
else if (tax < 0)
|
|
||||||
{
|
|
||||||
msgDoc("<i>Instead of taxes you faction pays you <reset>%s <i>.", Money.format(tax * -1));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msgDoc("<i>You don't pay taxes.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.req.ReqFactionWarpsEnabled;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPerm.MPermable;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class CmdFactionsDocumentationWarps extends FactionsCommandDocumentation
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsDocumentationWarps()
|
|
||||||
{
|
|
||||||
this.addRequirements(ReqFactionWarpsEnabled.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
msgDoc("A faction can have warps which allows it's members to easily go to important places within the faction.");
|
|
||||||
|
|
||||||
if (MConf.get().warpsMax < 0)
|
|
||||||
{
|
|
||||||
msgDoc("There is <h>no limit <i>to how many warps a faction can have.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msgDoc("A faction can only have <h>%d <i>warps.", MConf.get().warpsMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MConf.get().warpsMustBeInClaimedTerritory)
|
|
||||||
{
|
|
||||||
msgDoc("Warps must be within claimed territory.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MConf.get().warpsTeleportToOnDeathActive)
|
|
||||||
{
|
|
||||||
msgDoc("If your faction has a warp with the name <h>%s <i>you will teleport there after death.", MConf.get().warpsTeleportToOnDeathName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!MConf.get().warpsTeleportAllowedFromEnemyTerritory)
|
|
||||||
{
|
|
||||||
msgDoc("You can't use faction warps while in enemy territory.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!MConf.get().warpsTeleportAllowedFromDifferentWorld)
|
|
||||||
{
|
|
||||||
msgDoc("You can't teleporty to a warp from another world.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MConf.get().warpsTeleportAllowedEnemyDistance > 0)
|
|
||||||
{
|
|
||||||
String str = String.format("You can't teleport home if there is an enemy within <h>%.1f <i>blocks of you", MConf.get().warpsTeleportAllowedEnemyDistance);
|
|
||||||
if (MConf.get().warpsTeleportIgnoreEnemiesIfInOwnTerritory) str += " unless you are in your own territory.";
|
|
||||||
else str += ".";
|
|
||||||
msgDoc(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msenderFaction.isNormal())
|
|
||||||
{
|
|
||||||
Set<MPermable> set = msenderFaction.getPermittedPermables(MPerm.getPermWarp());
|
|
||||||
String permables = CmdFactionsPermShow.permablesToDisplayString(set, msender);
|
|
||||||
msgDoc("In your faction warps can be used by: %s<i>.", permables);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsFactionShowAsync;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.PriorityLines;
|
|
||||||
import com.massivecraft.massivecore.mixin.MixinMessage;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
public class CmdFactionsFaction extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsFaction()
|
|
||||||
{
|
|
||||||
// Aliases
|
|
||||||
this.addAliases("f", "show", "who").setDesc("the faction to show info about");
|
|
||||||
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Args
|
|
||||||
final Faction faction = this.readArg(msenderFaction);
|
|
||||||
final CommandSender sender = this.sender;
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
|
||||||
// Event
|
|
||||||
EventFactionsFactionShowAsync event = new EventFactionsFactionShowAsync(sender, faction);
|
|
||||||
event.run();
|
|
||||||
if (event.isCancelled()) return;
|
|
||||||
|
|
||||||
// Title
|
|
||||||
MixinMessage.get().messageOne(sender, Txt.titleize("Faction " + faction.getName(msender)));
|
|
||||||
|
|
||||||
// Lines
|
|
||||||
TreeSet<PriorityLines> priorityLiness = new TreeSet<>(event.getIdPriorityLiness().values());
|
|
||||||
for (PriorityLines priorityLines : priorityLiness)
|
|
||||||
{
|
|
||||||
MixinMessage.get().messageOne(sender, priorityLines.getLines());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
public class CmdFactionsFlag extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsFlagList cmdFactionsFlagList = new CmdFactionsFlagList();
|
|
||||||
public CmdFactionsFlagShow cmdFactionsFlagShow = new CmdFactionsFlagShow();
|
|
||||||
public CmdFactionsFlagSet cmdFactionsFlagSet = new CmdFactionsFlagSet();
|
|
||||||
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.entity.MFlag;
|
|
||||||
import com.massivecraft.factions.entity.MFlagColl;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.Parameter;
|
|
||||||
import com.massivecraft.massivecore.pager.Pager;
|
|
||||||
import com.massivecraft.massivecore.pager.Stringifier;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CmdFactionsFlagList extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsFlagList()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(Parameter.getPage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Parameter
|
|
||||||
final int page = this.readArg();
|
|
||||||
final MPlayer mplayer = msender;
|
|
||||||
|
|
||||||
// Pager create
|
|
||||||
String title = "Flag List for " + msenderFaction.describeTo(mplayer);
|
|
||||||
final Pager<MFlag> pager = new Pager<>(this, title, page, (Stringifier<MFlag>) (mflag, index) -> mflag.getStateDesc(false, false, true, true, true, false));
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
|
||||||
// Get items
|
|
||||||
List<MFlag> items = MFlagColl.get().getAll(mplayer.isOverriding() ? null : MFlag::isVisible);
|
|
||||||
|
|
||||||
// Pager items
|
|
||||||
pager.setItems(items);
|
|
||||||
|
|
||||||
// Pager message
|
|
||||||
pager.message();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMFlag;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MFlag;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsFlagChange;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes;
|
|
||||||
|
|
||||||
public class CmdFactionsFlagSet extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsFlagSet()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeMFlag.get(), "flag").setDesc("the faction flag to set a value for");
|
|
||||||
this.addParameter(TypeBooleanYes.get(), "yes/no").setDesc("should the flag be on or off?");
|
|
||||||
this.addParameter(TypeFaction.get(), "faction", "you").setDesc("the faction to set the flag for (per default your own)");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Args
|
|
||||||
MFlag flag = this.readArg();
|
|
||||||
boolean value = this.readArg();
|
|
||||||
Faction faction = this.readArg(msenderFaction);
|
|
||||||
|
|
||||||
// Do the sender have the right to change flags for this faction?
|
|
||||||
if ( ! MPerm.getPermFlags().has(msender, faction, true)) return;
|
|
||||||
|
|
||||||
// Is this flag editable?
|
|
||||||
if (!msender.isOverriding() && ! flag.isEditable())
|
|
||||||
{
|
|
||||||
throw new MassiveException().addMsg("<b>The flag <h>%s <b>is not editable.", flag.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Event
|
|
||||||
EventFactionsFlagChange event = new EventFactionsFlagChange(sender, faction, flag, value);
|
|
||||||
event.run();
|
|
||||||
if (event.isCancelled()) return;
|
|
||||||
value = event.isNewValue();
|
|
||||||
|
|
||||||
// No change
|
|
||||||
if (faction.getFlag(flag) == value)
|
|
||||||
{
|
|
||||||
throw new MassiveException().addMsg("%s <i>already has %s <i>set to %s<i>.", faction.describeTo(msender), flag.getStateDesc(value, false, true, true, false, true), flag.getStateDesc(value, true, true, false, false, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
faction.setFlag(flag, value);
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
String stateInfo = flag.getStateDesc(faction.getFlag(flag), true, false, true, true, true);
|
|
||||||
if (msender.getFaction() != faction)
|
|
||||||
{
|
|
||||||
// Send message to sender
|
|
||||||
msg("<h>%s <i>set a flag for <h>%s<i>.", msender.describeTo(msender, true), faction.describeTo(msender, true));
|
|
||||||
message(stateInfo);
|
|
||||||
}
|
|
||||||
faction.msg("<h>%s <i>set a flag for <h>%s<i>.", msender.describeTo(faction, true), faction.describeTo(faction, true));
|
|
||||||
faction.sendMessage(stateInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MFlag;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
|
||||||
import com.massivecraft.massivecore.command.Parameter;
|
|
||||||
import com.massivecraft.massivecore.pager.Pager;
|
|
||||||
import com.massivecraft.massivecore.pager.Stringifier;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CmdFactionsFlagShow extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsFlagShow()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeFaction.get(), "faction", "you").setDesc("the faction to show flags for");
|
|
||||||
this.addParameter(Parameter.getPage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
final Faction faction = this.readArg(msenderFaction);
|
|
||||||
int page = this.readArg();
|
|
||||||
|
|
||||||
// Pager create
|
|
||||||
String title = "Flags for " + faction.describeTo(msender);
|
|
||||||
Pager<MFlag> pager = new Pager<>(this, title, page, MFlag.getAll(), (Stringifier<MFlag>) (mflag, index) -> mflag.getStateDesc(faction.getFlag(mflag), true, true, true, true, true));
|
|
||||||
|
|
||||||
// Pager args
|
|
||||||
List<String> pagerArgs = new MassiveList<>(
|
|
||||||
faction.getId(),
|
|
||||||
String.valueOf(page)
|
|
||||||
);
|
|
||||||
pager.setArgs(pagerArgs);
|
|
||||||
|
|
||||||
// Pager message
|
|
||||||
pager.messageAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.engine.EngineFly;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.MassiveCommandToggle;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
|
||||||
import com.massivecraft.massivecore.engine.EngineMassiveCorePlayerUpdate;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class CmdFactionsFly extends MassiveCommandToggle
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static CmdFactionsFly i = new CmdFactionsFly();
|
|
||||||
public static CmdFactionsFly get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsFly()
|
|
||||||
{
|
|
||||||
this.addRequirements(RequirementIsPlayer.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return "faction flying";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getValue() throws MassiveException
|
|
||||||
{
|
|
||||||
return MPlayer.get(sender).isFlying();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(boolean value) throws MassiveException
|
|
||||||
{
|
|
||||||
MPlayer mplayer = MPlayer.get(sender);
|
|
||||||
Player player = me;
|
|
||||||
if (player == null) throw new MassiveException().addMsg("<b>Could not find player.");
|
|
||||||
|
|
||||||
PS ps = PS.valueOf(player);
|
|
||||||
if (value) EngineFly.canFlyInTerritoryOrThrow(mplayer, ps);
|
|
||||||
|
|
||||||
mplayer.setFlying(value);
|
|
||||||
EngineMassiveCorePlayerUpdate.update(player, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.Visibility;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CmdFactionsHome extends FactionsCommandWarp
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsHome()
|
|
||||||
{
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(RequirementIsPlayer.get());
|
|
||||||
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
|
||||||
|
|
||||||
|
|
||||||
// Visibility
|
|
||||||
this.setVisibility(Visibility.INVISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
List<String> args = MUtil.list(MConf.get().warpsHomeName, this.argAt(0));
|
|
||||||
CmdFactions.get().cmdFactionsWarp.cmdFactionsWarpGo.execute(me, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
public class CmdFactionsInvite extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsInviteList cmdFactionsInviteList = new CmdFactionsInviteList();
|
|
||||||
public CmdFactionsInviteAdd cmdFactionsInviteAdd = new CmdFactionsInviteAdd();
|
|
||||||
public CmdFactionsInviteRemove cmdFactionsInviteRemove = new CmdFactionsInviteRemove();
|
|
||||||
|
|
||||||
}
|
|
@ -1,92 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPlayer;
|
|
||||||
import com.massivecraft.factions.entity.Invitation;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsInvitedChange;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.container.TypeSet;
|
|
||||||
import com.massivecraft.massivecore.mson.Mson;
|
|
||||||
import com.massivecraft.massivecore.util.IdUtil;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public class CmdFactionsInviteAdd extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsInviteAdd()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeSet.get(TypeMPlayer.get()), "players", true).setDesc("the player to invite");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Args
|
|
||||||
Collection<MPlayer> mplayers = this.readArg();
|
|
||||||
|
|
||||||
String senderId = IdUtil.getId(sender);
|
|
||||||
long creationMillis = System.currentTimeMillis();
|
|
||||||
|
|
||||||
// MPerm
|
|
||||||
if ( ! MPerm.getPermInvite().has(msender, msenderFaction, true)) return;
|
|
||||||
|
|
||||||
for (MPlayer mplayer : mplayers)
|
|
||||||
{
|
|
||||||
// Already member?
|
|
||||||
if (mplayer.getFaction() == msenderFaction)
|
|
||||||
{
|
|
||||||
msg("%s<i> is already a member of %s<i>.", mplayer.getName(), msenderFaction.getName(msender));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Already invited?
|
|
||||||
boolean isInvited = msenderFaction.isInvited(mplayer);
|
|
||||||
|
|
||||||
if ( ! isInvited)
|
|
||||||
{
|
|
||||||
// Event
|
|
||||||
EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, mplayer, msenderFaction, isInvited);
|
|
||||||
event.run();
|
|
||||||
if (event.isCancelled()) continue;
|
|
||||||
isInvited = event.isNewInvited();
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
mplayer.msg("%s<i> invited you to %s<i>.", msender.describeTo(mplayer, true), msenderFaction.describeTo(mplayer));
|
|
||||||
msenderFaction.msg("%s<i> invited %s<i> to your faction.", msender.describeTo(msenderFaction, true), mplayer.describeTo(msenderFaction));
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
Invitation invitation = new Invitation(senderId, creationMillis);
|
|
||||||
msenderFaction.invite(mplayer.getId(), invitation);
|
|
||||||
msenderFaction.changed();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Mson
|
|
||||||
String command = CmdFactions.get().cmdFactionsInvite.cmdFactionsInviteRemove.getCommandLine(mplayer.getName());
|
|
||||||
String tooltip = Txt.parse("<i>Click to <c>%s<i>.", command);
|
|
||||||
|
|
||||||
Mson remove = Mson.mson(
|
|
||||||
mson("You might want to remove him. ").color(ChatColor.YELLOW),
|
|
||||||
mson("Click to " + command).color(ChatColor.RED).tooltip(tooltip).suggest(command)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
msg("%s <i>is already invited to %s<i>.", mplayer.getName(), msenderFaction.getName(msender));
|
|
||||||
message(remove);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Perm;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.Invitation;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
|
||||||
import com.massivecraft.massivecore.command.Parameter;
|
|
||||||
import com.massivecraft.massivecore.comparator.ComparatorSmart;
|
|
||||||
import com.massivecraft.massivecore.mixin.MixinDisplayName;
|
|
||||||
import com.massivecraft.massivecore.pager.Pager;
|
|
||||||
import com.massivecraft.massivecore.pager.Stringifier;
|
|
||||||
import com.massivecraft.massivecore.util.TimeDiffUtil;
|
|
||||||
import com.massivecraft.massivecore.util.TimeUnit;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
public class CmdFactionsInviteList extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsInviteList()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(Parameter.getPage());
|
|
||||||
this.addParameter(TypeFaction.get(), "faction", "you").setDesc("the faction to list invites for");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Args
|
|
||||||
int page = this.readArg();
|
|
||||||
|
|
||||||
Faction faction = this.readArg(msenderFaction);
|
|
||||||
|
|
||||||
if ( faction != msenderFaction && ! Perm.INVITE_LIST_OTHER.has(sender, true)) return;
|
|
||||||
|
|
||||||
// MPerm
|
|
||||||
if ( ! MPerm.getPermInvite().has(msender, msenderFaction, true)) return;
|
|
||||||
|
|
||||||
// Pager Create
|
|
||||||
final List<Entry<String, Invitation>> invitations = new MassiveList<>(faction.getInvitations().entrySet());
|
|
||||||
|
|
||||||
invitations.sort((i1, i2) -> ComparatorSmart.get().compare(i2.getValue().getCreationMillis(), i1.getValue().getCreationMillis()));
|
|
||||||
|
|
||||||
final long now = System.currentTimeMillis();
|
|
||||||
|
|
||||||
final Pager<Entry<String, Invitation>> pager = new Pager<>(this, "Invited Players List", page, invitations, (Stringifier<Entry<String, Invitation>>) (entry, index) -> {
|
|
||||||
String inviteeId = entry.getKey();
|
|
||||||
String inviterId = entry.getValue().getInviterId();
|
|
||||||
|
|
||||||
String inviteeDisplayName = MixinDisplayName.get().getDisplayName(inviteeId, sender);
|
|
||||||
String inviterDisplayName = inviterId != null ? MixinDisplayName.get().getDisplayName(inviterId, sender) : Txt.parse("<silver>unknown");
|
|
||||||
|
|
||||||
String ageDesc = "";
|
|
||||||
if (entry.getValue().getCreationMillis() != null)
|
|
||||||
{
|
|
||||||
long millis = now - entry.getValue().getCreationMillis();
|
|
||||||
LinkedHashMap<TimeUnit, Long> ageUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(millis, TimeUnit.getAllButMillis()), 2);
|
|
||||||
ageDesc = TimeDiffUtil.formatedMinimal(ageUnitcounts, "<i>");
|
|
||||||
ageDesc = " " + ageDesc + Txt.parse(" ago");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Txt.parse("%s<i> was invited by %s<reset>%s<i>.", inviteeDisplayName, inviterDisplayName, ageDesc);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Pager Message
|
|
||||||
pager.message();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,146 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPlayer;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsInvitedChange;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.container.TypeSet;
|
|
||||||
import com.massivecraft.massivecore.mson.Mson;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class CmdFactionsInviteRemove extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
public CmdFactionsInviteRemove()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeSet.get(TypeMPlayer.get()), "players/all", true).setDesc("the player to deinvite");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
Set<MPlayer> mplayers = new HashSet<>();
|
|
||||||
boolean all = false;
|
|
||||||
|
|
||||||
// Args
|
|
||||||
if ("all".equalsIgnoreCase(this.argAt(0)))
|
|
||||||
{
|
|
||||||
Set<String> ids = msenderFaction.getInvitations().keySet();
|
|
||||||
// Doesn't show up if list is empty. Test at home if it worked.
|
|
||||||
if (ids == null || ids.isEmpty())
|
|
||||||
{
|
|
||||||
throw new MassiveException().addMsg("<b>No one is invited to your faction.");
|
|
||||||
}
|
|
||||||
all = true;
|
|
||||||
|
|
||||||
for (String id : ids)
|
|
||||||
{
|
|
||||||
mplayers.add(MPlayer.get(id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mplayers = this.readArgAt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// MPerm
|
|
||||||
if ( ! MPerm.getPermInvite().has(msender, msenderFaction, true)) return;
|
|
||||||
|
|
||||||
for (MPlayer mplayer : mplayers)
|
|
||||||
{
|
|
||||||
// Already member?
|
|
||||||
if (mplayer.getFaction() == msenderFaction)
|
|
||||||
{
|
|
||||||
// Mson
|
|
||||||
String command = CmdFactions.get().cmdFactionsKick.getCommandLine(mplayer.getName());
|
|
||||||
String tooltip = Txt.parse("Click to <c>%s<i>.", command);
|
|
||||||
|
|
||||||
Mson kick = Mson.mson(
|
|
||||||
mson("You might want to kick him. ").color(ChatColor.YELLOW),
|
|
||||||
mson(ChatColor.RED.toString() + tooltip).tooltip(ChatColor.YELLOW.toString() + tooltip).suggest(command)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
msg("%s<i> is already a member of %s<i>.", mplayer.getName(), msenderFaction.getName(msender));
|
|
||||||
message(kick);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Already invited?
|
|
||||||
boolean isInvited = msenderFaction.isInvited(mplayer);
|
|
||||||
|
|
||||||
if (isInvited)
|
|
||||||
{
|
|
||||||
// Event
|
|
||||||
EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, mplayer, msenderFaction, isInvited);
|
|
||||||
event.run();
|
|
||||||
if (event.isCancelled()) continue;
|
|
||||||
isInvited = event.isNewInvited();
|
|
||||||
|
|
||||||
// Inform Player
|
|
||||||
mplayer.msg("%s<i> revoked your invitation to <h>%s<i>.", msender.describeTo(mplayer, true), msenderFaction.describeTo(mplayer));
|
|
||||||
|
|
||||||
// Inform Faction
|
|
||||||
if ( ! all)
|
|
||||||
{
|
|
||||||
msenderFaction.msg("%s<i> revoked %s's<i> invitation.", msender.describeTo(msenderFaction), mplayer.describeTo(msenderFaction));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
msenderFaction.uninvite(mplayer);
|
|
||||||
|
|
||||||
// If all, we do this at last. So we only do it once.
|
|
||||||
if (! all) msenderFaction.changed();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Mson
|
|
||||||
String command = CmdFactions.get().cmdFactionsInvite.cmdFactionsInviteAdd.getCommandLine(mplayer.getName());
|
|
||||||
String tooltip = Txt.parse("Click to <c>%s<i>.", command);
|
|
||||||
|
|
||||||
Mson invite = Mson.mson(
|
|
||||||
mson("You might want to invite him. ").color(ChatColor.YELLOW),
|
|
||||||
mson(ChatColor.GREEN.toString() + tooltip).tooltip(ChatColor.YELLOW.toString() + tooltip).suggest(command)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
msg("%s <i>is not invited to %s<i>.", mplayer.describeTo(msender, true), msenderFaction.describeTo(mplayer));
|
|
||||||
message(invite);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inform Faction if all
|
|
||||||
if (all)
|
|
||||||
{
|
|
||||||
List<String> names = new ArrayList<>();
|
|
||||||
for (MPlayer mplayer : mplayers)
|
|
||||||
{
|
|
||||||
names.add(mplayer.describeTo(msender, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
Mson factionsRevokeAll = mson(
|
|
||||||
Mson.parse("%s<i> revoked ", msender.describeTo(msenderFaction)),
|
|
||||||
Mson.parse("<i>all <h>%s <i>pending invitations", mplayers.size()).tooltip(names),
|
|
||||||
mson(" from your faction.").color(ChatColor.YELLOW)
|
|
||||||
);
|
|
||||||
|
|
||||||
msenderFaction.sendMessage(factionsRevokeAll);
|
|
||||||
msenderFaction.changed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,137 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.Perm;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPlayer;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.factions.entity.MFlag;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsMembershipChange;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.mson.Mson;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CmdFactionsJoin extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsJoin()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeFaction.get(), "faction").setDesc("the faction to join");
|
|
||||||
this.addParameter(TypeMPlayer.get(), "player", "you").setDesc("the player that should join tje faction (for admins only)");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Args
|
|
||||||
Faction faction = this.readArg();
|
|
||||||
|
|
||||||
MPlayer mplayer = this.readArg(msender);
|
|
||||||
Faction mplayerFaction = mplayer.getFaction();
|
|
||||||
|
|
||||||
boolean samePlayer = mplayer == msender;
|
|
||||||
|
|
||||||
// Validate
|
|
||||||
if (!samePlayer && ! Perm.JOIN_OTHERS.has(sender, false))
|
|
||||||
{
|
|
||||||
msg("<b>You do not have permission to move other players into a faction.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (faction == mplayerFaction)
|
|
||||||
{
|
|
||||||
String command = CmdFactions.get().cmdFactionsKick.getCommandLine(mplayer.getName());
|
|
||||||
|
|
||||||
// Mson creation
|
|
||||||
Mson alreadyMember = Mson.mson(
|
|
||||||
Mson.parse(mplayer.describeTo(msender, true)),
|
|
||||||
mson((samePlayer ? " are" : " is") + " already a member of " + faction.getName(msender) + ".").color(ChatColor.YELLOW)
|
|
||||||
);
|
|
||||||
|
|
||||||
message(alreadyMember.suggest(command).tooltip(Txt.parse("<i>Click to <c>%s<i>.", command)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MConf.get().factionMemberLimit > 0 && faction.getMPlayers().size() >= MConf.get().factionMemberLimit)
|
|
||||||
{
|
|
||||||
msg(" <b>!<white> The faction %s is at the limit of %d members, so %s cannot currently join.", faction.getName(msender), MConf.get().factionMemberLimit, mplayer.describeTo(msender, false));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mplayerFaction.isNormal())
|
|
||||||
{
|
|
||||||
String command = CmdFactions.get().cmdFactionsLeave.getCommandLine(mplayer.getName());
|
|
||||||
|
|
||||||
// Mson creation
|
|
||||||
Mson leaveFirst = Mson.mson(
|
|
||||||
Mson.parse(mplayer.describeTo(msender, true)),
|
|
||||||
mson(" must leave " + (samePlayer ? "your" : "their") + " current faction first.").color(ChatColor.RED)
|
|
||||||
);
|
|
||||||
|
|
||||||
message(leaveFirst.suggest(command).tooltip(Txt.parse("<i>Click to <c>%s<i>.", command)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!MConf.get().canLeaveWithNegativePower && mplayer.getPower() < 0)
|
|
||||||
{
|
|
||||||
msg("<b>%s cannot join a faction with a negative power level.", mplayer.describeTo(msender, true));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ! (faction.getFlag(MFlag.getFlagOpen()) || faction.isInvited(mplayer) || msender.isOverriding()))
|
|
||||||
{
|
|
||||||
msg("<i>This faction requires invitation.");
|
|
||||||
if (samePlayer)
|
|
||||||
{
|
|
||||||
faction.msg("%s<i> tried to join your faction.", mplayer.describeTo(faction, true));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Event
|
|
||||||
EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, msender, faction, MembershipChangeReason.JOIN);
|
|
||||||
membershipChangeEvent.run();
|
|
||||||
if (membershipChangeEvent.isCancelled()) return;
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
if (!samePlayer)
|
|
||||||
{
|
|
||||||
mplayer.msg("<i>%s <i>moved you into the faction %s<i>.", msender.describeTo(mplayer, true), faction.getName(mplayer));
|
|
||||||
}
|
|
||||||
faction.msg("<i>%s <i>joined <lime>your faction<i>.", mplayer.describeTo(faction, true));
|
|
||||||
msender.msg("<i>%s <i>successfully joined %s<i>.", mplayer.describeTo(msender, true), faction.getName(msender));
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
mplayer.resetFactionData();
|
|
||||||
mplayer.setFaction(faction);
|
|
||||||
mplayer.setRank(faction.getLowestRank());
|
|
||||||
|
|
||||||
faction.uninvite(mplayer);
|
|
||||||
|
|
||||||
// Derplog
|
|
||||||
if (MConf.get().logFactionJoin)
|
|
||||||
{
|
|
||||||
if (samePlayer)
|
|
||||||
{
|
|
||||||
Factions.get().log(Txt.parse("%s joined the faction %s.", mplayer.getName(), faction.getName()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Factions.get().log(Txt.parse("%s moved the player %s into the faction %s.", msender.getName(), mplayer.getName(), faction.getName()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPlayer;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.FactionColl;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsMembershipChange;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.util.IdUtil;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CmdFactionsKick extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsKick()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeMPlayer.get(), "player").setDesc("the player to kick");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Arg
|
|
||||||
MPlayer mplayer = this.readArg();
|
|
||||||
|
|
||||||
// Validate
|
|
||||||
if (msender == mplayer)
|
|
||||||
{
|
|
||||||
msg("<b>You can't kick yourself.");
|
|
||||||
message(mson(mson("You might want to: ").color(ChatColor.YELLOW), CmdFactions.get().cmdFactionsLeave.getTemplate(false)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !msender.isOverriding() && mplayer.getRank().isLeader())
|
|
||||||
{
|
|
||||||
throw new MassiveException().addMsg("<b>The leader cannot be kicked.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! msender.isOverriding() && mplayer.getFaction() == msenderFaction && mplayer.getRank().isMoreThan(msender.getRank()) )
|
|
||||||
{
|
|
||||||
throw new MassiveException().addMsg("<b>You can't kick people of higher rank than yourself.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! msender.isOverriding() && mplayer.getRank() == msender.getRank())
|
|
||||||
{
|
|
||||||
throw new MassiveException().addMsg("<b>You can't kick people of the same rank as yourself.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! msender.isOverriding() && ! MConf.get().canLeaveWithNegativePower && mplayer.getPower() < 0)
|
|
||||||
{
|
|
||||||
msg("<b>You can't kick that person until their power is positive.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// MPerm
|
|
||||||
Faction mplayerFaction = mplayer.getFaction();
|
|
||||||
if ( ! MPerm.getPermKick().has(msender, mplayerFaction, true)) return;
|
|
||||||
|
|
||||||
// Event
|
|
||||||
EventFactionsMembershipChange event = new EventFactionsMembershipChange(sender, mplayer, FactionColl.get().getNone(), MembershipChangeReason.KICK);
|
|
||||||
event.run();
|
|
||||||
if (event.isCancelled()) return;
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
mplayerFaction.msg("%s<i> kicked %s<i> from the faction! :O", msender.describeTo(mplayerFaction, true), mplayer.describeTo(mplayerFaction, true));
|
|
||||||
mplayer.msg("%s<i> kicked you from %s<i>! :O", msender.describeTo(mplayer, true), mplayerFaction.describeTo(mplayer));
|
|
||||||
if (mplayerFaction != msenderFaction)
|
|
||||||
{
|
|
||||||
msender.msg("<i>You kicked %s<i> from the faction %s<i>!", mplayer.describeTo(msender), mplayerFaction.describeTo(msender));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MConf.get().logFactionKick)
|
|
||||||
{
|
|
||||||
Factions.get().log(msender.getDisplayName(IdUtil.getConsole()) + " kicked " + mplayer.getName() + " from the faction " + mplayerFaction.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
if (mplayer.getRank().isLeader())
|
|
||||||
{
|
|
||||||
mplayerFaction.promoteNewLeader();
|
|
||||||
}
|
|
||||||
mplayerFaction.uninvite(mplayer);
|
|
||||||
mplayer.resetFactionData();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.req.ReqHasFaction;
|
|
||||||
|
|
||||||
public class CmdFactionsLeave extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsLeave()
|
|
||||||
{
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(ReqHasFaction.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform()
|
|
||||||
{
|
|
||||||
msender.leave();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.comparator.ComparatorFactionList;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.FactionColl;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.Parameter;
|
|
||||||
import com.massivecraft.massivecore.pager.Pager;
|
|
||||||
import com.massivecraft.massivecore.pager.Stringifier;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CmdFactionsList extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsList()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(Parameter.getPage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Args
|
|
||||||
int page = this.readArg();
|
|
||||||
final CommandSender sender = this.sender;
|
|
||||||
final MPlayer msender = this.msender;
|
|
||||||
|
|
||||||
// NOTE: The faction list is quite slow and mostly thread safe.
|
|
||||||
// We run it asynchronously to spare the primary server thread.
|
|
||||||
|
|
||||||
// Pager Create
|
|
||||||
final Pager<Faction> pager = new Pager<>(this, "Faction List", page, (Stringifier<Faction>) (faction, index) -> {
|
|
||||||
if (faction.isNone())
|
|
||||||
{
|
|
||||||
return Txt.parse("<i>Factionless<i> %d online", FactionColl.get().getNone().getMPlayersWhereOnlineTo(sender).size());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Txt.parse("%s<i> %d/%d online, %d/%d/%d",
|
|
||||||
faction.getName(msender),
|
|
||||||
faction.getMPlayersWhereOnlineTo(sender).size(),
|
|
||||||
faction.getMPlayers().size(),
|
|
||||||
faction.getLandCount(),
|
|
||||||
faction.getPowerRounded(),
|
|
||||||
faction.getPowerMaxRounded()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
|
||||||
// Pager Items
|
|
||||||
final List<Faction> factions = FactionColl.get().getAll(ComparatorFactionList.get(sender));
|
|
||||||
pager.setItems(factions);
|
|
||||||
|
|
||||||
// Pager Message
|
|
||||||
pager.message();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.util.AsciiMap;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes;
|
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
public class CmdFactionsMap extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsMap()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeBooleanYes.get(), "on/off", "once").setDesc("set to yes to get an auto updating map\nset to no to disable");
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(RequirementIsPlayer.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// NOTE: Map show is performed when auto == true || once
|
|
||||||
boolean argSet = this.argIsSet();
|
|
||||||
boolean showMap = true;
|
|
||||||
|
|
||||||
// Auto update
|
|
||||||
if (argSet) showMap = this.adjustAutoUpdating();
|
|
||||||
if (!showMap) return;
|
|
||||||
|
|
||||||
// Show Map
|
|
||||||
AsciiMap map = new AsciiMap(msender, PS.valueOf(me), !argSet);
|
|
||||||
message(map.render());
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean adjustAutoUpdating() throws MassiveException
|
|
||||||
{
|
|
||||||
// Get
|
|
||||||
boolean autoUpdating = this.readArg(!msender.isMapAutoUpdating());
|
|
||||||
|
|
||||||
// Set
|
|
||||||
msender.setMapAutoUpdating(autoUpdating);
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
msg("<i>Map auto update %s<i>.", Txt.parse(autoUpdating ? "<green>ENABLED" : "<red>DISABLED"));
|
|
||||||
return autoUpdating;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
|
||||||
|
|
||||||
public class CmdFactionsMoney extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsMoneyBalance cmdMoneyBalance = new CmdFactionsMoneyBalance();
|
|
||||||
public CmdFactionsMoneyDeposit cmdMoneyDeposit = new CmdFactionsMoneyDeposit();
|
|
||||||
public CmdFactionsMoneyWithdraw cmdMoneyWithdraw = new CmdFactionsMoneyWithdraw();
|
|
||||||
public CmdFactionsMoneyTransferF2f cmdMoneyTransferFf = new CmdFactionsMoneyTransferF2f();
|
|
||||||
public CmdFactionsMoneyTransferF2p cmdMoneyTransferFp = new CmdFactionsMoneyTransferF2p();
|
|
||||||
public CmdFactionsMoneyTransferP2f cmdMoneyTransferPf = new CmdFactionsMoneyTransferP2f();
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsMoney()
|
|
||||||
{
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(ReqBankCommandsEnabled.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Perm;
|
|
||||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.integration.Econ;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
|
|
||||||
public class CmdFactionsMoneyBalance extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsMoneyBalance()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeFaction.get(), "faction", "you").setDesc("the faction whose balance to check");
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(ReqBankCommandsEnabled.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
Faction faction = this.readArg(msenderFaction);
|
|
||||||
|
|
||||||
if (faction != msenderFaction && ! Perm.MONEY_BALANCE_ANY.has(sender, true)) return;
|
|
||||||
|
|
||||||
Econ.sendBalanceInfo(msender, faction);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.factions.integration.Econ;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeDouble;
|
|
||||||
import com.massivecraft.massivecore.money.Money;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CmdFactionsMoneyDeposit extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsMoneyDeposit()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeDouble.get(), "amount").setDesc("the amount of money to deposit");
|
|
||||||
this.addParameter(TypeFaction.get(), "faction", "you").setDesc("the faction to deposit money to");
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(ReqBankCommandsEnabled.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
double amount = this.readArg();
|
|
||||||
|
|
||||||
Faction faction = this.readArg(msenderFaction);
|
|
||||||
|
|
||||||
boolean success = Econ.transferMoney(msender, msender, faction, amount);
|
|
||||||
|
|
||||||
if (success && MConf.get().logMoneyTransactions)
|
|
||||||
{
|
|
||||||
Factions.get().log(ChatColor.stripColor(Txt.parse("%s deposited %s in the faction bank: %s", msender.getName(), Money.format(amount), faction.describeTo(null))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.factions.integration.Econ;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeDouble;
|
|
||||||
import com.massivecraft.massivecore.money.Money;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CmdFactionsMoneyTransferF2f extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsMoneyTransferF2f()
|
|
||||||
{
|
|
||||||
// Fields
|
|
||||||
this.setSetupEnabled(false);
|
|
||||||
|
|
||||||
// Aliases
|
|
||||||
this.addAliases("ff");
|
|
||||||
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeDouble.get(), "amount").setDesc("the amount of money to transfer");
|
|
||||||
this.addParameter(TypeFaction.get(), "faction").setDesc("the faction to transfer money from");
|
|
||||||
this.addParameter(TypeFaction.get(), "faction").setDesc("the faction to transfer money to");
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(ReqBankCommandsEnabled.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
double amount = this.readArg();
|
|
||||||
Faction from = this.readArg();
|
|
||||||
Faction to = this.readArg();
|
|
||||||
|
|
||||||
boolean success = Econ.transferMoney(msender, from, to, amount);
|
|
||||||
|
|
||||||
if (success && MConf.get().logMoneyTransactions)
|
|
||||||
{
|
|
||||||
Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the faction \"%s\"", msender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPlayer;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.integration.Econ;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeDouble;
|
|
||||||
import com.massivecraft.massivecore.money.Money;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CmdFactionsMoneyTransferF2p extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsMoneyTransferF2p()
|
|
||||||
{
|
|
||||||
// Fields
|
|
||||||
this.setSetupEnabled(false);
|
|
||||||
|
|
||||||
// Aliases
|
|
||||||
this.addAliases("fp");
|
|
||||||
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeDouble.get(), "amount").setDesc("the amount of money to transfer");
|
|
||||||
this.addParameter(TypeFaction.get(), "faction").setDesc("the faction to transfer money from");
|
|
||||||
this.addParameter(TypeMPlayer.get(), "player").setDesc("the player to transfer money to");
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(ReqBankCommandsEnabled.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
double amount = this.readArg();
|
|
||||||
Faction from = this.readArg();
|
|
||||||
MPlayer to = this.readArg();
|
|
||||||
|
|
||||||
boolean success = Econ.transferMoney(msender, from, to, amount);
|
|
||||||
|
|
||||||
if (success && MConf.get().logMoneyTransactions)
|
|
||||||
{
|
|
||||||
Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the player \"%s\"", msender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPlayer;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.integration.Econ;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeDouble;
|
|
||||||
import com.massivecraft.massivecore.money.Money;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CmdFactionsMoneyTransferP2f extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsMoneyTransferP2f()
|
|
||||||
{
|
|
||||||
// Fields
|
|
||||||
this.setSetupEnabled(false);
|
|
||||||
|
|
||||||
// Aliases
|
|
||||||
this.addAliases("pf");
|
|
||||||
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeDouble.get(), "amount").setDesc("the amount of money to transfer");
|
|
||||||
this.addParameter(TypeMPlayer.get(), "player").setDesc("the player to transfer money from");
|
|
||||||
this.addParameter(TypeFaction.get(), "faction").setDesc("the faction to transfer money to");
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(ReqBankCommandsEnabled.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
double amount = this.readArg();
|
|
||||||
MPlayer from = this.readArg();
|
|
||||||
Faction to = this.readArg();
|
|
||||||
|
|
||||||
boolean success = Econ.transferMoney(msender, from, to, amount);
|
|
||||||
|
|
||||||
if (success && MConf.get().logMoneyTransactions)
|
|
||||||
{
|
|
||||||
Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the player \"%s\" to the faction \"%s\"", msender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.integration.Econ;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeDouble;
|
|
||||||
import com.massivecraft.massivecore.money.Money;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CmdFactionsMoneyWithdraw extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsMoneyWithdraw()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeDouble.get(), "amount").setDesc("the amount of money to withdraw");
|
|
||||||
this.addParameter(TypeFaction.get(), "faction", "you").setDesc("the faction to transfer money to");
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(ReqBankCommandsEnabled.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
Double amount = this.readArg();
|
|
||||||
Faction from = this.readArg(msenderFaction);
|
|
||||||
|
|
||||||
MPlayer to = msender;
|
|
||||||
|
|
||||||
boolean success = Econ.transferMoney(msender, from, to, amount);
|
|
||||||
|
|
||||||
if (success && MConf.get().logMoneyTransactions)
|
|
||||||
{
|
|
||||||
Factions.get().log(ChatColor.stripColor(Txt.parse("%s withdrew %s from the faction bank: %s", msender.getName(), Money.format(amount), from.describeTo(null))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.FactionColl;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.Visibility;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeStringConfirmation;
|
|
||||||
import com.massivecraft.massivecore.money.Money;
|
|
||||||
import com.massivecraft.massivecore.util.ConfirmationUtil;
|
|
||||||
|
|
||||||
public class CmdFactionsMoneyconvert extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsMoneyconvert()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeStringConfirmation.get(), "confirmation", "");
|
|
||||||
|
|
||||||
// Low priority
|
|
||||||
this.setPriority(-100);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Visibility getVisibility()
|
|
||||||
{
|
|
||||||
//return Visibility.INVISIBLE;
|
|
||||||
return MConf.get().useNewMoneySystem ? Visibility.INVISIBLE : Visibility.SECRET;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
if (MConf.get().useNewMoneySystem)
|
|
||||||
{
|
|
||||||
throw new MassiveException().addMsg("<b>The economy system is already converted.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Args
|
|
||||||
if (!this.argIsSet(0))
|
|
||||||
{
|
|
||||||
msg("<i>Money in Factions used to be stored within the applicable economy plugin." +
|
|
||||||
" This is problematic because not all economy plugins support that." +
|
|
||||||
" This command allows to convert to the new system where the money of a Faction" +
|
|
||||||
" is stored within the Factions plugin. Then all economy plugins can be used with Factions.");
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfirmationUtil.tryConfirm(this);
|
|
||||||
|
|
||||||
MConf.get().useNewMoneySystem = true;
|
|
||||||
|
|
||||||
for (Faction f : FactionColl.get().getAll())
|
|
||||||
{
|
|
||||||
if (!Money.exists(f))
|
|
||||||
{
|
|
||||||
msg("<h>%s <i>does not have any money.", f.getName());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
double money = Money.get(f);
|
|
||||||
f.setMoney(money);
|
|
||||||
|
|
||||||
Money.set(f, null, 0);
|
|
||||||
|
|
||||||
msg("<h>%s <i>has <h>%s <i> and has been converted.", f.getName(), Money.format(money));
|
|
||||||
}
|
|
||||||
msg("<i>Converted all factions. Hooray!");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsMotdChange;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.TypeNullable;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeString;
|
|
||||||
import com.massivecraft.massivecore.mixin.MixinDisplayName;
|
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
public class CmdFactionsMotd extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsMotd()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeNullable.get(TypeString.get()), "new", "read", true).setDesc("the new motd\nif not specified you will just see the current one");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Read
|
|
||||||
if (!this.argIsSet(0))
|
|
||||||
{
|
|
||||||
message(msenderFaction.getMotdMessages());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// MPerm
|
|
||||||
if (!MPerm.getPermMotd().has(msender, msenderFaction, true)) return;
|
|
||||||
|
|
||||||
// Args
|
|
||||||
String target = this.readArg();
|
|
||||||
|
|
||||||
if (target != null)
|
|
||||||
{
|
|
||||||
target = target.trim();
|
|
||||||
target = Txt.parse(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get Old
|
|
||||||
String old = msenderFaction.getMotd();
|
|
||||||
|
|
||||||
// NoChange
|
|
||||||
if (MUtil.equals(old, target))
|
|
||||||
{
|
|
||||||
msg("<i>The motd for %s <i>is already: <h>%s", msenderFaction.describeTo(msender, true), msenderFaction.getMotdDesc());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Event
|
|
||||||
EventFactionsMotdChange event = new EventFactionsMotdChange(sender, msenderFaction, target);
|
|
||||||
event.run();
|
|
||||||
if (event.isCancelled()) return;
|
|
||||||
target = event.getNewMotd();
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
msenderFaction.setMotd(target);
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
for (MPlayer follower : msenderFaction.getMPlayers())
|
|
||||||
{
|
|
||||||
follower.msg("<i>%s <i>changed your faction motd.", MixinDisplayName.get().getDisplayName(sender, follower));
|
|
||||||
follower.message(msenderFaction.getMotdMessages());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFactionNameLenient;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsNameChange;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
|
|
||||||
public class CmdFactionsName extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsName()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeFactionNameLenient.get(), "new name").setDesc("the new name of the faction");
|
|
||||||
this.addParameter(TypeFaction.get(), "faction", "you").setDesc("the faction whose name to change");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Args
|
|
||||||
String newName = this.readArg();
|
|
||||||
Faction faction = this.readArg(msenderFaction);
|
|
||||||
|
|
||||||
// MPerm
|
|
||||||
if ( ! MPerm.getPermName().has(msender, faction, true)) return;
|
|
||||||
|
|
||||||
// Event
|
|
||||||
EventFactionsNameChange event = new EventFactionsNameChange(sender, faction, newName);
|
|
||||||
event.run();
|
|
||||||
if (event.isCancelled()) return;
|
|
||||||
newName = event.getNewName();
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
faction.setName(newName);
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
faction.msg("%s<i> changed your faction name to %s", msender.describeTo(faction, true), faction.getName(faction));
|
|
||||||
if (msenderFaction != faction)
|
|
||||||
{
|
|
||||||
msg("<i>You changed the faction name to %s", faction.getName(msender));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes;
|
|
||||||
import com.massivecraft.massivecore.util.IdUtil;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
public class CmdFactionsOverride extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsOverride()
|
|
||||||
{
|
|
||||||
// Aliases
|
|
||||||
this.addAliases("admin");
|
|
||||||
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeBooleanYes.get(), "on/off", "flip");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Args
|
|
||||||
boolean target = this.readArg( ! msender.isOverriding());
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
msender.setOverriding(target);
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
String desc = Txt.parse(msender.isOverriding() ? "<g>ENABLED" : "<b>DISABLED");
|
|
||||||
|
|
||||||
String messageYou = Txt.parse("<i>%s %s <i>override mode.", msender.getDisplayName(msender), desc);
|
|
||||||
String messageLog = Txt.parse("<i>%s %s <i>override mode.", msender.getDisplayName(IdUtil.getConsole()), desc);
|
|
||||||
|
|
||||||
msender.message(messageYou);
|
|
||||||
Factions.get().log(messageLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
public class CmdFactionsPerm extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
CmdFactionsPermList cmdFactionsPermList = new CmdFactionsPermList();
|
|
||||||
CmdFactionsPermShow cmdFactionsPermShow = new CmdFactionsPermShow();
|
|
||||||
CmdFactionsPermView cmdFactionsPermView = new CmdFactionsPermView();
|
|
||||||
CmdFactionsPermViewall cmdFactionsPermViewall = new CmdFactionsPermViewall();
|
|
||||||
CmdFactionsPermSet cmdFactionsPermSet = new CmdFactionsPermSet();
|
|
||||||
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPermColl;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.Parameter;
|
|
||||||
import com.massivecraft.massivecore.pager.Pager;
|
|
||||||
import com.massivecraft.massivecore.pager.Stringifier;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
public class CmdFactionsPermList extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsPermList()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(Parameter.getPage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Parameter
|
|
||||||
int page = this.readArg();
|
|
||||||
|
|
||||||
// Pager create
|
|
||||||
String title = String.format("Perms for %s", msenderFaction.describeTo(msender));
|
|
||||||
final Pager<MPerm> pager = new Pager<>(this, title, page, (Stringifier<MPerm>) (mp, i) -> mp.getDesc(true, true));
|
|
||||||
final Predicate<MPerm> predicate = msender.isOverriding() ? null : MPerm::isVisible;
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
|
||||||
// Get items
|
|
||||||
List<MPerm> items = MPermColl.get().getAll(predicate);
|
|
||||||
|
|
||||||
// Pager items
|
|
||||||
pager.setItems(items);
|
|
||||||
|
|
||||||
// Pager message
|
|
||||||
pager.message();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPerm;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPermable;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.event.EventFactionsPermChange;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
public class CmdFactionsPermSet extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsPermSet()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeMPerm.get(), "perm");
|
|
||||||
this.addParameter(TypeMPermable.get(), "rank/rel/player/faction");
|
|
||||||
this.addParameter(TypeBooleanYes.get(), "yes/no");
|
|
||||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Args
|
|
||||||
MPerm perm = this.readArgAt(0);
|
|
||||||
Boolean value = this.readArgAt(2);
|
|
||||||
Faction faction = this.readArgAt(3, msenderFaction);
|
|
||||||
|
|
||||||
MPerm.MPermable permable = TypeMPermable.get(faction).read(this.argAt(1), sender);
|
|
||||||
|
|
||||||
// Do the sender have the right to change perms for this faction?
|
|
||||||
if ( ! MPerm.getPermPerms().has(msender, faction, true)) return;
|
|
||||||
|
|
||||||
// Is this perm editable?
|
|
||||||
if ( ! msender.isOverriding() && ! perm.isEditable())
|
|
||||||
{
|
|
||||||
throw new MassiveException().addMsg("<b>The perm <h>%s <b>is not editable.", perm.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (permable == faction)
|
|
||||||
{
|
|
||||||
throw new MassiveException().addMsg("<b>A faction can't have perms for itself. Perhaps try ranks.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Event
|
|
||||||
EventFactionsPermChange event = new EventFactionsPermChange(sender, faction, perm, permable, value);
|
|
||||||
event.run();
|
|
||||||
if (event.isCancelled()) return;
|
|
||||||
value = event.getNewValue();
|
|
||||||
|
|
||||||
// Apply
|
|
||||||
boolean change = faction.setPermitted(permable, perm, value);
|
|
||||||
|
|
||||||
// No change
|
|
||||||
if (!change)
|
|
||||||
{
|
|
||||||
throw new MassiveException().addMsg("%s <i>already has %s <i>set to %s <i>for %s<i>.", faction.describeTo(msender), perm.getDesc(true, false), Txt.parse(value ? "<g>YES" : "<b>NOO"), permable.getDisplayName(msender));
|
|
||||||
}
|
|
||||||
|
|
||||||
// The following is to make sure the leader always has the right to change perms if that is our goal.
|
|
||||||
if (perm == MPerm.getPermPerms() && MConf.get().perm2default.get(MPerm.ID_PERMS).contains("LEADER"))
|
|
||||||
{
|
|
||||||
faction.setPermitted( faction.getLeaderRank(), MPerm.getPermPerms(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inform sender
|
|
||||||
String yesNo = Txt.parse(value ? "<g>YES" : "<b>NOO");
|
|
||||||
msg("<i>Set perm <h>%s <i>to <h>%s <i>for <reset>%s<i> in <reset>%s<i>.", perm.getName(), yesNo, permable.getDisplayName(msender), faction.describeTo(msender));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,84 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPerm;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPerm.MPermable;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class CmdFactionsPermShow extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsPermShow()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeMPerm.get(), "perm");
|
|
||||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Arg: Faction
|
|
||||||
MPerm mperm = this.readArg();
|
|
||||||
Faction faction = this.readArg(msenderFaction);
|
|
||||||
|
|
||||||
Set<String> permittedIds = faction.getPerms().get(mperm.getId());
|
|
||||||
List<MPermable> permables = new MassiveList<>();
|
|
||||||
|
|
||||||
for (String permitted : permittedIds)
|
|
||||||
{
|
|
||||||
permables.add(MPerm.idToMPermable(permitted));
|
|
||||||
}
|
|
||||||
|
|
||||||
String removeString = Txt.parse(" of ") + faction.getDisplayName(msender);
|
|
||||||
List<String> permableList = permables.stream()
|
|
||||||
.map(permable -> permable.getDisplayName(msender))
|
|
||||||
.map(s -> s.replace(removeString, ""))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
String permableNames = Txt.implodeCommaAnd(permableList, Txt.parse("<i>"));
|
|
||||||
|
|
||||||
// Create messages
|
|
||||||
msg("<i>In <reset>%s <i>permission <reset>%s <i>is granted to <reset>%s<i>.", faction.describeTo(msender), mperm.getDesc(true, false), permableNames);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static MPerm.MPermable idToMPermable(String id)
|
|
||||||
{
|
|
||||||
return MPerm.idToMPermable(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String permablesToDisplayString(Collection<MPermable> permables, Object watcherObject)
|
|
||||||
{
|
|
||||||
MPlayer mplayer = MPlayer.get(watcherObject);
|
|
||||||
Faction faction = mplayer.getFaction();
|
|
||||||
|
|
||||||
String removeString;
|
|
||||||
if (faction.isNone()) removeString = "";
|
|
||||||
else removeString = Txt.parse(" of ") + faction.getDisplayName(mplayer);
|
|
||||||
|
|
||||||
List<String> permableList = permables.stream()
|
|
||||||
.map(permable -> permable.getDisplayName(mplayer))
|
|
||||||
.map(s -> s.replace(removeString, ""))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
return Txt.implodeCommaAnd(permableList, Txt.parse("<i>"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,103 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPermable;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.entity.Rank;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
|
||||||
import com.massivecraft.massivecore.mson.Mson;
|
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class CmdFactionsPermView extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsPermView()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeMPermable.get(), "rank/rel/player/faction");
|
|
||||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Arg: Faction
|
|
||||||
Faction faction = this.readArgAt(1, msenderFaction);
|
|
||||||
TypeMPermable permableType = TypeMPermable.get(faction);
|
|
||||||
MPerm.MPermable permable = permableType.read(this.argAt(0), sender);
|
|
||||||
|
|
||||||
if (permable == faction)
|
|
||||||
{
|
|
||||||
throw new MassiveException().addMsg("<b>A faction can't have perms for itself.");
|
|
||||||
}
|
|
||||||
|
|
||||||
List<MPerm> perms = new MassiveList<>();
|
|
||||||
|
|
||||||
for (MPerm mperm : MPerm.getAll())
|
|
||||||
{
|
|
||||||
if (faction.isPermitted(permable.getId(), mperm.getId())) perms.add(mperm);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (perms.isEmpty())
|
|
||||||
{
|
|
||||||
msg("<i>In <reset>%s <reset>%s <i>specifically has <b>no permissions<i>.", faction.describeTo(msender), permable.getDisplayName(sender));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
List<String> permNames = perms.stream().map(perm -> Txt.parse("<h>") + perm.getName()).collect(Collectors.toList());
|
|
||||||
String names = Txt.implodeCommaAnd(permNames, Txt.parse("<i>"));
|
|
||||||
|
|
||||||
// Create messages
|
|
||||||
String permissionSingularPlural = permNames.size() == 1 ? "permission" : "permissions";
|
|
||||||
msg("<i>In <reset>%s <reset>%s <i>specifically has the %s: <reset>%s<i>.", faction.describeTo(msender), permable.getDisplayName(sender), permissionSingularPlural, names);
|
|
||||||
}
|
|
||||||
if (permable instanceof MPlayer)
|
|
||||||
{
|
|
||||||
MPlayer mplayer = (MPlayer) permable;
|
|
||||||
msg("<i>They may have other permissions through their faction membership, rank or relation to <reset>%s<i>.", faction.describeTo(msender));
|
|
||||||
|
|
||||||
List<Mson> msons = new MassiveList<>();
|
|
||||||
|
|
||||||
if (mplayer.getFaction() != faction) msons.add(Mson.parse("<command>[faction]").command(this, mplayer.getFaction().getName(), faction.getName()));
|
|
||||||
msons.add(Mson.parse("<command>[rank]").command(this, mplayer.getFaction().getName() + "-" + mplayer.getRank().getName(), faction.getName()));
|
|
||||||
if (mplayer.getFaction() != faction) msons.add(Mson.parse("<command>[relation]").command(this, faction.getRelationTo(mplayer).toString(), faction.getName()));
|
|
||||||
Mson msons2 = Mson.implode(msons, Mson.SPACE);
|
|
||||||
message(mson(mson("Commands: ").color(ChatColor.YELLOW), msons2));
|
|
||||||
}
|
|
||||||
if (permable instanceof Faction)
|
|
||||||
{
|
|
||||||
Faction faction1 = (Faction) permable;
|
|
||||||
msg("<i>They may have other permissions through their relation to <reset>%s<i>.", faction.describeTo(msender));
|
|
||||||
Mson msonRelation = Mson.parse("<command>[relation]").command(this, faction.getRelationTo(faction1).toString(), faction.getName());
|
|
||||||
Mson msons = Mson.implode(MUtil.list(msonRelation), Mson.SPACE);
|
|
||||||
message(mson(mson("Commands: ").color(ChatColor.YELLOW), msons));
|
|
||||||
}
|
|
||||||
if (permable instanceof Rank && !faction.hasRank((Rank) permable))
|
|
||||||
{
|
|
||||||
Rank rank = (Rank) permable;
|
|
||||||
msg("<i>They may have other permissions thorugh their faction membership or relation to <reset>%s<i>.", faction.describeTo(msender));
|
|
||||||
Mson msonFaction = Mson.parse("<command>[faction]").command(this, rank.getFaction().getName(), faction.getName());
|
|
||||||
Mson msonRelation = Mson.parse("<command>[relation]").command(this, faction.getRelationTo(rank.getFaction()).toString(), faction.getName());
|
|
||||||
Mson msons = Mson.implode(MUtil.list(msonFaction, msonRelation), Mson.SPACE);
|
|
||||||
message(mson(mson("Commands: ").color(ChatColor.YELLOW), msons));
|
|
||||||
}
|
|
||||||
msg("<i>To view all perms held by %s <i>type:", permable.getDisplayName(sender));
|
|
||||||
message(CmdFactions.get().cmdFactionsPerm.cmdFactionsPermViewall.getTemplateWithArgs(sender, MUtil.list(permable.getName(), faction.getName())));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,104 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPermable;
|
|
||||||
import com.massivecraft.factions.entity.Faction;
|
|
||||||
import com.massivecraft.factions.entity.MPerm;
|
|
||||||
import com.massivecraft.factions.entity.MPerm.MPermable;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.factions.entity.Rank;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class CmdFactionsPermViewall extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsPermViewall()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeMPermable.get(), "rank/rel/player/faction");
|
|
||||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Arg: Faction
|
|
||||||
Faction faction = this.readArgAt(1, msenderFaction);
|
|
||||||
TypeMPermable permableType = TypeMPermable.get(faction);
|
|
||||||
MPerm.MPermable permable = permableType.read(this.argAt(0), sender);
|
|
||||||
|
|
||||||
// Self check
|
|
||||||
if (permable == faction)
|
|
||||||
{
|
|
||||||
throw new MassiveException().addMsg("<b>A faction can't have perms for itself.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create list of all applicable permables
|
|
||||||
List<MPermable> permables = new MassiveList<>();
|
|
||||||
permables.add(permable);
|
|
||||||
|
|
||||||
if (permable instanceof MPlayer)
|
|
||||||
{
|
|
||||||
MPlayer mplayer = (MPlayer) permable;
|
|
||||||
permables.add(mplayer.getFaction());
|
|
||||||
permables.add(mplayer.getRank());
|
|
||||||
permables.add(faction.getRelationTo(mplayer));
|
|
||||||
}
|
|
||||||
if (permable instanceof Faction)
|
|
||||||
{
|
|
||||||
Faction faction1 = (Faction) permable;
|
|
||||||
permables.add(faction.getRelationTo(faction1));
|
|
||||||
}
|
|
||||||
if (permable instanceof Rank && !faction.hasRank((Rank) permable))
|
|
||||||
{
|
|
||||||
Rank rank = (Rank) permable;
|
|
||||||
Faction faction1 = rank.getFaction();
|
|
||||||
permables.add(faction1);
|
|
||||||
permables.add(faction.getRelationTo(faction1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the perms they have
|
|
||||||
List<MPerm> perms = new MassiveList<>();
|
|
||||||
|
|
||||||
perm:
|
|
||||||
for (MPerm mperm : MPerm.getAll())
|
|
||||||
{
|
|
||||||
String mpermId = mperm.getId();
|
|
||||||
permable:
|
|
||||||
for (MPermable mpa : permables)
|
|
||||||
{
|
|
||||||
if (!faction.isPermitted(mpa.getId(), mperm.getId())) continue permable;
|
|
||||||
perms.add(mperm);
|
|
||||||
continue perm;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (perms.isEmpty())
|
|
||||||
{
|
|
||||||
msg("<i>In <reset>%s <reset>%s <i>has <b>no permissions<i>.", faction.describeTo(msender), permable.getDisplayName(sender));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
List<String> permNames = perms.stream().map(perm -> Txt.parse("<h>") + perm.getName()).collect(Collectors.toList());
|
|
||||||
String names = Txt.implodeCommaAnd(permNames, Txt.parse("<i>"));
|
|
||||||
|
|
||||||
// Create messages
|
|
||||||
String permissionSingularPlural = permNames.size() == 1 ? "permission" : "permissions";
|
|
||||||
msg("<i>In <reset>%s <reset>%s <i>has the %s: <reset>%s<i> either specifically granted to them or through rank, relation or faction membership.", faction.describeTo(msender), permable.getDisplayName(sender), permissionSingularPlural, names);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,109 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeMPlayer;
|
|
||||||
import com.massivecraft.factions.entity.MConf;
|
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.Progressbar;
|
|
||||||
import com.massivecraft.massivecore.event.EventMassiveCorePlayerCleanInactivityToleranceMillis;
|
|
||||||
import com.massivecraft.massivecore.util.TimeDiffUtil;
|
|
||||||
import com.massivecraft.massivecore.util.TimeUnit;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
public class CmdFactionsPlayer extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsPlayer()
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(TypeMPlayer.get(), "player", "you");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Args
|
|
||||||
MPlayer mplayer = this.readArg(msender);
|
|
||||||
|
|
||||||
// INFO: Title
|
|
||||||
message(Txt.titleize("Player " + mplayer.describeTo(msender)));
|
|
||||||
|
|
||||||
// INFO: Rank
|
|
||||||
msg("<a>Rank: <v>%s", mplayer.getRank().getDisplayName(sender));
|
|
||||||
|
|
||||||
// INFO: Power (as progress bar)
|
|
||||||
double progressbarQuota = 0;
|
|
||||||
double playerPowerMax = mplayer.getPowerMax();
|
|
||||||
if (playerPowerMax != 0)
|
|
||||||
{
|
|
||||||
progressbarQuota = mplayer.getPower() / playerPowerMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
int progressbarWidth = (int) Math.round(mplayer.getPowerMax() / mplayer.getPowerMaxUniversal() * 100);
|
|
||||||
msg("<a>Power: <v>%s", Progressbar.HEALTHBAR_CLASSIC.withQuota(progressbarQuota).withWidth(progressbarWidth).render());
|
|
||||||
|
|
||||||
// INFO: Power (as digits)
|
|
||||||
msg("<a>Power: <v>%.2f / %.2f", mplayer.getPower(), mplayer.getPowerMax());
|
|
||||||
|
|
||||||
// INFO: Power Boost
|
|
||||||
if (mplayer.hasPowerBoost())
|
|
||||||
{
|
|
||||||
double powerBoost = mplayer.getPowerBoost();
|
|
||||||
String powerBoostType = (powerBoost > 0 ? "bonus" : "penalty");
|
|
||||||
msg("<a>Power Boost: <v>%f <i>(a manually granted %s)", powerBoost, powerBoostType);
|
|
||||||
}
|
|
||||||
|
|
||||||
// INFO: Power per Hour
|
|
||||||
// If the player is not at maximum we wan't to display how much time left.
|
|
||||||
|
|
||||||
String stringTillMax = "";
|
|
||||||
double powerTillMax = mplayer.getPowerMax() - mplayer.getPower();
|
|
||||||
if (powerTillMax > 0)
|
|
||||||
{
|
|
||||||
long millisTillMax = (long) (powerTillMax * TimeUnit.MILLIS_PER_HOUR / mplayer.getPowerPerHour());
|
|
||||||
LinkedHashMap<TimeUnit, Long> unitcountsTillMax = TimeDiffUtil.unitcounts(millisTillMax, TimeUnit.getAllButMillis());
|
|
||||||
unitcountsTillMax = TimeDiffUtil.limit(unitcountsTillMax, 2);
|
|
||||||
String unitcountsTillMaxFormated = TimeDiffUtil.formatedVerboose(unitcountsTillMax, "<i>");
|
|
||||||
stringTillMax = Txt.parse(" <i>(%s <i>left till max)", unitcountsTillMaxFormated);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("<a>Power per Hour: <v>%.2f%s", mplayer.getPowerPerHour(), stringTillMax);
|
|
||||||
|
|
||||||
// INFO: Power per Death
|
|
||||||
msg("<a>Power per Death: <v>%.2f", mplayer.getPowerPerDeath());
|
|
||||||
|
|
||||||
// Display automatic kick / remove info if the system is in use
|
|
||||||
if (MConf.get().cleanInactivityToleranceMillis <= 0) return;
|
|
||||||
|
|
||||||
EventMassiveCorePlayerCleanInactivityToleranceMillis event = new EventMassiveCorePlayerCleanInactivityToleranceMillis(mplayer.getLastActivityMillis(), mplayer);
|
|
||||||
event.run();
|
|
||||||
msg("<i>Automatic removal after %s <i>of inactivity:", format(event.getToleranceMillis()));
|
|
||||||
for (Entry<String, Long> causeMillis : event.getToleranceCauseMillis().entrySet())
|
|
||||||
{
|
|
||||||
String cause = causeMillis.getKey();
|
|
||||||
long millis = causeMillis.getValue();
|
|
||||||
msg("<a>%s<a>: <v>%s", cause, format(millis));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// TIME FORMAT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public static String format(long millis)
|
|
||||||
{
|
|
||||||
LinkedHashMap<TimeUnit, Long> unitcounts = TimeDiffUtil.unitcounts(millis, TimeUnit.getAllBut(TimeUnit.MILLISECOND, TimeUnit.WEEK, TimeUnit.MONTH));
|
|
||||||
return TimeDiffUtil.formatedVerboose(unitcounts);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
public class CmdFactionsPowerboost extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsPowerboostPlayer cmdFactionsPowerBoostPlayer = new CmdFactionsPowerboostPlayer();
|
|
||||||
public CmdFactionsPowerboostFaction cmdFactionsPowerBoostFaction = new CmdFactionsPowerboostFaction();
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsPowerboost()
|
|
||||||
{
|
|
||||||
// Child
|
|
||||||
this.addChild(this.cmdFactionsPowerBoostPlayer);
|
|
||||||
this.addChild(this.cmdFactionsPowerBoostFaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.FactionsParticipator;
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
|
||||||
import com.massivecraft.massivecore.command.type.Type;
|
|
||||||
import com.massivecraft.massivecore.command.type.primitive.TypeDouble;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
|
|
||||||
public abstract class CmdFactionsPowerboostAbstract extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
protected CmdFactionsPowerboostAbstract(Type<? extends FactionsParticipator> parameterType, String parameterName)
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
this.addParameter(parameterType, parameterName);
|
|
||||||
if (!this.getClass().getSimpleName().contains("Show"))
|
|
||||||
{
|
|
||||||
this.addParameter(TypeDouble.get(), "amount");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// ABSTRACT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public abstract double calcNewPowerboost(double current, double d);
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void perform() throws MassiveException
|
|
||||||
{
|
|
||||||
// Parameters
|
|
||||||
FactionsParticipator factionsParticipator = this.readArg();
|
|
||||||
|
|
||||||
boolean updated = false;
|
|
||||||
// Try set the powerBoost
|
|
||||||
if (this.argIsSet(1))
|
|
||||||
{
|
|
||||||
// Yes updated
|
|
||||||
updated = true;
|
|
||||||
|
|
||||||
// Calc powerboost
|
|
||||||
double current = factionsParticipator.getPowerBoost();
|
|
||||||
double number = this.readArg();
|
|
||||||
double powerBoost = this.calcNewPowerboost(current, number);
|
|
||||||
|
|
||||||
// Set
|
|
||||||
factionsParticipator.setPowerBoost(powerBoost);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
this.informPowerBoost(factionsParticipator, updated);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void informPowerBoost(FactionsParticipator factionsParticipator, boolean updated)
|
|
||||||
{
|
|
||||||
// Prepare
|
|
||||||
Double powerBoost = factionsParticipator.getPowerBoost();
|
|
||||||
String participatorDescribe = factionsParticipator.describeTo(msender, true);
|
|
||||||
String powerDescription = Txt.parse(Double.compare(powerBoost, 0D) >= 0 ? "<g>bonus" : "<b>penalty");
|
|
||||||
String when = updated ? "now " : "";
|
|
||||||
String verb = factionsParticipator.equals(msender) ? "have" : "has";
|
|
||||||
|
|
||||||
// Create message
|
|
||||||
String messagePlayer = Txt.parse("<i>%s<i> %s%s a power %s<i> of <h>%.2f<i> to min and max power levels.", participatorDescribe, when, verb, powerDescription, powerBoost);
|
|
||||||
String messageLog = Txt.parse("%s %s set the power %s<i> for %s<i> to <h>%.2f<i>.", msender.getName(), verb, powerDescription, factionsParticipator.getName(), powerBoost);
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
msender.message(messagePlayer);
|
|
||||||
if (updated) Factions.get().log(messageLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
public class CmdFactionsPowerboostFaction extends FactionsCommand
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// FIELDS
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsPowerboostFactionShow cmdFactionsPowerBoostFactionShow = new CmdFactionsPowerboostFactionShow();
|
|
||||||
public CmdFactionsPowerboostFactionSet cmdFactionsPowerBoostFactionSet = new CmdFactionsPowerboostFactionSet();
|
|
||||||
public CmdFactionsPowerboostFactionAdd cmdFactionsPowerBoostFactionAdd = new CmdFactionsPowerboostFactionAdd();
|
|
||||||
public CmdFactionsPowerboostFactionTake cmdFactionsPowerBoostFactionTake = new CmdFactionsPowerboostFactionTake();
|
|
||||||
public CmdFactionsPowerboostFactionMultiply cmdFactionsPowerBoostFactionMultiply = new CmdFactionsPowerboostFactionMultiply();
|
|
||||||
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
||||||
|
|
||||||
public abstract class CmdFactionsPowerboostFactionAbstract extends CmdFactionsPowerboostAbstract
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdFactionsPowerboostFactionAbstract()
|
|
||||||
{
|
|
||||||
super(TypeFaction.get(), "faction");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
public class CmdFactionsPowerboostFactionAdd extends CmdFactionsPowerboostFactionAbstract
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double calcNewPowerboost(double current, double d)
|
|
||||||
{
|
|
||||||
return current + d;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
public class CmdFactionsPowerboostFactionMultiply extends CmdFactionsPowerboostFactionAbstract
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double calcNewPowerboost(double current, double d)
|
|
||||||
{
|
|
||||||
return current * d;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
public class CmdFactionsPowerboostFactionSet extends CmdFactionsPowerboostFactionAbstract
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double calcNewPowerboost(double current, double d)
|
|
||||||
{
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user