├── .gitattributes
├── .gitignore
├── LICENSE.txt
├── README.md
├── core
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── doctordark
│ │ └── hcf
│ │ ├── Configuration.java
│ │ ├── ConfigurationService.java
│ │ ├── DateTimeFormats.java
│ │ ├── HCF.java
│ │ ├── ImageFolder.java
│ │ ├── combatlog
│ │ ├── CombatLogListener.java
│ │ ├── event
│ │ │ ├── LoggerDeathEvent.java
│ │ │ ├── LoggerRemovedEvent.java
│ │ │ └── LoggerSpawnEvent.java
│ │ └── type
│ │ │ ├── LoggerEntity.java
│ │ │ └── LoggerEntityHuman.java
│ │ ├── command
│ │ ├── AngleCommand.java
│ │ ├── DeathCommand.java
│ │ ├── GoppleCommand.java
│ │ ├── LocationCommand.java
│ │ ├── LogoutCommand.java
│ │ ├── MapKitCommand.java
│ │ ├── PvpTimerCommand.java
│ │ ├── RegenCommand.java
│ │ ├── ServerTimeCommand.java
│ │ ├── SpawnCannonCommand.java
│ │ ├── ToggleCapzoneEntryCommand.java
│ │ ├── ToggleLightningCommand.java
│ │ └── ToggleSidebarCommand.java
│ │ ├── deathban
│ │ ├── Deathban.java
│ │ ├── DeathbanListener.java
│ │ ├── DeathbanManager.java
│ │ ├── FlatFileDeathbanManager.java
│ │ ├── StaffReviveCommand.java
│ │ └── lives
│ │ │ ├── LivesExecutor.java
│ │ │ └── argument
│ │ │ ├── LivesCheckArgument.java
│ │ │ ├── LivesCheckDeathbanArgument.java
│ │ │ ├── LivesClearDeathbansArgument.java
│ │ │ ├── LivesGiveArgument.java
│ │ │ ├── LivesReviveArgument.java
│ │ │ ├── LivesSetArgument.java
│ │ │ └── LivesSetDeathbanTimeArgument.java
│ │ ├── economy
│ │ ├── EconomyCommand.java
│ │ ├── EconomyManager.java
│ │ ├── FlatFileEconomyManager.java
│ │ ├── PayCommand.java
│ │ └── ShopSignListener.java
│ │ ├── eventgame
│ │ ├── CaptureZone.java
│ │ ├── EventExecutor.java
│ │ ├── EventScheduler.java
│ │ ├── EventTimer.java
│ │ ├── EventType.java
│ │ ├── IEventScheduler.java
│ │ ├── argument
│ │ │ ├── EventAddLootTableArgument.java
│ │ │ ├── EventCancelArgument.java
│ │ │ ├── EventCreateArgument.java
│ │ │ ├── EventDelLootTableArgument.java
│ │ │ ├── EventDeleteArgument.java
│ │ │ ├── EventRenameArgument.java
│ │ │ ├── EventSetAreaArgument.java
│ │ │ ├── EventSetCapzoneArgument.java
│ │ │ ├── EventSetLootArgument.java
│ │ │ ├── EventStartArgument.java
│ │ │ └── EventUptimeArgument.java
│ │ ├── conquest
│ │ │ ├── ConquestExecutor.java
│ │ │ └── ConquestSetpointsArgument.java
│ │ ├── crate
│ │ │ ├── EventKey.java
│ │ │ ├── Key.java
│ │ │ ├── KeyListener.java
│ │ │ └── KeyManager.java
│ │ ├── eotw
│ │ │ ├── EotwCommand.java
│ │ │ ├── EotwHandler.java
│ │ │ └── EotwListener.java
│ │ ├── faction
│ │ │ ├── CapturableFaction.java
│ │ │ ├── ConquestFaction.java
│ │ │ ├── EventFaction.java
│ │ │ └── KothFaction.java
│ │ ├── koth
│ │ │ ├── KothExecutor.java
│ │ │ └── argument
│ │ │ │ ├── KothHelpArgument.java
│ │ │ │ ├── KothNextArgument.java
│ │ │ │ ├── KothScheduleArgument.java
│ │ │ │ └── KothSetCapDelayArgument.java
│ │ └── tracker
│ │ │ ├── ConquestTracker.java
│ │ │ ├── EventTracker.java
│ │ │ └── KothTracker.java
│ │ ├── faction
│ │ ├── FactionExecutor.java
│ │ ├── FactionManager.java
│ │ ├── FactionMember.java
│ │ ├── FlatFileFactionManager.java
│ │ ├── LandMap.java
│ │ ├── argument
│ │ │ ├── FactionAcceptArgument.java
│ │ │ ├── FactionAllyArgument.java
│ │ │ ├── FactionAnnouncementArgument.java
│ │ │ ├── FactionChatArgument.java
│ │ │ ├── FactionClaimArgument.java
│ │ │ ├── FactionClaimChunkArgument.java
│ │ │ ├── FactionClaimsArgument.java
│ │ │ ├── FactionCreateArgument.java
│ │ │ ├── FactionDemoteArgument.java
│ │ │ ├── FactionDepositArgument.java
│ │ │ ├── FactionDisbandArgument.java
│ │ │ ├── FactionHelpArgument.java
│ │ │ ├── FactionHomeArgument.java
│ │ │ ├── FactionInviteArgument.java
│ │ │ ├── FactionInvitesArgument.java
│ │ │ ├── FactionKickArgument.java
│ │ │ ├── FactionLeaderArgument.java
│ │ │ ├── FactionLeaveArgument.java
│ │ │ ├── FactionListArgument.java
│ │ │ ├── FactionMapArgument.java
│ │ │ ├── FactionMessageArgument.java
│ │ │ ├── FactionOpenArgument.java
│ │ │ ├── FactionPromoteArgument.java
│ │ │ ├── FactionRenameArgument.java
│ │ │ ├── FactionSetHomeArgument.java
│ │ │ ├── FactionShowArgument.java
│ │ │ ├── FactionStuckArgument.java
│ │ │ ├── FactionSubclaimArgumentExecutor.java
│ │ │ ├── FactionUnallyArgument.java
│ │ │ ├── FactionUnclaimArgument.java
│ │ │ ├── FactionUninviteArgument.java
│ │ │ ├── FactionUnsubclaimArgument.java
│ │ │ ├── FactionWithdrawArgument.java
│ │ │ ├── staff
│ │ │ │ ├── FactionChatSpyArgument.java
│ │ │ │ ├── FactionClaimForArgument.java
│ │ │ │ ├── FactionClearClaimsArgument.java
│ │ │ │ ├── FactionForceDemoteArgument.java
│ │ │ │ ├── FactionForceJoinArgument.java
│ │ │ │ ├── FactionForceKickArgument.java
│ │ │ │ ├── FactionForceLeaderArgument.java
│ │ │ │ ├── FactionForcePromoteArgument.java
│ │ │ │ ├── FactionForceUnclaimHereArgument.java
│ │ │ │ ├── FactionMuteArgument.java
│ │ │ │ ├── FactionRemoveArgument.java
│ │ │ │ ├── FactionSetDeathbanMultiplierArgument.java
│ │ │ │ ├── FactionSetDtrArgument.java
│ │ │ │ └── FactionSetDtrRegenArgument.java
│ │ │ └── subclaim
│ │ │ │ ├── FactionSubclaimAddMemberArgument.java
│ │ │ │ ├── FactionSubclaimCreateArgument.java
│ │ │ │ ├── FactionSubclaimDelMemberArgument.java
│ │ │ │ ├── FactionSubclaimDeleteArgument.java
│ │ │ │ ├── FactionSubclaimListArgument.java
│ │ │ │ ├── FactionSubclaimMembersArgument.java
│ │ │ │ ├── FactionSubclaimRenameArgument.java
│ │ │ │ └── FactionSubclaimStartArgument.java
│ │ ├── claim
│ │ │ ├── Claim.java
│ │ │ ├── ClaimHandler.java
│ │ │ ├── ClaimSelection.java
│ │ │ ├── ClaimWandListener.java
│ │ │ ├── Subclaim.java
│ │ │ └── SubclaimWandListener.java
│ │ ├── event
│ │ │ ├── CaptureZoneEnterEvent.java
│ │ │ ├── CaptureZoneLeaveEvent.java
│ │ │ ├── FactionChatEvent.java
│ │ │ ├── FactionClaimChangeEvent.java
│ │ │ ├── FactionClaimChangedEvent.java
│ │ │ ├── FactionCreateEvent.java
│ │ │ ├── FactionDtrChangeEvent.java
│ │ │ ├── FactionEvent.java
│ │ │ ├── FactionRelationCreateEvent.java
│ │ │ ├── FactionRelationRemoveEvent.java
│ │ │ ├── FactionRemoveEvent.java
│ │ │ ├── FactionRenameEvent.java
│ │ │ ├── PlayerClaimEnterEvent.java
│ │ │ ├── PlayerJoinFactionEvent.java
│ │ │ ├── PlayerJoinedFactionEvent.java
│ │ │ ├── PlayerLeaveFactionEvent.java
│ │ │ ├── PlayerLeftFactionEvent.java
│ │ │ └── cause
│ │ │ │ ├── ClaimChangeCause.java
│ │ │ │ └── FactionLeaveCause.java
│ │ ├── struct
│ │ │ ├── ChatChannel.java
│ │ │ ├── Raidable.java
│ │ │ ├── RegenStatus.java
│ │ │ ├── Relation.java
│ │ │ └── Role.java
│ │ └── type
│ │ │ ├── ClaimableFaction.java
│ │ │ ├── EndPortalFaction.java
│ │ │ ├── Faction.java
│ │ │ ├── PlayerFaction.java
│ │ │ ├── RoadFaction.java
│ │ │ ├── SpawnFaction.java
│ │ │ ├── WarzoneFaction.java
│ │ │ └── WildernessFaction.java
│ │ ├── listener
│ │ ├── BookDisenchantListener.java
│ │ ├── BottledExpListener.java
│ │ ├── ChatListener.java
│ │ ├── CoreListener.java
│ │ ├── Crowbar.java
│ │ ├── CrowbarListener.java
│ │ ├── DeathListener.java
│ │ ├── EnchantLimitListener.java
│ │ ├── EntityLimitListener.java
│ │ ├── EventSignListener.java
│ │ ├── ExpMultiplierListener.java
│ │ ├── FactionListener.java
│ │ ├── FurnaceSmeltSpeedListener.java
│ │ ├── PortalListener.java
│ │ ├── PotionLimitListener.java
│ │ ├── ProtectionListener.java
│ │ ├── SignSubclaimListener.java
│ │ ├── SkullListener.java
│ │ ├── WorldListener.java
│ │ └── fixes
│ │ │ ├── BeaconStrengthFixListener.java
│ │ │ ├── BlockHitFixListener.java
│ │ │ ├── BlockJumpGlitchFixListener.java
│ │ │ ├── BoatGlitchFixListener.java
│ │ │ ├── EnderChestRemovalListener.java
│ │ │ ├── InfinityArrowFixListener.java
│ │ │ ├── PearlGlitchListener.java
│ │ │ └── VoidGlitchFixListener.java
│ │ ├── packetwrapper
│ │ ├── AbstractPacket.java
│ │ └── WrapperPlayServerMultiBlockChange.java
│ │ ├── pvpclass
│ │ ├── PvpClass.java
│ │ ├── PvpClassManager.java
│ │ ├── archer
│ │ │ ├── ArcherClass.java
│ │ │ └── ArcherMark.java
│ │ ├── bard
│ │ │ ├── BardClass.java
│ │ │ ├── BardData.java
│ │ │ ├── BardEffect.java
│ │ │ └── EffectRestorer.java
│ │ ├── event
│ │ │ ├── PvpClassEquipEvent.java
│ │ │ └── PvpClassUnequipEvent.java
│ │ └── type
│ │ │ ├── AssassinClass.java
│ │ │ ├── MinerClass.java
│ │ │ └── RogueClass.java
│ │ ├── scoreboard
│ │ ├── BufferedObjective.java
│ │ ├── PlayerBoard.java
│ │ ├── ScoreboardHandler.java
│ │ ├── SidebarEntry.java
│ │ ├── SidebarProvider.java
│ │ └── provider
│ │ │ └── TimerSidebarProvider.java
│ │ ├── sotw
│ │ ├── SotwCommand.java
│ │ ├── SotwListener.java
│ │ └── SotwTimer.java
│ │ ├── timer
│ │ ├── GlobalTimer.java
│ │ ├── PlayerTimer.java
│ │ ├── Timer.java
│ │ ├── TimerCooldown.java
│ │ ├── TimerExecutor.java
│ │ ├── TimerManager.java
│ │ ├── argument
│ │ │ ├── TimerCheckArgument.java
│ │ │ └── TimerSetArgument.java
│ │ ├── event
│ │ │ ├── TimerClearEvent.java
│ │ │ ├── TimerExpireEvent.java
│ │ │ ├── TimerExtendEvent.java
│ │ │ ├── TimerPauseEvent.java
│ │ │ └── TimerStartEvent.java
│ │ └── type
│ │ │ ├── CombatTimer.java
│ │ │ ├── EnderPearlTimer.java
│ │ │ ├── GappleTimer.java
│ │ │ ├── InvincibilityTimer.java
│ │ │ ├── LogoutTimer.java
│ │ │ ├── PvpClassWarmupTimer.java
│ │ │ ├── StuckTimer.java
│ │ │ └── TeleportTimer.java
│ │ ├── user
│ │ ├── FactionUser.java
│ │ └── UserManager.java
│ │ ├── util
│ │ ├── ConcurrentValueOrderedMap.java
│ │ ├── DelayedMessageRunnable.java
│ │ ├── DurationFormatter.java
│ │ ├── NameUtils.java
│ │ ├── NmsUtils.java
│ │ ├── ReflectionUtils.java
│ │ ├── SpigotUtils.java
│ │ └── UUIDFetcher.java
│ │ └── visualise
│ │ ├── BlockFiller.java
│ │ ├── ProtocolLibHook.java
│ │ ├── VisualBlock.java
│ │ ├── VisualBlockData.java
│ │ ├── VisualType.java
│ │ ├── VisualiseHandler.java
│ │ ├── VisualiseUtil.java
│ │ └── WallBorderListener.java
│ └── resources
│ ├── balances.yml
│ ├── config.cdl
│ ├── eventSchedules.txt
│ ├── faction-users.yml
│ ├── factions.yml
│ ├── imageMessages
│ └── gapple.png
│ ├── lives.yml
│ ├── plugin.yml
│ └── timers.yml
├── extra
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── org
│ │ └── ipvp
│ │ └── hcfextra
│ │ ├── Configuration.java
│ │ ├── HCFExtra.java
│ │ ├── command
│ │ ├── CoordsCommand.java
│ │ ├── EndportalHandler.java
│ │ ├── HCFExtraCommand.java
│ │ └── HelpCommand.java
│ │ └── inventoryrestore
│ │ └── InventoryRestoreHandler.java
│ └── resources
│ ├── coords.txt
│ ├── help.txt
│ └── plugin.yml
└── pom.xml
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea
2 | /*/target
3 | /*/*.iml
4 | /*.iml
5 | /*/dependency-reduced-pom.xml
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Matthew Steglinski
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # iHCF - Hardcore Factions Core #
2 |
iHCF is a well rounded HCF core developed by primarily by DoctorDark
3 | for various servers (Para, IPVP, etc). It improves the game-play of factions while increasing
4 | the challenge of the game.
5 |
6 | This plugin is currently not in use by the IPVP network and as such updates and
7 | bug fixes may be far and few. I make no promises on the state of the code and it
8 | being bug free, this repository is primarily for educational purposes. However,
9 | reporting issues are always welcome as it allows the community to see what bugs
10 | are present in the current build.
11 |
12 | ## Compilation ##
13 | Compilation requires the following be fulfilled:
14 |
15 | * [Java 8](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
16 | * [Maven 3](http://maven.apache.org/download.html)
17 | * You will need to verify that the following resources have been installed:
18 | * [IPVP PaperSpigot 1.7.10](https://github.com/IPVP-MC/Paper-1.7)
19 | * [iBase](https://github.com/IPVP-MC/iBase)
20 | * Newbies: Installation instructions provided at the links above
21 |
22 | Once these tasks have been taken care of, compilation via `mvn clean install` will result in `core/target/iHCF.jar` being created.
23 |
24 | ## License ##
25 | This software is available under the following licenses:
26 |
27 | * MIT
28 |
29 | ## Notes ##
30 | To whom it may concern,
31 |
32 | As the owner of the former HCF server "IPVP" previously available at IPVP.org, of which the iHCF software was created/modified/given to/for as witnessed in the original stub commit by DoctorDark [here](https://github.com/IPVP-MC/iHCF/commit/dcab2972de84481ea88ee2fbefdcd5be9eb9aaea), please heed the following.
33 |
34 | As per the [MIT license that this plugin is under](/LICENSE.txt), this software is available for any person to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software. Please consider this note as my giving explicit permission to any persons for the aforementioned claims as defined by the license.
35 |
36 | This note may also be considered as giving explicit permissions for redistribution/modification/sublicensing as specified in rules 5.4 (`"Do not offer or sell anything you do not own or have the right to redistribute."`) and 6.6 (`"Do not attempt to sell/leak or otherwise redistribute content which is not both unique and owned by you"`) of the MCM Rules as seen [here](https://www.mc-market.org/wiki/rules/). Additionally, this note may also be considered as granting any applicable rights (as defined by the license) for the software which may be required by MCM staff as per the MCM Redistribution Rights requirements (see [here](https://www.mc-market.org/wiki/redistribution-rights/)).
37 |
38 | Saint
39 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/ConfigurationService.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf;
2 |
3 | import org.bukkit.World;
4 |
5 | import java.util.EnumMap;
6 | import java.util.Map;
7 |
8 | //TODO: This needs to be removed.
9 | @Deprecated
10 | public final class ConfigurationService {
11 |
12 | public static final int END_PORTAL_RADIUS = 20;
13 | public static final int END_PORTAL_CENTER = 500;
14 | public static final Map ROAD_LENGTHS = new EnumMap<>(World.Environment.class);
15 | public static final Map SPAWN_RADIUS_MAP = new EnumMap<>(World.Environment.class);
16 |
17 | static {
18 | ROAD_LENGTHS.put(World.Environment.NORMAL, 4000);
19 | ROAD_LENGTHS.put(World.Environment.NETHER, 4000);
20 |
21 | SPAWN_RADIUS_MAP.put(World.Environment.NORMAL, 50);
22 | SPAWN_RADIUS_MAP.put(World.Environment.NETHER, 25);
23 | SPAWN_RADIUS_MAP.put(World.Environment.THE_END, 15);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/DateTimeFormats.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf;
2 |
3 | import com.google.common.base.Preconditions;
4 | import org.apache.commons.lang3.time.FastDateFormat;
5 |
6 | import java.text.DecimalFormat;
7 | import java.util.Locale;
8 | import java.util.TimeZone;
9 | import java.util.concurrent.atomic.AtomicBoolean;
10 |
11 | public final class DateTimeFormats {
12 |
13 | private static final AtomicBoolean loaded = new AtomicBoolean(false);
14 |
15 | public static FastDateFormat DAY_MTH_HR_MIN_SECS;
16 | public static FastDateFormat DAY_MTH_YR_HR_MIN_AMPM;
17 | public static FastDateFormat DAY_MTH_HR_MIN_AMPM;
18 | public static FastDateFormat HR_MIN_AMPM;
19 | public static FastDateFormat HR_MIN_AMPM_TIMEZONE;
20 | public static FastDateFormat HR_MIN;
21 | public static FastDateFormat KOTH_FORMAT;
22 |
23 | private DateTimeFormats() {
24 | }
25 |
26 | public static void reload(TimeZone timeZone) throws IllegalStateException {
27 | Preconditions.checkArgument(!loaded.getAndSet(true), "Already loaded");
28 |
29 | DAY_MTH_HR_MIN_SECS = FastDateFormat.getInstance("dd/MM HH:mm:ss", timeZone, Locale.ENGLISH);
30 | DAY_MTH_YR_HR_MIN_AMPM = FastDateFormat.getInstance("dd/MM/yy hh:mma", timeZone, Locale.ENGLISH);
31 | DAY_MTH_HR_MIN_AMPM = FastDateFormat.getInstance("dd/MM hh:mma", timeZone, Locale.ENGLISH);
32 | HR_MIN_AMPM = FastDateFormat.getInstance("hh:mma", timeZone, Locale.ENGLISH);
33 | HR_MIN_AMPM_TIMEZONE = FastDateFormat.getInstance("hh:mma z", timeZone, Locale.ENGLISH);
34 | HR_MIN = FastDateFormat.getInstance("hh:mm", timeZone, Locale.ENGLISH);
35 | KOTH_FORMAT = FastDateFormat.getInstance("m:ss", timeZone, Locale.ENGLISH);
36 | }
37 |
38 | // The format used to show one decimal without a trailing zero.
39 | public static final ThreadLocal REMAINING_SECONDS = new ThreadLocal() {
40 | @Override
41 | protected DecimalFormat initialValue() {
42 | return new DecimalFormat("0.#");
43 | }
44 | };
45 |
46 | public static final ThreadLocal REMAINING_SECONDS_TRAILING = new ThreadLocal() {
47 | @Override
48 | protected DecimalFormat initialValue() {
49 | return new DecimalFormat("0.0");
50 | }
51 | };
52 | }
53 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/ImageFolder.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf;
2 |
3 | import com.google.common.io.ByteStreams;
4 | import lombok.Getter;
5 |
6 | import javax.imageio.ImageIO;
7 | import java.awt.image.BufferedImage;
8 | import java.io.File;
9 | import java.io.FileOutputStream;
10 | import java.io.IOException;
11 | import java.io.InputStream;
12 | import java.io.OutputStream;
13 | import java.util.logging.Level;
14 |
15 | public class ImageFolder {
16 |
17 | @Getter
18 | private final File directory;
19 | private final HCF plugin;
20 |
21 | @Getter
22 | private BufferedImage gopple;
23 |
24 | public ImageFolder(HCF plugin) {
25 | this.plugin = plugin;
26 |
27 | directory = new File(plugin.getDataFolder(), "imageMessages");
28 | if (!directory.exists() && directory.mkdir()) {
29 | plugin.getLogger().log(Level.INFO, "Created image directory");
30 | }
31 |
32 | gopple = load("gapple.png");
33 | }
34 |
35 | public BufferedImage load(String imageName) {
36 | File file = new File(directory, imageName);
37 | if (file.exists()) {
38 | try {
39 | return ImageIO.read(file);
40 | } catch (IOException ignored) {
41 | // continue to next block
42 | }
43 | }
44 |
45 | plugin.getLogger().info("Attempting to copy resource '" + imageName + "' to plugin folder");
46 | try (InputStream input = plugin.getResource(directory.getName() + "/" + file.getName()); OutputStream output = new FileOutputStream(file)) {
47 | ByteStreams.copy(input, output);
48 | return ImageIO.read(input);
49 | } catch (IOException ex) {
50 | plugin.getLogger().log(Level.WARNING, "Failed to get resource for file '" + imageName + "'", ex);
51 | return null;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/combatlog/event/LoggerDeathEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.combatlog.event;
2 |
3 | import com.doctordark.hcf.combatlog.type.LoggerEntity;
4 | import org.bukkit.event.Event;
5 | import org.bukkit.event.HandlerList;
6 |
7 | public class LoggerDeathEvent extends Event {
8 |
9 | private static final HandlerList handlers = new HandlerList();
10 |
11 | private final LoggerEntity loggerEntity;
12 |
13 | public LoggerDeathEvent(LoggerEntity loggerEntity) {
14 | this.loggerEntity = loggerEntity;
15 | }
16 |
17 | public LoggerEntity getLoggerEntity() {
18 | return loggerEntity;
19 | }
20 |
21 | public static HandlerList getHandlerList() {
22 | return handlers;
23 | }
24 |
25 | @Override
26 | public HandlerList getHandlers() {
27 | return handlers;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/combatlog/event/LoggerRemovedEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.combatlog.event;
2 |
3 | import com.doctordark.hcf.combatlog.type.LoggerEntity;
4 | import org.bukkit.event.Event;
5 | import org.bukkit.event.HandlerList;
6 |
7 | public class LoggerRemovedEvent extends Event {
8 |
9 | private static final HandlerList handlers = new HandlerList();
10 |
11 | private final LoggerEntity loggerEntity;
12 |
13 | public LoggerRemovedEvent(LoggerEntity loggerEntity) {
14 | this.loggerEntity = loggerEntity;
15 | }
16 |
17 | public LoggerEntity getLoggerEntity() {
18 | return loggerEntity;
19 | }
20 |
21 | public static HandlerList getHandlerList() {
22 | return handlers;
23 | }
24 |
25 | @Override
26 | public HandlerList getHandlers() {
27 | return handlers;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/combatlog/event/LoggerSpawnEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.combatlog.event;
2 |
3 | import com.doctordark.hcf.combatlog.type.LoggerEntity;
4 | import org.bukkit.event.Cancellable;
5 | import org.bukkit.event.Event;
6 | import org.bukkit.event.HandlerList;
7 |
8 | public class LoggerSpawnEvent extends Event implements Cancellable {
9 |
10 | private static final HandlerList handlers = new HandlerList();
11 |
12 | private boolean cancelled;
13 | private final LoggerEntity loggerEntity;
14 |
15 | public LoggerSpawnEvent(LoggerEntity loggerEntity) {
16 | this.loggerEntity = loggerEntity;
17 | }
18 |
19 | public LoggerEntity getLoggerEntity() {
20 | return loggerEntity;
21 | }
22 |
23 | @Override
24 | public boolean isCancelled() {
25 | return this.cancelled;
26 | }
27 |
28 | @Override
29 | public void setCancelled(boolean cancelled) {
30 | this.cancelled = cancelled;
31 | }
32 |
33 | public static HandlerList getHandlerList() {
34 | return handlers;
35 | }
36 |
37 | @Override
38 | public HandlerList getHandlers() {
39 | return handlers;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/combatlog/type/LoggerEntity.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.combatlog.type;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
5 |
6 | import java.util.UUID;
7 |
8 | public interface LoggerEntity {
9 |
10 | /**
11 | * Spawns this NPC.
12 | *
13 | * @param plugin the plugin instance
14 | */
15 | void postSpawn(HCF plugin);
16 |
17 | /**
18 | * Gets the Bukkit entity view.
19 | *
20 | * @return the {@link org.bukkit.entity.Entity}
21 | */
22 | CraftPlayer getBukkitEntity();
23 |
24 | /**
25 | * Gets the {@link UUID} of the represented.
26 | *
27 | * @return the represented {@link UUID}
28 | */
29 | UUID getUniqueID();
30 |
31 | /**
32 | * Removes this entity.
33 | */
34 | void destroy();
35 | }
36 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/command/AngleCommand.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.command;
2 |
3 | import com.doctordark.util.JavaUtils;
4 | import org.bukkit.ChatColor;
5 | import org.bukkit.Location;
6 | import org.bukkit.command.Command;
7 | import org.bukkit.command.CommandExecutor;
8 | import org.bukkit.command.CommandSender;
9 | import org.bukkit.command.TabCompleter;
10 | import org.bukkit.entity.Player;
11 |
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | /**
16 | * Command used to check the angle and yaw positions of {@link Player}s.
17 | */
18 | public class AngleCommand implements CommandExecutor, TabCompleter {
19 |
20 | @Override
21 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
22 | if (!(sender instanceof Player)) {
23 | sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
24 | return true;
25 | }
26 |
27 | Location location = ((Player) sender).getLocation();
28 | sender.sendMessage(ChatColor.GOLD + JavaUtils.format(location.getYaw()) + " yaw" + ChatColor.WHITE + ", " + ChatColor.GOLD
29 | + JavaUtils.format(location.getPitch()) + " pitch");
30 |
31 | return true;
32 | }
33 |
34 | @Override
35 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
36 | return Collections.emptyList();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/command/DeathCommand.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.command;
2 |
3 | import org.bukkit.ChatColor;
4 | import org.bukkit.command.Command;
5 | import org.bukkit.command.CommandExecutor;
6 | import org.bukkit.command.CommandSender;
7 | import org.bukkit.command.TabCompleter;
8 |
9 | import java.util.Collections;
10 | import java.util.List;
11 |
12 | public class DeathCommand implements CommandExecutor, TabCompleter {
13 |
14 | @Override
15 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
16 | if (args.length > 0) {
17 | sender.sendMessage("Currently unimplemented.");
18 | return true;
19 | }
20 |
21 | sender.sendMessage(ChatColor.RED + "Usage: /" + label + " ");
22 | return true;
23 | }
24 |
25 | @Override
26 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
27 | return Collections.emptyList();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/command/GoppleCommand.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.command;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.timer.PlayerTimer;
5 | import com.doctordark.hcf.util.DurationFormatter;
6 | import org.bukkit.ChatColor;
7 | import org.bukkit.command.Command;
8 | import org.bukkit.command.CommandExecutor;
9 | import org.bukkit.command.CommandSender;
10 | import org.bukkit.command.TabCompleter;
11 | import org.bukkit.entity.Player;
12 |
13 | import java.util.Collections;
14 | import java.util.List;
15 |
16 | /**
17 | * Command used to check remaining Notch Apple cooldown time for {@link Player}.
18 | */
19 | public class GoppleCommand implements CommandExecutor, TabCompleter {
20 |
21 | private final HCF plugin;
22 |
23 | public GoppleCommand(HCF plugin) {
24 | this.plugin = plugin;
25 | }
26 |
27 | @Override
28 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
29 | if (!(sender instanceof Player)) {
30 | sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
31 | return true;
32 | }
33 |
34 | Player player = (Player) sender;
35 |
36 | PlayerTimer timer = plugin.getTimerManager().getGappleTimer();
37 | long remaining = timer.getRemaining(player);
38 |
39 | if (remaining <= 0L) {
40 | sender.sendMessage(ChatColor.RED + "Your " + timer.getName() + ChatColor.RED + " timer is currently not active.");
41 | return true;
42 | }
43 |
44 | sender.sendMessage(ChatColor.YELLOW + "Your " + timer.getName() + ChatColor.YELLOW + " timer is active for another "
45 | + ChatColor.BOLD + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.YELLOW + '.');
46 |
47 | return true;
48 | }
49 |
50 | @Override
51 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
52 | return Collections.emptyList();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/command/LocationCommand.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.command;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.faction.type.Faction;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.ChatColor;
7 | import org.bukkit.Location;
8 | import org.bukkit.command.Command;
9 | import org.bukkit.command.CommandExecutor;
10 | import org.bukkit.command.CommandSender;
11 | import org.bukkit.command.TabCompleter;
12 | import org.bukkit.entity.Player;
13 |
14 | import java.util.Collections;
15 | import java.util.List;
16 |
17 | /**
18 | * Command used to check current the current {@link Faction} at
19 | * the position of a given {@link Player}s {@link Location}.
20 | */
21 | public class LocationCommand implements CommandExecutor, TabCompleter {
22 |
23 | private final HCF plugin;
24 |
25 | public LocationCommand(HCF plugin) {
26 | this.plugin = plugin;
27 | }
28 |
29 | @Override
30 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
31 | Player target;
32 | if (args.length >= 1 && sender.hasPermission(command.getPermission() + ".others")) {
33 | target = Bukkit.getPlayer(args[0]);
34 | } else if (sender instanceof Player) {
35 | target = (Player) sender;
36 | } else {
37 | sender.sendMessage(ChatColor.RED + "Usage: /" + label + " [playerName]");
38 | return true;
39 | }
40 |
41 | if (target == null || (sender instanceof Player && !((Player) sender).canSee(target))) {
42 | sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[0] + ChatColor.GOLD + "' not found.");
43 | return true;
44 | }
45 |
46 | Location location = target.getLocation();
47 | Faction factionAt = plugin.getFactionManager().getFactionAt(location);
48 | sender.sendMessage(ChatColor.YELLOW + target.getName() + " is in the territory of " + factionAt.getDisplayName(sender)
49 | + ChatColor.YELLOW + '(' + (factionAt.isSafezone() ? ChatColor.GREEN + "Non-Deathban" : ChatColor.RED + "Deathban") + ChatColor.YELLOW + ')');
50 |
51 | return true;
52 | }
53 |
54 | @Override
55 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
56 | return args.length == 1 && sender.hasPermission(command.getPermission() + ".others") ? null : Collections.emptyList();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/command/LogoutCommand.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.command;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.timer.type.LogoutTimer;
5 | import org.bukkit.ChatColor;
6 | import org.bukkit.command.Command;
7 | import org.bukkit.command.CommandExecutor;
8 | import org.bukkit.command.CommandSender;
9 | import org.bukkit.command.TabCompleter;
10 | import org.bukkit.entity.Player;
11 |
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | public class LogoutCommand implements CommandExecutor, TabCompleter {
16 |
17 | private final HCF plugin;
18 |
19 | public LogoutCommand(HCF plugin) {
20 | this.plugin = plugin;
21 | }
22 |
23 | @Override
24 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
25 | if (!(sender instanceof Player)) {
26 | sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
27 | return true;
28 | }
29 |
30 | Player player = (Player) sender;
31 | LogoutTimer logoutTimer = plugin.getTimerManager().getLogoutTimer();
32 |
33 | if (!logoutTimer.setCooldown(player, player.getUniqueId())) {
34 | sender.sendMessage(ChatColor.RED + "Your " + logoutTimer.getName() + ChatColor.RED + " timer is already active.");
35 | return true;
36 | }
37 |
38 | sender.sendMessage(ChatColor.RED + "Your " + logoutTimer.getName() + ChatColor.RED + " timer has started.");
39 | return true;
40 | }
41 |
42 | @Override
43 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
44 | return Collections.emptyList();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/command/ServerTimeCommand.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.command;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import org.apache.commons.lang3.time.FastDateFormat;
5 | import org.bukkit.ChatColor;
6 | import org.bukkit.command.Command;
7 | import org.bukkit.command.CommandExecutor;
8 | import org.bukkit.command.CommandSender;
9 | import org.bukkit.command.TabCompleter;
10 |
11 | import java.util.Collections;
12 | import java.util.List;
13 | import java.util.Locale;
14 |
15 | /**
16 | * Command used to check the current time for the server.
17 | */
18 | public class ServerTimeCommand implements CommandExecutor, TabCompleter {
19 |
20 | private final FastDateFormat format;
21 |
22 | public ServerTimeCommand(HCF plugin) {
23 | format = FastDateFormat.getInstance("E MMM dd h:mm:ssa z yyyy", plugin.getConfiguration().getServerTimeZone(), Locale.ENGLISH);
24 | }
25 |
26 | @Override
27 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
28 | sender.sendMessage(ChatColor.GREEN + "The server time is " + ChatColor.LIGHT_PURPLE + format.format(System.currentTimeMillis()) + ChatColor.GREEN + '.');
29 | return true;
30 | }
31 |
32 | @Override
33 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
34 | return Collections.emptyList();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/command/ToggleCapzoneEntryCommand.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.command;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.user.FactionUser;
5 | import org.bukkit.ChatColor;
6 | import org.bukkit.command.Command;
7 | import org.bukkit.command.CommandExecutor;
8 | import org.bukkit.command.CommandSender;
9 | import org.bukkit.command.TabExecutor;
10 | import org.bukkit.entity.Player;
11 |
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | /**
16 | * Command used to toggle messages shown when entering or leaving
17 | */
18 | public class ToggleCapzoneEntryCommand implements CommandExecutor, TabExecutor {
19 |
20 | private final HCF plugin;
21 |
22 | public ToggleCapzoneEntryCommand(HCF plugin) {
23 | this.plugin = plugin;
24 | }
25 |
26 | @Override
27 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
28 | if (!(sender instanceof Player)) {
29 | sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
30 | return true;
31 | }
32 |
33 | FactionUser factionUser = plugin.getUserManager().getUser(((Player) sender).getUniqueId());
34 | boolean newStatus = !factionUser.isCapzoneEntryAlerts();
35 | factionUser.setCapzoneEntryAlerts(newStatus);
36 |
37 | sender.sendMessage(ChatColor.AQUA + "You will now " + (newStatus ? ChatColor.GREEN.toString() : ChatColor.RED + "un") + "able" +
38 | ChatColor.AQUA + " to see capture zone entry messages.");
39 |
40 | return true;
41 | }
42 |
43 | @Override
44 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
45 | return Collections.emptyList();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/command/ToggleLightningCommand.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.command;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.user.FactionUser;
5 | import org.bukkit.ChatColor;
6 | import org.bukkit.command.Command;
7 | import org.bukkit.command.CommandExecutor;
8 | import org.bukkit.command.CommandSender;
9 | import org.bukkit.command.TabExecutor;
10 | import org.bukkit.entity.Player;
11 |
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | /**
16 | * Command used to toggle the lightning strikes on death for a {@link Player}.
17 | */
18 | public class ToggleLightningCommand implements CommandExecutor, TabExecutor {
19 |
20 | private final HCF plugin;
21 |
22 | public ToggleLightningCommand(HCF plugin) {
23 | this.plugin = plugin;
24 | }
25 |
26 | @Override
27 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
28 | if (!(sender instanceof Player)) {
29 | sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
30 | return true;
31 | }
32 |
33 | FactionUser factionUser = plugin.getUserManager().getUser(((Player) sender).getUniqueId());
34 | boolean newShowLightning = !factionUser.isShowLightning();
35 | factionUser.setShowLightning(newShowLightning);
36 |
37 | sender.sendMessage(ChatColor.AQUA + "You will now " + (newShowLightning ? ChatColor.GREEN + "able" : ChatColor.RED + "unable") +
38 | ChatColor.AQUA + " to see lightning strikes on death.");
39 |
40 | return true;
41 | }
42 |
43 | @Override
44 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
45 | return Collections.emptyList();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/command/ToggleSidebarCommand.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.command;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.scoreboard.PlayerBoard;
5 | import org.bukkit.ChatColor;
6 | import org.bukkit.command.Command;
7 | import org.bukkit.command.CommandExecutor;
8 | import org.bukkit.command.CommandSender;
9 | import org.bukkit.command.TabExecutor;
10 | import org.bukkit.entity.Player;
11 |
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | /**
16 | * Command used to toggle the sidebar for a {@link Player}.
17 | */
18 | public class ToggleSidebarCommand implements CommandExecutor, TabExecutor {
19 |
20 | private final HCF plugin;
21 |
22 | public ToggleSidebarCommand(HCF plugin) {
23 | this.plugin = plugin;
24 | }
25 |
26 | @Override
27 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
28 | if (!(sender instanceof Player)) {
29 | sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
30 | return true;
31 | }
32 |
33 | PlayerBoard playerBoard = plugin.getScoreboardHandler().getPlayerBoard(((Player) sender).getUniqueId());
34 | boolean newVisibile = !playerBoard.isSidebarVisible();
35 | playerBoard.setSidebarVisible(newVisibile);
36 |
37 | sender.sendMessage(ChatColor.YELLOW + "Scoreboard sidebar is " + (newVisibile ? ChatColor.GREEN + "now" : ChatColor.RED + "no longer") + ChatColor.YELLOW + " visible.");
38 | return true;
39 | }
40 |
41 | @Override
42 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
43 | return Collections.emptyList();
44 | }
45 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/deathban/DeathbanManager.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.deathban;
2 |
3 | import gnu.trove.map.TObjectIntMap;
4 | import org.bukkit.entity.Player;
5 |
6 | import java.util.UUID;
7 | import java.util.concurrent.TimeUnit;
8 |
9 | public interface DeathbanManager {
10 |
11 | long MAX_DEATHBAN_TIME = TimeUnit.HOURS.toMillis(8);
12 |
13 | /**
14 | * Gets the map storing the lives with the {@link UUID} string by the amount.
15 | *
16 | * @return the lives map
17 | */
18 | TObjectIntMap getLivesMap();
19 |
20 | /**
21 | * Gets the lives of a player.
22 | *
23 | * @param uuid the uuid of player to get for
24 | * @return the amount of owned lives
25 | */
26 | int getLives(UUID uuid);
27 |
28 | /**
29 | * Sets the amount of lives a player has.
30 | *
31 | * @param uuid the uuid of player to set for
32 | * @param amount the amount to set at
33 | * @return the new lives of the player
34 | */
35 | int setLives(UUID uuid, int amount);
36 |
37 | /**
38 | * Gives lives to a player.
39 | *
40 | * @param uuid the uuid of player to give to
41 | * @param amount the amount to give
42 | * @return the new lives of the player
43 | */
44 | int addLives(UUID uuid, int amount);
45 |
46 | /**
47 | * Takes lives away from a player.
48 | *
49 | * @param uuid the uuid of player to take for
50 | * @param amount the amount to take
51 | * @return the new lives of the player
52 | */
53 | int takeLives(UUID uuid, int amount);
54 |
55 | /**
56 | * Gets the deathban multiplier for a {@link Player}.
57 | *
58 | * @param player the {@link Player} to get for
59 | * @return the deathban multiplier
60 | */
61 | double getDeathBanMultiplier(Player player);
62 |
63 | /**
64 | * Applies a {@link Deathban} to a {@link Player}.
65 | *
66 | * @param player the {@link Player} to apply to
67 | * @param reason the reason for {@link Deathban}
68 | * @return the {@link Deathban} that has been applied
69 | */
70 | Deathban applyDeathBan(Player player, String reason);
71 |
72 | /**
73 | * Applies a {@link Deathban} to a {@link Player}.
74 | *
75 | * @param uuid the uuid of player to apply to
76 | * @param deathban the {@link Deathban} to be applied
77 | * @return the {@link Deathban} that has been applied
78 | */
79 | Deathban applyDeathBan(UUID uuid, Deathban deathban);
80 |
81 | /**
82 | * Reloads deathban data from storage.
83 | */
84 | void reloadDeathbanData();
85 |
86 | /**
87 | * Saves deathban data to storage.
88 | */
89 | void saveDeathbanData();
90 | }
91 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/deathban/lives/LivesExecutor.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.deathban.lives;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.deathban.lives.argument.LivesCheckArgument;
5 | import com.doctordark.hcf.deathban.lives.argument.LivesCheckDeathbanArgument;
6 | import com.doctordark.hcf.deathban.lives.argument.LivesClearDeathbansArgument;
7 | import com.doctordark.hcf.deathban.lives.argument.LivesGiveArgument;
8 | import com.doctordark.hcf.deathban.lives.argument.LivesReviveArgument;
9 | import com.doctordark.hcf.deathban.lives.argument.LivesSetArgument;
10 | import com.doctordark.hcf.deathban.lives.argument.LivesSetDeathbanTimeArgument;
11 | import com.doctordark.util.command.ArgumentExecutor;
12 |
13 | /**
14 | * Handles the execution and tab completion of the lives command.
15 | */
16 | public class LivesExecutor extends ArgumentExecutor {
17 |
18 | public LivesExecutor(HCF plugin) {
19 | super("lives");
20 |
21 | addArgument(new LivesCheckArgument(plugin));
22 | addArgument(new LivesCheckDeathbanArgument(plugin));
23 | addArgument(new LivesClearDeathbansArgument(plugin));
24 | addArgument(new LivesGiveArgument(plugin));
25 | addArgument(new LivesReviveArgument(plugin));
26 | addArgument(new LivesSetArgument(plugin));
27 | addArgument(new LivesSetDeathbanTimeArgument(plugin));
28 | }
29 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/deathban/lives/argument/LivesCheckArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.deathban.lives.argument;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.util.command.CommandArgument;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.ChatColor;
7 | import org.bukkit.OfflinePlayer;
8 | import org.bukkit.command.Command;
9 | import org.bukkit.command.CommandSender;
10 | import org.bukkit.entity.Player;
11 |
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | /**
16 | * An {@link CommandArgument} used to check how many lives a {@link Player} has.
17 | */
18 | public class LivesCheckArgument extends CommandArgument {
19 |
20 | private final HCF plugin;
21 |
22 | public LivesCheckArgument(HCF plugin) {
23 | super("check", "Check how much lives a player has");
24 | this.plugin = plugin;
25 | this.permission = "hcf.command.lives.argument." + getName();
26 | }
27 |
28 | @Override
29 | public String getUsage(String label) {
30 | return '/' + label + ' ' + getName() + " [playerName]";
31 | }
32 |
33 | @Override
34 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
35 | OfflinePlayer target;
36 | if (args.length > 1) {
37 | target = Bukkit.getOfflinePlayer(args[1]); //TODO: breaking
38 | } else if (sender instanceof Player) {
39 | target = (Player) sender;
40 | } else {
41 | sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
42 | return true;
43 | }
44 |
45 | if (!target.hasPlayedBefore() && !target.isOnline()) {
46 | sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[1] + ChatColor.GOLD + "' not found.");
47 | return true;
48 | }
49 |
50 | int targetLives = plugin.getDeathbanManager().getLives(target.getUniqueId());
51 |
52 | sender.sendMessage(target.getName() + ChatColor.YELLOW + " has " + ChatColor.AQUA + targetLives + ChatColor.YELLOW + ' ' + (targetLives == 1 ? "life" : "lives") + '.');
53 | return true;
54 | }
55 |
56 | @Override
57 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
58 | return args.length == 2 ? null : Collections.emptyList();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/deathban/lives/argument/LivesClearDeathbansArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.deathban.lives.argument;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.deathban.Deathban;
5 | import com.doctordark.hcf.user.FactionUser;
6 | import com.doctordark.util.command.CommandArgument;
7 | import org.bukkit.ChatColor;
8 | import org.bukkit.command.Command;
9 | import org.bukkit.command.CommandSender;
10 |
11 | /**
12 | * An {@link CommandArgument} used to clear all {@link Deathban}s.
13 | */
14 | public class LivesClearDeathbansArgument extends CommandArgument {
15 |
16 | private final HCF plugin;
17 |
18 | public LivesClearDeathbansArgument(HCF plugin) {
19 | super("cleardeathbans", "Clears the global deathbans");
20 | this.plugin = plugin;
21 | this.aliases = new String[]{"resetdeathbans"};
22 | this.permission = "hcf.command.lives.argument." + getName();
23 | }
24 |
25 | @Override
26 | public String getUsage(String label) {
27 | return '/' + label + ' ' + getName();
28 | }
29 |
30 | @Override
31 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
32 | for (FactionUser user : plugin.getUserManager().getUsers().values()) {
33 | user.removeDeathban();
34 | }
35 |
36 | Command.broadcastCommandMessage(sender, ChatColor.YELLOW + "All death-bans have been cleared.");
37 | return true;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/deathban/lives/argument/LivesSetArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.deathban.lives.argument;
2 |
3 | import com.doctordark.base.BaseConstants;
4 | import com.doctordark.hcf.HCF;
5 | import com.doctordark.util.BukkitUtils;
6 | import com.doctordark.util.JavaUtils;
7 | import com.doctordark.util.command.CommandArgument;
8 | import org.bukkit.ChatColor;
9 | import org.bukkit.OfflinePlayer;
10 | import org.bukkit.command.Command;
11 | import org.bukkit.command.CommandSender;
12 | import org.bukkit.entity.Player;
13 |
14 | import java.util.Collections;
15 | import java.util.List;
16 |
17 | /**
18 | * An {@link CommandArgument} used to set the lives of {@link Player}s.
19 | */
20 | public class LivesSetArgument extends CommandArgument {
21 |
22 | private final HCF plugin;
23 |
24 | public LivesSetArgument(HCF plugin) {
25 | super("set", "Set how much lives a player has");
26 | this.plugin = plugin;
27 | this.permission = "hcf.command.lives.argument." + getName();
28 | }
29 |
30 | @Override
31 | public String getUsage(String label) {
32 | return '/' + label + ' ' + getName() + " ";
33 | }
34 |
35 | @Override
36 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
37 | if (args.length < 3) {
38 | sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
39 | return true;
40 | }
41 |
42 | Integer amount = JavaUtils.tryParseInt(args[2]);
43 |
44 | if (amount == null) {
45 | sender.sendMessage(ChatColor.RED + "'" + args[2] + "' is not a number.");
46 | return true;
47 | }
48 |
49 | OfflinePlayer target = BukkitUtils.offlinePlayerWithNameOrUUID(args[1]);
50 |
51 | if (!target.hasPlayedBefore() && !target.isOnline()) {
52 | sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, args[1]));
53 | return true;
54 | }
55 |
56 | plugin.getDeathbanManager().setLives(target.getUniqueId(), amount);
57 |
58 | sender.sendMessage(ChatColor.YELLOW + target.getName() + " now has " + ChatColor.GOLD + amount + ChatColor.YELLOW + " lives.");
59 | return true;
60 | }
61 |
62 | @Override
63 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
64 | return args.length == 2 ? null : Collections.emptyList();
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/deathban/lives/argument/LivesSetDeathbanTimeArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.deathban.lives.argument;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.deathban.Deathban;
5 | import com.doctordark.util.JavaUtils;
6 | import com.doctordark.util.command.CommandArgument;
7 | import org.apache.commons.lang3.time.DurationFormatUtils;
8 | import org.bukkit.ChatColor;
9 | import org.bukkit.command.Command;
10 | import org.bukkit.command.CommandSender;
11 |
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | /**
16 | * An {@link CommandArgument} used to set the base {@link Deathban} time, not including multipliers, etc.
17 | */
18 | public class LivesSetDeathbanTimeArgument extends CommandArgument {
19 |
20 | private final HCF plugin;
21 |
22 | public LivesSetDeathbanTimeArgument(HCF plugin) {
23 | super("setdeathbantime", "Sets the base deathban time");
24 | this.permission = "hcf.command.lives.argument." + getName();
25 | this.plugin = plugin;
26 | }
27 |
28 | @Override
29 | public String getUsage(String label) {
30 | return '/' + label + ' ' + getName() + " ";
31 | }
32 |
33 | @Override
34 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
35 | if (args.length < 2) {
36 | sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
37 | return true;
38 | }
39 |
40 | Integer duration = JavaUtils.tryParseInt(args[1]);
41 |
42 | if (duration == null) {
43 | sender.sendMessage(ChatColor.RED + "Invalid duration, use the correct format: 10m 1s");
44 | return true;
45 | }
46 |
47 | plugin.getConfiguration().setDeathbanBaseDurationMinutes(duration);
48 | Command.broadcastCommandMessage(sender, ChatColor.YELLOW + "Base death-ban time set to " +
49 | DurationFormatUtils.formatDurationWords(duration, true, true) + " (not including multipliers, etc).");
50 |
51 | return true;
52 | }
53 |
54 | @Override
55 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
56 | return Collections.emptyList();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/economy/EconomyManager.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.economy;
2 |
3 | import gnu.trove.map.TObjectIntMap;
4 |
5 | import java.util.UUID;
6 |
7 | /**
8 | * Handles balances of players.
9 | */
10 | public interface EconomyManager {
11 |
12 | char ECONOMY_SYMBOL = '$';
13 |
14 | /**
15 | * Gets the map of economy balances.
16 | *
17 | * @return the map of economy balances
18 | */
19 | TObjectIntMap getBalanceMap();
20 |
21 | /**
22 | * Gets the balance of a player.
23 | *
24 | * @param uuid the uuid of player to get for
25 | * @return the balance of the player
26 | */
27 | int getBalance(UUID uuid);
28 |
29 | /**
30 | * Sets the balance of a player.
31 | *
32 | * @param uuid the uuid of player to set for
33 | * @param amount the amount to set
34 | * @return the new balance of player
35 | */
36 | int setBalance(UUID uuid, int amount);
37 |
38 | /**
39 | * Adds to the balance of a player.
40 | *
41 | * @param uuid the uuid of player to add for
42 | * @param amount the amount to add
43 | * @return the new balance of player
44 | */
45 | int addBalance(UUID uuid, int amount);
46 |
47 | /**
48 | * Takes from the balance of a player.
49 | *
50 | * @param uuid the uuid of player to take from
51 | * @param amount the amount to take
52 | * @return the new balance of player
53 | */
54 | int subtractBalance(UUID uuid, int amount);
55 |
56 | /**
57 | * Reloads the data from storage.
58 | */
59 | void reloadEconomyData();
60 |
61 | /**
62 | * Saves the data to storage.
63 | */
64 | void saveEconomyData();
65 | }
66 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/EventExecutor.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.eventgame.argument.EventAddLootTableArgument;
5 | import com.doctordark.hcf.eventgame.argument.EventCancelArgument;
6 | import com.doctordark.hcf.eventgame.argument.EventCreateArgument;
7 | import com.doctordark.hcf.eventgame.argument.EventDelLootTableArgument;
8 | import com.doctordark.hcf.eventgame.argument.EventDeleteArgument;
9 | import com.doctordark.hcf.eventgame.argument.EventRenameArgument;
10 | import com.doctordark.hcf.eventgame.argument.EventSetAreaArgument;
11 | import com.doctordark.hcf.eventgame.argument.EventSetCapzoneArgument;
12 | import com.doctordark.hcf.eventgame.argument.EventSetLootArgument;
13 | import com.doctordark.hcf.eventgame.argument.EventStartArgument;
14 | import com.doctordark.hcf.eventgame.argument.EventUptimeArgument;
15 | import com.doctordark.util.command.ArgumentExecutor;
16 |
17 | /**
18 | * Handles the execution and tab completion of the event command.
19 | */
20 | public class EventExecutor extends ArgumentExecutor {
21 |
22 | public EventExecutor(HCF plugin) {
23 | super("event");
24 |
25 | addArgument(new EventCancelArgument(plugin));
26 | addArgument(new EventCreateArgument(plugin));
27 | addArgument(new EventDeleteArgument(plugin));
28 | addArgument(new EventRenameArgument(plugin));
29 | addArgument(new EventSetAreaArgument(plugin));
30 | addArgument(new EventSetCapzoneArgument(plugin));
31 | addArgument(new EventAddLootTableArgument(plugin));
32 | addArgument(new EventDelLootTableArgument(plugin));
33 | addArgument(new EventSetLootArgument(plugin));
34 | addArgument(new EventStartArgument(plugin));
35 | addArgument(new EventUptimeArgument(plugin));
36 | }
37 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/EventType.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.eventgame.tracker.ConquestTracker;
5 | import com.doctordark.hcf.eventgame.tracker.EventTracker;
6 | import com.doctordark.hcf.eventgame.tracker.KothTracker;
7 | import com.google.common.collect.ImmutableBiMap;
8 | import com.google.common.collect.ImmutableMap;
9 |
10 | public enum EventType {
11 |
12 | CONQUEST("Conquest", new ConquestTracker(HCF.getPlugin())), KOTH("KOTH", new KothTracker(HCF.getPlugin()));
13 |
14 | private final EventTracker eventTracker;
15 | private final String displayName;
16 |
17 | EventType(String displayName, EventTracker eventTracker) {
18 | this.displayName = displayName;
19 | this.eventTracker = eventTracker;
20 | }
21 |
22 | public EventTracker getEventTracker() {
23 | return eventTracker;
24 | }
25 |
26 | public String getDisplayName() {
27 | return displayName;
28 | }
29 |
30 | private static final ImmutableMap byDisplayName;
31 |
32 | static {
33 | ImmutableMap.Builder builder = new ImmutableBiMap.Builder<>();
34 | for (EventType eventType : values()) {
35 | builder.put(eventType.displayName.toLowerCase(), eventType);
36 | }
37 |
38 | byDisplayName = builder.build();
39 | }
40 |
41 | @Deprecated
42 | public static EventType getByDisplayName(String name) {
43 | return byDisplayName.get(name.toLowerCase());
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/IEventScheduler.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame;
2 |
3 | import java.time.LocalDateTime;
4 | import java.util.Map;
5 |
6 | public interface IEventScheduler {
7 |
8 | Map getScheduleMap();
9 | }
10 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/argument/EventCancelArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame.argument;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.eventgame.EventTimer;
5 | import com.doctordark.hcf.faction.type.Faction;
6 | import com.doctordark.util.command.CommandArgument;
7 | import org.bukkit.Bukkit;
8 | import org.bukkit.ChatColor;
9 | import org.bukkit.command.Command;
10 | import org.bukkit.command.CommandSender;
11 |
12 | /**
13 | * An {@link CommandArgument} used for cancelling the current running event.
14 | */
15 | public class EventCancelArgument extends CommandArgument {
16 |
17 | private final HCF plugin;
18 |
19 | public EventCancelArgument(HCF plugin) {
20 | super("cancel", "Cancels a running event", new String[]{"stop", "end"});
21 | this.plugin = plugin;
22 | this.permission = "hcf.command.event.argument." + getName();
23 | }
24 |
25 | @Override
26 | public String getUsage(String label) {
27 | return '/' + label + ' ' + getName();
28 | }
29 |
30 | @Override
31 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
32 | EventTimer eventTimer = plugin.getTimerManager().getEventTimer();
33 | Faction eventFaction = eventTimer.getEventFaction();
34 |
35 | if (!eventTimer.clearCooldown()) {
36 | sender.sendMessage(ChatColor.RED + "There is not a running event.");
37 | return true;
38 | }
39 |
40 | Bukkit.broadcastMessage(sender.getName() + ChatColor.YELLOW + " has cancelled " + (eventFaction == null ? "the active event" : eventFaction.getName() + ChatColor.YELLOW) + ".");
41 | return true;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/argument/EventDeleteArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame.argument;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.eventgame.faction.EventFaction;
5 | import com.doctordark.hcf.faction.type.Faction;
6 | import com.doctordark.util.command.CommandArgument;
7 | import org.bukkit.ChatColor;
8 | import org.bukkit.command.Command;
9 | import org.bukkit.command.CommandSender;
10 |
11 | import java.util.Collections;
12 | import java.util.List;
13 | import java.util.stream.Collectors;
14 |
15 | /**
16 | * An {@link CommandArgument} used for deleting an {@link EventFaction}.
17 | */
18 | public class EventDeleteArgument extends CommandArgument {
19 |
20 | private final HCF plugin;
21 |
22 | public EventDeleteArgument(HCF plugin) {
23 | super("delete", "Deletes an event");
24 | this.plugin = plugin;
25 | this.aliases = new String[]{"remove", "del"};
26 | this.permission = "hcf.command.event.argument." + getName();
27 | }
28 |
29 | @Override
30 | public String getUsage(String label) {
31 | return '/' + label + ' ' + getName() + " ";
32 | }
33 |
34 | @Override
35 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
36 | if (args.length < 2) {
37 | sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
38 | return true;
39 | }
40 |
41 | Faction faction = plugin.getFactionManager().getFaction(args[1]);
42 |
43 | if (!(faction instanceof EventFaction)) {
44 | sender.sendMessage(ChatColor.RED + "There is not an event faction named '" + args[1] + "'.");
45 | return true;
46 | }
47 |
48 | if (plugin.getFactionManager().removeFaction(faction, sender)) {
49 | sender.sendMessage(ChatColor.YELLOW + "Deleted event faction " + ChatColor.WHITE + faction.getDisplayName(sender) + ChatColor.YELLOW + '.');
50 | }
51 |
52 | return true;
53 | }
54 |
55 | @Override
56 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
57 | if (args.length != 2) {
58 | return Collections.emptyList();
59 | }
60 |
61 | return plugin.getFactionManager().getFactions().stream().filter(faction -> faction instanceof EventFaction).map(Faction::getName).collect(Collectors.toList());
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/argument/EventRenameArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame.argument;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.eventgame.faction.CapturableFaction;
5 | import com.doctordark.hcf.eventgame.faction.EventFaction;
6 | import com.doctordark.hcf.faction.type.Faction;
7 | import com.doctordark.util.command.CommandArgument;
8 | import org.bukkit.ChatColor;
9 | import org.bukkit.command.Command;
10 | import org.bukkit.command.CommandSender;
11 |
12 | import java.util.Collections;
13 | import java.util.List;
14 | import java.util.stream.Collectors;
15 |
16 | /**
17 | * An {@link CommandArgument} used for renaming an {@link CapturableFaction}.
18 | */
19 | public class EventRenameArgument extends CommandArgument {
20 |
21 | private final HCF plugin;
22 |
23 | public EventRenameArgument(HCF plugin) {
24 | super("rename", "Renames an event");
25 | this.plugin = plugin;
26 | this.permission = "hcf.command.event.argument." + getName();
27 | }
28 |
29 | @Override
30 | public String getUsage(String label) {
31 | return '/' + label + ' ' + getName() + " ";
32 | }
33 |
34 | @Override
35 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
36 | if (args.length < 3) {
37 | sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
38 | return true;
39 | }
40 |
41 | Faction faction = plugin.getFactionManager().getFaction(args[2]);
42 |
43 | if (faction != null) {
44 | sender.sendMessage(ChatColor.RED + "There is already a faction named " + args[2] + '.');
45 | return true;
46 | }
47 |
48 | faction = plugin.getFactionManager().getFaction(args[1]);
49 |
50 | if (!(faction instanceof EventFaction)) {
51 | sender.sendMessage(ChatColor.RED + "There is not an event faction named '" + args[1] + "'.");
52 | return true;
53 | }
54 |
55 | String oldName = faction.getName();
56 | faction.setName(args[2], sender);
57 |
58 | sender.sendMessage(ChatColor.YELLOW + "Renamed event " + ChatColor.WHITE + oldName + ChatColor.YELLOW + " to " + ChatColor.WHITE + faction.getName() + ChatColor.YELLOW + '.');
59 | return true;
60 | }
61 |
62 | @Override
63 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
64 | if (args.length != 2) {
65 | return Collections.emptyList();
66 | }
67 |
68 | return plugin.getFactionManager().getFactions().stream().filter(faction -> faction instanceof EventFaction).map(Faction::getName).collect(Collectors.toList());
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/argument/EventStartArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame.argument;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.eventgame.faction.EventFaction;
5 | import com.doctordark.hcf.faction.type.Faction;
6 | import com.doctordark.util.command.CommandArgument;
7 | import org.bukkit.ChatColor;
8 | import org.bukkit.command.Command;
9 | import org.bukkit.command.CommandSender;
10 |
11 | import java.util.Collections;
12 | import java.util.List;
13 | import java.util.stream.Collectors;
14 |
15 | /**
16 | * A {@link CommandArgument} used for starting an event.
17 | */
18 | public class EventStartArgument extends CommandArgument {
19 |
20 | private final HCF plugin;
21 |
22 | public EventStartArgument(HCF plugin) {
23 | super("start", "Starts an event");
24 | this.plugin = plugin;
25 | this.aliases = new String[]{"begin"};
26 | this.permission = "hcf.command.event.argument." + getName();
27 | }
28 |
29 | @Override
30 | public String getUsage(String label) {
31 | return '/' + label + ' ' + getName() + " ";
32 | }
33 |
34 | @Override
35 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
36 | if (args.length < 2) {
37 | sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
38 | return true;
39 | }
40 |
41 | Faction faction = plugin.getFactionManager().getFaction(args[1]);
42 |
43 | if (!(faction instanceof EventFaction)) {
44 | sender.sendMessage(ChatColor.RED + "There is not an event faction named '" + args[1] + "'.");
45 | return true;
46 | }
47 |
48 | if (plugin.getTimerManager().getEventTimer().tryContesting(((EventFaction) faction), sender)) {
49 | sender.sendMessage(ChatColor.YELLOW + "Successfully contested " + faction.getName() + '.');
50 | }
51 |
52 | return true;
53 | }
54 |
55 | @Override
56 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
57 | if (args.length != 2) {
58 | return Collections.emptyList();
59 | }
60 |
61 | return plugin.getFactionManager().getFactions().stream().filter(faction -> faction instanceof EventFaction).map(Faction::getName).collect(Collectors.toList());
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/argument/EventUptimeArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame.argument;
2 |
3 | import com.doctordark.hcf.DateTimeFormats;
4 | import com.doctordark.hcf.HCF;
5 | import com.doctordark.hcf.eventgame.EventTimer;
6 | import com.doctordark.hcf.eventgame.faction.EventFaction;
7 | import com.doctordark.util.command.CommandArgument;
8 | import org.apache.commons.lang3.time.DurationFormatUtils;
9 | import org.bukkit.ChatColor;
10 | import org.bukkit.command.Command;
11 | import org.bukkit.command.CommandSender;
12 |
13 | /**
14 | * A {@link CommandArgument} argument used for checking the uptime of current event.
15 | */
16 | public class EventUptimeArgument extends CommandArgument {
17 |
18 | private final HCF plugin;
19 |
20 | public EventUptimeArgument(HCF plugin) {
21 | super("uptime", "Check the uptime of an event");
22 | this.plugin = plugin;
23 | this.permission = "hcf.command.event.argument." + getName();
24 | }
25 |
26 | @Override
27 | public String getUsage(String label) {
28 | return '/' + label + ' ' + getName();
29 | }
30 |
31 | @Override
32 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
33 | EventTimer eventTimer = plugin.getTimerManager().getEventTimer();
34 |
35 | if (eventTimer.getRemaining() <= 0L) {
36 | sender.sendMessage(ChatColor.RED + "There is not a running event.");
37 | return true;
38 | }
39 |
40 | EventFaction eventFaction = eventTimer.getEventFaction();
41 | sender.sendMessage(ChatColor.YELLOW + "Up-time of " + eventTimer.getName() + " timer" +
42 | (eventFaction == null ? "" : ": " + ChatColor.BLUE + '(' + eventFaction.getDisplayName(sender) + ChatColor.BLUE + ')') +
43 | ChatColor.YELLOW + " is " + ChatColor.GRAY + DurationFormatUtils.formatDurationWords(eventTimer.getUptime(), true, true) + ChatColor.YELLOW + ", started at " +
44 | ChatColor.GOLD + DateTimeFormats.HR_MIN_AMPM_TIMEZONE.format(eventTimer.getStartStamp()) + ChatColor.YELLOW + '.');
45 |
46 | return true;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/conquest/ConquestExecutor.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame.conquest;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.util.command.ArgumentExecutor;
5 |
6 | public class ConquestExecutor extends ArgumentExecutor {
7 |
8 | public ConquestExecutor(HCF plugin) {
9 | super("conquest");
10 | addArgument(new ConquestSetpointsArgument(plugin));
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/conquest/ConquestSetpointsArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame.conquest;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.eventgame.EventType;
5 | import com.doctordark.hcf.eventgame.tracker.ConquestTracker;
6 | import com.doctordark.hcf.faction.type.Faction;
7 | import com.doctordark.hcf.faction.type.PlayerFaction;
8 | import com.doctordark.util.JavaUtils;
9 | import com.doctordark.util.command.CommandArgument;
10 | import org.bukkit.ChatColor;
11 | import org.bukkit.command.Command;
12 | import org.bukkit.command.CommandSender;
13 |
14 | public class ConquestSetpointsArgument extends CommandArgument {
15 |
16 | private final HCF plugin;
17 |
18 | public ConquestSetpointsArgument(HCF plugin) {
19 | super("setpoints", "Sets the points of a faction in the Conquest event", "hcf.command.conquest.argument.setpoints");
20 | this.plugin = plugin;
21 | }
22 |
23 | @Override
24 | public String getUsage(String label) {
25 | return '/' + label + ' ' + getName() + " ";
26 | }
27 |
28 | @Override
29 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
30 | if (args.length < 3) {
31 | sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
32 | return true;
33 | }
34 |
35 | Faction faction = plugin.getFactionManager().getFaction(args[1]);
36 |
37 | if (!(faction instanceof PlayerFaction)) {
38 | sender.sendMessage(ChatColor.RED + "Faction " + args[1] + " is either not found or is not a player faction.");
39 | return true;
40 | }
41 |
42 | Integer amount = JavaUtils.tryParseInt(args[2]);
43 |
44 | if (amount == null) {
45 | sender.sendMessage(ChatColor.RED + "'" + args[2] + "' is not a number.");
46 | return true;
47 | }
48 |
49 | if (amount > plugin.getConfiguration().getConquestRequiredVictoryPoints()) {
50 | sender.sendMessage(ChatColor.RED + "Maximum points for Conquest is " + plugin.getConfiguration().getConquestRequiredVictoryPoints() + '.');
51 | return true;
52 | }
53 |
54 | PlayerFaction playerFaction = (PlayerFaction) faction;
55 | ((ConquestTracker) EventType.CONQUEST.getEventTracker()).setPoints(playerFaction, amount);
56 |
57 | Command.broadcastCommandMessage(sender, ChatColor.YELLOW + "Set the points of faction " + playerFaction.getName() + " to " + amount + '.');
58 | return true;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/crate/Key.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame.crate;
2 |
3 | import com.doctordark.util.Config;
4 | import org.bukkit.ChatColor;
5 | import org.bukkit.inventory.ItemStack;
6 |
7 | /**
8 | * Represents an {@link Key} that can be used to unlock crates.
9 | */
10 | public abstract class Key {
11 |
12 | private String name;
13 |
14 | /**
15 | * Constructs a new {@link Key} with a given name.
16 | *
17 | * @param name the name to construct with
18 | */
19 | public Key(String name) {
20 | this.name = name;
21 | }
22 |
23 | /**
24 | * Gets the name of this {@link Key}.
25 | *
26 | * @return the name
27 | */
28 | public String getName() {
29 | return name;
30 | }
31 |
32 | /**
33 | * Sets the name of the {@link Key}.
34 | *
35 | * @param name the name to set
36 | */
37 | public void setName(String name) {
38 | this.name = name;
39 | }
40 |
41 | /**
42 | * Gets the {@link ChatColor} of this {@link Key}.
43 | *
44 | * @return the {@link ChatColor}
45 | */
46 | public abstract ChatColor getColour();
47 |
48 | /**
49 | * Gets the display name of this {@link Key}.
50 | * This will return the prefix, followed by the display name.
51 | *
52 | * @return the {@link Key} display name
53 | */
54 | public String getDisplayName() {
55 | return getColour() + name;
56 | }
57 |
58 | /**
59 | * Gets the {@link ItemStack} of this {@link Key}
60 | *
61 | * @return the {@link ItemStack}
62 | */
63 | public abstract ItemStack getItemStack();
64 |
65 | /**
66 | * Loads data from the {@link Key} {@link Config}.
67 | *
68 | * @param config the {@link Config} to load from
69 | */
70 | public void load(Config config) {
71 | }
72 |
73 | /**
74 | * Saves data to the {@link Key} {@link Config}.
75 | *
76 | * @param config the {@link Config} to save to
77 | */
78 | public void save(Config config) {
79 | }
80 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/faction/CapturableFaction.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame.faction;
2 |
3 | import java.util.Map;
4 |
5 | public abstract class CapturableFaction extends EventFaction {
6 |
7 | public CapturableFaction(String name) {
8 | super(name);
9 | }
10 |
11 | public CapturableFaction(Map map) {
12 | super(map);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/faction/EventFaction.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame.faction;
2 |
3 | import com.doctordark.hcf.eventgame.CaptureZone;
4 | import com.doctordark.hcf.eventgame.EventType;
5 | import com.doctordark.hcf.faction.claim.Claim;
6 | import com.doctordark.hcf.faction.claim.ClaimHandler;
7 | import com.doctordark.hcf.faction.type.ClaimableFaction;
8 | import com.doctordark.hcf.faction.type.Faction;
9 | import com.doctordark.util.cuboid.Cuboid;
10 | import org.bukkit.ChatColor;
11 | import org.bukkit.Location;
12 | import org.bukkit.command.CommandSender;
13 |
14 | import java.util.List;
15 | import java.util.Map;
16 |
17 | public abstract class EventFaction extends ClaimableFaction {
18 |
19 | public EventFaction(String name) {
20 | super(name);
21 | setDeathban(true); // make cappable factions death-ban between reloads.
22 | }
23 |
24 | public EventFaction(Map map) {
25 | super(map);
26 | }
27 |
28 | @Override
29 | public String getDisplayName(Faction faction) {
30 | return ChatColor.AQUA + getName() + ' ' + ChatColor.GOLD + getEventType().getDisplayName();
31 | }
32 |
33 | @Override
34 | public String getDisplayName(CommandSender sender) {
35 | return ChatColor.AQUA + getName();
36 | }
37 |
38 | public String getScoreboardName() {
39 | return ChatColor.AQUA + ChatColor.BOLD.toString() + getName();
40 | }
41 |
42 | /**
43 | * Sets the {@link Cuboid} area of this {@link KothFaction}.
44 | *
45 | * @param cuboid the {@link Cuboid} to set
46 | * @param sender the {@link CommandSender} setting the claim
47 | */
48 | public void setClaim(Cuboid cuboid, CommandSender sender) {
49 | removeClaims(getClaims(), sender);
50 |
51 | // Now add the new claim.
52 | Location min = cuboid.getMinimumPoint();
53 | min.setY(ClaimHandler.MIN_CLAIM_HEIGHT);
54 |
55 | Location max = cuboid.getMaximumPoint();
56 | max.setY(ClaimHandler.MAX_CLAIM_HEIGHT);
57 |
58 | addClaim(new Claim(this, min, max), sender);
59 | }
60 |
61 | /**
62 | * Gets the {@link EventType} of this {@link CapturableFaction}.
63 | *
64 | * @return the {@link EventType}
65 | */
66 | public abstract EventType getEventType();
67 |
68 | /**
69 | * Gets the {@link CaptureZone}s for this {@link CapturableFaction}.
70 | *
71 | * @return list of {@link CaptureZone}s
72 | */
73 | public abstract List getCaptureZones();
74 | }
75 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/koth/KothExecutor.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame.koth;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.eventgame.koth.argument.KothHelpArgument;
5 | import com.doctordark.hcf.eventgame.koth.argument.KothNextArgument;
6 | import com.doctordark.hcf.eventgame.koth.argument.KothScheduleArgument;
7 | import com.doctordark.hcf.eventgame.koth.argument.KothSetCapDelayArgument;
8 | import com.doctordark.util.command.ArgumentExecutor;
9 | import org.bukkit.command.Command;
10 | import org.bukkit.command.CommandSender;
11 |
12 | /**
13 | * Command used to handle KingOfTheHills.
14 | */
15 | public class KothExecutor extends ArgumentExecutor {
16 |
17 | private final KothScheduleArgument kothScheduleArgument;
18 |
19 | public KothExecutor(HCF plugin) {
20 | super("koth");
21 |
22 | addArgument(new KothHelpArgument(this));
23 | addArgument(new KothNextArgument(plugin));
24 | addArgument(this.kothScheduleArgument = new KothScheduleArgument(plugin));
25 | addArgument(new KothSetCapDelayArgument(plugin));
26 | }
27 |
28 | @Override
29 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
30 | if (args.length < 1) {
31 | this.kothScheduleArgument.onCommand(sender, command, label, args);
32 | return true;
33 | }
34 |
35 | return super.onCommand(sender, command, label, args);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/koth/argument/KothHelpArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame.koth.argument;
2 |
3 | import com.doctordark.hcf.eventgame.koth.KothExecutor;
4 | import com.doctordark.util.command.CommandArgument;
5 | import org.bukkit.ChatColor;
6 | import org.bukkit.command.Command;
7 | import org.bukkit.command.CommandSender;
8 |
9 | /**
10 | * An {@link CommandArgument} used for viewing help about KingOfTheHill games.
11 | */
12 | public class KothHelpArgument extends CommandArgument {
13 |
14 | private final KothExecutor kothExecutor;
15 |
16 | public KothHelpArgument(KothExecutor kothExecutor) {
17 | super("help", "View help about how KOTH's work");
18 | this.kothExecutor = kothExecutor;
19 | this.permission = "hcf.command.koth.argument." + getName();
20 | }
21 |
22 | @Override
23 | public String getUsage(String label) {
24 | return '/' + label + ' ' + getName();
25 | }
26 |
27 | @Override
28 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
29 | sender.sendMessage(ChatColor.AQUA + "*** KotH Help ***");
30 | for (CommandArgument argument : kothExecutor.getArguments()) {
31 | if (argument != this) {
32 | String permission = argument.getPermission();
33 | if (permission == null || sender.hasPermission(permission)) {
34 | sender.sendMessage(ChatColor.GRAY + argument.getUsage(label) + " - " + argument.getDescription() + '.');
35 | }
36 | }
37 | }
38 |
39 | sender.sendMessage(ChatColor.GRAY + "/fac show - View information about a KOTH.");
40 | return true;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/eventgame/tracker/EventTracker.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.eventgame.tracker;
2 |
3 | import com.doctordark.hcf.eventgame.CaptureZone;
4 | import com.doctordark.hcf.eventgame.EventTimer;
5 | import com.doctordark.hcf.eventgame.EventType;
6 | import com.doctordark.hcf.eventgame.faction.EventFaction;
7 | import org.bukkit.entity.Player;
8 |
9 | /**
10 | * Tracker for handling event mini-games.
11 | * NOTE: The methods here are called before they happen, so
12 | * the onControlLoss method for example would still
13 | * have its' {@link CaptureZone} player unchanged.
14 | */
15 | @Deprecated
16 | public interface EventTracker {
17 |
18 | EventType getEventType();
19 |
20 | /**
21 | * Handles ticking every 5 seconds
22 | *
23 | * @param eventTimer the timer
24 | * @param eventFaction the faction
25 | */
26 | void tick(EventTimer eventTimer, EventFaction eventFaction);
27 |
28 | void onContest(EventFaction eventFaction, EventTimer eventTimer);
29 |
30 | boolean onControlTake(Player player, CaptureZone captureZone, EventFaction eventFaction);
31 |
32 | void onControlLoss(Player player, CaptureZone captureZone, EventFaction eventFaction);
33 |
34 | void stopTiming();
35 | }
36 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/argument/FactionClaimChunkArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.argument;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.faction.claim.Claim;
5 | import com.doctordark.hcf.faction.claim.ClaimHandler;
6 | import com.doctordark.hcf.faction.struct.Role;
7 | import com.doctordark.hcf.faction.type.PlayerFaction;
8 | import com.doctordark.util.command.CommandArgument;
9 | import org.bukkit.ChatColor;
10 | import org.bukkit.Location;
11 | import org.bukkit.command.Command;
12 | import org.bukkit.command.CommandSender;
13 | import org.bukkit.entity.Player;
14 |
15 | public class FactionClaimChunkArgument extends CommandArgument {
16 |
17 | private static final int CHUNK_RADIUS = 7;
18 | private final HCF plugin;
19 |
20 | public FactionClaimChunkArgument(HCF plugin) {
21 | super("claimchunk", "Claim a chunk of land in the Wilderness.", new String[]{"chunkclaim"});
22 | this.plugin = plugin;
23 | }
24 |
25 | @Override
26 | public String getUsage(String label) {
27 | return '/' + label + ' ' + getName();
28 | }
29 |
30 | @Override
31 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
32 | if (!(sender instanceof Player)) {
33 | sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
34 | return true;
35 | }
36 |
37 | Player player = (Player) sender;
38 | PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
39 |
40 | if (playerFaction == null) {
41 | sender.sendMessage(ChatColor.RED + "You are not in a faction.");
42 | return true;
43 | }
44 |
45 | if (playerFaction.isRaidable()) {
46 | sender.sendMessage(ChatColor.RED + "You cannot claim land for your faction while raidable.");
47 | return true;
48 | }
49 |
50 | if (playerFaction.getMember(player.getUniqueId()).getRole() == Role.MEMBER) {
51 | sender.sendMessage(ChatColor.RED + "You must be an officer to claim land.");
52 | return true;
53 | }
54 |
55 | Location location = player.getLocation();
56 | plugin.getClaimHandler().tryPurchasing(player, new Claim(playerFaction,
57 | location.clone().add(CHUNK_RADIUS, ClaimHandler.MIN_CLAIM_HEIGHT, CHUNK_RADIUS),
58 | location.clone().add(-CHUNK_RADIUS, ClaimHandler.MAX_CLAIM_HEIGHT, -CHUNK_RADIUS)));
59 |
60 | return true;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/argument/FactionDisbandArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.argument;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.faction.struct.Role;
5 | import com.doctordark.hcf.faction.type.PlayerFaction;
6 | import com.doctordark.util.command.CommandArgument;
7 | import org.bukkit.ChatColor;
8 | import org.bukkit.command.Command;
9 | import org.bukkit.command.CommandSender;
10 | import org.bukkit.entity.Player;
11 |
12 | public class FactionDisbandArgument extends CommandArgument {
13 |
14 | private final HCF plugin;
15 |
16 | public FactionDisbandArgument(HCF plugin) {
17 | super("disband", "Disband your faction.");
18 | this.plugin = plugin;
19 | }
20 |
21 | @Override
22 | public String getUsage(String label) {
23 | return '/' + label + ' ' + getName();
24 | }
25 |
26 | @Override
27 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
28 | if (!(sender instanceof Player)) {
29 | sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
30 | return true;
31 | }
32 |
33 | Player player = (Player) sender;
34 | PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
35 |
36 | if (playerFaction == null) {
37 | sender.sendMessage(ChatColor.RED + "You are not in a faction.");
38 | return true;
39 | }
40 |
41 | if (playerFaction.isRaidable() && !plugin.getEotwHandler().isEndOfTheWorld()) {
42 | sender.sendMessage(ChatColor.RED + "You cannot disband your faction while it is raidable.");
43 | return true;
44 | }
45 |
46 | if (playerFaction.getMember(player.getUniqueId()).getRole() != Role.LEADER) {
47 | sender.sendMessage(ChatColor.RED + "You must be a leader to disband the faction.");
48 | return true;
49 | }
50 |
51 | plugin.getFactionManager().removeFaction(playerFaction, sender);
52 | return true;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/argument/FactionLeaveArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.argument;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.faction.struct.Relation;
5 | import com.doctordark.hcf.faction.struct.Role;
6 | import com.doctordark.hcf.faction.type.PlayerFaction;
7 | import com.doctordark.util.command.CommandArgument;
8 | import org.bukkit.ChatColor;
9 | import org.bukkit.command.Command;
10 | import org.bukkit.command.CommandSender;
11 | import org.bukkit.entity.Player;
12 |
13 | import java.util.UUID;
14 |
15 | public class FactionLeaveArgument extends CommandArgument {
16 |
17 | private final HCF plugin;
18 |
19 | public FactionLeaveArgument(HCF plugin) {
20 | super("leave", "Leave your current faction.");
21 | this.plugin = plugin;
22 | }
23 |
24 | @Override
25 | public String getUsage(String label) {
26 | return '/' + label + ' ' + getName();
27 | }
28 |
29 | @Override
30 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
31 | if (!(sender instanceof Player)) {
32 | sender.sendMessage(ChatColor.RED + "Only players can leave faction.");
33 | return true;
34 | }
35 |
36 | Player player = (Player) sender;
37 | PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
38 |
39 | if (playerFaction == null) {
40 | sender.sendMessage(ChatColor.RED + "You are not in a faction.");
41 | return true;
42 | }
43 |
44 | UUID uuid = player.getUniqueId();
45 | if (playerFaction.getMember(uuid).getRole() == Role.LEADER) {
46 | sender.sendMessage(ChatColor.RED + "You cannot leave factions as a leader. Either use " + ChatColor.GOLD + '/' + label + " disband" + ChatColor.RED + " or " +
47 | ChatColor.GOLD + '/' + label + " leader" + ChatColor.RED + '.');
48 |
49 | return true;
50 | }
51 |
52 | if (playerFaction.removeMember(player, player, player.getUniqueId(), false, false)) {
53 | sender.sendMessage(ChatColor.YELLOW + "Successfully left the faction.");
54 | playerFaction.broadcast(Relation.ENEMY.toChatColour() + sender.getName() + ChatColor.YELLOW + " has left the faction.");
55 | }
56 |
57 | return true;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/argument/FactionMessageArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.argument;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.faction.struct.ChatChannel;
5 | import com.doctordark.hcf.faction.type.PlayerFaction;
6 | import com.doctordark.util.command.CommandArgument;
7 | import org.bukkit.ChatColor;
8 | import org.bukkit.command.Command;
9 | import org.bukkit.command.CommandSender;
10 | import org.bukkit.entity.Player;
11 |
12 | import java.util.Arrays;
13 |
14 | public class FactionMessageArgument extends CommandArgument {
15 |
16 | private final HCF plugin;
17 |
18 | public FactionMessageArgument(HCF plugin) {
19 | super("message", "Sends a message to your faction.");
20 | this.plugin = plugin;
21 | this.aliases = new String[]{"msg"};
22 | }
23 |
24 | @Override
25 | public String getUsage(String label) {
26 | return '/' + label + ' ' + getName() + " ";
27 | }
28 |
29 | @Override
30 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
31 | if (!(sender instanceof Player)) {
32 | sender.sendMessage(ChatColor.RED + "Only players can use faction chat.");
33 | return true;
34 | }
35 |
36 | if (args.length < 2) {
37 | sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
38 | return true;
39 | }
40 |
41 | Player player = (Player) sender;
42 | PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
43 |
44 | if (playerFaction == null) {
45 | sender.sendMessage(ChatColor.RED + "You are not in a faction.");
46 | return true;
47 | }
48 |
49 | String format = String.format(ChatChannel.FACTION.getRawFormat(player), "", HCF.SPACE_JOINER.join(Arrays.copyOfRange(args, 1, args.length)));
50 | for (Player target : playerFaction.getOnlinePlayers()) {
51 | target.sendMessage(format);
52 | }
53 |
54 | return true;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/argument/FactionOpenArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.argument;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.faction.FactionMember;
5 | import com.doctordark.hcf.faction.struct.Role;
6 | import com.doctordark.hcf.faction.type.PlayerFaction;
7 | import com.doctordark.util.command.CommandArgument;
8 | import org.bukkit.ChatColor;
9 | import org.bukkit.command.Command;
10 | import org.bukkit.command.CommandSender;
11 | import org.bukkit.entity.Player;
12 |
13 | public class FactionOpenArgument extends CommandArgument {
14 |
15 | private final HCF plugin;
16 |
17 | public FactionOpenArgument(HCF plugin) {
18 | super("open", "Opens the faction to the public.");
19 | this.plugin = plugin;
20 | }
21 |
22 | @Override
23 | public String getUsage(String label) {
24 | return '/' + label + ' ' + getName();
25 | }
26 |
27 | @Override
28 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
29 | if (!(sender instanceof Player)) {
30 | sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
31 | return true;
32 | }
33 |
34 | Player player = (Player) sender;
35 | PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
36 |
37 | if (playerFaction == null) {
38 | sender.sendMessage(ChatColor.RED + "You are not in a faction.");
39 | return true;
40 | }
41 |
42 | FactionMember factionMember = playerFaction.getMember(player.getUniqueId());
43 |
44 | if (factionMember.getRole() != Role.LEADER) {
45 | sender.sendMessage(ChatColor.RED + "You must be a faction leader to do this.");
46 | return true;
47 | }
48 |
49 | boolean newOpen = !playerFaction.isOpen();
50 | playerFaction.setOpen(newOpen);
51 | playerFaction.broadcast(ChatColor.YELLOW + sender.getName() + " has " + (newOpen ? ChatColor.GREEN + "opened" : ChatColor.RED + "closed") + ChatColor.YELLOW + " the faction to public.");
52 | return true;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/argument/FactionStuckArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.argument;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.timer.type.StuckTimer;
5 | import com.doctordark.hcf.util.DurationFormatter;
6 | import com.doctordark.util.command.CommandArgument;
7 | import org.bukkit.ChatColor;
8 | import org.bukkit.World;
9 | import org.bukkit.command.Command;
10 | import org.bukkit.command.CommandSender;
11 | import org.bukkit.entity.Player;
12 |
13 | /**
14 | * Faction argument used to teleport to a nearby {@link org.bukkit.Location} safely if stuck.
15 | */
16 | public class FactionStuckArgument extends CommandArgument {
17 |
18 | private final HCF plugin;
19 |
20 | public FactionStuckArgument(HCF plugin) {
21 | super("stuck", "Teleport to a safe position.", new String[]{"trap", "trapped"});
22 | this.plugin = plugin;
23 | }
24 |
25 | @Override
26 | public String getUsage(String label) {
27 | return '/' + label + ' ' + getName();
28 | }
29 |
30 | @Override
31 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
32 | if (!(sender instanceof Player)) {
33 | sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
34 | return true;
35 | }
36 |
37 | Player player = (Player) sender;
38 |
39 | if (player.getWorld().getEnvironment() != World.Environment.NORMAL) {
40 | sender.sendMessage(ChatColor.RED + "You can only use this command from the overworld.");
41 | return true;
42 | }
43 |
44 | StuckTimer stuckTimer = plugin.getTimerManager().getStuckTimer();
45 |
46 | if (!stuckTimer.setCooldown(player, player.getUniqueId())) {
47 | sender.sendMessage(ChatColor.RED + "Your " + stuckTimer.getName() + ChatColor.RED + " timer is already active.");
48 | return true;
49 | }
50 |
51 | sender.sendMessage(ChatColor.YELLOW + stuckTimer.getName() + ChatColor.YELLOW + " timer has started. " +
52 | "Teleport will occur in " + ChatColor.AQUA + DurationFormatter.getRemaining(stuckTimer.getRemaining(player), true, false) + ChatColor.YELLOW + ". " +
53 | "This will cancel if you move more than " + StuckTimer.MAX_MOVE_DISTANCE + " blocks.");
54 |
55 | return true;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/argument/staff/FactionForceDemoteArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.argument.staff;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.faction.FactionMember;
5 | import com.doctordark.hcf.faction.struct.Role;
6 | import com.doctordark.hcf.faction.type.PlayerFaction;
7 | import com.doctordark.util.command.CommandArgument;
8 | import org.bukkit.ChatColor;
9 | import org.bukkit.command.Command;
10 | import org.bukkit.command.CommandSender;
11 |
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | public class FactionForceDemoteArgument extends CommandArgument {
16 |
17 | private final HCF plugin;
18 |
19 | public FactionForceDemoteArgument(HCF plugin) {
20 | super("forcedemote", "Forces the demotion status of a player.");
21 | this.plugin = plugin;
22 | this.permission = "hcf.command.faction.argument." + getName();
23 | }
24 |
25 | @Override
26 | public String getUsage(String label) {
27 | return '/' + label + ' ' + getName() + " ";
28 | }
29 |
30 | @Override
31 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
32 | if (args.length < 2) {
33 | sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
34 | return true;
35 | }
36 |
37 | PlayerFaction playerFaction = plugin.getFactionManager().getContainingPlayerFaction(args[1]);
38 |
39 | if (playerFaction == null) {
40 | sender.sendMessage(ChatColor.RED + "Faction containing member with IGN or UUID " + args[1] + " not found.");
41 | return true;
42 | }
43 |
44 | FactionMember factionMember = playerFaction.getMember(args[1]);
45 |
46 | if (factionMember == null) {
47 | sender.sendMessage(ChatColor.RED + "Faction containing member with IGN or UUID " + args[1] + " not found.");
48 | return true;
49 | }
50 |
51 | if (factionMember.getRole() != Role.LEADER) {
52 | sender.sendMessage(ChatColor.RED + factionMember.getName() + " is a " + factionMember.getRole().getName() + "; cannot be demoted.");
53 | return true;
54 | }
55 |
56 | factionMember.setRole(Role.MEMBER);
57 | playerFaction.broadcast(ChatColor.GOLD.toString() + ChatColor.BOLD + sender.getName() + " has been forcefully assigned as a member.");
58 | return true;
59 | }
60 |
61 | @Override
62 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
63 | return args.length == 2 ? null : Collections.emptyList();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/argument/staff/FactionForceKickArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.argument.staff;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.faction.FactionMember;
5 | import com.doctordark.hcf.faction.struct.Role;
6 | import com.doctordark.hcf.faction.type.PlayerFaction;
7 | import com.doctordark.util.command.CommandArgument;
8 | import org.bukkit.ChatColor;
9 | import org.bukkit.command.Command;
10 | import org.bukkit.command.CommandSender;
11 |
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | public class FactionForceKickArgument extends CommandArgument {
16 |
17 | private final HCF plugin;
18 |
19 | public FactionForceKickArgument(HCF plugin) {
20 | super("forcekick", "Forcefully kick a player from their faction.");
21 | this.plugin = plugin;
22 | this.permission = "hcf.command.faction.argument." + getName();
23 | }
24 |
25 | @Override
26 | public String getUsage(String label) {
27 | return '/' + label + ' ' + getName() + " ";
28 | }
29 |
30 | @Override
31 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
32 | if (args.length < 2) {
33 | sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
34 | return true;
35 | }
36 |
37 | PlayerFaction playerFaction = plugin.getFactionManager().getContainingPlayerFaction(args[1]);
38 |
39 | if (playerFaction == null) {
40 | sender.sendMessage(ChatColor.RED + "Faction containing member with IGN or UUID " + args[1] + " not found.");
41 | return true;
42 | }
43 |
44 | FactionMember factionMember = playerFaction.getMember(args[1]);
45 |
46 | if (factionMember == null) {
47 | sender.sendMessage(ChatColor.RED + "Faction containing member with IGN or UUID " + args[1] + " not found.");
48 | return true;
49 | }
50 |
51 | if (factionMember.getRole() == Role.LEADER) {
52 | sender.sendMessage(ChatColor.RED + "You cannot forcefully kick faction leaders. Use /f forceremove instead.");
53 | return true;
54 | }
55 |
56 | if (playerFaction.removeMember(sender, null, factionMember.getUniqueId(), true, true)) {
57 | playerFaction.broadcast(ChatColor.GOLD.toString() + ChatColor.BOLD + factionMember.getName() + " has been forcefully kicked by " + sender.getName() + '.');
58 | }
59 |
60 | return true;
61 | }
62 |
63 | @Override
64 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
65 | return args.length == 2 ? null : Collections.emptyList();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/argument/staff/FactionForcePromoteArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.argument.staff;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.faction.FactionMember;
5 | import com.doctordark.hcf.faction.struct.Role;
6 | import com.doctordark.hcf.faction.type.PlayerFaction;
7 | import com.doctordark.util.command.CommandArgument;
8 | import org.bukkit.ChatColor;
9 | import org.bukkit.command.Command;
10 | import org.bukkit.command.CommandSender;
11 |
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | public class FactionForcePromoteArgument extends CommandArgument {
16 |
17 | private final HCF plugin;
18 |
19 | public FactionForcePromoteArgument(HCF plugin) {
20 | super("forcepromote", "Forces the promotion status of a player.");
21 | this.plugin = plugin;
22 | this.permission = "hcf.command.faction.argument." + getName();
23 | }
24 |
25 | @Override
26 | public String getUsage(String label) {
27 | return '/' + label + ' ' + getName() + " ";
28 | }
29 |
30 | @Override
31 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
32 | if (args.length < 2) {
33 | sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
34 | return true;
35 | }
36 |
37 | PlayerFaction playerFaction = plugin.getFactionManager().getContainingPlayerFaction(args[1]);
38 |
39 | if (playerFaction == null) {
40 | sender.sendMessage(ChatColor.RED + "Faction containing member with IGN or UUID " + args[1] + " not found.");
41 | return true;
42 | }
43 |
44 | FactionMember factionMember = playerFaction.getMember(args[1]);
45 |
46 | if (factionMember == null) {
47 | sender.sendMessage(ChatColor.RED + "Faction containing member with IGN or UUID " + args[1] + " not found.");
48 | return true;
49 | }
50 |
51 | if (factionMember.getRole() != Role.MEMBER) {
52 | sender.sendMessage(ChatColor.RED + factionMember.getName() + " is already a " + factionMember.getRole().getName() + '.');
53 | return true;
54 | }
55 |
56 | factionMember.setRole(Role.CAPTAIN);
57 | playerFaction.broadcast(ChatColor.GOLD.toString() + ChatColor.BOLD + sender.getName() + " has been forcefully assigned as a captain.");
58 | return true;
59 | }
60 |
61 | @Override
62 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
63 | return args.length == 2 ? null : Collections.emptyList();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/argument/staff/FactionForceUnclaimHereArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.argument.staff;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.faction.claim.Claim;
5 | import com.doctordark.util.command.CommandArgument;
6 | import org.bukkit.ChatColor;
7 | import org.bukkit.command.Command;
8 | import org.bukkit.command.CommandSender;
9 | import org.bukkit.entity.Player;
10 |
11 | import java.util.Collections;
12 | import java.util.List;
13 |
14 | public class FactionForceUnclaimHereArgument extends CommandArgument {
15 |
16 | private final HCF plugin;
17 |
18 | public FactionForceUnclaimHereArgument(HCF plugin) {
19 | super("forceunclaimhere", "Forces land unclaim where you are standing.");
20 | this.plugin = plugin;
21 | this.permission = "hcf.command.faction.argument." + getName();
22 | }
23 |
24 | @Override
25 | public String getUsage(String label) {
26 | return '/' + label + ' ' + getName();
27 | }
28 |
29 | @Override
30 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
31 | if (args.length < 2) {
32 | sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
33 | return true;
34 | }
35 |
36 | if (!(sender instanceof Player)) {
37 | sender.sendMessage(ChatColor.RED + "Only players can un-claim land from a faction.");
38 | return true;
39 | }
40 |
41 | Player player = (Player) sender;
42 | Claim claimAt = plugin.getFactionManager().getClaimAt(player.getLocation());
43 |
44 | if (claimAt == null) {
45 | sender.sendMessage(ChatColor.RED + "There is not a claim at your current position.");
46 | return true;
47 | }
48 |
49 | if (claimAt.getFaction().removeClaim(claimAt, sender)) {
50 | player.sendMessage(ChatColor.YELLOW + "Removed claim " + claimAt.getClaimUniqueID().toString() + " owned by " + claimAt.getFaction().getName() + ".");
51 | return true;
52 | }
53 |
54 | sender.sendMessage(ChatColor.RED + "Failed to remove claim " + claimAt.getClaimUniqueID().toString());
55 | return true;
56 | }
57 |
58 | @Override
59 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
60 | return Collections.emptyList();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/argument/staff/FactionMuteArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.argument.staff;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.faction.type.Faction;
5 | import com.doctordark.hcf.faction.type.PlayerFaction;
6 | import com.doctordark.util.command.CommandArgument;
7 | import org.bukkit.Bukkit;
8 | import org.bukkit.ChatColor;
9 | import org.bukkit.command.Command;
10 | import org.bukkit.command.CommandSender;
11 | import org.bukkit.command.ConsoleCommandSender;
12 |
13 | import java.util.Arrays;
14 | import java.util.Collections;
15 | import java.util.List;
16 | import java.util.UUID;
17 |
18 | public class FactionMuteArgument extends CommandArgument {
19 |
20 | private final HCF plugin;
21 |
22 | public FactionMuteArgument(HCF plugin) {
23 | super("mute", "Mutes every member in this faction.");
24 | this.plugin = plugin;
25 | this.permission = "hcf.command.faction.argument." + getName();
26 | }
27 |
28 | @Override
29 | public String getUsage(String label) {
30 | return '/' + label + ' ' + getName() + " ";
31 | }
32 |
33 | @Override
34 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
35 | if (args.length < 3) {
36 | sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
37 | return true;
38 | }
39 |
40 | Faction faction = plugin.getFactionManager().getContainingFaction(args[1]);
41 |
42 | if (!(faction instanceof PlayerFaction)) {
43 | sender.sendMessage(ChatColor.RED + "Player faction named or containing member with IGN or UUID " + args[1] + " not found.");
44 | return true;
45 | }
46 |
47 | PlayerFaction playerFaction = (PlayerFaction) faction;
48 | String extraArgs = HCF.SPACE_JOINER.join(Arrays.copyOfRange(args, 2, args.length));
49 | ConsoleCommandSender console = Bukkit.getConsoleSender();
50 | for (UUID uuid : playerFaction.getMembers().keySet()) {
51 | String commandLine = "mute " + uuid.toString() + " " + extraArgs;
52 | sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "Executing " + ChatColor.RED + commandLine);
53 | console.getServer().dispatchCommand(sender, commandLine);
54 | }
55 |
56 | sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "Executed mute action on faction " + playerFaction.getName() + ".");
57 | return true;
58 | }
59 |
60 | @Override
61 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
62 | return args.length == 2 ? null : Collections.emptyList();
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/argument/subclaim/FactionSubclaimListArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.argument.subclaim;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.faction.claim.Claim;
5 | import com.doctordark.hcf.faction.claim.Subclaim;
6 | import com.doctordark.hcf.faction.type.PlayerFaction;
7 | import com.doctordark.util.command.CommandArgument;
8 | import com.google.common.base.Joiner;
9 | import org.bukkit.ChatColor;
10 | import org.bukkit.command.Command;
11 | import org.bukkit.command.CommandSender;
12 | import org.bukkit.entity.Player;
13 |
14 | import java.util.ArrayList;
15 | import java.util.Collections;
16 | import java.util.List;
17 | import java.util.stream.Collectors;
18 |
19 | public class FactionSubclaimListArgument extends CommandArgument {
20 |
21 | private final HCF plugin;
22 |
23 | public FactionSubclaimListArgument(HCF plugin) {
24 | super("list", "List subclaims in this faction", new String[]{"listsubs"});
25 | this.plugin = plugin;
26 | }
27 |
28 | @Override
29 | public String getUsage(String label) {
30 | return '/' + label + " subclaim " + getName();
31 | }
32 |
33 | @Override
34 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
35 | if (!(sender instanceof Player)) {
36 | sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
37 | return true;
38 | }
39 |
40 | Player player = (Player) sender;
41 | PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
42 |
43 | if (playerFaction == null) {
44 | sender.sendMessage(ChatColor.RED + "You are not in a faction.");
45 | return true;
46 | }
47 |
48 | List subclaimNames = new ArrayList<>();
49 | for (Claim claim : playerFaction.getClaims()) {
50 | subclaimNames.addAll(claim.getSubclaims().stream().map(Subclaim::getName).collect(Collectors.toList()));
51 | }
52 |
53 | if (subclaimNames.isEmpty()) {
54 | sender.sendMessage(ChatColor.RED + "Your faction does not own any subclaims.");
55 | return true;
56 | }
57 |
58 | sender.sendMessage(ChatColor.YELLOW + "Factions' Subclaims (" + subclaimNames.size() + "): " + ChatColor.AQUA + HCF.COMMA_JOINER.join(subclaimNames));
59 | return true;
60 | }
61 |
62 | @Override
63 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
64 | return Collections.emptyList();
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/argument/subclaim/FactionSubclaimStartArgument.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.argument.subclaim;
2 |
3 | import com.doctordark.hcf.faction.claim.ClaimHandler;
4 | import com.doctordark.util.command.CommandArgument;
5 | import org.bukkit.ChatColor;
6 | import org.bukkit.command.Command;
7 | import org.bukkit.command.CommandSender;
8 | import org.bukkit.entity.Player;
9 | import org.bukkit.inventory.PlayerInventory;
10 |
11 | import java.util.Collections;
12 | import java.util.List;
13 |
14 | /**
15 | * Faction subclaim argument used to receive the Subclaim Wand.
16 | */
17 | public class FactionSubclaimStartArgument extends CommandArgument {
18 |
19 | public FactionSubclaimStartArgument() {
20 | super("start", "Receive the subclaim wand", new String[]{"begin", "claim", "wand"});
21 | }
22 |
23 | @Override
24 | public String getUsage(String label) {
25 | return '/' + label + " subclaim " + getName();
26 | }
27 |
28 | @Override
29 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
30 | if (!(sender instanceof Player)) {
31 | sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
32 | return true;
33 | }
34 |
35 | PlayerInventory inventory = ((Player) sender).getInventory();
36 |
37 | if (inventory.contains(ClaimHandler.SUBCLAIM_WAND)) {
38 | sender.sendMessage(ChatColor.RED + "You already have a subclaim wand in your inventory.");
39 | return true;
40 | }
41 |
42 | if (inventory.contains(ClaimHandler.CLAIM_WAND)) {
43 | sender.sendMessage(ChatColor.RED + "You cannot have a subclaim wand whilst you have a claiming wand in your inventory.");
44 | return true;
45 | }
46 |
47 | if (!inventory.addItem(ClaimHandler.SUBCLAIM_WAND).isEmpty()) {
48 | sender.sendMessage(ChatColor.RED + "Your inventory is full.");
49 | return true;
50 | }
51 |
52 | sender.sendMessage(ChatColor.YELLOW + "Subclaim wand added to inventory. Read the item to understand how to create a subclaim.");
53 | return true;
54 | }
55 |
56 | @Override
57 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
58 | return Collections.emptyList();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/CaptureZoneEnterEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.eventgame.CaptureZone;
4 | import com.doctordark.hcf.eventgame.faction.CapturableFaction;
5 | import org.bukkit.entity.Player;
6 | import org.bukkit.event.Cancellable;
7 | import org.bukkit.event.HandlerList;
8 |
9 | import java.util.Objects;
10 |
11 | /**
12 | * Faction event called when a player enters an event capture zone.
13 | */
14 | public class CaptureZoneEnterEvent extends FactionEvent implements Cancellable {
15 |
16 | private static final HandlerList handlers = new HandlerList();
17 |
18 | private boolean cancelled;
19 | private final CaptureZone captureZone;
20 | private final Player player;
21 |
22 | public CaptureZoneEnterEvent(Player player, CapturableFaction capturableFaction, CaptureZone captureZone) {
23 | super(capturableFaction);
24 |
25 | Objects.requireNonNull(player, "Player cannot be null");
26 | Objects.requireNonNull(captureZone, "Capture zone cannot be null");
27 |
28 | this.captureZone = captureZone;
29 | this.player = player;
30 | }
31 |
32 | @Override
33 | public CapturableFaction getFaction() {
34 | return (CapturableFaction) super.getFaction();
35 | }
36 |
37 | /**
38 | * Gets the capture zone of the faction the player is entering.
39 | *
40 | * @return the entered capture zone
41 | */
42 | public CaptureZone getCaptureZone() {
43 | return captureZone;
44 | }
45 |
46 | /**
47 | * Gets the player entering this capture zone.
48 | *
49 | * @return the player entering capture zone
50 | */
51 | public Player getPlayer() {
52 | return player;
53 | }
54 |
55 | @Override
56 | public boolean isCancelled() {
57 | return cancelled;
58 | }
59 |
60 | @Override
61 | public void setCancelled(boolean cancelled) {
62 | this.cancelled = cancelled;
63 | }
64 |
65 | @Override
66 | public HandlerList getHandlers() {
67 | return handlers;
68 | }
69 |
70 | public static HandlerList getHandlerList() {
71 | return handlers;
72 | }
73 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/CaptureZoneLeaveEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.eventgame.CaptureZone;
4 | import com.doctordark.hcf.eventgame.faction.CapturableFaction;
5 | import org.bukkit.entity.Player;
6 | import org.bukkit.event.Cancellable;
7 | import org.bukkit.event.HandlerList;
8 |
9 | import java.util.Objects;
10 |
11 | /**
12 | * Faction event called when a player leaves an event capture zone.
13 | */
14 | public class CaptureZoneLeaveEvent extends FactionEvent implements Cancellable {
15 |
16 | private static final HandlerList handlers = new HandlerList();
17 |
18 | private boolean cancelled;
19 | private final CaptureZone captureZone;
20 | private final Player player;
21 |
22 | public CaptureZoneLeaveEvent(Player player, CapturableFaction capturableFaction, CaptureZone captureZone) {
23 | super(capturableFaction);
24 |
25 | Objects.requireNonNull(player, "Player cannot be null");
26 | Objects.requireNonNull(captureZone, "Capture zone cannot be null");
27 |
28 | this.captureZone = captureZone;
29 | this.player = player;
30 | }
31 |
32 | @Override
33 | public CapturableFaction getFaction() {
34 | return (CapturableFaction) super.getFaction();
35 | }
36 |
37 | /**
38 | * Gets the player leaving this capture zone.
39 | *
40 | * @return the player leaving capture zone
41 | */
42 | public CaptureZone getCaptureZone() {
43 | return captureZone;
44 | }
45 |
46 | /**
47 | * Gets the capture zone of the faction the player is leaving.
48 | *
49 | * @return the leaving capture zone
50 | */
51 | public Player getPlayer() {
52 | return player;
53 | }
54 |
55 | @Override
56 | public boolean isCancelled() {
57 | return cancelled;
58 | }
59 |
60 | @Override
61 | public void setCancelled(boolean cancelled) {
62 | this.cancelled = cancelled;
63 | }
64 |
65 | @Override
66 | public HandlerList getHandlers() {
67 | return handlers;
68 | }
69 |
70 | public static HandlerList getHandlerList() {
71 | return handlers;
72 | }
73 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/FactionChatEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.faction.FactionMember;
4 | import com.doctordark.hcf.faction.struct.ChatChannel;
5 | import com.doctordark.hcf.faction.type.PlayerFaction;
6 | import org.bukkit.command.CommandSender;
7 | import org.bukkit.entity.Player;
8 | import org.bukkit.event.Cancellable;
9 | import org.bukkit.event.HandlerList;
10 |
11 | import java.util.Collection;
12 |
13 | /**
14 | * Faction event called when a {@link Player} in a faction talks to their relations.
15 | */
16 | public class FactionChatEvent extends FactionEvent implements Cancellable {
17 |
18 | private static final HandlerList handlers = new HandlerList();
19 |
20 | private boolean cancelled;
21 | private final Player player;
22 | private final FactionMember factionMember;
23 | private final ChatChannel chatChannel;
24 | private final String message;
25 | private final Collection extends CommandSender> recipients;
26 | private final String fallbackFormat;
27 |
28 | public FactionChatEvent(boolean async, PlayerFaction faction, Player player, ChatChannel chatChannel, Collection extends CommandSender> recipients, String message) {
29 | super(faction, async);
30 | this.player = player;
31 | this.factionMember = faction.getMember(player.getUniqueId());
32 | this.chatChannel = chatChannel;
33 | this.recipients = recipients;
34 | this.message = message;
35 | this.fallbackFormat = chatChannel.getRawFormat(player);
36 | }
37 |
38 | public Player getPlayer() {
39 | return player;
40 | }
41 |
42 | public FactionMember getFactionMember() {
43 | return factionMember;
44 | }
45 |
46 | public ChatChannel getChatChannel() {
47 | return chatChannel;
48 | }
49 |
50 | public Collection extends CommandSender> getRecipients() {
51 | return recipients;
52 | }
53 |
54 | public String getMessage() {
55 | return message;
56 | }
57 |
58 | public String getFallbackFormat() {
59 | return fallbackFormat;
60 | }
61 |
62 | @Override
63 | public boolean isCancelled() {
64 | return cancelled;
65 | }
66 |
67 | @Override
68 | public void setCancelled(boolean cancel) {
69 | cancelled = cancel;
70 | }
71 |
72 | public static HandlerList getHandlerList() {
73 | return handlers;
74 | }
75 |
76 | @Override
77 | public HandlerList getHandlers() {
78 | return handlers;
79 | }
80 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/FactionClaimChangedEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.faction.claim.Claim;
4 | import com.doctordark.hcf.faction.event.cause.ClaimChangeCause;
5 | import com.doctordark.hcf.faction.type.ClaimableFaction;
6 | import org.bukkit.command.CommandSender;
7 | import org.bukkit.event.Event;
8 | import org.bukkit.event.HandlerList;
9 |
10 | import java.util.Collection;
11 |
12 | /**
13 | * Faction event called when a {@link Claim} has been claimed by a {@link ClaimableFaction}.
14 | */
15 | public class FactionClaimChangedEvent extends Event {
16 |
17 | private static final HandlerList handlers = new HandlerList();
18 |
19 | private final CommandSender sender;
20 | private final ClaimChangeCause cause;
21 | private final Collection affectedClaims;
22 |
23 | public FactionClaimChangedEvent(CommandSender sender, ClaimChangeCause cause, Collection affectedClaims) {
24 | this.sender = sender;
25 | this.cause = cause;
26 | this.affectedClaims = affectedClaims;
27 | }
28 |
29 | /**
30 | * Gets the {@link CommandSender} that made this claim.
31 | *
32 | * @return the claiming {@link CommandSender}, null if none
33 | */
34 | public CommandSender getSender() {
35 | return sender;
36 | }
37 |
38 | /**
39 | * Gets the {@link ClaimChangeCause} of this event.
40 | *
41 | * @return the {@link ClaimChangeCause}
42 | */
43 | public ClaimChangeCause getCause() {
44 | return cause;
45 | }
46 |
47 | /**
48 | * Gets the {@link Claim}s being affected.
49 | *
50 | * @return the {@link Claim}s being affected
51 | */
52 | public Collection getAffectedClaims() {
53 | return affectedClaims;
54 | }
55 |
56 | public static HandlerList getHandlerList() {
57 | return handlers;
58 | }
59 |
60 | @Override
61 | public HandlerList getHandlers() {
62 | return handlers;
63 | }
64 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/FactionCreateEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.faction.type.Faction;
4 | import org.bukkit.command.CommandSender;
5 | import org.bukkit.event.Cancellable;
6 | import org.bukkit.event.HandlerList;
7 |
8 | /**
9 | * Event called when a {@link Faction} is about to be created.
10 | */
11 | public class FactionCreateEvent extends FactionEvent implements Cancellable {
12 |
13 | private static final HandlerList handlers = new HandlerList();
14 |
15 | private boolean cancelled;
16 | private final CommandSender sender;
17 |
18 | public FactionCreateEvent(Faction faction, CommandSender sender) {
19 | super(faction);
20 | this.sender = sender;
21 | }
22 |
23 | /**
24 | * Gets the {@link CommandSender} attempting to create this {@link Faction}.
25 | *
26 | * @return the {@link CommandSender}
27 | */
28 | public CommandSender getSender() {
29 | return sender;
30 | }
31 |
32 | @Override
33 | public boolean isCancelled() {
34 | return cancelled;
35 | }
36 |
37 | @Override
38 | public void setCancelled(boolean cancelled) {
39 | this.cancelled = cancelled;
40 | }
41 |
42 | public static HandlerList getHandlerList() {
43 | return handlers;
44 | }
45 |
46 | @Override
47 | public HandlerList getHandlers() {
48 | return handlers;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/FactionDtrChangeEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.faction.struct.Raidable;
4 | import com.doctordark.hcf.faction.type.Faction;
5 | import org.bukkit.event.Cancellable;
6 | import org.bukkit.event.Event;
7 | import org.bukkit.event.HandlerList;
8 |
9 | /**
10 | * Event called when the DTR of a {@link Faction} is changed.
11 | */
12 | public class FactionDtrChangeEvent extends Event implements Cancellable {
13 |
14 | private static final HandlerList handlers = new HandlerList();
15 |
16 | private boolean cancelled;
17 | private final DtrUpdateCause cause;
18 | private final Raidable raidable;
19 | private final double originalDtr;
20 | private double newDtr;
21 |
22 | public FactionDtrChangeEvent(DtrUpdateCause cause, Raidable raidable, double originalDtr, double newDtr) {
23 | this.cause = cause;
24 | this.raidable = raidable;
25 | this.originalDtr = originalDtr;
26 | this.newDtr = newDtr;
27 | }
28 |
29 | public DtrUpdateCause getCause() {
30 | return cause;
31 | }
32 |
33 | public Raidable getRaidable() {
34 | return raidable;
35 | }
36 |
37 | public double getOriginalDtr() {
38 | return originalDtr;
39 | }
40 |
41 | public double getNewDtr() {
42 | return newDtr;
43 | }
44 |
45 | public void setNewDtr(double newDtr) {
46 | this.newDtr = newDtr;
47 | }
48 |
49 | public enum DtrUpdateCause {
50 | REGENERATION, MEMBER_DEATH
51 | }
52 |
53 | @Override
54 | public boolean isCancelled() {
55 | return cancelled || (Math.abs(newDtr - originalDtr) == 0);
56 | }
57 |
58 | @Override
59 | public void setCancelled(boolean cancelled) {
60 | this.cancelled = cancelled;
61 | }
62 |
63 | public static HandlerList getHandlerList() {
64 | return handlers;
65 | }
66 |
67 | @Override
68 | public HandlerList getHandlers() {
69 | return handlers;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/FactionEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.faction.type.Faction;
4 | import org.bukkit.event.Event;
5 |
6 | import java.util.Objects;
7 |
8 | /**
9 | * Represents a faction related event
10 | */
11 | public abstract class FactionEvent extends Event {
12 |
13 | protected final Faction faction;
14 |
15 | public FactionEvent(final Faction faction) {
16 | this.faction = Objects.requireNonNull(faction, "Faction cannot be null");
17 | }
18 |
19 | FactionEvent(final Faction faction, boolean async) {
20 | super(async);
21 | this.faction = Objects.requireNonNull(faction, "Faction cannot be null");
22 | }
23 |
24 | /**
25 | * Returns the {@link Faction} involved in this event
26 | *
27 | * @return the {@link Faction} that is involved in this event
28 | */
29 | public Faction getFaction() {
30 | return faction;
31 | }
32 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/FactionRelationCreateEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.faction.struct.Relation;
4 | import com.doctordark.hcf.faction.type.PlayerFaction;
5 | import org.bukkit.event.Cancellable;
6 | import org.bukkit.event.Event;
7 | import org.bukkit.event.HandlerList;
8 |
9 | /**
10 | * Faction event called a {@link PlayerFaction} has created a {@link Relation} with another {@link PlayerFaction}.
11 | */
12 | public class FactionRelationCreateEvent extends Event implements Cancellable {
13 |
14 | private static final HandlerList handlers = new HandlerList();
15 |
16 | private boolean cancelled;
17 | private final PlayerFaction senderFaction;
18 | private final PlayerFaction targetFaction;
19 | private final Relation relation;
20 |
21 | public FactionRelationCreateEvent(PlayerFaction senderFaction, PlayerFaction targetFaction, Relation relation) {
22 | this.senderFaction = senderFaction;
23 | this.targetFaction = targetFaction;
24 | this.relation = relation;
25 | }
26 |
27 | /**
28 | * Gets the {@link PlayerFaction} sending the request.
29 | *
30 | * @return the requesting {@link PlayerFaction}
31 | */
32 | public PlayerFaction getSenderFaction() {
33 | return senderFaction;
34 | }
35 |
36 | /**
37 | * Gets the {@link PlayerFaction} asked to accept request.
38 | *
39 | * @return the targeted {@link PlayerFaction}
40 | */
41 | public PlayerFaction getTargetFaction() {
42 | return targetFaction;
43 | }
44 |
45 | public Relation getRelation() {
46 | return relation;
47 | }
48 |
49 | @Override
50 | public boolean isCancelled() {
51 | return cancelled;
52 | }
53 |
54 | @Override
55 | public void setCancelled(boolean cancel) {
56 | cancelled = cancel;
57 | }
58 |
59 | public static HandlerList getHandlerList() {
60 | return handlers;
61 | }
62 |
63 | @Override
64 | public HandlerList getHandlers() {
65 | return handlers;
66 | }
67 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/FactionRelationRemoveEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.faction.struct.Relation;
4 | import com.doctordark.hcf.faction.type.Faction;
5 | import com.doctordark.hcf.faction.type.PlayerFaction;
6 | import org.bukkit.event.Cancellable;
7 | import org.bukkit.event.Event;
8 | import org.bukkit.event.HandlerList;
9 |
10 | /**
11 | * Faction event called a {@link PlayerFaction} has removed a {@link Relation}
12 | * with another {@link PlayerFaction}.
13 | */
14 | public class FactionRelationRemoveEvent extends Event implements Cancellable {
15 |
16 | private static final HandlerList handlers = new HandlerList();
17 |
18 | private boolean cancelled;
19 | private final PlayerFaction senderFaction;
20 | private final PlayerFaction targetFaction;
21 | private final Relation relation;
22 |
23 | public FactionRelationRemoveEvent(PlayerFaction senderFaction, PlayerFaction targetFaction, Relation relation) {
24 | this.senderFaction = senderFaction;
25 | this.targetFaction = targetFaction;
26 | this.relation = relation;
27 | }
28 |
29 | /**
30 | * Gets the {@link Faction} sending the request.
31 | *
32 | * @return the requesting {@link Faction}
33 | */
34 | public PlayerFaction getSenderFaction() {
35 | return senderFaction;
36 | }
37 |
38 | /**
39 | * Gets the {@link Faction} asked to accept request.
40 | *
41 | * @return the targeted {@link Faction}
42 | */
43 | public PlayerFaction getTargetFaction() {
44 | return targetFaction;
45 | }
46 |
47 | public Relation getRelation() {
48 | return relation;
49 | }
50 |
51 | @Override
52 | public boolean isCancelled() {
53 | return cancelled;
54 | }
55 |
56 | @Override
57 | public void setCancelled(boolean cancel) {
58 | cancelled = cancel;
59 | }
60 |
61 | public static HandlerList getHandlerList() {
62 | return handlers;
63 | }
64 |
65 | @Override
66 | public HandlerList getHandlers() {
67 | return handlers;
68 | }
69 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/FactionRemoveEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.faction.type.Faction;
4 | import org.bukkit.command.CommandSender;
5 | import org.bukkit.event.Cancellable;
6 | import org.bukkit.event.HandlerList;
7 |
8 | /**
9 | * Event called when a {@link Faction} is about to be removed.
10 | */
11 | public class FactionRemoveEvent extends FactionEvent implements Cancellable {
12 |
13 | private static final HandlerList handlers = new HandlerList();
14 |
15 | private boolean cancelled;
16 | private final CommandSender sender;
17 |
18 | public FactionRemoveEvent(Faction faction, CommandSender sender) {
19 | super(faction);
20 | this.sender = sender;
21 | }
22 |
23 | /**
24 | * Gets the {@link CommandSender} attempting to remove this {@link Faction}.
25 | *
26 | * @return the {@link CommandSender}
27 | */
28 | public CommandSender getSender() {
29 | return sender;
30 | }
31 |
32 | @Override
33 | public boolean isCancelled() {
34 | return cancelled;
35 | }
36 |
37 | @Override
38 | public void setCancelled(boolean cancelled) {
39 | this.cancelled = cancelled;
40 | }
41 |
42 | public static HandlerList getHandlerList() {
43 | return handlers;
44 | }
45 |
46 | @Override
47 | public HandlerList getHandlers() {
48 | return handlers;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/FactionRenameEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.faction.type.Faction;
4 | import org.bukkit.command.CommandSender;
5 | import org.bukkit.event.Cancellable;
6 | import org.bukkit.event.HandlerList;
7 |
8 | /**
9 | * Event called when a {@link Faction} is about to be renamed.
10 | */
11 | public class FactionRenameEvent extends FactionEvent implements Cancellable {
12 |
13 | private static final HandlerList handlers = new HandlerList();
14 |
15 | private boolean cancelled;
16 | private final CommandSender sender;
17 | private final String originalName;
18 | private String newName;
19 |
20 | public FactionRenameEvent(Faction faction, CommandSender sender, String originalName, String newName) {
21 | super(faction);
22 | this.sender = sender;
23 | this.originalName = originalName;
24 | this.newName = newName;
25 | }
26 |
27 | /**
28 | * Gets the {@link CommandSender} attempting to remove this {@link Faction}.
29 | *
30 | * @return the {@link CommandSender}
31 | */
32 | public CommandSender getSender() {
33 | return sender;
34 | }
35 |
36 | /**
37 | * Gets the name before the {@link Faction} decided to
38 | * perform the rename.
39 | *
40 | * @return the original name
41 | */
42 | public String getOriginalName() {
43 | return originalName;
44 | }
45 |
46 | /**
47 | * Gets the name the {@link Faction} is attempting to change to
48 | *
49 | * @return the new name
50 | */
51 | public String getNewName() {
52 | return newName;
53 | }
54 |
55 | /**
56 | * Sets the new name to provide for this faction.
57 | *
58 | * @param newName the new name to set
59 | */
60 | public void setNewName(String newName) {
61 | if (!newName.equals(this.newName)) {
62 | this.newName = newName;
63 | }
64 | }
65 |
66 | @Override
67 | public boolean isCancelled() {
68 | return cancelled || (originalName.equals(newName));
69 | }
70 |
71 | @Override
72 | public void setCancelled(boolean cancelled) {
73 | this.cancelled = cancelled;
74 | }
75 |
76 | public static HandlerList getHandlerList() {
77 | return handlers;
78 | }
79 |
80 | @Override
81 | public HandlerList getHandlers() {
82 | return handlers;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/PlayerClaimEnterEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.faction.claim.Claim;
4 | import com.doctordark.hcf.faction.type.Faction;
5 | import org.bukkit.Location;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.Cancellable;
8 | import org.bukkit.event.Event;
9 | import org.bukkit.event.HandlerList;
10 |
11 | /**
12 | * Faction event called when a {@link Player} enters a different {@link Claim}.
13 | */
14 | public class PlayerClaimEnterEvent extends Event implements Cancellable {
15 |
16 | private static final HandlerList handlers = new HandlerList();
17 |
18 | private boolean cancelled;
19 | private final Player player;
20 | private final Faction fromFaction;
21 | private final Faction toFaction;
22 | private final Location from;
23 | private final Location to;
24 | private final EnterCause enterCause;
25 |
26 | public PlayerClaimEnterEvent(Player player, Location from, Location to, Faction fromFaction, Faction toFaction, EnterCause enterCause) {
27 | this.player = player;
28 | this.from = from;
29 | this.to = to;
30 | this.fromFaction = fromFaction;
31 | this.toFaction = toFaction;
32 | this.enterCause = enterCause;
33 | }
34 |
35 | public enum EnterCause {
36 |
37 | TELEPORT, MOVEMENT
38 | }
39 |
40 | /**
41 | * Gets the {@link Faction} at the from {@link Location}.
42 | *
43 | * @return the {@link Faction} at the from {@link Location}
44 | */
45 | public Faction getFromFaction() {
46 | return fromFaction;
47 | }
48 |
49 | /**
50 | * Gets the {@link Faction} at the to {@link Location}.
51 | *
52 | * @return the {@link Faction} at the to {@link Location}
53 | */
54 | public Faction getToFaction() {
55 | return toFaction;
56 | }
57 |
58 | public Player getPlayer() {
59 | return player;
60 | }
61 |
62 | public Location getFrom() {
63 | return from;
64 | }
65 |
66 | public Location getTo() {
67 | return to;
68 | }
69 |
70 | public EnterCause getEnterCause() {
71 | return enterCause;
72 | }
73 |
74 | public static HandlerList getHandlerList() {
75 | return handlers;
76 | }
77 |
78 | @Override
79 | public boolean isCancelled() {
80 | return cancelled;
81 | }
82 |
83 | @Override
84 | public void setCancelled(boolean cancelled) {
85 | this.cancelled = cancelled;
86 | }
87 |
88 | @Override
89 | public HandlerList getHandlers() {
90 | return handlers;
91 | }
92 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/PlayerJoinFactionEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.faction.type.Faction;
4 | import com.doctordark.hcf.faction.type.PlayerFaction;
5 | import lombok.Getter;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.command.CommandSender;
8 | import org.bukkit.entity.Player;
9 | import org.bukkit.event.Cancellable;
10 | import org.bukkit.event.HandlerList;
11 |
12 | import javax.annotation.Nullable;
13 | import java.util.Objects;
14 | import java.util.Optional;
15 | import java.util.UUID;
16 |
17 | /**
18 | * Event called when a user is about to join a {@link Faction}.
19 | */
20 | public class PlayerJoinFactionEvent extends FactionEvent implements Cancellable {
21 |
22 | private static final HandlerList handlers = new HandlerList();
23 |
24 | private boolean cancelled;
25 | private Optional player; // lazy-load
26 |
27 | @Getter
28 | private final CommandSender sender;
29 |
30 | @Getter
31 | private final UUID playerUUID;
32 |
33 | public PlayerJoinFactionEvent(CommandSender sender, @Nullable Player player, UUID playerUUID, PlayerFaction playerFaction) {
34 | super(playerFaction);
35 |
36 | Objects.requireNonNull(sender, "Sender cannot be null");
37 | Objects.requireNonNull(playerUUID, "Player UUID cannot be null");
38 | Objects.requireNonNull(playerFaction, "Player faction cannot be null");
39 |
40 | this.sender = sender;
41 | if (player != null) {
42 | this.player = Optional.of(player);
43 | }
44 |
45 | this.playerUUID = playerUUID;
46 | }
47 |
48 | public Optional getPlayer() {
49 | if (this.player == null) {
50 | this.player = Optional.ofNullable(Bukkit.getPlayer(this.playerUUID));
51 | }
52 |
53 | return this.player;
54 | }
55 |
56 | @Override
57 | public boolean isCancelled() {
58 | return cancelled;
59 | }
60 |
61 | @Override
62 | public void setCancelled(boolean cancelled) {
63 | this.cancelled = cancelled;
64 | }
65 |
66 | public static HandlerList getHandlerList() {
67 | return handlers;
68 | }
69 |
70 | @Override
71 | public HandlerList getHandlers() {
72 | return handlers;
73 | }
74 |
75 | @Override
76 | public PlayerFaction getFaction() {
77 | return (PlayerFaction) super.getFaction();
78 | }
79 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/PlayerJoinedFactionEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.faction.type.Faction;
4 | import com.doctordark.hcf.faction.type.PlayerFaction;
5 | import lombok.Getter;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.command.CommandSender;
8 | import org.bukkit.entity.Player;
9 | import org.bukkit.event.HandlerList;
10 |
11 | import javax.annotation.Nullable;
12 | import java.util.Objects;
13 | import java.util.Optional;
14 | import java.util.UUID;
15 |
16 | /**
17 | * Event called when a user has joined a {@link Faction}.
18 | */
19 | public class PlayerJoinedFactionEvent extends FactionEvent {
20 |
21 | private static final HandlerList handlers = new HandlerList();
22 |
23 | private Optional player; // lazy-load
24 |
25 | @Getter
26 | private final CommandSender sender;
27 |
28 | @Getter
29 | private final UUID playerUUID;
30 |
31 | public PlayerJoinedFactionEvent(CommandSender sender, @Nullable Player player, UUID playerUUID, PlayerFaction playerFaction) {
32 | super(playerFaction);
33 |
34 | Objects.requireNonNull(sender, "Sender cannot be null");
35 | Objects.requireNonNull(playerUUID, "Player UUID cannot be null");
36 | Objects.requireNonNull(playerFaction, "Player faction cannot be null");
37 |
38 | this.sender = sender;
39 | if (player != null) {
40 | this.player = Optional.of(player);
41 | }
42 |
43 | this.playerUUID = playerUUID;
44 | }
45 |
46 | /**
47 | * Gets the optional {@link Player} joining, this will load lazily.
48 | *
49 | * @return the {@link Player} or {@link Optional#empty()} ()} or if offline
50 | */
51 | public Optional getPlayer() {
52 | if (this.player == null) {
53 | this.player = Optional.ofNullable(Bukkit.getPlayer(this.playerUUID));
54 | }
55 |
56 | return this.player;
57 | }
58 |
59 | public static HandlerList getHandlerList() {
60 | return handlers;
61 | }
62 |
63 | @Override
64 | public HandlerList getHandlers() {
65 | return handlers;
66 | }
67 |
68 | @Override
69 | public PlayerFaction getFaction() {
70 | return (PlayerFaction) super.getFaction();
71 | }
72 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/PlayerLeftFactionEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event;
2 |
3 | import com.doctordark.hcf.faction.event.cause.FactionLeaveCause;
4 | import com.doctordark.hcf.faction.type.Faction;
5 | import com.doctordark.hcf.faction.type.PlayerFaction;
6 | import lombok.Getter;
7 | import org.bukkit.Bukkit;
8 | import org.bukkit.command.CommandSender;
9 | import org.bukkit.entity.Player;
10 | import org.bukkit.event.HandlerList;
11 |
12 | import javax.annotation.Nullable;
13 | import java.util.Objects;
14 | import java.util.Optional;
15 | import java.util.UUID;
16 |
17 | /**
18 | * Faction event called when a user has left their {@link Faction}.
19 | */
20 | public class PlayerLeftFactionEvent extends FactionEvent {
21 |
22 | private static final HandlerList handlers = new HandlerList();
23 |
24 | private Optional player;
25 |
26 | @Getter
27 | private final UUID uniqueID;
28 |
29 | @Getter
30 | private final FactionLeaveCause cause;
31 |
32 | @Getter
33 | private final CommandSender sender;
34 |
35 | @Getter
36 | private final boolean isKick;
37 |
38 | @Getter
39 | private final boolean force;
40 |
41 | public PlayerLeftFactionEvent(CommandSender sender, @Nullable Player player, UUID playerUUID, PlayerFaction playerFaction, FactionLeaveCause cause, boolean isKick, boolean force) {
42 | super(playerFaction);
43 |
44 | Objects.requireNonNull(sender, "Sender cannot be null");
45 | Objects.requireNonNull(playerUUID, "Player UUID cannot be null");
46 | Objects.requireNonNull(playerFaction, "Player faction cannot be null");
47 | Objects.requireNonNull(cause, "Cause cannot be null");
48 |
49 | this.sender = sender;
50 | if (player != null) {
51 | this.player = Optional.of(player);
52 | }
53 |
54 | this.uniqueID = playerUUID;
55 | this.cause = cause;
56 | this.isKick = isKick;
57 | this.force = force;
58 | }
59 |
60 | public Optional getPlayer() {
61 | if (this.player == null) {
62 | this.player = Optional.ofNullable(Bukkit.getPlayer(uniqueID));
63 | }
64 |
65 | return player;
66 | }
67 |
68 | public static HandlerList getHandlerList() {
69 | return handlers;
70 | }
71 |
72 | @Override
73 | public HandlerList getHandlers() {
74 | return handlers;
75 | }
76 |
77 | @Override
78 | public PlayerFaction getFaction() {
79 | return (PlayerFaction) super.getFaction();
80 | }
81 | }
82 |
83 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/cause/ClaimChangeCause.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event.cause;
2 |
3 | public enum ClaimChangeCause {
4 |
5 | UNCLAIM, CLAIM, RESIZE
6 | }
7 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/event/cause/FactionLeaveCause.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.event.cause;
2 |
3 | public enum FactionLeaveCause {
4 |
5 | KICK, LEAVE, DISBAND
6 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/struct/Raidable.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.struct;
2 |
3 | import com.doctordark.hcf.faction.type.Faction;
4 |
5 | /**
6 | * Represents a {@link Faction} that can be raided.
7 | * When a faction has 0 or below DTR (deaths until raidable), they are considered 'raidable'.
8 | */
9 | public interface Raidable {
10 |
11 | /**
12 | * Checks if this is raidable.
13 | *
14 | * @return true if is raidable
15 | */
16 | boolean isRaidable();
17 |
18 | /**
19 | * Gets the remaining deaths until this becomes 'raidable'.
20 | *
21 | * @return the deaths until raidable value
22 | */
23 | double getDeathsUntilRaidable();
24 |
25 | /**
26 | * Gets the maximum deaths until this faction becomes 'raidable'.
27 | *
28 | * @return maximum deaths until raidable
29 | */
30 | double getMaximumDeathsUntilRaidable();
31 |
32 | /**
33 | * Sets the remaining deaths until this becomes 'raidable'.
34 | *
35 | * @param deathsUntilRaidable the value to set
36 | * @return the new deaths until raidable value
37 | */
38 | double setDeathsUntilRaidable(double deathsUntilRaidable);
39 |
40 | /**
41 | * Gets the remaining time in milliseconds until this can
42 | * start regenerating DTR again.
43 | *
44 | * @return the time in milliseconds
45 | */
46 | long getRemainingRegenerationTime();
47 |
48 | /**
49 | * Sets the remaining time in milliseconds until this can
50 | * start regenerating DTR again.
51 | *
52 | * @param millis the time to set
53 | */
54 | void setRemainingRegenerationTime(long millis);
55 |
56 | /**
57 | * Gets the {@link RegenStatus} of this.
58 | *
59 | * @return the {@link RegenStatus}
60 | */
61 | RegenStatus getRegenStatus();
62 | }
63 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/struct/RegenStatus.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.struct;
2 |
3 | import com.doctordark.hcf.faction.type.Faction;
4 | import org.bukkit.ChatColor;
5 |
6 | /**
7 | * Represents the {@link RegenStatus} of a {@link Faction}.
8 | */
9 | public enum RegenStatus {
10 |
11 | FULL(ChatColor.GREEN.toString() + '\u25B6'),
12 | REGENERATING(ChatColor.GOLD.toString() + '\u21ea'),
13 | PAUSED(ChatColor.RED.toString() + '\u25a0');
14 |
15 | private final String symbol;
16 |
17 | RegenStatus(String symbol) {
18 | this.symbol = symbol;
19 | }
20 |
21 | /**
22 | * Gets the symbol of this {@link RegenStatus}.
23 | *
24 | * @return the regeneration status
25 | */
26 | public String getSymbol() {
27 | return symbol;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/struct/Relation.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.struct;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.faction.type.Faction;
5 | import com.doctordark.util.BukkitUtils;
6 | import org.bukkit.ChatColor;
7 | import org.bukkit.DyeColor;
8 |
9 | /**
10 | * Represents a relation between {@link Faction}s and {@link org.bukkit.entity.Player}s.
11 | */
12 | public enum Relation {
13 |
14 | MEMBER(3), ALLY(2), ENEMY(1);
15 |
16 | private final int value;
17 |
18 | Relation(final int value) {
19 | this.value = value;
20 | }
21 |
22 | public int getValue() {
23 | return value;
24 | }
25 |
26 | public boolean isAtLeast(Relation relation) {
27 | return this.value >= relation.value;
28 | }
29 |
30 | public boolean isAtMost(Relation relation) {
31 | return this.value <= relation.value;
32 | }
33 |
34 | public boolean isMember() {
35 | return this == MEMBER;
36 | }
37 |
38 | public boolean isAlly() {
39 | return this == ALLY;
40 | }
41 |
42 | public boolean isEnemy() {
43 | return this == ENEMY;
44 | }
45 |
46 | public String getDisplayName() {
47 | switch (this) {
48 | case ALLY:
49 | return toChatColour() + "alliance";
50 | default:
51 | return toChatColour() + name().toLowerCase();
52 | }
53 | }
54 |
55 | public ChatColor toChatColour() {
56 | HCF plugin = HCF.getPlugin();
57 | switch (this) {
58 | case MEMBER:
59 | return plugin.getConfiguration().getRelationColourTeammate();
60 | case ALLY:
61 | return plugin.getConfiguration().getRelationColourAlly();
62 | case ENEMY:
63 | default:
64 | return plugin.getConfiguration().getRelationColourEnemy();
65 | }
66 | }
67 |
68 | public DyeColor toDyeColour() {
69 | return BukkitUtils.toDyeColor(toChatColour());
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/struct/Role.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.struct;
2 |
3 | import com.doctordark.hcf.faction.type.Faction;
4 |
5 | /**
6 | * Represents the {@link Role} of a {@link org.bukkit.entity.Player} in a {@link Faction}.
7 | */
8 | public enum Role {
9 |
10 | LEADER("Leader", "**"),
11 | CAPTAIN("Captain", "*"),
12 | MEMBER("Member", "");
13 |
14 | private final String name;
15 | private final String astrix;
16 |
17 | Role(String name, String astrix) {
18 | this.name = name;
19 | this.astrix = astrix;
20 | }
21 |
22 | /**
23 | * Gets the name of this {@link Role}.
24 | *
25 | * @return the name
26 | */
27 | public String getName() {
28 | return name;
29 | }
30 |
31 | /**
32 | * Gets the astrix of this {@link Role}.
33 | *
34 | * @return the astrix
35 | */
36 | public String getAstrix() {
37 | return astrix;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/type/EndPortalFaction.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.type;
2 |
3 | import com.doctordark.hcf.ConfigurationService;
4 | import com.doctordark.hcf.faction.claim.Claim;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.Location;
7 | import org.bukkit.World;
8 | import org.bukkit.configuration.serialization.ConfigurationSerializable;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * Represents the {@link EndPortalFaction}.
14 | */
15 | public class EndPortalFaction extends ClaimableFaction implements ConfigurationSerializable {
16 |
17 | public EndPortalFaction() {
18 | super("EndPortal");
19 |
20 | World overworld = Bukkit.getWorld("world");
21 | int maxHeight = overworld.getMaxHeight();
22 | int min = ConfigurationService.END_PORTAL_CENTER - ConfigurationService.END_PORTAL_RADIUS;
23 | int max = ConfigurationService.END_PORTAL_CENTER + ConfigurationService.END_PORTAL_RADIUS;
24 |
25 | // North East (++)
26 | addClaim(new Claim(this, new Location(overworld, min, 0, min), new Location(overworld, max, maxHeight, max)), null);
27 |
28 | // South West (--)
29 | addClaim(new Claim(this, new Location(overworld, -max, maxHeight, -max), new Location(overworld, -min, 0, -min)), null);
30 |
31 | // North West (-+)
32 | addClaim(new Claim(this, new Location(overworld, -max, 0, min), new Location(overworld, -min, maxHeight, max)), null);
33 |
34 | // South East (+-)
35 | addClaim(new Claim(this, new Location(overworld, min, 0, -max), new Location(overworld, max, maxHeight, -min)), null);
36 |
37 | this.safezone = true;
38 | }
39 |
40 | public EndPortalFaction(Map map) {
41 | super(map);
42 | }
43 |
44 | @Override
45 | public boolean isDeathban() {
46 | return false;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/type/SpawnFaction.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.type;
2 |
3 | import com.doctordark.hcf.ConfigurationService;
4 | import com.doctordark.hcf.faction.claim.Claim;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.Location;
7 | import org.bukkit.World;
8 | import org.bukkit.configuration.serialization.ConfigurationSerializable;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * Represents the {@link SpawnFaction}.
14 | */
15 | public class SpawnFaction extends ClaimableFaction implements ConfigurationSerializable {
16 |
17 | public SpawnFaction() {
18 | super("Spawn");
19 |
20 | this.safezone = true;
21 | for (World world : Bukkit.getWorlds()) {
22 | int radius = ConfigurationService.SPAWN_RADIUS_MAP.get(world.getEnvironment());
23 | if (radius > 0) {
24 | addClaim(new Claim(this, new Location(world, radius, 0, radius), new Location(world, -radius, world.getMaxHeight(), -radius)), null);
25 | }
26 | }
27 | }
28 |
29 | public SpawnFaction(Map map) {
30 | super(map);
31 | }
32 |
33 | @Override
34 | public boolean isDeathban() {
35 | return false;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/type/WarzoneFaction.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.type;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import org.bukkit.command.CommandSender;
5 |
6 | import java.util.Map;
7 |
8 | /**
9 | * Represents the {@link WarzoneFaction}.
10 | */
11 | public class WarzoneFaction extends Faction {
12 |
13 | public WarzoneFaction() {
14 | super("Warzone");
15 | }
16 |
17 | public WarzoneFaction(Map map) {
18 | super(map);
19 | }
20 |
21 | @Override
22 | public String getDisplayName(CommandSender sender) {
23 | return HCF.getPlugin().getConfiguration().getRelationColourWarzone() + getName();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/faction/type/WildernessFaction.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.faction.type;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import org.bukkit.command.CommandSender;
5 |
6 | import java.util.Map;
7 |
8 | /**
9 | * Represents the {@link WildernessFaction}.
10 | */
11 | public class WildernessFaction extends Faction {
12 |
13 | public WildernessFaction() {
14 | super("Wilderness");
15 | }
16 |
17 | public WildernessFaction(Map map) {
18 | super(map);
19 | }
20 |
21 | @Override
22 | public String getDisplayName(CommandSender sender) {
23 | return HCF.getPlugin().getConfiguration().getRelationColourWilderness() + getName();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/listener/BookDisenchantListener.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.listener;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import org.bukkit.ChatColor;
5 | import org.bukkit.Material;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.EventHandler;
8 | import org.bukkit.event.EventPriority;
9 | import org.bukkit.event.Listener;
10 | import org.bukkit.event.block.Action;
11 | import org.bukkit.event.player.PlayerInteractEvent;
12 | import org.bukkit.inventory.ItemStack;
13 |
14 | public class BookDisenchantListener implements Listener {
15 |
16 | private final HCF plugin;
17 |
18 | public BookDisenchantListener(HCF plugin) {
19 | this.plugin = plugin;
20 | }
21 |
22 | @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
23 | public void disenchantBook(PlayerInteractEvent event) {
24 | // Do nothing if disenchanting is disabled in configuration or player
25 | // is not left clicking an enchantment table.
26 | if (!plugin.getConfiguration().isBookDisenchanting() ||
27 | event.getAction() != Action.LEFT_CLICK_BLOCK ||
28 | event.getClickedBlock().getType() != Material.ENCHANTMENT_TABLE) {
29 | return;
30 | }
31 |
32 | // Do nothing if player is not holding a valid enchanted book.
33 | Player player = event.getPlayer();
34 | ItemStack item = player.getItemInHand();
35 | if (item == null || item.getType() != Material.ENCHANTED_BOOK) {
36 | return;
37 | }
38 |
39 | // Cancel the event, set the book to a regular book and inform.
40 | event.setCancelled(true);
41 | player.setItemInHand(new ItemStack(Material.BOOK, 1));
42 | player.sendMessage(ChatColor.YELLOW + "You reverted this item to its original form.");
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/listener/DeathListener.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.listener;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.faction.struct.Role;
5 | import com.doctordark.hcf.faction.type.Faction;
6 | import com.doctordark.hcf.faction.type.PlayerFaction;
7 | import com.doctordark.hcf.user.FactionUser;
8 | import com.doctordark.util.JavaUtils;
9 | import org.bukkit.ChatColor;
10 | import org.bukkit.entity.Player;
11 | import org.bukkit.event.EventHandler;
12 | import org.bukkit.event.EventPriority;
13 | import org.bukkit.event.Listener;
14 | import org.bukkit.event.entity.PlayerDeathEvent;
15 |
16 | public class DeathListener implements Listener {
17 |
18 | private final HCF plugin;
19 |
20 | public DeathListener(HCF plugin) {
21 | this.plugin = plugin;
22 | }
23 |
24 | @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
25 | public void onPlayerDeathKillIncrement(PlayerDeathEvent event) {
26 | Player killer = event.getEntity().getKiller();
27 | if (killer != null) {
28 | FactionUser user = plugin.getUserManager().getUser(killer.getUniqueId());
29 | user.setKills(user.getKills() + 1);
30 | }
31 | }
32 |
33 | @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
34 | public void onPlayerDeath(PlayerDeathEvent event) {
35 | Player player = event.getEntity();
36 | PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
37 |
38 | if (playerFaction == null) return;
39 |
40 | Faction factionAt = plugin.getFactionManager().getFactionAt(player.getLocation());
41 | double dtrLoss = (1.0D * factionAt.getDtrLossMultiplier());
42 | double newDtr = playerFaction.setDeathsUntilRaidable(playerFaction.getDeathsUntilRaidable() - dtrLoss);
43 |
44 | Role role = playerFaction.getMember(player.getUniqueId()).getRole();
45 | long baseDelay = plugin.getConfiguration().getFactionDtrRegenFreezeBaseMilliseconds();
46 | playerFaction.setRemainingRegenerationTime(baseDelay + (playerFaction.getOnlinePlayers().size() * plugin.getConfiguration().getFactionDtrRegenFreezeMillisecondsPerMember()));
47 | playerFaction.broadcast(ChatColor.GOLD + "Member Death: " + plugin.getConfiguration().getRelationColourTeammate() +
48 | role.getAstrix() + player.getName() + ChatColor.GOLD + ". " +
49 | "DTR: (" + ChatColor.WHITE + JavaUtils.format(newDtr, 2) + '/' + JavaUtils.format(playerFaction.getMaximumDeathsUntilRaidable(), 2) + ChatColor.GOLD + ").");
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/listener/EntityLimitListener.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.listener;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import org.bukkit.entity.Entity;
5 | import org.bukkit.entity.Squid;
6 | import org.bukkit.event.EventHandler;
7 | import org.bukkit.event.EventPriority;
8 | import org.bukkit.event.Listener;
9 | import org.bukkit.event.entity.CreatureSpawnEvent;
10 |
11 | /**
12 | * Listener that limits the amount of entities in one chunk.
13 | */
14 | public class EntityLimitListener implements Listener {
15 |
16 | private static final int MAX_CHUNK_GENERATED_ENTITIES = 25;
17 | private static final int MAX_NATURAL_CHUNK_ENTITIES = 25;
18 |
19 | private final HCF plugin;
20 |
21 | public EntityLimitListener(HCF plugin) {
22 | this.plugin = plugin;
23 | }
24 |
25 | @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
26 | public void onCreatureSpawn(CreatureSpawnEvent event) {
27 | if (!plugin.getConfiguration().isHandleEntityLimiting()) {
28 | return;
29 | }
30 |
31 | Entity entity = event.getEntity();
32 | if (entity instanceof Squid) {
33 | event.setCancelled(true);
34 | return;
35 | }
36 |
37 | if (event.getSpawnReason() != CreatureSpawnEvent.SpawnReason.SLIME_SPLIT) { // allow slimes to always split
38 | switch (event.getSpawnReason()) {
39 | case NATURAL:
40 | if (event.getLocation().getChunk().getEntities().length > MAX_NATURAL_CHUNK_ENTITIES) {
41 | event.setCancelled(true);
42 | }
43 | break;
44 | case CHUNK_GEN:
45 | if (event.getLocation().getChunk().getEntities().length > MAX_CHUNK_GENERATED_ENTITIES) {
46 | event.setCancelled(true);
47 | }
48 | break;
49 | default:
50 | break;
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/listener/FurnaceSmeltSpeedListener.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.listener;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import org.bukkit.block.Block;
5 | import org.bukkit.block.BlockState;
6 | import org.bukkit.block.Furnace;
7 | import org.bukkit.event.EventHandler;
8 | import org.bukkit.event.EventPriority;
9 | import org.bukkit.event.Listener;
10 | import org.bukkit.event.block.Action;
11 | import org.bukkit.event.player.PlayerInteractEvent;
12 |
13 | public class FurnaceSmeltSpeedListener implements Listener {
14 |
15 | private final HCF plugin;
16 |
17 | public FurnaceSmeltSpeedListener(HCF plugin) {
18 | this.plugin = plugin;
19 | }
20 |
21 | @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
22 | public void onPlayerInteract(PlayerInteractEvent event) {
23 | if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
24 | double multiplier = plugin.getConfiguration().getFurnaceCookSpeedMultiplier();
25 | if (multiplier == 1.0) {
26 | return;
27 | }
28 |
29 | Block block = event.getClickedBlock();
30 | BlockState state = block.getState();
31 | if (state instanceof Furnace) {
32 | ((Furnace) state).setCookSpeedMultiplier(plugin.getConfiguration().getFurnaceCookSpeedMultiplier());
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/listener/SkullListener.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.listener;
2 |
3 | import org.bukkit.ChatColor;
4 | import org.bukkit.Material;
5 | import org.bukkit.SkullType;
6 | import org.bukkit.block.Block;
7 | import org.bukkit.block.Skull;
8 | import org.bukkit.entity.Player;
9 | import org.bukkit.event.EventHandler;
10 | import org.bukkit.event.EventPriority;
11 | import org.bukkit.event.Listener;
12 | import org.bukkit.event.block.Action;
13 | import org.bukkit.event.entity.PlayerDeathEvent;
14 | import org.bukkit.event.player.PlayerInteractEvent;
15 | import org.bukkit.inventory.ItemStack;
16 | import org.bukkit.inventory.meta.SkullMeta;
17 |
18 | public class SkullListener implements Listener {
19 |
20 | @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
21 | public void dropPlayerSkull(PlayerDeathEvent event) {
22 | Player player = event.getEntity();
23 | Player killer = player.getKiller();
24 | if (killer != null && killer.hasPermission("hcf.kill.behead")) {
25 | ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
26 | SkullMeta meta = (SkullMeta) skull.getItemMeta();
27 | meta.setOwner(player.getName());
28 | skull.setItemMeta(meta);
29 | event.getDrops().add(skull);
30 | }
31 | }
32 |
33 | @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
34 | public void showPlayerSkullInformation(PlayerInteractEvent event) {
35 | Player player = event.getPlayer();
36 | Block block = event.getClickedBlock();
37 |
38 | if (event.getAction() == Action.RIGHT_CLICK_BLOCK
39 | && block.getState() instanceof Skull) {
40 | Skull skull = (Skull) block.getState();
41 | if (skull.getSkullType() == SkullType.PLAYER) {
42 | player.sendMessage(ChatColor.YELLOW + "This is the skull of " + skull.getOwner());
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/listener/fixes/BeaconStrengthFixListener.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.listener.fixes;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import org.bukkit.entity.LivingEntity;
5 | import org.bukkit.entity.Player;
6 | import org.bukkit.event.EventHandler;
7 | import org.bukkit.event.EventPriority;
8 | import org.bukkit.event.Listener;
9 | import org.bukkit.potion.PotionEffect;
10 | import org.bukkit.potion.PotionEffectType;
11 | import org.github.paperspigot.event.block.BeaconEffectEvent;
12 |
13 | public class BeaconStrengthFixListener implements Listener {
14 |
15 | private static final int VANILLA_BEACON_STRENGTH_LIMIT = 2;
16 |
17 | private final HCF plugin;
18 |
19 | public BeaconStrengthFixListener(HCF plugin) {
20 | this.plugin = plugin;
21 | }
22 |
23 | @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
24 | public void onPotionEffectAdd(BeaconEffectEvent event) {
25 | int limit = plugin.getConfiguration().getBeaconStrengthLevelLimit();
26 |
27 | if (limit <= 0) {
28 | event.setCancelled(true);
29 | return;
30 | }
31 |
32 | limit--; // we do this because the numbering for potion effects are weird in bukkit
33 | // amplifier of 0 is a level 1 potion, amplifier of 1 is a level 2, etc..
34 | // so let's not confuse the config editor.
35 | if (limit >= BeaconStrengthFixListener.VANILLA_BEACON_STRENGTH_LIMIT) {
36 | return;
37 | }
38 |
39 | PotionEffect effect = event.getEffect();
40 | if (effect.getAmplifier() > limit && effect.getType().equals(PotionEffectType.INCREASE_DAMAGE)) {
41 | event.getPlayer().addPotionEffect(new PotionEffect(effect.getType(), effect.getDuration(), limit, effect.isAmbient()));
42 | event.setCancelled(true);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/listener/fixes/BlockJumpGlitchFixListener.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.listener.fixes;
2 |
3 | import org.bukkit.GameMode;
4 | import org.bukkit.block.Block;
5 | import org.bukkit.block.Sign;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.EventHandler;
8 | import org.bukkit.event.EventPriority;
9 | import org.bukkit.event.Listener;
10 | import org.bukkit.event.block.BlockPlaceEvent;
11 | import org.bukkit.util.Vector;
12 |
13 | public class BlockJumpGlitchFixListener implements Listener {
14 |
15 | @EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR)
16 | public void onBlockBreak(BlockPlaceEvent event) {
17 | if (event.isCancelled()) {
18 | Player player = event.getPlayer();
19 | if (player.getGameMode() == GameMode.CREATIVE || player.getAllowFlight()) {
20 | return;
21 | }
22 |
23 | Block block = event.getBlockPlaced();
24 | if (block.getType().isSolid() && !(block.getState() instanceof Sign)) {
25 | int playerY = player.getLocation().getBlockY();
26 | int blockY = block.getLocation().getBlockY();
27 | if (playerY > blockY) {
28 | Vector vector = player.getVelocity();
29 | vector.setX(-0.1);
30 | vector.setZ(-0.1);
31 | player.setVelocity(vector.setY(vector.getY() - 0.41999998688697815D)); // Magic number acquired from EntityLiving#bj()
32 | }
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/listener/fixes/BoatGlitchFixListener.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.listener.fixes;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import org.bukkit.Material;
5 | import org.bukkit.block.Block;
6 | import org.bukkit.entity.Boat;
7 | import org.bukkit.entity.Vehicle;
8 | import org.bukkit.event.EventHandler;
9 | import org.bukkit.event.EventPriority;
10 | import org.bukkit.event.Listener;
11 | import org.bukkit.event.vehicle.VehicleCreateEvent;
12 |
13 | /**
14 | * Listener that prevents boats from being placed on land.
15 | */
16 | public class BoatGlitchFixListener implements Listener {
17 |
18 | private final HCF plugin;
19 |
20 | public BoatGlitchFixListener(HCF plugin) {
21 | this.plugin = plugin;
22 | }
23 |
24 | @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
25 | public void onVehicleCreate(VehicleCreateEvent event) {
26 | if (plugin.getConfiguration().isDisableBoatPlacementOnLand()) {
27 | Vehicle vehicle = event.getVehicle();
28 | if (vehicle instanceof Boat) {
29 | Boat boat = (Boat) vehicle;
30 | Block belowBlock = boat.getLocation().add(0, -1, 0).getBlock();
31 | if (belowBlock.getType() != Material.WATER && belowBlock.getType() != Material.STATIONARY_WATER) {
32 | boat.remove();
33 | }
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/listener/fixes/EnderChestRemovalListener.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.listener.fixes;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import org.bukkit.Bukkit;
5 | import org.bukkit.Material;
6 | import org.bukkit.event.EventHandler;
7 | import org.bukkit.event.EventPriority;
8 | import org.bukkit.event.Listener;
9 | import org.bukkit.event.block.Action;
10 | import org.bukkit.event.inventory.InventoryOpenEvent;
11 | import org.bukkit.event.player.PlayerInteractEvent;
12 | import org.bukkit.inventory.Recipe;
13 | import org.bukkit.material.EnderChest;
14 |
15 | import java.util.Iterator;
16 |
17 | /**
18 | * Listener that prevents the use of Ender Chests.
19 | */
20 | public class EnderChestRemovalListener implements Listener {
21 |
22 | private final HCF plugin;
23 |
24 | public EnderChestRemovalListener(HCF plugin) {
25 | this.plugin = plugin;
26 | if (plugin.getConfiguration().isDisableEnderchests()) {
27 | this.removeRecipe();
28 | }
29 | }
30 |
31 | @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
32 | public void onEnderChestOpen(PlayerInteractEvent event) {
33 | if (plugin.getConfiguration().isDisableEnderchests() && event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.ENDER_CHEST) {
34 | event.setCancelled(true);
35 | }
36 | }
37 |
38 | @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
39 | public void onInventoryOpen(InventoryOpenEvent event) {
40 | if (plugin.getConfiguration().isDisableEnderchests() && event.getInventory() instanceof EnderChest) {
41 | event.setCancelled(true);
42 | }
43 | }
44 |
45 | /**
46 | * Removes the ender-chest crafting recipe from the server meaning
47 | * it can only be obtained from creative mode.
48 | */
49 | private void removeRecipe() {
50 | for (Iterator iterator = Bukkit.recipeIterator(); iterator.hasNext(); ) {
51 | if (iterator.next().getResult().getType() == Material.ENDER_CHEST) {
52 | iterator.remove();
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/listener/fixes/InfinityArrowFixListener.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.listener.fixes;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow;
5 | import org.bukkit.entity.Arrow;
6 | import org.bukkit.entity.Entity;
7 | import org.bukkit.entity.Player;
8 | import org.bukkit.event.EventHandler;
9 | import org.bukkit.event.EventPriority;
10 | import org.bukkit.event.Listener;
11 | import org.bukkit.event.entity.ProjectileHitEvent;
12 |
13 | /**
14 | * Listener that removes {@link org.bukkit.entity.Arrow}s from bows with Infinity when they land.
15 | */
16 | public class InfinityArrowFixListener implements Listener {
17 |
18 | private final HCF plugin;
19 |
20 | public InfinityArrowFixListener(HCF plugin) {
21 | this.plugin = plugin;
22 | }
23 |
24 | @EventHandler(ignoreCancelled = false, priority = EventPriority.NORMAL)
25 | public void onProjectileHit(ProjectileHitEvent event) {
26 | if (plugin.getConfiguration().isRemoveInfinityArrowsOnLand()) {
27 | Entity entity = event.getEntity();
28 | if (entity instanceof Arrow) {
29 | Arrow arrow = (Arrow) entity;
30 | if (!(arrow.getShooter() instanceof Player) || ((CraftArrow) arrow).getHandle().fromPlayer == 2) {
31 | arrow.remove();
32 | }
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/listener/fixes/VoidGlitchFixListener.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.listener.fixes;
2 |
3 | import com.doctordark.util.BukkitUtils;
4 | import org.bukkit.ChatColor;
5 | import org.bukkit.Location;
6 | import org.bukkit.World;
7 | import org.bukkit.entity.Entity;
8 | import org.bukkit.entity.Player;
9 | import org.bukkit.event.EventHandler;
10 | import org.bukkit.event.EventPriority;
11 | import org.bukkit.event.Listener;
12 | import org.bukkit.event.entity.EntityDamageEvent;
13 | import org.bukkit.event.player.PlayerTeleportEvent;
14 |
15 | /**
16 | * Listener that prevents players being killed by the void in the Overworld.
17 | */
18 | public class VoidGlitchFixListener implements Listener {
19 |
20 | @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
21 | public void onPlayerDamage(EntityDamageEvent event) {
22 | if (event.getCause() == EntityDamageEvent.DamageCause.VOID) {
23 | Entity entity = event.getEntity();
24 | if (entity instanceof Player) {
25 | // Allow players to die by VOID in the END
26 | if (entity.getWorld().getEnvironment() == World.Environment.THE_END) {
27 | return;
28 | }
29 |
30 | Location destination = BukkitUtils.getHighestLocation(entity.getLocation());
31 | if (destination != null && entity.teleport(destination, PlayerTeleportEvent.TeleportCause.PLUGIN)) {
32 | event.setCancelled(true);
33 | ((Player) entity).sendMessage(ChatColor.YELLOW + "You were saved from the void.");
34 | }
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/pvpclass/PvpClass.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.pvpclass;
2 |
3 | import org.bukkit.ChatColor;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.potion.PotionEffect;
6 |
7 | import java.util.HashSet;
8 | import java.util.Set;
9 | import java.util.concurrent.TimeUnit;
10 |
11 | /**
12 | * Represents a class that can apply PVP buffs for players.
13 | */
14 | public abstract class PvpClass {
15 |
16 | public static final long DEFAULT_MAX_DURATION = TimeUnit.MINUTES.toMillis(8L);
17 |
18 | protected final Set passiveEffects = new HashSet<>();
19 | protected final String name;
20 | protected final long warmupDelay;
21 |
22 | public PvpClass(String name, long warmupDelay) {
23 | this.name = name;
24 | this.warmupDelay = warmupDelay;
25 | }
26 |
27 | /**
28 | * Gets the name of this {@link PvpClass}.
29 | *
30 | * @return the name
31 | */
32 | public String getName() {
33 | return name;
34 | }
35 |
36 | /**
37 | * Gets the warmup delay of this {@link PvpClass}.
38 | *
39 | * @return the warmup delay in milliseconds
40 | */
41 | public long getWarmupDelay() {
42 | return warmupDelay;
43 | }
44 |
45 | /**
46 | * Method called when a {@link Player} equips a {@link PvpClass}.
47 | *
48 | * @param player the equipping {@link Player}
49 | * @return true if successfully equipped
50 | */
51 | public boolean onEquip(Player player) {
52 | for (PotionEffect effect : passiveEffects) {
53 | player.addPotionEffect(effect, true);
54 | }
55 |
56 | player.sendMessage(ChatColor.AQUA + name + " has been activated.");
57 | return true;
58 | }
59 |
60 | /**
61 | * Method called when a {@link Player} unequips a {@link PvpClass}.
62 | *
63 | * @param player the unequipping {@link Player}
64 | */
65 | public void onUnequip(Player player) {
66 | for (PotionEffect effect : passiveEffects) {
67 | for (PotionEffect active : player.getActivePotionEffects()) {
68 | if (active.getDuration() > DEFAULT_MAX_DURATION && active.getType().equals(effect.getType()) && active.getAmplifier() == effect.getAmplifier()) {
69 | player.removePotionEffect(effect.getType());
70 | break;
71 | }
72 | }
73 | }
74 |
75 | player.sendMessage(ChatColor.AQUA + name + " has been deactivated.");
76 | }
77 |
78 | //TODO: More automated method
79 | public abstract boolean isApplicableFor(Player player);
80 | }
81 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/pvpclass/archer/ArcherMark.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.pvpclass.archer;
2 |
3 | import org.bukkit.scheduler.BukkitTask;
4 |
5 | import javax.annotation.Nonnull;
6 |
7 | /**
8 | * Represents a tag made by {@link org.bukkit.entity.Player} who has the {@link ArcherClass} equipped.
9 | */
10 | public class ArcherMark implements Comparable {
11 |
12 | public BukkitTask decrementTask;
13 | public int currentLevel;
14 |
15 | public void reset() {
16 | if (this.decrementTask != null) {
17 | this.decrementTask.cancel();
18 | this.decrementTask = null;
19 | }
20 |
21 | this.currentLevel = 0;
22 | }
23 |
24 | public int incrementMark() {
25 | return ++this.currentLevel;
26 | }
27 |
28 | public int decrementMark() {
29 | return --this.currentLevel;
30 | }
31 |
32 | @Override
33 | public boolean equals(Object o) {
34 | if (this == o) return true;
35 | if (!(o instanceof ArcherMark)) return false;
36 |
37 | ArcherMark that = (ArcherMark) o;
38 |
39 | if (currentLevel != that.currentLevel) return false;
40 | return !(decrementTask != null ? !decrementTask.equals(that.decrementTask) : that.decrementTask != null);
41 | }
42 |
43 | @Override
44 | public int hashCode() {
45 | int result = decrementTask != null ? decrementTask.hashCode() : 0;
46 | result = 31 * result + currentLevel;
47 | return result;
48 | }
49 |
50 | @Override
51 | public int compareTo(@Nonnull ArcherMark archerMark) {
52 | return Integer.compare(currentLevel, archerMark.currentLevel);
53 | }
54 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/pvpclass/bard/BardData.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.pvpclass.bard;
2 |
3 | import com.google.common.base.Preconditions;
4 | import lombok.Getter;
5 | import org.bukkit.scheduler.BukkitTask;
6 |
7 | /**
8 | * Holds data about a {@link BardClass}.
9 | */
10 | public class BardData {
11 |
12 | public static final double ENERGY_PER_MILLISECOND = 1.25D;
13 | public static final double MIN_ENERGY = 0.0D;
14 | public static final double MAX_ENERGY = 120.0D;
15 | public static final long MAX_ENERGY_MILLIS = (long) (MAX_ENERGY * 1000L);
16 |
17 | @Getter
18 | private long buffCooldown;
19 |
20 | @Getter
21 | protected BukkitTask heldTask; //TODO: find a way to make private
22 |
23 | private long energyStart;
24 |
25 | public void setBuffCooldown(long millis) {
26 | this.buffCooldown = System.currentTimeMillis() + millis;
27 | }
28 |
29 | public long getRemainingBuffDelay() {
30 | return this.buffCooldown - System.currentTimeMillis();
31 | }
32 |
33 | /**
34 | * Begins tracking energy.
35 | */
36 | public void startEnergyTracking() {
37 | this.setEnergy(0);
38 | }
39 |
40 | /**
41 | * Gets the energy in milliseconds.
42 | *
43 | * @return energy in milliseconds
44 | */
45 | public long getEnergyMillis() {
46 | if (this.energyStart == 0L) {
47 | return 0L;
48 | }
49 |
50 | return Math.min(MAX_ENERGY_MILLIS, (long) (ENERGY_PER_MILLISECOND * (System.currentTimeMillis() - this.energyStart)));
51 | }
52 |
53 | public double getEnergy() {
54 | return Math.round(this.getEnergyMillis() / 100.0) / 10.0;
55 | }
56 |
57 | public void setEnergy(double energy) {
58 | Preconditions.checkArgument(energy >= MIN_ENERGY, "Energy cannot be less than " + MIN_ENERGY);
59 | Preconditions.checkArgument(energy <= MAX_ENERGY, "Energy cannot be more than " + MAX_ENERGY);
60 | this.energyStart = (long) (System.currentTimeMillis() - (1000L * energy));
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/pvpclass/bard/BardEffect.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.pvpclass.bard;
2 |
3 | import org.bukkit.potion.PotionEffect;
4 |
5 | /**
6 | * Represents a {@link BardClass} effect.
7 | */
8 | public class BardEffect {
9 |
10 | public final int energyCost;
11 | public final PotionEffect clickable;
12 | public final PotionEffect heldable;
13 |
14 | public BardEffect(int energyCost, PotionEffect clickable, PotionEffect heldable) {
15 | this.energyCost = energyCost;
16 | this.clickable = clickable;
17 | this.heldable = heldable;
18 | }
19 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/pvpclass/event/PvpClassEquipEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.pvpclass.event;
2 |
3 | import com.doctordark.hcf.pvpclass.PvpClass;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.HandlerList;
6 | import org.bukkit.event.player.PlayerEvent;
7 |
8 | /**
9 | * Event called when a player equips a {@link PvpClass}.
10 | */
11 | public class PvpClassEquipEvent extends PlayerEvent {
12 |
13 | private static final HandlerList handlers = new HandlerList();
14 |
15 | private final PvpClass pvpClass;
16 |
17 | public PvpClassEquipEvent(Player player, PvpClass pvpClass) {
18 | super(player);
19 | this.pvpClass = pvpClass;
20 | }
21 |
22 | /**
23 | * Gets the {@link PvpClass} being unequipped.
24 | *
25 | * @return the unequipped {@link PvpClass}
26 | */
27 | public PvpClass getPvpClass() {
28 | return pvpClass;
29 | }
30 |
31 | public static HandlerList getHandlerList() {
32 | return handlers;
33 | }
34 |
35 | @Override
36 | public HandlerList getHandlers() {
37 | return handlers;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/pvpclass/event/PvpClassUnequipEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.pvpclass.event;
2 |
3 | import com.doctordark.hcf.pvpclass.PvpClass;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.HandlerList;
6 | import org.bukkit.event.player.PlayerEvent;
7 |
8 | /**
9 | * Event called when a player unequips a {@link PvpClass}.
10 | */
11 | public class PvpClassUnequipEvent extends PlayerEvent {
12 |
13 | private static final HandlerList handlers = new HandlerList();
14 |
15 | private final PvpClass pvpClass;
16 |
17 | public PvpClassUnequipEvent(Player player, PvpClass pvpClass) {
18 | super(player);
19 | this.pvpClass = pvpClass;
20 | }
21 |
22 | /**
23 | * Gets the {@link PvpClass} being unequipped.
24 | *
25 | * @return the unequipped {@link PvpClass}
26 | */
27 | public PvpClass getPvpClass() {
28 | return pvpClass;
29 | }
30 |
31 | public static HandlerList getHandlerList() {
32 | return handlers;
33 | }
34 |
35 | @Override
36 | public HandlerList getHandlers() {
37 | return handlers;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/scoreboard/SidebarEntry.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.scoreboard;
2 |
3 | import javax.annotation.Nonnull;
4 |
5 | @Nonnull
6 | public class SidebarEntry {
7 |
8 | public final String name;
9 | public String prefix;
10 | public String suffix;
11 |
12 | public SidebarEntry(String name) {
13 | this.name = name;
14 | }
15 |
16 | public SidebarEntry(Object name) {
17 | this.name = String.valueOf(name);
18 | }
19 |
20 | public SidebarEntry(String prefix, String name, String suffix) {
21 | this.name = name;
22 | this.prefix = prefix;
23 | this.suffix = suffix;
24 | }
25 |
26 | public SidebarEntry(Object prefix, Object name, Object suffix) {
27 | this(name);
28 | this.prefix = String.valueOf(prefix);
29 | this.suffix = String.valueOf(suffix);
30 | }
31 |
32 | @Override
33 | public boolean equals(Object o) {
34 | if (this == o) return true;
35 | if (!(o instanceof SidebarEntry)) return false;
36 |
37 | SidebarEntry that = (SidebarEntry) o;
38 |
39 | if (name != null ? !name.equals(that.name) : that.name != null) return false;
40 | if (prefix != null ? !prefix.equals(that.prefix) : that.prefix != null) return false;
41 | return !(suffix != null ? !suffix.equals(that.suffix) : that.suffix != null);
42 | }
43 |
44 | @Override
45 | public int hashCode() {
46 | int result = name != null ? name.hashCode() : 0;
47 | result = 31 * result + (prefix != null ? prefix.hashCode() : 0);
48 | result = 31 * result + (suffix != null ? suffix.hashCode() : 0);
49 | return result;
50 | }
51 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/scoreboard/SidebarProvider.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.scoreboard;
2 |
3 | import org.bukkit.entity.Player;
4 |
5 | import java.util.List;
6 |
7 | public interface SidebarProvider {
8 |
9 | /**
10 | * Gets the lines this provider will show for a {@link Player}.
11 | *
12 | * @param player the {@link Player} to get for
13 | * @return list of lines to show
14 | */
15 | List getLines(Player player);
16 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/sotw/SotwListener.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.sotw;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.EventHandler;
6 | import org.bukkit.event.EventPriority;
7 | import org.bukkit.event.Listener;
8 | import org.bukkit.event.entity.EntityDamageEvent;
9 |
10 | public class SotwListener implements Listener {
11 |
12 | private final HCF plugin;
13 |
14 | public SotwListener(HCF plugin) {
15 | this.plugin = plugin;
16 | }
17 |
18 | @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
19 | public void onEntityDamage(EntityDamageEvent event) {
20 | if (event.getEntity() instanceof Player && event.getCause() != EntityDamageEvent.DamageCause.SUICIDE && plugin.getSotwTimer().getSotwRunnable() != null) {
21 | event.setCancelled(true);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/sotw/SotwTimer.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.sotw;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import lombok.Getter;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.ChatColor;
7 | import org.bukkit.scheduler.BukkitRunnable;
8 |
9 | public class SotwTimer {
10 |
11 | @Getter
12 | private SotwRunnable sotwRunnable;
13 |
14 | public boolean cancel() {
15 | if (this.sotwRunnable != null) {
16 | this.sotwRunnable.cancel();
17 | this.sotwRunnable = null;
18 | return true;
19 | }
20 |
21 | return false;
22 | }
23 |
24 | public void start(long millis) {
25 | if (this.sotwRunnable == null) {
26 | this.sotwRunnable = new SotwRunnable(this, millis);
27 | this.sotwRunnable.runTaskLater(HCF.getPlugin(), millis / 50L);
28 | }
29 | }
30 |
31 | public static class SotwRunnable extends BukkitRunnable {
32 |
33 | private SotwTimer sotwTimer;
34 | private long startMillis;
35 | private long endMillis;
36 |
37 | public SotwRunnable(SotwTimer sotwTimer, long duration) {
38 | this.sotwTimer = sotwTimer;
39 | this.startMillis = System.currentTimeMillis();
40 | this.endMillis = this.startMillis + duration;
41 | }
42 |
43 | public long getRemaining() {
44 | return endMillis - System.currentTimeMillis();
45 | }
46 |
47 | @Override
48 | public void run() {
49 | Bukkit.broadcastMessage(ChatColor.RED.toString() + ChatColor.BOLD + "SOTW Protection is now over!");
50 | Bukkit.broadcastMessage(ChatColor.RED.toString() + ChatColor.BOLD + "You are no longer invincible.");
51 | this.cancel();
52 | this.sotwTimer.sotwRunnable = null;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/timer/GlobalTimer.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.timer;
2 |
3 | import com.doctordark.hcf.timer.event.TimerExtendEvent;
4 | import com.doctordark.hcf.timer.event.TimerPauseEvent;
5 | import com.doctordark.hcf.timer.event.TimerStartEvent;
6 | import org.bukkit.Bukkit;
7 |
8 | /**
9 | * Represents a global {@link Timer}.
10 | */
11 | public abstract class GlobalTimer extends Timer {
12 |
13 | private TimerCooldown runnable;
14 |
15 | public GlobalTimer(String name, long defaultCooldown) {
16 | super(name, defaultCooldown);
17 | }
18 |
19 | public boolean clearCooldown() {
20 | if (runnable != null) {
21 | runnable.cancel();
22 | runnable = null;
23 | return true;
24 | }
25 |
26 | return false;
27 | }
28 |
29 | public boolean isPaused() {
30 | return runnable != null && runnable.isPaused();
31 | }
32 |
33 | public void setPaused(boolean paused) {
34 | if (runnable != null && runnable.isPaused() != paused) {
35 | TimerPauseEvent event = new TimerPauseEvent(this, paused);
36 | Bukkit.getPluginManager().callEvent(event);
37 | if (!event.isCancelled()) {
38 | runnable.setPaused(paused);
39 | }
40 | }
41 | }
42 |
43 | public long getRemaining() {
44 | return runnable == null ? 0L : runnable.getRemaining();
45 | }
46 |
47 | public boolean setRemaining() {
48 | return setRemaining(defaultCooldown, false);
49 | }
50 |
51 | public boolean setRemaining(long duration, boolean overwrite) {
52 | boolean hadCooldown = false;
53 | if (runnable != null) {
54 | if (!overwrite) return false;
55 |
56 | TimerExtendEvent event = new TimerExtendEvent(this, runnable.getRemaining(), duration);
57 | Bukkit.getPluginManager().callEvent(event);
58 | if (event.isCancelled()) return false;
59 |
60 | hadCooldown = runnable.getRemaining() > 0L;
61 | runnable.setRemaining(duration);
62 | } else {
63 | Bukkit.getPluginManager().callEvent(new TimerStartEvent(this, duration));
64 | runnable = new TimerCooldown(this, duration);
65 | }
66 |
67 | return !hadCooldown;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/timer/Timer.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.timer;
2 |
3 | import com.doctordark.util.Config;
4 | import lombok.Getter;
5 |
6 | /**
7 | * Represents a {@link Timer}, used to manage cooldowns.
8 | */
9 | public abstract class Timer {
10 |
11 | @Getter
12 | protected final String name;
13 |
14 | protected final long defaultCooldown;
15 |
16 | /**
17 | * Constructs a new {@link Timer} with a given name.
18 | *
19 | * @param name the name
20 | * @param defaultCooldown the default cooldown in milliseconds
21 | */
22 | public Timer(String name, long defaultCooldown) {
23 | this.name = name;
24 | this.defaultCooldown = defaultCooldown;
25 | }
26 |
27 | /**
28 | * Gets the prefix this {@link Timer} will display on a scoreboard.
29 | *
30 | * @return the scoreboard prefix
31 | */
32 | public abstract String getScoreboardPrefix();
33 |
34 | /**
35 | * Gets the display name of this {@link Timer}.
36 | *
37 | * @return the display name
38 | */
39 | public final String getDisplayName() {
40 | return getScoreboardPrefix() + name;
41 | }
42 |
43 | /**
44 | * Loads the {@link Timer} data from storage.
45 | *
46 | * @param config the {@link Config} to load from
47 | */
48 | public void load(Config config) {
49 | }
50 |
51 | /**
52 | * Saves the {@link Timer} data to storage.
53 | *
54 | * @param config the {@link Config} to save to
55 | */
56 | public void onDisable(Config config) {
57 | }
58 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/timer/TimerExecutor.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.timer;
2 |
3 | import com.doctordark.hcf.HCF;
4 | import com.doctordark.hcf.timer.argument.TimerCheckArgument;
5 | import com.doctordark.hcf.timer.argument.TimerSetArgument;
6 | import com.doctordark.util.command.ArgumentExecutor;
7 |
8 | /**
9 | * Handles the execution and tab completion of the timer command.
10 | */
11 | public class TimerExecutor extends ArgumentExecutor {
12 |
13 | public TimerExecutor(HCF plugin) {
14 | super("timer");
15 |
16 | addArgument(new TimerCheckArgument(plugin));
17 | addArgument(new TimerSetArgument(plugin));
18 | }
19 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/timer/event/TimerClearEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.timer.event;
2 |
3 | import com.doctordark.hcf.timer.Timer;
4 | import org.bukkit.Bukkit;
5 | import org.bukkit.entity.Player;
6 | import org.bukkit.event.Event;
7 | import org.bukkit.event.HandlerList;
8 |
9 | import java.util.Objects;
10 | import java.util.Optional;
11 | import java.util.UUID;
12 |
13 | /**
14 | * Event called when a {@link Timer} is removed.
15 | */
16 | public class TimerClearEvent extends Event {
17 |
18 | private static final HandlerList handlers = new HandlerList();
19 |
20 | private Optional player;
21 | private final Optional userUUID;
22 | private final Timer timer;
23 |
24 | public TimerClearEvent(Timer timer) {
25 | this.userUUID = Optional.empty();
26 | this.timer = timer;
27 | }
28 |
29 | public TimerClearEvent(UUID userUUID, Timer timer) {
30 | this.userUUID = Optional.of(userUUID);
31 | this.timer = timer;
32 | }
33 |
34 | public TimerClearEvent(Player player, Timer timer) {
35 | Objects.requireNonNull(player);
36 |
37 | this.player = Optional.of(player);
38 | this.userUUID = Optional.of(player.getUniqueId());
39 | this.timer = timer;
40 | }
41 |
42 | public Optional getPlayer() {
43 | if (player == null) {
44 | player = userUUID.isPresent() ? Optional.of(Bukkit.getPlayer(userUUID.get())) : Optional.empty();
45 | }
46 |
47 | return player;
48 | }
49 |
50 | /**
51 | * Gets the optional UUID of the user this was removed for.
52 | * This may return absent if the timer is not of a player type
53 | *
54 | * @return the removed user UUID or {@link Optional#empty()}
55 | */
56 | public Optional getUserUUID() {
57 | return userUUID;
58 | }
59 |
60 | /**
61 | * Gets the {@link Timer} that was expired.
62 | *
63 | * @return the expiring timer
64 | */
65 | public Timer getTimer() {
66 | return timer;
67 | }
68 |
69 | public static HandlerList getHandlerList() {
70 | return handlers;
71 | }
72 |
73 | @Override
74 | public HandlerList getHandlers() {
75 | return handlers;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/timer/event/TimerExpireEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.timer.event;
2 |
3 | import com.doctordark.hcf.timer.Timer;
4 | import org.bukkit.Bukkit;
5 | import org.bukkit.entity.Player;
6 | import org.bukkit.event.Event;
7 | import org.bukkit.event.HandlerList;
8 |
9 | import java.util.Objects;
10 | import java.util.Optional;
11 | import java.util.UUID;
12 |
13 | /**
14 | * Event called when a {@link Timer} expires.
15 | */
16 | public class TimerExpireEvent extends Event {
17 |
18 | private static final HandlerList handlers = new HandlerList();
19 |
20 | private Optional player;
21 | private final Optional userUUID;
22 | private final Timer timer;
23 |
24 | public TimerExpireEvent(Timer timer) {
25 | this.userUUID = Optional.empty();
26 | this.timer = timer;
27 | }
28 |
29 | public TimerExpireEvent(UUID userUUID, Timer timer) {
30 | this.userUUID = Optional.ofNullable(userUUID);
31 | this.timer = timer;
32 | }
33 |
34 | public TimerExpireEvent(Player player, Timer timer) {
35 | Objects.requireNonNull(player);
36 |
37 | this.player = Optional.of(player);
38 | this.userUUID = Optional.of(player.getUniqueId());
39 | this.timer = timer;
40 | }
41 |
42 | public Optional getPlayer() {
43 | if (player == null) {
44 | player = userUUID.isPresent() ? Optional.of(Bukkit.getPlayer(userUUID.get())) : Optional.empty();
45 | }
46 |
47 | return player;
48 | }
49 |
50 | /**
51 | * Gets the optional UUID of the user this has expired for.
52 | * This may return absent if the timer is not of a player type
53 | *
54 | * @return the expiring user UUID or {@link Optional#empty()}
55 | */
56 | public Optional getUserUUID() {
57 | return userUUID;
58 | }
59 |
60 | /**
61 | * Gets the {@link Timer} that was expired.
62 | *
63 | * @return the expiring timer
64 | */
65 | public Timer getTimer() {
66 | return timer;
67 | }
68 |
69 | public static HandlerList getHandlerList() {
70 | return handlers;
71 | }
72 |
73 | @Override
74 | public HandlerList getHandlers() {
75 | return handlers;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/timer/event/TimerPauseEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.timer.event;
2 |
3 | import com.doctordark.hcf.timer.Timer;
4 | import org.bukkit.event.Cancellable;
5 | import org.bukkit.event.Event;
6 | import org.bukkit.event.HandlerList;
7 |
8 | import java.util.Optional;
9 | import java.util.UUID;
10 |
11 | /**
12 | * Event called when the pause state of a {@link Timer} changes.
13 | */
14 | public class TimerPauseEvent extends Event implements Cancellable {
15 |
16 | private static final HandlerList handlers = new HandlerList();
17 |
18 | private boolean cancelled;
19 | private final boolean paused;
20 | private final Optional userUUID;
21 | private final Timer timer;
22 |
23 | public TimerPauseEvent(Timer timer, boolean paused) {
24 | this.userUUID = Optional.empty();
25 | this.timer = timer;
26 | this.paused = paused;
27 | }
28 |
29 | public TimerPauseEvent(UUID userUUID, Timer timer, boolean paused) {
30 | this.userUUID = Optional.ofNullable(userUUID);
31 | this.timer = timer;
32 | this.paused = paused;
33 | }
34 |
35 | /**
36 | * Gets the optional UUID of the user this has expired for.
37 | * This may return absent if the timer is not of a player type
38 | *
39 | * @return the expiring user UUID or {@link Optional#empty()}
40 | */
41 | public Optional getUserUUID() {
42 | return userUUID;
43 | }
44 |
45 | /**
46 | * Gets the {@link Timer} that was expired.
47 | *
48 | * @return the expiring timer
49 | */
50 | public Timer getTimer() {
51 | return timer;
52 | }
53 |
54 | public static HandlerList getHandlerList() {
55 | return handlers;
56 | }
57 |
58 | public boolean isPaused() {
59 | return paused;
60 | }
61 |
62 | @Override
63 | public HandlerList getHandlers() {
64 | return handlers;
65 | }
66 |
67 | @Override
68 | public boolean isCancelled() {
69 | return cancelled;
70 | }
71 |
72 | @Override
73 | public void setCancelled(boolean cancelled) {
74 | this.cancelled = cancelled;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/timer/event/TimerStartEvent.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.timer.event;
2 |
3 | import com.doctordark.hcf.timer.Timer;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.Event;
6 | import org.bukkit.event.HandlerList;
7 |
8 | import javax.annotation.Nullable;
9 | import java.util.Optional;
10 | import java.util.UUID;
11 |
12 | /**
13 | * Event called when a {@link Timer} starts.
14 | */
15 | public class TimerStartEvent extends Event {
16 |
17 | private static final HandlerList handlers = new HandlerList();
18 |
19 | private final Optional player;
20 | private final Optional userUUID;
21 | private final Timer timer;
22 | private final long duration;
23 |
24 | public TimerStartEvent(Timer timer, final long duration) {
25 | this.player = Optional.empty();
26 | this.userUUID = Optional.empty();
27 | this.timer = timer;
28 | this.duration = duration;
29 | }
30 |
31 | public TimerStartEvent(@Nullable Player player, UUID uniqueId, Timer timer, long duration) {
32 | this.player = Optional.ofNullable(player);
33 | this.userUUID = Optional.ofNullable(uniqueId);
34 | this.timer = timer;
35 | this.duration = duration;
36 | }
37 |
38 | public Optional getPlayer() {
39 | return player;
40 | }
41 |
42 | /**
43 | * Gets the optional UUID of the user this has expired for.
44 | * This may return absent if the timer is not of a player type
45 | *
46 | * @return the expiring user UUID or {@link Optional#empty()}
47 | */
48 | public Optional getUserUUID() {
49 | return userUUID;
50 | }
51 |
52 | /**
53 | * Gets the {@link Timer} that was expired.
54 | *
55 | * @return the expiring timer
56 | */
57 | public Timer getTimer() {
58 | return timer;
59 | }
60 |
61 | public long getDuration() {
62 | return duration;
63 | }
64 |
65 | public static HandlerList getHandlerList() {
66 | return handlers;
67 | }
68 |
69 | @Override
70 | public HandlerList getHandlers() {
71 | return handlers;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/util/ConcurrentValueOrderedMap.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.util;
2 |
3 | import javax.annotation.Nonnull;
4 | import java.io.Serializable;
5 | import java.util.AbstractMap;
6 | import java.util.Collections;
7 | import java.util.Map;
8 | import java.util.Set;
9 | import java.util.concurrent.ConcurrentHashMap;
10 | import java.util.concurrent.ConcurrentMap;
11 | import java.util.concurrent.ConcurrentSkipListSet;
12 |
13 | public class ConcurrentValueOrderedMap> extends AbstractMap implements Map, Cloneable, Serializable {
14 |
15 | private final Set> ordering = new ConcurrentSkipListSet<>();
16 | private final ConcurrentMap> lookup = new ConcurrentHashMap<>();
17 |
18 | public V get(Object key) {
19 | InternalEntry old = lookup.get(key);
20 | return old != null ? old.getValue() : null;
21 | }
22 |
23 | public V put(K key, V val) {
24 | InternalEntry entry = new InternalEntry<>(key, val);
25 | InternalEntry old = lookup.put(key, entry);
26 | if (old == null) {
27 | ordering.add(entry);
28 | return null;
29 | }
30 |
31 | ordering.remove(old);
32 | ordering.add(entry);
33 | return old.getValue();
34 | }
35 |
36 | public V remove(Object key) {
37 | InternalEntry old = lookup.remove(key);
38 | if (old != null) {
39 | ordering.remove(old);
40 | return old.getValue();
41 | }
42 |
43 | return null;
44 | }
45 |
46 | public void clear() {
47 | ordering.clear();
48 | lookup.clear();
49 | }
50 |
51 | @Nonnull
52 | @Override
53 | public Set> entrySet() {
54 | return Collections.unmodifiableSet(ordering);
55 | }
56 |
57 | private static class InternalEntry> implements Comparable>, Map.Entry {
58 |
59 | private final K key;
60 | private final V value;
61 |
62 | InternalEntry(K key, V value) {
63 | this.key = key;
64 | this.value = value;
65 | }
66 |
67 | @Override
68 | public K getKey() {
69 | return key;
70 | }
71 |
72 | @Override
73 | public V getValue() {
74 | return value;
75 | }
76 |
77 | @Override
78 | public V setValue(V value) throws UnsupportedOperationException {
79 | throw new UnsupportedOperationException();
80 | }
81 |
82 | @Override
83 | public int compareTo(@Nonnull InternalEntry o) {
84 | return o.value.compareTo(value);
85 | }
86 | }
87 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/util/DelayedMessageRunnable.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.util;
2 |
3 | import org.bukkit.entity.Player;
4 | import org.bukkit.plugin.java.JavaPlugin;
5 | import org.bukkit.scheduler.BukkitRunnable;
6 |
7 | /**
8 | * Runnable used to message {@link Player}s with a delay, can be useful for the {@link org.bukkit.event.player.PlayerLoginEvent}
9 | * for example, where chat input is not received.
10 | */
11 | public class DelayedMessageRunnable extends BukkitRunnable {
12 |
13 | private final Player player;
14 | private final String message;
15 |
16 | public DelayedMessageRunnable(JavaPlugin plugin, Player player, String message) {
17 | this.player = player;
18 | this.message = message;
19 |
20 | runTask(plugin);
21 | }
22 |
23 | @Override
24 | public void run() {
25 | player.sendMessage(message);
26 | }
27 | }
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/util/DurationFormatter.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.util;
2 |
3 | import com.doctordark.hcf.DateTimeFormats;
4 | import org.apache.commons.lang3.time.DurationFormatUtils;
5 |
6 | import java.util.concurrent.TimeUnit;
7 |
8 | public class DurationFormatter {
9 |
10 | private static final long MINUTE = TimeUnit.MINUTES.toMillis(1L);
11 | private static final long HOUR = TimeUnit.HOURS.toMillis(1L);
12 |
13 | public static String getRemaining(long millis, boolean milliseconds) {
14 | return getRemaining(millis, milliseconds, true);
15 | }
16 |
17 | public static String getRemaining(long duration, boolean milliseconds, boolean trail) {
18 | if (milliseconds && duration < MINUTE) {
19 | return (trail ? DateTimeFormats.REMAINING_SECONDS_TRAILING : DateTimeFormats.REMAINING_SECONDS).get().format(duration * 0.001) + 's';
20 | } else {
21 | return DurationFormatUtils.formatDuration(duration, (duration >= HOUR ? "HH:" : "") + "mm:ss");
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/util/NameUtils.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.util;
2 |
3 | public final class NameUtils {
4 |
5 | private NameUtils() {
6 | }
7 |
8 | /**
9 | * Retrieves a more friendly looking name for a string, used mainly for
10 | * enums. Replaces underscores with spaces and ensures capitals are at the
11 | * start of every word.
12 | *
13 | * @param str the string to make better looking.
14 | * @return a pretty version of the passed string.
15 | */
16 | public static String getPrettyName(String str) {
17 | char[] chars = str.trim().toCharArray();
18 | for (int i = 0; i < chars.length; i++) {
19 | // First character must always be uppercase.
20 | if (i == 0) {
21 | chars[i] = Character.toUpperCase(chars[i]);
22 | }
23 |
24 | // Replace all underscores with spaces.
25 | else if (chars[i] == '_') {
26 | chars[i] = ' ';
27 | }
28 |
29 | // First character of a word must always be uppercase.
30 | else if (chars[i - 1] == ' ') {
31 | chars[i] = Character.toUpperCase(chars[i]);
32 | }
33 |
34 | // Other characters should be lowercase.
35 | else {
36 | chars[i] = Character.toLowerCase(chars[i]);
37 | }
38 | }
39 | return String.valueOf(chars);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/util/ReflectionUtils.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.util;
2 |
3 | import org.bukkit.OfflinePlayer;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.metadata.MetadataValue;
6 | import org.bukkit.plugin.Plugin;
7 |
8 | import java.lang.reflect.Field;
9 | import java.lang.reflect.InvocationTargetException;
10 | import java.lang.reflect.Method;
11 | import java.util.Map;
12 |
13 | public final class ReflectionUtils {
14 |
15 | private ReflectionUtils() {
16 | }
17 |
18 | public static MetadataValue getPlayerMetadata(Player subject, String metadataKey, Plugin owningPlugin) {
19 | try {
20 | Method getPlayerMetadata = owningPlugin.getServer().getClass().getDeclaredMethod("getPlayerMetadata");
21 | getPlayerMetadata.setAccessible(true);
22 | Object metadata = getPlayerMetadata.invoke(owningPlugin.getServer());
23 | Field metadataMapField = metadata.getClass().getSuperclass().getDeclaredField("metadataMap");
24 | metadataMapField.setAccessible(true);
25 | Map> metadataMap = (Map>) metadataMapField.get(metadata);
26 | Method disambiguate = metadata.getClass().getDeclaredMethod("disambiguate", OfflinePlayer.class, String.class);
27 | disambiguate.setAccessible(true);
28 | String key = (String) disambiguate.invoke(metadata, subject, metadataKey);
29 | Map values = metadataMap.get(key);
30 | return values == null ? null : values.get(owningPlugin);
31 | } catch (NoSuchFieldException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
32 | e.printStackTrace();
33 | }
34 | return null;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/util/SpigotUtils.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.util;
2 |
3 | public class SpigotUtils {
4 |
5 | public static net.md_5.bungee.api.ChatColor toBungee(org.bukkit.ChatColor color) {
6 | switch (color) {
7 | case BLACK:
8 | return net.md_5.bungee.api.ChatColor.BLACK;
9 | case DARK_BLUE:
10 | return net.md_5.bungee.api.ChatColor.DARK_BLUE;
11 | case DARK_GREEN:
12 | return net.md_5.bungee.api.ChatColor.DARK_GREEN;
13 | case DARK_AQUA:
14 | return net.md_5.bungee.api.ChatColor.DARK_AQUA;
15 | case DARK_RED:
16 | return net.md_5.bungee.api.ChatColor.DARK_RED;
17 | case DARK_PURPLE:
18 | return net.md_5.bungee.api.ChatColor.DARK_PURPLE;
19 | case GOLD:
20 | return net.md_5.bungee.api.ChatColor.GOLD;
21 | case GRAY:
22 | return net.md_5.bungee.api.ChatColor.GRAY;
23 | case DARK_GRAY:
24 | return net.md_5.bungee.api.ChatColor.DARK_GRAY;
25 | case BLUE:
26 | return net.md_5.bungee.api.ChatColor.BLUE;
27 | case GREEN:
28 | return net.md_5.bungee.api.ChatColor.GREEN;
29 | case AQUA:
30 | return net.md_5.bungee.api.ChatColor.AQUA;
31 | case RED:
32 | return net.md_5.bungee.api.ChatColor.RED;
33 | case LIGHT_PURPLE:
34 | return net.md_5.bungee.api.ChatColor.LIGHT_PURPLE;
35 | case YELLOW:
36 | return net.md_5.bungee.api.ChatColor.YELLOW;
37 | case WHITE:
38 | return net.md_5.bungee.api.ChatColor.WHITE;
39 | case MAGIC:
40 | return net.md_5.bungee.api.ChatColor.MAGIC;
41 | case BOLD:
42 | return net.md_5.bungee.api.ChatColor.BOLD;
43 | case STRIKETHROUGH:
44 | return net.md_5.bungee.api.ChatColor.STRIKETHROUGH;
45 | case UNDERLINE:
46 | return net.md_5.bungee.api.ChatColor.UNDERLINE;
47 | case ITALIC:
48 | return net.md_5.bungee.api.ChatColor.ITALIC;
49 | case RESET:
50 | return net.md_5.bungee.api.ChatColor.RESET;
51 | default:
52 | throw new IllegalArgumentException("Unrecognised Bukkit colour " + color.name() + ".");
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/visualise/BlockFiller.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.visualise;
2 |
3 | import com.google.common.collect.Iterables;
4 | import org.bukkit.Location;
5 | import org.bukkit.entity.Player;
6 |
7 | import java.util.ArrayList;
8 |
9 | /**
10 | * Represents how visual blocks are filled.
11 | */
12 | abstract class BlockFiller {
13 |
14 | abstract VisualBlockData generate(Player player, Location location);
15 |
16 | ArrayList bulkGenerate(Player player, Iterable locations) {
17 | ArrayList data = new ArrayList<>(Iterables.size(locations));
18 | for (Location location : locations) {
19 | data.add(generate(player, location));
20 | }
21 |
22 | return data;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/visualise/VisualBlock.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.visualise;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import org.bukkit.Location;
6 |
7 | @Data
8 | @AllArgsConstructor
9 | public class VisualBlock {
10 |
11 | private final VisualType visualType;
12 | private final VisualBlockData blockData;
13 | private final Location location;
14 | }
15 |
--------------------------------------------------------------------------------
/core/src/main/java/com/doctordark/hcf/visualise/VisualBlockData.java:
--------------------------------------------------------------------------------
1 | package com.doctordark.hcf.visualise;
2 |
3 | import org.bukkit.Material;
4 | import org.bukkit.inventory.ItemStack;
5 | import org.bukkit.material.MaterialData;
6 |
7 | public class VisualBlockData extends MaterialData {
8 |
9 | public VisualBlockData(Material type) {
10 | super(type);
11 | }
12 |
13 | public VisualBlockData(Material type, byte data) {
14 | super(type, data);
15 | }
16 |
17 | public Material getBlockType() {
18 | return getItemType();
19 | }
20 |
21 | /**
22 | * @deprecated is a block not an item, internal use only
23 | */
24 | @Override
25 | @Deprecated
26 | public Material getItemType() {
27 | return super.getItemType();
28 | }
29 |
30 | @Override
31 | @Deprecated
32 | public ItemStack toItemStack() {
33 | throw new UnsupportedOperationException("This is a VisualBlock data");
34 | }
35 |
36 | @Override
37 | @Deprecated
38 | public ItemStack toItemStack(int amount) {
39 | throw new UnsupportedOperationException("This is a VisualBlock data");
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/core/src/main/resources/balances.yml:
--------------------------------------------------------------------------------
1 | balances: {}
2 |
--------------------------------------------------------------------------------
/core/src/main/resources/eventSchedules.txt:
--------------------------------------------------------------------------------
1 | # year, month, day, hour, minute: eventName (24 hour clock)
2 | # 2015,1,1,2,0:Example This would run event named 'Example' at 2AM on the 1st of January, 2015.
3 |
--------------------------------------------------------------------------------
/core/src/main/resources/faction-users.yml:
--------------------------------------------------------------------------------
1 | users: {}
2 |
--------------------------------------------------------------------------------
/core/src/main/resources/factions.yml:
--------------------------------------------------------------------------------
1 | factions: {}
2 |
--------------------------------------------------------------------------------
/core/src/main/resources/imageMessages/gapple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IPVP-MC/iHCF/0baca0036d020c961db7785b3d0b859b1138880d/core/src/main/resources/imageMessages/gapple.png
--------------------------------------------------------------------------------
/core/src/main/resources/lives.yml:
--------------------------------------------------------------------------------
1 | lives: {}
2 |
--------------------------------------------------------------------------------
/core/src/main/resources/timers.yml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IPVP-MC/iHCF/0baca0036d020c961db7785b3d0b859b1138880d/core/src/main/resources/timers.yml
--------------------------------------------------------------------------------
/extra/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.doctordark
9 | ihcf-parent
10 | 1.0.0-SNAPSHOT
11 |
12 |
13 | iHCFExtra
14 | Extra utilities to add onto iHCF
15 | ihcf-extra
16 |
17 |
18 | UTF-8
19 | UTF-8
20 |
21 |
22 |
23 | ${basedir}/src/main/java/
24 | ${project.name}
25 |
26 |
27 |
28 |
29 | com.doctordark
30 | ihcf-core
31 | 1.0.0-SNAPSHOT
32 | provided
33 |
34 |
35 |
--------------------------------------------------------------------------------
/extra/src/main/java/org/ipvp/hcfextra/Configuration.java:
--------------------------------------------------------------------------------
1 | package org.ipvp.hcfextra;
2 |
3 | import com.google.common.collect.Iterables;
4 | import lombok.Getter;
5 | import net.minecraft.util.org.apache.commons.io.FileUtils;
6 | import org.bukkit.ChatColor;
7 | import org.bukkit.plugin.java.JavaPlugin;
8 |
9 | import java.io.File;
10 | import java.io.IOException;
11 | import java.util.logging.Level;
12 |
13 | public class Configuration {
14 |
15 | @Getter
16 | private String[] coordsMessage;
17 |
18 | @Getter
19 | private String[] helpMessage;
20 |
21 | private final JavaPlugin plugin;
22 |
23 | public Configuration(JavaPlugin plugin) {
24 | this.plugin = plugin;
25 | }
26 |
27 | public void reload() {
28 | File folder = plugin.getDataFolder();
29 | if (!folder.exists()) {
30 | this.quietlyCreateFile(folder);
31 | }
32 |
33 | try {
34 | this.coordsMessage = this.convertLines(new File(folder, "coords.txt"));
35 | this.helpMessage = this.convertLines(new File(folder, "help.txt"));
36 | } catch (IOException ex) {
37 | ex.printStackTrace();
38 | }
39 | }
40 |
41 | private String[] convertLines(File file) throws IOException {
42 | if (!file.exists()) {
43 | this.quietlyCreateFile(file);
44 | return new String[]{};
45 | }
46 |
47 | plugin.getLogger().log(Level.INFO, "Reading lines of file " + file.getName() + ".");
48 |
49 | String[] lines = Iterables.toArray(FileUtils.readLines(file), String.class);
50 | int count = 0;
51 | for (String line : lines) {
52 | lines[count++] = ChatColor.translateAlternateColorCodes('&', line);
53 | }
54 |
55 | return lines;
56 | }
57 |
58 | private void quietlyCreateFile(File file) {
59 | try {
60 | HCFExtra.getPlugin().getLogger().log(Level.INFO, (file.createNewFile() ? "Created" : "Failed to create") + " file " + file.getName() + ".");
61 | } catch (IOException ex) {
62 | ex.printStackTrace();
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/extra/src/main/java/org/ipvp/hcfextra/HCFExtra.java:
--------------------------------------------------------------------------------
1 | package org.ipvp.hcfextra;
2 |
3 | import lombok.Getter;
4 | import org.bukkit.command.PluginCommand;
5 | import org.bukkit.plugin.java.JavaPlugin;
6 | import org.ipvp.hcfextra.command.CoordsCommand;
7 | import org.ipvp.hcfextra.command.EndportalHandler;
8 | import org.ipvp.hcfextra.command.HCFExtraCommand;
9 | import org.ipvp.hcfextra.command.HelpCommand;
10 | import org.ipvp.hcfextra.inventoryrestore.InventoryRestoreHandler;
11 |
12 | public class HCFExtra extends JavaPlugin {
13 |
14 | @Getter
15 | private static HCFExtra plugin;
16 |
17 | @Getter
18 | private Configuration configuration;
19 |
20 | @Override
21 | public void onEnable() {
22 | HCFExtra.plugin = this;
23 | PluginCommand temp;
24 |
25 | (this.configuration = new Configuration(this)).reload();
26 |
27 | InventoryRestoreHandler inventoryRestoreHandler = new InventoryRestoreHandler();
28 | this.getServer().getPluginManager().registerEvents(inventoryRestoreHandler, this);
29 | (temp = this.getCommand("inv")).setExecutor(inventoryRestoreHandler);
30 | temp.setPermission("ihcfextra.command.inv");
31 |
32 | EndportalHandler endportalHandler = new EndportalHandler();
33 | this.getServer().getPluginManager().registerEvents(endportalHandler, this);
34 | (temp = this.getCommand("endportal")).setExecutor(endportalHandler);
35 | temp.setPermission("ihcfextra.command.endportal");
36 |
37 | (temp = this.getCommand("hcfextra")).setExecutor(new HCFExtraCommand(this));
38 | temp.setPermission("ihcfextra.command.hcfextra");
39 |
40 | this.getCommand("coords").setExecutor(new CoordsCommand(this));
41 | this.getCommand("help").setExecutor(new HelpCommand(this));
42 | }
43 |
44 | @Override
45 | public void onDisable() {
46 | HCFExtra.plugin = null;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/extra/src/main/java/org/ipvp/hcfextra/command/CoordsCommand.java:
--------------------------------------------------------------------------------
1 | package org.ipvp.hcfextra.command;
2 |
3 | import org.bukkit.command.Command;
4 | import org.bukkit.command.CommandExecutor;
5 | import org.bukkit.command.CommandSender;
6 | import org.bukkit.command.TabCompleter;
7 | import org.ipvp.hcfextra.HCFExtra;
8 |
9 | import java.util.Collections;
10 | import java.util.List;
11 |
12 | public class CoordsCommand implements CommandExecutor, TabCompleter {
13 |
14 | private final HCFExtra plugin;
15 |
16 | public CoordsCommand(HCFExtra plugin) {
17 | this.plugin = plugin;
18 | }
19 |
20 | @Override
21 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
22 | sender.sendMessage(plugin.getConfiguration().getCoordsMessage());
23 | return true;
24 | }
25 |
26 | @Override
27 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
28 | return Collections.emptyList();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/extra/src/main/java/org/ipvp/hcfextra/command/HCFExtraCommand.java:
--------------------------------------------------------------------------------
1 | package org.ipvp.hcfextra.command;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import org.bukkit.ChatColor;
5 | import org.bukkit.command.Command;
6 | import org.bukkit.command.CommandExecutor;
7 | import org.bukkit.command.CommandSender;
8 | import org.bukkit.command.TabCompleter;
9 | import org.ipvp.hcfextra.HCFExtra;
10 |
11 | import java.util.Collections;
12 | import java.util.List;
13 |
14 | public class HCFExtraCommand implements CommandExecutor, TabCompleter {
15 |
16 | private static final List COMPLETIONS_FIRST = ImmutableList.of("reload");
17 |
18 | private final HCFExtra plugin;
19 |
20 | public HCFExtraCommand(HCFExtra plugin) {
21 | this.plugin = plugin;
22 | }
23 |
24 | @Override
25 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
26 | if (args.length > 0) {
27 | if (args[0].equalsIgnoreCase("reload")) {
28 | plugin.getConfiguration().reload();
29 | sender.sendMessage(ChatColor.RED + "Reloaded " + ChatColor.YELLOW + plugin.getDescription().getFullName() + ChatColor.RED + ".");
30 | return true;
31 | }
32 | }
33 |
34 | sender.sendMessage(ChatColor.RED + "Usage: /" + label + " ");
35 | return true;
36 | }
37 |
38 | @Override
39 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
40 | return args.length == 1 ? COMPLETIONS_FIRST : Collections.emptyList();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/extra/src/main/java/org/ipvp/hcfextra/command/HelpCommand.java:
--------------------------------------------------------------------------------
1 | package org.ipvp.hcfextra.command;
2 |
3 | import org.bukkit.command.Command;
4 | import org.bukkit.command.CommandExecutor;
5 | import org.bukkit.command.CommandSender;
6 | import org.bukkit.command.TabCompleter;
7 | import org.ipvp.hcfextra.HCFExtra;
8 |
9 | import java.util.Collections;
10 | import java.util.List;
11 |
12 | public class HelpCommand implements CommandExecutor, TabCompleter {
13 |
14 | private final HCFExtra plugin;
15 |
16 | public HelpCommand(HCFExtra plugin) {
17 | this.plugin = plugin;
18 | }
19 |
20 | @Override
21 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
22 | sender.sendMessage(plugin.getConfiguration().getHelpMessage());
23 | return true;
24 | }
25 |
26 | @Override
27 | public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
28 | return Collections.emptyList();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/extra/src/main/resources/coords.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IPVP-MC/iHCF/0baca0036d020c961db7785b3d0b859b1138880d/extra/src/main/resources/coords.txt
--------------------------------------------------------------------------------
/extra/src/main/resources/help.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IPVP-MC/iHCF/0baca0036d020c961db7785b3d0b859b1138880d/extra/src/main/resources/help.txt
--------------------------------------------------------------------------------
/extra/src/main/resources/plugin.yml:
--------------------------------------------------------------------------------
1 | name: ${project.name}
2 | version: ${project.version} (Build ${git.commit.id.abbrev}, ${git.commit.time})
3 | description: ${project.description}
4 | author: DoctorDark
5 | main: org.ipvp.hcfextra.HCFExtra
6 | license: MIT
7 | commands:
8 | coords:
9 | description: Shows co-ordinates for events.
10 | endportal:
11 | description: Lights up end-portals properly.
12 | inv:
13 | aliases: [invrestore, restoreinv]
14 | description: Restore player inventories from last death.
15 | help:
16 | aliases: ["?"]
17 | description: Find out more about this server.
18 | hcfextra:
19 | description: Manage this plugin.
--------------------------------------------------------------------------------