v2.4 Release
This commit is contained in:
1 parent
0d6f429e1e
commit
a61ae9894f
270 files changed
+10419
-12544
No files matched your search
+91
-48
@@ -4,61 +4,104 @@ This changelog records only changes made by the Unions-OG soft fork relative
|
||||
to upstream [SimpleClans](https://github.com/RoinujNosde/SimpleClans). Changes
|
||||
inherited unchanged from SimpleClans are intentionally omitted.
|
||||
|
||||
## [2.4] - 2026-08-10
|
||||
|
||||
### Added
|
||||
|
||||
- Unions decide by member vote. `disband`, `home set` and `war start` now open
|
||||
a proposal that passes when half the members are in favour, is rejected once
|
||||
half becomes unreachable, and expires after 7 days. Votes are stored in the
|
||||
database, so members can vote when they next log in.
|
||||
- `/union vote` shows the open proposal and its tally; `/union vote yes|no`
|
||||
casts a vote. A vote screen in the GUI does the same, and is shown once on
|
||||
login to members who have not voted.
|
||||
- Disbanding a union splits its bank evenly between all members. Inert until
|
||||
union bank accounts are enabled.
|
||||
- `/clan`, `/clans`, `/factions`, `/guilds`, `/party`, `/tribe`, `/nation`,
|
||||
`/crew`, `/squad` and `/gang` tell the player to use `/union` instead.
|
||||
`/f`, `/faction` and `/guild` are left to Utilities-OG.
|
||||
|
||||
### Changed
|
||||
|
||||
- Unions are flat. Every union command is member-level, and the three actions
|
||||
above are the only ones needing more than one member's say-so.
|
||||
- Folded `unionsog.leader.*` into `unionsog.member.*`, which is granted by
|
||||
default. Union ally management is `unionsog.member.ally-set` and union
|
||||
friendly fire is `unionsog.member.union-ff`, to avoid clashing with the
|
||||
existing ally-chat and personal-friendly-fire nodes.
|
||||
- Renamed clan to union across the API, config sections and message keys:
|
||||
`Clan` is `Union`, `clan:` is `union:`, `clanchat:` is `unionchat:`.
|
||||
Database identifiers and PlaceholderAPI placeholder names deliberately keep
|
||||
their `clan` spelling.
|
||||
- Renamed `/union clanff` to `/union unionff`.
|
||||
- Chat and display formats accept `{union}`; `{clan}` still works.
|
||||
- A union now ends with its last member.
|
||||
- `/union war start` no longer asks the target union, so the member-count
|
||||
guard always applies. Removed `war-and-protection.war-start.request-enabled`.
|
||||
- Inter-union requests are answered by the first member of the asked union
|
||||
rather than by its leaders.
|
||||
- Set the union GUI title to "Union Management".
|
||||
|
||||
### Removed
|
||||
|
||||
- Ranks, promotion and demotion, with their commands, settings, events and GUI
|
||||
screens.
|
||||
- The leader role: no leader flag, leader-only command, tag colour, Discord
|
||||
role or `sc_leader` LuckPerms group. The `sc_players.leader` column is kept
|
||||
and always written `0` for data compatibility.
|
||||
- The leaders-only land creation option.
|
||||
- The in-game Crowdin translation prompts.
|
||||
|
||||
### Fixed
|
||||
|
||||
- `/union lookup` and `/union profile` no longer print a literal
|
||||
`%player_rank%` or `%clan_leaders%`.
|
||||
- Removed a stale `%rank%` token from the default chat formats.
|
||||
- `/union unionff block` now requires union membership, matching
|
||||
`/union unionff allow`.
|
||||
- The legacy database importer no longer reads or writes leader relationships.
|
||||
|
||||
## [2.3] - Initial release
|
||||
|
||||
### Added
|
||||
|
||||
- Added `/union` and `/unions` as primary command aliases while retaining
|
||||
`/clan` and `/clans`.
|
||||
- Added `/u [message]` for union chat. Running `/u` without a message toggles
|
||||
the player's union-chat channel.
|
||||
- Added `/union color <color>` with named, legacy, and hex color support,
|
||||
governed by `unionsog.leader.color`.
|
||||
- Added `simpleunions` PlaceholderAPI aliases alongside the legacy
|
||||
`simpleclans` identifier.
|
||||
- Added MiniPlaceholders support through Utilities-OG, including clan/union
|
||||
aliases and relational placeholders.
|
||||
- Added a stable `&8None` result for the no-union color-tag placeholder.
|
||||
- Added a Union Banking preview to the main GUI.
|
||||
- Added a configuration-gated legacy database migration from `unions_parties` and
|
||||
`unions_players` into the configured Unions-OG tables. The migration:
|
||||
- Never modifies the legacy source tables.
|
||||
- Requires empty, transactional destination tables.
|
||||
- Runs in a transaction and records successful application for idempotency.
|
||||
- Preserves membership and leader relationships, resolves duplicate tags,
|
||||
and supplies deterministic player-name placeholders when needed.
|
||||
- Aborts plugin startup on configuration, connection, validation, or import
|
||||
failure so the server cannot continue with partially migrated data.
|
||||
- Includes unit and database-backed tests for mapping, idempotency, safety,
|
||||
and rollback behavior.
|
||||
- Renamed the plugin and artifact to Unions-OG and changed user-facing clan
|
||||
terminology to union.
|
||||
- Moved the Java and Gradle namespace to `net.trueog.unionsog`, the plugin main
|
||||
class to `net.trueog.unionsog.UnionsOG`, and permission nodes to
|
||||
`unionsog.*`.
|
||||
- Disabled verification as a gameplay gate; newly created unions are treated
|
||||
as verified while the stored field remains for data compatibility.
|
||||
- Reserved `None` as a union name or tag to avoid ambiguity with the
|
||||
no-union display value.
|
||||
- Disabled bulletin-board messages on login by default.
|
||||
- Replaced Vault economy access with DiamondBank-OG and its shard-based player
|
||||
balances. Legacy Vault-denominated union balances are zeroed once.
|
||||
- Temporarily disabled union-bank commands and detail-screen controls until
|
||||
DiamondBank-OG provides union-owned accounts; the main GUI shows a preview
|
||||
in their place.
|
||||
- `/union` and `/unions` as primary command aliases, keeping `/clan` and
|
||||
`/clans`.
|
||||
- `/u [message]` for union chat. Running `/u` alone toggles the channel.
|
||||
- `/union color <color>` with named, legacy and hex color support.
|
||||
- `simpleunions` PlaceholderAPI aliases alongside the legacy `simpleclans`
|
||||
identifier, plus MiniPlaceholders support through Utilities-OG.
|
||||
- A Union Banking preview in the main GUI.
|
||||
- A configuration-gated legacy database migration from `unions_parties` and
|
||||
`unions_players`. It never touches the source tables, requires empty
|
||||
transactional destinations, is idempotent, and aborts startup on failure so
|
||||
the server cannot run on partially migrated data.
|
||||
|
||||
### Changed
|
||||
|
||||
- Renamed the plugin and artifact to Unions-OG, moved the namespace to
|
||||
`net.trueog.unionsog` and permission nodes to `unionsog.*`.
|
||||
- Replaced Vault with DiamondBank-OG and its shard-based balances. Legacy
|
||||
Vault-denominated union balances are zeroed once. Union-bank commands are
|
||||
disabled until DiamondBank-OG provides union-owned accounts.
|
||||
- Unions are treated as verified without the upstream verification workflow.
|
||||
- Reserved `None` as a union name or tag, and made the no-union color-tag
|
||||
placeholder return a stable `&8None`.
|
||||
- Bulletin-board messages no longer show on login by default.
|
||||
- Reordered the main GUI around the union overview, banking preview, lists,
|
||||
leaderboards, and administrative tools.
|
||||
- Replaced the legacy WorldGuard 6 reflection provider with the WorldEdit and
|
||||
leaderboards and administrative tools.
|
||||
- Replaced the WorldGuard 6 reflection provider with the WorldEdit and
|
||||
WorldGuard 7 APIs.
|
||||
- Updated MySQL driver loading for Connector/J 8, the legacy Connector/J
|
||||
class name, MariaDB, and JDBC service discovery.
|
||||
- Updated MySQL driver loading for Connector/J 8, MariaDB and JDBC service
|
||||
discovery.
|
||||
- Migrated the build from Maven to Gradle with a Java 17 toolchain,
|
||||
reproducible shaded jars, formatting checks, and the Utilities-OG and
|
||||
DiamondBank-OG submodules.
|
||||
- Removed the Vault dependency and the scheduled Vault-backed member-fee and
|
||||
upkeep tasks.
|
||||
- Removed the legacy WorldGuard 6 provider.
|
||||
- Removed bStats telemetry from the fork.
|
||||
reproducible shaded jars, and the Utilities-OG and DiamondBank-OG submodules.
|
||||
|
||||
### Removed
|
||||
|
||||
- The Vault dependency, along with the member-fee and upkeep tasks it backed.
|
||||
- The legacy WorldGuard 6 provider.
|
||||
- bStats telemetry.
|
||||
|
||||
## Fork baseline
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ A full-featured union system for PvP Minecraft servers.
|
||||
> TrueOG Network. Upstream behavior is retained where practical, while
|
||||
> branding, integrations, and selected gameplay behavior intentionally differ.
|
||||
|
||||
Current fork version: **2.3**
|
||||
Current fork version: **2.4**
|
||||
|
||||
- [Fork-only changelog](CHANGELOG.md)
|
||||
- [PlaceholderAPI and MiniPlaceholders reference](placeholder-info.txt)
|
||||
@@ -18,16 +18,52 @@ Current fork version: **2.3**
|
||||
|
||||
## Main fork differences
|
||||
|
||||
- Uses Unions-OG branding and union terminology.
|
||||
- Provides `/union` and `/unions` while keeping `/clan` and `/clans` as
|
||||
compatibility aliases.
|
||||
### Flat unions
|
||||
|
||||
Unions have no internal hierarchy. Ranks, promotion, demotion and the leader
|
||||
role itself were removed, so every member holds the same powers.
|
||||
|
||||
- Every union command is member-level. There is no leader flag, no rank
|
||||
system, and no way to grant one member authority over another.
|
||||
- A union ends with its last member: resigning, or being kicked or moved out
|
||||
as the only member, disbands it.
|
||||
|
||||
### Decisions by member consensus
|
||||
|
||||
Three actions need a vote of the union's own members instead of a leader's
|
||||
say-so: **disband**, **home set**, and **war start**.
|
||||
|
||||
- A proposal passes as soon as half the members (rounded up) vote in favour,
|
||||
and is rejected as soon as enough vote against that half can no longer be
|
||||
reached.
|
||||
- Votes are stored in the database, so a member who is offline when a
|
||||
proposal opens can still vote the next time they log in. Proposals expire
|
||||
after 7 days.
|
||||
- A union can only have one proposal open at a time.
|
||||
- Members vote with `/union vote yes|no`, or by clicking the vote buttons in
|
||||
the union GUI. The GUI is presented once on login to members who have not
|
||||
voted yet.
|
||||
- `/union vote` on its own shows the open proposal and the running tally.
|
||||
|
||||
### Other differences
|
||||
|
||||
- Uses Unions-OG branding and union terminology throughout, including config
|
||||
sections (`union:`, `unionchat:`) and message keys.
|
||||
- Provides `/union` and `/unions`. Other group words — `/clan`, `/clans`,
|
||||
`/factions`, `/guilds`, `/party`, `/tribe`, `/nation`, `/crew`, `/squad` and
|
||||
`/gang` — are registered as signposts that tell the player to run the same command with
|
||||
`/union` instead. `/f`, `/faction` and `/guild` belong to Utilities-OG,
|
||||
which already redirects them.
|
||||
- Uses `/u` for union chat; a bare `/u` toggles the union-chat channel.
|
||||
- Adds `/union color <color>` with the `unionsog.leader.color` permission.
|
||||
- Adds `/union rename <name>` and `/union color <color>`, both open to any
|
||||
member.
|
||||
- Union-wide friendly fire is `/union unionff allow|block`.
|
||||
- Supports both `simpleclans` and `simpleunions` placeholder identifiers in
|
||||
PlaceholderAPI and MiniPlaceholders.
|
||||
- Uses DiamondBank-OG instead of Vault for player economy access. Union-owned
|
||||
bank accounts remain under development, so their commands are currently
|
||||
disabled.
|
||||
disabled. Once enabled, disbanding a union splits its bank evenly between
|
||||
all members.
|
||||
- Treats unions as verified without requiring the upstream verification
|
||||
workflow.
|
||||
- Includes a configuration-gated, transactional importer for the legacy
|
||||
@@ -39,16 +75,21 @@ there.
|
||||
|
||||
## Documentation
|
||||
|
||||
The [SimpleClans documentation](https://simpleclans.gitbook.io/simpleclans/)
|
||||
remains the baseline reference for inherited features. It uses upstream clan
|
||||
terminology, and fork-specific commands, permissions, banking behavior, and
|
||||
integrations may differ.
|
||||
The [Unions-OG wiki](wiki/) documents this fork, and is the reference to use.
|
||||
|
||||
- [Upstream commands](https://simpleclans.gitbook.io/simpleclans/commands-and-permissions/commands)
|
||||
- [Upstream permissions](https://simpleclans.gitbook.io/simpleclans/commands-and-permissions/permissions)
|
||||
- [Upstream configuration](https://simpleclans.gitbook.io/simpleclans/how-to-setup/configuration)
|
||||
- [Upstream ranks](https://simpleclans.gitbook.io/simpleclans/commands-and-permissions/ranks-with-permissions)
|
||||
- [Upstream land protection integrations](https://simpleclans.gitbook.io/simpleclans/other/land-claims)
|
||||
- [Commands](wiki/commands-and-permissions/commands.md)
|
||||
- [Permissions](wiki/commands-and-permissions/permissions.md)
|
||||
- [Proposals and Voting](wiki/commands-and-permissions/proposals-and-voting.md)
|
||||
- [Union Alliances and Rivalries](wiki/commands-and-permissions/alliances-and-rivalries.md)
|
||||
- [Configuration](wiki/how-to-setup/configuration.md)
|
||||
- [PlaceholderAPI Support](wiki/other/placeholderapi-support.md)
|
||||
- [API example](wiki/other/unions-og-api.md)
|
||||
|
||||
> [!WARNING]
|
||||
> The [upstream SimpleClans documentation](https://simpleclans.gitbook.io/simpleclans/)
|
||||
> no longer describes this fork. Its pages on leaders, ranks, promotion,
|
||||
> demotion, member fees and upkeep do **not** apply, and its command,
|
||||
> permission and configuration names have all been renamed here.
|
||||
|
||||
For the unmodified upstream plugin and its public releases, use the
|
||||
[SimpleClans Spigot page](https://www.spigotmc.org/resources/simpleclans.71242/).
|
||||
@@ -64,16 +105,28 @@ git submodule update --init --recursive
|
||||
```
|
||||
|
||||
The shaded plugin is produced under `build/libs/` with the
|
||||
`Unions-OG-2.3.jar` name.
|
||||
`Unions-OG-2.4.jar` name.
|
||||
|
||||
## Developer compatibility
|
||||
|
||||
- Java and Gradle namespace: `net.trueog.unionsog`
|
||||
- Bukkit main class: `net.trueog.unionsog.UnionsOG`
|
||||
- Permission prefix: `unionsog.*`
|
||||
- Command aliases: `union`, `unions`, `clan`, and `clans`
|
||||
- API types use union naming: `Union`, `UnionPlayer`, `UnionManager`,
|
||||
`Proposal`, `DisbandUnionEvent`
|
||||
- Permission prefix: `unionsog.*`. Union actions all live under
|
||||
`unionsog.member.*`, which is granted by default; there is no
|
||||
`unionsog.leader.*` tree
|
||||
- Command aliases: `union` and `unions`. Other group words are redirect-only
|
||||
signposts, not aliases, and never execute a union command
|
||||
- Placeholder identifiers: `simpleunions` and the retained `simpleclans`
|
||||
compatibility identifier
|
||||
compatibility identifier. Placeholder **names** deliberately keep their
|
||||
upstream `clan` spelling (`%simpleunions_clan_name%`) so existing setups
|
||||
keep resolving
|
||||
- Database identifiers are unchanged for live-data compatibility: the table
|
||||
prefix stays `sc_`, and the `clans` table and `leader` column are retained
|
||||
even though the leader column is no longer used
|
||||
- Chat and display formats accept `{union}`; the legacy `{clan}` token still
|
||||
works
|
||||
|
||||
The old SimpleClans Maven coordinates and Java packages do not describe this
|
||||
fork and should not be used as Unions-OG API coordinates.
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ kotlin { jvmToolchain(17) }
|
||||
/* ----------------------------- Metadata ------------------------------ */
|
||||
group = "net.trueog.unionsog" // Declare bundle identifier.
|
||||
|
||||
version = "2.3" // Declare plugin version (will be in .jar).
|
||||
version = "2.4" // Declare plugin version (will be in .jar).
|
||||
|
||||
val apiVersion = "1.19" // Declare minecraft server target version.
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ These resolve against the requested player:
|
||||
|
||||
- name
|
||||
- clean_name
|
||||
- is_leader
|
||||
- lastseendays
|
||||
- total_kills
|
||||
- rival_kills
|
||||
@@ -66,9 +65,6 @@ These resolve against the requested player:
|
||||
- is_bb_enabled
|
||||
- is_invite_enabled
|
||||
- is_tag_enabled
|
||||
- rank_displayname
|
||||
- has_rank
|
||||
- rank
|
||||
- is_muted
|
||||
- is_mutedally
|
||||
|
||||
@@ -103,7 +99,6 @@ These resolve against the requested player's union:
|
||||
- rivals_count
|
||||
- is_permanent
|
||||
- onlinemembers_count
|
||||
- leader_size
|
||||
- total_kdr
|
||||
- topclans_position
|
||||
- total_deaths
|
||||
|
||||
@@ -762,7 +762,7 @@ public class ChatBlock {
|
||||
|
||||
}
|
||||
|
||||
public static void sendMessage(@Nullable ClanPlayer receiver, @NotNull String msg) {
|
||||
public static void sendMessage(@Nullable UnionPlayer receiver, @NotNull String msg) {
|
||||
|
||||
if (receiver == null) {
|
||||
|
||||
@@ -774,7 +774,7 @@ public class ChatBlock {
|
||||
|
||||
}
|
||||
|
||||
// ClanCommands#setbanner, LandCommands#Allow/BlockCommand/verify,
|
||||
// UnionCommands#setbanner, LandCommands#Allow/BlockCommand/verify,
|
||||
// StaffCommands#kick, etc
|
||||
public static void sendMessageKey(@Nullable CommandSender receiver, @NotNull String key, @NotNull Object... args) {
|
||||
|
||||
@@ -782,9 +782,9 @@ public class ChatBlock {
|
||||
|
||||
}
|
||||
|
||||
public static void sendMessageKey(@NotNull ClanPlayer clanPlayer, @NotNull String key, @NotNull Object... args) {
|
||||
public static void sendMessageKey(@NotNull UnionPlayer unionPlayer, @NotNull String key, @NotNull Object... args) {
|
||||
|
||||
sendMessageKey(clanPlayer.toPlayer(), key, args);
|
||||
sendMessageKey(unionPlayer.toPlayer(), key, args);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package net.trueog.unionsog;
|
||||
|
||||
/**
|
||||
* Clan Requests
|
||||
*
|
||||
* @author phaed
|
||||
*/
|
||||
public enum ClanRequest {
|
||||
DEMOTE, PROMOTE, DISBAND, INVITE, CREATE_ALLY, BREAK_RIVALRY, START_WAR, END_WAR, RENAME
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package net.trueog.unionsog;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import net.trueog.unionsog.managers.PermissionsManager;
|
||||
import org.bukkit.Location;
|
||||
@@ -39,7 +37,6 @@ import static net.trueog.unionsog.utils.ChatUtils.stripColors;
|
||||
public final class Helper {
|
||||
|
||||
private static final Gson GSON = new Gson();
|
||||
private static final Type RANKS_TYPE = TypeToken.getParameterized(List.class, Rank.class).getType();
|
||||
private static final Type RESIGN_TYPE = TypeToken.getParameterized(Map.class, String.class, Long.class).getType();
|
||||
|
||||
private Helper() {
|
||||
@@ -140,69 +137,6 @@ public final class Helper {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a list of ranks from the specified Json String
|
||||
*
|
||||
* @param json the Json String
|
||||
* @return a list of ranks or null if the JSON String is null/empty
|
||||
*/
|
||||
public static @Nullable List<Rank> ranksFromJson(@Nullable String json) {
|
||||
|
||||
if (json != null && !json.isEmpty()) {
|
||||
|
||||
JsonObject object = GSON.fromJson(json, JsonObject.class);
|
||||
JsonElement ranks = object.get("ranks");
|
||||
return GSON.fromJson(ranks, RANKS_TYPE);
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the default rank from the specified Json String
|
||||
*
|
||||
* @param json the Json String
|
||||
* @return the default rank or null if not found and/or it does not exist
|
||||
*/
|
||||
public static @Nullable String defaultRankFromJson(@Nullable String json) {
|
||||
|
||||
if (json != null && !json.isEmpty()) {
|
||||
|
||||
JsonObject object = GSON.fromJson(json, JsonObject.class);
|
||||
JsonElement defaultRank = object.get("defaultRank");
|
||||
if (defaultRank != null && !defaultRank.isJsonNull()) {
|
||||
|
||||
return defaultRank.getAsString();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a list of ranks and the default rank to a JSON String
|
||||
*
|
||||
* @param ranks the ranks
|
||||
* @param defaultRank the default rank
|
||||
* @return a JSON String
|
||||
*/
|
||||
public static String ranksToJson(List<Rank> ranks, @Nullable String defaultRank) {
|
||||
|
||||
if (ranks == null)
|
||||
ranks = new ArrayList<>();
|
||||
|
||||
JsonObject object = new JsonObject();
|
||||
object.add("ranks", GSON.toJsonTree(ranks));
|
||||
object.addProperty("defaultRank", defaultRank);
|
||||
return object.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a resign times map to a JSON String
|
||||
*
|
||||
@@ -327,25 +261,6 @@ public final class Helper {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the Permission values array to a String array
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String[] fromPermissionArray() {
|
||||
|
||||
RankPermission[] permissions = RankPermission.values();
|
||||
String[] sa = new String[permissions.length];
|
||||
for (int i = 0; i < permissions.length; i++) {
|
||||
|
||||
sa[i] = permissions[i].toString();
|
||||
|
||||
}
|
||||
|
||||
return sa;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up the tag from color codes and makes it lowercase
|
||||
*
|
||||
@@ -379,16 +294,16 @@ public final class Helper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove offline players from a ClanPlayer array
|
||||
* Remove offline players from a UnionPlayer array
|
||||
*
|
||||
* @param in
|
||||
* @return
|
||||
*/
|
||||
public static List<ClanPlayer> stripOffLinePlayers(List<ClanPlayer> in) {
|
||||
public static List<UnionPlayer> stripOffLinePlayers(List<UnionPlayer> in) {
|
||||
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
List<UnionPlayer> out = new ArrayList<>();
|
||||
|
||||
for (ClanPlayer cp : in) {
|
||||
for (UnionPlayer cp : in) {
|
||||
|
||||
if (cp.toPlayer() != null) {
|
||||
|
||||
@@ -475,10 +390,10 @@ public final class Helper {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getFormattedClanStatus(Clan clan, CommandSender sender) {
|
||||
public static String getFormattedUnionStatus(Union union, CommandSender sender) {
|
||||
|
||||
ArrayList<String> statuses = new ArrayList<>();
|
||||
if (clan.isPermanent()) {
|
||||
if (union.isPermanent()) {
|
||||
|
||||
statuses.add(lang("permanent", sender));
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ import java.time.LocalDateTime;
|
||||
|
||||
public class Kill {
|
||||
|
||||
private final ClanPlayer killer;
|
||||
private final ClanPlayer victim;
|
||||
private final UnionPlayer killer;
|
||||
private final UnionPlayer victim;
|
||||
private final LocalDateTime time;
|
||||
|
||||
public Kill(ClanPlayer killer, ClanPlayer victim, LocalDateTime time) {
|
||||
public Kill(UnionPlayer killer, UnionPlayer victim, LocalDateTime time) {
|
||||
|
||||
this.killer = killer;
|
||||
this.victim = victim;
|
||||
@@ -16,13 +16,13 @@ public class Kill {
|
||||
|
||||
}
|
||||
|
||||
public ClanPlayer getKiller() {
|
||||
public UnionPlayer getKiller() {
|
||||
|
||||
return killer;
|
||||
|
||||
}
|
||||
|
||||
public ClanPlayer getVictim() {
|
||||
public UnionPlayer getVictim() {
|
||||
|
||||
return victim;
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package net.trueog.unionsog;
|
||||
|
||||
public enum PermissionLevel {
|
||||
LEADER, TRUSTED
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
package net.trueog.unionsog;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A decision put to a union's own members.
|
||||
* <p>
|
||||
* A proposal passes as soon as half of the union's members have voted yes, and
|
||||
* is rejected as soon as enough members have voted no that half can no longer
|
||||
* be reached. Votes survive logouts and restarts, so members can answer the
|
||||
* next time they log in.
|
||||
* </p>
|
||||
*/
|
||||
public final class Proposal {
|
||||
|
||||
private final @NotNull ProposalType type;
|
||||
private final @NotNull String unionTag;
|
||||
private final @NotNull UUID proposer;
|
||||
private final @NotNull String target;
|
||||
private final long createdAt;
|
||||
private final Map<UUID, Boolean> votes = new LinkedHashMap<>();
|
||||
|
||||
public Proposal(@NotNull ProposalType type, @NotNull String unionTag, @NotNull UUID proposer,
|
||||
@NotNull String target, long createdAt)
|
||||
{
|
||||
|
||||
this.type = type;
|
||||
this.unionTag = unionTag;
|
||||
this.proposer = proposer;
|
||||
this.target = target;
|
||||
this.createdAt = createdAt;
|
||||
|
||||
}
|
||||
|
||||
public @NotNull ProposalType getType() {
|
||||
|
||||
return type;
|
||||
|
||||
}
|
||||
|
||||
public @NotNull String getUnionTag() {
|
||||
|
||||
return unionTag;
|
||||
|
||||
}
|
||||
|
||||
public @NotNull UUID getProposer() {
|
||||
|
||||
return proposer;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the proposal's payload, empty for proposals that do not need one
|
||||
*/
|
||||
public @NotNull String getTarget() {
|
||||
|
||||
return target;
|
||||
|
||||
}
|
||||
|
||||
public long getCreatedAt() {
|
||||
|
||||
return createdAt;
|
||||
|
||||
}
|
||||
|
||||
public @NotNull Map<UUID, Boolean> getVotes() {
|
||||
|
||||
return Collections.unmodifiableMap(votes);
|
||||
|
||||
}
|
||||
|
||||
public void putVote(@NotNull UUID voter, boolean inFavour) {
|
||||
|
||||
votes.put(voter, inFavour);
|
||||
|
||||
}
|
||||
|
||||
public void putVotes(@NotNull Map<UUID, Boolean> votes) {
|
||||
|
||||
this.votes.putAll(votes);
|
||||
|
||||
}
|
||||
|
||||
public @Nullable Boolean getVote(@NotNull UUID voter) {
|
||||
|
||||
return votes.get(voter);
|
||||
|
||||
}
|
||||
|
||||
public boolean hasVoted(@NotNull UUID voter) {
|
||||
|
||||
return votes.containsKey(voter);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the votes of players who are no longer members of the union, so that
|
||||
* someone leaving cannot keep holding a proposal open.
|
||||
*
|
||||
* @param members the current members
|
||||
*/
|
||||
public void retainVoters(@NotNull Iterable<UnionPlayer> members) {
|
||||
|
||||
Set<UUID> current = new HashSet<>();
|
||||
for (UnionPlayer cp : members) {
|
||||
|
||||
current.add(cp.getUniqueId());
|
||||
|
||||
}
|
||||
|
||||
votes.keySet().retainAll(current);
|
||||
|
||||
}
|
||||
|
||||
public int countVotes(boolean inFavour) {
|
||||
|
||||
int count = 0;
|
||||
for (Boolean vote : votes.values()) {
|
||||
|
||||
if (vote == inFavour) {
|
||||
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of yes votes needed, which is half of the union rounded up.
|
||||
*
|
||||
* @param memberCount the union's member count
|
||||
*/
|
||||
public static int votesNeeded(int memberCount) {
|
||||
|
||||
return (memberCount + 1) / 2;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param memberCount the union's member count
|
||||
* @return whether enough members are in favour
|
||||
*/
|
||||
public boolean isPassed(int memberCount) {
|
||||
|
||||
return countVotes(true) >= votesNeeded(memberCount);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param memberCount the union's member count
|
||||
* @return whether so many members are against that it can no longer pass
|
||||
*/
|
||||
public boolean isRejected(int memberCount) {
|
||||
|
||||
return countVotes(false) > memberCount - votesNeeded(memberCount);
|
||||
|
||||
}
|
||||
|
||||
public boolean isExpired(long now, long lifetimeMillis) {
|
||||
|
||||
return now - createdAt >= lifetimeMillis;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package net.trueog.unionsog;
|
||||
|
||||
/**
|
||||
* The decisions a union's own members vote on.
|
||||
*
|
||||
* @see Proposal
|
||||
*/
|
||||
public enum ProposalType {
|
||||
|
||||
/**
|
||||
* Disband the union. The target is unused.
|
||||
*/
|
||||
DISBAND,
|
||||
/**
|
||||
* Move the union's home base. The target is the serialized location.
|
||||
*/
|
||||
SET_HOME,
|
||||
/**
|
||||
* Declare war on another union. The target is that union's tag.
|
||||
*/
|
||||
START_WAR;
|
||||
|
||||
public static @org.jetbrains.annotations.Nullable ProposalType fromName(
|
||||
@org.jetbrains.annotations.Nullable String name)
|
||||
{
|
||||
|
||||
if (name == null) {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
return valueOf(name);
|
||||
|
||||
} catch (IllegalArgumentException ex) {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
package net.trueog.unionsog;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public class Rank implements Comparable<Rank> {
|
||||
|
||||
private String name;
|
||||
private String displayName;
|
||||
private Set<String> permissions;
|
||||
|
||||
public Rank(String name) {
|
||||
|
||||
setName(name);
|
||||
permissions = new HashSet<>();
|
||||
setDisplayName(displayName);
|
||||
|
||||
}
|
||||
|
||||
public Rank(String name, @Nullable String displayName, Set<String> permissions) {
|
||||
|
||||
setName(name);
|
||||
setDisplayName(displayName);
|
||||
setPermissions(permissions);
|
||||
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
|
||||
if (name == null || name.isEmpty()) {
|
||||
|
||||
throw new IllegalArgumentException("name cannot be null or empty");
|
||||
|
||||
}
|
||||
|
||||
this.name = name;
|
||||
|
||||
}
|
||||
|
||||
public void setDisplayName(@Nullable String displayName) {
|
||||
|
||||
if (displayName == null || displayName.isEmpty()) {
|
||||
|
||||
displayName = name;
|
||||
|
||||
}
|
||||
|
||||
this.displayName = displayName;
|
||||
|
||||
}
|
||||
|
||||
public void setPermissions(Set<String> permissions) {
|
||||
|
||||
if (permissions == null) {
|
||||
|
||||
permissions = new HashSet<>();
|
||||
|
||||
}
|
||||
|
||||
this.permissions = permissions;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Rank other = (Rank) obj;
|
||||
if (name == null) {
|
||||
|
||||
if (other.name != null)
|
||||
return false;
|
||||
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rank's permissions
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<String> getPermissions() {
|
||||
|
||||
return permissions;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rank's display name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
|
||||
return displayName;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rank's name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
|
||||
return name;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Rank other) {
|
||||
|
||||
return Integer.compare(permissions.size(), other.permissions.size());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package net.trueog.unionsog;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*
|
||||
*/
|
||||
public enum RankPermission {
|
||||
|
||||
ALLY_ADD("unionsog.leader.ally", PermissionLevel.LEADER),
|
||||
ALLY_CHAT("unionsog.member.ally", PermissionLevel.TRUSTED),
|
||||
ALLY_REMOVE("unionsog.leader.ally", PermissionLevel.LEADER),
|
||||
BANK_BALANCE("unionsog.member.bank", PermissionLevel.TRUSTED),
|
||||
BANK_DEPOSIT("unionsog.member.bank", PermissionLevel.LEADER),
|
||||
BANK_WITHDRAW("unionsog.member.bank", PermissionLevel.LEADER),
|
||||
BB_ADD("unionsog.member.bb-add", PermissionLevel.TRUSTED),
|
||||
BB_CLEAR("unionsog.leader.bb-clear", PermissionLevel.LEADER),
|
||||
COORDS("unionsog.member.coords", PermissionLevel.TRUSTED),
|
||||
REGROUP_HOME("unionsog.leader.regroup.home", PermissionLevel.LEADER),
|
||||
REGROUP_ME("unionsog.leader.regroup.me", PermissionLevel.LEADER),
|
||||
HOME_SET("unionsog.leader.home-set", PermissionLevel.LEADER),
|
||||
HOME_TP("unionsog.member.home", PermissionLevel.TRUSTED), INVITE("unionsog.leader.invite", PermissionLevel.LEADER),
|
||||
KICK("unionsog.leader.kick", PermissionLevel.LEADER), COLOR("unionsog.leader.color", PermissionLevel.LEADER),
|
||||
RANK_DISPLAYNAME("unionsog.leader.rank.setdisplayname", PermissionLevel.LEADER),
|
||||
RANK_LIST("unionsog.leader.rank.list", PermissionLevel.LEADER),
|
||||
RIVAL_ADD("unionsog.leader.rival", PermissionLevel.LEADER),
|
||||
RIVAL_REMOVE("unionsog.leader.rival", PermissionLevel.LEADER),
|
||||
WAR_END("unionsog.leader.war", PermissionLevel.LEADER), WAR_START("unionsog.leader.war", PermissionLevel.LEADER),
|
||||
STATS("unionsog.member.stats", PermissionLevel.TRUSTED), VITALS("unionsog.member.vitals", PermissionLevel.TRUSTED),
|
||||
KILLS("unionsog.member.kills", PermissionLevel.TRUSTED),
|
||||
DESCRIPTION("unionsog.leader.description", PermissionLevel.LEADER),
|
||||
MOSTKILLED("unionsog.mod.mostkilled", PermissionLevel.TRUSTED),
|
||||
FRIENDLYFIRE("unionsog.leader.ff", PermissionLevel.LEADER),
|
||||
SETBANNER("unionsog.leader.setbanner", PermissionLevel.LEADER);
|
||||
|
||||
private final String bukkitPermission;
|
||||
private final PermissionLevel permissionLevel;
|
||||
|
||||
RankPermission(String bukkitPermission, PermissionLevel permissionLevel) {
|
||||
|
||||
this.bukkitPermission = bukkitPermission;
|
||||
this.permissionLevel = permissionLevel;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the Bukkit equivalent to this rank permission
|
||||
*/
|
||||
public String getBukkitPermission() {
|
||||
|
||||
return bukkitPermission;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the PermissionLevel
|
||||
*
|
||||
*/
|
||||
public PermissionLevel getPermissionLevel() {
|
||||
|
||||
return permissionLevel;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return super.toString().replace("_", ".").toLowerCase();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param permission the permission
|
||||
* @return true if this is a valid rank permission
|
||||
*/
|
||||
@Contract("null -> false")
|
||||
public static boolean isValid(@Nullable String permission) {
|
||||
|
||||
for (RankPermission p : values()) {
|
||||
|
||||
if (p.toString().equalsIgnoreCase(permission)) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,21 +13,21 @@ import static net.trueog.unionsog.managers.SettingsManager.ConfigField.REQUEST_M
|
||||
*/
|
||||
public final class Request {
|
||||
|
||||
private List<ClanPlayer> acceptors = new ArrayList<>();
|
||||
private Clan clan;
|
||||
private List<UnionPlayer> acceptors = new ArrayList<>();
|
||||
private Union union;
|
||||
private String msg;
|
||||
private String target;
|
||||
private ClanRequest type;
|
||||
private ClanPlayer requester;
|
||||
private UnionRequest type;
|
||||
private UnionPlayer requester;
|
||||
private int askCount;
|
||||
|
||||
public Request(ClanRequest type, @Nullable List<ClanPlayer> acceptors, ClanPlayer requester, String target,
|
||||
Clan clan, String msg)
|
||||
public Request(UnionRequest type, @Nullable List<UnionPlayer> acceptors, UnionPlayer requester, String target,
|
||||
Union union, String msg)
|
||||
{
|
||||
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
this.clan = clan;
|
||||
this.union = union;
|
||||
this.msg = msg;
|
||||
if (acceptors != null) {
|
||||
|
||||
@@ -44,7 +44,7 @@ public final class Request {
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public ClanRequest getType() {
|
||||
public UnionRequest getType() {
|
||||
|
||||
return type;
|
||||
|
||||
@@ -53,7 +53,7 @@ public final class Request {
|
||||
/**
|
||||
* @param type the type to set
|
||||
*/
|
||||
public void setType(ClanRequest type) {
|
||||
public void setType(UnionRequest type) {
|
||||
|
||||
this.type = type;
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class Request {
|
||||
/**
|
||||
* @return the acceptors
|
||||
*/
|
||||
public List<ClanPlayer> getAcceptors() {
|
||||
public List<UnionPlayer> getAcceptors() {
|
||||
|
||||
return Collections.unmodifiableList(acceptors);
|
||||
|
||||
@@ -71,27 +71,27 @@ public final class Request {
|
||||
/**
|
||||
* @param acceptors the acceptors to set
|
||||
*/
|
||||
public void setAcceptors(List<ClanPlayer> acceptors) {
|
||||
public void setAcceptors(List<UnionPlayer> acceptors) {
|
||||
|
||||
this.acceptors = acceptors;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the clan
|
||||
* @return the union
|
||||
*/
|
||||
public Clan getClan() {
|
||||
public Union getUnion() {
|
||||
|
||||
return clan;
|
||||
return union;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clan the clan to set
|
||||
* @param union the union to set
|
||||
*/
|
||||
public void setClan(Clan clan) {
|
||||
public void setUnion(Union union) {
|
||||
|
||||
this.clan = clan;
|
||||
this.union = union;
|
||||
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public final class Request {
|
||||
|
||||
public void vote(String playerName, VoteResult vote) {
|
||||
|
||||
for (ClanPlayer cp : acceptors) {
|
||||
for (UnionPlayer cp : acceptors) {
|
||||
|
||||
if (cp.getName().equalsIgnoreCase(playerName)) {
|
||||
|
||||
@@ -148,7 +148,7 @@ public final class Request {
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
public boolean votingFinished() {
|
||||
|
||||
for (ClanPlayer cp : acceptors) {
|
||||
for (UnionPlayer cp : acceptors) {
|
||||
|
||||
if (cp.getVote() == null) {
|
||||
|
||||
@@ -166,7 +166,7 @@ public final class Request {
|
||||
|
||||
List<String> out = new ArrayList<>();
|
||||
|
||||
for (ClanPlayer cp : acceptors) {
|
||||
for (UnionPlayer cp : acceptors) {
|
||||
|
||||
if (cp.getVote() != null && cp.getVote().equals(VoteResult.DENY)) {
|
||||
|
||||
@@ -184,7 +184,7 @@ public final class Request {
|
||||
|
||||
List<String> out = new ArrayList<>();
|
||||
|
||||
for (ClanPlayer cp : acceptors) {
|
||||
for (UnionPlayer cp : acceptors) {
|
||||
|
||||
if (cp.getVote() != null && cp.getVote().equals(VoteResult.ACCEPT)) {
|
||||
|
||||
@@ -203,7 +203,7 @@ public final class Request {
|
||||
*/
|
||||
public void cleanVotes() {
|
||||
|
||||
for (ClanPlayer cp : acceptors) {
|
||||
for (UnionPlayer cp : acceptors) {
|
||||
|
||||
cp.setVote(null);
|
||||
|
||||
@@ -214,7 +214,7 @@ public final class Request {
|
||||
/**
|
||||
* @return the requester
|
||||
*/
|
||||
public ClanPlayer getRequester() {
|
||||
public UnionPlayer getRequester() {
|
||||
|
||||
return requester;
|
||||
|
||||
@@ -223,7 +223,7 @@ public final class Request {
|
||||
/**
|
||||
* @param requester the requester to set
|
||||
*/
|
||||
public void setRequester(ClanPlayer requester) {
|
||||
public void setRequester(UnionPlayer requester) {
|
||||
|
||||
this.requester = requester;
|
||||
|
||||
|
||||
@@ -11,15 +11,15 @@ public class TeleportState {
|
||||
private final Location origin;
|
||||
private final Location destination;
|
||||
private int counter;
|
||||
private final String clanName;
|
||||
private final String unionName;
|
||||
private boolean processing;
|
||||
|
||||
public TeleportState(Player player, Location destination, String clanName, int counter) {
|
||||
public TeleportState(Player player, Location destination, String unionName, int counter) {
|
||||
|
||||
this.offlinePlayer = player;
|
||||
this.destination = destination;
|
||||
this.origin = player.getLocation();
|
||||
this.clanName = clanName;
|
||||
this.unionName = unionName;
|
||||
this.counter = counter;
|
||||
|
||||
}
|
||||
@@ -71,9 +71,9 @@ public class TeleportState {
|
||||
|
||||
}
|
||||
|
||||
public String getClanName() {
|
||||
public String getUnionName() {
|
||||
|
||||
return this.clanName;
|
||||
return this.unionName;
|
||||
|
||||
}
|
||||
|
||||
|
||||
+233
-559
File diff suppressed because it is too large.
Load diff
+78
-161
@@ -26,34 +26,33 @@ import static net.trueog.unionsog.managers.SettingsManager.ConfigField.*;
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
public class UnionPlayer implements Serializable, Comparable<UnionPlayer> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private UUID uniqueId;
|
||||
private String displayName;
|
||||
private boolean leader;
|
||||
private boolean trusted;
|
||||
private String tag;
|
||||
private @Nullable Clan clan;
|
||||
private @Nullable Union union;
|
||||
private boolean friendlyFire;
|
||||
private final Map<Kill.Type, Integer> kills = new HashMap<>();
|
||||
private int deaths;
|
||||
private long lastSeen;
|
||||
private long joinDate;
|
||||
private final Set<String> pastClans = new LinkedHashSet<>();
|
||||
private final Set<String> pastUnions = new LinkedHashSet<>();
|
||||
private final Map<String, Long> resignTimes = new HashMap<>();
|
||||
private @Nullable VoteResult vote;
|
||||
private Flags flags = new Flags(null);
|
||||
|
||||
private boolean allyChatMute = false;
|
||||
private boolean clanChatMute = false;
|
||||
private boolean unionChatMute = false;
|
||||
|
||||
private @Nullable Locale locale;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ClanPlayer() {
|
||||
public UnionPlayer() {
|
||||
|
||||
this.tag = "";
|
||||
|
||||
@@ -63,7 +62,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public ClanPlayer(String playerName) {
|
||||
public UnionPlayer(String playerName) {
|
||||
|
||||
this(Bukkit.getOfflinePlayer(playerName).getUniqueId());
|
||||
|
||||
@@ -72,7 +71,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
/**
|
||||
* @param uuid the Player's UUID
|
||||
*/
|
||||
public ClanPlayer(UUID uuid) {
|
||||
public UnionPlayer(UUID uuid) {
|
||||
|
||||
uniqueId = uuid;
|
||||
Player onlinePlayer = UnionsOG.getInstance().getServer().getPlayer(uuid);
|
||||
@@ -103,19 +102,19 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (!(obj instanceof ClanPlayer)) {
|
||||
if (!(obj instanceof UnionPlayer)) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
ClanPlayer other = (ClanPlayer) obj;
|
||||
UnionPlayer other = (UnionPlayer) obj;
|
||||
return other.getName().equals(getName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ClanPlayer other) {
|
||||
public int compareTo(UnionPlayer other) {
|
||||
|
||||
return getUniqueId().compareTo(other.getUniqueId());
|
||||
|
||||
@@ -185,46 +184,17 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this player is a leader or not
|
||||
*
|
||||
* @return the leader
|
||||
*/
|
||||
@Placeholder("is_leader")
|
||||
public boolean isLeader() {
|
||||
|
||||
return leader;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this player as a leader (does not update clanplayer to db)
|
||||
*
|
||||
* @param leader the leader to set
|
||||
*/
|
||||
public void setLeader(boolean leader) {
|
||||
|
||||
if (leader) {
|
||||
|
||||
trusted = true;
|
||||
|
||||
}
|
||||
|
||||
this.leader = leader;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the player is an ally with another player
|
||||
*/
|
||||
public boolean isAlly(Player player) {
|
||||
|
||||
ClanPlayer allycp = UnionsOG.getInstance().getClanManager().getClanPlayer(player);
|
||||
UnionPlayer allycp = UnionsOG.getInstance().getUnionManager().getUnionPlayer(player);
|
||||
|
||||
if (allycp != null) {
|
||||
|
||||
// noinspection ConstantConditions
|
||||
return allycp.getClan().isAlly(tag);
|
||||
return allycp.getUnion().isAlly(tag);
|
||||
|
||||
}
|
||||
|
||||
@@ -237,12 +207,12 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
*/
|
||||
public boolean isRival(Player player) {
|
||||
|
||||
ClanPlayer allycp = UnionsOG.getInstance().getClanManager().getClanPlayer(player);
|
||||
UnionPlayer allycp = UnionsOG.getInstance().getUnionManager().getUnionPlayer(player);
|
||||
|
||||
if (allycp != null) {
|
||||
|
||||
// noinspection ConstantConditions
|
||||
return allycp.getClan().isRival(tag);
|
||||
return allycp.getUnion().isRival(tag);
|
||||
|
||||
}
|
||||
|
||||
@@ -361,7 +331,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds one rival kill to this player (does not update clanplayer to db)
|
||||
* Adds one rival kill to this player (does not update unionplayer to db)
|
||||
*/
|
||||
@Deprecated
|
||||
public void addRivalKill() {
|
||||
@@ -394,7 +364,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds one civilian kill to this player (does not update clanplayer to db)
|
||||
* Adds one civilian kill to this player (does not update unionplayer to db)
|
||||
*/
|
||||
@Deprecated
|
||||
public void addCivilianKill() {
|
||||
@@ -427,7 +397,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds one civilian kill to this player (does not update clanplayer to db)
|
||||
* Adds one civilian kill to this player (does not update unionplayer to db)
|
||||
*/
|
||||
@Deprecated
|
||||
public void addNeutralKill() {
|
||||
@@ -472,7 +442,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
|
||||
/**
|
||||
* Sets whether this player is allowing friendly fire (does not update
|
||||
* clanplayer to db)
|
||||
* unionplayer to db)
|
||||
*
|
||||
* @param friendlyFire the friendlyFire to set
|
||||
*/
|
||||
@@ -528,7 +498,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds one death to this player (does not update clanplayer to db)
|
||||
* Adds one death to this player (does not update unionplayer to db)
|
||||
*/
|
||||
public void addDeath() {
|
||||
|
||||
@@ -578,8 +548,8 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player's join date to his current clan in milliseconds, 0 if not
|
||||
* in a clan
|
||||
* Returns the player's join date to his current union in milliseconds, 0 if not
|
||||
* in a union
|
||||
*
|
||||
* @return the joinDate
|
||||
*/
|
||||
@@ -601,7 +571,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the join date, blank if not in a clan
|
||||
* Returns a string representation of the join date, blank if not in a union
|
||||
*/
|
||||
@Placeholder("join_date")
|
||||
public String getJoinDateString() {
|
||||
@@ -663,92 +633,92 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
/**
|
||||
* (used internally)
|
||||
*
|
||||
* @return the PackedPastClans
|
||||
* @return the PackedPastUnions
|
||||
*/
|
||||
public String getPackedPastClans() {
|
||||
public String getPackedPastUnions() {
|
||||
|
||||
return String.join("|", getPastClans());
|
||||
return String.join("|", getPastUnions());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* (used internally)
|
||||
*
|
||||
* @param packedPastClans the packedPastClans to set
|
||||
* @param packedPastUnions the packedPastUnions to set
|
||||
*/
|
||||
public void setPackedPastClans(String packedPastClans) {
|
||||
public void setPackedPastUnions(String packedPastUnions) {
|
||||
|
||||
String[] clans = packedPastClans.split("\\|");
|
||||
Collections.addAll(pastClans, clans);
|
||||
String[] unions = packedPastUnions.split("\\|");
|
||||
Collections.addAll(pastUnions, unions);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a past clan to the player (does not update the clanplayer to db)
|
||||
* Adds a past union to the player (does not update the unionplayer to db)
|
||||
*/
|
||||
public void addPastClan(String tag) {
|
||||
public void addPastUnion(String tag) {
|
||||
|
||||
getPastClans().add(tag);
|
||||
getPastUnions().add(tag);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a past clan from the player (does not update the clanplayer to db)
|
||||
* Removes a past union from the player (does not update the unionplayer to db)
|
||||
*
|
||||
* @param tag is the clan's colored tag
|
||||
* @param tag is the union's colored tag
|
||||
*/
|
||||
public void removePastClan(String tag) {
|
||||
public void removePastUnion(String tag) {
|
||||
|
||||
getPastClans().remove(tag);
|
||||
getPastUnions().remove(tag);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sep the separator
|
||||
* @return a separator delimited string with the color tags for all past clans
|
||||
* @return a separator delimited string with the color tags for all past unions
|
||||
* this player has been in
|
||||
*/
|
||||
@NotNull
|
||||
public String getPastClansString(@NotNull String sep) {
|
||||
public String getPastUnionsString(@NotNull String sep) {
|
||||
|
||||
return getPastClansString(sep, null);
|
||||
return getPastUnionsString(sep, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sep the separator
|
||||
* @param viewer the Player viewing the clan's string
|
||||
* @return a separator delimited string with the color tags for all past clans
|
||||
* @param viewer the Player viewing the union's string
|
||||
* @return a separator delimited string with the color tags for all past unions
|
||||
* this player has been in
|
||||
*/
|
||||
@NotNull
|
||||
public String getPastClansString(String sep, @Nullable Player viewer) {
|
||||
public String getPastUnionsString(String sep, @Nullable Player viewer) {
|
||||
|
||||
if (getPastClans().isEmpty()) {
|
||||
if (getPastUnions().isEmpty()) {
|
||||
|
||||
return lang("none", viewer);
|
||||
|
||||
}
|
||||
|
||||
SettingsManager settings = UnionsOG.getInstance().getSettingsManager();
|
||||
return getPastClans().stream().sorted(Collections.reverseOrder()).limit(settings.getInt(PAST_CLANS_LIMIT))
|
||||
return getPastUnions().stream().sorted(Collections.reverseOrder()).limit(settings.getInt(PAST_UNIONS_LIMIT))
|
||||
.collect(Collectors.joining(sep));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with all past clans color tags this player has been in
|
||||
* Returns a list with all past unions color tags this player has been in
|
||||
*
|
||||
* @return the pastClans
|
||||
* @return the pastUnions
|
||||
*/
|
||||
public Set<String> getPastClans() {
|
||||
public Set<String> getPastUnions() {
|
||||
|
||||
return pastClans;
|
||||
return pastUnions;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map containing the time the player resigned from certain clans
|
||||
* Returns a map containing the time the player resigned from certain unions
|
||||
*
|
||||
* @return the resign times
|
||||
*/
|
||||
@@ -759,7 +729,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time in millis when the player resigned from the clan
|
||||
* Returns the time in millis when the player resigned from the union
|
||||
*
|
||||
* @return the time in millis
|
||||
*/
|
||||
@@ -793,7 +763,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the clan to the resign times map
|
||||
* Adds the union to the resign times map
|
||||
*/
|
||||
public void addResignTime(String tag) {
|
||||
|
||||
@@ -803,41 +773,41 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this player's clan
|
||||
* Returns this player's union
|
||||
*
|
||||
* @return the clan
|
||||
* @return the union
|
||||
*/
|
||||
@Nullable
|
||||
@Placeholder(value = "in_clan", resolver = "not_null_return")
|
||||
public Clan getClan() {
|
||||
public Union getUnion() {
|
||||
|
||||
return clan;
|
||||
return union;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* (used internally)
|
||||
*
|
||||
* @param clan the clan to set
|
||||
* @param union the union to set
|
||||
*/
|
||||
public void setClan(@Nullable Clan clan) {
|
||||
public void setUnion(@Nullable Union union) {
|
||||
|
||||
if (clan == null) {
|
||||
if (union == null) {
|
||||
|
||||
tag = "";
|
||||
|
||||
} else {
|
||||
|
||||
tag = clan.getTag();
|
||||
tag = union.getTag();
|
||||
|
||||
}
|
||||
|
||||
this.clan = clan;
|
||||
this.union = union;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this player's clan's tag. Empty string if he's not in a clan.
|
||||
* Returns this player's union's tag. Empty string if he's not in a union.
|
||||
*
|
||||
* @return the tag
|
||||
*/
|
||||
@@ -849,20 +819,20 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this player's clan's tag label. Empty string if he's not in a clan.
|
||||
* Returns this player's union's tag label. Empty string if he's not in a union.
|
||||
*
|
||||
* @return the tag
|
||||
*/
|
||||
@Placeholder("tag_label")
|
||||
public String getTagLabel() {
|
||||
|
||||
if (clan == null) {
|
||||
if (union == null) {
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
return clan.getTagLabel(isLeader());
|
||||
return union.getTagLabel();
|
||||
|
||||
}
|
||||
|
||||
@@ -880,7 +850,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this player's trusted status (does not update the clanplayer to db)
|
||||
* Sets this player's trusted status (does not update the unionplayer to db)
|
||||
*
|
||||
* @param trusted the trusted to set
|
||||
*/
|
||||
@@ -948,7 +918,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean isClanChat() {
|
||||
public boolean isUnionChat() {
|
||||
|
||||
return true;
|
||||
|
||||
@@ -965,7 +935,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setClanChat(boolean clanChat) {
|
||||
public void setUnionChat(boolean unionChat) {
|
||||
|
||||
}
|
||||
|
||||
@@ -985,7 +955,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
public void setBbEnabled(boolean bbEnabled) {
|
||||
|
||||
flags.put("bb-enabled", bbEnabled);
|
||||
UnionsOG.getInstance().getStorageManager().updateClanPlayer(this);
|
||||
UnionsOG.getInstance().getStorageManager().updateUnionPlayer(this);
|
||||
|
||||
}
|
||||
|
||||
@@ -999,7 +969,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
public void setInviteEnabled(boolean inviteEnabled) {
|
||||
|
||||
flags.put("invite", inviteEnabled);
|
||||
UnionsOG.getInstance().getStorageManager().updateClanPlayer(this);
|
||||
UnionsOG.getInstance().getStorageManager().updateUnionPlayer(this);
|
||||
|
||||
}
|
||||
|
||||
@@ -1026,8 +996,8 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
|
||||
flags.put("hide-tag", tagEnabled);
|
||||
|
||||
UnionsOG.getInstance().getStorageManager().updateClanPlayer(this);
|
||||
UnionsOG.getInstance().getClanManager().updateDisplayName(toPlayer());
|
||||
UnionsOG.getInstance().getStorageManager().updateUnionPlayer(this);
|
||||
UnionsOG.getInstance().getUnionManager().updateDisplayName(toPlayer());
|
||||
|
||||
}
|
||||
|
||||
@@ -1038,59 +1008,6 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
|
||||
}
|
||||
|
||||
@Placeholder("rank_displayname")
|
||||
public String getRankDisplayName() {
|
||||
|
||||
if (clan != null) {
|
||||
|
||||
Rank r = clan.getRank(getRankId());
|
||||
if (r != null) {
|
||||
|
||||
return r.getDisplayName();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
@Placeholder("has_rank")
|
||||
public boolean hasRank() {
|
||||
|
||||
return !getRankId().isEmpty();
|
||||
|
||||
}
|
||||
|
||||
@Placeholder("rank")
|
||||
public @NotNull String getRankId() {
|
||||
|
||||
return flags.getString("rank", "");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rank displayname
|
||||
*/
|
||||
@Deprecated
|
||||
public String getRank() {
|
||||
|
||||
return getRankDisplayName();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rank id
|
||||
*
|
||||
* @param rank the rank id
|
||||
*/
|
||||
public void setRank(@Nullable String rank) {
|
||||
|
||||
flags.put("rank", rank == null ? "" : rank);
|
||||
|
||||
}
|
||||
|
||||
public @Nullable Locale getLocale() {
|
||||
|
||||
return locale;
|
||||
@@ -1121,8 +1038,8 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
|
||||
switch (channel) {
|
||||
|
||||
case CLAN:
|
||||
clanChatMute = b;
|
||||
case UNION:
|
||||
unionChatMute = b;
|
||||
break;
|
||||
case ALLY:
|
||||
allyChatMute = b;
|
||||
@@ -1132,17 +1049,17 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link ClanPlayer#mute(Channel, boolean)}
|
||||
* @deprecated use {@link UnionPlayer#mute(Channel, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMuted(boolean b) {
|
||||
|
||||
clanChatMute = b;
|
||||
unionChatMute = b;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link ClanPlayer#mute(Channel, boolean)}
|
||||
* @deprecated use {@link UnionPlayer#mute(Channel, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMutedAlly(boolean b) {
|
||||
@@ -1154,7 +1071,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
@Placeholder("is_muted")
|
||||
public boolean isMuted() {
|
||||
|
||||
return clanChatMute;
|
||||
return unionChatMute;
|
||||
|
||||
}
|
||||
|
||||
@@ -1199,7 +1116,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
public enum Channel {
|
||||
CLAN, ALLY, NONE
|
||||
UNION, ALLY, NONE
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.trueog.unionsog;
|
||||
|
||||
/**
|
||||
* Requests that are sent to another union and resolved by the first member of
|
||||
* that union who answers.
|
||||
* <p>
|
||||
* Decisions that only concern a union's own members are not requests, they are
|
||||
* {@link Proposal}s and need a consensus of that union's members.
|
||||
* </p>
|
||||
*
|
||||
* @author phaed
|
||||
*/
|
||||
public enum UnionRequest {
|
||||
INVITE, CREATE_ALLY, BREAK_RIVALRY, END_WAR
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.trueog.unionsog;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import net.trueog.unionsog.commands.GroupAliasCommand;
|
||||
import net.trueog.unionsog.commands.SCCommandManager;
|
||||
import net.trueog.unionsog.hooks.papi.UnionsOGExpansion;
|
||||
import net.trueog.unionsog.hooks.papi.UnionsOGMiniPlaceholders;
|
||||
@@ -22,6 +23,7 @@ import net.trueog.unionsog.utils.ChatUtils;
|
||||
import net.trueog.unionsog.utils.TagValidator;
|
||||
import net.trueog.unionsog.uuid.UUIDMigration;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -50,8 +52,9 @@ public class UnionsOG extends JavaPlugin {
|
||||
private static LanguageResource languageResource;
|
||||
private static final Logger logger = Logger.getLogger("Unions-OG");
|
||||
private SCCommandManager commandManager;
|
||||
private ClanManager clanManager;
|
||||
private UnionManager unionManager;
|
||||
private RequestManager requestManager;
|
||||
private ProposalManager proposalManager;
|
||||
private StorageManager storageManager;
|
||||
private SettingsManager settingsManager;
|
||||
private PermissionsManager permissionsManager;
|
||||
@@ -124,7 +127,7 @@ public class UnionsOG extends JavaPlugin {
|
||||
|
||||
permissionsManager = new PermissionsManager();
|
||||
requestManager = new RequestManager();
|
||||
clanManager = new ClanManager();
|
||||
unionManager = new UnionManager();
|
||||
proxyManager = new BungeeManager(this);
|
||||
try {
|
||||
|
||||
@@ -138,6 +141,7 @@ public class UnionsOG extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
proposalManager = new ProposalManager();
|
||||
teleportManager = new TeleportManager();
|
||||
protectionManager = new ProtectionManager();
|
||||
protectionManager.registerListeners();
|
||||
@@ -151,6 +155,8 @@ public class UnionsOG extends JavaPlugin {
|
||||
new UnionBankZeroMigration(this).migrate();
|
||||
// TODO: end
|
||||
|
||||
registerGroupAliases();
|
||||
|
||||
tagValidator = new TagValidator(settingsManager, permissionsManager);
|
||||
|
||||
logStatus();
|
||||
@@ -161,13 +167,34 @@ public class UnionsOG extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Points other group plugins' command words at {@code /union}.
|
||||
*/
|
||||
private void registerGroupAliases() {
|
||||
|
||||
GroupAliasCommand executor = new GroupAliasCommand();
|
||||
for (String alias : GroupAliasCommand.ALIASES) {
|
||||
|
||||
PluginCommand command = getCommand(alias);
|
||||
if (command == null) {
|
||||
|
||||
getLogger().warning("Group alias /" + alias + " is not registered in plugin.yml, skipping it.");
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
command.setExecutor(executor);
|
||||
command.setTabCompleter(executor);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void logStatus() {
|
||||
|
||||
getLogger().info("Multithreading: " + settingsManager.is(PERFORMANCE_USE_THREADS));
|
||||
getLogger().info("BungeeCord: " + settingsManager.is(PERFORMANCE_USE_BUNGEECORD));
|
||||
getLogger().info("HEX support: " + ChatUtils.HEX_COLOR_SUPPORT);
|
||||
getLogger().info(
|
||||
"Help us translate Unions-OG to your language! " + "Access https://crowdin.com/project/simpleclans/");
|
||||
|
||||
}
|
||||
|
||||
@@ -249,11 +276,11 @@ public class UnionsOG extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the clanManager
|
||||
* @return the unionManager
|
||||
*/
|
||||
public ClanManager getClanManager() {
|
||||
public UnionManager getUnionManager() {
|
||||
|
||||
return clanManager;
|
||||
return unionManager;
|
||||
|
||||
}
|
||||
|
||||
@@ -266,6 +293,15 @@ public class UnionsOG extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the proposalManager
|
||||
*/
|
||||
public ProposalManager getProposalManager() {
|
||||
|
||||
return proposalManager;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the storageManager
|
||||
*/
|
||||
@@ -343,14 +379,14 @@ public class UnionsOG extends JavaPlugin {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String optionalLang(@NotNull String key, @Nullable ClanPlayer clanPlayer, Object... arguments) {
|
||||
public static String optionalLang(@NotNull String key, @Nullable UnionPlayer unionPlayer, Object... arguments) {
|
||||
|
||||
Locale locale = instance.getSettingsManager().getLanguage();
|
||||
if (clanPlayer != null && clanPlayer.getLocale() != null
|
||||
if (unionPlayer != null && unionPlayer.getLocale() != null
|
||||
&& instance.getSettingsManager().is(LANGUAGE_SELECTOR))
|
||||
{
|
||||
|
||||
locale = clanPlayer.getLocale();
|
||||
locale = unionPlayer.getLocale();
|
||||
|
||||
}
|
||||
|
||||
@@ -376,14 +412,14 @@ public class UnionsOG extends JavaPlugin {
|
||||
@Nullable
|
||||
public static String optionalLang(@NotNull String key, @Nullable Player player, Object... arguments) {
|
||||
|
||||
ClanPlayer clanPlayer = null;
|
||||
UnionPlayer unionPlayer = null;
|
||||
if (player != null) {
|
||||
|
||||
clanPlayer = instance.getClanManager().getAnyClanPlayer(player.getUniqueId());
|
||||
unionPlayer = instance.getUnionManager().getAnyUnionPlayer(player.getUniqueId());
|
||||
|
||||
}
|
||||
|
||||
return optionalLang(key, clanPlayer, arguments);
|
||||
return optionalLang(key, unionPlayer, arguments);
|
||||
|
||||
}
|
||||
|
||||
@@ -396,9 +432,9 @@ public class UnionsOG extends JavaPlugin {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String lang(@NotNull String key, @Nullable ClanPlayer clanPlayer, Object... arguments) {
|
||||
public static String lang(@NotNull String key, @Nullable UnionPlayer unionPlayer, Object... arguments) {
|
||||
|
||||
String lang = optionalLang(key, clanPlayer, arguments);
|
||||
String lang = optionalLang(key, unionPlayer, arguments);
|
||||
return (lang == null) ? key : lang;
|
||||
|
||||
}
|
||||
|
||||
@@ -9,36 +9,36 @@ import java.util.Map;
|
||||
|
||||
public class War {
|
||||
|
||||
private final Map<Clan, Integer> clans = new HashMap<>();
|
||||
private final Map<Union, Integer> unions = new HashMap<>();
|
||||
|
||||
public War(@NotNull Clan clan1, @NotNull Clan clan2) {
|
||||
public War(@NotNull Union union1, @NotNull Union union2) {
|
||||
|
||||
clans.put(clan1, 0);
|
||||
clans.put(clan2, 0);
|
||||
unions.put(union1, 0);
|
||||
unions.put(union2, 0);
|
||||
|
||||
}
|
||||
|
||||
public List<Clan> getClans() {
|
||||
public List<Union> getUnions() {
|
||||
|
||||
return new ArrayList<>(clans.keySet());
|
||||
return new ArrayList<>(unions.keySet());
|
||||
|
||||
}
|
||||
|
||||
public int getTotalCasualties() {
|
||||
|
||||
return clans.values().stream().mapToInt(value -> value).sum();
|
||||
return unions.values().stream().mapToInt(value -> value).sum();
|
||||
|
||||
}
|
||||
|
||||
public int getCasualties(@NotNull Clan clan) {
|
||||
public int getCasualties(@NotNull Union union) {
|
||||
|
||||
return clans.getOrDefault(clan, 0);
|
||||
return unions.getOrDefault(union, 0);
|
||||
|
||||
}
|
||||
|
||||
public void increaseCasualties(@NotNull Clan clan) {
|
||||
public void increaseCasualties(@NotNull Union union) {
|
||||
|
||||
clans.computeIfPresent(clan, (c, i) -> i + 1);
|
||||
unions.computeIfPresent(union, (c, i) -> i + 1);
|
||||
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class War {
|
||||
|
||||
if (obj instanceof War) {
|
||||
|
||||
return clans.equals(((War) obj).clans);
|
||||
return unions.equals(((War) obj).unions);
|
||||
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class War {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
return clans.hashCode();
|
||||
return unions.hashCode();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.trueog.unionsog.chat;
|
||||
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -9,22 +9,22 @@ import java.util.List;
|
||||
public class SCMessage implements Cloneable {
|
||||
|
||||
private final Source source;
|
||||
private final ClanPlayer.Channel channel;
|
||||
private final ClanPlayer sender;
|
||||
private List<ClanPlayer> receivers;
|
||||
private final UnionPlayer.Channel channel;
|
||||
private final UnionPlayer sender;
|
||||
private List<UnionPlayer> receivers;
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* Creates a message with initial parameters
|
||||
*
|
||||
* @param source The source of message
|
||||
* @param channel The channel of clan player
|
||||
* @param sender The clan player sender
|
||||
* @param channel The channel of union player
|
||||
* @param sender The union player sender
|
||||
* @param content The content of message
|
||||
* @param receivers The clan players, who will receive the content
|
||||
* @param receivers The union players, who will receive the content
|
||||
*/
|
||||
public SCMessage(@NotNull Source source, @NotNull ClanPlayer.Channel channel, @NotNull ClanPlayer sender,
|
||||
String content, @NotNull List<ClanPlayer> receivers)
|
||||
public SCMessage(@NotNull Source source, @NotNull UnionPlayer.Channel channel, @NotNull UnionPlayer sender,
|
||||
String content, @NotNull List<UnionPlayer> receivers)
|
||||
{
|
||||
|
||||
this.source = source;
|
||||
@@ -38,10 +38,10 @@ public class SCMessage implements Cloneable {
|
||||
/**
|
||||
* Creates a new SCMessage without receivers
|
||||
*
|
||||
* @see SCMessage#SCMessage(Source, ClanPlayer.Channel, ClanPlayer, String,
|
||||
* @see SCMessage#SCMessage(Source, UnionPlayer.Channel, UnionPlayer, String,
|
||||
* List) instantiate with initial receievers
|
||||
*/
|
||||
public SCMessage(@NotNull Source source, @NotNull ClanPlayer.Channel channel, @NotNull ClanPlayer sender,
|
||||
public SCMessage(@NotNull Source source, @NotNull UnionPlayer.Channel channel, @NotNull UnionPlayer sender,
|
||||
String content)
|
||||
{
|
||||
|
||||
@@ -49,13 +49,13 @@ public class SCMessage implements Cloneable {
|
||||
|
||||
}
|
||||
|
||||
public ClanPlayer.Channel getChannel() {
|
||||
public UnionPlayer.Channel getChannel() {
|
||||
|
||||
return channel;
|
||||
|
||||
}
|
||||
|
||||
public ClanPlayer getSender() {
|
||||
public UnionPlayer getSender() {
|
||||
|
||||
return sender;
|
||||
|
||||
@@ -73,7 +73,7 @@ public class SCMessage implements Cloneable {
|
||||
|
||||
}
|
||||
|
||||
public List<ClanPlayer> getReceivers() {
|
||||
public List<UnionPlayer> getReceivers() {
|
||||
|
||||
return receivers;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class SCMessage implements Cloneable {
|
||||
|
||||
}
|
||||
|
||||
public void setReceivers(@NotNull List<ClanPlayer> receivers) {
|
||||
public void setReceivers(@NotNull List<UnionPlayer> receivers) {
|
||||
|
||||
this.receivers = receivers;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.trueog.unionsog.chat.handlers;
|
||||
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel;
|
||||
import github.scarsz.discordsrv.util.DiscordUtil;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.chat.ChatHandler;
|
||||
import net.trueog.unionsog.chat.SCMessage;
|
||||
import net.trueog.unionsog.hooks.discord.DiscordHook;
|
||||
@@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import static net.trueog.unionsog.ClanPlayer.Channel.CLAN;
|
||||
import static net.trueog.unionsog.UnionPlayer.Channel.UNION;
|
||||
import static net.trueog.unionsog.chat.SCMessage.Source;
|
||||
import static net.trueog.unionsog.chat.SCMessage.Source.SPIGOT;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.DISCORDCHAT_FORMAT_TO;
|
||||
@@ -26,7 +26,7 @@ public class DiscordChatHandler implements ChatHandler {
|
||||
@Override
|
||||
public void sendMessage(@NotNull SCMessage message) {
|
||||
|
||||
if (message.getChannel() != CLAN) {
|
||||
if (message.getChannel() != UNION) {
|
||||
|
||||
return;
|
||||
|
||||
@@ -35,15 +35,15 @@ public class DiscordChatHandler implements ChatHandler {
|
||||
String format = settingsManager.getString(DISCORDCHAT_FORMAT_TO);
|
||||
String formattedMessage = ChatUtils.stripColors(chatManager.parseChatFormat(format, message));
|
||||
|
||||
Clan clan = message.getSender().getClan();
|
||||
if (clan == null) {
|
||||
Union union = message.getSender().getUnion();
|
||||
if (union == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
DiscordHook discordHook = Objects.requireNonNull(chatManager.getDiscordHook(), "DiscordHook cannot be null");
|
||||
Optional<TextChannel> channel = discordHook.getCachedChannel(clan.getTag());
|
||||
Optional<TextChannel> channel = discordHook.getCachedChannel(union.getTag());
|
||||
channel.ifPresent(textChannel -> DiscordUtil.sendMessage(textChannel, formattedMessage));
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.trueog.unionsog.chat.handlers;
|
||||
|
||||
import net.trueog.unionsog.ChatBlock;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import net.trueog.unionsog.chat.ChatHandler;
|
||||
import net.trueog.unionsog.chat.SCMessage;
|
||||
import net.trueog.unionsog.events.ChatEvent;
|
||||
@@ -47,7 +47,7 @@ public class SpigotChatHandler implements ChatHandler {
|
||||
|
||||
plugin.getLogger().info(ChatUtils.stripColors(formattedMessage));
|
||||
|
||||
for (ClanPlayer cp : message.getReceivers()) {
|
||||
for (UnionPlayer cp : message.getReceivers()) {
|
||||
|
||||
ChatBlock.sendMessage(cp, formattedMessage);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class SpigotChatHandler implements ChatHandler {
|
||||
|
||||
}
|
||||
|
||||
private String stripColorsAndFormatsPerPermission(ClanPlayer sender, String message) {
|
||||
private String stripColorsAndFormatsPerPermission(UnionPlayer sender, String message) {
|
||||
|
||||
if (!permissionsManager.has(sender.toPlayer(), "unionsog.member.chat.color")) {
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.trueog.unionsog.chat.handlers;
|
||||
|
||||
import net.trueog.unionsog.ChatBlock;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import net.trueog.unionsog.chat.ChatHandler;
|
||||
import net.trueog.unionsog.chat.SCMessage;
|
||||
import net.trueog.unionsog.utils.ChatUtils;
|
||||
@@ -32,9 +32,9 @@ public class SpyChatHandler implements ChatHandler {
|
||||
message.setContent(ChatUtils.stripColors(message.getContent()));
|
||||
String formattedMessage = chatManager.parseChatFormat(format, message);
|
||||
|
||||
List<ClanPlayer> onlineSpies = getOnlineSpies();
|
||||
List<UnionPlayer> onlineSpies = getOnlineSpies();
|
||||
|
||||
// Don't send a duplicate message if a spy is inside the clan
|
||||
// Don't send a duplicate message if a spy is inside the union
|
||||
onlineSpies.removeAll(message.getReceivers());
|
||||
onlineSpies.forEach(receiver -> ChatBlock.sendMessage(receiver, formattedMessage));
|
||||
|
||||
@@ -48,12 +48,12 @@ public class SpyChatHandler implements ChatHandler {
|
||||
|
||||
}
|
||||
|
||||
private List<ClanPlayer> getOnlineSpies() {
|
||||
private List<UnionPlayer> getOnlineSpies() {
|
||||
|
||||
return new ArrayList<>(Bukkit.getOnlinePlayers()).stream().filter(Objects::nonNull)
|
||||
.filter(player -> permissionsManager.has(player, "unionsog.admin.all-seeing-eye"))
|
||||
.map(player -> plugin.getClanManager().getCreateClanPlayer(player.getUniqueId()))
|
||||
.filter(Objects::nonNull).filter(clanPlayer -> !clanPlayer.isMuted()).collect(Collectors.toList());
|
||||
.map(player -> plugin.getUnionManager().getCreateUnionPlayer(player.getUniqueId()))
|
||||
.filter(Objects::nonNull).filter(unionPlayer -> !unionPlayer.isMuted()).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
package net.trueog.unionsog.commands;
|
||||
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ClanPlayerInput {
|
||||
|
||||
private final ClanPlayer clanPlayer;
|
||||
|
||||
public ClanPlayerInput(@NotNull ClanPlayer clanPlayer) {
|
||||
|
||||
this.clanPlayer = clanPlayer;
|
||||
|
||||
}
|
||||
|
||||
public ClanPlayer getClanPlayer() {
|
||||
|
||||
return clanPlayer;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
ClanPlayerInput that = (ClanPlayerInput) o;
|
||||
return clanPlayer.equals(that.clanPlayer);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
return Objects.hash(clanPlayer);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package net.trueog.unionsog.commands;
|
||||
|
||||
import net.trueog.unionsog.ChatBlock;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.COMMANDS_UNION;
|
||||
|
||||
/**
|
||||
* Points players at {@code /union} when they reach for another server's word
|
||||
* for the same thing, such as {@code /clan} or {@code /guilds}.
|
||||
* <p>
|
||||
* These are registered as plain Bukkit commands rather than command aliases so
|
||||
* they never execute anything: the player is told what to type instead, with
|
||||
* their own arguments carried over.
|
||||
* </p>
|
||||
*/
|
||||
public class GroupAliasCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
/**
|
||||
* Words other group plugins use for a union. Deliberately excludes {@code f},
|
||||
* {@code faction} and {@code guild}, which Utilities-OG already redirects.
|
||||
*/
|
||||
public static final List<String> ALIASES = Collections.unmodifiableList(
|
||||
Arrays.asList("clan", "clans", "factions", "guilds", "party", "tribe", "nation", "crew", "squad", "gang"));
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
String union = UnionsOG.getInstance().getSettingsManager().getString(COMMANDS_UNION);
|
||||
String arguments = args.length == 0 ? "" : " " + String.join(" ", args);
|
||||
|
||||
ChatBlock.sendMessage(sender, lang("use.union.instead", sender, union + arguments, label));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import co.aikar.commands.CommandIssuer;
|
||||
import co.aikar.commands.PaperCommandManager;
|
||||
import co.aikar.locales.MessageKey;
|
||||
import co.aikar.locales.MessageKeyProvider;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import net.trueog.unionsog.Helper;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.completions.AbstractAsyncCompletion;
|
||||
@@ -65,7 +65,7 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
|
||||
private void registerDependencies() {
|
||||
|
||||
registerDependency(ClanManager.class, plugin.getClanManager());
|
||||
registerDependency(UnionManager.class, plugin.getUnionManager());
|
||||
registerDependency(SettingsManager.class, plugin.getSettingsManager());
|
||||
registerDependency(StorageManager.class, plugin.getStorageManager());
|
||||
registerDependency(PermissionsManager.class, plugin.getPermissionsManager());
|
||||
@@ -220,7 +220,7 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
// TODO: start - remove with UnionBankZeroMigration once union bank accounts
|
||||
// exist. Union banks hold no real value yet, so their commands stay
|
||||
// unregistered.
|
||||
if (c == net.trueog.unionsog.commands.clan.BankCommand.class
|
||||
if (c == net.trueog.unionsog.commands.union.BankCommand.class
|
||||
|| c == net.trueog.unionsog.commands.staff.BankCommand.class)
|
||||
{
|
||||
|
||||
@@ -247,24 +247,23 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
private void addReplacements() {
|
||||
|
||||
SettingsManager sm = plugin.getSettingsManager();
|
||||
getCommandReplacements().addReplacements("basic_conditions", "not_blacklisted|not_banned", "clan",
|
||||
getClanCommandAliases(sm), "deny", sm.getString(COMMANDS_DENY) + "|deny", "more",
|
||||
getCommandReplacements().addReplacements("basic_conditions", "not_blacklisted|not_banned", "union",
|
||||
getUnionCommandAliases(sm), "deny", sm.getString(COMMANDS_DENY) + "|deny", "more",
|
||||
sm.getString(COMMANDS_MORE), "ally_chat", sm.getString(COMMANDS_ALLY), "accept",
|
||||
sm.getString(COMMANDS_ACCEPT) + "|accept", "clan_chat", sm.getString(COMMANDS_CLAN_CHAT));
|
||||
sm.getString(COMMANDS_ACCEPT) + "|accept", "union_chat", sm.getString(COMMANDS_UNION_CHAT));
|
||||
|
||||
SUBCOMMANDS.forEach(s -> processReplacement(s, "", ".command", true));
|
||||
COMPLETIONS.forEach(s -> processReplacement(s, "compl:", ".completion", false));
|
||||
|
||||
}
|
||||
|
||||
private String getClanCommandAliases(SettingsManager sm) {
|
||||
private String getUnionCommandAliases(SettingsManager sm) {
|
||||
|
||||
Set<String> aliases = new LinkedHashSet<>();
|
||||
aliases.add(sm.getString(COMMANDS_CLAN));
|
||||
aliases.add(sm.getString(COMMANDS_UNION));
|
||||
aliases.add("union");
|
||||
aliases.add("unions");
|
||||
aliases.add("clan");
|
||||
aliases.add("clans");
|
||||
// clan and clans are not aliases; GroupAliasCommand redirects them.
|
||||
return String.join("|", aliases);
|
||||
|
||||
}
|
||||
@@ -316,7 +315,7 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
|
||||
private void processReplacement(String key, String prefix, String suffix, boolean hasFallback) {
|
||||
|
||||
String replacement = optionalLang(key + suffix, (ClanPlayer) null);
|
||||
String replacement = optionalLang(key + suffix, (UnionPlayer) null);
|
||||
if (replacement == null) {
|
||||
|
||||
replacement = key;
|
||||
@@ -336,16 +335,14 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
|
||||
static {
|
||||
|
||||
SUBCOMMANDS = Arrays.asList("setbanner", "resetkdr", "place", "rank", "home", "war", "regroup", "mostkilled",
|
||||
"kills", "globalff", "reload", "unban", "ban", "disband", "resign", "ff", "clanff", "demote", "promote",
|
||||
"untrust", "trust", "purge", "bank", "kick", "invite", "toggle", "modtag", "bb", "display", "clear",
|
||||
"rival", "ally", "add", "remove", "stats", "coords", "vitals", "rivalries", "alliances", "leaderboard",
|
||||
"allow", "block", "auto", "check", "assign", "unassign", "delete", "me", "setdisplayname",
|
||||
"permissions", "tag", "deposit", "withdraw", "set", "status", "tp", "all", "everyone", "lookup",
|
||||
"roster", "profile", "list", "create", "description", "start", "end", "admin", "help", "mod",
|
||||
"setdefault", "removedefault", "land", "break", "interact", "place_block", "damage", "interact_entity",
|
||||
"container", "permanent", "take", "give", "join", "leave", "mute", "confirm", "balance", "discord",
|
||||
"rename", "locale", "color");
|
||||
SUBCOMMANDS = Arrays.asList("setbanner", "resetkdr", "place", "home", "war", "regroup", "mostkilled", "kills",
|
||||
"globalff", "reload", "unban", "ban", "disband", "resign", "ff", "unionff", "vote", "yes", "no",
|
||||
"purge", "bank", "kick", "invite", "toggle", "modtag", "bb", "display", "clear", "rival", "ally", "add",
|
||||
"remove", "stats", "coords", "vitals", "rivalries", "alliances", "leaderboard", "allow", "block",
|
||||
"auto", "check", "delete", "me", "tag", "deposit", "withdraw", "set", "status", "tp", "all", "everyone",
|
||||
"lookup", "roster", "profile", "list", "create", "description", "start", "end", "admin", "help", "mod",
|
||||
"land", "break", "interact", "place_block", "damage", "interact_entity", "container", "permanent",
|
||||
"take", "give", "join", "leave", "mute", "confirm", "balance", "discord", "rename", "locale", "color");
|
||||
|
||||
COMPLETIONS = Arrays.asList("tag", "name");
|
||||
|
||||
|
||||
+10
-10
@@ -1,23 +1,23 @@
|
||||
package net.trueog.unionsog.commands;
|
||||
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ClanInput {
|
||||
public class UnionInput {
|
||||
|
||||
private final Clan clan;
|
||||
private final Union union;
|
||||
|
||||
public ClanInput(@NotNull Clan clan) {
|
||||
public UnionInput(@NotNull Union union) {
|
||||
|
||||
this.clan = clan;
|
||||
this.union = union;
|
||||
|
||||
}
|
||||
|
||||
public Clan getClan() {
|
||||
public Union getUnion() {
|
||||
|
||||
return clan;
|
||||
return union;
|
||||
|
||||
}
|
||||
|
||||
@@ -28,15 +28,15 @@ public class ClanInput {
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
ClanInput clanInput = (ClanInput) o;
|
||||
return clan.equals(clanInput.clan);
|
||||
UnionInput unionInput = (UnionInput) o;
|
||||
return union.equals(unionInput.union);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
return Objects.hash(clan);
|
||||
return Objects.hash(union);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.trueog.unionsog.commands;
|
||||
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class UnionPlayerInput {
|
||||
|
||||
private final UnionPlayer unionPlayer;
|
||||
|
||||
public UnionPlayerInput(@NotNull UnionPlayer unionPlayer) {
|
||||
|
||||
this.unionPlayer = unionPlayer;
|
||||
|
||||
}
|
||||
|
||||
public UnionPlayer getUnionPlayer() {
|
||||
|
||||
return unionPlayer;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
UnionPlayerInput that = (UnionPlayerInput) o;
|
||||
return unionPlayer.equals(that.unionPlayer);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
return Objects.hash(unionPlayer);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package net.trueog.unionsog.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.trueog.unionsog.ChatBlock;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.managers.ChatManager;
|
||||
import net.trueog.unionsog.managers.SettingsManager;
|
||||
import net.trueog.unionsog.managers.StorageManager;
|
||||
|
||||
import static net.trueog.unionsog.ClanPlayer.Channel.ALLY;
|
||||
import static net.trueog.unionsog.ClanPlayer.Channel.NONE;
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.chat.SCMessage.Source.SPIGOT;
|
||||
|
||||
@CommandAlias("%ally_chat")
|
||||
@Description("{@@command.description.ally}")
|
||||
@CommandPermission("unionsog.member.ally")
|
||||
@Conditions("%basic_conditions|clan_member|can_chat:type=ALLY|rank:name=ALLY_CHAT")
|
||||
public class AllyChatCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private ChatManager chatManager;
|
||||
@Dependency
|
||||
private SettingsManager settingsManager;
|
||||
@Dependency
|
||||
private StorageManager storageManager;
|
||||
|
||||
@Default
|
||||
@HelpSearchTags("chat")
|
||||
public void sendMessage(ClanPlayer cp, @Name("message") String message) {
|
||||
|
||||
chatManager.processChat(SPIGOT, ALLY, cp, message);
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%join")
|
||||
public void join(ClanPlayer clanPlayer) {
|
||||
|
||||
if (clanPlayer.getChannel() == ALLY) {
|
||||
|
||||
ChatBlock.sendMessage(clanPlayer, lang("already.joined.ally.chat"));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
clanPlayer.setChannel(ALLY);
|
||||
storageManager.updateClanPlayer(clanPlayer);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("joined.ally.chat"));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%leave")
|
||||
public void leave(ClanPlayer clanPlayer) {
|
||||
|
||||
if (clanPlayer.getChannel() == ALLY) {
|
||||
|
||||
clanPlayer.setChannel(NONE);
|
||||
storageManager.updateClanPlayer(clanPlayer);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("left.ally.chat", clanPlayer));
|
||||
|
||||
} else {
|
||||
|
||||
ChatBlock.sendMessage(clanPlayer, lang("chat.didnt.join", clanPlayer));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%mute")
|
||||
public void mute(ClanPlayer clanPlayer) {
|
||||
|
||||
if (!clanPlayer.isMutedAlly()) {
|
||||
|
||||
clanPlayer.mute(ALLY, true);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("muted.ally.chat", clanPlayer));
|
||||
|
||||
} else {
|
||||
|
||||
clanPlayer.mute(ALLY, false);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("unmuted.ally.chat", clanPlayer));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
package net.trueog.unionsog.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.trueog.unionsog.ChatBlock;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.managers.ChatManager;
|
||||
import net.trueog.unionsog.managers.StorageManager;
|
||||
|
||||
import static net.trueog.unionsog.ClanPlayer.Channel.CLAN;
|
||||
import static net.trueog.unionsog.ClanPlayer.Channel.NONE;
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.chat.SCMessage.Source.SPIGOT;
|
||||
|
||||
@CommandAlias("%clan_chat")
|
||||
@Conditions("%basic_conditions|clan_member|can_chat:type=CLAN")
|
||||
@CommandPermission("unionsog.member.chat")
|
||||
@Description("{@@command.description.chat}")
|
||||
public class ChatCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private ChatManager chatManager;
|
||||
@Dependency
|
||||
private StorageManager storageManager;
|
||||
|
||||
@Default
|
||||
@HelpSearchTags("chat")
|
||||
public void sendMessage(ClanPlayer cp, @Optional @Name("message") String message) {
|
||||
|
||||
if (message == null || message.isBlank()) {
|
||||
|
||||
toggle(cp);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
chatManager.processChat(SPIGOT, CLAN, cp, message);
|
||||
|
||||
}
|
||||
|
||||
// Bare command flips the player in or out of the union chat channel.
|
||||
private void toggle(ClanPlayer clanPlayer) {
|
||||
|
||||
if (clanPlayer.getChannel() == CLAN) {
|
||||
|
||||
clanPlayer.setChannel(NONE);
|
||||
storageManager.updateClanPlayer(clanPlayer);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("left.clan.chat", clanPlayer));
|
||||
|
||||
} else {
|
||||
|
||||
clanPlayer.setChannel(CLAN);
|
||||
storageManager.updateClanPlayer(clanPlayer);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("joined.clan.chat"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%join")
|
||||
public void join(ClanPlayer clanPlayer) {
|
||||
|
||||
if (clanPlayer.getChannel() == CLAN) {
|
||||
|
||||
ChatBlock.sendMessage(clanPlayer, lang("already.joined.clan.chat"));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
clanPlayer.setChannel(CLAN);
|
||||
storageManager.updateClanPlayer(clanPlayer);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("joined.clan.chat"));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%leave")
|
||||
public void leave(ClanPlayer clanPlayer) {
|
||||
|
||||
if (clanPlayer.getChannel() == CLAN) {
|
||||
|
||||
clanPlayer.setChannel(NONE);
|
||||
storageManager.updateClanPlayer(clanPlayer);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("left.clan.chat", clanPlayer));
|
||||
|
||||
} else {
|
||||
|
||||
ChatBlock.sendMessage(clanPlayer, lang("chat.didnt.join", clanPlayer));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%mute")
|
||||
public void mute(ClanPlayer clanPlayer) {
|
||||
|
||||
if (!clanPlayer.isMuted()) {
|
||||
|
||||
clanPlayer.mute(CLAN, true);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("muted.clan.chat", clanPlayer));
|
||||
|
||||
} else {
|
||||
|
||||
clanPlayer.mute(CLAN, false);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("unmuted.clan.chat", clanPlayer));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,543 +0,0 @@
|
||||
package net.trueog.unionsog.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.trueog.unionsog.*;
|
||||
import net.trueog.unionsog.commands.ClanInput;
|
||||
import net.trueog.unionsog.commands.ClanPlayerInput;
|
||||
import net.trueog.unionsog.conversation.ResignPrompt;
|
||||
import net.trueog.unionsog.conversation.SCConversation;
|
||||
import net.trueog.unionsog.events.TagChangeEvent;
|
||||
import net.trueog.unionsog.managers.*;
|
||||
import net.trueog.unionsog.utils.ChatUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Conditions("%basic_conditions")
|
||||
public class ClanCommands extends BaseCommand {
|
||||
|
||||
private static final Map<String, String> CLAN_COLORS = new LinkedHashMap<>();
|
||||
|
||||
static {
|
||||
|
||||
CLAN_COLORS.put("black", "&0");
|
||||
CLAN_COLORS.put("dark_blue", "&1");
|
||||
CLAN_COLORS.put("dark_green", "&2");
|
||||
CLAN_COLORS.put("dark_aqua", "&3");
|
||||
CLAN_COLORS.put("dark_red", "&4");
|
||||
CLAN_COLORS.put("dark_purple", "&5");
|
||||
CLAN_COLORS.put("gold", "&6");
|
||||
CLAN_COLORS.put("gray", "&7");
|
||||
CLAN_COLORS.put("dark_gray", "&8");
|
||||
CLAN_COLORS.put("blue", "&9");
|
||||
CLAN_COLORS.put("green", "&a");
|
||||
CLAN_COLORS.put("aqua", "&b");
|
||||
CLAN_COLORS.put("red", "&c");
|
||||
CLAN_COLORS.put("light_purple", "&d");
|
||||
CLAN_COLORS.put("yellow", "&e");
|
||||
CLAN_COLORS.put("white", "&f");
|
||||
|
||||
}
|
||||
|
||||
@Dependency
|
||||
private UnionsOG plugin;
|
||||
@Dependency
|
||||
private SettingsManager settings;
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
@Dependency
|
||||
private PermissionsManager permissions;
|
||||
@Dependency
|
||||
private RequestManager requestManager;
|
||||
@Dependency
|
||||
private ProtectionManager protectionManager;
|
||||
|
||||
@Subcommand("%war %start")
|
||||
@CommandPermission("unionsog.leader.war")
|
||||
@Conditions("rank:name=WAR_START")
|
||||
@Description("{@@command.description.war.start}")
|
||||
@CommandCompletion("@rivals")
|
||||
public void startWar(Player player, ClanPlayer requester, Clan requestClan,
|
||||
@Conditions("can_war_target") @Name("clan") ClanInput targetClanInput)
|
||||
{
|
||||
|
||||
Clan targetClan = targetClanInput.getClan();
|
||||
|
||||
List<ClanPlayer> onlineLeaders = Helper.stripOffLinePlayers(requestClan.getLeaders());
|
||||
|
||||
if (settings.is(WAR_START_REQUEST_ENABLED)) {
|
||||
|
||||
if (!onlineLeaders.isEmpty()) {
|
||||
|
||||
requestManager.addWarStartRequest(requester, targetClan, requestClan);
|
||||
ChatBlock.sendMessage(player,
|
||||
AQUA + lang("leaders.have.been.asked.to.accept.the.war.request", player, targetClan.getName()));
|
||||
|
||||
} else {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("at.least.one.leader.accept.the.alliance", player));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
protectionManager.addWar(requester, requestClan, targetClan);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%war %end")
|
||||
@CommandPermission("unionsog.leader.war")
|
||||
@Conditions("rank:name=WAR_END")
|
||||
@Description("{@@command.description.war.end}")
|
||||
@CommandCompletion("@warring_clans")
|
||||
public void endWar(ClanPlayer cp, Clan issuerClan, @Name("clan") ClanInput other) {
|
||||
|
||||
Clan war = other.getClan();
|
||||
if (issuerClan.isWarring(war.getTag())) {
|
||||
|
||||
requestManager.addWarEndRequest(cp, war, issuerClan);
|
||||
ChatBlock.sendMessage(cp, AQUA + lang("leaders.asked.to.end.rivalry", cp, war.getName()));
|
||||
|
||||
} else {
|
||||
|
||||
ChatBlock.sendMessage(cp, RED + lang("clans.not.at.war", cp));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%color")
|
||||
@CommandPermission("unionsog.leader.color")
|
||||
@Conditions("rank:name=COLOR")
|
||||
@CommandCompletion("@clan_colors")
|
||||
@Description("{@@command.description.color}")
|
||||
public void color(Player player, Clan clan, @Name("color") String color) {
|
||||
|
||||
Optional<String> tagColor = resolveTagColor(color);
|
||||
if (tagColor.isEmpty()) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("invalid.color", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
String currentTag = ChatUtils.stripColors(clan.getColorTag());
|
||||
String tag = tagColor.get() + currentTag;
|
||||
TagChangeEvent event = new TagChangeEvent(player, clan, tag);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
tag = event.getNewTag();
|
||||
String cleanTag = ChatUtils.stripColors(tag);
|
||||
|
||||
Optional<String> validationError = plugin.getTagValidator().validate(player, tag, true);
|
||||
if (validationError.isPresent()) {
|
||||
|
||||
ChatBlock.sendMessage(player, validationError.get());
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!cleanTag.equals(currentTag)) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("you.can.only.modify.the.color.of.the.tag", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), lang("tag.changed.to.0", ChatUtils.parseColors(tag)));
|
||||
clan.changeClanTag(tag);
|
||||
cm.updateDisplayName(player);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("clan.color.changed.to.0", player, ChatUtils.parseColors(tag)));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%setbanner")
|
||||
@CommandPermission("unionsog.leader.setbanner")
|
||||
@Conditions("rank:name=SETBANNER")
|
||||
@Description("{@@command.description.setbanner}")
|
||||
public void setbanner(Player player, Clan clan) {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
ItemStack hand = player.getItemInHand();
|
||||
if (!hand.getType().toString().contains("BANNER")) {
|
||||
|
||||
ChatBlock.sendMessageKey(player, "you.must.hold.a.banner");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
clan.setBanner(hand);
|
||||
storage.updateClan(clan);
|
||||
ChatBlock.sendMessageKey(player, "you.changed.clan.banner");
|
||||
|
||||
}
|
||||
|
||||
private Optional<String> resolveTagColor(String input) {
|
||||
|
||||
String normalized = input.toLowerCase(Locale.ROOT);
|
||||
if (CLAN_COLORS.containsKey(normalized)) {
|
||||
|
||||
return Optional.of(CLAN_COLORS.get(normalized));
|
||||
|
||||
}
|
||||
|
||||
if (normalized.matches("#[0-9a-f]{6}")) {
|
||||
|
||||
return Optional.of("&" + normalized);
|
||||
|
||||
}
|
||||
|
||||
if (normalized.matches("&#[0-9a-f]{6}")) {
|
||||
|
||||
return Optional.of(normalized);
|
||||
|
||||
}
|
||||
|
||||
if (normalized.matches("&[0-9a-f]")) {
|
||||
|
||||
return Optional.of(normalized);
|
||||
|
||||
}
|
||||
|
||||
if (normalized.matches("[0-9a-f]")) {
|
||||
|
||||
return Optional.of("&" + normalized);
|
||||
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%invite")
|
||||
@CommandPermission("unionsog.leader.invite")
|
||||
@CommandCompletion("@non_members:ignore_vanished")
|
||||
@Conditions("rank:name=INVITE")
|
||||
@Description("{@@command.description.invite}")
|
||||
public void invite(Player sender, ClanPlayer cp, Clan clan,
|
||||
@Conditions("not_banned|not_in_clan|online:ignore_vanished") @Name("player") ClanPlayerInput invited)
|
||||
{
|
||||
|
||||
if (!invited.getClanPlayer().isInviteEnabled()) {
|
||||
|
||||
ChatBlock.sendMessage(sender, RED + lang("invitedplayer.invite.off", sender));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Player invitedPlayer = invited.getClanPlayer().toPlayer();
|
||||
if (invitedPlayer == null)
|
||||
return;
|
||||
if (!permissions.has(invitedPlayer, "unionsog.member.can-join")) {
|
||||
|
||||
ChatBlock.sendMessage(sender,
|
||||
RED + lang("the.player.doesn.t.not.have.the.permissions.to.join.clans", sender));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (invitedPlayer.getUniqueId().equals(sender.getUniqueId())) {
|
||||
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.cannot.invite.yourself", sender));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
long minutesBeforeRejoin = cm.getMinutesBeforeRejoin(invited.getClanPlayer(), clan);
|
||||
if (minutesBeforeRejoin != 0) {
|
||||
|
||||
ChatBlock.sendMessage(sender,
|
||||
RED + lang("the.player.must.wait.0.before.joining.your.clan.again", sender, minutesBeforeRejoin));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (clan.getSize() >= settings.getInt(CLAN_MAX_MEMBERS) && settings.getInt(CLAN_MAX_MEMBERS) > 0) {
|
||||
|
||||
ChatBlock.sendMessage(sender, RED + lang("the.clan.members.reached.limit", sender));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!cm.purchaseInvite(sender)) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
requestManager.addInviteRequest(cp, invitedPlayer.getName(), clan);
|
||||
ChatBlock.sendMessage(sender,
|
||||
AQUA + lang("has.been.asked.to.join", sender, invitedPlayer.getName(), clan.getName()));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%clanff %allow")
|
||||
@CommandPermission("unionsog.leader.ff")
|
||||
@Conditions("rank:name=FRIENDLYFIRE")
|
||||
@Description("{@@command.description.clanff.allow}")
|
||||
public void allowClanFf(Player player, Clan clan) {
|
||||
|
||||
clan.addBb(player.getName(), lang("clan.wide.friendly.fire.is.allowed"));
|
||||
clan.setFriendlyFire(true);
|
||||
storage.updateClan(clan);
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%clanff %block")
|
||||
@CommandPermission("unionsog.leader.ff")
|
||||
@Description("{@@command.description.clanff.block}")
|
||||
public void blockClanFf(Player player, Clan clan) {
|
||||
|
||||
clan.addBb(player.getName(), lang("clan.wide.friendly.fire.blocked"));
|
||||
clan.setFriendlyFire(false);
|
||||
storage.updateClan(clan);
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%description")
|
||||
@CommandPermission("unionsog.leader.description")
|
||||
@Conditions("rank:name=DESCRIPTION")
|
||||
@Description("{@@command.description.description}")
|
||||
public void setDescription(Player player, Clan clan, @Name("description") String description) {
|
||||
|
||||
if (description.length() < settings.getInt(CLAN_MIN_DESCRIPTION_LENGTH)) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clan.description.must.be.longer.than", player,
|
||||
settings.getInt(CLAN_MIN_DESCRIPTION_LENGTH)));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (description.length() > settings.getInt(CLAN_MAX_DESCRIPTION_LENGTH)) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clan.description.cannot.be.longer.than", player,
|
||||
settings.getInt(CLAN_MAX_DESCRIPTION_LENGTH)));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
clan.setDescription(description);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("description.changed", player));
|
||||
storage.updateClan(clan);
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%rival %add")
|
||||
@CommandPermission("unionsog.leader.rival")
|
||||
@Conditions("rivable|minimum_to_rival|rank:name=RIVAL_ADD")
|
||||
@CommandCompletion("@clans:hide_own")
|
||||
@Description("{@@command.description.rival.add}")
|
||||
public void addRival(Player player, Clan issuerClan, @Conditions("different") @Name("clan") ClanInput rival) {
|
||||
|
||||
Clan rivalInput = rival.getClan();
|
||||
if (settings.isUnrivable(rivalInput.getTag())) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("the.clan.cannot.be.rivaled", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!issuerClan.reachedRivalLimit()) {
|
||||
|
||||
if (!issuerClan.isRival(rivalInput.getTag())) {
|
||||
|
||||
issuerClan.addRival(rivalInput);
|
||||
rivalInput.addBb(player.getName(),
|
||||
lang("has.initiated.a.rivalry", issuerClan.getName(), rivalInput.getName()), false);
|
||||
issuerClan.addBb(player.getName(),
|
||||
lang("has.initiated.a.rivalry", player.getName(), rivalInput.getName()));
|
||||
|
||||
} else {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clans.are.already.rivals", player));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("rival.limit.reached", player));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%rival %remove")
|
||||
@CommandPermission("unionsog.leader.rival")
|
||||
@Conditions("rank:name=RIVAL_REMOVE")
|
||||
@CommandCompletion("@rivals")
|
||||
@Description("{@@command.description.rival.remove}")
|
||||
public void removeRival(Player player, ClanPlayer cp, Clan issuerClan,
|
||||
@Conditions("different") @Name("clan") ClanInput rival)
|
||||
{
|
||||
|
||||
Clan rivalInput = rival.getClan();
|
||||
if (issuerClan.isRival(rivalInput.getTag())) {
|
||||
|
||||
requestManager.addRivalryBreakRequest(cp, rivalInput, issuerClan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("leaders.asked.to.end.rivalry", player, rivalInput.getName()));
|
||||
|
||||
} else {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clans.are.not.rivals", player));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%ally %add")
|
||||
@CommandPermission("unionsog.leader.ally")
|
||||
@Conditions("rank:name=ALLY_ADD|minimum_to_ally")
|
||||
@CommandCompletion("@clans:hide_own")
|
||||
@Description("{@@command.description.ally.add}")
|
||||
public void addAlly(Player player, ClanPlayer cp, Clan issuerClan,
|
||||
@Conditions("different") @Name("clan") ClanInput other)
|
||||
{
|
||||
|
||||
Clan input = other.getClan();
|
||||
if (issuerClan.isAlly(input.getTag())) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clans.are.already.allies", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
int maxAlliances = settings.getInt(CLAN_MAX_ALLIANCES);
|
||||
if (maxAlliances != -1) {
|
||||
|
||||
if (issuerClan.getAllies().size() >= maxAlliances) {
|
||||
|
||||
ChatBlock.sendMessage(player, lang("your.clan.reached.max.alliances", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (input.getAllies().size() >= maxAlliances) {
|
||||
|
||||
ChatBlock.sendMessage(player, lang("other.clan.reached.max.alliances", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<ClanPlayer> onlineLeaders = Helper.stripOffLinePlayers(issuerClan.getLeaders());
|
||||
if (onlineLeaders.isEmpty()) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("at.least.one.leader.accept.the.alliance", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
requestManager.addAllyRequest(cp, input, issuerClan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("leaders.have.been.asked.for.an.alliance", player, input.getName()));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%ally %remove")
|
||||
@Conditions("rank:name=ALLY_REMOVE")
|
||||
@CommandPermission("unionsog.leader.ally")
|
||||
@Description("{@@command.description.ally.remove}")
|
||||
@CommandCompletion("@allied_clans")
|
||||
public void removeAlly(Player player, Clan issuerClan,
|
||||
@Conditions("different|allied_clan") @Name("clan") ClanInput ally)
|
||||
{
|
||||
|
||||
Clan allyInput = ally.getClan();
|
||||
issuerClan.removeAlly(allyInput);
|
||||
allyInput.addBb(player.getName(), lang("has.broken.the.alliance", issuerClan.getName(), allyInput.getName()),
|
||||
false);
|
||||
issuerClan.addBb(player.getName(), lang("has.broken.the.alliance", player.getName(), allyInput.getName()));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%kick")
|
||||
@CommandPermission("unionsog.leader.kick")
|
||||
@CommandCompletion("@clan_members:hide_own")
|
||||
@Conditions("rank:name=KICK")
|
||||
@Description("{@@command.description.kick}")
|
||||
public void kick(@Conditions("clan_member") Player sender,
|
||||
@Conditions("same_clan") @Name("member") ClanPlayerInput other)
|
||||
{
|
||||
|
||||
ClanPlayer clanPlayer = other.getClanPlayer();
|
||||
if (sender.getUniqueId().equals(clanPlayer.getUniqueId())) {
|
||||
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.cannot.kick.yourself", sender));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Clan clan = cm.getClanByPlayerUniqueId(sender.getUniqueId());
|
||||
if (Objects.requireNonNull(clan).isLeader(clanPlayer.getUniqueId())) {
|
||||
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.cannot.kick.another.leader", sender));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
clan.addBb(sender.getName(), lang("has.been.kicked.by", clanPlayer.getName(), sender.getName(), sender));
|
||||
clan.removePlayerFromClan(clanPlayer.getUniqueId());
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%resign %confirm")
|
||||
@CommandPermission("unionsog.member.resign")
|
||||
@Description("{@@command.description.resign}")
|
||||
@HelpSearchTags("leave")
|
||||
public void resignConfirm(Player player, ClanPlayer cp, Clan clan) {
|
||||
|
||||
if (clan.isPermanent() || !clan.isLeader(player) || clan.getLeaders().size() > 1) {
|
||||
|
||||
clan.addBb(player.getName(), lang("0.has.resigned", player.getName()));
|
||||
cp.addResignTime(clan.getTag());
|
||||
clan.removePlayerFromClan(player.getUniqueId());
|
||||
|
||||
ChatBlock.sendMessage(cp, AQUA + lang("resign.success", player));
|
||||
|
||||
} else if (clan.isLeader(player) && clan.getLeaders().size() == 1) {
|
||||
|
||||
clan.disband(player, true, false);
|
||||
ChatBlock.sendMessage(cp, RED + lang("clan.has.been.disbanded", player, clan.getName()));
|
||||
|
||||
} else {
|
||||
|
||||
ChatBlock.sendMessage(cp, RED
|
||||
+ lang("last.leader.cannot.resign.you.must.appoint.another.leader.or.disband.the.clan", player));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%resign")
|
||||
@CommandPermission("unionsog.member.resign")
|
||||
@Description("{@@command.description.resign}")
|
||||
@HelpSearchTags("leave")
|
||||
public void resign(@Conditions("clan_member") Player player) {
|
||||
|
||||
new SCConversation(plugin, player, new ResignPrompt()).begin();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,228 +0,0 @@
|
||||
package net.trueog.unionsog.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.trueog.unionsog.*;
|
||||
import net.trueog.unionsog.commands.ClanPlayerInput;
|
||||
import net.trueog.unionsog.conversation.DisbandPrompt;
|
||||
import net.trueog.unionsog.conversation.SCConversation;
|
||||
import net.trueog.unionsog.hooks.discord.DiscordHook;
|
||||
import net.trueog.unionsog.hooks.discord.exceptions.DiscordHookException;
|
||||
import net.trueog.unionsog.managers.*;
|
||||
import net.trueog.unionsog.utils.ChatUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Conditions("%basic_conditions|leader")
|
||||
public class LeaderCommands extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private UnionsOG plugin;
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
@Dependency
|
||||
private PermissionsManager permissions;
|
||||
@Dependency
|
||||
private SettingsManager settings;
|
||||
@Dependency
|
||||
private RequestManager requestManager;
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
@Dependency
|
||||
private ChatManager chatManager;
|
||||
|
||||
@Subcommand("%demote")
|
||||
@CommandCompletion("@clan_leaders")
|
||||
@CommandPermission("unionsog.leader.demote")
|
||||
@Description("{@@command.description.demote}")
|
||||
public void demote(Player player, ClanPlayer cp, Clan clan,
|
||||
@Conditions("same_clan") @Name("leader") ClanPlayerInput other)
|
||||
{
|
||||
|
||||
ClanPlayer otherCp = other.getClanPlayer();
|
||||
if (!clan.enoughLeadersOnlineToDemote(otherCp)) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("not.enough.leaders.online.to.vote.on.demotion", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!clan.isLeader(otherCp.getUniqueId())) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("player.is.not.a.leader.of.your.clan", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (clan.getLeaders().size() > 2 && settings.is(CLAN_CONFIRMATION_FOR_DEMOTE)) {
|
||||
|
||||
requestManager.addDemoteRequest(cp, otherCp.getName(), clan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("demotion.vote.has.been.requested.from.all.leaders", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), lang("demoted.back.to.member", otherCp.getName()));
|
||||
clan.demote(otherCp.getUniqueId());
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%promote")
|
||||
@CommandPermission("unionsog.leader.promote")
|
||||
@CommandCompletion("@clan_non_leaders")
|
||||
@Description("{@@command.description.promote}")
|
||||
public void promote(Player player, Clan clan, ClanPlayer cp,
|
||||
@Conditions("online|same_clan") @Name("member") ClanPlayerInput other)
|
||||
{
|
||||
|
||||
Player otherPl = Objects.requireNonNull(other.getClanPlayer().toPlayer());
|
||||
if (!permissions.has(otherPl, "unionsog.leader.promotable")) {
|
||||
|
||||
ChatBlock.sendMessage(player,
|
||||
RED + lang("the.player.does.not.have.the.permissions.to.lead.a.clan", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (otherPl.getUniqueId().equals(player.getUniqueId())) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("you.cannot.promote.yourself", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (clan.isLeader(otherPl.getUniqueId())) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("the.player.is.already.a.leader", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (settings.is(CLAN_CONFIRMATION_FOR_PROMOTE) && clan.getLeaders().size() > 1) {
|
||||
|
||||
requestManager.requestAllLeaders(cp, ClanRequest.PROMOTE, otherPl.getName(), "asking.for.the.promotion",
|
||||
player.getName(), otherPl.getName());
|
||||
ChatBlock.sendMessage(player, AQUA + lang("promotion.vote.has.been.requested.from.all.leaders", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), lang("promoted.to.leader", otherPl.getName()));
|
||||
clan.promote(otherPl.getUniqueId());
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%disband")
|
||||
@CommandPermission("unionsog.leader.disband")
|
||||
@Description("{@@command.description.disband}")
|
||||
public void disband(Player player, ClanPlayer cp, Clan clan) {
|
||||
|
||||
if (clan.getLeaders().size() != 1) {
|
||||
|
||||
requestManager.requestAllLeaders(cp, ClanRequest.DISBAND, clan.getTag(), "asking.to.disband",
|
||||
player.getName());
|
||||
ChatBlock.sendMessage(player, AQUA + lang("clan.disband.vote.has.been.requested.from.all.leaders", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
new SCConversation(plugin, player, new DisbandPrompt()).begin();
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%rename")
|
||||
@CommandPermission("unionsog.leader.rename")
|
||||
@CommandCompletion("@nothing")
|
||||
@Description("{@@command.description.rename}")
|
||||
public void rename(Player player, ClanPlayer cp, Clan clan, @Name("name") String clanName) {
|
||||
|
||||
if (clanName.contains("&")) {
|
||||
|
||||
ChatBlock.sendMessageKey(cp, "your.clan.name.cannot.contain.color.codes");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (ChatUtils.stripColors(clanName).trim().equalsIgnoreCase("None")) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + "Your union cannot be named \"None\".");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
boolean bypass = plugin.getPermissionsManager().has(player, "unionsog.mod.bypass");
|
||||
if (!bypass) {
|
||||
|
||||
if (ChatUtils.stripColors(clanName).length() > plugin.getSettingsManager().getInt(CLAN_MAX_LENGTH)) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clan.name.cannot.be.longer.than.characters", player,
|
||||
plugin.getSettingsManager().getInt(CLAN_MAX_LENGTH)));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (ChatUtils.stripColors(clanName).length() <= plugin.getSettingsManager().getInt(CLAN_MIN_LENGTH)) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clan.name.must.be.longer.than.characters", player,
|
||||
plugin.getSettingsManager().getInt(CLAN_MIN_LENGTH)));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (clan.getLeaders().size() != 1) {
|
||||
|
||||
requestManager.requestAllLeaders(cp, ClanRequest.RENAME, clanName, "asking.to.rename", cp.getName(),
|
||||
clanName);
|
||||
ChatBlock.sendMessageKey(cp, "rename.vote.has.been.requested.from.all.leaders");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
clan.setName(clanName);
|
||||
storage.updateClan(clan);
|
||||
|
||||
ChatBlock.sendMessageKey(cp, "you.have.successfully.renamed.your.clan", clanName);
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%discord %create")
|
||||
@CommandPermission("unionsog.leader.discord.create")
|
||||
@Description("{@@command.description.discord.create}")
|
||||
public void discord(Player player, Clan clan) {
|
||||
|
||||
DiscordHook discordHook = chatManager.getDiscordHook();
|
||||
if (discordHook == null) {
|
||||
|
||||
ChatBlock.sendMessageKey(player, "discordhook.is.disabled");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
discordHook.createChannel(clan.getTag());
|
||||
ChatBlock.sendMessageKey(player, "discord.created.successfully");
|
||||
|
||||
} catch (DiscordHookException ex) {
|
||||
|
||||
String messageKey = ex.getMessageKey();
|
||||
if (messageKey != null) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang(messageKey));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,259 +0,0 @@
|
||||
package net.trueog.unionsog.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.trueog.unionsog.*;
|
||||
import net.trueog.unionsog.commands.ClanPlayerInput;
|
||||
import net.trueog.unionsog.conversation.CreateRankNamePrompt;
|
||||
import net.trueog.unionsog.conversation.RequestCanceller;
|
||||
import net.trueog.unionsog.conversation.SCConversation;
|
||||
import net.trueog.unionsog.events.DeleteRankEvent;
|
||||
import net.trueog.unionsog.events.PlayerRankUpdateEvent;
|
||||
import net.trueog.unionsog.managers.PermissionsManager;
|
||||
import net.trueog.unionsog.managers.StorageManager;
|
||||
import net.trueog.unionsog.utils.ChatUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Subcommand("%rank")
|
||||
@Conditions("%basic_conditions|leader")
|
||||
public class RankCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private UnionsOG plugin;
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
@Dependency
|
||||
private PermissionsManager permissions;
|
||||
|
||||
@Subcommand("%assign")
|
||||
@CommandPermission("unionsog.leader.rank.assign")
|
||||
@CommandCompletion("@clan_members @ranks")
|
||||
@Description("{@@command.description.rank.assign}")
|
||||
public void assign(ClanPlayer player, Clan clan, @Name("member") @Conditions("same_clan") ClanPlayerInput member,
|
||||
@Name("rank") Rank rank)
|
||||
{
|
||||
|
||||
ClanPlayer memberInput = member.getClanPlayer();
|
||||
|
||||
PlayerRankUpdateEvent event = new PlayerRankUpdateEvent(player, memberInput, clan,
|
||||
clan.getRank(memberInput.getRankId()), rank);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (memberInput.getRankId().equals(rank.getName())) {
|
||||
|
||||
ChatBlock.sendMessage(player, lang("player.already.has.that.rank", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
memberInput.setRank(rank.getName());
|
||||
storage.updateClanPlayer(memberInput);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("player.rank.changed", player));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%unassign")
|
||||
@CommandPermission("unionsog.leader.rank.unassign")
|
||||
@CommandCompletion("@clan_members")
|
||||
@Description("{@@command.description.rank.unassign}")
|
||||
public void unassign(ClanPlayer player, Clan clan, @Conditions("same_clan") @Name("member") ClanPlayerInput cp) {
|
||||
|
||||
ClanPlayer memberInput = cp.getClanPlayer();
|
||||
|
||||
PlayerRankUpdateEvent event = new PlayerRankUpdateEvent(player, memberInput, clan,
|
||||
clan.getRank(memberInput.getRankId()), null);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
memberInput.setRank(null);
|
||||
storage.updateClanPlayer(memberInput);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("player.unassigned.from.rank", player));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%create")
|
||||
@CommandPermission("unionsog.leader.rank.create")
|
||||
@Description("{@@command.description.rank.create}")
|
||||
public void create(Player player, Clan clan) {
|
||||
|
||||
SCConversation conversation = new SCConversation(plugin, player, new CreateRankNamePrompt(), 60);
|
||||
conversation.addConversationCanceller(
|
||||
new RequestCanceller(player, RED + lang("rank.create.request.cancelled", player)));
|
||||
conversation.getContext().setSessionData("clan", clan);
|
||||
conversation.begin();
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%delete")
|
||||
@CommandPermission("unionsog.leader.rank.delete")
|
||||
@CommandCompletion("@ranks")
|
||||
@Description("{@@command.description.rank.delete}")
|
||||
public void delete(Player player, Clan clan, @Name("rank") Rank rank) {
|
||||
|
||||
DeleteRankEvent event = new DeleteRankEvent(player, clan, rank);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
|
||||
clan.deleteRank(rank.getName());
|
||||
storage.updateClan(clan, true);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("rank.0.deleted", player, rank.getDisplayName()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%list")
|
||||
@CommandPermission("unionsog.leader.rank.list")
|
||||
@Description("{@@command.description.rank.list}")
|
||||
public void list(Player player, Clan clan) {
|
||||
|
||||
List<Rank> ranks = clan.getRanks();
|
||||
|
||||
if (ranks.isEmpty()) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("no.ranks", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
ranks.sort(Comparator.reverseOrder());
|
||||
ChatBlock.sendMessage(player, AQUA + lang("clans.ranks", player));
|
||||
int count = 1;
|
||||
for (Rank rank : ranks) {
|
||||
|
||||
ChatBlock.sendMessage(player, AQUA + lang("ranks.list.item", player, count,
|
||||
ChatUtils.parseColors(rank.getDisplayName()) + AQUA, rank.getName()));
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%setdisplayname")
|
||||
@CommandPermission("unionsog.leader.rank.setdisplayname")
|
||||
@CommandCompletion("@ranks @nothing")
|
||||
@Description("{@@command.description.rank.setdisplayname}")
|
||||
public void setDisplayName(Player player, Clan clan, @Name("rank") Rank rank,
|
||||
@Name("displayname") String displayName)
|
||||
{
|
||||
|
||||
if (displayName.contains("&") && !permissions.has(player, "unionsog.leader.coloredrank")) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("you.cannot.set.colored.ranks", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
rank.setDisplayName(displayName);
|
||||
storage.updateClan(clan, true);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("rank.displayname.updated", player));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%setdefault")
|
||||
@CommandPermission("unionsog.leader.rank.setdefault")
|
||||
@CommandCompletion("@ranks")
|
||||
@Description("{@@command.description.rank.setdefault}")
|
||||
public void setDefault(Player player, Clan clan, @Name("rank") Rank rank) {
|
||||
|
||||
clan.setDefaultRank(rank.getName());
|
||||
ChatBlock.sendMessage(player, AQUA + lang("rank.setdefault", player, rank.getDisplayName()));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%removedefault")
|
||||
@CommandPermission("unionsog.leader.rank.removedefault")
|
||||
@Description("{@@command.description.rank.removedefault}")
|
||||
public void removeDefault(Player player, Clan clan) {
|
||||
|
||||
clan.setDefaultRank(null);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("rank.removedefault", player));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%permissions")
|
||||
public class PermissionsCommand extends BaseCommand {
|
||||
|
||||
private final String validPermissionsToMessage = String.join(",", Helper.fromPermissionArray());
|
||||
|
||||
@Default
|
||||
@CommandPermission("unionsog.leader.rank.permissions.available")
|
||||
@Description("{@@command.description.rank.permissions.available}")
|
||||
public void availablePermissions(Player player) {
|
||||
|
||||
ChatBlock.sendMessage(player, AQUA + lang("available.rank.permissions", player));
|
||||
ChatBlock.sendMessage(player, AQUA + validPermissionsToMessage);
|
||||
|
||||
}
|
||||
|
||||
@Default
|
||||
@CommandPermission("unionsog.leader.rank.permissions.list")
|
||||
@CommandCompletion("@ranks")
|
||||
@Description("{@@command.description.rank.permissions.rank}")
|
||||
public void list(Player player, @Name("rank") Rank rank) {
|
||||
|
||||
Set<String> permissions = rank.getPermissions();
|
||||
if (permissions.isEmpty()) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("rank.no.permissions", player));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
ChatBlock.sendMessage(player, AQUA + lang("rank.0.permissions", player, rank.getDisplayName()));
|
||||
ChatBlock.sendMessage(player, AQUA + String.join(",", permissions));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%add")
|
||||
@CommandPermission("unionsog.leader.rank.permissions.add")
|
||||
@CommandCompletion("@ranks @rank_permissions")
|
||||
@Description("{@@command.description.rank.permissions.add}")
|
||||
public void add(Player player, Clan clan, @Name("rank") Rank rank,
|
||||
@Values("@rank_permissions") @Name("permission") String permission)
|
||||
{
|
||||
|
||||
Set<String> permissions = rank.getPermissions();
|
||||
permissions.add(permission);
|
||||
ChatBlock.sendMessage(player,
|
||||
AQUA + lang("permission.0.added.to.rank.1", player, permission, rank.getDisplayName()));
|
||||
storage.updateClan(clan, true);
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%remove")
|
||||
@CommandCompletion("@ranks @rank_permissions")
|
||||
@CommandPermission("unionsog.leader.rank.permissions.remove")
|
||||
@Description("{@@command.description.rank.permissions.remove}")
|
||||
public void remove(Player player, Clan clan, @Name("rank") Rank rank,
|
||||
@Values("@rank_permissions") @Name("permission") String permission)
|
||||
{
|
||||
|
||||
Set<String> permissions = rank.getPermissions();
|
||||
permissions.remove(permission);
|
||||
ChatBlock.sendMessage(player,
|
||||
AQUA + lang("permission.0.removed.from.rank.1", player, permission, rank.getDisplayName()));
|
||||
storage.updateClan(clan, true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package net.trueog.unionsog.commands.completions;
|
||||
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.managers.ClanManager;
|
||||
import net.trueog.unionsog.managers.UnionManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractCompletion implements IdentifiableCompletion {
|
||||
|
||||
protected final UnionsOG plugin;
|
||||
protected final ClanManager clanManager;
|
||||
protected final UnionManager unionManager;
|
||||
|
||||
public AbstractCompletion(@NotNull UnionsOG plugin) {
|
||||
|
||||
this.plugin = plugin;
|
||||
this.clanManager = plugin.getClanManager();
|
||||
this.unionManager = plugin.getUnionManager();
|
||||
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -2,7 +2,7 @@ package net.trueog.unionsog.commands.completions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -10,9 +10,9 @@ import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class AllLeadersCompletion extends AbstractSyncCompletion {
|
||||
public class AllMembersCompletion extends AbstractSyncCompletion {
|
||||
|
||||
public AllLeadersCompletion(@NotNull UnionsOG plugin) {
|
||||
public AllMembersCompletion(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class AllLeadersCompletion extends AbstractSyncCompletion {
|
||||
@Override
|
||||
public Collection<String> getCompletions(BukkitCommandCompletionContext context) throws InvalidCommandArgument {
|
||||
|
||||
return clanManager.getAllClanPlayers().stream().filter(ClanPlayer::isLeader).map(ClanPlayer::getName)
|
||||
return unionManager.getAllUnionPlayers().stream().filter(cp -> cp.getUnion() != null).map(UnionPlayer::getName)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class AllLeadersCompletion extends AbstractSyncCompletion {
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "all_leaders";
|
||||
return "all_members";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package net.trueog.unionsog.commands.completions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class AllNonLeadersCompletion extends AbstractSyncCompletion {
|
||||
|
||||
public AllNonLeadersCompletion(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getCompletions(BukkitCommandCompletionContext context) throws InvalidCommandArgument {
|
||||
|
||||
return clanManager.getAllClanPlayers().stream().filter(cp -> !cp.isLeader() && cp.getClan() != null)
|
||||
.map(ClanPlayer::getName).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "all_non_leaders";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+7
-7
@@ -2,7 +2,7 @@ package net.trueog.unionsog.commands.completions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -11,9 +11,9 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class AlliedClansCompletion extends AbstractSyncCompletion {
|
||||
public class AlliedUnionsCompletion extends AbstractSyncCompletion {
|
||||
|
||||
public AlliedClansCompletion(@NotNull UnionsOG plugin) {
|
||||
public AlliedUnionsCompletion(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
@@ -25,10 +25,10 @@ public class AlliedClansCompletion extends AbstractSyncCompletion {
|
||||
Player player = context.getPlayer();
|
||||
if (player != null) {
|
||||
|
||||
Clan clan = clanManager.getClanByPlayerUniqueId(player.getUniqueId());
|
||||
if (clan != null) {
|
||||
Union union = unionManager.getUnionByPlayerUniqueId(player.getUniqueId());
|
||||
if (union != null) {
|
||||
|
||||
return clan.getAllies();
|
||||
return union.getAllies();
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class AlliedClansCompletion extends AbstractSyncCompletion {
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "allied_clans";
|
||||
return "allied_unions";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package net.trueog.unionsog.commands.completions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ClanLeadersCompletion extends AbstractSyncCompletion {
|
||||
|
||||
public ClanLeadersCompletion(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getCompletions(BukkitCommandCompletionContext c) throws InvalidCommandArgument {
|
||||
|
||||
Player player = c.getPlayer();
|
||||
if (player != null) {
|
||||
|
||||
Clan clan = clanManager.getClanByPlayerUniqueId(player.getUniqueId());
|
||||
if (clan != null) {
|
||||
|
||||
return clan.getLeaders().stream().map(ClanPlayer::getName).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "clan_leaders";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package net.trueog.unionsog.commands.completions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ClanNonLeadersCompletion extends AbstractSyncCompletion {
|
||||
|
||||
public ClanNonLeadersCompletion(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getCompletions(BukkitCommandCompletionContext c) throws InvalidCommandArgument {
|
||||
|
||||
Player player = c.getPlayer();
|
||||
if (player != null) {
|
||||
|
||||
Clan clan = clanManager.getClanByPlayerUniqueId(player.getUniqueId());
|
||||
if (clan != null) {
|
||||
|
||||
return clan.getNonLeaders().stream().map(ClanPlayer::getName).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "clan_non_leaders";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class ListTypeCompletion extends AbstractStaticCompletion {
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "clan_list_type";
|
||||
return "union_list_type";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class NonMembersCompletion extends AbstractSyncCompletion {
|
||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
|
||||
boolean vanished = VanishUtils.isVanished(c.getSender(), onlinePlayer);
|
||||
if (clanManager.getClanByPlayerUniqueId(onlinePlayer.getUniqueId()) != null
|
||||
if (unionManager.getUnionByPlayerUniqueId(onlinePlayer.getUniqueId()) != null
|
||||
|| (c.hasConfig("ignore_vanished") && vanished))
|
||||
{
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package net.trueog.unionsog.commands.completions;
|
||||
|
||||
import net.trueog.unionsog.Helper;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class RankPermissionsCompletion extends AbstractStaticCompletion {
|
||||
|
||||
public RankPermissionsCompletion(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<String> getCompletions() {
|
||||
|
||||
return Arrays.asList(Helper.fromPermissionArray());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "rank_permissions";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package net.trueog.unionsog.commands.completions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Rank;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RanksCompletion extends AbstractSyncCompletion {
|
||||
|
||||
public RanksCompletion(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getCompletions(BukkitCommandCompletionContext context) throws InvalidCommandArgument {
|
||||
|
||||
Player player = context.getPlayer();
|
||||
if (player != null) {
|
||||
|
||||
Clan clan = clanManager.getClanByPlayerUniqueId(player.getUniqueId());
|
||||
if (clan != null) {
|
||||
|
||||
return clan.getRanks().stream().map(Rank::getName).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "ranks";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package net.trueog.unionsog.commands.completions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -25,10 +25,10 @@ public class RivalsCompletion extends AbstractSyncCompletion {
|
||||
Player player = c.getPlayer();
|
||||
if (player != null) {
|
||||
|
||||
Clan clan = clanManager.getClanByPlayerUniqueId(player.getUniqueId());
|
||||
if (clan != null) {
|
||||
Union union = unionManager.getUnionByPlayerUniqueId(player.getUniqueId());
|
||||
if (union != null) {
|
||||
|
||||
return clan.getRivals();
|
||||
return union.getRivals();
|
||||
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -7,9 +7,9 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ClanColorsCompletion extends AbstractStaticCompletion {
|
||||
public class UnionColorsCompletion extends AbstractStaticCompletion {
|
||||
|
||||
public ClanColorsCompletion(@NotNull UnionsOG plugin) {
|
||||
public UnionColorsCompletion(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ClanColorsCompletion extends AbstractStaticCompletion {
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "clan_colors";
|
||||
return "union_colors";
|
||||
|
||||
}
|
||||
|
||||
+8
-8
@@ -2,8 +2,8 @@ package net.trueog.unionsog.commands.completions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -14,9 +14,9 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ClanMembersCompletion extends AbstractSyncCompletion {
|
||||
public class UnionMembersCompletion extends AbstractSyncCompletion {
|
||||
|
||||
public ClanMembersCompletion(@NotNull UnionsOG plugin) {
|
||||
public UnionMembersCompletion(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
@@ -28,10 +28,10 @@ public class ClanMembersCompletion extends AbstractSyncCompletion {
|
||||
Player player = c.getPlayer();
|
||||
if (player != null) {
|
||||
|
||||
Clan clan = clanManager.getClanByPlayerUniqueId(player.getUniqueId());
|
||||
if (clan != null) {
|
||||
Union union = unionManager.getUnionByPlayerUniqueId(player.getUniqueId());
|
||||
if (union != null) {
|
||||
|
||||
List<String> list = clan.getMembers().stream().map(ClanPlayer::getName).collect(Collectors.toList());
|
||||
List<String> list = union.getMembers().stream().map(UnionPlayer::getName).collect(Collectors.toList());
|
||||
if (c.hasConfig("hide_own")) {
|
||||
|
||||
list.remove(player.getName());
|
||||
@@ -51,7 +51,7 @@ public class ClanMembersCompletion extends AbstractSyncCompletion {
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "clan_members";
|
||||
return "union_members";
|
||||
|
||||
}
|
||||
|
||||
+12
-12
@@ -3,7 +3,7 @@ package net.trueog.unionsog.commands.completions;
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.CommandIssuer;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -12,9 +12,9 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ClansCompletion extends AbstractSyncCompletion {
|
||||
public class UnionsCompletion extends AbstractSyncCompletion {
|
||||
|
||||
public ClansCompletion(@NotNull UnionsOG plugin) {
|
||||
public UnionsCompletion(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
@@ -23,38 +23,38 @@ public class ClansCompletion extends AbstractSyncCompletion {
|
||||
@Override
|
||||
public Collection<String> getCompletions(BukkitCommandCompletionContext c) throws InvalidCommandArgument {
|
||||
|
||||
List<Clan> clans = clanManager.getClans();
|
||||
List<Union> unions = unionManager.getUnions();
|
||||
if (c.hasConfig("has_home")) {
|
||||
|
||||
clans.removeIf(clan -> clan.getHomeLocation() == null);
|
||||
unions.removeIf(union -> union.getHomeLocation() == null);
|
||||
|
||||
}
|
||||
|
||||
if (c.hasConfig("hide_own")) {
|
||||
|
||||
Clan clan = getClan(c.getIssuer());
|
||||
if (clan != null) {
|
||||
Union union = getUnion(c.getIssuer());
|
||||
if (union != null) {
|
||||
|
||||
clans.remove(clan);
|
||||
unions.remove(union);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return clans.stream().map(Clan::getTag).collect(Collectors.toList());
|
||||
return unions.stream().map(Union::getTag).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "clans";
|
||||
return "unions";
|
||||
|
||||
}
|
||||
|
||||
private @Nullable Clan getClan(CommandIssuer issuer) {
|
||||
private @Nullable Union getUnion(CommandIssuer issuer) {
|
||||
|
||||
return clanManager.getClanByPlayerUniqueId(issuer.getUniqueId());
|
||||
return unionManager.getUnionByPlayerUniqueId(issuer.getUniqueId());
|
||||
|
||||
}
|
||||
|
||||
+7
-7
@@ -2,7 +2,7 @@ package net.trueog.unionsog.commands.completions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -12,9 +12,9 @@ import java.util.Collections;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class WarringClansCompletion extends AbstractSyncCompletion {
|
||||
public class WarringUnionsCompletion extends AbstractSyncCompletion {
|
||||
|
||||
public WarringClansCompletion(@NotNull UnionsOG plugin) {
|
||||
public WarringUnionsCompletion(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
@@ -26,10 +26,10 @@ public class WarringClansCompletion extends AbstractSyncCompletion {
|
||||
if (c.getIssuer().isPlayer()) {
|
||||
|
||||
Player player = c.getPlayer();
|
||||
Clan clan = clanManager.getClanByPlayerUniqueId(player.getUniqueId());
|
||||
if (clan != null) {
|
||||
Union union = unionManager.getUnionByPlayerUniqueId(player.getUniqueId());
|
||||
if (union != null) {
|
||||
|
||||
return clan.getWarringClans().stream().map(Clan::getTag).collect(Collectors.toList());
|
||||
return union.getWarringUnions().stream().map(Union::getTag).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class WarringClansCompletion extends AbstractSyncCompletion {
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "warring_clans";
|
||||
return "warring_unions";
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public abstract class AbstractCondition implements IdentifiableCondition {
|
||||
|
||||
protected final UnionsOG plugin;
|
||||
protected final PermissionsManager permissionsManager;
|
||||
protected final ClanManager clanManager;
|
||||
protected final UnionManager unionManager;
|
||||
protected final RequestManager requestManager;
|
||||
protected final SettingsManager settingsManager;
|
||||
protected final ProtectionManager protectionManager;
|
||||
@@ -17,7 +17,7 @@ public abstract class AbstractCondition implements IdentifiableCondition {
|
||||
|
||||
this.plugin = plugin;
|
||||
permissionsManager = plugin.getPermissionsManager();
|
||||
clanManager = plugin.getClanManager();
|
||||
unionManager = plugin.getUnionManager();
|
||||
requestManager = plugin.getRequestManager();
|
||||
settingsManager = plugin.getSettingsManager();
|
||||
protectionManager = plugin.getProtectionManager();
|
||||
|
||||
+11
-11
@@ -1,40 +1,40 @@
|
||||
package net.trueog.unionsog.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.ClanInput;
|
||||
import net.trueog.unionsog.commands.UnionInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class AlliedClanCondition extends AbstractParameterCondition<ClanInput> {
|
||||
public class AlliedUnionCondition extends AbstractParameterCondition<UnionInput> {
|
||||
|
||||
public AlliedClanCondition(@NotNull UnionsOG plugin) {
|
||||
public AlliedUnionCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanInput> getType() {
|
||||
public Class<UnionInput> getType() {
|
||||
|
||||
return ClanInput.class;
|
||||
return UnionInput.class;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, ClanInput value) throws InvalidCommandArgument
|
||||
BukkitCommandExecutionContext execContext, UnionInput value) throws InvalidCommandArgument
|
||||
{
|
||||
|
||||
BukkitCommandIssuer issuer = context.getIssuer();
|
||||
Clan clan = Conditions.assertClanMember(clanManager, issuer);
|
||||
if (!clan.isAlly(value.getClan().getTag())) {
|
||||
Union union = Conditions.assertUnionMember(unionManager, issuer);
|
||||
if (!union.isAlly(value.getUnion().getTag())) {
|
||||
|
||||
throw new ConditionFailedException(RED + lang("your.clans.are.not.allies", issuer));
|
||||
throw new ConditionFailedException(RED + lang("your.unions.are.not.allies", issuer));
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class AlliedClanCondition extends AbstractParameterCondition<ClanInput> {
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "allied_clan";
|
||||
return "allied_union";
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.ConditionContext;
|
||||
import co.aikar.commands.ConditionFailedException;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -26,22 +26,16 @@ public class CanVoteCondition extends AbstractCommandCondition {
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
|
||||
Player player = Conditions.assertPlayer(context.getIssuer());
|
||||
ClanPlayer cp = clanManager.getCreateClanPlayer(player.getUniqueId());
|
||||
Clan clan = cp.getClan();
|
||||
if (clan != null) {
|
||||
UnionPlayer cp = unionManager.getCreateUnionPlayer(player.getUniqueId());
|
||||
Union union = cp.getUnion();
|
||||
if (union != null) {
|
||||
|
||||
if (!requestManager.hasRequest(clan.getTag())) {
|
||||
if (!requestManager.hasRequest(union.getTag())) {
|
||||
|
||||
throw new ConditionFailedException(lang("nothing.to.vote", player));
|
||||
|
||||
}
|
||||
|
||||
if (!clan.isLeader(player)) {
|
||||
|
||||
throw new ConditionFailedException(RED + lang("no.leader.permissions", player));
|
||||
|
||||
}
|
||||
|
||||
if (cp.getVote() != null) {
|
||||
|
||||
throw new ConditionFailedException(RED + lang("you.have.already.voted", player));
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package net.trueog.unionsog.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.ClanInput;
|
||||
import net.trueog.unionsog.commands.UnionInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.WAR_MAX_MEMBERS_DIFFERENCE;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.WAR_START_REQUEST_ENABLED;
|
||||
|
||||
public class CanWarTargetCondition extends AbstractParameterCondition<ClanInput> {
|
||||
public class CanWarTargetCondition extends AbstractParameterCondition<UnionInput> {
|
||||
|
||||
public CanWarTargetCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
@@ -19,39 +18,39 @@ public class CanWarTargetCondition extends AbstractParameterCondition<ClanInput>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanInput> getType() {
|
||||
public Class<UnionInput> getType() {
|
||||
|
||||
return ClanInput.class;
|
||||
return UnionInput.class;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, ClanInput target) throws InvalidCommandArgument
|
||||
BukkitCommandExecutionContext execContext, UnionInput target) throws InvalidCommandArgument
|
||||
{
|
||||
|
||||
BukkitCommandIssuer issuer = execContext.getIssuer();
|
||||
Clan issuerClan = Conditions.assertClanMember(clanManager, issuer);
|
||||
Clan targetClan = target.getClan();
|
||||
Union issuerUnion = Conditions.assertUnionMember(unionManager, issuer);
|
||||
Union targetUnion = target.getUnion();
|
||||
|
||||
if (!issuerClan.isRival(targetClan.getTag())) {
|
||||
if (!issuerUnion.isRival(targetUnion.getTag())) {
|
||||
|
||||
throw new ConditionFailedException(lang("you.can.only.start.war.with.rivals", issuer));
|
||||
|
||||
}
|
||||
|
||||
if (issuerClan.isWarring(targetClan)) {
|
||||
if (issuerUnion.isWarring(targetUnion)) {
|
||||
|
||||
throw new ConditionFailedException(lang("clans.already.at.war", issuer));
|
||||
throw new ConditionFailedException(lang("unions.already.at.war", issuer));
|
||||
|
||||
}
|
||||
|
||||
boolean isWarRequestEnabled = settingsManager.is(WAR_START_REQUEST_ENABLED);
|
||||
// War no longer needs the target's consent, so the size guard always applies.
|
||||
int maxDifference = settingsManager.getInt(WAR_MAX_MEMBERS_DIFFERENCE);
|
||||
|
||||
if (!isWarRequestEnabled && maxDifference >= 0) {
|
||||
if (maxDifference >= 0) {
|
||||
|
||||
int difference = Math.abs(issuerClan.getOnlineMembers().size() - targetClan.getOnlineMembers().size());
|
||||
int difference = Math.abs(issuerUnion.getOnlineMembers().size() - targetUnion.getOnlineMembers().size());
|
||||
if (difference > maxDifference)
|
||||
throw new ConditionFailedException(lang("you.cant.start.war.online.members.difference", issuer));
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package net.trueog.unionsog.commands.conditions;
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.ConditionFailedException;
|
||||
import co.aikar.commands.MessageKeys;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.managers.ClanManager;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.managers.UnionManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -17,17 +17,17 @@ public class Conditions {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Clan assertClanMember(@NotNull ClanManager clanManager, @NotNull BukkitCommandIssuer issuer) {
|
||||
public static Union assertUnionMember(@NotNull UnionManager unionManager, @NotNull BukkitCommandIssuer issuer) {
|
||||
|
||||
Conditions.assertPlayer(issuer);
|
||||
Clan clan = clanManager.getClanByPlayerUniqueId(issuer.getUniqueId());
|
||||
if (clan == null) {
|
||||
Union union = unionManager.getUnionByPlayerUniqueId(issuer.getUniqueId());
|
||||
if (union == null) {
|
||||
|
||||
throw new ConditionFailedException(lang("not.a.member.of.any.clan", issuer));
|
||||
throw new ConditionFailedException(lang("not.a.member.of.any.union", issuer));
|
||||
|
||||
}
|
||||
|
||||
return clan;
|
||||
return union;
|
||||
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -1,44 +1,44 @@
|
||||
package net.trueog.unionsog.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.ClanInput;
|
||||
import net.trueog.unionsog.commands.UnionInput;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class DifferentClanCondition extends AbstractParameterCondition<ClanInput> {
|
||||
public class DifferentUnionCondition extends AbstractParameterCondition<UnionInput> {
|
||||
|
||||
public DifferentClanCondition(@NotNull UnionsOG plugin) {
|
||||
public DifferentUnionCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanInput> getType() {
|
||||
public Class<UnionInput> getType() {
|
||||
|
||||
return ClanInput.class;
|
||||
return UnionInput.class;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, ClanInput value) throws InvalidCommandArgument
|
||||
BukkitCommandExecutionContext execContext, UnionInput value) throws InvalidCommandArgument
|
||||
{
|
||||
|
||||
if (execContext.getIssuer().isPlayer()) {
|
||||
|
||||
Player player = execContext.getPlayer();
|
||||
ClanPlayer cp = clanManager.getAnyClanPlayer(player.getUniqueId());
|
||||
if (cp != null && cp.getClan() != null) {
|
||||
UnionPlayer cp = unionManager.getAnyUnionPlayer(player.getUniqueId());
|
||||
if (cp != null && cp.getUnion() != null) {
|
||||
|
||||
if (value.getClan().equals(cp.getClan())) {
|
||||
if (value.getUnion().equals(cp.getUnion())) {
|
||||
|
||||
throw new ConditionFailedException(lang("cannot.be.same.clan", player));
|
||||
throw new ConditionFailedException(lang("cannot.be.same.union", player));
|
||||
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package net.trueog.unionsog.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.ClanPlayerInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
public class InputClanMemberCondition extends AbstractParameterCondition<ClanPlayerInput> {
|
||||
|
||||
public InputClanMemberCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanPlayerInput> getType() {
|
||||
|
||||
return ClanPlayerInput.class;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, ClanPlayerInput value) throws InvalidCommandArgument
|
||||
{
|
||||
|
||||
if (value.getClanPlayer().getClan() == null) {
|
||||
|
||||
throw new ConditionFailedException(RED + lang("player.not.a.member.of.any.clan", execContext.getSender()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "clan_member";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package net.trueog.unionsog.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.UnionPlayerInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
public class InputUnionMemberCondition extends AbstractParameterCondition<UnionPlayerInput> {
|
||||
|
||||
public InputUnionMemberCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<UnionPlayerInput> getType() {
|
||||
|
||||
return UnionPlayerInput.class;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, UnionPlayerInput value) throws InvalidCommandArgument
|
||||
{
|
||||
|
||||
if (value.getUnionPlayer().getUnion() == null) {
|
||||
|
||||
throw new ConditionFailedException(RED + lang("player.not.a.member.of.any.union", execContext.getSender()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "union_member";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package net.trueog.unionsog.commands.conditions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.ConditionContext;
|
||||
import co.aikar.commands.ConditionFailedException;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class LeaderCondition extends AbstractCommandCondition {
|
||||
|
||||
public LeaderCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
|
||||
Player player = Conditions.assertPlayer(context.getIssuer());
|
||||
Clan clan = Conditions.assertClanMember(clanManager, context.getIssuer());
|
||||
if (!clan.isLeader(player)) {
|
||||
|
||||
throw new ConditionFailedException(ChatColor.RED + lang("no.leader.permissions", player));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "leader";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,12 +4,12 @@ import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.ConditionContext;
|
||||
import co.aikar.commands.ConditionFailedException;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.CLAN_MIN_SIZE_TO_SET_ALLY;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.UNION_MIN_SIZE_TO_SET_ALLY;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -24,11 +24,11 @@ public class MinimumToAllyCondition extends AbstractCommandCondition {
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
|
||||
Clan clan = Conditions.assertClanMember(clanManager, context.getIssuer());
|
||||
if (clan.getSize() < settingsManager.getInt(CLAN_MIN_SIZE_TO_SET_ALLY)) {
|
||||
Union union = Conditions.assertUnionMember(unionManager, context.getIssuer());
|
||||
if (union.getSize() < settingsManager.getInt(UNION_MIN_SIZE_TO_SET_ALLY)) {
|
||||
|
||||
throw new ConditionFailedException(RED + lang("minimum.to.make.alliance", context.getIssuer(),
|
||||
settingsManager.getInt(CLAN_MIN_SIZE_TO_SET_ALLY)));
|
||||
settingsManager.getInt(UNION_MIN_SIZE_TO_SET_ALLY)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.ConditionContext;
|
||||
import co.aikar.commands.ConditionFailedException;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.CLAN_MIN_SIZE_TO_SET_RIVAL;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.UNION_MIN_SIZE_TO_SET_RIVAL;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -25,11 +25,11 @@ public class MinimumToRivalCondition extends AbstractCommandCondition {
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
|
||||
BukkitCommandIssuer issuer = context.getIssuer();
|
||||
Clan clan = Conditions.assertClanMember(clanManager, issuer);
|
||||
if (clan.getSize() < settingsManager.getInt(CLAN_MIN_SIZE_TO_SET_RIVAL)) {
|
||||
Union union = Conditions.assertUnionMember(unionManager, issuer);
|
||||
if (union.getSize() < settingsManager.getInt(UNION_MIN_SIZE_TO_SET_RIVAL)) {
|
||||
|
||||
throw new ConditionFailedException(
|
||||
RED + lang("min.players.rivalries", issuer, settingsManager.getInt(CLAN_MIN_SIZE_TO_SET_RIVAL)));
|
||||
RED + lang("min.players.rivalries", issuer, settingsManager.getInt(UNION_MIN_SIZE_TO_SET_RIVAL)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.trueog.unionsog.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.ClanPlayerInput;
|
||||
import net.trueog.unionsog.commands.UnionPlayerInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -11,7 +11,7 @@ import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class NotBannedInputCondition extends AbstractParameterCondition<ClanPlayerInput> {
|
||||
public class NotBannedInputCondition extends AbstractParameterCondition<UnionPlayerInput> {
|
||||
|
||||
public NotBannedInputCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
@@ -20,22 +20,22 @@ public class NotBannedInputCondition extends AbstractParameterCondition<ClanPlay
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanPlayerInput> getType() {
|
||||
public Class<UnionPlayerInput> getType() {
|
||||
|
||||
return ClanPlayerInput.class;
|
||||
return UnionPlayerInput.class;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, ClanPlayerInput value) throws InvalidCommandArgument
|
||||
BukkitCommandExecutionContext execContext, UnionPlayerInput value) throws InvalidCommandArgument
|
||||
{
|
||||
|
||||
UUID uniqueId = value.getClanPlayer().getUniqueId();
|
||||
UUID uniqueId = value.getUnionPlayer().getUniqueId();
|
||||
if (settingsManager.isBanned(uniqueId)) {
|
||||
|
||||
throw new ConditionFailedException(
|
||||
RED + lang("this.player.is.banned.from.using.clan.commands", execContext.getSender()));
|
||||
RED + lang("this.player.is.banned.from.using.union.commands", execContext.getSender()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
package net.trueog.unionsog.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.ClanPlayerInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.debug;
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class NotInClanCondition extends AbstractParameterCondition<ClanPlayerInput> {
|
||||
|
||||
public NotInClanCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanPlayerInput> getType() {
|
||||
|
||||
return ClanPlayerInput.class;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, ClanPlayerInput value) throws InvalidCommandArgument
|
||||
{
|
||||
|
||||
ClanPlayer clanPlayer = value.getClanPlayer();
|
||||
debug(String.format("NotInClanCondition -> %s %s", clanPlayer.getName(), clanPlayer.getUniqueId()));
|
||||
if (clanPlayer.getClan() != null) {
|
||||
|
||||
throw new ConditionFailedException(
|
||||
RED + lang("the.player.is.already.member.of.another.clan", execContext.getSender()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "not_in_clan";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.trueog.unionsog.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.UnionPlayerInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.debug;
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class NotInUnionCondition extends AbstractParameterCondition<UnionPlayerInput> {
|
||||
|
||||
public NotInUnionCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<UnionPlayerInput> getType() {
|
||||
|
||||
return UnionPlayerInput.class;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, UnionPlayerInput value) throws InvalidCommandArgument
|
||||
{
|
||||
|
||||
UnionPlayer unionPlayer = value.getUnionPlayer();
|
||||
debug(String.format("NotInClanCondition -> %s %s", unionPlayer.getName(), unionPlayer.getUniqueId()));
|
||||
if (unionPlayer.getUnion() != null) {
|
||||
|
||||
throw new ConditionFailedException(
|
||||
RED + lang("the.player.is.already.member.of.another.union", execContext.getSender()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "not_in_union";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package net.trueog.unionsog.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.ClanPlayerInput;
|
||||
import net.trueog.unionsog.commands.UnionPlayerInput;
|
||||
import net.trueog.unionsog.utils.VanishUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -12,7 +12,7 @@ import static net.trueog.unionsog.UnionsOG.debug;
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class OnlineCondition extends AbstractParameterCondition<ClanPlayerInput> {
|
||||
public class OnlineCondition extends AbstractParameterCondition<UnionPlayerInput> {
|
||||
|
||||
public OnlineCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
@@ -21,20 +21,20 @@ public class OnlineCondition extends AbstractParameterCondition<ClanPlayerInput>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanPlayerInput> getType() {
|
||||
public Class<UnionPlayerInput> getType() {
|
||||
|
||||
return ClanPlayerInput.class;
|
||||
return UnionPlayerInput.class;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, ClanPlayerInput value) throws InvalidCommandArgument
|
||||
BukkitCommandExecutionContext execContext, UnionPlayerInput value) throws InvalidCommandArgument
|
||||
{
|
||||
|
||||
ClanPlayer clanPlayer = value.getClanPlayer();
|
||||
debug(String.format("OnlineCondition -> %s %s", clanPlayer.getName(), clanPlayer.getUniqueId()));
|
||||
Player player = clanPlayer.toPlayer();
|
||||
UnionPlayer unionPlayer = value.getUnionPlayer();
|
||||
debug(String.format("OnlineCondition -> %s %s", unionPlayer.getName(), unionPlayer.getUniqueId()));
|
||||
Player player = unionPlayer.toPlayer();
|
||||
|
||||
if (player != null) {
|
||||
|
||||
|
||||
+4
-4
@@ -11,9 +11,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
import static net.trueog.unionsog.UnionsOG.debug;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class PlayerClanMemberCondition extends AbstractParameterCondition<Player> {
|
||||
public class PlayerUnionMemberCondition extends AbstractParameterCondition<Player> {
|
||||
|
||||
public PlayerClanMemberCondition(@NotNull UnionsOG plugin) {
|
||||
public PlayerUnionMemberCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
@@ -32,14 +32,14 @@ public class PlayerClanMemberCondition extends AbstractParameterCondition<Player
|
||||
{
|
||||
|
||||
debug(String.format("PlayerClanMemberCondition -> %s %s", value.getName(), value.getUniqueId()));
|
||||
Conditions.assertClanMember(clanManager, context.getIssuer());
|
||||
Conditions.assertUnionMember(unionManager, context.getIssuer());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "clan_member";
|
||||
return "union_member";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package net.trueog.unionsog.commands.conditions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.ConditionContext;
|
||||
import co.aikar.commands.ConditionFailedException;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.RankPermission;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class RankPermissionCondition extends AbstractCommandCondition {
|
||||
|
||||
public RankPermissionCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
|
||||
String name = context.getConfigValue("name", (String) null);
|
||||
Player player = context.getIssuer().getPlayer();
|
||||
if (player == null || name == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
RankPermission rankPermission = net.trueog.unionsog.RankPermission.valueOf(name);
|
||||
|
||||
if (!permissionsManager.has(player, rankPermission, true)) {
|
||||
|
||||
throw new ConditionFailedException();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "rank";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.ConditionContext;
|
||||
import co.aikar.commands.ConditionFailedException;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -23,10 +23,10 @@ public class RivableCondition extends AbstractCommandCondition {
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
|
||||
Clan clan = Conditions.assertClanMember(clanManager, context.getIssuer());
|
||||
if (clan.isUnrivable()) {
|
||||
Union union = Conditions.assertUnionMember(unionManager, context.getIssuer());
|
||||
if (union.isUnrivable()) {
|
||||
|
||||
throw new ConditionFailedException(RED + lang("your.clan.cannot.create.rivals", context.getIssuer()));
|
||||
throw new ConditionFailedException(RED + lang("your.union.cannot.create.rivals", context.getIssuer()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package net.trueog.unionsog.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.ClanPlayerInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class SameClanCondition extends AbstractParameterCondition<ClanPlayerInput> {
|
||||
|
||||
public SameClanCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanPlayerInput> getType() {
|
||||
|
||||
return ClanPlayerInput.class;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, ClanPlayerInput value) throws InvalidCommandArgument
|
||||
{
|
||||
|
||||
BukkitCommandIssuer issuer = context.getIssuer();
|
||||
Clan clan = Conditions.assertClanMember(clanManager, issuer);
|
||||
if (value == null || value.getClanPlayer().getClan() == null || !value.getClanPlayer().getClan().equals(clan)) {
|
||||
|
||||
throw new ConditionFailedException(lang("the.player.is.not.a.member.of.your.clan", issuer));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "same_clan";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package net.trueog.unionsog.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.UnionPlayerInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class SameUnionCondition extends AbstractParameterCondition<UnionPlayerInput> {
|
||||
|
||||
public SameUnionCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<UnionPlayerInput> getType() {
|
||||
|
||||
return UnionPlayerInput.class;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, UnionPlayerInput value) throws InvalidCommandArgument
|
||||
{
|
||||
|
||||
BukkitCommandIssuer issuer = context.getIssuer();
|
||||
Union union = Conditions.assertUnionMember(unionManager, issuer);
|
||||
if (value == null || value.getUnionPlayer().getUnion() == null
|
||||
|| !value.getUnionPlayer().getUnion().equals(union))
|
||||
{
|
||||
|
||||
throw new ConditionFailedException(lang("the.player.is.not.a.member.of.your.union", issuer));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "same_union";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -7,9 +7,9 @@ import net.trueog.unionsog.UnionsOG;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class SenderClanMemberCondition extends AbstractCommandCondition {
|
||||
public class SenderUnionMemberCondition extends AbstractCommandCondition {
|
||||
|
||||
public SenderClanMemberCondition(@NotNull UnionsOG plugin) {
|
||||
public SenderUnionMemberCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
@@ -18,14 +18,14 @@ public class SenderClanMemberCondition extends AbstractCommandCondition {
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
|
||||
Conditions.assertClanMember(clanManager, context.getIssuer());
|
||||
Conditions.assertUnionMember(unionManager, context.getIssuer());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "clan_member";
|
||||
return "union_member";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.trueog.unionsog.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.Flags;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
|
||||
public class TeleportCondition extends AbstractParameterCondition<Clan> {
|
||||
public class TeleportCondition extends AbstractParameterCondition<Union> {
|
||||
|
||||
public TeleportCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
@@ -18,15 +18,15 @@ public class TeleportCondition extends AbstractParameterCondition<Clan> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Clan> getType() {
|
||||
public Class<Union> getType() {
|
||||
|
||||
return Clan.class;
|
||||
return Union.class;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, Clan value) throws InvalidCommandArgument
|
||||
BukkitCommandExecutionContext execContext, Union value) throws InvalidCommandArgument
|
||||
{
|
||||
|
||||
Player player = execContext.getPlayer();
|
||||
|
||||
@@ -5,10 +5,10 @@ import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.ConditionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.ClanInput;
|
||||
import net.trueog.unionsog.commands.UnionInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TeleportInputCondition extends AbstractParameterCondition<ClanInput> {
|
||||
public class TeleportInputCondition extends AbstractParameterCondition<UnionInput> {
|
||||
|
||||
public TeleportInputCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
@@ -17,18 +17,18 @@ public class TeleportInputCondition extends AbstractParameterCondition<ClanInput
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanInput> getType() {
|
||||
public Class<UnionInput> getType() {
|
||||
|
||||
return ClanInput.class;
|
||||
return UnionInput.class;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, ClanInput value) throws InvalidCommandArgument
|
||||
BukkitCommandExecutionContext execContext, UnionInput value) throws InvalidCommandArgument
|
||||
{
|
||||
|
||||
new TeleportCondition(plugin).validateCondition(context, execContext, value.getClan());
|
||||
new TeleportCondition(plugin).validateCondition(context, execContext, value.getUnion());
|
||||
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -4,39 +4,39 @@ import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.ConditionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ClanMemberCondition extends AbstractParameterCondition<ClanPlayer> {
|
||||
public class UnionMemberCondition extends AbstractParameterCondition<UnionPlayer> {
|
||||
|
||||
public ClanMemberCondition(@NotNull UnionsOG plugin) {
|
||||
public UnionMemberCondition(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanPlayer> getType() {
|
||||
public Class<UnionPlayer> getType() {
|
||||
|
||||
return ClanPlayer.class;
|
||||
return UnionPlayer.class;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, ClanPlayer value) throws InvalidCommandArgument
|
||||
BukkitCommandExecutionContext execContext, UnionPlayer value) throws InvalidCommandArgument
|
||||
{
|
||||
|
||||
Conditions.assertClanMember(clanManager, context.getIssuer());
|
||||
Conditions.assertUnionMember(unionManager, context.getIssuer());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
|
||||
return "clan_member";
|
||||
return "union_member";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package net.trueog.unionsog.commands.contexts;
|
||||
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.managers.ClanManager;
|
||||
import net.trueog.unionsog.managers.UnionManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractContextResolver<T> {
|
||||
|
||||
protected final @NotNull UnionsOG plugin;
|
||||
protected final @NotNull ClanManager clanManager;
|
||||
protected final @NotNull UnionManager unionManager;
|
||||
|
||||
public AbstractContextResolver(@NotNull UnionsOG plugin) {
|
||||
|
||||
this.plugin = plugin;
|
||||
clanManager = plugin.getClanManager();
|
||||
unionManager = plugin.getUnionManager();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package net.trueog.unionsog.commands.contexts;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ClanContextResolver extends AbstractIssuerOnlyContextResolver<Clan> {
|
||||
|
||||
public ClanContextResolver(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clan getContext(BukkitCommandExecutionContext c) throws InvalidCommandArgument {
|
||||
|
||||
return Contexts.assertClanMember(clanManager, c.getIssuer());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Clan> getType() {
|
||||
|
||||
return Clan.class;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package net.trueog.unionsog.commands.contexts;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.ClanInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ClanInputContextResolver extends AbstractInputOnlyContextResolver<ClanInput> {
|
||||
|
||||
public ClanInputContextResolver(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClanInput getContext(BukkitCommandExecutionContext context) throws InvalidCommandArgument {
|
||||
|
||||
String arg = context.popFirstArg();
|
||||
Clan clan = clanManager.getClan(arg);
|
||||
if (clan == null) {
|
||||
|
||||
throw new InvalidCommandArgument(RED + lang("the.clan.does.not.exist", context.getSender()), false);
|
||||
|
||||
}
|
||||
|
||||
return new ClanInput(clan);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanInput> getType() {
|
||||
|
||||
return ClanInput.class;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package net.trueog.unionsog.commands.contexts;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ClanPlayerContextResolver extends AbstractIssuerOnlyContextResolver<ClanPlayer> {
|
||||
|
||||
public ClanPlayerContextResolver(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClanPlayer getContext(BukkitCommandExecutionContext context) throws InvalidCommandArgument {
|
||||
|
||||
Player player = Contexts.assertPlayer(context.getIssuer());
|
||||
return clanManager.getCreateClanPlayer(player.getUniqueId());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanPlayer> getType() {
|
||||
|
||||
return ClanPlayer.class;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,8 +2,8 @@ package net.trueog.unionsog.commands.contexts;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.managers.ClanManager;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.managers.UnionManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -17,17 +17,17 @@ public class Contexts {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Clan assertClanMember(@NotNull ClanManager clanManager, @NotNull BukkitCommandIssuer issuer) {
|
||||
public static Union assertUnionMember(@NotNull UnionManager unionManager, @NotNull BukkitCommandIssuer issuer) {
|
||||
|
||||
assertPlayer(issuer);
|
||||
Clan clan = clanManager.getClanByPlayerUniqueId(issuer.getUniqueId());
|
||||
if (clan == null) {
|
||||
Union union = unionManager.getUnionByPlayerUniqueId(issuer.getUniqueId());
|
||||
if (union == null) {
|
||||
|
||||
throw new InvalidCommandArgument(lang("not.a.member.of.any.clan", issuer), false);
|
||||
throw new InvalidCommandArgument(lang("not.a.member.of.any.union", issuer), false);
|
||||
|
||||
}
|
||||
|
||||
return clan;
|
||||
return union;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package net.trueog.unionsog.commands.contexts;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Rank;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class RankContextResolver extends AbstractInputOnlyContextResolver<Rank> {
|
||||
|
||||
public RankContextResolver(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rank getContext(BukkitCommandExecutionContext context) throws InvalidCommandArgument {
|
||||
|
||||
Clan clan = Contexts.assertClanMember(clanManager, context.getIssuer());
|
||||
String rankName = context.isLastArg() ? context.joinArgs() : context.popFirstArg();
|
||||
Rank rank = clan.getRank(rankName);
|
||||
if (rank == null) {
|
||||
|
||||
throw new InvalidCommandArgument(RED + lang("rank.0.does.not.exist", context.getIssuer(), rankName), false);
|
||||
|
||||
}
|
||||
|
||||
return rank;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Rank> getType() {
|
||||
|
||||
return Rank.class;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.trueog.unionsog.commands.contexts;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class UnionContextResolver extends AbstractIssuerOnlyContextResolver<Union> {
|
||||
|
||||
public UnionContextResolver(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Union getContext(BukkitCommandExecutionContext c) throws InvalidCommandArgument {
|
||||
|
||||
return Contexts.assertUnionMember(unionManager, c.getIssuer());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Union> getType() {
|
||||
|
||||
return Union.class;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package net.trueog.unionsog.commands.contexts;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.UnionInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class UnionInputContextResolver extends AbstractInputOnlyContextResolver<UnionInput> {
|
||||
|
||||
public UnionInputContextResolver(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnionInput getContext(BukkitCommandExecutionContext context) throws InvalidCommandArgument {
|
||||
|
||||
String arg = context.popFirstArg();
|
||||
Union union = unionManager.getUnion(arg);
|
||||
if (union == null) {
|
||||
|
||||
throw new InvalidCommandArgument(RED + lang("the.union.does.not.exist", context.getSender()), false);
|
||||
|
||||
}
|
||||
|
||||
return new UnionInput(union);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<UnionInput> getType() {
|
||||
|
||||
return UnionInput.class;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package net.trueog.unionsog.commands.contexts;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class UnionPlayerContextResolver extends AbstractIssuerOnlyContextResolver<UnionPlayer> {
|
||||
|
||||
public UnionPlayerContextResolver(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnionPlayer getContext(BukkitCommandExecutionContext context) throws InvalidCommandArgument {
|
||||
|
||||
Player player = Contexts.assertPlayer(context.getIssuer());
|
||||
return unionManager.getCreateUnionPlayer(player.getUniqueId());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<UnionPlayer> getType() {
|
||||
|
||||
return UnionPlayer.class;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+10
-10
@@ -3,9 +3,9 @@ package net.trueog.unionsog.commands.contexts;
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.MinecraftMessageKeys;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.commands.ClanPlayerInput;
|
||||
import net.trueog.unionsog.commands.UnionPlayerInput;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -16,11 +16,11 @@ import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.USERNAME_REGEX;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ClanPlayerInputContextResolver extends AbstractInputOnlyContextResolver<ClanPlayerInput> {
|
||||
public class UnionPlayerInputContextResolver extends AbstractInputOnlyContextResolver<UnionPlayerInput> {
|
||||
|
||||
private final Pattern validUsername;
|
||||
|
||||
public ClanPlayerInputContextResolver(@NotNull UnionsOG plugin) {
|
||||
public UnionPlayerInputContextResolver(@NotNull UnionsOG plugin) {
|
||||
|
||||
super(plugin);
|
||||
validUsername = Pattern.compile(plugin.getSettingsManager().getString(USERNAME_REGEX));
|
||||
@@ -28,7 +28,7 @@ public class ClanPlayerInputContextResolver extends AbstractInputOnlyContextReso
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClanPlayerInput getContext(BukkitCommandExecutionContext context) throws InvalidCommandArgument {
|
||||
public UnionPlayerInput getContext(BukkitCommandExecutionContext context) throws InvalidCommandArgument {
|
||||
|
||||
String arg = context.popFirstArg();
|
||||
if (!validUsername.matcher(arg).matches()) {
|
||||
@@ -37,7 +37,7 @@ public class ClanPlayerInputContextResolver extends AbstractInputOnlyContextReso
|
||||
|
||||
}
|
||||
|
||||
ClanPlayer cp = clanManager.getAnyClanPlayer(arg);
|
||||
UnionPlayer cp = unionManager.getAnyUnionPlayer(arg);
|
||||
if (cp == null) {
|
||||
|
||||
Player player = Bukkit.getPlayer(arg);
|
||||
@@ -47,18 +47,18 @@ public class ClanPlayerInputContextResolver extends AbstractInputOnlyContextReso
|
||||
|
||||
}
|
||||
|
||||
cp = clanManager.getCreateClanPlayer(player.getUniqueId());
|
||||
cp = unionManager.getCreateUnionPlayer(player.getUniqueId());
|
||||
|
||||
}
|
||||
|
||||
return new ClanPlayerInput(cp);
|
||||
return new UnionPlayerInput(cp);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanPlayerInput> getType() {
|
||||
public Class<UnionPlayerInput> getType() {
|
||||
|
||||
return ClanPlayerInput.class;
|
||||
return UnionPlayerInput.class;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.trueog.unionsog.commands.data;
|
||||
|
||||
import net.trueog.unionsog.ChatBlock;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.Helper;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -26,13 +26,13 @@ public class Alliances extends Sendable {
|
||||
@Override
|
||||
public void send() {
|
||||
|
||||
List<Clan> clans = cm.getClans();
|
||||
cm.sortClansByKDR(clans);
|
||||
List<Union> unions = cm.getUnions();
|
||||
cm.sortUnionsByKDR(unions);
|
||||
sendHeader();
|
||||
|
||||
for (Clan clan : clans) {
|
||||
for (Union union : unions) {
|
||||
|
||||
chatBlock.addRow(" " + AQUA + clan.getName(), clan.getAllyString(DARK_GRAY + ", ", sender));
|
||||
chatBlock.addRow(" " + AQUA + union.getName(), union.getAllyString(DARK_GRAY + ", ", sender));
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Alliances extends Sendable {
|
||||
ChatBlock.sendBlank(sender);
|
||||
|
||||
chatBlock.setAlignment("l", "l");
|
||||
chatBlock.addRow(" " + headColor + lang("clan", sender), lang("allies", sender));
|
||||
chatBlock.addRow(" " + headColor + lang("union", sender), lang("allies", sender));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
package net.trueog.unionsog.commands.data;
|
||||
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Helper;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.utils.KDRFormat;
|
||||
import net.trueog.unionsog.utils.VanishUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.PAGE_LEADER_COLOR;
|
||||
|
||||
public class ClanProfile extends Sendable {
|
||||
|
||||
private final Clan clan;
|
||||
|
||||
public ClanProfile(@NotNull UnionsOG plugin, @NotNull CommandSender sender, @NotNull Clan clan) {
|
||||
|
||||
super(plugin, sender);
|
||||
this.clan = clan;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send() {
|
||||
|
||||
String message = lang("clan.profile").replace("%clan_name%", clan.getName())
|
||||
.replace("%clan_color_tag%", clan.getColorTag()).replace("%clan_description%", getDescription())
|
||||
.replace("%clan_status%", Helper.getFormattedClanStatus(clan, sender))
|
||||
.replace("%clan_leaders%", clan.getLeadersString(sm.getColored(PAGE_LEADER_COLOR), subColor + ", "))
|
||||
.replace("%clan_online_count%", String.valueOf(VanishUtils.getNonVanished(sender, clan).size()))
|
||||
.replace("%clan_size%", String.valueOf(clan.getSize()))
|
||||
.replace("%clan_kdr%", KDRFormat.format(clan.getTotalKDR()))
|
||||
.replace("%clan_rival_kills%", String.valueOf(clan.getTotalRival()))
|
||||
.replace("%clan_neutral_kills%", String.valueOf(clan.getTotalNeutral()))
|
||||
.replace("%clan_civilian_kills%", String.valueOf(clan.getTotalCivilian()))
|
||||
.replace("%clan_ally_kills%", String.valueOf(clan.getTotalAlly()))
|
||||
.replace("%clan_deaths%", String.valueOf(clan.getTotalDeaths()))
|
||||
.replace("%clan_allies%", clan.getAllyString(subColor + ", ", sender))
|
||||
.replace("%clan_rivals%", clan.getRivalString(subColor + ", ", sender))
|
||||
.replace("%clan_founded%", clan.getFoundedString())
|
||||
.replace("%clan_inactive_days%", String.valueOf(clan.getInactiveDays()))
|
||||
.replace("%clan_max_inactive_days%", Helper.formatMaxInactiveDays(clan.getMaxInactiveDays()));
|
||||
sender.sendMessage(message);
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getDescription() {
|
||||
|
||||
return clan.getDescription() != null && !clan.getDescription().isEmpty() ? clan.getDescription()
|
||||
: lang("no.description", sender);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package net.trueog.unionsog.commands.data;
|
||||
|
||||
import net.trueog.unionsog.*;
|
||||
import net.trueog.unionsog.utils.ChatUtils;
|
||||
import net.trueog.unionsog.utils.VanishUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class ClanRoster extends Sendable {
|
||||
|
||||
private final Clan clan;
|
||||
|
||||
public ClanRoster(@NotNull UnionsOG plugin, @NotNull CommandSender sender, @NotNull Clan clan) {
|
||||
|
||||
super(plugin, sender);
|
||||
this.clan = clan;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send() {
|
||||
|
||||
configureAndSendHeader();
|
||||
addLeaders();
|
||||
addMembers();
|
||||
|
||||
sendBlock();
|
||||
|
||||
}
|
||||
|
||||
private void addMembers() {
|
||||
|
||||
List<ClanPlayer> members = clan.getNonLeaders();
|
||||
plugin.getClanManager().sortClanPlayersByLastSeen(members);
|
||||
for (ClanPlayer cp : members) {
|
||||
|
||||
String name = (cp.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR) : sm.getColored(PAGE_UNTRUSTED_COLOR))
|
||||
+ cp.getName();
|
||||
String lastSeen = VanishUtils.isVanished(sender, cp) ? WHITE + cp.getLastSeenDaysString(sender)
|
||||
: GREEN + lang("online", sender);
|
||||
|
||||
chatBlock.addRow(" " + name, YELLOW + ChatUtils.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addLeaders() {
|
||||
|
||||
List<ClanPlayer> leaders = clan.getLeaders();
|
||||
plugin.getClanManager().sortClanPlayersByLastSeen(leaders);
|
||||
for (ClanPlayer cp : leaders) {
|
||||
|
||||
String name = sm.getColored(PAGE_LEADER_COLOR) + cp.getName();
|
||||
String lastSeen = VanishUtils.isVanished(sender, cp) ? WHITE + cp.getLastSeenDaysString(sender)
|
||||
: GREEN + lang("online", sender);
|
||||
|
||||
chatBlock.addRow(" " + name, YELLOW + ChatUtils.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void configureAndSendHeader() {
|
||||
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender,
|
||||
sm.getColored(PAGE_CLAN_NAME_COLOR) + clan.getName() + subColor + " " + lang("roster", sender) + " "
|
||||
+ headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender,
|
||||
headColor + lang("legend", sender) + " " + sm.getColored(PAGE_LEADER_COLOR) + lang("leader", sender)
|
||||
+ headColor + ", " + sm.getColored(PAGE_TRUSTED_COLOR) + lang("trusted", sender) + headColor
|
||||
+ ", " + sm.getColored(PAGE_UNTRUSTED_COLOR) + lang("untrusted", sender));
|
||||
ChatBlock.sendBlank(sender);
|
||||
|
||||
chatBlock.setFlexibility(false, true, false, true);
|
||||
chatBlock.addRow(" " + headColor + lang("player", sender), lang("rank", sender), lang("seen", sender));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.PAGE_CLAN_NAME_COLOR;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.PAGE_UNION_NAME_COLOR;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.PAGE_SEPARATOR;
|
||||
|
||||
public class Kills extends Sendable {
|
||||
@@ -71,7 +71,7 @@ public class Kills extends Sendable {
|
||||
chatBlock.setFlexibility(true, false);
|
||||
chatBlock.setAlignment("l", "c");
|
||||
chatBlock.addRow(" " + headColor + lang("victim", player), lang("killcount", player));
|
||||
ChatBlock.saySingle(player, sm.getColored(PAGE_CLAN_NAME_COLOR) + polled + subColor + " "
|
||||
ChatBlock.saySingle(player, sm.getColored(PAGE_UNION_NAME_COLOR) + polled + subColor + " "
|
||||
+ lang("kills", player) + " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.trueog.unionsog.commands.data;
|
||||
|
||||
import net.trueog.unionsog.ChatBlock;
|
||||
import net.trueog.unionsog.ClanPlayer;
|
||||
import net.trueog.unionsog.UnionPlayer;
|
||||
import net.trueog.unionsog.Helper;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.utils.KDRFormat;
|
||||
@@ -19,14 +19,14 @@ import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class Leaderboard extends Sendable {
|
||||
|
||||
private final RankingNumberResolver<ClanPlayer, BigDecimal> rankingResolver;
|
||||
private final List<ClanPlayer> clanPlayers;
|
||||
private final RankingNumberResolver<UnionPlayer, BigDecimal> rankingResolver;
|
||||
private final List<UnionPlayer> unionPlayers;
|
||||
|
||||
public Leaderboard(@NotNull UnionsOG plugin, @NotNull CommandSender sender) {
|
||||
|
||||
super(plugin, sender);
|
||||
clanPlayers = cm.getAllClanPlayers();
|
||||
rankingResolver = new RankingNumberResolver<>(clanPlayers, c -> KDRFormat.toBigDecimal(c.getKDR()), false,
|
||||
unionPlayers = cm.getAllUnionPlayers();
|
||||
rankingResolver = new RankingNumberResolver<>(unionPlayers, c -> KDRFormat.toBigDecimal(c.getKDR()), false,
|
||||
sm.getRankingType());
|
||||
|
||||
}
|
||||
@@ -42,25 +42,24 @@ public class Leaderboard extends Sendable {
|
||||
|
||||
private void addLines() {
|
||||
|
||||
for (ClanPlayer cp : clanPlayers) {
|
||||
for (UnionPlayer cp : unionPlayers) {
|
||||
|
||||
boolean online = !VanishUtils.isVanished(cp);
|
||||
|
||||
String name = (cp.isLeader() ? sm.getColored(PAGE_LEADER_COLOR)
|
||||
: (cp.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR) : sm.getColored(PAGE_UNTRUSTED_COLOR)))
|
||||
String name = (cp.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR) : sm.getColored(PAGE_UNTRUSTED_COLOR))
|
||||
+ cp.getName();
|
||||
String lastSeen = online ? GREEN + lang("online", sender) : WHITE + cp.getLastSeenDaysString(sender);
|
||||
|
||||
String clanTag = WHITE + lang("free.agent", sender);
|
||||
String unionTag = WHITE + lang("free.agent", sender);
|
||||
|
||||
if (cp.getClan() != null) {
|
||||
if (cp.getUnion() != null) {
|
||||
|
||||
clanTag = cp.getClan().getColorTag();
|
||||
unionTag = cp.getUnion().getColorTag();
|
||||
|
||||
}
|
||||
|
||||
chatBlock.addRow(" " + rankingResolver.getRankingNumber(cp), name,
|
||||
YELLOW + "" + KDRFormat.format(cp.getKDR()), WHITE + clanTag, lastSeen);
|
||||
YELLOW + "" + KDRFormat.format(cp.getKDR()), WHITE + unionTag, lastSeen);
|
||||
|
||||
}
|
||||
|
||||
@@ -72,12 +71,13 @@ public class Leaderboard extends Sendable {
|
||||
ChatBlock.saySingle(sender, sm.getColored(SERVER_NAME) + subColor + " " + lang("leaderboard.command", sender)
|
||||
+ " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, headColor + lang("total.clan.players.0", sender, subColor + clanPlayers.size()));
|
||||
ChatBlock.sendMessage(sender,
|
||||
headColor + lang("total.union.players.0", sender, subColor + unionPlayers.size()));
|
||||
ChatBlock.sendBlank(sender);
|
||||
|
||||
chatBlock.setAlignment("c", "l", "c", "c", "c", "c");
|
||||
chatBlock.addRow(" " + headColor + lang("rank", sender), lang("player", sender), lang("kdr", sender),
|
||||
lang("clan", sender), lang("seen", sender));
|
||||
lang("union", sender), lang("seen", sender));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.trueog.unionsog.commands.data;
|
||||
|
||||
import net.trueog.unionsog.*;
|
||||
import net.trueog.unionsog.utils.ChatUtils;
|
||||
import net.trueog.unionsog.utils.KDRFormat;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -19,20 +18,20 @@ public class Lookup extends Sendable {
|
||||
@NotNull
|
||||
private final UUID targetUuid;
|
||||
@Nullable
|
||||
private final ClanPlayer target;
|
||||
private final UnionPlayer target;
|
||||
@Nullable
|
||||
private final Clan senderClan;
|
||||
private final Union senderUnion;
|
||||
@Nullable
|
||||
private final Clan targetClan;
|
||||
private final Union targetUnion;
|
||||
|
||||
public Lookup(@NotNull UnionsOG plugin, @NotNull CommandSender sender, @NotNull UUID targetUuid) {
|
||||
|
||||
super(plugin, sender);
|
||||
this.targetUuid = targetUuid;
|
||||
target = cm.getAnyClanPlayer(targetUuid);
|
||||
ClanPlayer senderCp = !isPlayer() ? null : cm.getClanPlayer(getPlayer().getUniqueId());
|
||||
senderClan = senderCp == null ? null : senderCp.getClan();
|
||||
targetClan = target != null ? target.getClan() : null;
|
||||
target = cm.getAnyUnionPlayer(targetUuid);
|
||||
UnionPlayer senderCp = !isPlayer() ? null : cm.getUnionPlayer(getPlayer().getUniqueId());
|
||||
senderUnion = senderCp == null ? null : senderCp.getUnion();
|
||||
targetUnion = target != null ? target.getUnion() : null;
|
||||
|
||||
}
|
||||
|
||||
@@ -42,9 +41,7 @@ public class Lookup extends Sendable {
|
||||
if (target != null) {
|
||||
|
||||
String lookup = lang("player.lookup", sender).replace("%player_name%", target.getName())
|
||||
.replace("%clan_name%", getClanName())
|
||||
.replace("%player_rank%", ChatUtils.parseColors(target.getRankDisplayName()))
|
||||
.replace("%player_status%", getPlayerStatus())
|
||||
.replace("%union_name%", getUnionName()).replace("%player_status%", getPlayerStatus())
|
||||
.replace("%player_kdr%", KDRFormat.format(target.getKDR()))
|
||||
.replace("%player_rival_kills%", String.valueOf(target.getRivalKills()))
|
||||
.replace("%player_neutral_kills%", String.valueOf(target.getNeutralKills()))
|
||||
@@ -53,7 +50,7 @@ public class Lookup extends Sendable {
|
||||
.replace("%player_deaths%", String.valueOf(target.getDeaths()))
|
||||
.replace("%player_join_date%", target.getJoinDateString())
|
||||
.replace("%player_last_seen%", target.getLastSeenString(sender))
|
||||
.replace("%player_past_clans%", target.getPastClansString(headColor + ", "))
|
||||
.replace("%player_past_unions%", target.getPastUnionsString(headColor + ", "))
|
||||
.replace("%player_inactive_days%", String.valueOf(target.getInactiveDays()))
|
||||
.replace("%player_max_inactive_days%",
|
||||
Helper.formatMaxInactiveDays(sm.getInt(PURGE_INACTIVE_PLAYER_DAYS)))
|
||||
@@ -64,7 +61,7 @@ public class Lookup extends Sendable {
|
||||
|
||||
ChatBlock.sendMessage(sender, RED + lang("no.player.data.found", sender));
|
||||
|
||||
if (isOtherPlayer() && senderClan != null) {
|
||||
if (isOtherPlayer() && senderUnion != null) {
|
||||
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, lang("kill.type.civilian", sender, DARK_GRAY));
|
||||
@@ -76,47 +73,35 @@ public class Lookup extends Sendable {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getClanName() {
|
||||
private String getUnionName() {
|
||||
|
||||
String clanName = lang("none", sender);
|
||||
if (targetClan != null) {
|
||||
String unionName = lang("none", sender);
|
||||
if (targetUnion != null) {
|
||||
|
||||
clanName = lang("player.lookup.clanname").replace("%clan_color_tag%", targetClan.getColorTag())
|
||||
.replace("%clan_name%", targetClan.getName());
|
||||
unionName = lang("player.lookup.unionname").replace("%union_color_tag%", targetUnion.getColorTag())
|
||||
.replace("%union_name%", targetUnion.getName());
|
||||
|
||||
}
|
||||
|
||||
return clanName;
|
||||
return unionName;
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getPlayerStatus() {
|
||||
|
||||
if (target == null || targetClan == null) {
|
||||
if (target == null || targetUnion == null) {
|
||||
|
||||
return lang("free.agent", sender);
|
||||
|
||||
}
|
||||
|
||||
if (target.isLeader()) {
|
||||
|
||||
return sm.getColored(PAGE_LEADER_COLOR) + lang("leader", sender);
|
||||
|
||||
}
|
||||
|
||||
if (target.isTrusted()) {
|
||||
|
||||
return sm.getColored(PAGE_TRUSTED_COLOR) + lang("trusted", sender);
|
||||
|
||||
}
|
||||
|
||||
if (!target.getRankId().isEmpty()) {
|
||||
|
||||
return sm.getColored(PAGE_TRUSTED_COLOR) + lang("in.rank", sender);
|
||||
|
||||
}
|
||||
|
||||
return sm.getColored(PAGE_UNTRUSTED_COLOR) + lang("untrusted", sender);
|
||||
|
||||
}
|
||||
@@ -129,19 +114,19 @@ public class Lookup extends Sendable {
|
||||
|
||||
String killType = GRAY + lang("neutral", sender);
|
||||
|
||||
if (targetClan == null) {
|
||||
if (targetUnion == null) {
|
||||
|
||||
killType = DARK_GRAY + lang("civilian", sender);
|
||||
|
||||
} else if (senderClan != null) {
|
||||
} else if (senderUnion != null) {
|
||||
|
||||
if (senderClan.isRival(targetClan.getTag())) {
|
||||
if (senderUnion.isRival(targetUnion.getTag())) {
|
||||
|
||||
killType = WHITE + lang("rival", sender);
|
||||
|
||||
}
|
||||
|
||||
if (senderClan.equals(targetClan) || senderClan.isAlly(targetClan.getTag())) {
|
||||
if (senderUnion.equals(targetUnion) || senderUnion.isAlly(targetUnion.getTag())) {
|
||||
|
||||
killType = RED + lang("ally", sender);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.trueog.unionsog.commands.data;
|
||||
|
||||
import net.trueog.unionsog.ChatBlock;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.Helper;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -25,13 +25,13 @@ public class Rivalries extends Sendable {
|
||||
@Override
|
||||
public void send() {
|
||||
|
||||
List<Clan> clans = cm.getClans();
|
||||
cm.sortClansByKDR(clans);
|
||||
List<Union> unions = cm.getUnions();
|
||||
cm.sortUnionsByKDR(unions);
|
||||
sendHeader();
|
||||
|
||||
for (Clan clan : clans) {
|
||||
for (Union union : unions) {
|
||||
|
||||
chatBlock.addRow(" " + AQUA + clan.getName(), clan.getRivalString(DARK_GRAY + ", ", sender));
|
||||
chatBlock.addRow(" " + AQUA + union.getName(), union.getRivalString(DARK_GRAY + ", ", sender));
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Rivalries extends Sendable {
|
||||
ChatBlock.sendBlank(sender);
|
||||
|
||||
chatBlock.setAlignment("l", "l");
|
||||
chatBlock.addRow(lang("clan", sender), lang("rivals", sender));
|
||||
chatBlock.addRow(lang("union", sender), lang("rivals", sender));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.trueog.unionsog.commands.data;
|
||||
|
||||
import net.trueog.unionsog.ChatBlock;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.managers.ClanManager;
|
||||
import net.trueog.unionsog.managers.UnionManager;
|
||||
import net.trueog.unionsog.managers.SettingsManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -14,7 +14,7 @@ public abstract class Sendable {
|
||||
|
||||
protected final UnionsOG plugin;
|
||||
protected final SettingsManager sm;
|
||||
protected final ClanManager cm;
|
||||
protected final UnionManager cm;
|
||||
protected final CommandSender sender;
|
||||
protected final ChatBlock chatBlock = new ChatBlock();
|
||||
protected final String headColor;
|
||||
@@ -24,7 +24,7 @@ public abstract class Sendable {
|
||||
|
||||
this.plugin = plugin;
|
||||
sm = plugin.getSettingsManager();
|
||||
cm = plugin.getClanManager();
|
||||
cm = plugin.getUnionManager();
|
||||
this.sender = sender;
|
||||
headColor = sm.getColored(PAGE_HEADINGS_COLOR);
|
||||
subColor = sm.getColored(PAGE_SUBTITLE_COLOR);
|
||||
|
||||
+8
-9
@@ -16,31 +16,30 @@ import static net.trueog.unionsog.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.WHITE;
|
||||
|
||||
public class ClanCoords extends Sendable {
|
||||
public class UnionCoords extends Sendable {
|
||||
|
||||
private final Player player;
|
||||
private final Clan clan;
|
||||
private final Union union;
|
||||
|
||||
public ClanCoords(@NotNull UnionsOG plugin, @NotNull Player player, @NotNull Clan clan) {
|
||||
public UnionCoords(@NotNull UnionsOG plugin, @NotNull Player player, @NotNull Union union) {
|
||||
|
||||
super(plugin, player);
|
||||
this.player = player;
|
||||
this.clan = clan;
|
||||
this.union = union;
|
||||
|
||||
}
|
||||
|
||||
private void populateRows() {
|
||||
|
||||
Map<Integer, List<String>> rows = new TreeMap<>();
|
||||
for (ClanPlayer cpm : VanishUtils.getNonVanished(player, clan)) {
|
||||
for (UnionPlayer cpm : VanishUtils.getNonVanished(player, union)) {
|
||||
|
||||
Player p = cpm.toPlayer();
|
||||
|
||||
if (p != null) {
|
||||
|
||||
String name = (cpm.isLeader() ? sm.getColored(PAGE_LEADER_COLOR)
|
||||
: (cpm.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR) : sm.getColored(PAGE_UNTRUSTED_COLOR)))
|
||||
+ cpm.getName();
|
||||
String name = (cpm.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR)
|
||||
: sm.getColored(PAGE_UNTRUSTED_COLOR)) + cpm.getName();
|
||||
Location loc = p.getLocation();
|
||||
int distance = (int) Math.ceil(loc.toVector().distance(player.getLocation().toVector()));
|
||||
String coords = loc.getBlockX() + " " + loc.getBlockY() + " " + loc.getBlockZ();
|
||||
@@ -72,7 +71,7 @@ public class ClanCoords extends Sendable {
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player,
|
||||
sm.getColored(PAGE_CLAN_NAME_COLOR) + clan.getName() + subColor + " " + lang("coords", player) + " "
|
||||
sm.getColored(PAGE_UNION_NAME_COLOR) + union.getName() + subColor + " " + lang("coords", player) + " "
|
||||
+ headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
+33
-33
@@ -5,7 +5,7 @@ import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.trueog.unionsog.ChatBlock;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.Helper;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.utils.ChatUtils;
|
||||
@@ -23,15 +23,15 @@ import static net.trueog.unionsog.managers.SettingsManager.ConfigField.*;
|
||||
import static net.trueog.unionsog.utils.RankingNumberResolver.RankingType.ORDINAL;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class ClanList extends Sendable {
|
||||
public class UnionList extends Sendable {
|
||||
|
||||
private static final int CLANS_PER_PAGE = 8;
|
||||
private static final int UNIONS_PER_PAGE = 8;
|
||||
|
||||
private final String type;
|
||||
private final String order;
|
||||
private final int page;
|
||||
|
||||
public ClanList(@NotNull UnionsOG plugin, @NotNull CommandSender sender, @Nullable String type,
|
||||
public UnionList(@NotNull UnionsOG plugin, @NotNull CommandSender sender, @Nullable String type,
|
||||
@Nullable String order, @Nullable Integer page)
|
||||
{
|
||||
|
||||
@@ -62,23 +62,23 @@ public class ClanList extends Sendable {
|
||||
@Override
|
||||
public void send() {
|
||||
|
||||
List<Clan> clans = getListableClans();
|
||||
if (clans.isEmpty()) {
|
||||
List<Union> unions = getListableUnions();
|
||||
if (unions.isEmpty()) {
|
||||
|
||||
ChatBlock.sendMessage(sender, RED + lang("no.clans.have.been.created", sender));
|
||||
ChatBlock.sendMessage(sender, RED + lang("no.unions.have.been.created", sender));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
RankingNumberResolver<Clan, ? extends Comparable<?>> ranking = getRankingResolver(clans);
|
||||
int totalPages = (clans.size() + CLANS_PER_PAGE - 1) / CLANS_PER_PAGE;
|
||||
RankingNumberResolver<Union, ? extends Comparable<?>> ranking = getRankingResolver(unions);
|
||||
int totalPages = (unions.size() + UNIONS_PER_PAGE - 1) / UNIONS_PER_PAGE;
|
||||
int currentPage = Math.min(page, totalPages);
|
||||
|
||||
sendHeader(clans);
|
||||
int start = (currentPage - 1) * CLANS_PER_PAGE;
|
||||
for (Clan clan : clans.subList(start, Math.min(start + CLANS_PER_PAGE, clans.size()))) {
|
||||
sendHeader(unions);
|
||||
int start = (currentPage - 1) * UNIONS_PER_PAGE;
|
||||
for (Union union : unions.subList(start, Math.min(start + UNIONS_PER_PAGE, unions.size()))) {
|
||||
|
||||
addLine(ranking, clan);
|
||||
addLine(ranking, union);
|
||||
|
||||
}
|
||||
|
||||
@@ -101,52 +101,52 @@ public class ClanList extends Sendable {
|
||||
|
||||
}
|
||||
|
||||
private RankingNumberResolver<Clan, ? extends Comparable<?>> getRankingResolver(List<Clan> clans) {
|
||||
private RankingNumberResolver<Union, ? extends Comparable<?>> getRankingResolver(List<Union> unions) {
|
||||
|
||||
boolean ascending = lang("list.order.asc").equalsIgnoreCase(order);
|
||||
if (type.equalsIgnoreCase(lang("list.type.active"))) {
|
||||
|
||||
return new RankingNumberResolver<>(clans, Clan::getLastUsed, ascending, ORDINAL);
|
||||
return new RankingNumberResolver<>(unions, Union::getLastUsed, ascending, ORDINAL);
|
||||
|
||||
}
|
||||
|
||||
if (type.equalsIgnoreCase(lang("list.type.founded"))) {
|
||||
|
||||
return new RankingNumberResolver<>(clans, Clan::getFounded, ascending, ORDINAL);
|
||||
return new RankingNumberResolver<>(unions, Union::getFounded, ascending, ORDINAL);
|
||||
|
||||
}
|
||||
|
||||
if (type.equalsIgnoreCase(lang("list.type.name"))) {
|
||||
|
||||
return new RankingNumberResolver<>(clans, Clan::getName, ascending, ORDINAL);
|
||||
return new RankingNumberResolver<>(unions, Union::getName, ascending, ORDINAL);
|
||||
|
||||
}
|
||||
|
||||
if (type.equalsIgnoreCase(lang("list.type.kdr"))) {
|
||||
|
||||
return new RankingNumberResolver<>(clans, clan -> KDRFormat.toBigDecimal(clan.getTotalKDR()), ascending,
|
||||
return new RankingNumberResolver<>(unions, union -> KDRFormat.toBigDecimal(union.getTotalKDR()), ascending,
|
||||
sm.getRankingType());
|
||||
|
||||
}
|
||||
|
||||
return new RankingNumberResolver<>(clans, Clan::getSize, ascending, ORDINAL);
|
||||
return new RankingNumberResolver<>(unions, Union::getSize, ascending, ORDINAL);
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<Clan> getListableClans() {
|
||||
private List<Union> getListableUnions() {
|
||||
|
||||
return plugin.getClanManager().getClans();
|
||||
return plugin.getUnionManager().getUnions();
|
||||
|
||||
}
|
||||
|
||||
private void sendHeader(List<Clan> clans) {
|
||||
private void sendHeader(List<Union> unions) {
|
||||
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender, sm.getColored(SERVER_NAME) + subColor + " " + lang("clans.lower", sender) + " "
|
||||
ChatBlock.saySingle(sender, sm.getColored(SERVER_NAME) + subColor + " " + lang("unions.lower", sender) + " "
|
||||
+ headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, headColor + lang("total.clans", sender) + " " + subColor + clans.size());
|
||||
ChatBlock.sendMessage(sender, headColor + lang("total.unions", sender) + " " + subColor + unions.size());
|
||||
ChatBlock.sendBlank(sender);
|
||||
chatBlock.setAlignment("c", "l", "c", "c");
|
||||
chatBlock.setFlexibility(false, true, false, false);
|
||||
@@ -155,29 +155,29 @@ public class ClanList extends Sendable {
|
||||
|
||||
}
|
||||
|
||||
private void addLine(RankingNumberResolver<Clan, ? extends Comparable<?>> ranking, Clan clan) {
|
||||
private void addLine(RankingNumberResolver<Union, ? extends Comparable<?>> ranking, Union union) {
|
||||
|
||||
String name = coloredName(clan);
|
||||
String size = WHITE + "" + clan.getSize();
|
||||
String kdr = YELLOW + "" + KDRFormat.format(clan.getTotalKDR());
|
||||
String name = coloredName(union);
|
||||
String size = WHITE + "" + union.getSize();
|
||||
String kdr = YELLOW + "" + KDRFormat.format(union.getTotalKDR());
|
||||
|
||||
chatBlock.addRow(" " + ranking.getRankingNumber(clan), name, kdr, size);
|
||||
chatBlock.addRow(" " + ranking.getRankingNumber(union), name, kdr, size);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the union once: its name, in the union's own color.
|
||||
*/
|
||||
private String coloredName(Clan clan) {
|
||||
private String coloredName(Union union) {
|
||||
|
||||
String colors = leadingColors(ChatUtils.parseColors(clan.getColorTag()));
|
||||
String colors = leadingColors(ChatUtils.parseColors(union.getColorTag()));
|
||||
if (colors.isEmpty()) {
|
||||
|
||||
colors = DARK_GRAY.toString();
|
||||
|
||||
}
|
||||
|
||||
return colors + clan.getName();
|
||||
return colors + union.getName();
|
||||
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ public class ClanList extends Sendable {
|
||||
|
||||
private String listCommand(int targetPage) {
|
||||
|
||||
return "/" + sm.getString(COMMANDS_CLAN) + " list " + type + " " + order + " " + targetPage;
|
||||
return "/" + sm.getString(COMMANDS_UNION) + " list " + type + " " + order + " " + targetPage;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package net.trueog.unionsog.commands.data;
|
||||
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.Helper;
|
||||
import net.trueog.unionsog.UnionsOG;
|
||||
import net.trueog.unionsog.utils.KDRFormat;
|
||||
import net.trueog.unionsog.utils.VanishUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
|
||||
public class UnionProfile extends Sendable {
|
||||
|
||||
private final Union union;
|
||||
|
||||
public UnionProfile(@NotNull UnionsOG plugin, @NotNull CommandSender sender, @NotNull Union union) {
|
||||
|
||||
super(plugin, sender);
|
||||
this.union = union;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send() {
|
||||
|
||||
String message = lang("union.profile").replace("%union_name%", union.getName())
|
||||
.replace("%union_color_tag%", union.getColorTag()).replace("%union_description%", getDescription())
|
||||
.replace("%union_status%", Helper.getFormattedUnionStatus(union, sender))
|
||||
.replace("%union_online_count%", String.valueOf(VanishUtils.getNonVanished(sender, union).size()))
|
||||
.replace("%union_size%", String.valueOf(union.getSize()))
|
||||
.replace("%union_kdr%", KDRFormat.format(union.getTotalKDR()))
|
||||
.replace("%union_rival_kills%", String.valueOf(union.getTotalRival()))
|
||||
.replace("%union_neutral_kills%", String.valueOf(union.getTotalNeutral()))
|
||||
.replace("%union_civilian_kills%", String.valueOf(union.getTotalCivilian()))
|
||||
.replace("%union_ally_kills%", String.valueOf(union.getTotalAlly()))
|
||||
.replace("%union_deaths%", String.valueOf(union.getTotalDeaths()))
|
||||
.replace("%union_allies%", union.getAllyString(subColor + ", ", sender))
|
||||
.replace("%union_rivals%", union.getRivalString(subColor + ", ", sender))
|
||||
.replace("%union_founded%", union.getFoundedString())
|
||||
.replace("%union_inactive_days%", String.valueOf(union.getInactiveDays()))
|
||||
.replace("%union_max_inactive_days%", Helper.formatMaxInactiveDays(union.getMaxInactiveDays()));
|
||||
sender.sendMessage(message);
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getDescription() {
|
||||
|
||||
return union.getDescription() != null && !union.getDescription().isEmpty() ? union.getDescription()
|
||||
: lang("no.description", sender);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package net.trueog.unionsog.commands.data;
|
||||
|
||||
import net.trueog.unionsog.*;
|
||||
import net.trueog.unionsog.utils.VanishUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class UnionRoster extends Sendable {
|
||||
|
||||
private final Union union;
|
||||
|
||||
public UnionRoster(@NotNull UnionsOG plugin, @NotNull CommandSender sender, @NotNull Union union) {
|
||||
|
||||
super(plugin, sender);
|
||||
this.union = union;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send() {
|
||||
|
||||
configureAndSendHeader();
|
||||
addMembers();
|
||||
|
||||
sendBlock();
|
||||
|
||||
}
|
||||
|
||||
private void addMembers() {
|
||||
|
||||
List<UnionPlayer> members = union.getMembers();
|
||||
plugin.getUnionManager().sortUnionPlayersByLastSeen(members);
|
||||
for (UnionPlayer cp : members) {
|
||||
|
||||
String name = (cp.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR) : sm.getColored(PAGE_UNTRUSTED_COLOR))
|
||||
+ cp.getName();
|
||||
String lastSeen = VanishUtils.isVanished(sender, cp) ? WHITE + cp.getLastSeenDaysString(sender)
|
||||
: GREEN + lang("online", sender);
|
||||
|
||||
chatBlock.addRow(" " + name, lastSeen);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void configureAndSendHeader() {
|
||||
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender,
|
||||
sm.getColored(PAGE_UNION_NAME_COLOR) + union.getName() + subColor + " " + lang("roster", sender) + " "
|
||||
+ headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender,
|
||||
headColor + lang("legend", sender) + " " + sm.getColored(PAGE_TRUSTED_COLOR) + lang("trusted", sender)
|
||||
+ headColor + ", " + sm.getColored(PAGE_UNTRUSTED_COLOR) + lang("untrusted", sender));
|
||||
ChatBlock.sendBlank(sender);
|
||||
|
||||
chatBlock.setFlexibility(false, true);
|
||||
chatBlock.addRow(" " + headColor + lang("player", sender), lang("seen", sender));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+10
-18
@@ -12,14 +12,14 @@ import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class ClanStats extends Sendable {
|
||||
public class UnionStats extends Sendable {
|
||||
|
||||
private final Clan clan;
|
||||
private final Union union;
|
||||
|
||||
public ClanStats(@NotNull UnionsOG plugin, @NotNull CommandSender sender, @NotNull Clan clan) {
|
||||
public UnionStats(@NotNull UnionsOG plugin, @NotNull CommandSender sender, @NotNull Union union) {
|
||||
|
||||
super(plugin, sender);
|
||||
this.clan = clan;
|
||||
this.union = union;
|
||||
|
||||
}
|
||||
|
||||
@@ -28,12 +28,8 @@ public class ClanStats extends Sendable {
|
||||
|
||||
configureAndSendHeader();
|
||||
|
||||
List<ClanPlayer> leaders = clan.getLeaders();
|
||||
cm.sortClanPlayersByKDR(leaders);
|
||||
addRows(leaders);
|
||||
|
||||
List<ClanPlayer> members = clan.getNonLeaders();
|
||||
cm.sortClanPlayersByKDR(members);
|
||||
List<UnionPlayer> members = union.getMembers();
|
||||
cm.sortUnionPlayersByKDR(members);
|
||||
addRows(members);
|
||||
|
||||
sendBlock();
|
||||
@@ -42,7 +38,7 @@ public class ClanStats extends Sendable {
|
||||
|
||||
private void configureAndSendHeader() {
|
||||
|
||||
ChatBlock.saySingle(sender, sm.getColored(PAGE_CLAN_NAME_COLOR) + clan.getName() + subColor + " "
|
||||
ChatBlock.saySingle(sender, sm.getColored(PAGE_UNION_NAME_COLOR) + union.getName() + subColor + " "
|
||||
+ lang("stats", sender) + " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender,
|
||||
@@ -61,16 +57,12 @@ public class ClanStats extends Sendable {
|
||||
|
||||
}
|
||||
|
||||
private void addRows(List<ClanPlayer> clanPlayers) {
|
||||
private void addRows(List<UnionPlayer> unionPlayers) {
|
||||
|
||||
for (ClanPlayer cp : clanPlayers) {
|
||||
for (UnionPlayer cp : unionPlayers) {
|
||||
|
||||
String color;
|
||||
if (cp.isLeader()) {
|
||||
|
||||
color = sm.getColored(PAGE_LEADER_COLOR);
|
||||
|
||||
} else if (cp.isTrusted()) {
|
||||
if (cp.isTrusted()) {
|
||||
|
||||
color = sm.getColored(PAGE_TRUSTED_COLOR);
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.*;
|
||||
@@ -14,12 +13,12 @@ import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class Vitals extends Sendable {
|
||||
|
||||
private final Clan clan;
|
||||
private final Union union;
|
||||
|
||||
public Vitals(@NotNull UnionsOG plugin, @NotNull CommandSender sender, @NotNull Clan clan) {
|
||||
public Vitals(@NotNull UnionsOG plugin, @NotNull CommandSender sender, @NotNull Union union) {
|
||||
|
||||
super(plugin, sender);
|
||||
this.clan = clan;
|
||||
this.union = union;
|
||||
|
||||
}
|
||||
|
||||
@@ -28,14 +27,11 @@ public class Vitals extends Sendable {
|
||||
|
||||
configureAndSendHeader();
|
||||
|
||||
List<ClanPlayer> members = Helper.stripOffLinePlayers(clan.getLeaders());
|
||||
members.addAll(Helper.stripOffLinePlayers(clan.getNonLeaders()));
|
||||
|
||||
addRows(members);
|
||||
addRows(Helper.stripOffLinePlayers(union.getMembers()));
|
||||
|
||||
chatBlock.addRow(" -- Allies -- ", "", "", "", "", "");
|
||||
|
||||
addRows(clan.getAllAllyMembers());
|
||||
addRows(union.getAllAllyMembers());
|
||||
|
||||
sendBlock();
|
||||
|
||||
@@ -45,7 +41,7 @@ public class Vitals extends Sendable {
|
||||
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender,
|
||||
sm.getColored(PAGE_CLAN_NAME_COLOR) + clan.getName() + subColor + " " + lang("vitals", sender) + " "
|
||||
sm.getColored(PAGE_UNION_NAME_COLOR) + union.getName() + subColor + " " + lang("vitals", sender) + " "
|
||||
+ headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, headColor + lang("weapons", sender) + ": "
|
||||
@@ -65,17 +61,16 @@ public class Vitals extends Sendable {
|
||||
|
||||
}
|
||||
|
||||
private void addRows(Collection<ClanPlayer> players) {
|
||||
private void addRows(Collection<UnionPlayer> players) {
|
||||
|
||||
for (ClanPlayer cpm : players) {
|
||||
for (UnionPlayer cpm : players) {
|
||||
|
||||
Player p = cpm.toPlayer();
|
||||
|
||||
if (p != null) {
|
||||
|
||||
String name = (cpm.isLeader() ? sm.getColored(PAGE_LEADER_COLOR)
|
||||
: (cpm.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR) : sm.getColored(PAGE_UNTRUSTED_COLOR)))
|
||||
+ cpm.getName();
|
||||
String name = (cpm.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR)
|
||||
: sm.getColored(PAGE_UNTRUSTED_COLOR)) + cpm.getName();
|
||||
String health = cm.getBar(p.getHealth());
|
||||
String hunger = cm.getBar(p.getFoodLevel());
|
||||
String armor = cm.getArmorString(p.getInventory());
|
||||
|
||||
@@ -6,15 +6,15 @@ import co.aikar.commands.CommandParameter;
|
||||
import co.aikar.commands.HelpEntry;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.trueog.unionsog.*;
|
||||
import net.trueog.unionsog.commands.ClanInput;
|
||||
import net.trueog.unionsog.commands.ClanPlayerInput;
|
||||
import net.trueog.unionsog.commands.UnionInput;
|
||||
import net.trueog.unionsog.commands.UnionPlayerInput;
|
||||
import net.trueog.unionsog.commands.data.*;
|
||||
import net.trueog.unionsog.conversation.CreateClanTagPrompt;
|
||||
import net.trueog.unionsog.conversation.CreateUnionTagPrompt;
|
||||
import net.trueog.unionsog.conversation.RequestCanceller;
|
||||
import net.trueog.unionsog.conversation.ResetKdrPrompt;
|
||||
import net.trueog.unionsog.conversation.SCConversation;
|
||||
import net.trueog.unionsog.events.PlayerResetKdrEvent;
|
||||
import net.trueog.unionsog.managers.ClanManager;
|
||||
import net.trueog.unionsog.managers.UnionManager;
|
||||
import net.trueog.unionsog.managers.RequestManager;
|
||||
import net.trueog.unionsog.managers.SettingsManager;
|
||||
import net.trueog.unionsog.managers.StorageManager;
|
||||
@@ -31,12 +31,12 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static net.trueog.unionsog.conversation.CreateClanNamePrompt.NAME_KEY;
|
||||
import static net.trueog.unionsog.conversation.CreateClanTagPrompt.TAG_KEY;
|
||||
import static net.trueog.unionsog.conversation.CreateUnionNamePrompt.NAME_KEY;
|
||||
import static net.trueog.unionsog.conversation.CreateUnionTagPrompt.TAG_KEY;
|
||||
import static net.trueog.unionsog.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@CommandAlias("%union")
|
||||
@Conditions("%basic_conditions")
|
||||
public class GeneralCommands extends BaseCommand {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
@Dependency
|
||||
private UnionsOG plugin;
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
private UnionManager cm;
|
||||
@Dependency
|
||||
private SettingsManager settings;
|
||||
@Dependency
|
||||
@@ -57,7 +57,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
private RequestManager requestManager;
|
||||
|
||||
@Default
|
||||
@Description("{@@command.description.clan}")
|
||||
@Description("{@@command.description.union}")
|
||||
@HelpSearchTags("menu gui interface ui")
|
||||
public void main(CommandSender sender) {
|
||||
|
||||
@@ -78,7 +78,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
@CommandPermission("unionsog.anyone.locale")
|
||||
@Description("{@@command.description.locale}")
|
||||
@CommandCompletion("@locales")
|
||||
public void locale(ClanPlayer cp, @Values("@locales") @Name("locale") @Single String locale) {
|
||||
public void locale(UnionPlayer cp, @Values("@locales") @Name("locale") @Single String locale) {
|
||||
|
||||
if (!settings.is(LANGUAGE_SELECTOR)) {
|
||||
|
||||
@@ -88,23 +88,23 @@ public class GeneralCommands extends BaseCommand {
|
||||
}
|
||||
|
||||
cp.setLocale(Helper.forLanguageTag(locale.replace("_", "-")));
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
plugin.getStorageManager().updateUnionPlayer(cp);
|
||||
|
||||
ChatBlock.sendMessageKey(cp, "locale.has.been.changed");
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%create")
|
||||
@CommandPermission("unionsog.leader.create")
|
||||
@CommandPermission("unionsog.member.create")
|
||||
@CommandCompletion("%compl:tag %compl:name")
|
||||
@Description("{@@command.description.create}")
|
||||
public void create(Player player, @Optional @Name("tag") String tag, @Optional @Name("name") String name) {
|
||||
|
||||
ClanPlayer cp = cm.getAnyClanPlayer(player.getUniqueId());
|
||||
UnionPlayer cp = cm.getAnyUnionPlayer(player.getUniqueId());
|
||||
|
||||
if (cp != null && cp.getClan() != null) {
|
||||
if (cp != null && cp.getUnion() != null) {
|
||||
|
||||
ChatBlock.sendMessage(player, RED + lang("you.must.first.resign", player, cp.getClan().getName()));
|
||||
ChatBlock.sendMessage(player, RED + lang("you.must.first.resign", player, cp.getUnion().getName()));
|
||||
return;
|
||||
|
||||
}
|
||||
@@ -112,9 +112,9 @@ public class GeneralCommands extends BaseCommand {
|
||||
HashMap<Object, Object> initialData = new HashMap<>();
|
||||
initialData.put(TAG_KEY, tag);
|
||||
initialData.put(NAME_KEY, name != null ? name : tag != null ? ChatUtils.stripColors(tag) : null);
|
||||
SCConversation conversation = new SCConversation(plugin, player, new CreateClanTagPrompt(), initialData);
|
||||
SCConversation conversation = new SCConversation(plugin, player, new CreateUnionTagPrompt(), initialData);
|
||||
conversation.addConversationCanceller(
|
||||
new RequestCanceller(player, RED + lang("clan.create.request.cancelled", player)));
|
||||
new RequestCanceller(player, RED + lang("union.create.request.cancelled", player)));
|
||||
conversation.begin();
|
||||
|
||||
}
|
||||
@@ -133,9 +133,9 @@ public class GeneralCommands extends BaseCommand {
|
||||
@CommandCompletion("@players")
|
||||
@CommandPermission("unionsog.anyone.lookup")
|
||||
@Description("{@@command.description.lookup.other}")
|
||||
public void lookup(CommandSender sender, @Name("player") ClanPlayerInput player) {
|
||||
public void lookup(CommandSender sender, @Name("player") UnionPlayerInput player) {
|
||||
|
||||
Lookup l = new Lookup(plugin, sender, player.getClanPlayer().getUniqueId());
|
||||
Lookup l = new Lookup(plugin, sender, player.getUnionPlayer().getUniqueId());
|
||||
l.send();
|
||||
|
||||
}
|
||||
@@ -152,15 +152,15 @@ public class GeneralCommands extends BaseCommand {
|
||||
|
||||
@Subcommand("%kills")
|
||||
@CommandPermission("unionsog.member.kills")
|
||||
@Conditions("rank:name=KILLS")
|
||||
@Conditions("union_member")
|
||||
@CommandCompletion("@players")
|
||||
@Description("{@@command.description.kills}")
|
||||
public void kills(Player sender, @Optional @Name("player") ClanPlayerInput player) {
|
||||
public void kills(Player sender, @Optional @Name("player") UnionPlayerInput player) {
|
||||
|
||||
String name = sender.getName();
|
||||
if (player != null) {
|
||||
|
||||
name = player.getClanPlayer().getName();
|
||||
name = player.getUnionPlayer().getName();
|
||||
|
||||
}
|
||||
|
||||
@@ -171,22 +171,22 @@ public class GeneralCommands extends BaseCommand {
|
||||
|
||||
@Subcommand("%profile")
|
||||
@CommandPermission("unionsog.anyone.profile")
|
||||
@CommandCompletion("@clans:hide_own")
|
||||
@CommandCompletion("@unions:hide_own")
|
||||
@Description("{@@command.description.profile.other}")
|
||||
public void profile(CommandSender sender, @Name("clan") ClanInput clan) {
|
||||
public void profile(CommandSender sender, @Name("union") UnionInput union) {
|
||||
|
||||
ClanProfile p = new ClanProfile(plugin, sender, clan.getClan());
|
||||
UnionProfile p = new UnionProfile(plugin, sender, union.getUnion());
|
||||
p.send();
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%roster")
|
||||
@CommandCompletion("@clans:hide_own")
|
||||
@CommandCompletion("@unions:hide_own")
|
||||
@CommandPermission("unionsog.anyone.roster")
|
||||
@Description("{@@command.description.roster.other}")
|
||||
public void roster(CommandSender sender, @Name("clan") ClanInput clan) {
|
||||
public void roster(CommandSender sender, @Name("union") UnionInput union) {
|
||||
|
||||
ClanRoster r = new ClanRoster(plugin, sender, clan.getClan());
|
||||
UnionRoster r = new UnionRoster(plugin, sender, union.getUnion());
|
||||
r.send();
|
||||
|
||||
}
|
||||
@@ -194,10 +194,10 @@ public class GeneralCommands extends BaseCommand {
|
||||
@Subcommand("%ff %allow")
|
||||
@CommandPermission("unionsog.member.ff")
|
||||
@Description("{@@command.description.ff.allow}")
|
||||
public void allowPersonalFf(Player player, ClanPlayer cp) {
|
||||
public void allowPersonalFf(Player player, UnionPlayer cp) {
|
||||
|
||||
cp.setFriendlyFire(true);
|
||||
storage.updateClanPlayer(cp);
|
||||
storage.updateUnionPlayer(cp);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("personal.friendly.fire.is.set.to.allowed", player));
|
||||
|
||||
}
|
||||
@@ -205,18 +205,18 @@ public class GeneralCommands extends BaseCommand {
|
||||
@Subcommand("%ff %auto")
|
||||
@CommandPermission("unionsog.member.ff")
|
||||
@Description("{@@command.description.ff.auto}")
|
||||
public void autoPersonalFf(Player player, ClanPlayer cp) {
|
||||
public void autoPersonalFf(Player player, UnionPlayer cp) {
|
||||
|
||||
cp.setFriendlyFire(false);
|
||||
storage.updateClanPlayer(cp);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("friendy.fire.is.now.managed.by.your.clan", player));
|
||||
storage.updateUnionPlayer(cp);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("friendy.fire.is.now.managed.by.your.union", player));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%resetkdr %confirm")
|
||||
@CommandPermission("unionsog.vip.resetkdr")
|
||||
@Description("{@@command.description.resetkdr}")
|
||||
public void resetKdrConfirm(Player player, ClanPlayer cp) {
|
||||
public void resetKdrConfirm(Player player, UnionPlayer cp) {
|
||||
|
||||
if (!settings.is(ALLOW_RESET_KDR)) {
|
||||
|
||||
@@ -239,7 +239,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
@Subcommand("%resetkdr")
|
||||
@CommandPermission("unionsog.vip.resetkdr")
|
||||
@Description("{@@command.description.resetkdr}")
|
||||
public void resetKdr(Player player, ClanPlayer cp) {
|
||||
public void resetKdr(Player player, UnionPlayer cp) {
|
||||
|
||||
if (!settings.is(ALLOW_RESET_KDR)) {
|
||||
|
||||
@@ -256,12 +256,12 @@ public class GeneralCommands extends BaseCommand {
|
||||
@CommandAlias("%accept")
|
||||
@Description("{@@command.description.accept}")
|
||||
@Conditions("can_vote")
|
||||
public void accept(Player player, ClanPlayer cp) {
|
||||
public void accept(Player player, UnionPlayer cp) {
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
if (clan != null) {
|
||||
Union union = cp.getUnion();
|
||||
if (union != null) {
|
||||
|
||||
clan.leaderAnnounce(GREEN + lang("voted.to.accept", player.getName()));
|
||||
union.memberAnnounce(GREEN + lang("voted.to.accept", player.getName()));
|
||||
|
||||
}
|
||||
|
||||
@@ -272,12 +272,12 @@ public class GeneralCommands extends BaseCommand {
|
||||
@CommandAlias("%deny")
|
||||
@Description("{@@command.description.deny}")
|
||||
@Conditions("can_vote")
|
||||
public void deny(Player player, ClanPlayer cp) {
|
||||
public void deny(Player player, UnionPlayer cp) {
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
if (clan != null) {
|
||||
Union union = cp.getUnion();
|
||||
if (union != null) {
|
||||
|
||||
clan.leaderAnnounce(RED + lang("has.voted.to.deny", player.getName()));
|
||||
union.memberAnnounce(RED + lang("has.voted.to.deny", player.getName()));
|
||||
|
||||
}
|
||||
|
||||
@@ -317,14 +317,14 @@ public class GeneralCommands extends BaseCommand {
|
||||
@Description("{@@command.description.help}")
|
||||
public void help(CommandSender sender, CommandHelp help) {
|
||||
|
||||
boolean inClan = sender instanceof Player
|
||||
&& cm.getClanByPlayerUniqueId(((Player) sender).getUniqueId()) != null;
|
||||
boolean inUnion = sender instanceof Player
|
||||
&& cm.getUnionByPlayerUniqueId(((Player) sender).getUniqueId()) != null;
|
||||
for (HelpEntry helpEntry : help.getHelpEntries()) {
|
||||
|
||||
for (@SuppressWarnings("rawtypes")
|
||||
CommandParameter parameter : helpEntry.getParameters()) {
|
||||
|
||||
if (parameter.getType().equals(Clan.class) && !inClan) {
|
||||
if (parameter.getType().equals(Union.class) && !inUnion) {
|
||||
|
||||
helpEntry.setSearchScore(0);
|
||||
|
||||
@@ -340,7 +340,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
|
||||
@Subcommand("%mostkilled")
|
||||
@CommandPermission("unionsog.mod.mostkilled")
|
||||
@Conditions("rank:name=MOSTKILLED")
|
||||
@Conditions("union_member")
|
||||
@Description("{@@command.description.mostkilled}")
|
||||
public void mostKilled(Player player) {
|
||||
|
||||
@@ -364,27 +364,27 @@ public class GeneralCommands extends BaseCommand {
|
||||
}
|
||||
// TODO: end
|
||||
|
||||
List<Clan> clans = cm.getClans();
|
||||
if (clans.isEmpty()) {
|
||||
List<Union> unions = cm.getUnions();
|
||||
if (unions.isEmpty()) {
|
||||
|
||||
sender.sendMessage(RED + lang("no.clans.have.been.created", sender));
|
||||
sender.sendMessage(RED + lang("no.unions.have.been.created", sender));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
clans.sort(Comparator.comparingDouble(Clan::getBalance).reversed());
|
||||
unions.sort(Comparator.comparingDouble(Union::getBalance).reversed());
|
||||
|
||||
sender.sendMessage(lang("clan.list.balance.header", sender, settings.getColored(SERVER_NAME), clans.size()));
|
||||
String lineFormat = lang("clan.list.balance.line", sender);
|
||||
sender.sendMessage(lang("union.list.balance.header", sender, settings.getColored(SERVER_NAME), unions.size()));
|
||||
String lineFormat = lang("union.list.balance.line", sender);
|
||||
|
||||
String leftBracket = settings.getColored(TAG_BRACKET_COLOR) + settings.getColored(TAG_BRACKET_LEFT);
|
||||
String rightBracket = settings.getColored(TAG_BRACKET_COLOR) + settings.getColored(TAG_BRACKET_RIGHT);
|
||||
for (int i = 0; i < 10 && i < clans.size(); i++) {
|
||||
for (int i = 0; i < 10 && i < unions.size(); i++) {
|
||||
|
||||
Clan clan = clans.get(i);
|
||||
String name = " " + settings.getColored(PAGE_CLAN_NAME_COLOR) + clan.getName();
|
||||
String line = MessageFormat.format(lineFormat, i + 1, leftBracket, clan.getColorTag(), rightBracket, name,
|
||||
clan.getBalanceFormatted());
|
||||
Union union = unions.get(i);
|
||||
String name = " " + settings.getColored(PAGE_UNION_NAME_COLOR) + union.getName();
|
||||
String line = MessageFormat.format(lineFormat, i + 1, leftBracket, union.getColorTag(), rightBracket, name,
|
||||
union.getBalanceFormatted());
|
||||
sender.sendMessage(line);
|
||||
|
||||
}
|
||||
@@ -394,12 +394,12 @@ public class GeneralCommands extends BaseCommand {
|
||||
@Subcommand("%list")
|
||||
@CommandPermission("unionsog.anyone.list")
|
||||
@Description("{@@command.description.list}")
|
||||
@CommandCompletion("@clan_list_type @order")
|
||||
@CommandCompletion("@union_list_type @order")
|
||||
public void list(CommandSender sender, @Optional String type, @Optional @Single String order,
|
||||
@Optional Integer page)
|
||||
{
|
||||
|
||||
ClanList list = new ClanList(plugin, sender, type, order, page);
|
||||
UnionList list = new UnionList(plugin, sender, type, order, page);
|
||||
list.send();
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ package net.trueog.unionsog.commands.staff;
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.trueog.unionsog.ChatBlock;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.EconomyResponse;
|
||||
import net.trueog.unionsog.commands.ClanInput;
|
||||
import net.trueog.unionsog.events.ClanBalanceUpdateEvent;
|
||||
import net.trueog.unionsog.commands.UnionInput;
|
||||
import net.trueog.unionsog.events.UnionBalanceUpdateEvent;
|
||||
import net.trueog.unionsog.loggers.BankLogger;
|
||||
import net.trueog.unionsog.loggers.BankOperator;
|
||||
import net.trueog.unionsog.managers.PermissionsManager;
|
||||
@@ -18,7 +18,7 @@ import static net.md_5.bungee.api.ChatColor.RED;
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@CommandAlias("%union")
|
||||
@Conditions("%basic_conditions")
|
||||
@Subcommand("%admin %bank")
|
||||
public class BankCommand extends BaseCommand {
|
||||
@@ -28,23 +28,23 @@ public class BankCommand extends BaseCommand {
|
||||
|
||||
@Subcommand("%status")
|
||||
@CommandPermission("unionsog.admin.bank.status")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandCompletion("@unions")
|
||||
@Description("{@@command.description.bank.admin.status}")
|
||||
public void status(CommandSender sender, @Name("clan") ClanInput clanInput) {
|
||||
public void status(CommandSender sender, @Name("union") UnionInput unionInput) {
|
||||
|
||||
Clan clan = clanInput.getClan();
|
||||
Union union = unionInput.getUnion();
|
||||
ChatBlock.sendMessage(sender,
|
||||
AQUA + lang("clan.admin.balance", sender, clan.getName(), clan.getBalanceFormatted()));
|
||||
AQUA + lang("union.admin.balance", sender, union.getName(), union.getBalanceFormatted()));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%take")
|
||||
@CommandPermission("unionsog.admin.bank.take")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandCompletion("@unions")
|
||||
@Description("{@@command.description.bank.admin.take}")
|
||||
public void take(CommandSender sender, @Name("clan") ClanInput clanInput, @Name("amount") double amount) {
|
||||
public void take(CommandSender sender, @Name("union") UnionInput unionInput, @Name("amount") double amount) {
|
||||
|
||||
Clan clan = clanInput.getClan();
|
||||
Union union = unionInput.getUnion();
|
||||
long shards = permissions.diamondsToShards(Math.abs(amount));
|
||||
if (shards < 0) {
|
||||
|
||||
@@ -56,17 +56,17 @@ public class BankCommand extends BaseCommand {
|
||||
BankOperator operator = new BankOperator(sender,
|
||||
sender instanceof Player ? permissions.playerGetShards((Player) sender) : 0);
|
||||
|
||||
EconomyResponse economyResponse = clan.withdraw(operator, ClanBalanceUpdateEvent.Cause.COMMAND, shards);
|
||||
EconomyResponse economyResponse = union.withdraw(operator, UnionBalanceUpdateEvent.Cause.COMMAND, shards);
|
||||
switch (economyResponse) {
|
||||
|
||||
case SUCCESS:
|
||||
ChatBlock.sendMessage(sender, AQUA
|
||||
+ lang("clan.admin.take", sender, CurrencyFormat.formatShards(shards, sender), clan.getName()));
|
||||
clan.addBb(sender.getName(),
|
||||
lang("bb.clan.take", sender, CurrencyFormat.formatShards(shards), sender.getName()));
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("union.admin.take", sender,
|
||||
CurrencyFormat.formatShards(shards, sender), union.getName()));
|
||||
union.addBb(sender.getName(),
|
||||
lang("bb.union.take", sender, CurrencyFormat.formatShards(shards), sender.getName()));
|
||||
break;
|
||||
case NOT_ENOUGH_BALANCE:
|
||||
sender.sendMessage(RED + lang("clan.admin.bank.not.enough.money", sender, clan.getName()));
|
||||
sender.sendMessage(RED + lang("union.admin.bank.not.enough.money", sender, union.getName()));
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -75,11 +75,11 @@ public class BankCommand extends BaseCommand {
|
||||
|
||||
@Subcommand("%give")
|
||||
@CommandPermission("unionsog.admin.bank.give")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandCompletion("@unions")
|
||||
@Description("{@@command.description.bank.admin.give}")
|
||||
public void give(CommandSender sender, @Name("clan") ClanInput clanInput, @Name("amount") double amount) {
|
||||
public void give(CommandSender sender, @Name("union") UnionInput unionInput, @Name("amount") double amount) {
|
||||
|
||||
Clan clan = clanInput.getClan();
|
||||
Union union = unionInput.getUnion();
|
||||
long shards = permissions.diamondsToShards(Math.abs(amount));
|
||||
if (shards < 0) {
|
||||
|
||||
@@ -91,13 +91,13 @@ public class BankCommand extends BaseCommand {
|
||||
BankOperator operator = new BankOperator(sender,
|
||||
sender instanceof Player ? permissions.playerGetShards((Player) sender) : 0);
|
||||
|
||||
EconomyResponse economyResponse = clan.deposit(operator, ClanBalanceUpdateEvent.Cause.COMMAND, shards);
|
||||
EconomyResponse economyResponse = union.deposit(operator, UnionBalanceUpdateEvent.Cause.COMMAND, shards);
|
||||
if (economyResponse == EconomyResponse.SUCCESS) {
|
||||
|
||||
ChatBlock.sendMessage(sender, AQUA
|
||||
+ lang("clan.admin.give", sender, CurrencyFormat.formatShards(shards, sender), clan.getName()));
|
||||
clan.addBb(sender.getName(),
|
||||
lang("bb.clan.give", sender, CurrencyFormat.formatShards(shards), sender.getName()));
|
||||
+ lang("union.admin.give", sender, CurrencyFormat.formatShards(shards, sender), union.getName()));
|
||||
union.addBb(sender.getName(),
|
||||
lang("bb.union.give", sender, CurrencyFormat.formatShards(shards), sender.getName()));
|
||||
|
||||
}
|
||||
|
||||
@@ -105,11 +105,11 @@ public class BankCommand extends BaseCommand {
|
||||
|
||||
@Subcommand("%set")
|
||||
@CommandPermission("unionsog.admin.bank.set")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandCompletion("@unions")
|
||||
@Description("{@@command.description.bank.admin.set}")
|
||||
public void set(CommandSender sender, @Name("clan") ClanInput clanInput, @Name("amount") double amount) {
|
||||
public void set(CommandSender sender, @Name("union") UnionInput unionInput, @Name("amount") double amount) {
|
||||
|
||||
Clan clan = clanInput.getClan();
|
||||
Union union = unionInput.getUnion();
|
||||
long shards = permissions.diamondsToShards(Math.abs(amount));
|
||||
if (shards < 0) {
|
||||
|
||||
@@ -121,14 +121,14 @@ public class BankCommand extends BaseCommand {
|
||||
BankOperator operator = new BankOperator(sender,
|
||||
sender instanceof Player ? permissions.playerGetShards((Player) sender) : 0);
|
||||
|
||||
EconomyResponse response = clan.setBalance(operator, ClanBalanceUpdateEvent.Cause.COMMAND,
|
||||
EconomyResponse response = union.setBalance(operator, UnionBalanceUpdateEvent.Cause.COMMAND,
|
||||
BankLogger.Operation.SET, shards);
|
||||
if (response == EconomyResponse.SUCCESS) {
|
||||
|
||||
ChatBlock.sendMessage(sender,
|
||||
AQUA + lang("clan.admin.set", sender, clan.getName(), CurrencyFormat.formatShards(shards, sender)));
|
||||
clan.addBb(sender.getName(),
|
||||
lang("bb.clan.set", sender, CurrencyFormat.formatShards(shards), sender.getName()));
|
||||
ChatBlock.sendMessage(sender, AQUA
|
||||
+ lang("union.admin.set", sender, union.getName(), CurrencyFormat.formatShards(shards, sender)));
|
||||
union.addBb(sender.getName(),
|
||||
lang("bb.union.set", sender, CurrencyFormat.formatShards(shards), sender.getName()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ package net.trueog.unionsog.commands.staff;
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.trueog.unionsog.ChatBlock;
|
||||
import net.trueog.unionsog.Clan;
|
||||
import net.trueog.unionsog.commands.ClanInput;
|
||||
import net.trueog.unionsog.managers.ClanManager;
|
||||
import net.trueog.unionsog.Union;
|
||||
import net.trueog.unionsog.commands.UnionInput;
|
||||
import net.trueog.unionsog.managers.UnionManager;
|
||||
import net.trueog.unionsog.managers.SettingsManager;
|
||||
import net.trueog.unionsog.managers.StorageManager;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
|
||||
import static net.trueog.unionsog.UnionsOG.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@CommandAlias("%union")
|
||||
@Conditions("%basic_conditions")
|
||||
@Subcommand("%mod %bb")
|
||||
public class BbCommand extends BaseCommand {
|
||||
@@ -21,42 +21,42 @@ public class BbCommand extends BaseCommand {
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
private UnionManager cm;
|
||||
|
||||
@Dependency
|
||||
private SettingsManager settings;
|
||||
|
||||
@Subcommand("%display")
|
||||
@CommandPermission("unionsog.mod.bb")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandCompletion("@unions")
|
||||
@Description("{@@command.description.mod.bb.display}")
|
||||
public void display(Player sender, @Name("clan") ClanInput input) {
|
||||
public void display(Player sender, @Name("union") UnionInput input) {
|
||||
|
||||
input.getClan().displayBb(sender);
|
||||
input.getUnion().displayBb(sender);
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%clear")
|
||||
@CommandPermission("unionsog.mod.bb-clear")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandCompletion("@unions")
|
||||
@Description("{@@command.description.mod.bb.clear}")
|
||||
public void clear(Player player, @Name("clan") ClanInput input) {
|
||||
public void clear(Player player, @Name("union") UnionInput input) {
|
||||
|
||||
input.getClan().clearBb();
|
||||
input.getUnion().clearBb();
|
||||
ChatBlock.sendMessage(player, RED + lang("cleared.bb", player));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("%add")
|
||||
@CommandPermission("unionsog.mod.bb-add")
|
||||
@CommandCompletion("@clans @nothing")
|
||||
@CommandCompletion("@unions @nothing")
|
||||
@Description("{@@command.description.mod.bb.post}")
|
||||
public void postMessage(Player player, @Name("clan") ClanInput input, @Name("message") String msg) {
|
||||
public void postMessage(Player player, @Name("union") UnionInput input, @Name("message") String msg) {
|
||||
|
||||
Clan clan = input.getClan();
|
||||
clan.addBb(lang("bulletin.board.message", player.getName(), msg));
|
||||
clan.displayBb(player);
|
||||
storage.updateClan(clan);
|
||||
Union union = input.getUnion();
|
||||
union.addBb(lang("bulletin.board.message", player.getName(), msg));
|
||||
union.displayBb(player);
|
||||
storage.updateUnion(union);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loaded 100 of 270 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user