Compare commits
183 Commits
Author | SHA1 | Date | |
---|---|---|---|
b63b632756 | |||
0b47509c4c | |||
|
32f0337b3d | ||
6df07dc9d6 | |||
d2e0f551aa | |||
46fca2ab49 | |||
dc1543681a | |||
|
3700bfe1e9 | ||
|
5e12f1aa3a | ||
|
9ba801e8e4 | ||
|
0241244520 | ||
|
89248928c6 | ||
|
0e54edcaf4 | ||
|
c3ab3c1bd2 | ||
|
735d875aa6 | ||
|
141bf2f6fc | ||
|
cbf9246981 | ||
|
9ae143933e | ||
|
f440e48435 | ||
|
94b424b8dc | ||
|
bc62e17068 | ||
|
bc01275933 | ||
|
7d06b137fd | ||
|
2a1db8e8f7 | ||
|
2038aafb51 | ||
|
41bed534d4 | ||
|
befb61fbb7 | ||
|
7e5601462c | ||
|
d8139a16b3 | ||
|
abb00e3c81 | ||
|
7ed4aedcac | ||
|
a76644ffb9 | ||
|
2426308f32 | ||
|
59e52d749c | ||
|
b6212d77ec | ||
|
fd865ca037 | ||
|
fba645a338 | ||
|
664e173860 | ||
|
8437a05660 | ||
|
a7f794b5f8 | ||
|
9c6a107bff | ||
|
6bb73d438d | ||
|
56cfc3fddb | ||
|
bdae7bd68f | ||
|
e4f0b8e3de | ||
|
8e169ea269 | ||
|
e7dc6bd2c2 | ||
|
5d78a395eb | ||
|
a092852a1c | ||
|
a1e59edce0 | ||
|
6eca202694 | ||
|
da97ad1119 | ||
|
d0f056cce2 | ||
|
fe7bd41455 | ||
|
ecbb4c1a43 | ||
|
b4db679ae9 | ||
|
98be34e20b | ||
|
cd3b846ae1 | ||
|
46cf009b01 | ||
|
6724c4f065 | ||
|
35c38ce4b8 | ||
|
193a4acc83 | ||
|
4a66c2fe47 | ||
|
d0960911b8 | ||
|
1618da1083 | ||
|
9953573c9f | ||
|
ef2f76c4c4 | ||
|
33c201d6de | ||
|
02aac37999 | ||
|
1afc5d7988 | ||
|
a6af3c69c8 | ||
|
51135db452 | ||
|
61bea411f5 | ||
|
0d48819641 | ||
|
e370d1050d | ||
|
b134bc705b | ||
|
4c8094f3e0 | ||
|
c341f7f11e | ||
|
c2798cc569 | ||
|
f0a2eff079 | ||
|
ae442c677b | ||
|
d015f19181 | ||
|
7c214496b7 | ||
|
7171d43a2a | ||
|
1157607397 | ||
|
bcae649e0e | ||
|
abc27821f4 | ||
|
c38181e5e9 | ||
|
7961202809 | ||
|
de9c4e273a | ||
|
b936923bb1 | ||
|
1125324371 | ||
|
b67e02f8e9 | ||
|
32f52c1158 | ||
|
994bf770e5 | ||
|
a3ef16ea10 | ||
|
5e2b2bf912 | ||
|
e4e1b666d2 | ||
|
2a4777c4b1 | ||
|
88562a0010 | ||
|
b5cade3793 | ||
|
c0a6e0481c | ||
|
06788d7287 | ||
|
38a0b93cc3 | ||
|
d6ec4ad5f0 | ||
|
edb9f46167 | ||
|
f6c4031827 | ||
|
0a0cc047ae | ||
|
858343d121 | ||
|
55fce7c055 | ||
|
4dd9e3ee37 | ||
|
15f03799a9 | ||
|
1e20892392 | ||
|
1b0f2d29f8 | ||
|
9e81d6d865 | ||
|
59d8091ca8 | ||
|
4ce820d1cf | ||
|
f35c040af7 | ||
|
cf8852524e | ||
|
0644c917aa | ||
|
573177915a | ||
|
216dd14bf8 | ||
|
442e90759d | ||
|
19de471de0 | ||
|
b13d2665da | ||
|
f91c36b9c7 | ||
|
b5be4e3aca | ||
|
5118e18a0b | ||
|
d24ed94cf8 | ||
|
9a4a68e30c | ||
|
c89ee61b34 | ||
|
8d9392eb87 | ||
|
9a66681e52 | ||
|
bb9a72dbf6 | ||
|
da5df54b62 | ||
|
6b14bb0b56 | ||
|
5d09b5d05f | ||
|
1e36c9f744 | ||
|
84b66ba18b | ||
|
9219c3eaa4 | ||
|
fb89af8e6f | ||
|
e5f864ca6b | ||
|
c5a1bb4801 | ||
|
3827d2bf06 | ||
|
c955ddc552 | ||
|
96989ee653 | ||
|
1dd2356c0f | ||
|
6690a63ed0 | ||
|
47b2635154 | ||
|
2bfe2bdc75 | ||
|
56370bfab2 | ||
|
2375ce0452 | ||
|
c2a47926c6 | ||
|
a85b2b9f2d | ||
|
c0041e60e2 | ||
|
ad052f762e | ||
|
595a051a23 | ||
|
cee15b6333 | ||
|
0efccf335c | ||
|
f347c1058a | ||
|
d7728f3a79 | ||
|
7b690dc52b | ||
|
129fb6e63f | ||
|
6bf9d29bed | ||
|
3642301de0 | ||
|
808782376d | ||
|
8d36342579 | ||
|
140152c463 | ||
|
6635ec9710 | ||
|
5fad79b026 | ||
|
2c774bbfb4 | ||
|
4db8dcbc8e | ||
|
2c1e72fa2b | ||
|
8536d3db7b | ||
|
1a8a601357 | ||
|
3145777fc5 | ||
|
8bcd11fba3 | ||
|
e1edbdc05e | ||
|
27b8c24e6c | ||
|
3d80f9d0d8 | ||
|
4930475f08 | ||
|
41eab37334 | ||
|
302a9b5dd1 |
14
.gitignore
vendored
14
.gitignore
vendored
@ -90,19 +90,7 @@ local.properties
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff:
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/dictionaries
|
||||
.idea/vcs.xml
|
||||
.idea/jsLibraryMappings.xml
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/dataSources.ids
|
||||
.idea/dataSources.xml
|
||||
.idea/dataSources.local.xml
|
||||
.idea/sqlDataSources.xml
|
||||
.idea/dynamic.xml
|
||||
.idea/uiDesigner.xml
|
||||
.idea/*
|
||||
|
||||
# Gradle:
|
||||
.idea/gradle.xml
|
||||
|
@ -1,2 +1,8 @@
|
||||
<a href="https://www.massivecraft.com/factions"></a>
|
||||
<a href="https://www.massivecraft.com/plugins/factions"></a>
|
||||
<b>https://www.massivecraft.com/factions</b>
|
||||
|
||||
<b>Please read the guide below if you want to compile.</b><br>
|
||||
<b>https://www.massivecraft.com/about/departments/technology-department/tech-compile</b>
|
||||
|
||||
**License**:
|
||||
This software uses the GNU Lesser General Public License version 3.
|
||||
|
211
plugin.yml
211
plugin.yml
@ -3,19 +3,31 @@ name: ${project.name}
|
||||
version: ${project.version}
|
||||
website: ${project.url}
|
||||
description: ${project.description}
|
||||
authors: [Cayorion, Madus, Ulumulu1510, MarkehMe, Brettflan]
|
||||
authors: [Madus, Cayorion, Ulumulu1510, MarkehMe, Brettflan, AlkorZ3]
|
||||
depend: [MassiveCore]
|
||||
softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag]
|
||||
softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, LocalAreaChat, LWC, ChatManager, AuthMe, Vault, WorldEdit, WorldGuard, WorldGuardExtraFlags]
|
||||
api-version: 1.13
|
||||
permissions:
|
||||
# -------------------------------------------- #
|
||||
# THE REAL NODES
|
||||
# -------------------------------------------- #
|
||||
# -------------------------------------------- #
|
||||
# THE REAL NODES
|
||||
# -------------------------------------------- #
|
||||
factions.access: {description: manage access, with the proper fperm, default: false}
|
||||
factions.access.faction: {description: grant faction access, with the proper fperm, default: false}
|
||||
factions.access.player: {description: grant player 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.autofly: {description: enable auto_fly mode, 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}
|
||||
@ -26,13 +38,21 @@ permissions:
|
||||
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.home: {description: teleport to faction home, 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}
|
||||
@ -52,33 +72,57 @@ permissions:
|
||||
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 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: show faction powerboost, default: false}
|
||||
factions.powerboost.player: {description: show player powerboost, default: false}
|
||||
factions.powerboost.set: {description: set 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.action: {description: change 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.sethome: {description: set the faction home, 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}
|
||||
@ -86,7 +130,17 @@ permissions:
|
||||
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.unsethome: {description: unset faction home, 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}
|
||||
@ -97,11 +151,22 @@ permissions:
|
||||
factions.*:
|
||||
children:
|
||||
factions.access: true
|
||||
factions.access.faction: true
|
||||
factions.access.player: 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.autofly: true
|
||||
factions.override: true
|
||||
factions.basecommand: true
|
||||
factions.chunkname: true
|
||||
factions.claim: true
|
||||
factions.claim.one: true
|
||||
factions.claim.auto: true
|
||||
@ -113,12 +178,21 @@ permissions:
|
||||
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
|
||||
@ -141,6 +215,7 @@ permissions:
|
||||
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
|
||||
@ -149,11 +224,32 @@ permissions:
|
||||
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.set: 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
|
||||
@ -164,10 +260,16 @@ permissions:
|
||||
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
|
||||
@ -177,6 +279,17 @@ permissions:
|
||||
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
|
||||
@ -191,17 +304,26 @@ permissions:
|
||||
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.set: 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
|
||||
@ -213,10 +335,20 @@ permissions:
|
||||
default: false
|
||||
children:
|
||||
factions.access: true
|
||||
factions.access.faction: true
|
||||
factions.access.player: 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
|
||||
@ -228,12 +360,19 @@ permissions:
|
||||
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
|
||||
@ -260,14 +399,25 @@ permissions:
|
||||
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.action: 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
|
||||
@ -276,10 +426,16 @@ permissions:
|
||||
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
|
||||
@ -289,6 +445,17 @@ permissions:
|
||||
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
|
||||
|
37
pom.xml
37
pom.xml
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.massivecraft.massivesuper</groupId>
|
||||
<artifactId>MassiveSuper</artifactId>
|
||||
<version>2.13.4</version>
|
||||
<version>3.3.4</version>
|
||||
<relativePath>../MassiveSuper</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -32,6 +32,10 @@
|
||||
<artifactId>MassiveCore</artifactId>
|
||||
</dependency>
|
||||
<!-- WorldEdit -->
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
@ -39,23 +43,42 @@
|
||||
<!-- WorldGuard -->
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-legacy</artifactId>
|
||||
<artifactId>worldguard-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
</dependency>
|
||||
<!-- WorldGuardExtraFlags -->
|
||||
<dependency>
|
||||
<groupId>net.goldtreeservers</groupId>
|
||||
<artifactId>worldguardextraflags</artifactId>
|
||||
</dependency>
|
||||
<!-- Vault -->
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>Vault</artifactId>
|
||||
</dependency>
|
||||
<!-- Herochat -->
|
||||
<dependency>
|
||||
<groupId>com.dthielke.herochat</groupId>
|
||||
<artifactId>Herochat</artifactId>
|
||||
</dependency>
|
||||
<!-- LWC -->
|
||||
<dependency>
|
||||
<groupId>com.griefcraft</groupId>
|
||||
<artifactId>lwc</artifactId>
|
||||
</dependency>
|
||||
<!-- PlaceholderAPI -->
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
</dependency>
|
||||
<!-- MineverseChat/VentureChat -->
|
||||
<dependency>
|
||||
<groupId>mineverse.Aust1n46.chat</groupId>
|
||||
<artifactId>MineverseChat</artifactId>
|
||||
</dependency>
|
||||
<!-- Dynmap -->
|
||||
<dependency>
|
||||
<groupId>us.dynmap</groupId>
|
||||
<artifactId>dynmap</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Build -->
|
||||
|
@ -1,13 +1,51 @@
|
||||
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.RelAdapter;
|
||||
import com.massivecraft.factions.adapter.TerritoryAccessAdapter;
|
||||
import com.massivecraft.factions.chat.ChatActive;
|
||||
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.EnginePlayerDamage;
|
||||
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;
|
||||
@ -15,13 +53,34 @@ 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.collections.MassiveList;
|
||||
import com.massivecraft.massivecore.command.type.RegistryType;
|
||||
import com.massivecraft.massivecore.store.migrator.MigratorUtil;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
import com.massivecraft.massivecore.xlib.gson.GsonBuilder;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.List;
|
||||
@ -73,12 +132,37 @@ public class Factions extends MassivePlugin
|
||||
// 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(this.getClassesActive("chat", ChatActive.class));
|
||||
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()
|
||||
{
|
||||
@ -90,7 +174,7 @@ public class Factions extends MassivePlugin
|
||||
// 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 new MassiveList<Class<?>>(
|
||||
return MUtil.list(
|
||||
MConfColl.class,
|
||||
MFlagColl.class,
|
||||
MPermColl.class,
|
||||
@ -100,15 +184,100 @@ public class Factions extends MassivePlugin
|
||||
);
|
||||
}
|
||||
|
||||
@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()
|
||||
{
|
||||
List<Class<?>> ret = super.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,
|
||||
EnginePlayerDamage.class,
|
||||
EnginePlayerData.class,
|
||||
EnginePower.class,
|
||||
EngineSeeChunk.class,
|
||||
EngineShow.class,
|
||||
EngineTeleportHomeOnDeath.class,
|
||||
EngineTerritoryShield.class,
|
||||
EngineVisualizations.class,
|
||||
EngineEcon.class
|
||||
);
|
||||
}
|
||||
|
||||
ret.remove(EngineEcon.class);
|
||||
ret.add(EngineEcon.class);
|
||||
@Override
|
||||
public List<Class<?>> getClassesActiveMixins()
|
||||
{
|
||||
return MUtil.list(
|
||||
PowerMixin.class
|
||||
);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@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
|
||||
@ -118,7 +287,6 @@ public class Factions extends MassivePlugin
|
||||
.registerTypeAdapter(TerritoryAccess.class, TerritoryAccessAdapter.get())
|
||||
.registerTypeAdapter(Board.class, BoardAdapter.get())
|
||||
.registerTypeAdapter(Board.MAP_TYPE, BoardMapAdapter.get())
|
||||
.registerTypeAdapter(Rel.class, RelAdapter.get())
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -79,17 +79,28 @@ public class FactionsIndex
|
||||
{
|
||||
if (!MPlayerColl.get().isActive()) throw new IllegalStateException("The MPlayerColl is not yet fully activated.");
|
||||
|
||||
for (MPlayer mplayer : MPlayerColl.get().getAll())
|
||||
{
|
||||
this.update(mplayer);
|
||||
}
|
||||
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.");
|
||||
if (!mplayer.attached()) return;
|
||||
|
||||
// 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);
|
||||
@ -118,10 +129,7 @@ public class FactionsIndex
|
||||
{
|
||||
if (faction == null) throw new NullPointerException("faction");
|
||||
|
||||
for (MPlayer mplayer : this.getMPlayers(faction))
|
||||
{
|
||||
this.update(mplayer);
|
||||
}
|
||||
this.getMPlayers(faction).forEach(this::update);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -153,7 +161,7 @@ public class FactionsIndex
|
||||
@Override
|
||||
public Set<MPlayer> createValue()
|
||||
{
|
||||
return Collections.newSetFromMap(new WeakHashMap<MPlayer, Boolean>());
|
||||
return Collections.newSetFromMap(new WeakHashMap<>());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
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;
|
||||
|
||||
@ -10,88 +11,43 @@ public enum Perm implements Identified
|
||||
// ENUM
|
||||
// -------------------------------------------- //
|
||||
|
||||
ACCESS,
|
||||
ACCESS_VIEW,
|
||||
ACCESS_PLAYER,
|
||||
ACCESS_FACTION,
|
||||
OVERRIDE,
|
||||
BASECOMMAND,
|
||||
CLAIM,
|
||||
// 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,
|
||||
AUTOFLY,
|
||||
CLAIM_ONE,
|
||||
CLAIM_AUTO,
|
||||
CLAIM_FILL,
|
||||
CLAIM_SQUARE,
|
||||
CLAIM_CIRCLE,
|
||||
CLAIM_ALL,
|
||||
CREATE,
|
||||
DESCRIPTION,
|
||||
DISBAND,
|
||||
EXPANSIONS,
|
||||
FACTION,
|
||||
FLAG,
|
||||
FLAG_LIST,
|
||||
FLAG_SET,
|
||||
FLAG_SHOW,
|
||||
HOME,
|
||||
INVITE,
|
||||
INVITE_LIST,
|
||||
INVITE_LIST_OTHER,
|
||||
INVITE_ADD,
|
||||
INVITE_REMOVE,
|
||||
JOIN,
|
||||
JOIN_OTHERS,
|
||||
KICK,
|
||||
LEAVE,
|
||||
LIST,
|
||||
MAP,
|
||||
MONEY,
|
||||
MONEY_BALANCE,
|
||||
MONEY_BALANCE_ANY,
|
||||
MONEY_DEPOSIT,
|
||||
MONEY_F2F,
|
||||
MONEY_F2P,
|
||||
MONEY_P2F,
|
||||
MONEY_WITHDRAW,
|
||||
MOTD,
|
||||
OPEN,
|
||||
PERM,
|
||||
PERM_LIST,
|
||||
PERM_SET,
|
||||
PERM_SHOW,
|
||||
PLAYER,
|
||||
POWERBOOST,
|
||||
POWERBOOST_PLAYER,
|
||||
POWERBOOST_FACTION,
|
||||
POWERBOOST_SET,
|
||||
RANK,
|
||||
RANK_SHOW,
|
||||
RANK_ACTION,
|
||||
RELATION,
|
||||
RELATION_SET,
|
||||
RELATION_LIST,
|
||||
RELATION_WISHES,
|
||||
SEECHUNK,
|
||||
SEECHUNKOLD,
|
||||
SETHOME,
|
||||
SETPOWER,
|
||||
STATUS,
|
||||
NAME,
|
||||
TITLE,
|
||||
TITLE_COLOR,
|
||||
TERRITORYTITLES,
|
||||
UNCLAIM,
|
||||
UNCLAIM_ONE,
|
||||
UNCLAIM_AUTO,
|
||||
UNCLAIM_FILL,
|
||||
UNCLAIM_SQUARE,
|
||||
UNCLAIM_CIRCLE,
|
||||
UNCLAIM_ALL,
|
||||
UNSETHOME,
|
||||
UNSTUCK,
|
||||
OVERRIDE,
|
||||
FLY,
|
||||
JOIN_OTHERS,
|
||||
INVITE_LIST_OTHER,
|
||||
TITLE_COLOR,
|
||||
POWERBOOST_SET,
|
||||
MONEY_BALANCE_ANY,
|
||||
SETPOWER,
|
||||
CONFIG,
|
||||
CLEAN,
|
||||
VERSION,
|
||||
|
||||
// These are just here to tell the system that it is seechunk rather than see.chunk
|
||||
SEECHUNK,
|
||||
SEECHUNKOLD,
|
||||
|
||||
// END OF LIST
|
||||
;
|
||||
|
||||
@ -125,4 +81,9 @@ public enum Perm implements Identified
|
||||
return PermissionUtil.hasPermission(permissible, this);
|
||||
}
|
||||
|
||||
public void hasOrThrow(Permissible permissible) throws MassiveException
|
||||
{
|
||||
PermissionUtil.hasPermissionOrThrow(permissible, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
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;
|
||||
@ -9,7 +10,7 @@ import org.bukkit.ChatColor;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public enum Rel implements Colorized, Named
|
||||
public enum Rel implements Colorized, Named, MPerm.MPermable
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// ENUM
|
||||
@ -35,25 +36,10 @@ public enum Rel implements Colorized, Named
|
||||
"Ally"
|
||||
) { @Override public ChatColor getColor() { return MConf.get().colorAlly; } },
|
||||
|
||||
RECRUIT(
|
||||
"a recruit in your faction", "recruits in your faction", "", "",
|
||||
"Recruit"
|
||||
) { @Override public String getPrefix() { return MConf.get().prefixRecruit; } },
|
||||
|
||||
MEMBER(
|
||||
"a member in your faction", "members in your faction", "your faction", "your factions",
|
||||
"Member"
|
||||
) { @Override public String getPrefix() { return MConf.get().prefixMember; } },
|
||||
|
||||
OFFICER(
|
||||
"an officer in your faction", "officers in your faction", "", "",
|
||||
"Officer", "Moderator"
|
||||
) { @Override public String getPrefix() { return MConf.get().prefixOfficer; } },
|
||||
|
||||
LEADER(
|
||||
"your faction leader", "your faction leader", "", "",
|
||||
"Leader", "Admin", "Owner"
|
||||
) { @Override public String getPrefix() { return MConf.get().prefixLeader; } },
|
||||
FACTION(
|
||||
"your faction", "your faction", "your faction", "your faction",
|
||||
"Faction"
|
||||
) { @Override public ChatColor getColor() { return MConf.get().colorMember; } },
|
||||
|
||||
// END OF LIST
|
||||
;
|
||||
@ -103,6 +89,18 @@ public enum Rel implements Colorized, Named
|
||||
return MConf.get().colorMember;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(Object senderObject)
|
||||
{
|
||||
return this.getColor() + this.getName();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// UTIL
|
||||
// -------------------------------------------- //
|
||||
@ -127,17 +125,13 @@ public enum Rel implements Colorized, Named
|
||||
return this.getValue() > rel.getValue();
|
||||
}
|
||||
|
||||
public boolean isRank()
|
||||
{
|
||||
return this.isAtLeast(Rel.RECRUIT);
|
||||
}
|
||||
|
||||
// Used for friendly fire.
|
||||
public boolean isFriend()
|
||||
{
|
||||
return this.isAtLeast(TRUCE);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getPrefix()
|
||||
{
|
||||
return "";
|
||||
|
@ -1,7 +1,10 @@
|
||||
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;
|
||||
@ -23,56 +26,52 @@ public class TerritoryAccess
|
||||
public boolean isHostFactionAllowed() { return this.hostFactionAllowed; }
|
||||
|
||||
// default is empty
|
||||
private final Set<String> factionIds;
|
||||
public Set<String> getFactionIds() { return this.factionIds; }
|
||||
private final Set<String> grantedIds;
|
||||
public Set<String> getGrantedIds() { return this.grantedIds; }
|
||||
|
||||
// default is empty
|
||||
private final Set<String> playerIds;
|
||||
public Set<String> getPlayerIds() { return this.playerIds; }
|
||||
// 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, factionIds, playerIds); }
|
||||
public TerritoryAccess withHostFactionAllowed(Boolean hostFactionAllowed) { return valueOf(hostFactionId, hostFactionAllowed, factionIds, playerIds); }
|
||||
public TerritoryAccess withFactionIds(Collection<String> factionIds) { return valueOf(hostFactionId, hostFactionAllowed, factionIds, playerIds); }
|
||||
public TerritoryAccess withPlayerIds(Collection<String> playerIds) { return valueOf(hostFactionId, hostFactionAllowed, factionIds, playerIds); }
|
||||
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 withFactionId(String factionId, boolean with)
|
||||
public TerritoryAccess withGranted(MPermable mpermable, boolean with)
|
||||
{
|
||||
if (this.getHostFactionId().equals(factionId))
|
||||
{
|
||||
return valueOf(hostFactionId, with, factionIds, playerIds);
|
||||
return withGrantedId(mpermable.getId(), with);
|
||||
}
|
||||
|
||||
Set<String> factionIds = new MassiveSet<>(this.getFactionIds());
|
||||
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)
|
||||
{
|
||||
factionIds.add(factionId);
|
||||
grantedIds.add(grantedId);
|
||||
}
|
||||
else
|
||||
{
|
||||
factionIds.remove(factionId);
|
||||
grantedIds.remove(grantedId);
|
||||
}
|
||||
return valueOf(hostFactionId, hostFactionAllowed, factionIds, playerIds);
|
||||
}
|
||||
|
||||
public TerritoryAccess withPlayerId(String playerId, boolean with)
|
||||
{
|
||||
playerId = playerId.toLowerCase();
|
||||
Set<String> playerIds = new MassiveSet<>(this.getPlayerIds());
|
||||
if (with)
|
||||
{
|
||||
playerIds.add(playerId);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerIds.remove(playerId);
|
||||
}
|
||||
return valueOf(hostFactionId, hostFactionAllowed, factionIds, playerIds);
|
||||
return valueOf(hostFactionId, hostFactionAllowed, grantedIds, chunkName);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -86,114 +85,80 @@ public class TerritoryAccess
|
||||
return Faction.get(this.getHostFactionId());
|
||||
}
|
||||
|
||||
public Set<MPlayer> getGrantedMPlayers()
|
||||
public Set<MPermable> getGranteds()
|
||||
{
|
||||
// Create
|
||||
Set<MPlayer> ret = new MassiveSet<>();
|
||||
|
||||
// Fill
|
||||
for (String playerId : this.getPlayerIds())
|
||||
{
|
||||
ret.add(MPlayer.get(playerId));
|
||||
}
|
||||
|
||||
// Return
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Set<Faction> getGrantedFactions()
|
||||
{
|
||||
// Create
|
||||
Set<Faction> ret = new MassiveSet<>();
|
||||
|
||||
// Fill
|
||||
for (String factionId : this.getFactionIds())
|
||||
{
|
||||
Faction faction = Faction.get(factionId);
|
||||
if (faction == null) continue;
|
||||
ret.add(faction);
|
||||
}
|
||||
|
||||
// Return
|
||||
return ret;
|
||||
return MPerm.idsToMPermables(this.getGrantedIds());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// PRIVATE CONSTRUCTOR
|
||||
// -------------------------------------------- //
|
||||
|
||||
private TerritoryAccess(String hostFactionId, Boolean hostFactionAllowed, Collection<String> factionIds, Collection<String> playerIds)
|
||||
// Strictly for GSON only
|
||||
private TerritoryAccess()
|
||||
{
|
||||
if (hostFactionId == null) throw new IllegalArgumentException("hostFactionId was null");
|
||||
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> factionIdsInner = new MassiveSet<>();
|
||||
if (factionIds != null)
|
||||
{
|
||||
factionIdsInner.addAll(factionIds);
|
||||
if (factionIdsInner.remove(hostFactionId))
|
||||
Set<String> grantedIdsInner = new MassiveSet<>();
|
||||
grantedIdsInner.addAll(grantedIds);
|
||||
if (grantedIdsInner.remove(hostFactionId))
|
||||
{
|
||||
hostFactionAllowed = true;
|
||||
}
|
||||
}
|
||||
this.factionIds = Collections.unmodifiableSet(factionIdsInner);
|
||||
|
||||
Set<String> playerIdsInner = new MassiveSet<>();
|
||||
if (playerIds != null)
|
||||
{
|
||||
for (String playerId : playerIds)
|
||||
{
|
||||
playerIdsInner.add(playerId.toLowerCase());
|
||||
}
|
||||
}
|
||||
this.playerIds = Collections.unmodifiableSet(playerIdsInner);
|
||||
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> factionIds, Collection<String> playerIds)
|
||||
public static TerritoryAccess valueOf(String hostFactionId, Boolean hostFactionAllowed, Collection<String> grantedIds, String chunkName)
|
||||
{
|
||||
return new TerritoryAccess(hostFactionId, hostFactionAllowed, factionIds, playerIds);
|
||||
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)
|
||||
{
|
||||
return valueOf(hostFactionId, null, null, null);
|
||||
if (hostFactionId == null) throw new NullPointerException("hostFactionId");
|
||||
return valueOf(hostFactionId, null, Collections.emptySet(), null);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE METHODS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean isFactionGranted(Faction faction)
|
||||
public boolean isGranted(MPermable permable)
|
||||
{
|
||||
String factionId = faction.getId();
|
||||
|
||||
if (this.getHostFactionId().equals(factionId))
|
||||
{
|
||||
return this.isHostFactionAllowed();
|
||||
return isGranted(permable.getId());
|
||||
}
|
||||
|
||||
return this.getFactionIds().contains(factionId);
|
||||
}
|
||||
|
||||
// Note that the player can have access without being specifically granted.
|
||||
// The player could for example be a member of a granted faction.
|
||||
public boolean isMPlayerGranted(MPlayer mplayer)
|
||||
public boolean isGranted(String permableId)
|
||||
{
|
||||
String mplayerId = mplayer.getId();
|
||||
return this.getPlayerIds().contains(mplayerId);
|
||||
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.getFactionIds().isEmpty() && this.getPlayerIds().isEmpty();
|
||||
return this.isHostFactionAllowed() && this.getGrantedIds().isEmpty() && this.getChunkName() == null;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -202,20 +167,18 @@ public class TerritoryAccess
|
||||
|
||||
public AccessStatus getTerritoryAccess(MPlayer mplayer)
|
||||
{
|
||||
if (this.isMPlayerGranted(mplayer)) return AccessStatus.ELEVATED;
|
||||
if (isGranted(mplayer.getId())) return AccessStatus.ELEVATED;
|
||||
if (isGranted(mplayer.getRank().getId())) return AccessStatus.ELEVATED;
|
||||
|
||||
String factionId = mplayer.getFaction().getId();
|
||||
if (this.getFactionIds().contains(factionId)) return AccessStatus.ELEVATED;
|
||||
|
||||
if (this.getHostFactionId().equals(factionId) && !this.isHostFactionAllowed()) return AccessStatus.DECREASED;
|
||||
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;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Boolean hasTerritoryAccess(MPlayer mplayer)
|
||||
{
|
||||
return this.getTerritoryAccess(mplayer).hasAccess();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,14 @@
|
||||
package com.massivecraft.factions.adapter;
|
||||
|
||||
import com.massivecraft.factions.TerritoryAccess;
|
||||
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 com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializer;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonElement;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonParseException;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonSerializationContext;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
public class BoardAdapter implements JsonDeserializer<Board>, JsonSerializer<Board>
|
||||
{
|
||||
@ -30,7 +27,7 @@ public class BoardAdapter implements JsonDeserializer<Board>, JsonSerializer<Boa
|
||||
@Override
|
||||
public Board deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
return new Board((Map<PS, TerritoryAccess>) context.deserialize(json, Board.MAP_TYPE));
|
||||
return new Board(context.deserialize(json, Board.MAP_TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,14 +1,14 @@
|
||||
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 com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializer;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonElement;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonObject;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonParseException;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonSerializationContext;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
@ -1,39 +0,0 @@
|
||||
package com.massivecraft.factions.adapter;
|
||||
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.cmd.type.TypeRel;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializer;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonElement;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonParseException;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class RelAdapter implements JsonDeserializer<Rel>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static RelAdapter i = new RelAdapter();
|
||||
public static RelAdapter get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public Rel deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
try
|
||||
{
|
||||
return TypeRel.get().read(json.getAsString());
|
||||
}
|
||||
catch (MassiveException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +1,20 @@
|
||||
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.xlib.gson.JsonDeserializationContext;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonDeserializer;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonElement;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonObject;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonParseException;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonPrimitive;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonSerializationContext;
|
||||
import com.massivecraft.massivecore.xlib.gson.JsonSerializer;
|
||||
import com.massivecraft.massivecore.xlib.gson.reflect.TypeToken;
|
||||
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>
|
||||
@ -22,8 +25,8 @@ public class TerritoryAccessAdapter implements JsonDeserializer<TerritoryAccess>
|
||||
|
||||
public static final String HOST_FACTION_ID = "hostFactionId";
|
||||
public static final String HOST_FACTION_ALLOWED = "hostFactionAllowed";
|
||||
public static final String FACTION_IDS = "factionIds";
|
||||
public static final String PLAYER_IDS = "playerIds";
|
||||
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();
|
||||
|
||||
@ -54,29 +57,25 @@ public class TerritoryAccessAdapter implements JsonDeserializer<TerritoryAccess>
|
||||
// Prepare variables
|
||||
String hostFactionId = null;
|
||||
Boolean hostFactionAllowed = null;
|
||||
Set<String> factionIds = null;
|
||||
Set<String> playerIds = null;
|
||||
Set<String> grantedIds = Collections.emptySet();
|
||||
String chunkName = null;
|
||||
|
||||
// Read variables (test old values first)
|
||||
JsonElement element = null;
|
||||
|
||||
element = obj.get("ID");
|
||||
if (element == null) element = obj.get(HOST_FACTION_ID);
|
||||
element = obj.get(HOST_FACTION_ID);
|
||||
hostFactionId = element.getAsString();
|
||||
|
||||
element = obj.get("open");
|
||||
if (element == null) element = obj.get(HOST_FACTION_ALLOWED);
|
||||
element = obj.get(HOST_FACTION_ALLOWED);
|
||||
if (element != null) hostFactionAllowed = element.getAsBoolean();
|
||||
|
||||
element = obj.get("factions");
|
||||
if (element == null) element = obj.get(FACTION_IDS);
|
||||
if (element != null) factionIds = context.deserialize(element, SET_OF_STRING_TYPE);
|
||||
element = obj.get(GRANTED_IDS);
|
||||
if (element != null) grantedIds = context.deserialize(element, SET_OF_STRING_TYPE);
|
||||
|
||||
element = obj.get("fplayers");
|
||||
if (element == null) element = obj.get(PLAYER_IDS);
|
||||
if (element != null) playerIds = context.deserialize(element, SET_OF_STRING_TYPE);
|
||||
element = obj.get(CHUNK_NAME);
|
||||
if (element != null) chunkName = element.getAsString();
|
||||
|
||||
return TerritoryAccess.valueOf(hostFactionId, hostFactionAllowed, factionIds, playerIds);
|
||||
return TerritoryAccess.valueOf(hostFactionId, hostFactionAllowed, grantedIds, chunkName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -100,16 +99,18 @@ public class TerritoryAccessAdapter implements JsonDeserializer<TerritoryAccess>
|
||||
obj.addProperty(HOST_FACTION_ALLOWED, src.isHostFactionAllowed());
|
||||
}
|
||||
|
||||
if (!src.getFactionIds().isEmpty())
|
||||
if (!src.getGrantedIds().isEmpty())
|
||||
{
|
||||
obj.add(FACTION_IDS, context.serialize(src.getFactionIds(), SET_OF_STRING_TYPE));
|
||||
obj.add(GRANTED_IDS, context.serialize(src.getGrantedIds(), SET_OF_STRING_TYPE));
|
||||
}
|
||||
|
||||
if (!src.getPlayerIds().isEmpty())
|
||||
if (src.getChunkName() != null)
|
||||
{
|
||||
obj.add(PLAYER_IDS, context.serialize(src.getPlayerIds(), SET_OF_STRING_TYPE));
|
||||
obj.addProperty(CHUNK_NAME, src.getChunkName());
|
||||
}
|
||||
|
||||
obj.add(MigratorUtil.VERSION_FIELD_NAME, new JsonPrimitive(src.version));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ public abstract class ChatTag extends ChatActive
|
||||
// -------------------------------------------- //
|
||||
|
||||
private final static Map<String, ChatTag> idToTag = new MassiveMap<>();
|
||||
public static ChatTag getTag(String tagId) { return (ChatTag) idToTag.get(tagId); }
|
||||
public static ChatTag getTag(String tagId) { return idToTag.get(tagId); }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
|
@ -25,7 +25,7 @@ public class ChatTagRole extends ChatTag
|
||||
// Get entities
|
||||
MPlayer usender = MPlayer.get(sender);
|
||||
|
||||
return Txt.upperCaseFirst(usender.getRole().toString().toLowerCase());
|
||||
return Txt.upperCaseFirst(usender.getRank().getName().toLowerCase());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class ChatTagRoleprefix extends ChatTag
|
||||
Faction faction = usender.getFaction();
|
||||
if (faction.isNone()) return "";
|
||||
|
||||
return usender.getRole().getPrefix();
|
||||
return usender.getRank().getPrefix();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class ChatTagRoleprefixforce extends ChatTag
|
||||
// Get entities
|
||||
MPlayer usender = MPlayer.get(sender);
|
||||
|
||||
return usender.getRole().getPrefix();
|
||||
return usender.getRank().getPrefix();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.massivecore.command.MassiveCommandDeprecated;
|
||||
import com.massivecraft.massivecore.command.MassiveCommandVersion;
|
||||
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -22,55 +20,54 @@ public class CmdFactions extends FactionsCommand
|
||||
// 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 CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome();
|
||||
public CmdFactionsUnsethome cmdFactionsUnsethome = new CmdFactionsUnsethome();
|
||||
public CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite();
|
||||
public CmdFactionsKick cmdFactionsKick = new CmdFactionsKick();
|
||||
public CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle();
|
||||
public CmdFactionsRank cmdFactionsRank = new CmdFactionsRank();
|
||||
public CmdFactionsRankOld cmdFactionsRankOldLeader = new CmdFactionsRankOld("leader");
|
||||
public CmdFactionsRankOld cmdFactionsRankOldOwner = new CmdFactionsRankOld("owner");
|
||||
public CmdFactionsRankOld cmdFactionsRankOldOfficer = new CmdFactionsRankOld("officer");
|
||||
public CmdFactionsRankOld cmdFactionsRankOldModerator = new CmdFactionsRankOld("moderator");
|
||||
public CmdFactionsRankOld cmdFactionsRankOldPromote = new CmdFactionsRankOld("promote");
|
||||
public CmdFactionsRankOld cmdFactionsRankOldDemote = new CmdFactionsRankOld("demote");
|
||||
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 CmdFactionsStatus cmdFactionsStatus = new CmdFactionsStatus();
|
||||
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 CmdFactionsExpansions cmdFactionsExpansions = new CmdFactionsExpansions();
|
||||
public CmdFactionsXPlaceholder cmdFactionsTax = new CmdFactionsXPlaceholder("FactionsTax", "tax");
|
||||
public CmdFactionsXPlaceholder cmdFactionsDynmap = new CmdFactionsXPlaceholder("FactionsDynmap", "dynmap");
|
||||
public CmdFactionsOverride cmdFactionsOverride = new CmdFactionsOverride();
|
||||
public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband();
|
||||
public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost();
|
||||
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()).setAliases("v", "version").addRequirements(RequirementHasPerm.get(Perm.VERSION));
|
||||
public MassiveCommandVersion cmdFactionsVersion = new MassiveCommandVersion(Factions.get());
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
@ -78,11 +75,12 @@ public class CmdFactions extends FactionsCommand
|
||||
|
||||
public CmdFactions()
|
||||
{
|
||||
// Old rank stuff
|
||||
this.addChild(new CmdFactionsRankOld("demote"));
|
||||
this.addChild(new CmdFactionsRankOld("promote"));
|
||||
|
||||
// Deprecated Commands
|
||||
this.addChild(new MassiveCommandDeprecated(this.cmdFactionsClaim.cmdFactionsClaimAuto, "autoclaim"));
|
||||
this.addChild(new MassiveCommandDeprecated(this.cmdFactionsUnclaim.cmdFactionsUnclaimAll, "unclaimall"));
|
||||
this.addChild(new MassiveCommandDeprecated(this.cmdFactionsFlag, "open"));
|
||||
this.addChild(new MassiveCommandDeprecated(this.cmdFactionsFaction, "show", "who"));
|
||||
this.addChild(new MassiveCommandDeprecated(this.cmdFactionsRank, "leader", "owner", "officer", "moderator", "coleader"));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -9,8 +9,9 @@ public class CmdFactionsAccess extends FactionsCommand
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsAccessView cmdFactionsAccessView = new CmdFactionsAccessView();
|
||||
public CmdFactionsAccessPlayer cmdFactionsAccessPlayer = new CmdFactionsAccessPlayer();
|
||||
public CmdFactionsAccessFaction cmdFactionsAccessFaction = new CmdFactionsAccessFaction();
|
||||
public CmdFactionsAccessGrant cmdFactionsAccessGrant = new CmdFactionsAccessGrant();
|
||||
public CmdFactionsAccessDeny cmdFactionsAccessDeny = new CmdFactionsAccessDeny();
|
||||
public CmdFactionsAccessInspect cmdFactionsAccessInspect = new CmdFactionsAccessInspect();
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
|
@ -1,18 +1,16 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.RelationParticipator;
|
||||
import com.massivecraft.factions.TerritoryAccess;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
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.ps.PSFormatHumanSpace;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public abstract class CmdFactionsAccessAbstract extends FactionsCommand
|
||||
@ -40,38 +38,67 @@ public abstract class CmdFactionsAccessAbstract extends FactionsCommand
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
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();
|
||||
|
||||
this.innerPerform();
|
||||
}
|
||||
|
||||
public abstract void innerPerform() throws MassiveException;
|
||||
else
|
||||
{
|
||||
chunk = null;
|
||||
ta = null;
|
||||
hostFaction = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendAccessInfo()
|
||||
{
|
||||
Object title = "Access at " + chunk.toString(PSFormatHumanSpace.get());
|
||||
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 Players: %s", describeRelationParticipators(ta.getGrantedMPlayers(), msender));
|
||||
msg("<k>Granted Factions: %s", describeRelationParticipators(ta.getGrantedFactions(), msender));
|
||||
msg("<k>Granted to: %s", CmdFactionsPermShow.permablesToDisplayString(ta.getGranteds(), msender));
|
||||
}
|
||||
|
||||
public static String describeRelationParticipators(Collection<? extends RelationParticipator> relationParticipators, RelationParticipator observer)
|
||||
public void setAccess(Collection<PS> chunks, MPermable mpermable, boolean granted)
|
||||
{
|
||||
if (relationParticipators.size() == 0) return Txt.parse("<silver><em>none");
|
||||
List<String> descriptions = new ArrayList<>();
|
||||
for (RelationParticipator relationParticipator : relationParticipators)
|
||||
{
|
||||
descriptions.add(relationParticipator.describeTo(observer));
|
||||
chunks.forEach(chunk -> setAccess(chunk, mpermable, granted));
|
||||
}
|
||||
return Txt.implodeCommaAnd(descriptions, Txt.parse("<i>, "), Txt.parse(" <i>and "));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
26
src/com/massivecraft/factions/cmd/CmdFactionsAccessDeny.java
Normal file
26
src/com/massivecraft/factions/cmd/CmdFactionsAccessDeny.java
Normal file
@ -0,0 +1,26 @@
|
||||
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,45 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes;
|
||||
|
||||
public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsAccessFaction()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeFaction.get(), "faction");
|
||||
this.addParameter(TypeBooleanYes.get(), "yes/no", "toggle");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void innerPerform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
Faction faction = this.readArg();
|
||||
boolean newValue = this.readArg(!ta.isFactionGranted(faction));
|
||||
|
||||
// MPerm
|
||||
if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;
|
||||
|
||||
// Apply
|
||||
ta = ta.withFactionId(faction.getId(), newValue);
|
||||
BoardColl.get().setTerritoryAccessAt(chunk, ta);
|
||||
|
||||
// Inform
|
||||
this.sendAccessInfo();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
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.cmd.type.TypeMPlayer;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes;
|
||||
|
||||
public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsAccessPlayer()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeMPlayer.get(), "player");
|
||||
this.addParameter(TypeBooleanYes.get(), "yes/no", "toggle");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void innerPerform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
MPlayer mplayer = this.readArg();
|
||||
boolean newValue = this.readArg(!ta.isMPlayerGranted(mplayer));
|
||||
|
||||
// MPerm
|
||||
if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;
|
||||
|
||||
// Apply
|
||||
ta = ta.withPlayerId(mplayer.getId(), newValue);
|
||||
BoardColl.get().setTerritoryAccessAt(chunk, ta);
|
||||
|
||||
// Inform
|
||||
this.sendAccessInfo();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
68
src/com/massivecraft/factions/cmd/CmdFactionsAccessSetX.java
Normal file
68
src/com/massivecraft/factions/cmd/CmdFactionsAccessSetX.java
Normal file
@ -0,0 +1,68 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -7,7 +7,7 @@ public class CmdFactionsAccessView extends CmdFactionsAccessAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void innerPerform()
|
||||
public void perform()
|
||||
{
|
||||
this.sendAccessInfo();
|
||||
}
|
||||
|
83
src/com/massivecraft/factions/cmd/CmdFactionsChunkname.java
Normal file
83
src/com/massivecraft/factions/cmd/CmdFactionsChunkname.java
Normal file
@ -0,0 +1,83 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ 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;
|
||||
@ -144,11 +145,11 @@ public class CmdFactionsClean extends FactionsCommand
|
||||
TerritoryAccess territoryAccess = entry.getValue();
|
||||
boolean changed = false;
|
||||
|
||||
for (String factionId : territoryAccess.getFactionIds())
|
||||
for (String grantedIds : territoryAccess.getGrantedIds())
|
||||
{
|
||||
if (FactionColl.get().containsId(factionId)) continue;
|
||||
if (MPerm.idToMPermableOptional(grantedIds).isPresent()) continue;
|
||||
|
||||
territoryAccess = territoryAccess.withFactionId(factionId, false);
|
||||
territoryAccess = territoryAccess.withGrantedId(grantedIds, false);
|
||||
ret += 1;
|
||||
changed = true;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.cmd.req.ReqHasntFaction;
|
||||
import com.massivecraft.factions.cmd.type.TypeFactionNameStrict;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
@ -27,7 +26,7 @@ public class CmdFactionsCreate extends FactionsCommand
|
||||
this.addAliases("new");
|
||||
|
||||
// Parameters
|
||||
this.addParameter(TypeFactionNameStrict.get(), "name");
|
||||
this.addParameter(TypeFactionNameStrict.get(), "name").setDesc("the name of your new faction");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasntFaction.get());
|
||||
@ -55,7 +54,7 @@ public class CmdFactionsCreate extends FactionsCommand
|
||||
Faction faction = FactionColl.get().create(factionId);
|
||||
faction.setName(newName);
|
||||
|
||||
msender.setRole(Rel.LEADER);
|
||||
msender.setRank(faction.getLeaderRank());
|
||||
msender.setFaction(faction);
|
||||
|
||||
EventFactionsMembershipChange joinEvent = new EventFactionsMembershipChange(sender, msender, faction, MembershipChangeReason.CREATE);
|
||||
|
@ -17,7 +17,7 @@ public class CmdFactionsDescription extends FactionsCommand
|
||||
public CmdFactionsDescription()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeString.get(), "desc", true);
|
||||
this.addParameter(TypeString.get(), "desc", true).setDesc("the new faction desciption");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasFaction.get());
|
||||
|
@ -12,6 +12,8 @@ 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;
|
||||
|
||||
@ -24,7 +26,8 @@ public class CmdFactionsDisband extends FactionsCommand
|
||||
public CmdFactionsDisband()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
this.addParameter(TypeFaction.get(), "faction");
|
||||
this.addParameter(TypeStringConfirmation.get(), "confirmation", "");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -35,7 +38,10 @@ public class CmdFactionsDisband extends FactionsCommand
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
Faction faction = this.readArg(msenderFaction);
|
||||
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;
|
||||
@ -43,8 +49,7 @@ public class CmdFactionsDisband extends FactionsCommand
|
||||
// Verify
|
||||
if (faction.getFlag(MFlag.getFlagPermanent()))
|
||||
{
|
||||
msg("<i>This faction is designated as permanent, so you cannot disband it.");
|
||||
return;
|
||||
throw new MassiveException().addMsg("<i>This faction is designated as permanent, so you cannot disband it.");
|
||||
}
|
||||
|
||||
// Event
|
||||
|
@ -0,0 +1,28 @@
|
||||
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();
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
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.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
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,40 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.event.EventFactionsExpansions;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class CmdFactionsExpansions extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Event
|
||||
EventFactionsExpansions event = new EventFactionsExpansions(sender);
|
||||
event.run();
|
||||
|
||||
// Title
|
||||
Object title = "Factions Expansions";
|
||||
title = Txt.titleize(title);
|
||||
message(title);
|
||||
|
||||
// Lines
|
||||
for (Entry<String, Boolean> entry : event.getExpansions().entrySet())
|
||||
{
|
||||
String name = entry.getKey();
|
||||
Boolean installed = entry.getValue();
|
||||
String format = (installed ? "<g>[X] <h>%s" : "<b>[ ] <h>%s");
|
||||
msg(format, name);
|
||||
}
|
||||
|
||||
// URL Suggestion
|
||||
msg("<i>Learn all about expansions in the online documentation:");
|
||||
msg("<aqua>https://www.massivecraft.com/factions");
|
||||
}
|
||||
|
||||
}
|
@ -22,7 +22,7 @@ public class CmdFactionsFaction extends FactionsCommand
|
||||
public CmdFactionsFaction()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("f", "show", "who");
|
||||
this.addAliases("f", "show", "who").setDesc("the faction to show info about");
|
||||
|
||||
// Parameters
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
@ -39,11 +39,7 @@ public class CmdFactionsFaction extends FactionsCommand
|
||||
final Faction faction = this.readArg(msenderFaction);
|
||||
final CommandSender sender = this.sender;
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
||||
// Event
|
||||
EventFactionsFactionShowAsync event = new EventFactionsFactionShowAsync(sender, faction);
|
||||
event.run();
|
||||
@ -58,7 +54,6 @@ public class CmdFactionsFaction extends FactionsCommand
|
||||
{
|
||||
MixinMessage.get().messageOne(sender, priorityLines.getLines());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ public class CmdFactionsFlag extends FactionsCommand
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
CmdFactionsFlagList cmdFactionsFlagList = new CmdFactionsFlagList();
|
||||
CmdFactionsFlagShow cmdFactionsFlagShow = new CmdFactionsFlagShow();
|
||||
CmdFactionsFlagSet cmdFactionsFlagSet = new CmdFactionsFlagSet();
|
||||
public CmdFactionsFlagList cmdFactionsFlagList = new CmdFactionsFlagList();
|
||||
public CmdFactionsFlagShow cmdFactionsFlagShow = new CmdFactionsFlagShow();
|
||||
public CmdFactionsFlagSet cmdFactionsFlagSet = new CmdFactionsFlagSet();
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.entity.MFlag;
|
||||
import com.massivecraft.factions.entity.MFlagColl;
|
||||
@ -12,7 +8,9 @@ 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.predicate.Predicate;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CmdFactionsFlagList extends FactionsCommand
|
||||
{
|
||||
@ -39,36 +37,17 @@ public class CmdFactionsFlagList extends FactionsCommand
|
||||
|
||||
// Pager create
|
||||
String title = "Flag List for " + msenderFaction.describeTo(mplayer);
|
||||
final Pager<MFlag> pager = new Pager<>(this, title, page, new Stringifier<MFlag>()
|
||||
{
|
||||
@Override
|
||||
public String toString(MFlag mflag, int index)
|
||||
{
|
||||
return mflag.getStateDesc(false, false, true, true, true, false);
|
||||
}
|
||||
});
|
||||
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(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
||||
// Get items
|
||||
List<MFlag> items = MFlagColl.get().getAll(mplayer.isOverriding() ? null : new Predicate<MFlag>()
|
||||
{
|
||||
@Override
|
||||
public boolean apply(MFlag mflag)
|
||||
{
|
||||
return mflag.isVisible();
|
||||
}
|
||||
});
|
||||
List<MFlag> items = MFlagColl.get().getAll(mplayer.isOverriding() ? null : MFlag::isVisible);
|
||||
|
||||
// Pager items
|
||||
pager.setItems(items);
|
||||
|
||||
// Pager message
|
||||
pager.message();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,9 @@ public class CmdFactionsFlagSet extends FactionsCommand
|
||||
public CmdFactionsFlagSet()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeMFlag.get(), "flag");
|
||||
this.addParameter(TypeBooleanYes.get(), "yes/no");
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
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)");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -41,8 +41,7 @@ public class CmdFactionsFlagSet extends FactionsCommand
|
||||
// Is this flag editable?
|
||||
if (!msender.isOverriding() && ! flag.isEditable())
|
||||
{
|
||||
msg("<b>The flag <h>%s <b>is not editable.", flag.getName());
|
||||
return;
|
||||
throw new MassiveException().addMsg("<b>The flag <h>%s <b>is not editable.", flag.getName());
|
||||
}
|
||||
|
||||
// Event
|
||||
@ -54,8 +53,7 @@ public class CmdFactionsFlagSet extends FactionsCommand
|
||||
// No change
|
||||
if (faction.getFlag(flag) == value)
|
||||
{
|
||||
msg("%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));
|
||||
return;
|
||||
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
|
||||
|
@ -20,7 +20,7 @@ public class CmdFactionsFlagShow extends FactionsCommand
|
||||
public CmdFactionsFlagShow()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
this.addParameter(TypeFaction.get(), "faction", "you").setDesc("the faction to show flags for");
|
||||
this.addParameter(Parameter.getPage());
|
||||
}
|
||||
|
||||
@ -37,14 +37,7 @@ public class CmdFactionsFlagShow extends FactionsCommand
|
||||
|
||||
// Pager create
|
||||
String title = "Flags for " + faction.describeTo(msender);
|
||||
Pager<MFlag> pager = new Pager<>(this, title, page, MFlag.getAll(), new Stringifier<MFlag>()
|
||||
{
|
||||
@Override
|
||||
public String toString(MFlag mflag, int index)
|
||||
{
|
||||
return mflag.getStateDesc(faction.getFlag(mflag), true, true, true, true, true);
|
||||
}
|
||||
});
|
||||
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<>(
|
||||
|
58
src/com/massivecraft/factions/cmd/CmdFactionsFly.java
Normal file
58
src/com/massivecraft/factions/cmd/CmdFactionsFly.java
Normal file
@ -0,0 +1,58 @@
|
||||
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,28 +1,15 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
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.EventFactionsHomeTeleport;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.command.Visibility;
|
||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
|
||||
import com.massivecraft.massivecore.mixin.MixinMessage;
|
||||
import com.massivecraft.massivecore.mixin.MixinTeleport;
|
||||
import com.massivecraft.massivecore.mixin.TeleporterException;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.teleport.Destination;
|
||||
import com.massivecraft.massivecore.teleport.DestinationSimple;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CmdFactionsHome extends FactionsCommandHome
|
||||
import java.util.List;
|
||||
|
||||
public class CmdFactionsHome extends FactionsCommandWarp
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
@ -30,11 +17,15 @@ public class CmdFactionsHome extends FactionsCommandHome
|
||||
|
||||
public CmdFactionsHome()
|
||||
{
|
||||
// Requirements
|
||||
this.addRequirements(RequirementIsPlayer.get());
|
||||
|
||||
// Parameters
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(RequirementIsPlayer.get());
|
||||
|
||||
// Visibility
|
||||
this.setVisibility(Visibility.INVISIBLE);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -44,114 +35,8 @@ public class CmdFactionsHome extends FactionsCommandHome
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
if ( ! MConf.get().homesTeleportCommandEnabled)
|
||||
{
|
||||
msender.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Args
|
||||
Faction faction = this.readArg(msenderFaction);
|
||||
PS home = faction.getHome();
|
||||
String homeDesc = "home for " + faction.describeTo(msender, false);
|
||||
|
||||
// Any and MPerm
|
||||
if ( ! MPerm.getPermHome().has(msender, faction, true)) return;
|
||||
|
||||
if (home == null)
|
||||
{
|
||||
msender.msg("<b>%s <b>does not have a home.", faction.describeTo(msender, true));
|
||||
|
||||
if (MPerm.getPermSethome().has(msender, faction, false))
|
||||
{
|
||||
msender.msg("<i>You should:");
|
||||
msender.message(CmdFactions.get().cmdFactionsSethome.getTemplate());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! MConf.get().homesTeleportAllowedFromEnemyTerritory && msender.isInEnemyTerritory())
|
||||
{
|
||||
msender.msg("<b>You cannot teleport to %s <b>while in the territory of an enemy faction.", homeDesc);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! MConf.get().homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(home.getWorld()))
|
||||
{
|
||||
msender.msg("<b>You cannot teleport to %s <b>while in a different world.", homeDesc);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Faction factionHere = BoardColl.get().getFactionAt(PS.valueOf(me.getLocation()));
|
||||
Location locationHere = me.getLocation().clone();
|
||||
|
||||
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
|
||||
if
|
||||
(
|
||||
MConf.get().homesTeleportAllowedEnemyDistance > 0
|
||||
&&
|
||||
factionHere.getFlag(MFlag.getFlagPvp())
|
||||
&&
|
||||
(
|
||||
! msender.isInOwnTerritory()
|
||||
||
|
||||
(
|
||||
msender.isInOwnTerritory()
|
||||
&&
|
||||
! MConf.get().homesTeleportIgnoreEnemiesIfInOwnTerritory
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
World w = locationHere.getWorld();
|
||||
double x = locationHere.getX();
|
||||
double y = locationHere.getY();
|
||||
double z = locationHere.getZ();
|
||||
|
||||
for (Player p : me.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (MUtil.isntPlayer(p)) continue;
|
||||
|
||||
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w)
|
||||
continue;
|
||||
|
||||
MPlayer fp = MPlayer.get(p);
|
||||
if (msender.getRelationTo(fp) != Rel.ENEMY)
|
||||
continue;
|
||||
|
||||
Location l = p.getLocation();
|
||||
double dx = Math.abs(x - l.getX());
|
||||
double dy = Math.abs(y - l.getY());
|
||||
double dz = Math.abs(z - l.getZ());
|
||||
double max = MConf.get().homesTeleportAllowedEnemyDistance;
|
||||
|
||||
// box-shaped distance check
|
||||
if (dx > max || dy > max || dz > max)
|
||||
continue;
|
||||
|
||||
msender.msg("<b>You cannot teleport to %s <b>while an enemy is within %f blocks of you.", homeDesc, MConf.get().homesTeleportAllowedEnemyDistance);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Event
|
||||
EventFactionsHomeTeleport event = new EventFactionsHomeTeleport(sender);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
// Apply
|
||||
try
|
||||
{
|
||||
Destination destination = new DestinationSimple(home, homeDesc);
|
||||
MixinTeleport.get().teleport(me, destination, sender);
|
||||
}
|
||||
catch (TeleporterException e)
|
||||
{
|
||||
String message = e.getMessage();
|
||||
MixinMessage.get().messageOne(me, message);
|
||||
}
|
||||
List<String> args = MUtil.list(MConf.get().warpsHomeName, this.argAt(0));
|
||||
CmdFactions.get().cmdFactionsWarp.cmdFactionsWarpGo.execute(me, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class CmdFactionsInviteAdd extends FactionsCommand
|
||||
public CmdFactionsInviteAdd()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeSet.get(TypeMPlayer.get()), "players", true);
|
||||
this.addParameter(TypeSet.get(TypeMPlayer.get()), "players", true).setDesc("the player to invite");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -16,8 +16,6 @@ import com.massivecraft.massivecore.util.TimeDiffUtil;
|
||||
import com.massivecraft.massivecore.util.TimeUnit;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
@ -32,7 +30,7 @@ public class CmdFactionsInviteList extends FactionsCommand
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(Parameter.getPage());
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
this.addParameter(TypeFaction.get(), "faction", "you").setDesc("the faction to list invites for");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -55,21 +53,11 @@ public class CmdFactionsInviteList extends FactionsCommand
|
||||
// Pager Create
|
||||
final List<Entry<String, Invitation>> invitations = new MassiveList<>(faction.getInvitations().entrySet());
|
||||
|
||||
Collections.sort(invitations, new Comparator<Entry<String, Invitation>>()
|
||||
{
|
||||
@Override
|
||||
public int compare(Entry<String, Invitation> i1, Entry<String, Invitation> i2)
|
||||
{
|
||||
return ComparatorSmart.get().compare(i2.getValue().getCreationMillis(), i1.getValue().getCreationMillis());
|
||||
}
|
||||
});
|
||||
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, new Stringifier<Entry<String, Invitation>>()
|
||||
{
|
||||
public String toString(Entry<String, Invitation> entry, int index)
|
||||
{
|
||||
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();
|
||||
|
||||
@ -86,7 +74,6 @@ public class CmdFactionsInviteList extends FactionsCommand
|
||||
}
|
||||
|
||||
return Txt.parse("%s<i> was invited by %s<reset>%s<i>.", inviteeDisplayName, inviterDisplayName, ageDesc);
|
||||
}
|
||||
});
|
||||
|
||||
// Pager Message
|
||||
|
@ -23,7 +23,7 @@ public class CmdFactionsInviteRemove extends FactionsCommand
|
||||
public CmdFactionsInviteRemove()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeSet.get(TypeMPlayer.get()), "players/all", true);
|
||||
this.addParameter(TypeSet.get(TypeMPlayer.get()), "players/all", true).setDesc("the player to deinvite");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -24,8 +24,8 @@ public class CmdFactionsJoin extends FactionsCommand
|
||||
public CmdFactionsJoin()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeFaction.get(), "faction");
|
||||
this.addParameter(TypeMPlayer.get(), "player", "you");
|
||||
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)");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -116,6 +116,7 @@ public class CmdFactionsJoin extends FactionsCommand
|
||||
// Apply
|
||||
mplayer.resetFactionData();
|
||||
mplayer.setFaction(faction);
|
||||
mplayer.setRank(faction.getLowestRank());
|
||||
|
||||
faction.uninvite(mplayer);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.cmd.type.TypeMPlayer;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
@ -23,7 +22,7 @@ public class CmdFactionsKick extends FactionsCommand
|
||||
public CmdFactionsKick()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeMPlayer.get(), "player");
|
||||
this.addParameter(TypeMPlayer.get(), "player").setDesc("the player to kick");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -44,22 +43,22 @@ public class CmdFactionsKick extends FactionsCommand
|
||||
return;
|
||||
}
|
||||
|
||||
if (mplayer.getRole() == Rel.LEADER && !msender.isOverriding())
|
||||
if ( !msender.isOverriding() && mplayer.getRank().isLeader())
|
||||
{
|
||||
throw new MassiveException().addMsg("<b>The leader cannot be kicked.");
|
||||
}
|
||||
|
||||
if (mplayer.getRole().isMoreThan(msender.getRole()) && ! msender.isOverriding())
|
||||
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 (mplayer.getRole() == msender.getRole() && ! msender.isOverriding())
|
||||
if (! msender.isOverriding() && mplayer.getRank() == msender.getRank())
|
||||
{
|
||||
throw new MassiveException().addMsg("<b>You can't kick people of the same rank as yourself.");
|
||||
}
|
||||
|
||||
if ( ! MConf.get().canLeaveWithNegativePower && mplayer.getPower() < 0 && ! msender.isOverriding())
|
||||
if ( ! msender.isOverriding() && ! MConf.get().canLeaveWithNegativePower && mplayer.getPower() < 0)
|
||||
{
|
||||
msg("<b>You can't kick that person until their power is positive.");
|
||||
return;
|
||||
@ -88,7 +87,7 @@ public class CmdFactionsKick extends FactionsCommand
|
||||
}
|
||||
|
||||
// Apply
|
||||
if (mplayer.getRole() == Rel.LEADER)
|
||||
if (mplayer.getRank().isLeader())
|
||||
{
|
||||
mplayerFaction.promoteNewLeader();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.comparator.ComparatorFactionList;
|
||||
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;
|
||||
@ -43,10 +43,7 @@ public class CmdFactionsList extends FactionsCommand
|
||||
// We run it asynchronously to spare the primary server thread.
|
||||
|
||||
// Pager Create
|
||||
final Pager<Faction> pager = new Pager<>(this, "Faction List", page, new Stringifier<Faction>() {
|
||||
@Override
|
||||
public String toString(Faction faction, int index)
|
||||
{
|
||||
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());
|
||||
@ -62,21 +59,15 @@ public class CmdFactionsList extends FactionsCommand
|
||||
faction.getPowerMaxRounded()
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
||||
// Pager Items
|
||||
final List<Faction> factions = FactionColl.get().getAll(ComparatorFactionList.get(sender));
|
||||
pager.setItems(factions);
|
||||
|
||||
// Pager Message
|
||||
pager.message();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ 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
|
||||
@ -15,7 +16,7 @@ public class CmdFactionsMap extends FactionsCommand
|
||||
public CmdFactionsMap()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeBooleanYes.get(), "on/off", "once");
|
||||
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());
|
||||
@ -37,7 +38,7 @@ public class CmdFactionsMap extends FactionsCommand
|
||||
if (!showMap) return;
|
||||
|
||||
// Show Map
|
||||
AsciiMap map = new AsciiMap(msender, me, !argSet);
|
||||
AsciiMap map = new AsciiMap(msender, PS.valueOf(me), !argSet);
|
||||
message(map.render());
|
||||
}
|
||||
|
||||
|
@ -11,9 +11,9 @@ public class CmdFactionsMoney extends FactionsCommand
|
||||
public CmdFactionsMoneyBalance cmdMoneyBalance = new CmdFactionsMoneyBalance();
|
||||
public CmdFactionsMoneyDeposit cmdMoneyDeposit = new CmdFactionsMoneyDeposit();
|
||||
public CmdFactionsMoneyWithdraw cmdMoneyWithdraw = new CmdFactionsMoneyWithdraw();
|
||||
public CmdFactionsMoneyTransferFf cmdMoneyTransferFf = new CmdFactionsMoneyTransferFf();
|
||||
public CmdFactionsMoneyTransferFp cmdMoneyTransferFp = new CmdFactionsMoneyTransferFp();
|
||||
public CmdFactionsMoneyTransferPf cmdMoneyTransferPf = new CmdFactionsMoneyTransferPf();
|
||||
public CmdFactionsMoneyTransferF2f cmdMoneyTransferFf = new CmdFactionsMoneyTransferF2f();
|
||||
public CmdFactionsMoneyTransferF2p cmdMoneyTransferFp = new CmdFactionsMoneyTransferF2p();
|
||||
public CmdFactionsMoneyTransferP2f cmdMoneyTransferPf = new CmdFactionsMoneyTransferP2f();
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
|
@ -16,7 +16,7 @@ public class CmdFactionsMoneyBalance extends FactionsCommand
|
||||
public CmdFactionsMoneyBalance()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
this.addParameter(TypeFaction.get(), "faction", "you").setDesc("the faction whose balance to check");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqBankCommandsEnabled.get());
|
||||
|
@ -21,8 +21,8 @@ public class CmdFactionsMoneyDeposit extends FactionsCommand
|
||||
public CmdFactionsMoneyDeposit()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeDouble.get(), "amount");
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
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());
|
||||
|
@ -1,26 +1,24 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
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.entity.MConf;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
||||
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 CmdFactionsMoneyTransferFf extends FactionsCommand
|
||||
public class CmdFactionsMoneyTransferF2f extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsMoneyTransferFf()
|
||||
public CmdFactionsMoneyTransferF2f()
|
||||
{
|
||||
// Fields
|
||||
this.setSetupEnabled(false);
|
||||
@ -29,12 +27,11 @@ public class CmdFactionsMoneyTransferFf extends FactionsCommand
|
||||
this.addAliases("ff");
|
||||
|
||||
// Parameters
|
||||
this.addParameter(TypeDouble.get(), "amount");
|
||||
this.addParameter(TypeFaction.get(), "faction");
|
||||
this.addParameter(TypeFaction.get(), "faction");
|
||||
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(RequirementHasPerm.get(Perm.MONEY_F2F));
|
||||
this.addRequirements(ReqBankCommandsEnabled.get());
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
import com.massivecraft.factions.cmd.type.TypeMPlayer;
|
||||
@ -10,19 +9,18 @@ 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.requirement.RequirementHasPerm;
|
||||
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 CmdFactionsMoneyTransferFp extends FactionsCommand
|
||||
public class CmdFactionsMoneyTransferF2p extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsMoneyTransferFp()
|
||||
public CmdFactionsMoneyTransferF2p()
|
||||
{
|
||||
// Fields
|
||||
this.setSetupEnabled(false);
|
||||
@ -31,12 +29,11 @@ public class CmdFactionsMoneyTransferFp extends FactionsCommand
|
||||
this.addAliases("fp");
|
||||
|
||||
// Parameters
|
||||
this.addParameter(TypeDouble.get(), "amount");
|
||||
this.addParameter(TypeFaction.get(), "faction");
|
||||
this.addParameter(TypeMPlayer.get(), "player");
|
||||
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(RequirementHasPerm.get(Perm.MONEY_F2P));
|
||||
this.addRequirements(ReqBankCommandsEnabled.get());
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
import com.massivecraft.factions.cmd.type.TypeMPlayer;
|
||||
@ -10,19 +9,18 @@ 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.requirement.RequirementHasPerm;
|
||||
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 CmdFactionsMoneyTransferPf extends FactionsCommand
|
||||
public class CmdFactionsMoneyTransferP2f extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsMoneyTransferPf()
|
||||
public CmdFactionsMoneyTransferP2f()
|
||||
{
|
||||
// Fields
|
||||
this.setSetupEnabled(false);
|
||||
@ -31,12 +29,11 @@ public class CmdFactionsMoneyTransferPf extends FactionsCommand
|
||||
this.addAliases("pf");
|
||||
|
||||
// Parameters
|
||||
this.addParameter(TypeDouble.get(), "amount");
|
||||
this.addParameter(TypeMPlayer.get(), "player");
|
||||
this.addParameter(TypeFaction.get(), "faction");
|
||||
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(RequirementHasPerm.get(Perm.MONEY_P2F));
|
||||
this.addRequirements(ReqBankCommandsEnabled.get());
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ public class CmdFactionsMoneyWithdraw extends FactionsCommand
|
||||
public CmdFactionsMoneyWithdraw()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeDouble.get(), "amount");
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
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());
|
||||
|
@ -0,0 +1,77 @@
|
||||
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!");
|
||||
}
|
||||
|
||||
}
|
@ -19,7 +19,7 @@ public class CmdFactionsMotd extends FactionsCommand
|
||||
public CmdFactionsMotd()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeNullable.get(TypeString.get()), "new", "read", true);
|
||||
this.addParameter(TypeNullable.get(TypeString.get()), "new", "read", true).setDesc("the new motd\nif not specified you will just see the current one");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -42,8 +42,11 @@ public class CmdFactionsMotd extends FactionsCommand
|
||||
// Args
|
||||
String target = this.readArg();
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
target = target.trim();
|
||||
target = Txt.parse(target);
|
||||
}
|
||||
|
||||
// Get Old
|
||||
String old = msenderFaction.getMotd();
|
||||
@ -67,7 +70,8 @@ public class CmdFactionsMotd extends FactionsCommand
|
||||
// Inform
|
||||
for (MPlayer follower : msenderFaction.getMPlayers())
|
||||
{
|
||||
follower.msg("<i>%s <i>set your faction motd to:\n%s", MixinDisplayName.get().getDisplayName(sender, follower), msenderFaction.getMotdDesc());
|
||||
follower.msg("<i>%s <i>changed your faction motd.", MixinDisplayName.get().getDisplayName(sender, follower));
|
||||
follower.message(msenderFaction.getMotdMessages());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,14 +3,9 @@ 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.FactionColl;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.event.EventFactionsNameChange;
|
||||
import com.massivecraft.factions.util.MiscUtil;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.command.type.primitive.TypeString;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CmdFactionsName extends FactionsCommand
|
||||
{
|
||||
@ -21,8 +16,8 @@ public class CmdFactionsName extends FactionsCommand
|
||||
public CmdFactionsName()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeFactionNameLenient.get(), "new name");
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
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");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -8,6 +8,8 @@ public class CmdFactionsPerm extends FactionsCommand
|
||||
|
||||
CmdFactionsPermList cmdFactionsPermList = new CmdFactionsPermList();
|
||||
CmdFactionsPermShow cmdFactionsPermShow = new CmdFactionsPermShow();
|
||||
CmdFactionsPermView cmdFactionsPermView = new CmdFactionsPermView();
|
||||
CmdFactionsPermViewall cmdFactionsPermViewall = new CmdFactionsPermViewall();
|
||||
CmdFactionsPermSet cmdFactionsPermSet = new CmdFactionsPermSet();
|
||||
|
||||
}
|
||||
|
@ -7,26 +7,13 @@ 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.predicate.Predicate;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class CmdFactionsPermList extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// REUSABLE PREDICATE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static final Predicate<MPerm> PREDICATE_MPERM_VISIBLE = new Predicate<MPerm>()
|
||||
{
|
||||
@Override
|
||||
public boolean apply(MPerm mperm)
|
||||
{
|
||||
return mperm.isVisible();
|
||||
}
|
||||
};
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
@ -49,22 +36,10 @@ public class CmdFactionsPermList extends FactionsCommand
|
||||
|
||||
// Pager create
|
||||
String title = String.format("Perms for %s", msenderFaction.describeTo(msender));
|
||||
final Pager<MPerm> pager = new Pager<>(this, title, page, new Stringifier<MPerm>()
|
||||
{
|
||||
@Override
|
||||
public String toString(MPerm mperm, int index)
|
||||
{
|
||||
return mperm.getDesc(true, true);
|
||||
}
|
||||
});
|
||||
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;
|
||||
|
||||
final Predicate<MPerm> predicate = msender.isOverriding() ? null : PREDICATE_MPERM_VISIBLE;
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), () -> {
|
||||
// Get items
|
||||
List<MPerm> items = MPermColl.get().getAll(predicate);
|
||||
|
||||
@ -73,7 +48,6 @@ public class CmdFactionsPermList extends FactionsCommand
|
||||
|
||||
// Pager message
|
||||
pager.message();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,16 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
import com.massivecraft.factions.cmd.type.TypeMPerm;
|
||||
import com.massivecraft.factions.cmd.type.TypeRel;
|
||||
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.entity.MPlayer;
|
||||
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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CmdFactionsPermSet extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
@ -25,7 +21,7 @@ public class CmdFactionsPermSet extends FactionsCommand
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeMPerm.get(), "perm");
|
||||
this.addParameter(TypeRel.get(), "relation");
|
||||
this.addParameter(TypeMPermable.get(), "rank/rel/player/faction");
|
||||
this.addParameter(TypeBooleanYes.get(), "yes/no");
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
}
|
||||
@ -38,10 +34,11 @@ public class CmdFactionsPermSet extends FactionsCommand
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
MPerm perm = this.readArg();
|
||||
Rel rel = this.readArg();
|
||||
Boolean value = this.readArg();
|
||||
Faction faction = this.readArg(msenderFaction);
|
||||
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;
|
||||
@ -49,50 +46,38 @@ public class CmdFactionsPermSet extends FactionsCommand
|
||||
// Is this perm editable?
|
||||
if ( ! msender.isOverriding() && ! perm.isEditable())
|
||||
{
|
||||
msg("<b>The perm <h>%s <b>is not editable.", perm.getName());
|
||||
return;
|
||||
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, rel, value);
|
||||
EventFactionsPermChange event = new EventFactionsPermChange(sender, faction, perm, permable, value);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
value = event.getNewValue();
|
||||
|
||||
// No change
|
||||
if (faction.getPermitted(perm).contains(rel) == value)
|
||||
{
|
||||
msg("%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"), rel.getColor() + rel.getDescPlayerMany());
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply
|
||||
faction.setRelationPermitted(perm, rel, value);
|
||||
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() && MPerm.getPermPerms().getStandard().contains(Rel.LEADER))
|
||||
if (perm == MPerm.getPermPerms() && MConf.get().perm2default.get(MPerm.ID_PERMS).contains("LEADER"))
|
||||
{
|
||||
faction.setRelationPermitted(MPerm.getPermPerms(), Rel.LEADER, true);
|
||||
faction.setPermitted( faction.getLeaderRank(), MPerm.getPermPerms(), true);
|
||||
}
|
||||
|
||||
// Create messages
|
||||
List<Object> messages = new ArrayList<>();
|
||||
|
||||
// Inform sender
|
||||
messages.add(Txt.titleize("Perm for " + faction.describeTo(msender, true)));
|
||||
messages.add(MPerm.getStateHeaders());
|
||||
messages.add(Txt.parse(perm.getStateInfo(faction.getPermitted(perm), true)));
|
||||
message(messages);
|
||||
|
||||
// Inform faction (their message is slighly different)
|
||||
List<MPlayer> recipients = faction.getMPlayers();
|
||||
recipients.remove(msender);
|
||||
|
||||
for (MPlayer recipient : recipients)
|
||||
{
|
||||
recipient.msg("<h>%s <i>set a perm for <h>%s<i>.", msender.describeTo(recipient, true), faction.describeTo(recipient, true));
|
||||
recipient.message(messages);
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,13 +4,16 @@ 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.command.type.container.TypeSet;
|
||||
import com.massivecraft.massivecore.collections.MassiveList;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CmdFactionsPermShow extends FactionsCommand
|
||||
{
|
||||
@ -21,8 +24,8 @@ public class CmdFactionsPermShow extends FactionsCommand
|
||||
public CmdFactionsPermShow()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeMPerm.get(), "perm");
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
this.addParameter(TypeSet.get(TypeMPerm.get()), "perms", "all", true);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -33,21 +36,49 @@ public class CmdFactionsPermShow extends FactionsCommand
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Arg: Faction
|
||||
MPerm mperm = this.readArg();
|
||||
Faction faction = this.readArg(msenderFaction);
|
||||
Collection<MPerm> mperms = this.readArg(MPerm.getAll());
|
||||
|
||||
// Create messages
|
||||
List<Object> messages = new ArrayList<>();
|
||||
Set<String> permittedIds = faction.getPerms().get(mperm.getId());
|
||||
List<MPermable> permables = new MassiveList<>();
|
||||
|
||||
messages.add(Txt.titleize("Perm for " + faction.describeTo(msender, true)));
|
||||
messages.add(MPerm.getStateHeaders());
|
||||
for (MPerm mperm : mperms)
|
||||
for (String permitted : permittedIds)
|
||||
{
|
||||
messages.add(Txt.parse(mperm.getStateInfo(faction.getPermitted(mperm), true)));
|
||||
permables.add(MPerm.idToMPermable(permitted));
|
||||
}
|
||||
|
||||
// Send messages
|
||||
message(messages);
|
||||
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>"));
|
||||
}
|
||||
|
||||
}
|
||||
|
103
src/com/massivecraft/factions/cmd/CmdFactionsPermView.java
Normal file
103
src/com/massivecraft/factions/cmd/CmdFactionsPermView.java
Normal file
@ -0,0 +1,103 @@
|
||||
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())));
|
||||
}
|
||||
|
||||
}
|
104
src/com/massivecraft/factions/cmd/CmdFactionsPermViewall.java
Normal file
104
src/com/massivecraft/factions/cmd/CmdFactionsPermViewall.java
Normal file
@ -0,0 +1,104 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -38,6 +38,9 @@ public class CmdFactionsPlayer extends FactionsCommand
|
||||
// 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();
|
||||
|
@ -1,19 +1,19 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public class CmdFactionsPowerBoost extends FactionsCommand
|
||||
public class CmdFactionsPowerboost extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsPowerBoostPlayer cmdFactionsPowerBoostPlayer = new CmdFactionsPowerBoostPlayer();
|
||||
public CmdFactionsPowerBoostFaction cmdFactionsPowerBoostFaction = new CmdFactionsPowerBoostFaction();
|
||||
public CmdFactionsPowerboostPlayer cmdFactionsPowerBoostPlayer = new CmdFactionsPowerboostPlayer();
|
||||
public CmdFactionsPowerboostFaction cmdFactionsPowerBoostFaction = new CmdFactionsPowerboostFaction();
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsPowerBoost()
|
||||
public CmdFactionsPowerboost()
|
||||
{
|
||||
// Child
|
||||
this.addChild(this.cmdFactionsPowerBoostPlayer);
|
@ -2,25 +2,32 @@ package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.FactionsParticipator;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.command.type.Type;
|
||||
import com.massivecraft.massivecore.command.type.TypeNullable;
|
||||
import com.massivecraft.massivecore.command.type.primitive.TypeDouble;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public abstract class CmdFactionsPowerBoostAbstract extends FactionsCommand
|
||||
public abstract class CmdFactionsPowerboostAbstract extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
protected CmdFactionsPowerBoostAbstract(Type<? extends FactionsParticipator> parameterType, String parameterName)
|
||||
protected CmdFactionsPowerboostAbstract(Type<? extends FactionsParticipator> parameterType, String parameterName)
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(parameterType, parameterName);
|
||||
this.addParameter(TypeNullable.get(TypeDouble.get()), "amount", "show");
|
||||
if (!this.getClass().getSimpleName().contains("Show"))
|
||||
{
|
||||
this.addParameter(TypeDouble.get(), "amount");
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ABSTRACT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public abstract double calcNewPowerboost(double current, double d);
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
@ -31,35 +38,32 @@ public abstract class CmdFactionsPowerBoostAbstract extends FactionsCommand
|
||||
{
|
||||
// Parameters
|
||||
FactionsParticipator factionsParticipator = this.readArg();
|
||||
Double powerBoost = this.readArg(factionsParticipator.getPowerBoost());
|
||||
|
||||
boolean updated = false;
|
||||
// Try set the powerBoost
|
||||
boolean updated = this.trySet(factionsParticipator, powerBoost);
|
||||
|
||||
// Inform
|
||||
this.informPowerBoost(factionsParticipator, powerBoost, updated);
|
||||
}
|
||||
|
||||
private boolean trySet(FactionsParticipator factionsParticipator, Double powerBoost) throws MassiveException
|
||||
if (this.argIsSet(1))
|
||||
{
|
||||
// Trying to set?
|
||||
if (!this.argIsSet(1)) return false;
|
||||
// Yes updated
|
||||
updated = true;
|
||||
|
||||
// Check set permissions
|
||||
if (!Perm.POWERBOOST_SET.has(sender, true)) throw new MassiveException();
|
||||
// Calc powerboost
|
||||
double current = factionsParticipator.getPowerBoost();
|
||||
double number = this.readArg();
|
||||
double powerBoost = this.calcNewPowerboost(current, number);
|
||||
|
||||
// Set
|
||||
factionsParticipator.setPowerBoost(powerBoost);
|
||||
|
||||
// Return
|
||||
return true;
|
||||
}
|
||||
|
||||
private void informPowerBoost(FactionsParticipator factionsParticipator, Double powerBoost, boolean updated)
|
||||
// Inform
|
||||
this.informPowerBoost(factionsParticipator, updated);
|
||||
}
|
||||
|
||||
private void informPowerBoost(FactionsParticipator factionsParticipator, boolean updated)
|
||||
{
|
||||
// Prepare
|
||||
Double powerBoost = factionsParticipator.getPowerBoost();
|
||||
String participatorDescribe = factionsParticipator.describeTo(msender, true);
|
||||
powerBoost = powerBoost == null ? factionsParticipator.getPowerBoost() : powerBoost;
|
||||
String powerDescription = Txt.parse(Double.compare(powerBoost, 0D) >= 0 ? "<g>bonus" : "<b>penalty");
|
||||
String when = updated ? "now " : "";
|
||||
String verb = factionsParticipator.equals(msender) ? "have" : "has";
|
@ -0,0 +1,15 @@
|
||||
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();
|
||||
|
||||
}
|
@ -2,13 +2,13 @@ package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
|
||||
public class CmdFactionsPowerBoostFaction extends CmdFactionsPowerBoostAbstract
|
||||
public abstract class CmdFactionsPowerboostFactionAbstract extends CmdFactionsPowerboostAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsPowerBoostFaction()
|
||||
public CmdFactionsPowerboostFactionAbstract()
|
||||
{
|
||||
super(TypeFaction.get(), "faction");
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public class CmdFactionsPowerboostFactionAdd extends CmdFactionsPowerboostFactionAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public double calcNewPowerboost(double current, double d)
|
||||
{
|
||||
return current + d;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public class CmdFactionsPowerboostFactionMultiply extends CmdFactionsPowerboostFactionAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public double calcNewPowerboost(double current, double d)
|
||||
{
|
||||
return current * d;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public class CmdFactionsPowerboostFactionSet extends CmdFactionsPowerboostFactionAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public double calcNewPowerboost(double current, double d)
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public class CmdFactionsPowerboostFactionShow extends CmdFactionsPowerboostFactionAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public double calcNewPowerboost(double current, double d)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public class CmdFactionsPowerboostFactionTake extends CmdFactionsPowerboostFactionAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public double calcNewPowerboost(double current, double d)
|
||||
{
|
||||
return current - d;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public class CmdFactionsPowerboostPlayer extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsPowerboostPlayerShow cmdFactionsPowerBoostPlayerShow = new CmdFactionsPowerboostPlayerShow();
|
||||
public CmdFactionsPowerboostPlayerSet cmdFactionsPowerBoostPlayerSet = new CmdFactionsPowerboostPlayerSet();
|
||||
public CmdFactionsPowerboostPlayerAdd cmdFactionsPowerBoostPlayerAdd = new CmdFactionsPowerboostPlayerAdd();
|
||||
public CmdFactionsPowerboostPlayerTake cmdFactionsPowerBoostPlayerTake = new CmdFactionsPowerboostPlayerTake();
|
||||
public CmdFactionsPowerboostPlayerMultiply cmdFactionsPowerBoostPlayerMultiply = new CmdFactionsPowerboostPlayerMultiply();
|
||||
|
||||
}
|
@ -2,13 +2,13 @@ package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.cmd.type.TypeMPlayer;
|
||||
|
||||
public class CmdFactionsPowerBoostPlayer extends CmdFactionsPowerBoostAbstract
|
||||
public abstract class CmdFactionsPowerboostPlayerAbstract extends CmdFactionsPowerboostAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsPowerBoostPlayer()
|
||||
public CmdFactionsPowerboostPlayerAbstract()
|
||||
{
|
||||
super(TypeMPlayer.get(), "player");
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public class CmdFactionsPowerboostPlayerAdd extends CmdFactionsPowerboostPlayerAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public double calcNewPowerboost(double current, double d)
|
||||
{
|
||||
return current + d;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public class CmdFactionsPowerboostPlayerMultiply extends CmdFactionsPowerboostPlayerAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public double calcNewPowerboost(double current, double d)
|
||||
{
|
||||
return current * d;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public class CmdFactionsPowerboostPlayerSet extends CmdFactionsPowerboostPlayerAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public double calcNewPowerboost(double current, double d)
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public class CmdFactionsPowerboostPlayerShow extends CmdFactionsPowerboostPlayerAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public double calcNewPowerboost(double current, double d)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public class CmdFactionsPowerboostPlayerTake extends CmdFactionsPowerboostPlayerAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public double calcNewPowerboost(double current, double d)
|
||||
{
|
||||
return current - d;
|
||||
}
|
||||
|
||||
}
|
@ -1,393 +1,14 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
import com.massivecraft.factions.cmd.type.TypeMPlayer;
|
||||
import com.massivecraft.factions.cmd.type.TypeRank;
|
||||
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.entity.MPlayerColl;
|
||||
import com.massivecraft.factions.event.EventFactionsMembershipChange;
|
||||
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
|
||||
import com.massivecraft.factions.event.EventFactionsRankChange;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class CmdFactionsRank extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTANTS
|
||||
// -------------------------------------------- //
|
||||
|
||||
// The rank required to do any rank changes.
|
||||
final static Rel rankReq = Rel.OFFICER;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
// These fields are set upon perform() and unset afterwards.
|
||||
|
||||
// Target
|
||||
private Faction targetFaction = null;
|
||||
private MPlayer target = null;
|
||||
|
||||
// End faction (the faction they are changed to)
|
||||
private Faction endFaction = null;
|
||||
private boolean factionChange = false;
|
||||
|
||||
// Ranks
|
||||
private Rel senderRank = null;
|
||||
private Rel targetRank = null;
|
||||
private Rel rank = null;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsRank()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeMPlayer.get(), "player");
|
||||
this.addParameter(TypeRank.get(), "action", "show");
|
||||
this.addParameter(TypeFaction.get(), "faction", "their");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// This sets target and much other.
|
||||
this.registerFields();
|
||||
|
||||
// Sometimes we just want to show the rank.
|
||||
if ( ! this.argIsSet(1))
|
||||
{
|
||||
if ( ! Perm.RANK_SHOW.has(sender, true)) return;
|
||||
this.showRank();
|
||||
return;
|
||||
}
|
||||
|
||||
// Permission check.
|
||||
if ( ! Perm.RANK_ACTION.has(sender, true)) return;
|
||||
|
||||
// Is the player allowed or not. Method can be found later down.
|
||||
this.ensureAllowed();
|
||||
|
||||
if (factionChange)
|
||||
{
|
||||
this.changeFaction();
|
||||
}
|
||||
|
||||
// Does the change make sense.
|
||||
this.ensureMakesSense();
|
||||
|
||||
// Event
|
||||
EventFactionsRankChange event = new EventFactionsRankChange(sender, target, rank);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
rank = event.getNewRank();
|
||||
|
||||
// Change the rank.
|
||||
this.changeRank();
|
||||
}
|
||||
|
||||
// This is always run after performing a MassiveCommand.
|
||||
@Override
|
||||
public void senderFields(boolean set)
|
||||
{
|
||||
super.senderFields(set);
|
||||
|
||||
if ( ! set)
|
||||
{
|
||||
this.unregisterFields();
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// PRIVATE: REGISTER & UNREGISTER
|
||||
// -------------------------------------------- //
|
||||
|
||||
private void registerFields() throws MassiveException
|
||||
{
|
||||
// Getting the target and faction.
|
||||
target = this.readArg(msender);
|
||||
targetFaction = target.getFaction();
|
||||
|
||||
|
||||
// Ranks
|
||||
senderRank = msender.getRole();
|
||||
targetRank = target.getRole();
|
||||
|
||||
// Rank if any passed.
|
||||
if (this.argIsSet(1))
|
||||
{
|
||||
this.setParameterType(1, TypeRank.get(targetRank));
|
||||
rank = this.readArg();
|
||||
}
|
||||
|
||||
// Changing peoples faction.
|
||||
endFaction = this.readArgAt(2, targetFaction);
|
||||
factionChange = (endFaction != targetFaction);
|
||||
|
||||
}
|
||||
|
||||
private void unregisterFields()
|
||||
{
|
||||
targetFaction = null;
|
||||
target = null;
|
||||
|
||||
senderRank = null;
|
||||
targetRank = null;
|
||||
rank = null;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// PRIVATE: ENSURE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private void ensureAllowed() throws MassiveException
|
||||
{
|
||||
// People with permission don't follow the normal rules.
|
||||
if (msender.isOverriding()) return;
|
||||
|
||||
// If somone gets the leadership of wilderness (Which has happened before).
|
||||
// We can at least try to limit their powers.
|
||||
if (endFaction.isNone())
|
||||
{
|
||||
throw new MassiveException().addMsg("%s <b>doesn't use ranks sorry :(", targetFaction.getName() );
|
||||
}
|
||||
|
||||
if (target == msender)
|
||||
{
|
||||
// Don't change your own rank.
|
||||
throw new MassiveException().addMsg("<b>The target player mustn't be yourself.");
|
||||
}
|
||||
|
||||
if (targetFaction != msenderFaction)
|
||||
{
|
||||
// Don't change ranks outside of your faction.
|
||||
throw new MassiveException().addMsg("%s <b>is not in the same faction as you.", target.describeTo(msender, true));
|
||||
}
|
||||
|
||||
if (factionChange)
|
||||
{
|
||||
// Don't change peoples faction
|
||||
throw new MassiveException().addMsg("<b>You can't change %s's <b>faction.", target.describeTo(msender));
|
||||
}
|
||||
|
||||
if (senderRank.isLessThan(rankReq))
|
||||
{
|
||||
// You need a specific rank to change ranks.
|
||||
throw new MassiveException().addMsg("<b>You must be <h>%s <b>or higher to change ranks.", Txt.getNicedEnum(rankReq).toLowerCase());
|
||||
}
|
||||
|
||||
// The following two if statements could be merged.
|
||||
// But isn't for the sake of nicer error messages.
|
||||
if (senderRank == targetRank)
|
||||
{
|
||||
// You can't change someones rank if it is equal to yours.
|
||||
throw new MassiveException().addMsg("<h>%s <b>can't manage eachother.", Txt.getNicedEnum(rankReq)+"s");
|
||||
}
|
||||
|
||||
if (senderRank.isLessThan(targetRank))
|
||||
{
|
||||
// You can't change someones rank if it is higher than yours.
|
||||
throw new MassiveException().addMsg("<b>You can't manage people of higher rank.");
|
||||
}
|
||||
|
||||
// The following two if statements could be merged.
|
||||
// But isn't for the sake of nicer error messages.
|
||||
if (senderRank == rank && senderRank != Rel.LEADER)
|
||||
{
|
||||
// You can't set ranks equal to your own. Unless you are the leader.
|
||||
throw new MassiveException().addMsg("<b>You can't set ranks equal to your own.");
|
||||
}
|
||||
|
||||
if (senderRank.isLessThan(rank))
|
||||
{
|
||||
// You can't set ranks higher than your own.
|
||||
throw new MassiveException().addMsg("<b>You can't set ranks higher than your own.");
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureMakesSense() throws MassiveException
|
||||
{
|
||||
// Don't change their rank to something they already are.
|
||||
if (target.getRole() == rank)
|
||||
{
|
||||
throw new MassiveException().addMsg("%s <b>is already %s.", target.describeTo(msender), rank.getDescPlayerOne());
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// PRIVATE: SHOW
|
||||
// -------------------------------------------- //
|
||||
|
||||
private void showRank()
|
||||
{
|
||||
// Damn you grammar, causing all these checks.
|
||||
String targetName = target.describeTo(msender, true);
|
||||
String isAre = (target == msender) ? "are" : "is"; // "you are" or "he is"
|
||||
String theAan = (targetRank == Rel.LEADER) ? "the" : Txt.aan(targetRank.name()); // "a member", "an officer" or "the leader"
|
||||
String rankName = Txt.getNicedEnum(targetRank).toLowerCase();
|
||||
String ofIn = (targetRank == Rel.LEADER) ? "of" : "in"; // "member in" or "leader of"
|
||||
String factionName = targetFaction.describeTo(msender, true);
|
||||
if (targetFaction == msenderFaction)
|
||||
{
|
||||
// Having the "Y" in "Your faction" being uppercase in the middle of a sentence makes no sense.
|
||||
factionName = factionName.toLowerCase();
|
||||
}
|
||||
if (targetFaction.isNone())
|
||||
{
|
||||
// Wilderness aka none doesn't use ranks
|
||||
msg("%s <i>%s factionless", targetName, isAre);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Derp is a member in Faction
|
||||
msg("%s <i>%s %s <h>%s <i>%s %s<i>.", targetName, isAre, theAan, rankName, ofIn, factionName);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// PRIVATE: CHANGE FACTION
|
||||
// -------------------------------------------- //
|
||||
|
||||
private void changeFaction() throws MassiveException
|
||||
{
|
||||
// Don't change a leader to a new faction.
|
||||
if (targetRank == Rel.LEADER)
|
||||
{
|
||||
throw new MassiveException().addMsg("<b>You cannot remove the present leader. Demote them first.");
|
||||
}
|
||||
|
||||
// Event
|
||||
EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, msender, endFaction, MembershipChangeReason.RANK);
|
||||
membershipChangeEvent.run();
|
||||
if (membershipChangeEvent.isCancelled()) throw new MassiveException();
|
||||
|
||||
// Apply
|
||||
target.resetFactionData();
|
||||
target.setFaction(endFaction);
|
||||
|
||||
// No longer invited.
|
||||
endFaction.uninvite(target);
|
||||
|
||||
// Create recipients
|
||||
Set<MPlayer> recipients = new HashSet<>();
|
||||
recipients.addAll(targetFaction.getMPlayersWhereOnline(true));
|
||||
recipients.addAll(endFaction.getMPlayersWhereOnline(true));
|
||||
recipients.add(msender);
|
||||
|
||||
// Send message
|
||||
for (MPlayer recipient : recipients)
|
||||
{
|
||||
recipient.msg("%s <i>was moved from <i>%s to <i>%s<i>.", target.describeTo(recipient), targetFaction.describeTo(recipient), endFaction.describeTo(recipient));
|
||||
}
|
||||
|
||||
// Derplog
|
||||
if (MConf.get().logFactionJoin)
|
||||
{
|
||||
Factions.get().log(Txt.parse("%s moved %s from %s to %s.", msender.getName(), target.getName(), targetFaction.getName(), endFaction.getName()));
|
||||
}
|
||||
|
||||
// Now we don't need the old values.
|
||||
targetFaction = target.getFaction();
|
||||
targetRank = target.getRole();
|
||||
senderRank = msender.getRole(); // In case they changed their own rank
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// PRIVATE: CHANGE RANK
|
||||
// -------------------------------------------- //
|
||||
|
||||
private void changeRank() throws MassiveException
|
||||
{
|
||||
// In case of leadership change, we do special things not done in other rank changes.
|
||||
if (rank == Rel.LEADER)
|
||||
{
|
||||
this.changeRankLeader();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.changeRankOther();
|
||||
}
|
||||
}
|
||||
|
||||
private void changeRankLeader()
|
||||
{
|
||||
// If there is a current leader. Demote & inform them.
|
||||
MPlayer targetFactionCurrentLeader = targetFaction.getLeader();
|
||||
if (targetFactionCurrentLeader != null)
|
||||
{
|
||||
// Inform & demote the old leader.
|
||||
targetFactionCurrentLeader.setRole(Rel.OFFICER);
|
||||
if (targetFactionCurrentLeader != msender)
|
||||
{
|
||||
// They kinda know if they fired the command themself.
|
||||
targetFactionCurrentLeader.msg("<i>You have been demoted from the position of faction leader by %s<i>.", msender.describeTo(targetFactionCurrentLeader, true));
|
||||
}
|
||||
}
|
||||
|
||||
// Promote the new leader.
|
||||
target.setRole(Rel.LEADER);
|
||||
|
||||
// Inform everyone, this includes sender and target.
|
||||
for (MPlayer recipient : MPlayerColl.get().getAllOnline())
|
||||
{
|
||||
String changerName = senderIsConsole ? "A server admin" : msender.describeTo(recipient);
|
||||
recipient.msg("%s<i> gave %s<i> the leadership of %s<i>.", changerName, target.describeTo(recipient), targetFaction.describeTo(recipient));
|
||||
}
|
||||
}
|
||||
|
||||
private void changeRankOther() throws MassiveException
|
||||
{
|
||||
// If the target is currently the leader and faction isn't permanent a new leader should be promoted.
|
||||
// Sometimes a bug occurs and multiple leaders exist. Then we should be able to demote without promoting new leader
|
||||
if (targetRank == Rel.LEADER && ( ! MConf.get().permanentFactionsDisableLeaderPromotion || ! targetFaction.getFlag(MFlag.ID_PERMANENT)) && targetFaction.getMPlayersWhereRole(Rel.LEADER).size() == 1)
|
||||
// This if statement is very long. Should I nest it for readability?
|
||||
{
|
||||
targetFaction.promoteNewLeader(); // This might disband the faction.
|
||||
|
||||
// So if the faction disbanded...
|
||||
if (targetFaction.detached())
|
||||
{
|
||||
// ... we inform the sender.
|
||||
target.resetFactionData();
|
||||
throw new MassiveException().addMsg("<i>The target was a leader and got demoted. The faction disbanded and no rank was set.");
|
||||
}
|
||||
}
|
||||
|
||||
// Create recipients
|
||||
Set<MPlayer> recipients = new HashSet<>();
|
||||
recipients.addAll(targetFaction.getMPlayers());
|
||||
recipients.add(msender);
|
||||
|
||||
// Were they demoted or promoted?
|
||||
String change = (rank.isLessThan(targetRank) ? "demoted" : "promoted");
|
||||
|
||||
// The rank will be set before the msg, so they have the appropriate prefix.
|
||||
target.setRole(rank);
|
||||
String oldRankName = Txt.getNicedEnum(targetRank).toLowerCase();
|
||||
String rankName = Txt.getNicedEnum(rank).toLowerCase();
|
||||
|
||||
// Send message
|
||||
for(MPlayer recipient : recipients)
|
||||
{
|
||||
String targetName = target.describeTo(recipient, true);
|
||||
String wasWere = (recipient == target) ? "were" : "was";
|
||||
recipient.msg("%s<i> %s %s from %s to <h>%s <i>in %s<i>.", targetName, wasWere, change, oldRankName, rankName, targetFaction.describeTo(msender));
|
||||
}
|
||||
}
|
||||
public CmdFactionsRankSet cmdFactionsRankSet = new CmdFactionsRankSet();
|
||||
public CmdFactionsRankShow cmdFactionsRankShow = new CmdFactionsRankShow();
|
||||
public CmdFactionsRankList cmdFactionsRankList = new CmdFactionsRankList();
|
||||
public CmdFactionsRankEdit cmdFactionsRankEdit = new CmdFactionsRankEdit();
|
||||
|
||||
}
|
||||
|
34
src/com/massivecraft/factions/cmd/CmdFactionsRankEdit.java
Normal file
34
src/com/massivecraft/factions/cmd/CmdFactionsRankEdit.java
Normal file
@ -0,0 +1,34 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
|
||||
public class CmdFactionsRankEdit extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsRankEditCreate cmdFactionsRankEditCreate = new CmdFactionsRankEditCreate();
|
||||
public CmdFactionsRankEditDelete cmdFactionsRankEditDelete = new CmdFactionsRankEditDelete();
|
||||
public CmdFactionsRankEditName cmdFactionsRankEditName = new CmdFactionsRankEditName();
|
||||
public CmdFactionsRankEditPrefix cmdFactionsRankEditPrefix = new CmdFactionsRankEditPrefix();
|
||||
public CmdFactionsRankEditPriority cmdFactionsRankEditPriority = new CmdFactionsRankEditPriority();
|
||||
|
||||
static void ensureAllowed(MPlayer msender, Faction faction, String action) throws MassiveException
|
||||
{
|
||||
if (msender.isOverriding()) return;
|
||||
|
||||
if (faction != msender.getFaction())
|
||||
{
|
||||
throw new MassiveException().addMsg("<b>You can't manage ranks outside your own faction.");
|
||||
}
|
||||
|
||||
if (!msender.getRank().isLeader())
|
||||
{
|
||||
throw new MassiveException().addMsg("<b>Only the leader can %s ranks.", action);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.Rank;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
|
||||
import com.massivecraft.massivecore.command.type.primitive.TypeString;
|
||||
import com.massivecraft.massivecore.command.type.primitive.TypeStringParsed;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class CmdFactionsRankEditCreate extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsRankEditCreate()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeString.get(), "name");
|
||||
this.addParameter(TypeInteger.get(), "priority");
|
||||
this.addParameter("", TypeStringParsed.get(), "prefix", "none");
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
String name = this.readArg();
|
||||
Integer priority = this.readArg();
|
||||
String prefix = this.readArg();
|
||||
Faction faction = this.readArg(msenderFaction);
|
||||
|
||||
CmdFactionsRankEdit.ensureAllowed(msender, faction, "create");
|
||||
|
||||
Collection<Rank> ranks = faction.getRanks().getAll();
|
||||
|
||||
if (ranks.stream().map(Rank::getName).anyMatch(s -> s.equalsIgnoreCase(name)))
|
||||
{
|
||||
throw new MassiveException().addMsg("<b>There is already a rank called <h>%s<b>.", name);
|
||||
}
|
||||
if (ranks.stream().map(Rank::getPriority).anyMatch(i -> i.equals(priority)))
|
||||
{
|
||||
throw new MassiveException().addMsg("<b>There is already a rank with priority <h>%s<b>.", priority);
|
||||
}
|
||||
if (priority > faction.getLeaderRank().getPriority())
|
||||
{
|
||||
throw new MassiveException().addMsg("<b>You can't create a rank of higher priority than the leader rank.");
|
||||
}
|
||||
|
||||
Rank rank = new Rank(name, priority, prefix);
|
||||
|
||||
faction.getRanks().attach(rank);
|
||||
|
||||
// Inform
|
||||
msg("<i>You created the rank <reset>%s<i>.", rank.getVisual());
|
||||
msg("<i>You might want to change its permissions:");
|
||||
CmdFactions.get().cmdFactionsPerm.getTemplate(false, true, sender).messageOne(msender);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
import com.massivecraft.factions.cmd.type.TypeRank;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.entity.Rank;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.command.type.primitive.TypeString;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CmdFactionsRankEditDelete extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsRankEditDelete()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeString.get(), "rank");
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
Faction faction = this.readArgAt(1, msenderFaction);
|
||||
|
||||
// Rank if any passed.
|
||||
TypeRank typeRank = new TypeRank(faction);
|
||||
Rank rank = typeRank.read(this.argAt(0), sender);
|
||||
|
||||
CmdFactionsRankEdit.ensureAllowed(msender, faction, "delete");
|
||||
|
||||
Collection<Rank> ranks = faction.getRanks().getAll();
|
||||
if (ranks.size() <= 2)
|
||||
{
|
||||
throw new MassiveException().addMsg("<b>A faction must have at least two ranks.");
|
||||
}
|
||||
|
||||
List<MPlayer> mplayers = faction.getMPlayersWhereRank(rank);
|
||||
if (!mplayers.isEmpty())
|
||||
{
|
||||
int count = mplayers.size();
|
||||
List<String> names = mplayers.stream().map(m -> m.getDisplayName(sender)).collect(Collectors.toList());
|
||||
String namesDesc = Txt.implodeCommaAnd(names, Txt.parse("<i>"));
|
||||
String rankRanks = count == 1 ? "rank" : "ranks";
|
||||
throw new MassiveException().addMsg("<b>This rank is held by <h>%s <b>change their %s first.", namesDesc, rankRanks);
|
||||
}
|
||||
|
||||
String visual = rank.getVisual();
|
||||
faction.getRanks().detachEntity(rank);
|
||||
|
||||
// Inform
|
||||
msg("<i>You deleted the rank <reset>%s<i>.", visual);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
import com.massivecraft.factions.cmd.type.TypeRank;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.Rank;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.command.type.primitive.TypeString;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class CmdFactionsRankEditName extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsRankEditName()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeRank.get(), "rank");
|
||||
this.addParameter(TypeString.get(), "new name");
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
String name = this.readArgAt(1);
|
||||
Faction faction = this.readArgAt(2, msenderFaction);
|
||||
|
||||
// Rank if any passed.
|
||||
TypeRank typeRank = new TypeRank(faction);
|
||||
Rank rank = typeRank.read(this.argAt(0), sender);
|
||||
|
||||
// Args
|
||||
|
||||
CmdFactionsRankEdit.ensureAllowed(msender, faction, "rename");
|
||||
|
||||
Collection<Rank> ranks = faction.getRanks().getAll();
|
||||
|
||||
if (ranks.stream().map(Rank::getName).anyMatch(s -> s.equalsIgnoreCase(name)))
|
||||
{
|
||||
throw new MassiveException().addMsg("<b>There is already a rank called <h>%s<b>.", name);
|
||||
}
|
||||
|
||||
String priorVisual = rank.getVisual();
|
||||
rank.setName(name);
|
||||
|
||||
// Visual
|
||||
msg("<i>You renamed the rank from <reset>%s <i>to <reset>%s<i>.", priorVisual, rank.getVisual());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
import com.massivecraft.factions.cmd.type.TypeRank;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.Rank;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.command.type.primitive.TypeString;
|
||||
|
||||
public class CmdFactionsRankEditPrefix extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsRankEditPrefix()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeRank.get(), "rank");
|
||||
this.addParameter(TypeString.get(), "new prefix");
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
String prefix = this.readArgAt(1);
|
||||
Faction faction = this.readArgAt(2, msenderFaction);
|
||||
|
||||
// Rank if any passed.
|
||||
TypeRank typeRank = new TypeRank(faction);
|
||||
Rank rank = typeRank.read(this.argAt(0), sender);
|
||||
|
||||
// Args
|
||||
|
||||
CmdFactionsRankEdit.ensureAllowed(msender, faction, "edit");
|
||||
|
||||
String priorPrefix = rank.getPrefix();
|
||||
rank.setPrefix(prefix);
|
||||
|
||||
// Visual
|
||||
msg("<i>You changed the prefix of <reset>%s <i>from <h>%s <i>to <h>%s<i>.", rank.getVisual(), priorPrefix, prefix);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
import com.massivecraft.factions.cmd.type.TypeRank;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.Rank;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.command.type.primitive.TypeInteger;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class CmdFactionsRankEditPriority extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsRankEditPriority()
|
||||
{
|
||||
// Parameters
|
||||
this.addParameter(TypeRank.get(), "rank");
|
||||
this.addParameter(TypeInteger.get(), "new priority");
|
||||
this.addParameter(TypeFaction.get(), "faction", "you");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
Integer priority = this.readArgAt(1);
|
||||
Faction faction = this.readArgAt(2, msenderFaction);
|
||||
|
||||
// Rank if any passed.
|
||||
TypeRank typeRank = new TypeRank(faction);
|
||||
Rank rank = typeRank.read(this.argAt(0), sender);
|
||||
|
||||
CmdFactionsRankEdit.ensureAllowed(msender, faction, "edit");
|
||||
|
||||
Collection<Rank> ranks = faction.getRanks().getAll();
|
||||
|
||||
if (ranks.stream().map(Rank::getPriority).anyMatch(s -> s.equals(priority)))
|
||||
{
|
||||
throw new MassiveException().addMsg("<b>There is already a rank with the priority <h>%s<b>.", priority);
|
||||
}
|
||||
|
||||
if (rank.isLeader())
|
||||
{
|
||||
Rank below = rank.getRankBelow();
|
||||
if (below.getPriority() > priority)
|
||||
{
|
||||
throw new MassiveException().addMsg("<b>The leader rank must have the highest priority.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (priority >= faction.getLeaderRank().getPriority())
|
||||
{
|
||||
throw new MassiveException().addMsg("<b>No rank can have higher priority than the leader rank.");
|
||||
}
|
||||
}
|
||||
|
||||
int priorPriority = rank.getPriority();
|
||||
rank.setPriority(priority);
|
||||
|
||||
// Visual
|
||||
msg("<i>You changed the priority of <reset>%s <i>from <h>%s <i>to <h>%s<i>.", rank.getVisual(), priorPriority, priority);
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user