├── .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() + "