From 828daaffa6cd4382d14677bd6ef6328cec6bf16d Mon Sep 17 00:00:00 2001 From: Zrips Date: Tue, 31 Jan 2023 16:38:04 +0200 Subject: [PATCH] API update with maven support --- .classpath | 23 +- .gitignore | 1 + .project | 6 + .settings/org.eclipse.jdt.core.prefs | 8 + .settings/org.eclipse.m2e.core.prefs | 4 + pom.xml | 105 ++ .../CMI/AllListeners/ArmorChangeListener.java | 49 +- .../AllListeners/ArmorChangeListener1_9.java | 7 + .../AllListeners/BossBarCompassListener.java | 27 +- .../AllListeners/CustomMessagesListener.java | 37 +- .../CMI/AllListeners/FirstJoinListener.java | 12 + .../CMI/AllListeners/FlyListener1_17.java | 58 - .../CMI/AllListeners/GlicthListeners.java | 13 + .../CMI/AllListeners/LaunchPadListener.java | 18 +- .../AllListeners/LaunchPadListener1_9.java | 6 + .../CMI/AllListeners/NoTargetListener.java | 14 +- .../PlayerItemDamageListener.java | 10 + .../CMI/AllListeners/PlayerListeners.java | 324 +++- .../CMI/AllListeners/PlayerListeners1_8.java | 10 +- .../Zrips/CMI/AllListeners/PreviousName.java | 6 + .../Zrips/CMI/AllListeners/ProtocolEvent.java | 1 + .../CMI/AllListeners/UserCuffedEvents.java | 69 +- .../Zrips/CMI/AllListeners/UserEvents.java | 83 +- .../Zrips/CMI/AllListeners/WorldLimits.java | 56 +- .../CMI/AllListeners/WorldLimitsElytra.java | 20 +- .../Zrips/CMI/AllListeners/versionCheck.java | 10 + src/com/Zrips/CMI/CMI.java | 444 +++-- src/com/Zrips/CMI/Config.java | 440 +++-- src/com/Zrips/CMI/Containers/CMIBanEntry.java | 62 +- src/com/Zrips/CMI/Containers/CMIBlock.java | 161 -- .../Zrips/CMI/Containers/CMICollision.java | 26 +- .../Zrips/CMI/Containers/CMIDamageCause.java | 21 +- .../Zrips/CMI/Containers/CMIDirection.java | 54 +- .../CMI/Containers/CMIEquipmentSlot.java | 23 +- src/com/Zrips/CMI/Containers/CMIEvent.java | 16 +- src/com/Zrips/CMI/Containers/CMIHitBox.java | 134 +- .../Zrips/CMI/Containers/CMIInteractType.java | 13 +- .../Zrips/CMI/Containers/CMIItemRepair.java | 45 +- src/com/Zrips/CMI/Containers/CMILwc.java | 9 + src/com/Zrips/CMI/Containers/CMINumber.java | 14 + .../CMI/Containers/CMIPlayerInventory.java | 134 +- src/com/Zrips/CMI/Containers/CMIRay.java | 2 +- src/com/Zrips/CMI/Containers/CMIRayTrace.java | 2 - src/com/Zrips/CMI/Containers/CMISpawner.java | 183 +- src/com/Zrips/CMI/Containers/CMISunMover.java | 22 + .../Zrips/CMI/Containers/CMITabComplete.java | 50 +- .../Zrips/CMI/Containers/CMITextCleaner.java | 20 + src/com/Zrips/CMI/Containers/CMITreeType.java | 19 +- src/com/Zrips/CMI/Containers/CMIUser.java | 1496 +++++++++-------- src/com/Zrips/CMI/Containers/CMIVanish.java | 47 +- .../Zrips/CMI/Containers/CommandAlias.java | 184 +- src/com/Zrips/CMI/Containers/CommandReg.java | 82 +- src/com/Zrips/CMI/Containers/PlayerMail.java | 16 +- .../Zrips/CMI/Containers/RandomTeleport.java | 105 +- src/com/Zrips/CMI/Containers/SleepStats.java | 14 +- src/com/Zrips/CMI/Containers/Snd.java | 90 +- src/com/Zrips/CMI/Containers/Speed.java | 88 +- .../Zrips/CMI/Containers/worldFlyState.java | 30 + .../CMI/CustomEventTrigers/AnvilLstener.java | 14 +- src/com/Zrips/CMI/Locale/CMILC.java | 257 +++ src/com/Zrips/CMI/Locale/Language.java | 92 +- .../CMI/Modules/AStand/ArmorStandCopy.java | 2 - .../Modules/AStand/ArmorStandListener.java | 21 +- .../Modules/AStand/ArmorStandListener1_8.java | 32 + .../CMI/Modules/AStand/ArmorStandManager.java | 240 ++- .../CMI/Modules/AStand/ArmorStandSave.java | 107 ++ .../Advancements/AdvancementManager.java | 89 +- .../Modules/Advancements/CMIAdvancement.java | 231 +-- src/com/Zrips/CMI/Modules/Afk/AfkInfo.java | 40 +- .../Zrips/CMI/Modules/Afk/AfkListener.java | 197 ++- .../Zrips/CMI/Modules/Afk/AfkListener1_8.java | 9 +- src/com/Zrips/CMI/Modules/Afk/AfkManager.java | 122 +- src/com/Zrips/CMI/Modules/Afk/checkInfo.java | 2 +- .../Zrips/CMI/Modules/Alias/AliasManager.java | 105 +- .../AliasTabCompListener_1_13_older.java | 3 - .../AliasTabCompListener_1_14_never.java | 2 +- .../Modules/Alias/onPreprocessCommand.java | 17 + .../Alias/onServerPreprocessCommand.java | 13 + .../AnimationColoredArmorListener.java | 9 +- .../Modules/Animations/AnimationListener.java | 15 + .../Modules/Animations/AnimationManager.java | 278 +-- .../Animations/AnimationRideListener.java | 10 +- .../Animations/AnimationSitListener.java | 48 + .../Anvil/AnvilColorRenameListener.java | 22 +- .../Zrips/CMI/Modules/Anvil/AnvilManager.java | 8 +- .../Modules/Anvil/AnvilUnlimitedListener.java | 4 +- .../Zrips/CMI/Modules/Anvil/CMIAnvilGUI.java | 172 +- .../ArmorEffects/ArmorEffectListener.java | 33 + .../ArmorEffects/ArmorEffectManager.java | 59 + .../AttachedCommands/CustomNBTListener.java | 36 +- .../CustomNBTListener1_8.java | 9 +- .../AttachedCommands/CustomNBTManager.java | 26 +- .../BungeeCord/BungeeCordListener.java | 47 +- .../Modules/BungeeCord/BungeeCordManager.java | 131 +- .../Modules/BungeeCord/BungeeCordServer.java | 79 +- .../CMI/Modules/BungeeCord/BungeePlayer.java | 19 + .../CMI/Modules/BungeeCord/CMIBungeeCord.java | 240 ++- .../Modules/BungeeCord/ServerListPing.java | 252 +-- .../ChatFilter/ChatFilterListener.java | 32 +- .../Modules/ChatFilter/ChatFilterManager.java | 70 +- .../Modules/ChatFilter/ChatFilterRule.java | 4 +- .../CMI/Modules/ChatFilter/MessageLog.java | 11 +- .../CMI/Modules/ChatFilter/RuleResponce.java | 43 +- .../CMI/Modules/ChatFormat/CMIChatRoom.java | 98 +- .../Modules/ChatFormat/ChatColorListener.java | 10 +- .../ChatFormat/ChatFormatListener.java | 29 +- .../Modules/ChatFormat/ChatFormatManager.java | 177 +- .../CMI/Modules/ChatTag/TagListener.java | 15 +- .../Zrips/CMI/Modules/ChatTag/TagManager.java | 18 +- .../Modules/ChunkPreview/ChunkPreview.java | 13 +- .../Modules/CmdCooldown/CooldownListener.java | 15 +- .../Modules/CmdCooldown/CooldownManager.java | 44 +- .../CMI/Modules/CmdCost/CMICommandCost.java | 4 +- .../CmdCost/CMICommandCostManager.java | 35 +- .../CMI/Modules/CmdWarmUp/CmdWarmUp.java | 41 +- .../CMI/Modules/CmdWarmUp/WarmUpListener.java | 24 +- .../CMI/Modules/CmdWarmUp/WarmUpManager.java | 44 +- .../Zrips/CMI/Modules/CustomText/CText.java | 58 +- .../CustomText/CTextEditorListener.java | 16 +- .../CMI/Modules/CustomText/CTextManager.java | 95 +- .../Modules/DataBase/DBConnectionPool.java | 8 +- src/com/Zrips/CMI/Modules/DataBase/DBDAO.java | 674 ++++---- .../Zrips/CMI/Modules/DataBase/DBManager.java | 160 +- .../Zrips/CMI/Modules/DataBase/DBMySQL.java | 110 +- .../Zrips/CMI/Modules/DataBase/DBSQLite.java | 43 +- .../DeathMessages/CMIDeathMsgInfo.java | 75 + .../Modules/DeathMessages/CMIDeathType.java | 4 +- .../Modules/DeathMessages/CMIKillerInfo.java | 70 + .../DeathMessages/DeathMessageListener.java | 41 +- .../DeathMessages/DeathMessageManager.java | 94 +- .../Modules/DiscordSRV/DiscordSRVManager.java | 10 +- .../CMI/Modules/DynMap/DynMapListener.java | 19 +- .../CMI/Modules/DynMap/DynMapManager.java | 7 +- .../CMI/Modules/DynamicSigns/CMISign.java | 101 +- .../Modules/DynamicSigns/SignListener.java | 34 +- .../CMI/Modules/DynamicSigns/SignManager.java | 132 +- .../CMI/Modules/Economy/CMIEconomyAcount.java | 105 +- .../Zrips/CMI/Modules/Economy/Economy.java | 205 +-- .../CMI/Modules/Economy/EconomyManager.java | 545 +++--- .../CMI/Modules/Economy/VaultHandler.java | 245 ++- .../CMI/Modules/Economy/VaultManager.java | 30 +- .../Modules/Elytra/ElytraBoostListener.java | 70 +- .../Modules/Elytra/ElytraExploitListener.java | 15 +- .../Modules/Elytra/ElytraLaunchListener.java | 62 +- .../CMI/Modules/Enchants/EnchantListener.java | 20 +- .../CMI/Modules/Enchants/EnchantManager.java | 55 +- .../EventActions/EventActionListener.java | 108 +- .../EventActions/EventActionListener19.java | 10 + .../EventActions/EventActionManager.java | 9 +- .../Modules/FindBiome/FindBiomeManager.java | 7 +- .../Modules/FlightCharge/FlightCharge.java | 31 +- .../FlightCharge/FlightChargeManager.java | 57 +- .../Modules/FlightCharge/FlightListener.java | 67 +- .../FlightCharge/traveledDistance.java | 16 +- .../CMI/Modules/GeoIP/LookupService.java | 198 +-- .../CMI/Modules/Holograms/CMIDataWatcher.java | 46 +- .../Zrips/CMI/Modules/Holograms/CMIFont.java | 138 ++ .../CMI/Modules/Holograms/CMIHologram.java | 544 ++++-- .../Holograms/CMIHologramClickEvent.java | 69 + .../Modules/Holograms/CMIHologramLine.java | 108 +- .../Modules/Holograms/CMIHologramPage.java | 41 +- .../Modules/Holograms/HologramListener.java | 55 +- .../Modules/Holograms/HologramManager.java | 171 +- src/com/Zrips/CMI/Modules/Homes/CmiHome.java | 54 +- .../Zrips/CMI/Modules/Homes/HomeListener.java | 15 +- .../Zrips/CMI/Modules/Homes/HomeManager.java | 195 ++- .../CMI/Modules/Homes/HomeWorldLimit.java | 29 + .../CMI/Modules/HpBar/HpBarListener.java | 15 +- .../CMIInteractiveCommand.java | 185 +- .../Modules/InteractiveCommand/CMINPC.java | 28 +- .../InteractiveCommand/CitizensManager.java | 20 +- .../InteractiveCommandListener.java | 35 +- .../InteractiveCommandListener1_8.java | 9 +- .../InteractiveCommandManager.java | 57 +- .../InvEndEditor/EnderChestListener.java | 33 +- .../InvEndEditor/EnderChestManager.java | 20 +- .../CMI/Modules/InvRegEditor/CMIInvSee.java | 80 + .../InvRegEditor/RegChestListener.java | 27 +- .../InvRegEditor/RegChestListener19.java | 14 - .../Modules/InvRegEditor/RegChestManager.java | 107 +- .../CMI/Modules/InvRegEditor/RegWatcher.java | 59 - src/com/Zrips/CMI/Modules/Ips/IpManager.java | 10 +- src/com/Zrips/CMI/Modules/Jail/CMIJail.java | 70 +- .../Zrips/CMI/Modules/Jail/CMIJailCell.java | 33 +- .../Zrips/CMI/Modules/Jail/JailListener.java | 84 +- .../Zrips/CMI/Modules/Jail/JailManager.java | 175 +- src/com/Zrips/CMI/Modules/Kits/Clickery.java | 2 +- src/com/Zrips/CMI/Modules/Kits/Kit.java | 227 +-- .../Zrips/CMI/Modules/Kits/KitListener.java | 8 +- .../Zrips/CMI/Modules/Kits/KitsManager.java | 320 ++-- .../Zrips/CMI/Modules/LightFix/LightFix.java | 17 +- .../CMI/Modules/Mirror/MirrorListener.java | 11 +- .../CMI/Modules/Mirror/MirrorManager.java | 360 ++-- .../CMI/Modules/ModuleHandling/CMIModule.java | 35 +- .../ModuleHandling/CMIModuleManager.java | 13 - .../MoneyCheque/MoneyChequeListener.java | 24 +- .../Modules/NickName/NickNameListener.java | 30 +- .../CMI/Modules/NickName/NickNameManager.java | 9 +- .../Zrips/CMI/Modules/Packets/FakeInfo.java | 9 + .../CMI/Modules/Packets/PacketHandler.java | 52 - .../CMI/Modules/Packets/PacketInjector.java | 48 - .../Packets/PacketPlayerListeners.java | 14 +- .../Modules/Painting/PaintingListener.java | 39 +- .../CMI/Modules/Painting/PaintingManager.java | 13 +- .../CMI/Modules/Particl/CMIPEAnimation.java | 53 +- .../Particl/CMIPEAnimationInterface.java | 9 +- .../CMI/Modules/Particl/CMIPECircle.java | 127 +- .../CMI/Modules/Particl/CMIPEFireWork.java | 39 +- .../CMI/Modules/Particl/CMIVisualEffect.java | 115 +- .../CMI/Modules/Particl/ParticleManager.java | 282 ++-- .../CMI/Modules/Patrol/PatrolManager.java | 15 +- .../Permissions/BPermissionsHandler.java | 43 + .../Permissions/GroupManagerXHandler.java | 48 + .../Permissions/LuckPermsHandler4.java | 47 + .../Permissions/LuckPermsHandler5.java | 47 + .../CMI/Modules/Permissions/PEXHandler.java | 47 + .../Permissions/PermissionsManager.java | 1021 ++++++----- .../Permissions/PowerfullPermsHandler.java | 47 + .../PowerfullPermsgustav9797Handler.java | 47 + .../Permissions/UltraPermissions3Handler.java | 51 + .../CMI/Modules/Permissions/VaultHandler.java | 35 +- .../Permissions/ZPermissionsHandler.java | 48 + .../Placeholders/MVdWPlaceholderAPIHook.java | 13 + .../CMI/Modules/Placeholders/Placeholder.java | 646 +++---- .../Placeholders/PlaceholderCache.java | 22 + .../CMI/Modules/PlayTime/CMIPlayDay.java | 35 +- .../CMI/Modules/PlayTime/CMIPlayTime.java | 33 +- .../Modules/PlayTime/CMIPlayTimeFormat.java | 27 + .../Modules/PlayTime/PlayTimeListener.java | 13 +- .../CMI/Modules/PlayTime/PlayTimeManager.java | 218 ++- .../PlayTimeRewards/PlayTimeReward.java | 4 - .../PlayTimeRewardsListener.java | 2 +- .../PlayTimeRewardsManager.java | 49 +- .../Modules/PlayerCombat/CMIPlayerCombat.java | 30 +- .../Modules/PlayerCombat/EntityHeadDrop.java | 47 +- .../PlayerCombat/HeadDropListener.java | 43 +- .../PlayerCombat/PlayerCombatListener.java | 71 +- .../PlayerCombat/PlayerCombatManager.java | 142 +- .../CMI/Modules/PlayerMeta/PlayerMeta.java | 48 +- .../Modules/PlayerOptions/PlayerOption.java | 110 ++ .../PlayerOptions/PlayerOptionsManager.java | 36 + .../Modules/Portals/CMIPlaneIntersection.java | 44 +- .../Zrips/CMI/Modules/Portals/CMIPortal.java | 176 +- .../CMI/Modules/Portals/CMIVector3D.java | 17 +- .../Zrips/CMI/Modules/Portals/CuboidArea.java | 491 ++---- .../CMI/Modules/Portals/PortalListener.java | 56 +- .../CMI/Modules/Portals/PortalManager.java | 149 +- .../CMI/Modules/Ranks/AureliumManager.java | 33 + src/com/Zrips/CMI/Modules/Ranks/CMIRank.java | 172 +- .../Zrips/CMI/Modules/Ranks/JobsManager.java | 6 +- .../Zrips/CMI/Modules/Ranks/McMMOManager.java | 6 +- .../Zrips/CMI/Modules/Ranks/RankManager.java | 187 ++- .../Zrips/CMI/Modules/Recipes/CMIRecipe.java | 63 - .../CMI/Modules/Recipes/FurnaceTempData.java | 37 - .../CMI/Modules/Recipes/RecipeListener.java | 14 - .../CMI/Modules/Recipes/RecipeManager.java | 159 +- .../Modules/Recipes/recipeInformation.java | 35 + .../CMI/Modules/Region/RegionListener.java | 2 +- .../Zrips/CMI/Modules/Region/WorldInfo.java | 90 +- .../CMI/Modules/Region/WorldManager.java | 69 +- .../CMI/Modules/Repair/RepairListener.java | 28 +- .../CMI/Modules/ReplaceBlock/BRInfo.java | 80 +- .../Modules/ReplaceBlock/ReplaceBlock.java | 8 +- .../CMI/Modules/SavedInv/SaveInvListener.java | 27 +- .../SavedInv/SavedInventoryManager.java | 92 +- .../Modules/SavedItems/SavedItemManager.java | 57 +- src/com/Zrips/CMI/Modules/Scan/Scan.java | 47 +- src/com/Zrips/CMI/Modules/Scan/ScanInfo.java | 96 +- .../Modules/Scavenger/CMIScavengeItem.java | 89 +- .../Modules/Scavenger/ScavengeManager.java | 28 +- src/com/Zrips/CMI/Modules/Search/Search.java | 96 +- .../Zrips/CMI/Modules/Search/SearchInfo.java | 155 +- .../Modules/Selection/SelectionListener.java | 17 +- .../Modules/Selection/SelectionManager.java | 121 +- .../CMI/Modules/Selection/Visualizer.java | 99 +- .../Zrips/CMI/Modules/Sheduler/SchedTime.java | 49 +- .../Zrips/CMI/Modules/Sheduler/Schedule.java | 128 +- .../Modules/Sheduler/SchedulerManager.java | 101 +- .../ShulkerBoxListener.java | 49 +- .../ShulkerBoxManager.java | 38 +- .../SilentChest/silentChestListener.java | 50 +- .../Zrips/CMI/Modules/Skin/SkinListener.java | 9 +- .../Zrips/CMI/Modules/Skin/SkinManager.java | 35 +- .../Modules/SpawnerCharge/PlayerCharge.java | 83 +- .../SpawnerCharge/SpawnerActionsListener.java | 47 +- .../SpawnerCharge/SpawnerChargeListener.java | 41 +- .../SpawnerCharge/SpawnerChargeManager.java | 38 +- .../SpawnerProximityListener.java | 13 +- .../SpecializedCommandManager.java | 550 +++--- .../SpecializedCommands/specCommand.java | 43 + .../CMI/Modules/Statistics/CMIStats.java | 47 +- .../CMI/Modules/Statistics/StatsManager.java | 451 ++--- .../Modules/TabList/CMITabSortingType.java | 15 +- .../Zrips/CMI/Modules/TabList/TabList.java | 33 +- .../TabList/TabListHeaderFooterHandler.java | 21 +- .../CMI/Modules/TabList/TabListListener.java | 37 +- .../CMI/Modules/TabList/TabListManager.java | 52 +- .../TimedCommands/TimedCommandListener.java | 29 +- .../TimedCommands/TimedCommandManager.java | 39 +- .../Modules/Totems/ResurectionListener.java | 56 +- .../CMI/Modules/Totems/TotemManager.java | 135 +- .../CMI/Modules/Vanish/VanishListener.java | 86 +- .../CMI/Modules/Vanish/VanishManager.java | 83 +- .../CMI/Modules/ViewRange/ChunkChange.java | 7 +- .../CMI/Modules/ViewRange/ViewRangeInfo.java | 12 + .../Modules/ViewRange/ViewRangeListener.java | 16 +- .../Modules/ViewRange/ViewRangeManager.java | 21 +- .../Modules/Votifier/VotifierListener.java | 21 - .../CMI/Modules/Votifier/VotifierManager.java | 65 +- .../CMI/Modules/Warnings/WarningManager.java | 24 +- src/com/Zrips/CMI/Modules/Warps/CmiWarp.java | 130 +- .../Zrips/CMI/Modules/Warps/WarpManager.java | 178 +- .../Zrips/CMI/Modules/Worlds/CMIChunk.java | 71 +- .../Zrips/CMI/Modules/Worlds/CMIRegion.java | 5 - .../Zrips/CMI/Modules/Worlds/CMIWorld.java | 38 +- .../CMI/Modules/Worlds/CMIWorldListener.java | 10 +- .../CMI/Modules/Worth/WorthEnchantment.java | 34 +- .../Zrips/CMI/Modules/Worth/WorthItem.java | 94 +- .../CMI/Modules/Worth/WorthItemCheck.java | 30 +- .../CMI/Modules/Worth/WorthListener.java | 32 +- .../Zrips/CMI/Modules/Worth/WorthManager.java | 130 +- .../Zrips/CMI/Modules/tp/SafeTeleport.java | 53 +- .../Zrips/CMI/Modules/tp/Teleportations.java | 305 ++-- src/com/Zrips/CMI/Modules/tp/TpManager.java | 80 +- src/com/Zrips/CMI/NBT/NMS.java | 9 +- src/com/Zrips/CMI/PlayerManager.java | 362 ++-- src/com/Zrips/CMI/Reflections.java | 78 +- src/com/Zrips/CMI/TabComplete.java | 203 +-- src/com/Zrips/CMI/commands/CAnnotation.java | 8 +- src/com/Zrips/CMI/commands/CMICommand.java | 3 +- .../Zrips/CMI/commands/CommandsHandler.java | 144 +- .../Zrips/CMI/commands/list/colorlimits.java | 50 + .../Zrips/CMI/commands/list/vanishedit.java | 147 +- .../Zrips/CMI/events/CMIAfkLeaveEvent.java | 18 + .../CMI/events/CMIChequeCreationEvent.java | 58 + .../Zrips/CMI/events/CMIChequeUsageEvent.java | 58 + .../CMI/events/CMIConfigReloadEvent.java | 29 + .../CMI/events/CMIPlayerItemsSellEvent.java | 66 + .../Zrips/CMI/events/CMIPlayerJailEvent.java | 2 +- .../CMI/events/CMIUserBalanceChangeEvent.java | 2 +- src/com/Zrips/CMI/utils/CMIEncoder.java | 28 +- src/com/Zrips/CMI/utils/CMINBTListType.java | 6 +- src/com/Zrips/CMI/utils/ChunkFix.java | 1 + .../Zrips/CMI/utils/EssentialsConverter.java | 9 +- src/com/Zrips/CMI/utils/FileDownloader.java | 9 +- src/com/Zrips/CMI/utils/HDConverter.java | 13 - src/com/Zrips/CMI/utils/Lag.java | 25 +- src/com/Zrips/CMI/utils/ListEditor.java | 46 +- .../Zrips/CMI/utils/PlayerVaultManager.java | 13 +- src/com/Zrips/CMI/utils/PrevNamesFetcher.java | 34 +- src/com/Zrips/CMI/utils/Purge.java | 33 +- src/com/Zrips/CMI/utils/SpawnUtil.java | 199 +-- src/com/Zrips/CMI/utils/TimeManager.java | 101 +- src/com/Zrips/CMI/utils/UnloadChunks.java | 13 +- src/com/Zrips/CMI/utils/Util.java | 367 ++-- src/com/Zrips/CMI/utils/VersionChecker.java | 17 +- 356 files changed, 16861 insertions(+), 11765 deletions(-) create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs create mode 100644 pom.xml delete mode 100644 src/com/Zrips/CMI/AllListeners/FlyListener1_17.java delete mode 100644 src/com/Zrips/CMI/Containers/CMIBlock.java create mode 100644 src/com/Zrips/CMI/Containers/CMILwc.java create mode 100644 src/com/Zrips/CMI/Containers/CMINumber.java create mode 100644 src/com/Zrips/CMI/Containers/CMISunMover.java create mode 100644 src/com/Zrips/CMI/Containers/CMITextCleaner.java create mode 100644 src/com/Zrips/CMI/Containers/worldFlyState.java create mode 100644 src/com/Zrips/CMI/Locale/CMILC.java create mode 100644 src/com/Zrips/CMI/Modules/AStand/ArmorStandSave.java create mode 100644 src/com/Zrips/CMI/Modules/ArmorEffects/ArmorEffectListener.java create mode 100644 src/com/Zrips/CMI/Modules/ArmorEffects/ArmorEffectManager.java create mode 100644 src/com/Zrips/CMI/Modules/DeathMessages/CMIDeathMsgInfo.java create mode 100644 src/com/Zrips/CMI/Modules/DeathMessages/CMIKillerInfo.java create mode 100644 src/com/Zrips/CMI/Modules/Holograms/CMIFont.java create mode 100644 src/com/Zrips/CMI/Modules/Holograms/CMIHologramClickEvent.java create mode 100644 src/com/Zrips/CMI/Modules/Homes/HomeWorldLimit.java create mode 100644 src/com/Zrips/CMI/Modules/InvRegEditor/CMIInvSee.java delete mode 100644 src/com/Zrips/CMI/Modules/InvRegEditor/RegChestListener19.java delete mode 100644 src/com/Zrips/CMI/Modules/InvRegEditor/RegWatcher.java delete mode 100644 src/com/Zrips/CMI/Modules/Packets/PacketHandler.java delete mode 100644 src/com/Zrips/CMI/Modules/Packets/PacketInjector.java create mode 100644 src/com/Zrips/CMI/Modules/Permissions/BPermissionsHandler.java create mode 100644 src/com/Zrips/CMI/Modules/Permissions/GroupManagerXHandler.java create mode 100644 src/com/Zrips/CMI/Modules/Permissions/LuckPermsHandler4.java create mode 100644 src/com/Zrips/CMI/Modules/Permissions/LuckPermsHandler5.java create mode 100644 src/com/Zrips/CMI/Modules/Permissions/PEXHandler.java create mode 100644 src/com/Zrips/CMI/Modules/Permissions/PowerfullPermsHandler.java create mode 100644 src/com/Zrips/CMI/Modules/Permissions/PowerfullPermsgustav9797Handler.java create mode 100644 src/com/Zrips/CMI/Modules/Permissions/UltraPermissions3Handler.java create mode 100644 src/com/Zrips/CMI/Modules/Permissions/ZPermissionsHandler.java create mode 100644 src/com/Zrips/CMI/Modules/Placeholders/MVdWPlaceholderAPIHook.java create mode 100644 src/com/Zrips/CMI/Modules/Placeholders/PlaceholderCache.java create mode 100644 src/com/Zrips/CMI/Modules/PlayTime/CMIPlayTimeFormat.java create mode 100644 src/com/Zrips/CMI/Modules/PlayerOptions/PlayerOption.java create mode 100644 src/com/Zrips/CMI/Modules/PlayerOptions/PlayerOptionsManager.java create mode 100644 src/com/Zrips/CMI/Modules/Ranks/AureliumManager.java delete mode 100644 src/com/Zrips/CMI/Modules/Recipes/CMIRecipe.java delete mode 100644 src/com/Zrips/CMI/Modules/Recipes/FurnaceTempData.java delete mode 100644 src/com/Zrips/CMI/Modules/Recipes/RecipeListener.java create mode 100644 src/com/Zrips/CMI/Modules/Recipes/recipeInformation.java create mode 100644 src/com/Zrips/CMI/Modules/SpecializedCommands/specCommand.java delete mode 100644 src/com/Zrips/CMI/Modules/Votifier/VotifierListener.java create mode 100644 src/com/Zrips/CMI/commands/list/colorlimits.java create mode 100644 src/com/Zrips/CMI/events/CMIChequeCreationEvent.java create mode 100644 src/com/Zrips/CMI/events/CMIChequeUsageEvent.java create mode 100644 src/com/Zrips/CMI/events/CMIConfigReloadEvent.java create mode 100644 src/com/Zrips/CMI/events/CMIPlayerItemsSellEvent.java diff --git a/.classpath b/.classpath index b4b67c0..cb41219 100644 --- a/.classpath +++ b/.classpath @@ -1,9 +1,20 @@ - - - - - - + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore index 2f1d33d..a5bf0e7 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* /bin/ +/target/ diff --git a/.project b/.project index cbc05cb..da4da42 100644 --- a/.project +++ b/.project @@ -10,8 +10,14 @@ + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature org.eclipse.jdt.core.javanature diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..2f5cc74 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..82e3058 --- /dev/null +++ b/pom.xml @@ -0,0 +1,105 @@ + + 4.0.0 + CMI-API + CMI-API + 9.3.1.2 + + + + io.papermc.paper + paper-api + 1.17.1-R0.1-SNAPSHOT + provided + + + org.ow2.asm + asm-commons + + + com.google.code.findbugs + jsr305 + + + com.googlecode.json-simple + json-simple + + + org.slf4j + slf4j-api + + + org.ow2.asm + asm + + + + + com.mojang + authlib + 1.5.21 + provided + + + + com.github.MilkBowl + VaultAPI + 1.7 + provided + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + + + + net.Zrips + CMILib + latest + system + ${basedir}/libs/CMILib1.2.4.1.jar + + + + + jitpack.io + https://jitpack.io + + + + papermc + https://papermc.io/repo/repository/maven-public/ + + + minecraft-repo + https://libraries.minecraft.net/ + + + + + clean package + CMI-API${project.version} + ${basedir}/src + + + + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + + + \ No newline at end of file diff --git a/src/com/Zrips/CMI/AllListeners/ArmorChangeListener.java b/src/com/Zrips/CMI/AllListeners/ArmorChangeListener.java index a695b76..8f2bb29 100644 --- a/src/com/Zrips/CMI/AllListeners/ArmorChangeListener.java +++ b/src/com/Zrips/CMI/AllListeners/ArmorChangeListener.java @@ -1,6 +1,19 @@ package com.Zrips.CMI.AllListeners; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockDispenseEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; import com.Zrips.CMI.CMI; @@ -9,6 +22,40 @@ public class ArmorChangeListener implements Listener { private CMI plugin; public ArmorChangeListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.HIGH) + public void InventoryDragEvent(InventoryDragEvent event) { + } + + @EventHandler(priority = EventPriority.HIGH) + public void onInventoryClick(InventoryClickEvent event) { + } + + public static Set checked = new HashSet(); + + @EventHandler + public void playerInteractEvent(PlayerPickupItemEvent event) { + checked.remove(event.getPlayer().getUniqueId()); + } + + @EventHandler + public void playerInteractEvent(PlayerItemHeldEvent event) { + checked.remove(event.getPlayer().getUniqueId()); + } + + @EventHandler + public void playerInteractEvent(PlayerQuitEvent event) { + checked.remove(event.getPlayer().getUniqueId()); + } + + @EventHandler(priority = EventPriority.HIGH) + public void playerInteractEvent(PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH) + public void dispenserFireEvent(BlockDispenseEvent event) { } } diff --git a/src/com/Zrips/CMI/AllListeners/ArmorChangeListener1_9.java b/src/com/Zrips/CMI/AllListeners/ArmorChangeListener1_9.java index 2a07e67..cd20de3 100644 --- a/src/com/Zrips/CMI/AllListeners/ArmorChangeListener1_9.java +++ b/src/com/Zrips/CMI/AllListeners/ArmorChangeListener1_9.java @@ -1,6 +1,8 @@ package com.Zrips.CMI.AllListeners; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerSwapHandItemsEvent; import com.Zrips.CMI.CMI; @@ -11,4 +13,9 @@ public class ArmorChangeListener1_9 implements Listener { public ArmorChangeListener1_9(CMI plugin) { this.plugin = plugin; } + + @EventHandler + public void playerInteractEvent(PlayerSwapHandItemsEvent event) { + ArmorChangeListener.checked.remove(event.getPlayer().getUniqueId()); + } } diff --git a/src/com/Zrips/CMI/AllListeners/BossBarCompassListener.java b/src/com/Zrips/CMI/AllListeners/BossBarCompassListener.java index 07a0294..be157ea 100644 --- a/src/com/Zrips/CMI/AllListeners/BossBarCompassListener.java +++ b/src/com/Zrips/CMI/AllListeners/BossBarCompassListener.java @@ -1,6 +1,14 @@ package com.Zrips.CMI.AllListeners; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerMoveEvent; import com.Zrips.CMI.CMI; @@ -8,7 +16,24 @@ public class BossBarCompassListener implements Listener { private CMI plugin; public BossBarCompassListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + ConcurrentHashMap compassCheck = new ConcurrentHashMap(); + + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerItemHeldEvent(final PlayerJoinEvent event) { + compassCheck.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + 1000L); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerItemHeldEvent(final PlayerItemHeldEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerMoveEvent(final PlayerMoveEvent event) { + } } diff --git a/src/com/Zrips/CMI/AllListeners/CustomMessagesListener.java b/src/com/Zrips/CMI/AllListeners/CustomMessagesListener.java index afba7ac..272ffd8 100644 --- a/src/com/Zrips/CMI/AllListeners/CustomMessagesListener.java +++ b/src/com/Zrips/CMI/AllListeners/CustomMessagesListener.java @@ -1,14 +1,49 @@ package com.Zrips.CMI.AllListeners; +import java.util.regex.Matcher; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Config; +import com.Zrips.CMI.Containers.Snd; +import com.Zrips.CMI.Locale.CMILC; +import com.Zrips.CMI.Modules.BungeeCord.BungeePlayer; +import com.Zrips.CMI.Modules.InteractiveCommand.CMIInteractiveCommand; +import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; + +import net.Zrips.CMILib.Container.CMILocation; +import net.Zrips.CMILib.Locale.LC; +import net.Zrips.CMILib.Logs.CMIDebug; +import net.Zrips.CMILib.Messages.CMIMultiMessage; public class CustomMessagesListener implements Listener { CMI plugin; public CustomMessagesListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onQuit(PlayerQuitEvent event) { } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onJoinMulti(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onJoin(PlayerJoinEvent event) { + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onJoinMulti(PlayerJoinEvent event) { + + } } diff --git a/src/com/Zrips/CMI/AllListeners/FirstJoinListener.java b/src/com/Zrips/CMI/AllListeners/FirstJoinListener.java index a665bee..4970bc0 100644 --- a/src/com/Zrips/CMI/AllListeners/FirstJoinListener.java +++ b/src/com/Zrips/CMI/AllListeners/FirstJoinListener.java @@ -1,8 +1,17 @@ package com.Zrips.CMI.AllListeners; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Containers.Snd; +import com.Zrips.CMI.Locale.CMILC; + +import net.Zrips.CMILib.Locale.LC; public class FirstJoinListener implements Listener { CMI plugin; @@ -11,4 +20,7 @@ public FirstJoinListener(CMI plugin) { this.plugin = plugin; } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerFirstLogin(PlayerJoinEvent event) { + } } diff --git a/src/com/Zrips/CMI/AllListeners/FlyListener1_17.java b/src/com/Zrips/CMI/AllListeners/FlyListener1_17.java deleted file mode 100644 index 982890b..0000000 --- a/src/com/Zrips/CMI/AllListeners/FlyListener1_17.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.Zrips.CMI.AllListeners; - -import java.util.HashMap; -import java.util.UUID; - -import org.bukkit.World; -import org.bukkit.event.Listener; - -public class FlyListener1_17 implements Listener { - - private class flightData { - private boolean canFly = false; - private boolean flying = false; - private World world; - private Long time = 0l; - - public flightData(World world, boolean canFly, boolean flying) { - this.world = world; - this.canFly = canFly; - this.flying = flying; - this.time = System.currentTimeMillis(); - } - - public boolean isCanFly() { - return canFly; - } - - public void setCanFly(boolean canFly) { - this.canFly = canFly; - } - - public boolean isFlying() { - return flying; - } - - public void setFlying(boolean flying) { - this.flying = flying; - } - - public Long getTime() { - return time; - } - - public void setTime(Long time) { - this.time = time; - } - - public World getWorld() { - return world; - } - - public void setWorld(World world) { - this.world = world; - } - } - - HashMap map = new HashMap(); -} diff --git a/src/com/Zrips/CMI/AllListeners/GlicthListeners.java b/src/com/Zrips/CMI/AllListeners/GlicthListeners.java index 3be7edb..a214bbc 100644 --- a/src/com/Zrips/CMI/AllListeners/GlicthListeners.java +++ b/src/com/Zrips/CMI/AllListeners/GlicthListeners.java @@ -1,6 +1,10 @@ package com.Zrips.CMI.AllListeners; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerEditBookEvent; import com.Zrips.CMI.CMI; @@ -11,4 +15,13 @@ public GlicthListeners(CMI plugin) { this.plugin = plugin; } + @EventHandler(priority = EventPriority.LOWEST) + public void onCommand(PlayerCommandPreprocessEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onPlayerEditBookEvent(PlayerEditBookEvent event) { + } + } diff --git a/src/com/Zrips/CMI/AllListeners/LaunchPadListener.java b/src/com/Zrips/CMI/AllListeners/LaunchPadListener.java index e1a9683..83406d4 100644 --- a/src/com/Zrips/CMI/AllListeners/LaunchPadListener.java +++ b/src/com/Zrips/CMI/AllListeners/LaunchPadListener.java @@ -1,6 +1,10 @@ package com.Zrips.CMI.AllListeners; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.player.PlayerTeleportEvent; import com.Zrips.CMI.CMI; @@ -8,7 +12,19 @@ public class LaunchPadListener implements Listener { private CMI plugin; public LaunchPadListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.LOW) + public void onTeleport(PlayerTeleportEvent event) { + } + + @EventHandler(priority = EventPriority.LOW) + public void EntityDamageEvent(EntityDamageEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onTeleportLaunch(PlayerTeleportEvent event) { + } } diff --git a/src/com/Zrips/CMI/AllListeners/LaunchPadListener1_9.java b/src/com/Zrips/CMI/AllListeners/LaunchPadListener1_9.java index 17d8c10..5fb6b48 100644 --- a/src/com/Zrips/CMI/AllListeners/LaunchPadListener1_9.java +++ b/src/com/Zrips/CMI/AllListeners/LaunchPadListener1_9.java @@ -1,6 +1,9 @@ package com.Zrips.CMI.AllListeners; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityToggleGlideEvent; import com.Zrips.CMI.CMI; @@ -11,4 +14,7 @@ public LaunchPadListener1_9(CMI plugin) { this.plugin = plugin; } + @EventHandler(priority = EventPriority.MONITOR) + public void EntityToggleGlideEvent(EntityToggleGlideEvent event) { + } } diff --git a/src/com/Zrips/CMI/AllListeners/NoTargetListener.java b/src/com/Zrips/CMI/AllListeners/NoTargetListener.java index 12dd525..493c18b 100644 --- a/src/com/Zrips/CMI/AllListeners/NoTargetListener.java +++ b/src/com/Zrips/CMI/AllListeners/NoTargetListener.java @@ -4,14 +4,13 @@ import java.util.Set; import java.util.UUID; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityTargetEvent.TargetReason; import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Containers.CMIUser; public class NoTargetListener implements Listener { @@ -29,6 +28,13 @@ public static boolean isInNoTargetPlayers(UUID uuid) { return noTargetPlayers.contains(uuid); } + public static void toggleOn(CMIUser user) { + } + + public static void toggleOff(CMIUser user) { + removeNoTargetPlayers(user.getUniqueId()); + } + public static void addNoTargetPlayers(UUID uuid) { noTargetPlayers.add(uuid); } @@ -36,4 +42,8 @@ public static void addNoTargetPlayers(UUID uuid) { public static void removeNoTargetPlayers(UUID uuid) { noTargetPlayers.remove(uuid); } + + @EventHandler(priority = EventPriority.HIGHEST) + public void EntityTargetLivingEntityEvent(EntityTargetLivingEntityEvent event) { + } } \ No newline at end of file diff --git a/src/com/Zrips/CMI/AllListeners/PlayerItemDamageListener.java b/src/com/Zrips/CMI/AllListeners/PlayerItemDamageListener.java index 8fbc069..7105030 100644 --- a/src/com/Zrips/CMI/AllListeners/PlayerItemDamageListener.java +++ b/src/com/Zrips/CMI/AllListeners/PlayerItemDamageListener.java @@ -3,7 +3,10 @@ import java.util.HashMap; import java.util.UUID; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerItemDamageEvent; import com.Zrips.CMI.CMI; @@ -16,4 +19,11 @@ public PlayerItemDamageListener(CMI plugin) { HashMap informed = new HashMap(); + @EventHandler(priority = EventPriority.NORMAL) + public void itemDurabilityLoss(PlayerItemDamageEvent event) { + } + + @EventHandler(priority = EventPriority.NORMAL) + public void armorDurabilityLoss(PlayerItemDamageEvent event) { + } } diff --git a/src/com/Zrips/CMI/AllListeners/PlayerListeners.java b/src/com/Zrips/CMI/AllListeners/PlayerListeners.java index 1d6b09e..bcc693e 100644 --- a/src/com/Zrips/CMI/AllListeners/PlayerListeners.java +++ b/src/com/Zrips/CMI/AllListeners/PlayerListeners.java @@ -5,81 +5,333 @@ import java.util.Set; import java.util.UUID; +import org.bukkit.entity.Animals; import org.bukkit.entity.Entity; +import org.bukkit.entity.Monster; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.SignChangeEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityPortalEnterEvent; +import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.PotionSplashEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerBedEnterEvent; +import org.bukkit.event.player.PlayerBedLeaveEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerEditBookEvent; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.server.ServerCommandEvent; +import org.bukkit.event.vehicle.VehicleEnterEvent; +import org.bukkit.event.world.PortalCreateEvent; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.events.CMIPlayerUnVanishEvent; +import com.Zrips.CMI.events.CMIPortalCreateEvent; public class PlayerListeners implements Listener { private CMI plugin; public PlayerListeners(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(ignoreCancelled = true) + public void onUnVanish(CMIPlayerUnVanishEvent e) { + + } + + private static boolean isMonster(Entity ent) { + return (ent instanceof Monster); + } + + private static boolean isAnimal(Entity ent) { + return (ent instanceof Animals); + } + + // Preventing item pickup which got shoot with /shoot commmand + @SuppressWarnings("deprecation") + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void PlayerPickupItemEvent(PlayerPickupItemEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH) + public void onRespawn(PlayerRespawnEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerBedEnterEvent(PlayerBedEnterEvent event) { + } HashMap informMap = new HashMap(); + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerBedLeaveEvent(PlayerBedLeaveEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerDeathEvent(PlayerDeathEvent event) { + + } class HungerCache { - private int hunger = 20; - private float saturation = 5F; + private int hunger = 20; + private float saturation = 5F; - public HungerCache(int hunger, float saturation) { - this.hunger = hunger; - this.saturation = saturation; - } + public HungerCache(int hunger, float saturation) { + this.hunger = hunger; + this.saturation = saturation; + } - public int getHunger() { - return hunger; - } + public int getHunger() { + return hunger; + } - public void setHunger(int hunger) { - this.hunger = hunger; - } + public void setHunger(int hunger) { + this.hunger = hunger; + } - public float getSaturation() { - return saturation; - } + public float getSaturation() { + return saturation; + } - public void setSaturation(float saturation) { - this.saturation = saturation; - } + public void setSaturation(float saturation) { + this.saturation = saturation; + } } HashMap hungerMap = new HashMap(); + @EventHandler(priority = EventPriority.LOWEST) + public void PlayerDeathEventHunger(PlayerDeathEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void PlayerRespawnEventHunger(PlayerRespawnEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onFishingRodUse(PlayerFishEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void VehicleEnterEvent(VehicleEnterEvent event) { + + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) { + + } + + @EventHandler + public void onInteractHead(PlayerInteractEvent event) { + + } + + @EventHandler + public void onInteractBeeHive(PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void hatPlacement(InventoryClickEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerEditBookEvent(PlayerEditBookEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW) + public void EntityDeathEvent(EntityDeathEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onCommand(ServerCommandEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void EntityPortalEnterEvent(EntityPortalEnterEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW) + public void EntityDamageEvent(EntityDamageEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW) + public void PortalCreateEvent(PortalCreateEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW) + public void CMIPortalCreateEvent(CMIPortalCreateEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW) + public void onTeleport(PlayerTeleportEvent event) { + + } + class vehicleLast { - private UUID uuid; - private Entity vehicle; - private int tick; + private UUID uuid; + private Entity vehicle; + private int tick; - public vehicleLast(UUID uuid, Entity vehicle, int tick) { - this.uuid = uuid; - this.vehicle = vehicle; - this.tick = tick; - } + public vehicleLast(UUID uuid, Entity vehicle, int tick) { + this.uuid = uuid; + this.vehicle = vehicle; + this.tick = tick; + } - public UUID getUuid() { - return uuid; - } + public UUID getUuid() { + return uuid; + } - public Entity getVehicle() { - return vehicle; - } + public Entity getVehicle() { + return vehicle; + } - public int getTick() { - return tick; - } + public int getTick() { + return tick; + } } HashMap mapVehicle = new HashMap(); + @EventHandler(priority = EventPriority.LOWEST) + public void onTeleportWithEntity(final PlayerTeleportEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onPlayerLoginLimit(PlayerLoginEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPlayerLogin(PlayerLoginEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerFirstJoin(PlayerJoinEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onJoinInSpawn(PlayerJoinEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void PlayerQuitEvent(final PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW) + public void PlayerQuitEventPermissioCache(final PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onPlayerJoinSafe(PlayerJoinEvent event) { + + } + + @EventHandler + public void onSignChangeEvent(SignChangeEvent event) { + + } Set signEditCache = new HashSet(); + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onSignInteractShift(PlayerInteractEvent event) { + + } + public static HashMap scMap = new HashMap(); + @EventHandler + public void onSignInteract(PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onChatIgnore(AsyncPlayerChatEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onChat(AsyncPlayerChatEvent event) { + + } + + @EventHandler + public void FoodLevelChangeEvent(FoodLevelChangeEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void CreatureSpawnEvent(org.bukkit.event.entity.CreatureSpawnEvent event) { + SpawnReason reason = event.getSpawnReason(); + if (plugin.getConfigManager().isBlockedSpawnReason(event.getEntity().getWorld().getName(), reason)) + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onSignChangeEventElevator(final SignChangeEvent event) { + + } + HashMap elevatorUsage = new HashMap(); + @EventHandler(priority = EventPriority.HIGHEST) + public void PlayerInteractEvent(final PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPotionSplashEvent(PotionSplashEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onEntityDamage(EntityDamageEvent event) { + + } + + // Donation command fix + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerDropItemEvent(PlayerDropItemEvent event) { + + } + } diff --git a/src/com/Zrips/CMI/AllListeners/PlayerListeners1_8.java b/src/com/Zrips/CMI/AllListeners/PlayerListeners1_8.java index 88f11b5..ac2361d 100644 --- a/src/com/Zrips/CMI/AllListeners/PlayerListeners1_8.java +++ b/src/com/Zrips/CMI/AllListeners/PlayerListeners1_8.java @@ -1,6 +1,9 @@ package com.Zrips.CMI.AllListeners; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; import com.Zrips.CMI.CMI; @@ -8,7 +11,12 @@ public class PlayerListeners1_8 implements Listener { private CMI plugin; public PlayerListeners1_8(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @SuppressWarnings({ "incomplete-switch", "deprecation" }) + @EventHandler(priority = EventPriority.HIGHEST) + public void PlayerInteractMinecart(PlayerInteractAtEntityEvent event) { + + } } diff --git a/src/com/Zrips/CMI/AllListeners/PreviousName.java b/src/com/Zrips/CMI/AllListeners/PreviousName.java index 35b1810..573720f 100644 --- a/src/com/Zrips/CMI/AllListeners/PreviousName.java +++ b/src/com/Zrips/CMI/AllListeners/PreviousName.java @@ -1,7 +1,13 @@ package com.Zrips.CMI.AllListeners; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; public class PreviousName implements Listener { + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onJoin(PlayerJoinEvent event) { + } } diff --git a/src/com/Zrips/CMI/AllListeners/ProtocolEvent.java b/src/com/Zrips/CMI/AllListeners/ProtocolEvent.java index 2fbeec1..4422f63 100644 --- a/src/com/Zrips/CMI/AllListeners/ProtocolEvent.java +++ b/src/com/Zrips/CMI/AllListeners/ProtocolEvent.java @@ -4,6 +4,7 @@ public class ProtocolEvent { + public static void includeViewRange(CMI plugin) { } diff --git a/src/com/Zrips/CMI/AllListeners/UserCuffedEvents.java b/src/com/Zrips/CMI/AllListeners/UserCuffedEvents.java index afc32c7..2013464 100644 --- a/src/com/Zrips/CMI/AllListeners/UserCuffedEvents.java +++ b/src/com/Zrips/CMI/AllListeners/UserCuffedEvents.java @@ -1,6 +1,19 @@ package com.Zrips.CMI.AllListeners; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; import com.Zrips.CMI.CMI; @@ -8,7 +21,61 @@ public class UserCuffedEvents implements Listener { private CMI plugin; public UserCuffedEvents(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void chat(AsyncPlayerChatEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerQuit(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onPlayerInteract(PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onPlayerInteract(InventoryClickEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onPlayerDropItemEvent(PlayerDropItemEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onProjectileLaunchEvent(ProjectileLaunchEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onHit(EntityDamageByEntityEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onPlayerDamage(EntityDamageEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onPlayerMove(PlayerMoveEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerMove(PlayerCommandPreprocessEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerLogin(PlayerJoinEvent event) { + + } } diff --git a/src/com/Zrips/CMI/AllListeners/UserEvents.java b/src/com/Zrips/CMI/AllListeners/UserEvents.java index 53a0729..649286c 100644 --- a/src/com/Zrips/CMI/AllListeners/UserEvents.java +++ b/src/com/Zrips/CMI/AllListeners/UserEvents.java @@ -3,19 +3,100 @@ import java.util.HashMap; import java.util.UUID; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerTeleportEvent; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.events.CMIUserBalanceChangeEvent; public class UserEvents implements Listener { private CMI plugin; public UserEvents(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onCMIUserBalanceChangeEvent(CMIUserBalanceChangeEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onPlayerLoginNameCheck(PlayerLoginEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerLoginNewNameCheck(PlayerLoginEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onPlayerLogin(PlayerLoginEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerLoginIpRecord(final PlayerLoginEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerDeath(PlayerDeathEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void teleportBack(PlayerTeleportEvent event) { + } private HashMap weMap = new HashMap(); + @EventHandler(priority = EventPriority.LOWEST) + public void teleportBackWECompasss(PlayerInteractEvent event) { + + } + + HashMap roofTeleporterDelay = new HashMap(); + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerDeath(PlayerMoveEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMoveBelow(PlayerMoveEvent event) { + + } + HashMap informer = new HashMap(); + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onPlayerFlyToHigh(PlayerMoveEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerQuit(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void removeFromRankCheck(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerLogin(PlayerJoinEvent event) { + + } } diff --git a/src/com/Zrips/CMI/AllListeners/WorldLimits.java b/src/com/Zrips/CMI/AllListeners/WorldLimits.java index 4e083e0..80e3a52 100644 --- a/src/com/Zrips/CMI/AllListeners/WorldLimits.java +++ b/src/com/Zrips/CMI/AllListeners/WorldLimits.java @@ -1,6 +1,12 @@ package com.Zrips.CMI.AllListeners; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerTeleportEvent; import com.Zrips.CMI.CMI; @@ -8,7 +14,53 @@ public class WorldLimits implements Listener { private CMI plugin; public WorldLimits(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler + public void onWorldChangeGameMode(PlayerChangedWorldEvent event) { + + } + + @EventHandler + public void onLoginGameMode(PlayerLoginEvent event) { + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onWorldChangeFly(PlayerChangedWorldEvent event) { + processFly(event.getPlayer(), event.getFrom().getName()); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onWorldChangeFlyCached(PlayerChangedWorldEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW) + public void onTeleport(PlayerTeleportEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onLoginFly(PlayerLoginEvent event) { + + } + + private void processFly(Player player, String from) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onLoginGod(PlayerLoginEvent event) { + processGod(event.getPlayer()); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onWorldChangeGod(PlayerChangedWorldEvent event) { + processGod(event.getPlayer()); + } + + private void processGod(Player player) { + } - } diff --git a/src/com/Zrips/CMI/AllListeners/WorldLimitsElytra.java b/src/com/Zrips/CMI/AllListeners/WorldLimitsElytra.java index dc37f83..9d4f01a 100644 --- a/src/com/Zrips/CMI/AllListeners/WorldLimitsElytra.java +++ b/src/com/Zrips/CMI/AllListeners/WorldLimitsElytra.java @@ -1,6 +1,11 @@ package com.Zrips.CMI.AllListeners; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityToggleGlideEvent; +import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerLoginEvent; import com.Zrips.CMI.CMI; @@ -8,8 +13,21 @@ public class WorldLimitsElytra implements Listener { private CMI plugin; public WorldLimitsElytra(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler + public void onWorldChangeElytra(PlayerChangedWorldEvent event) { + } + + @EventHandler + public void onLoginElytra(PlayerLoginEvent event) { + } + @EventHandler + public void EntityToggleGlideEvent(EntityToggleGlideEvent event) { + } + + private void processElytra(Player player) { + } } diff --git a/src/com/Zrips/CMI/AllListeners/versionCheck.java b/src/com/Zrips/CMI/AllListeners/versionCheck.java index a10844a..2c715c9 100644 --- a/src/com/Zrips/CMI/AllListeners/versionCheck.java +++ b/src/com/Zrips/CMI/AllListeners/versionCheck.java @@ -1,8 +1,12 @@ package com.Zrips.CMI.AllListeners; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; public class versionCheck implements Listener { private CMI plugin; @@ -10,4 +14,10 @@ public class versionCheck implements Listener { public versionCheck(CMI plugin) { this.plugin = plugin; } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onJoin(PlayerJoinEvent event) { + if (plugin.getConfigManager().isShowNewVersion() && CMIPerm.versioncheck.hasPermission(event.getPlayer())) + plugin.getVersionCheckManager().VersionCheck(event.getPlayer()); + } } diff --git a/src/com/Zrips/CMI/CMI.java b/src/com/Zrips/CMI/CMI.java index a152704..e98a120 100644 --- a/src/com/Zrips/CMI/CMI.java +++ b/src/com/Zrips/CMI/CMI.java @@ -22,6 +22,7 @@ import com.Zrips.CMI.Modules.Alias.AliasManager; import com.Zrips.CMI.Modules.Animations.AnimationManager; import com.Zrips.CMI.Modules.Anvil.AnvilManager; +import com.Zrips.CMI.Modules.ArmorEffects.ArmorEffectManager; import com.Zrips.CMI.Modules.AttachedCommands.CustomNBTManager; import com.Zrips.CMI.Modules.BungeeCord.BungeeCordManager; import com.Zrips.CMI.Modules.ChatFilter.ChatFilterManager; @@ -56,7 +57,6 @@ import com.Zrips.CMI.Modules.LightFix.LightFix; import com.Zrips.CMI.Modules.Mirror.MirrorManager; import com.Zrips.CMI.Modules.NickName.NickNameManager; -import com.Zrips.CMI.Modules.Packets.PacketInjector; import com.Zrips.CMI.Modules.Painting.PaintingManager; import com.Zrips.CMI.Modules.Particl.ParticleManager; import com.Zrips.CMI.Modules.Patrol.PatrolManager; @@ -66,6 +66,7 @@ import com.Zrips.CMI.Modules.PlayTime.PlayTimeManager; import com.Zrips.CMI.Modules.PlayTimeRewards.PlayTimeRewardsManager; import com.Zrips.CMI.Modules.PlayerCombat.PlayerCombatManager; +import com.Zrips.CMI.Modules.PlayerOptions.PlayerOptionsManager; import com.Zrips.CMI.Modules.Portals.PortalManager; import com.Zrips.CMI.Modules.Ranks.RankManager; import com.Zrips.CMI.Modules.Recipes.RecipeManager; @@ -106,17 +107,17 @@ import com.Zrips.CMI.utils.Util; import com.Zrips.CMI.utils.VersionChecker; -import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Container.PageInfo; import net.Zrips.CMILib.GUI.GUIManager; -import net.Zrips.CMILib.Items.ItemManager; import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Util.Sorting; -import net.Zrips.CMILib.Version.Version; import net.milkbowl.vault.permission.Permission; public class CMI extends JavaPlugin { + public static final String configFolderName = "Settings"; + public static final String savesFolderName = "Saves"; + private boolean fullyLoaded = false; protected NMS nms; protected Reflections ref; @@ -169,8 +170,11 @@ public class CMI extends JavaPlugin { protected ParticleManager ParticleManager; protected FlightChargeManager FlightChargeManager; + private ArmorEffectManager armorEffectManager; + protected PaintingManager PaintingManager; protected VanishManager VanishManager; + protected PlayerOptionsManager PlayerOptionsManager; protected InteractiveCommandManager InteractiveCommandManager; protected SpecializedCommandManager SpecializedCommandManager; protected ArmorStandManager ArmorStandManager; @@ -234,7 +238,6 @@ public class CMI extends JavaPlugin { protected StatsManager statsManager; protected AliasManager aliasManager; protected CTextManager cTextManager; - protected ItemManager itemManager; protected EventActionManager eventActionManager; @@ -263,13 +266,12 @@ public class CMI extends JavaPlugin { private long timer = 0L; - private boolean mcmmoexpmodulepresent = false; private boolean jobsPresent = false; protected HashMap> preFetchNames = new HashMap>(); protected HashMap preFetchUUIDs = new HashMap(); - private static final UUID ServerUUID = UUID.fromString("00000000-0000-0000-0000-000000000000"); + private static final UUID ServerUUID = new UUID(0, 0); protected static CMI instance; @@ -277,559 +279,556 @@ public class CMI extends JavaPlugin { protected Scoreboard scoreboard = null; - private PacketInjector injector; - - public PacketInjector getPacketInjector() { - return injector; - } - protected String getWorldFolderPath() { - return worldFolderPath; + return worldFolderPath; } public static CMI getInstance() { - return instance; + return instance; } private DBClassLoader classLoader; public DBClassLoader getDBClassloader() { - return classLoader; + return classLoader; } public void setDBClassloader() { - classLoader = new DBClassLoader(this); + classLoader = new DBClassLoader(this); } - public HashMap> preFetchNames() { - return preFetchNames; + return preFetchNames; } public HashMap preFetchUUIDS() { - return preFetchUUIDs; + return preFetchUUIDs; } public NMS getNMS() { - return nms; + return nms; } @Deprecated public Reflections getRef() { - return getReflectionManager(); + return getReflectionManager(); } public Reflections getReflectionManager() { - if (ref == null) - ref = new Reflections(this); - return ref; + if (ref == null) + ref = new Reflections(this); + return ref; } public MirrorManager getMirrorManager() { - return mirror; + return mirror; } public LookupService getLookupService() { - return LookupService; + return null; } public void defaultLocaleDownloader() { - } - public DiscordSRVManager getDiscordSRVManager() { - return DiscordSRVManager; + return DiscordSRVManager; } public ArmorStandManager getArmorStandManager() { - return ArmorStandManager; + return ArmorStandManager; } public PlayerCombatManager getPlayerCombatManager() { - return PlayerCombatManager; + return PlayerCombatManager; } public DynMapManager getDynMapManager() { - return DynMapManager; + return DynMapManager; } public WarningManager getWarningManager() { - return WarningManager; + return WarningManager; } public EnchantManager getEnchantManager() { - return EnchantManager; + return EnchantManager; } public VotifierManager getVotifierManager() { - return VotifierManager; + return VotifierManager; } public CitizensManager getCitizensManager() { - return CitizensManager; + return CitizensManager; } public SpecializedCommandManager getSpecializedCommandManager() { - return SpecializedCommandManager; + return SpecializedCommandManager; } public InteractiveCommandManager getInteractiveCommandManager() { - return InteractiveCommandManager; + return InteractiveCommandManager; } public ChatFormatManager getChatFormatManager() { - return ChatFormatManager; + return ChatFormatManager; } public KitsManager getKitsManager() { - return kits; + return kits; } public SpawnerChargeManager getSpawnerChargesManager() { - return charges; + return charges; } public SkinManager getSkinManager() { - return SkinManager; + return SkinManager; } public RecipeManager getRecipeManager() { - return RecipeManager; + return RecipeManager; } public PaintingManager getPaintingManager() { - return PaintingManager; + return PaintingManager; } public VanishManager getVanishManager() { - return VanishManager; + return VanishManager; + } + + public PlayerOptionsManager getPlayerOptionsManager() { + return PlayerOptionsManager; } public ParticleManager getParticleManager() { - return ParticleManager; + return ParticleManager; } public DeathMessageManager getDeathMessageManager() { - return DeathMessageManager; + return DeathMessageManager; } public FlightChargeManager getFlightChargeManager() { - return FlightChargeManager; + return FlightChargeManager; } public Lag getLagMeter() { - return lagMeter; + return lagMeter; } public EnderChestManager getEnderChestManager() { - return EnderChestManager; + return EnderChestManager; } public RegChestManager getRegChestManager() { - return RegChestManager; + return RegChestManager; } public HologramManager getHologramManager() { - return HologramManager; + return HologramManager; } public EconomyManager getEconomyManager() { - return economyManager; + return economyManager; } public CMICommandCostManager getCommandCostManager() { - return CMICommandCostManager; + return CMICommandCostManager; } public CooldownManager getCooldownManager() { - return cooldownManager; + return cooldownManager; } public PortalManager getPortalManager() { - return portalManager; + return portalManager; } public SignManager getSignManager() { - return signManager; + return signManager; } public SelectionManager getSelectionManager() { - return SelectionManager; + return SelectionManager; + } + + public ArmorEffectManager getArmorEffectManager() { + return armorEffectManager; } public WarmUpManager getWarmUpManager() { - return WarmUpManager; + return WarmUpManager; } public WorldManager getRegionManager() { - return regionManager; + return regionManager; } public ShulkerBoxManager getShulkerBoxManager() { - return shulkerBoxManager; + return shulkerBoxManager; } public TimedCommandManager getTimedCommandManager() { - return timedCommandManager; + return timedCommandManager; } public PermissionsManager getPermissionsManager() { - return permissionsManager; + return permissionsManager; } public NickNameManager getNickNameManager() { - return nickNameManager; + return nickNameManager; } public TagManager getTagManager() { - return TagManager; + return TagManager; } public WarpManager getWarpManager() { - return warpManager; + return warpManager; } public IpManager getIpManager() { - return ipManager; + return ipManager; } public PlayTimeRewardsManager getPlayTimeRewardManager() { - return PlayTimeRewardsManager; + return PlayTimeRewardsManager; } public TpManager getTpManager() { - return tpManager; + return tpManager; } public Teleportations getTeleportations() { - return teleportations; + return teleportations; } public StatsManager getStatsManager() { - return statsManager; + return statsManager; } public JailManager getJailManager() { - return JailManager; + return JailManager; } public WorthManager getWorthManager() { - return WorthManager; + return WorthManager; } public AliasManager getAliasManager() { - return aliasManager; + return aliasManager; } public AfkManager getAfkManager() { - return AfkManager; + return AfkManager; } public TabListHeaderFooterHandler getTabListHandler() { - return TabListHandler; + return TabListHandler; } public TabListManager getTabListManager() { - return TabListManager; + return TabListManager; } public CTextManager getCTextManager() { - return cTextManager; + return cTextManager; } public CustomNBTManager getCustomNBTManager() { - return CustomNBTManager; + return CustomNBTManager; } public EventActionManager getEventActionManager() { - return eventActionManager; + return eventActionManager; } public HomeManager getHomeManager() { - return homeManager; + return homeManager; } public SchedulerManager getSchedulerManager() { - return schedulerManager; + return schedulerManager; } public AnvilManager getAnvilManager() { - return anvilManager; + return anvilManager; } public TotemManager getTotemManager() { - return totemManager; + return totemManager; } public AnimationManager getAnimationManager() { - return AnimationManager; + return AnimationManager; } - public FindBiomeManager getFindBiomeManager() { - return findBiomeManager; + return findBiomeManager; } public ChatFilterManager getChatFilterManager() { - return chatFilterManager; + return chatFilterManager; } public SavedInventoryManager getSavedInventoryManager() { - return SavedInventoryManager; + return SavedInventoryManager; } BungeeCordManager BungeeCordManager; public BungeeCordManager getBungeeCordManager() { - return BungeeCordManager; + return BungeeCordManager; } public PatrolManager getPatrolManager() { - return PatrolManager; + return PatrolManager; } public RankManager getRankManager() { - return rankManager; + return rankManager; } public PlayerManager getPlayerManager() { - return PM; + return PM; } public Sorting getSortingManager() { - return Sorting; + return Sorting; } public PrevNamesFetcher getNamesChecker() { - return NamesChecker; + return NamesChecker; } public TimeManager getTimeManager() { - return TimeManager; + return TimeManager; } public VersionChecker getVersionCheckManager() { - return versionCheckManager; + return versionCheckManager; } public CommandsHandler getCommandManager() { - return cManager; + return cManager; } public SavedItemManager getSavedItemManager() { - return SavedItemManager; + return SavedItemManager; } public PlayTimeManager getPlayTimeManager() { - return PlayTimeManager; + return PlayTimeManager; } public LightFix getLightFixManager() { - return LightFixManager; + return LightFixManager; } public ChunkPreview getChunkPreviewManager() { - return ChunkPreviewManager; + return ChunkPreviewManager; } public ViewRangeManager getViewRangeManager() { - return ViewRangeManager; + return ViewRangeManager; } public Search getSearchManager() { - return SearchManager; + return SearchManager; } public Scan getScanManager() { - return ScanManager; + return ScanManager; } public ChunkFix getChunkFixManager() { - return ChunkFixManager; + return ChunkFixManager; } public ReplaceBlock getReplaceBlockManager() { - return replaceblock; + return replaceblock; } public UnloadChunks getUnloadChunksManager() { - return unloadchunks; + return unloadchunks; } public Purge getPurgeManager() { - return PurgeManager; + return PurgeManager; } public Util getUtilManager() { - return UtilManager; + return UtilManager; } public Config getConfigManager() { - return config; + return config; } public ScavengeManager getScavengeManager() { - return scavengeManager; + return scavengeManager; } public DBManager getDbManager() { - return dbManager; + return dbManager; } public Language getLM() { - return languageManager; + return languageManager; } @Override public void onDisable() { - + } int lagId = -1; public Scoreboard getSB() { - return scoreboard; + return scoreboard; } public void renameDirectory(String fromDir, String toDir) { } public void Enabled(boolean state) { - this.setEnabled(state); + this.setEnabled(state); } List logo = new ArrayList(Arrays.asList( - "&7┏━━━┓ &f┏━┓┏━┓ &7┏━━┓", - "&7┃┏━┓┃ &f┃ ┗┛ ┃ &7┗┫┣┛", - "&7┃┃ ┗┛ &f┃┏┓┏┓┃ &7 ┃┃ ", - "&7┃┃ ┏┓ &f┃┃┃┃┃┃ &7 ┃┃ ", - "&7┃┗━┛┃ &f┃┃┃┃┃┃ &7┏┫┣┓", - "&7┗━━━┛ &f┗┛┗┛┗┛ &7┗━━┛", - "&7_______________________________________________________" + "&7┏━━━┓ &f┏━┓┏━┓ &7┏━━┓", + "&7┃┏━┓┃ &f┃ ┗┛ ┃ &7┗┫┣┛", + "&7┃┃ ┗┛ &f┃┏┓┏┓┃ &7 ┃┃ ", + "&7┃┃ ┏┓ &f┃┃┃┃┃┃ &7 ┃┃ ", + "&7┃┗━┛┃ &f┃┃┃┃┃┃ &7┏┫┣┓", + "&7┗━━━┛ &f┗┛┗┛┗┛ &7┗━━┛", + "&7_______________________________________________________" )); List SpigotLogo = new ArrayList(Arrays.asList( - "┏━━━┓ ┏━┓┏━┓ ┏━━┓", - "┃┏━┓┃ ┃ ┗┛ ┃ ┗┫┣┛", - "┃┃ ┗┛ ┃┏┓┏┓┃ ┃┃ ", - "┃┃ ┏┓ ┃┃┃┃┃┃ ┃┃ ", - "┃┗━┛┃ ┃┃┃┃┃┃ ┏┫┣┓", - "┗━━━┛ ┗┛┗┛┗┛ ┗━━┛", - "_______________________________________________________")); + "┏━━━┓ ┏━┓┏━┓ ┏━━┓", + "┃┏━┓┃ ┃ ┗┛ ┃ ┗┫┣┛", + "┃┃ ┗┛ ┃┏┓┏┓┃ ┃┃ ", + "┃┃ ┏┓ ┃┃┃┃┃┃ ┃┃ ", + "┃┗━┛┃ ┃┃┃┃┃┃ ┏┫┣┓", + "┗━━━┛ ┗┛┗┛┗┛ ┗━━┛", + "_______________________________________________________")); private int lastCMILibVersion = 1000100; private int requiredCMILibVersion = 1000100; - private String slastCMILibVersion = "1.0.1.0"; - private String srequiredCMILibVersion = "1.0.1.0"; + private final String slastCMILibVersion = "1.0.1.0"; + private final String srequiredCMILibVersion = "1.0.1.0"; public static int cmiLibId = 87610; + private void libCheck() { + } + + private void libDownloader() { + + } @Override public void onEnable() { - instance = this; - serverStartupTime = System.currentTimeMillis(); + instance = this; - Version.getCurrent(); - - for (String one : Version.isPaper() ? logo : SpigotLogo) { - sendMessage(Bukkit.getConsoleSender(), CMIChatColor.translate(one)); - } - fullyLoaded = true; } public void consoleMessage(String message) { - + } public void loadMessage(Integer amount, String type, Long took) { } public String getOffOn(Player player, Player whoGets) { - return getOffOn(whoGets == null ? player.isOnline() : whoGets.canSee(player) && player.isOnline()); + return getOffOn(whoGets == null ? player == null ? false : player.isOnline() : whoGets.canSee(player) && player.isOnline()); } public String getOffOn(Player player) { - return getOffOn(player.isOnline()); + return getOffOn(player.isOnline()); } public String getOffOn(boolean state) { - return state ? LC.info_variables_Online.getLocale() : LC.info_variables_Offline.getLocale(); + return state ? LC.info_variables_Online.getLocale() : LC.info_variables_Offline.getLocale(); } public void save(Player player) { } public Player getTarget(CommandSender sender, String playerName, Object cmd, boolean checkOrther, boolean inform) { - return getTarget(sender, playerName, cmd.getClass().getSimpleName(), checkOrther, inform); + return getTarget(sender, playerName, cmd.getClass().getSimpleName(), checkOrther, inform); } public Player getTarget(CommandSender sender, String playerName, Object cmd) { - return getTarget(sender, playerName, cmd.getClass().getSimpleName(), true); + return getTarget(sender, playerName, cmd.getClass().getSimpleName(), true); } public Player getTarget(CommandSender sender, String playerName, Object cmd, boolean checkOrther) { - return getTarget(sender, playerName, cmd.getClass().getSimpleName(), checkOrther); + return getTarget(sender, playerName, cmd.getClass().getSimpleName(), checkOrther); } public Player getTarget(CommandSender sender, String playerName, String cmd) { - return getTarget(sender, playerName, cmd, true); + return getTarget(sender, playerName, cmd, true); } public Player getTarget(CommandSender sender, String playerName, String cmd, boolean checkOther) { - return getTarget(sender, playerName, cmd, checkOther, true); + return getTarget(sender, playerName, cmd, checkOther, true); } public Player getTarget(CommandSender sender, String playerName, String cmd, boolean checkOther, boolean inform) { - CMIUser user = getUser(sender, playerName, cmd, inform, checkOther); - if (user == null) - return null; - return user.getPlayer(); + CMIUser user = getUser(sender, playerName, cmd, inform, checkOther); + if (user == null) + return null; + return user.getPlayer(); } public CMIUser getUser(CommandSender sender, String playerName, Object cmd, boolean inform, boolean checkOther) { - return getUser(sender, playerName, cmd.getClass().getSimpleName(), inform, checkOther); + return getUser(sender, playerName, cmd.getClass().getSimpleName(), inform, checkOther); } public CMIUser getUser(CommandSender sender, String playerName, Object cmd) { - return getUser(sender, playerName, cmd.getClass().getSimpleName(), true, true); + return getUser(sender, playerName, cmd.getClass().getSimpleName(), true, true); } public CMIUser getUser(CommandSender sender, String playerName, Object cmd, boolean checkOther) { - return getUser(sender, playerName, cmd.getClass().getSimpleName(), true, checkOther); + return getUser(sender, playerName, cmd.getClass().getSimpleName(), true, checkOther); } public CMIUser getUser(CommandSender sender, String playerName, String cmd) { - return getUser(sender, playerName, cmd, true, true); + return getUser(sender, playerName, cmd, true, true); } public CMIUser getUser(CommandSender sender, String playerName, String cmd, boolean inform, boolean checkOther) { - return getUser(sender, playerName, cmd, inform, checkOther, true); + return getUser(sender, playerName, cmd, inform, checkOther, true); } public CMIUser getUser(CommandSender sender, String playerName, String cmd, boolean inform, boolean checkOther, boolean informOnPerm) { - CMIUser user = null; - - return user; + return null; } public Player getPlayer(String playerName) { - - return null; + return null; } public void info(Object c, CMIUser user, String path, Object... variables) { } public void info(Class c, Player player, String path, Object... variables) { + info(c.getSimpleName(), player, path, variables); } public void info(Object c, Player player, String path, Object... variables) { + info(c.getClass().getSimpleName(), player, path, variables); } public void info(Object thi, CommandSender sender, String path, Object... variables) { + info(thi.getClass().getSimpleName(), sender, path, variables); } public void info(String c, CommandSender sender, String path, Object... variables) { @@ -839,143 +838,142 @@ public void info(String c, Player player, String path, Object... variables) { } public String getIM(Class c, String path, Object... variables) { - return getIM(c.getSimpleName(), path, variables); + return getIM(c.getSimpleName(), path, variables); } public String getIM(Object c, String path, Object... variables) { - return getIM(c.getClass().getSimpleName(), path, variables); + return getIM(c.getClass().getSimpleName(), path, variables); } public String getIM(String cmd, String path, Object... variables) { - return getLM().getMessage("command." + cmd + ".info." + path, variables); + return getLM().getMessage("command." + cmd + ".info." + path, variables); } public List getIML(String cmd, String path, Object... variables) { - return getLM().getMessageList("command." + cmd + ".info." + path, variables); + return getLM().getMessageList("command." + cmd + ".info." + path, variables); } public List getIML(Object c, String path, Object... variables) { - return getIML(c.getClass().getSimpleName(), path, variables); + return getIML(c.getClass().getSimpleName(), path, variables); + } + + public List getIML(Class c, String path, Object... variables) { + return getIML(c.getSimpleName(), path, variables); } public void sendMessage(Object sender, LC lc, Object... variables) { - + } public void sendMessage(Object sender, String msg) { - sendMessage(sender, msg, true); + sendMessage(sender, msg, true); } public void sendMessage(Object sender, String msg, boolean updateSnd) { - sendMessage(sender, msg, updateSnd, true); + sendMessage(sender, msg, updateSnd, true); } public void sendMessage(Object sender, String msg, boolean updateSnd, boolean translateColors) { - sendMessage(sender, msg, updateSnd, translateColors, true); + sendMessage(sender, msg, updateSnd, translateColors, true); } public void sendMessage(Object sender, String msg, boolean updateSnd, boolean translateColors, boolean translatePlaceholders) { - + } public int broadcastMessage(String msg) { - return broadcastMessage(null, msg, false, null, null); + return broadcastMessage(null, msg, false, null, null); } public int broadcastMessage(CommandSender sender, String msg) { - return broadcastMessage(sender, msg, true, null, null); + return broadcastMessage(sender, msg, true, null, null); } public int broadcastMessage(CommandSender sender, CMIPerm perm, String msg) { - return broadcastMessage(sender, msg, true, perm, null); + return broadcastMessage(sender, msg, true, perm, null); } public int broadcastMessage(CommandSender sender, String msg, boolean showForsender) { - return broadcastMessage(sender, msg, showForsender, null, null); + return broadcastMessage(sender, msg, showForsender, null, null); } public int broadcastMessage(CommandSender sender, String msg, boolean showForsender, Set ignorePlayers) { - return broadcastMessage(sender, msg, showForsender, null, ignorePlayers); + return broadcastMessage(sender, msg, showForsender, null, ignorePlayers); } public int broadcastMessage(CommandSender sender, String msg, boolean showForsender, CMIPerm perm, Set ignorePlayers) { - int i = 0; - - return i; + return 0; } public String getMsg(LC lc, Object... variables) { - return lc.getLocale(variables); + return lc.getLocale(variables); } public boolean isUseProtocollib() { - return useProtocollib; + return useProtocollib; } public boolean isPlayerVaultEnabled() { - return PlayerVaultEnabled; + return PlayerVaultEnabled; } public boolean isPlayerVaultXEnabled() { - return PlayerVaultXEnabled; + return PlayerVaultXEnabled; } public boolean isPlayerVaultNBTEnabled() { - return PlayerVaultNBTEnabled; + return PlayerVaultNBTEnabled; } public boolean isPlaceholderAPIEnabled() { - return PlaceholderAPIEnabled; + return PlaceholderAPIEnabled; } public Placeholder getPlaceholderAPIManager() { - if (Placeholder == null) - Placeholder = new Placeholder(this); - return Placeholder; + if (Placeholder == null) + Placeholder = new Placeholder(this); + return Placeholder; } public long getTimer() { - return timer; + return timer; } public void setTimer(long timer) { - this.timer = timer; + this.timer = timer; } public boolean isVaultPermEnabled() { - return VaultPermEnabled; + return VaultPermEnabled; } public Permission getPerms() { - return perms; + return perms; } public TabComplete getTab() { - return tab; + return tab; } public void setUseProtocollib(boolean b) { - useProtocollib = b; + useProtocollib = b; } -// public void ShowPagination(CommandSender sender, int pageCount, int CurrentPage, String cmd) { -// ShowPagination(sender, pageCount, CurrentPage, cmd, null); -// } - public void ShowPagination(CommandSender sender, PageInfo pi, String cmd) { - ShowPagination(sender, pi, cmd, null); + ShowPagination(sender, pi, cmd, null); } public void ShowPagination(CommandSender sender, PageInfo pi, Object cmd, String pagePref) { - ShowPagination(sender, pi.getTotalPages(), pi.getCurrentPage(), pi.getTotalEntries(), getCommandManager().getLabel() + " " + cmd.getClass().getSimpleName(), pagePref); + + ShowPagination(sender, pi.getTotalPages(), pi.getCurrentPage(), pi.getTotalEntries(), CommandsHandler.getLabel() + " " + cmd.getClass().getSimpleName(), pagePref); } public void ShowPagination(CommandSender sender, PageInfo pi, String cmd, String pagePref) { - ShowPagination(sender, pi.getTotalPages(), pi.getCurrentPage(), pi.getTotalEntries(), cmd, pagePref); + ShowPagination(sender, pi.getTotalPages(), pi.getCurrentPage(), pi.getTotalEntries(), cmd, pagePref); } public void ShowPagination(CommandSender sender, int pageCount, int CurrentPage, int totalEntries, String cmd, String pagePref) { - + } public void ShowPagination(Set players, int pageCount, int CurrentPage, int totalEntries, String cmd, String pagePref) { @@ -987,67 +985,67 @@ public void autoPagination(CommandSender sender, PageInfo pi, String cmd, String } public int getViewRange(World world) { - int view = Bukkit.getServer().getViewDistance(); - - return view; + int view = Bukkit.getServer().getViewDistance(); + return view; } public boolean isMcmmoexpmodulepresent() { - return mcmmoexpmodulepresent; + return mcmmoexpmodulepresent; } public boolean isJobsPresent() { - return jobsPresent; + return jobsPresent; } public void performCommand(CommandSender sender, Object cls) { - performCommand(sender, cls, ""); + performCommand(sender, cls, ""); } public void performCommand(CommandSender sender, Object cls, String cmd) { + cmd = CommandsHandler.getLabel() + " " + cls.getClass().getSimpleName() + (cmd.isEmpty() ? "" : " " + cmd); + performCommand(sender, cmd); } public void performCommand(CommandSender sender, String cmd) { - } public boolean isVotifierEnabled() { - return VotifierEnabled; + return VotifierEnabled; } public boolean isFullyLoaded() { - return fullyLoaded; + return fullyLoaded; } public boolean isCitizensEnabled() { - return CitizensEnabled; + return CitizensEnabled; } public boolean isNCPEnabled() { - return NCPEnabled; + return NCPEnabled; } public boolean isMVdWPlaceholderAPIEnabled() { - return MVdWPlaceholderAPIEnabled; + return MVdWPlaceholderAPIEnabled; } public void setFullyLoaded(boolean fullyLoaded) { - this.fullyLoaded = fullyLoaded; + this.fullyLoaded = fullyLoaded; } public UUID getServerUUID() { - return ServerUUID; + return ServerUUID; } public int getLastCMILibVersion() { - return lastCMILibVersion; + return lastCMILibVersion; } public int getRequiredCMILibVersion() { - return requiredCMILibVersion; + return requiredCMILibVersion; } public long getServerStartupTime() { - return serverStartupTime; + return serverStartupTime; } } diff --git a/src/com/Zrips/CMI/Config.java b/src/com/Zrips/CMI/Config.java index 6aae75f..f756244 100644 --- a/src/com/Zrips/CMI/Config.java +++ b/src/com/Zrips/CMI/Config.java @@ -2,6 +2,7 @@ import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.jar.JarFile; @@ -15,15 +16,15 @@ import org.bukkit.entity.EntityType; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.inventory.ItemStack; +import com.Zrips.CMI.Containers.CommandAlias; import com.Zrips.CMI.Containers.DamageControl; import com.Zrips.CMI.Containers.RandomTeleport; import com.Zrips.CMI.Modules.ChatFilter.ChatFilterRule; import com.Zrips.CMI.Modules.CustomText.CText; -import com.Zrips.CMI.Modules.Kits.KitsManager.CMIKitGUILayout; import com.Zrips.CMI.Modules.tp.TpManager.TpAction; +import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Container.CMILocation; import net.Zrips.CMILib.Effects.CMIEffectManager.CMIParticle; import net.Zrips.CMILib.FileHandler.ConfigReader; @@ -39,6 +40,7 @@ public class Config { public boolean CheckForNameChangeOnLogin = true; public boolean PerformCommandsOnNewName = false; private List OptimizationsNameChangeCommands = new ArrayList(); + private List signEditBlackList = new ArrayList(); private HashMap FlyAboveRoofLimitationsMap = new HashMap(); public int CheckForNameChangeAmountToShow = 3; public boolean CheckForNameChangeOnInfoShow = true; @@ -67,6 +69,7 @@ public class Config { private List fixWorldsToFix = new ArrayList(); public boolean hungeroveride = false; public String Lang = "EN"; + public boolean LanguageDownload = true; public static boolean monochromeConsole = false; public static int ImmortalityOnJoin = 3; @@ -81,9 +84,11 @@ public class Config { private List ItemLoreTypeBlackList = new ArrayList(); private boolean ItemNameMarkChanged = false; private boolean ItemLoreMarkChanged = false; + public static int ItemLoreMaxLength = 64; private boolean CMIPlayTimeTracking = false; public static List PlaytimeTopExclude = new ArrayList(); + public static long PlaytimeTopOffline = 0; private boolean RepairShareProtectNormalRepair = false; private boolean RepairShareProtectCommandRepair = false; @@ -106,6 +111,7 @@ public class Config { private boolean PreventBedExplosionNether = true; private boolean PreventBedExplosionTheEnd = true; private boolean PreventPlayersOnNetherRoof = true; + private int netherRoofHeight = 0; private boolean PreventPlayersBelowBedrock = true; private boolean PreventIronGolemRoses = false; @@ -113,6 +119,8 @@ public class Config { private boolean PreventHook = false; public static int NearDefaultDistance = 200; public static boolean NearCommand = false; + public static boolean NearHideInvisible = false; + public static boolean NearHideObfuscate = false; public static boolean NearDirection = true; public static int NearCommandCount = 10; private boolean MulticraftDisableList = false; @@ -145,7 +153,10 @@ public class Config { public int TeleportTpaTime; private boolean TeleportSwitchPlaces; - private boolean TeleportCurrentLoc; + + private boolean TpaCurrentLoc; + private boolean TpahereCurrentLoc; + private int TeleportJumpDefault; // private boolean TeleportVehicleWorkArround; public boolean SafeLocationDownThenUp; @@ -167,8 +178,9 @@ public class Config { private HashMap ItemRenamingPreventMap = new HashMap(); public static boolean ItemRenamingGlobalDisable = false; + public static int ItemRenamingMaxLength = 64; - private HashMap randomTeleports = new HashMap(); + private HashMap randomTeleports = new HashMap(); private int randomTeleportCooldown = 3; private int randomTeleportMaxTries = 10; private List randomTeleportExcludedBiomes = new ArrayList(); @@ -183,10 +195,19 @@ public class Config { public boolean LogoutDisabled = false; public boolean LoginCustomUse = false; public boolean LogoutCustomUse = false; + public boolean LogoutServerSwitch = false; + public boolean LoginServerSwitch = false; public boolean FirstJoinMessageUse = false; + + public static boolean loginNameFilterUse = false; + public static boolean logoutNameFilterUse = false; + + public static ChatFilterRule loginLogoutNameFilter = new ChatFilterRule(); + private int LogoutAutoHideFrom = -1; private int LoginAutoHideFrom = -1; - private int DeathMessageAutoHideFrom = -1; + +// private int DeathMessageAutoHideFrom = -1; private boolean NotesShowOnAlertEvent = true; public static long alertTimer = 1440; @@ -269,6 +290,7 @@ public class Config { private List BackBlackList = new ArrayList(); public boolean hatIgnoreLored = false; + public boolean hatBlockArmorItems = false; public boolean RemoveNegative = false; public List RemoveNegativeEffects = new ArrayList(); @@ -328,6 +350,7 @@ public class Config { private boolean ModifyChatFormat = false; private boolean ChatClickHoverMessages = false; public static boolean ChatDiscordSRV = false; + public static boolean DiscordSRVRanged = true; public static String ChatDiscordSRVGlobalChannel = "global"; // private boolean ChatDiscordSRVChangeIncomming = false; public static String DiscordSRVLabel = ""; @@ -343,10 +366,12 @@ public class Config { // public static boolean SleepingDisableVanillaMessage = false; public static boolean SleepingOnlyDurringNight, SleepingSpeedup, SleepingExcludeAfk, SleepingPercentage, SleepingInform; public static int SleepingBaseSpeed, SleepingInformDelay, - SleepingMinBeforeSpeeding, SleepingMinSpeed; + SleepingMinBeforeSpeeding, SleepingMinSpeed; private boolean CompassBossBar = false; - public static boolean CompassDefaultState = false; +// public static boolean CompassDefaultState = false; private boolean CompassRequireCompass = false; + private boolean recoveryRequireCompass = false; + private boolean recoveryAsRegularCompass = false; private int CompassUpdateInterval = 200; private String CompassShape; private String CompassColor; @@ -365,17 +390,16 @@ public class Config { private int PlayerMailExpiresIn = 30; private int PlayerMailAllDays = 30; - private int DisposeUILines = 4; - - private boolean KitsGUI = true; - private boolean KitsGUIFillEmptyFields = true; - private CMIItemStack GUIEmptyField = null; + public int DisposeUILines = 4; + public boolean DisposeCustomModelData = true; + public boolean DisposeAttachedCommands = true; private ConfigReader localeFile = null; private ConfigReader cfg = null; public static ChatFilterRule InteractiveCommandsSignRegex = new ChatFilterRule(); public static boolean InteractiveCommandsSort = true; + public static boolean UseFakeOperator = true; public static boolean ShowSkullOwner = true; public static boolean ShowBeeHive = true; @@ -385,654 +409,628 @@ public class Config { public static boolean DisableTeamManagement = false; private boolean AutoDownloadGeoIp = true; private boolean AutoDownloadGeoLiteCity = true; - private boolean ArmorStandsCheckBlockPlace = true; + private String maintenanceMessage = null; public static Boolean maintenanceBossbar = null; public static Boolean maintenanceAutoKick = null; - HashMap kitButtons = new HashMap(); - private CMI plugin; public Config(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void ChangeConfig(String path, Object list) { - ChangeConfig(path, list, true); + ChangeConfig(path, list, true); } public void ChangeConfig(String path, Object list, boolean load) { - } private static void newLn(StringBuilder header) { - header.append(System.lineSeparator()); + header.append(System.lineSeparator()); } private static StringBuilder formStringBuilder(List list) { - StringBuilder header = new StringBuilder(); - for (String one : list) { - newLn(header); - header.append(one); - } - return header; + StringBuilder header = new StringBuilder(); + return header; } // Language file public boolean LoadLang(String lang) { - return LoadLang(lang, false); + return LoadLang(lang, false); } public boolean LoadLang(String lang, boolean isReload) { - return true; + + return true; } public boolean load() { - return load(false); + return load(false); } - public boolean load(boolean isReload) { - return true; + public boolean load(boolean isReload) { + return true; } private void allias(String cmd, String cmiCmd, boolean enabled) { + plugin.getAliasManager().addDefault(new CommandAlias(cmd, Arrays.asList("cmi " + cmiCmd + " $1-"), cfg.getC().getBoolean("Alias." + cmd, enabled))); } private static DamageCause getCause(String name) { - return null; + return null; } public static List getClassesFromPackage(String pckgname, String cleaner) throws ClassNotFoundException { - List result = new ArrayList(); - - return result; + List result = new ArrayList(); + return result; } private static List getClassesInSamePackageFromJar(String packageName, String jarPath, String cleaner) { - JarFile jarFile = null; - List listOfCommands = new ArrayList(); - - return listOfCommands; + JarFile jarFile = null; + List listOfCommands = new ArrayList(); + + return listOfCommands; } - public void reload(CommandSender player) { + public void reload(CommandSender sender) { + } public boolean reloadLanguage() { - boolean langLoaded = LoadLang("EN", true); - return langLoaded; + boolean langLoaded = LoadLang("EN", true); + return langLoaded; } -// public Location getSpawnPoint() { -// return spawnPoint; -// } -// -// public boolean isRespawnLocation() { -// return RespawnLocation; -// } - public Location getFirstSpawnPoint() { - return firstSpawnPoint == null ? null : firstSpawnPoint.clone(); + return firstSpawnPoint == null ? null : firstSpawnPoint.clone(); } public boolean isModifyChatFormat() { - return ModifyChatFormat; + return ModifyChatFormat; } public boolean isChatClickHoverMessages() { - return ChatClickHoverMessages; + return ChatClickHoverMessages; } public boolean isColorsPublicMessages() { - return ColorsPublicMessages; + return ColorsPublicMessages; } public boolean isColorsPrivateMessage() { - return ColorsPrivateMessage; + return ColorsPrivateMessage; } public ConfigReader getConfig() { - return cfg; + return cfg; } public long getPlayerNotesExpiresIn() { - return PlayerNotesExpiresIn * 24L * 60L * 60L * 1000L; + return PlayerNotesExpiresIn * 24L * 60L * 60L * 1000L; } public long getPlayerMailExpiresIn() { - return PlayerMailExpiresIn * 24L * 60L * 60L * 1000L; - } - - public boolean isKitsGUI() { - return KitsGUI; - } - - public boolean isKitsGUIFillEmptyFields() { - return KitsGUIFillEmptyFields; + return PlayerMailExpiresIn * 24L * 60L * 60L * 1000L; } public HashMap getBlockedItems() { - return blockedItems; + return blockedItems; } public Boolean isBlackListedItemsEnabledFor(TpAction action) { - if (!BlackListedItemsEnabledFor.containsKey(action)) - return false; - return BlackListedItemsEnabledFor.get(action); + if (!BlackListedItemsEnabledFor.containsKey(action)) + return false; + return BlackListedItemsEnabledFor.get(action); } -// public Boolean isCustomAliasEnabled() { -// return customAlias; -// } - @Deprecated public boolean isDurabilityLossUse() { - return isToolDurabilityLossUse(); + return isToolDurabilityLossUse(); } public boolean isToolDurabilityLossUse() { - return durabilityLossUse; + return durabilityLossUse; } @Deprecated public int getDurabilityLossPercentage() { - return getToolDurabilityLossPercentage(); + return getToolDurabilityLossPercentage(); } public int getToolDurabilityLossPercentage() { - return durabilityLossPercentage; + return durabilityLossPercentage; } public HashMap getItemRenamingPreventMap() { - return ItemRenamingPreventMap; + return ItemRenamingPreventMap; } public boolean isTeleportSwitchPlaces() { - return TeleportSwitchPlaces; + return TeleportSwitchPlaces; } public boolean isOnLimitedItemUseInform() { - return OnLimitedItemUseInform; + return OnLimitedItemUseInform; } public boolean isRepairShareProtectNormalRepair() { - return RepairShareProtectNormalRepair; + return RepairShareProtectNormalRepair; } public int getRepairShareDurability() { - return RepairShareDurability; + return RepairShareDurability; } public boolean isRepairShareAddLore() { - return RepairShareAddLore; + return RepairShareAddLore; } public boolean isRepairShareCancelEvent() { - return RepairShareCancelEvent; + return RepairShareCancelEvent; } public boolean isRepairShareInformWithMessage() { - return RepairShareInformWithMessage; + return RepairShareInformWithMessage; } public boolean isRepairShareProtectCommandRepair() { - return RepairShareProtectCommandRepair; - } - - public int getDisposeUILines() { - return DisposeUILines; + return RepairShareProtectCommandRepair; } public int getMaxHp() { - return MaxHp > 2048 ? 2048 : MaxHp; + return MaxHp > 2048 ? 2048 : MaxHp; } public boolean isNotesShowOnAlertEvent() { - return NotesShowOnAlertEvent; + return NotesShowOnAlertEvent; } public boolean isRepairShareBypassWithPerm() { - return RepairShareBypassWithPerm; + return RepairShareBypassWithPerm; } public boolean isPreventExpPortals() { - return PreventExpPortals; + return PreventExpPortals; } public ConfigReader getLocaleConfig() { - return localeFile; + return localeFile; } public boolean isDisableWorldChunkCheckInfo() { - return DisableWorldChunkCheckInfo; + return DisableWorldChunkCheckInfo; } public boolean isPreventEntityBoatEnterAnimals() { - return PreventEntityBoatEnterAnimals; + return PreventEntityBoatEnterAnimals; } public boolean isPreventEntityBoatEnterMonsters() { - return PreventEntityBoatEnterMonsters; + return PreventEntityBoatEnterMonsters; } public boolean isPreventBedExplosionNether() { - return PreventBedExplosionNether; + return PreventBedExplosionNether; } public boolean isPreventIronGolemRoses() { - return PreventIronGolemRoses; + return PreventIronGolemRoses; } public boolean isMulticraftDisableList() { - return MulticraftDisableList; + return MulticraftDisableList; } public boolean isPreventBedExplosionTheEnd() { - return PreventBedExplosionTheEnd; + return PreventBedExplosionTheEnd; } public int getVisualizerSidesCap() { - return 1000; + return 1000; } public int getVisualizerFrameCap() { - return 1000; + return 1000; } public CMIParticle getSelectedSpigotSides() { - return CMIParticle.COLOURED_DUST; -// return null; + return CMIParticle.COLOURED_DUST; } public CMIParticle getSelectedSpigotFrame() { - return CMIParticle.HAPPY_VILLAGER; -// return null; + return CMIParticle.HAPPY_VILLAGER; } public long getVisualizerShowFor() { - return 60 * 1000L; + return 60 * 1000L; } public long getVisualizerUpdateInterval() { - return 10L; + return 10L; } public CMIItemStack getSelectionTool() { - return SelectionTool; + return SelectionTool; } - public CMIItemStack getGUIEmptyField() { - return GUIEmptyField; - } public boolean isNetherPortalPreventCreation() { - return NetherPortalPreventCreation; + return NetherPortalPreventCreation; } public boolean isMaintenance() { - return maintenance; + return maintenance; } public void setMaintenance(boolean maintenance) { - ChangeConfig("Optimizations.Maintenance", maintenance, false); - this.maintenance = maintenance; + ChangeConfig("Optimizations.Maintenance", maintenance, false); + this.maintenance = maintenance; } public String getMaintenanceMessage() { - return maintenanceMessage; + return maintenanceMessage; } public void setMaintenanceMessage(String maintenanceMessage) { - this.maintenanceMessage = maintenanceMessage; + this.maintenanceMessage = maintenanceMessage; } public boolean isOverrideLoginMessage() { - return OverrideLoginMessage; + return OverrideLoginMessage; } public CText getMotd() { - return Motd; + return Motd; } public boolean isPermisionOnError() { - return PermisionOnError; + return PermisionOnError; } public boolean isChatIgnorePublicMessage() { - return ChatIgnorePublicMessage; + return ChatIgnorePublicMessage; } public List getFixWorldsToFix() { - return fixWorldsToFix; + return fixWorldsToFix; } public List getCommandSpyBlackListed() { - return CommandSpyBlackListed; + return CommandSpyBlackListed; } public int getSpyDelayForTrigger() { - return SpyDelayForTrigger; + return SpyDelayForTrigger; } public int getTeleportTpaWarmup() { - return TeleportTpaWarmup; + return TeleportTpaWarmup; } public boolean isTeleportTpaMove() { - return TeleportTpaMove; + return TeleportTpaMove; } public boolean isOptimizationsCommandSorting() { - return OptimizationsCommandSorting; + return OptimizationsCommandSorting; } public boolean isPreventPlayersOnNetherRoof() { - return PreventPlayersOnNetherRoof; + return PreventPlayersOnNetherRoof; } public boolean isPreventPlayersBelowBedrock() { - return PreventPlayersBelowBedrock; + return PreventPlayersBelowBedrock; } public boolean isBossBarHpBarEnabled() { - return BossBarHpBarEnabled; + return BossBarHpBarEnabled; } public List getGroundCleanWhiteList() { - return GroundCleanWhiteList; + return GroundCleanWhiteList; } public boolean isPartialPlayerName() { - return PartialPlayerName; + return PartialPlayerName; } public boolean isOptimizationsCommandRemoveLabel() { - return OptimizationsCommandRemoveLabel; + return OptimizationsCommandRemoveLabel; } public boolean isBlockedSpawnReason(String worldName, SpawnReason reason) { - List reaons = blockedSpawnReasons.get(worldName); - if (reaons == null) - return false; - return reaons.contains(reason); + List reaons = blockedSpawnReasons.get(worldName); + if (reaons == null) + return false; + return reaons.contains(reason); } public boolean isPreventHook() { - return PreventHook; + return PreventHook; } public List getCleanUpWhiteList() { - return cleanUpWhiteList; + return cleanUpWhiteList; } public CMIParticle getPointDefaultParticle() { - return PointDefaultParticle; + return PointDefaultParticle; } public boolean isPermisionInConsole() { - return PermisionInConsole; + return PermisionInConsole; } public boolean isSellLog() { - return SellLog; + return SellLog; } public boolean isSpawnersSupportDisabled() { - return SpawnersSupportDisabled; + return SpawnersSupportDisabled; + } + + public boolean isTpaCurrentLoc() { + return TpaCurrentLoc; } - public boolean isTeleportCurrentLoc() { - return TeleportCurrentLoc; + public boolean isTpahereCurrentLoc() { + return TpahereCurrentLoc; } public int getTeleportJumpDefault() { - return TeleportJumpDefault; + return TeleportJumpDefault; } public String getBooksDefaultAuthor() { - return BooksDefaultAuthor; + return BooksDefaultAuthor; } public boolean isChatReplyToLastMessenger() { - return ChatReplyToLastMessenger; + return ChatReplyToLastMessenger; } public int getLastMessengerTimeOut() { - return LastMessengerTimeOut; + return LastMessengerTimeOut; } public List getCommandSpyCommandList() { - return CommandSpyCommandList; + return CommandSpyCommandList; } public boolean isCMIPlayTimeTracking() { - return CMIPlayTimeTracking; + return CMIPlayTimeTracking; } public void setCMIPlayTimeTracking(boolean cMIPlayTimeTracking) { - CMIPlayTimeTracking = cMIPlayTimeTracking; + CMIPlayTimeTracking = cMIPlayTimeTracking; } public int getBackMinDistance() { - return BackMinDistance; + return BackMinDistance; } public boolean isColorsMe() { - return ColorsMe; + return ColorsMe; } public int getPlayerMailAllDays() { - return PlayerMailAllDays; + return PlayerMailAllDays; } public String getElevatorIndicator() { - return ElevatorIndicator; + return ElevatorIndicator; } public String getElevatorStaticIndicator() { - return ElevatorStaticIndicator; + return ElevatorStaticIndicator; } public boolean isSpawnersXpDrop() { - return SpawnersXpDrop; + return SpawnersXpDrop; } public boolean isSafeLocationDownThenUp() { - return SafeLocationDownThenUp; + return SafeLocationDownThenUp; } public int getLogoutAutoHideFrom() { - return LogoutAutoHideFrom; + return LogoutAutoHideFrom; } public int getLoginAutoHideFrom() { - return LoginAutoHideFrom; - } - - public int getDeathMessageAutoHideFrom() { - return DeathMessageAutoHideFrom; + return LoginAutoHideFrom; } public boolean isAutoDownloadGeoIp() { - return AutoDownloadGeoIp; + return AutoDownloadGeoIp; } public boolean isAutoDownloadGeoLiteCity() { - return AutoDownloadGeoLiteCity; + return AutoDownloadGeoLiteCity; } public boolean isChatDynMapChat() { - return ChatDynMapChat; + return ChatDynMapChat; } public boolean isPreloadTopPlaytime() { - return PreloadTopPlaytime; + return PreloadTopPlaytime; } public List getOptimizationsNameChangeCommands() { - return OptimizationsNameChangeCommands; + return OptimizationsNameChangeCommands; } public boolean isElytraPreventSelfDamage() { - return ElytraPreventSelfDamage; + return ElytraPreventSelfDamage; } public boolean isFlyAboveRoof() { - return FlyAboveRoof; + return FlyAboveRoof; } public int getOptimizationsSimilarCommandChecker() { - return OptimizationsSimilarCommandChecker; + return OptimizationsSimilarCommandChecker; } public HashMap getFlyAboveRoofLimitationsMap() { - return FlyAboveRoofLimitationsMap; + return FlyAboveRoofLimitationsMap; } public String getLongDateFormat() { - return LongDateFormat; + return LongDateFormat; } public String getShortDateFormat() { - return ShortDateFormat; + return ShortDateFormat; } public boolean isAutoTimeSmooth() { - return AutoTimeSmooth; + return AutoTimeSmooth; } public int getAutoTimeSmoothSpeed() { - return AutoTimeSmoothSpeed; + return AutoTimeSmoothSpeed; } public boolean isBossBarCompassEnabled() { - return CompassBossBar; - } - - public CMIItemStack getKitPreviewIcon(CMIKitGUILayout type) { - return kitButtons.get(type) == null ? new CMIItemStack(new ItemStack(Material.STONE)) : kitButtons.get(type); + return CompassBossBar; } public String getSleepingSpeedupInfoType() { - return SleepingSpeedupInfoType; + return SleepingSpeedupInfoType; } public List getHpBarBlackList() { - return HpBarBlackList; + return HpBarBlackList; } public boolean isCompassRequireCompass() { - return CompassRequireCompass; + return CompassRequireCompass; } public int getCompassUpdateInterval() { - return CompassUpdateInterval; + return CompassUpdateInterval; } public RandomTeleport getRandomTeleport(World w) { - return getRandomTeleport(w, false); + return getRandomTeleport(w, false); } public RandomTeleport getRandomTeleport(World w, boolean includeDisabled) { - RandomTeleport rt = randomTeleports.get(w); - return rt == null ? null : randomTeleports.get(w).isEnabled() ? rt : includeDisabled ? rt : null; + RandomTeleport rt = randomTeleports.get(w.getName()); + return rt == null ? null : rt.isEnabled() && rt.getCenter().getWorld() != null ? rt : includeDisabled ? rt : null; } - public HashMap getRandomTeleports() { - return randomTeleports; + public HashMap getRandomTeleports() { + return randomTeleports; } public int getRandomTeleportMaxTries() { - return randomTeleportMaxTries; + return randomTeleportMaxTries; } public int getRandomTeleportCooldown() { - return randomTeleportCooldown; + return randomTeleportCooldown; } public List getRandomTeleportExcludedBiomes() { - return randomTeleportExcludedBiomes; + return randomTeleportExcludedBiomes; } public List getItemLoreTypeBlackList() { - return ItemLoreTypeBlackList; + return ItemLoreTypeBlackList; } public boolean isDisableRiptide() { - return disableRiptide; + return disableRiptide; } public boolean isOptimizationsSimilarCommandPrevention() { - return OptimizationsSimilarCommandPrevention; + return OptimizationsSimilarCommandPrevention; } public String getCompassShape() { - return CompassShape; + return CompassShape; } public String getCompassColor() { - return CompassColor; + return CompassColor; } public String getCompassHomeIcon() { - return CompassHomeIcon; + return CompassHomeIcon; } public String getCompassSpawnIcon() { - return CompassSpawnIcon; + return CompassSpawnIcon; } public String getCompassDeathIcon() { - return CompassDeathIcon; + return CompassDeathIcon; } public String getCompassTargetIcon() { - return CompassTargetIcon; - } - - public boolean isArmorStandsCheckBlockPlace() { - return ArmorStandsCheckBlockPlace; + return CompassTargetIcon; } public List getBackBlackList() { - return BackBlackList; + return BackBlackList; } public boolean isPotionEffectsDeductWhileOffline() { - return PotionEffectsDeductWhileOffline; + return PotionEffectsDeductWhileOffline; } public boolean isPreventEntityBoatEnterVillagers() { - return PreventEntityBoatEnterVillagers; + return PreventEntityBoatEnterVillagers; } public int getArmorDurabilityLossPercentage() { - return armorDurabilityLossPercentage; + return armorDurabilityLossPercentage; } public void setArmorDurabilityLossPercentage(int armorDurabilityLossPercentage) { - this.armorDurabilityLossPercentage = armorDurabilityLossPercentage; + this.armorDurabilityLossPercentage = armorDurabilityLossPercentage; } public boolean isArmorDurabilityLossUse() { - return armorDurabilityLossUse; + return armorDurabilityLossUse; } public void setArmorDurabilityLossUse(boolean armorDurabilityLossUse) { - this.armorDurabilityLossUse = armorDurabilityLossUse; + this.armorDurabilityLossUse = armorDurabilityLossUse; } public boolean isItemNameMarkChanged() { - return ItemNameMarkChanged; + return ItemNameMarkChanged; } public boolean isItemLoreMarkChanged() { - return ItemLoreMarkChanged; + return ItemLoreMarkChanged; } public boolean isShowNewVersion() { - return ShowNewVersion; + return ShowNewVersion; + } + + public boolean isSignEditBlocked(String line) { + return signEditBlackList.contains(CMIChatColor.stripColor(line).toLowerCase()); + } + + public boolean isRecoveryRequireCompass() { + return recoveryRequireCompass; + } + + public boolean isRecoveryAsRegularCompass() { + return recoveryAsRegularCompass; + } + + public int getNetherRoofHeight() { + return netherRoofHeight; } } diff --git a/src/com/Zrips/CMI/Containers/CMIBanEntry.java b/src/com/Zrips/CMI/Containers/CMIBanEntry.java index 337e714..59e45ca 100644 --- a/src/com/Zrips/CMI/Containers/CMIBanEntry.java +++ b/src/com/Zrips/CMI/Containers/CMIBanEntry.java @@ -1,14 +1,10 @@ package com.Zrips.CMI.Containers; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; import org.bukkit.BanEntry; -import org.bukkit.BanList.Type; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.Time.CMITimeManager; +import net.Zrips.CMILib.Locale.LC; public class CMIBanEntry { @@ -19,78 +15,78 @@ public class CMIBanEntry { CMIUser banned = null; public CMIBanEntry(CMIUser baned) { - this.banned = baned; - createdOn = System.currentTimeMillis(); + this.banned = baned; + createdOn = System.currentTimeMillis(); } public Long getCreated() { - return createdOn; + return createdOn; } public Long getExpiration() { - return banUntil; + return banUntil; } public String getReason() { - return reason; + return reason; } public String getSource() { - if (bannedBy == null) - return CMI.getInstance().getMsg(LC.info_Console); - return bannedBy.getName(); + if (bannedBy == null) + return CMI.getInstance().getMsg(LC.info_Console); + return bannedBy.getName(); } public CMIUser getSourceUser() { - return bannedBy; + return bannedBy; } public String getTarget() { - return banned.getName(); + return banned.getName(); } public CMIUser getTargetUser() { - return banned; + return banned; } public void setCreated(Long date) { - createdOn = date; + createdOn = date; } public void setExpiration(Long date) { - if (date != null) - banUntil = date; - else - banUntil = -1L; + if (date != null) + banUntil = date; + else + banUntil = -1L; } public void setReason(String reason) { - this.reason = reason; + this.reason = reason; } public void setSource(CMIUser user) { - bannedBy = user; + bannedBy = user; } public boolean isPermanent() { - if (banUntil == null) - return false; - return banUntil == -1L; + if (banUntil == null) + return false; + return banUntil == -1L; } public Long getLeftTime() { - if (banUntil == null) - return null; - if (banUntil < System.currentTimeMillis()) - return 0L; - return banUntil - System.currentTimeMillis(); + if (banUntil == null) + return null; + if (banUntil < System.currentTimeMillis()) + return 0L; + return banUntil - System.currentTimeMillis(); } public static String getBanMessage(BanEntry banEntry) { - return ""; + return ""; } public static String getIpBanMessage(BanEntry banEntry) { - return ""; + return ""; } } diff --git a/src/com/Zrips/CMI/Containers/CMIBlock.java b/src/com/Zrips/CMI/Containers/CMIBlock.java deleted file mode 100644 index 5a66c1c..0000000 --- a/src/com/Zrips/CMI/Containers/CMIBlock.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.Zrips.CMI.Containers; - -import org.bukkit.Axis; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; - -public class CMIBlock { - public static enum blockDirection { - none(-1), upWest(0), upEast(1), upNorth(2), upSouth(3), downWest(4), downEast(5), downNorth(6), downSouth(7); - - private int dir; - - blockDirection(int dir) { - this.dir = dir; - } - - public int getDir() { - return dir; - } - - public static blockDirection getByDir(int dir) { - for (blockDirection one : blockDirection.values()) { - if (one.getDir() == dir) - return one; - } - return null; - } - } - - public static enum FlipDirection { - NORTH_SOUTH, - WEST_EAST, - UP_DOWN - } - - public static enum Bisect { - TOP, - BOTTOM - } - - public static enum BedPart { - HEAD, - FOOT - - } - - public static enum StairShape { - INNER_LEFT, - INNER_RIGHT, - OUTER_LEFT, - OUTER_RIGHT, - STRAIGHT; - - public static StairShape getByName(String name) { - for (StairShape one : StairShape.values()) { - if (one.toString().equalsIgnoreCase(name)) - return one; - } - return null; - } - } - - private Block block; - private Integer data = null; - private Object blockd = null; - - public CMIBlock(Block block) { - this.block = block; - } - - public Inventory getShulkerInv() { - return null; - - } - - @Deprecated - public blockDirection getDirection() { - - return blockDirection.getByDir(block.getData()) == null ? blockDirection.none : blockDirection.getByDir(block.getData()); - } - - public boolean isWaterlogged() { - - return false; - } - - public Bisect getBisect() { - - return null; - } - - public boolean isAttached() { - - return false; - } - - public Axis getAxis() { - - return null; - } - - public BedPart getBedPart() { - - return null; - } - - public StairShape getStairShape() { - - return null; - } - - public BlockFace getFacing() { - - return null; - } - - public CMIBlock flip(FlipDirection direction, boolean angle) { - - return this; - } - - public CMIBlock rotate90Reverse() { - - return this; - - } - - public CMIBlock rotate90() { - - return this; - } - - public Object getData() { - return data.byteValue(); - } - - public CMIBlock setData(Object data) { - return this; - } - - public boolean hasInventory() { - return block.getState() instanceof InventoryHolder; - } - - public Inventory getInventory() { - - return null; - } - - public Block getSecondaryBedBlock() { - - return null; - } - - public Block getBedFootBlock() { - - return null; - } -} diff --git a/src/com/Zrips/CMI/Containers/CMICollision.java b/src/com/Zrips/CMI/Containers/CMICollision.java index 6b51be2..172dd96 100644 --- a/src/com/Zrips/CMI/Containers/CMICollision.java +++ b/src/com/Zrips/CMI/Containers/CMICollision.java @@ -9,49 +9,45 @@ public class CMICollision { private Vector max; public CMICollision(CMIHitBox box) { - this(box.getMin(), box.getMax()); + this(box.getMin(), box.getMax()); } public CMICollision(Vector min, Vector max) { - this(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ()); + this(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ()); } public CMICollision(double x1, double y1, double z1, double x2, double y2, double z2) { - this.min = new Vector(Math.min(x1, x2), Math.min(y1, y2), Math.min(z1, z2)); - this.max = new Vector(Math.max(x1, x2), Math.max(y1, y2), Math.max(z1, z2)); + this.min = new Vector(Math.min(x1, x2), Math.min(y1, y2), Math.min(z1, z2)); + this.max = new Vector(Math.max(x1, x2), Math.max(y1, y2), Math.max(z1, z2)); } public Vector getMin() { - return min; + return min; } public Vector getMax() { - return max; + return max; } public double min(int i) { - return 0; - + return 0; } public double max(int i) { - return 0; + return 0; } public boolean collides(CMIRay ray, double tmin, double tmax) { - - return true; + return true; } public double collidesNearest(CMIRay ray, double tmin, double tmax) { - - return tmin; + return 0; } public boolean contains(Location location) { - - return true; + return true; } } diff --git a/src/com/Zrips/CMI/Containers/CMIDamageCause.java b/src/com/Zrips/CMI/Containers/CMIDamageCause.java index 36291a1..51b588a 100644 --- a/src/com/Zrips/CMI/Containers/CMIDamageCause.java +++ b/src/com/Zrips/CMI/Containers/CMIDamageCause.java @@ -37,39 +37,32 @@ public enum CMIDamageCause { static HashMap byName = new HashMap(); - static { - } - private String name = null; private String secondaryName = null; private DamageCause cause = null; CMIDamageCause() { - this(null, null); + this(null, null); } -// CMIDamageCause(String name) { -// this(name, null); -// } - CMIDamageCause(String name, String secondaryName) { - this.name = name; - this.secondaryName = secondaryName; + this.name = name; + this.secondaryName = secondaryName; } public String getName() { - return name; + return name; } public String getSecondaryName() { - return secondaryName; + return secondaryName; } public static CMIDamageCause getByName(String name) { - return byName.get(name.toLowerCase().replace("_", "")); + return byName.get(name.toLowerCase().replace("_", "")); } public DamageCause getCause() { - return cause; + return cause; } } diff --git a/src/com/Zrips/CMI/Containers/CMIDirection.java b/src/com/Zrips/CMI/Containers/CMIDirection.java index 3e32cfb..67c1958 100644 --- a/src/com/Zrips/CMI/Containers/CMIDirection.java +++ b/src/com/Zrips/CMI/Containers/CMIDirection.java @@ -9,7 +9,7 @@ public enum CMIDirection { N("North", 0, 0, -1), NE("North_East", 45, 1, -1), E("East", 90, 1, 0), SE("South_East", 135, 1, 1), S("South", 180, 0, 1), SW("South_West", 225, -1, 1), W("West", 270, -1, 0), NW("North_West", 315, - -1, 1); + -1, 1); private int angle; private String name; @@ -17,73 +17,73 @@ public enum CMIDirection { private int z = 0; CMIDirection(String name, int angle, int x, int z) { - this.name = name; - this.angle = angle; - this.x = x; - this.z = z; + this.name = name; + this.angle = angle; + this.x = x; + this.z = z; } CMIDirection(String name, int angle) { - this.name = name; - this.angle = angle; + this.name = name; + this.angle = angle; } public static CMIDirection getFromAngle(double angle) { - return CMIDirection.N; + return CMIDirection.N; } public int getAngle() { - return angle; + return angle; } public String getName() { - return name; + return name; } public static Location rotateOnAxisDistance(Location location, double distance, double p, double ya) { - return location.clone().add(rotateOnAxisDistanceVector( location, distance, p, ya)); + return location.clone().add(rotateOnAxisDistanceVector(location, distance, p, ya)); } public static Vector rotateOnAxisDistanceVector(Location location, double distance, double p, double ya) { - return null; + return null; } public static float getAngle(Location loc1, Location loc2) { - org.bukkit.util.Vector dirBetweenLocations = loc1.toVector().subtract(loc2.toVector()); - Location l = loc1.clone(); - l.setDirection(dirBetweenLocations); - return (l.getYaw() + 540) % 360; + org.bukkit.util.Vector dirBetweenLocations = loc1.toVector().subtract(loc2.toVector()); + Location l = loc1.clone(); + l.setDirection(dirBetweenLocations); + return (l.getYaw() + 540) % 360; } public static float getAngle(float yaw) { - return (yaw + 540) % 360; + return (yaw + 540) % 360; } public static CMIDirection getFromLocations(Location loc1, Location loc2) { - return getFromAngle(CMIDirection.getAngle(loc1, loc2)); + return getFromAngle(CMIDirection.getAngle(loc1, loc2)); } public String getTranslatedName() { - return ""; + return CMILib.getInstance().getLM().getMessage("direction." + this.toString().toLowerCase()); } public int getX() { - return x; + return x; } public int getZ() { - return z; + return z; } public CMIDirection rotate90ClockWise() { - int a = this.getAngle() + 90; - a = a > 360 ? 360 - a : a; - return getFromAngle(a); + int a = this.getAngle() + 90; + a = a > 360 ? 360 - a : a; + return getFromAngle(a); } public CMIDirection rotate90CounterClockWise() { - int a = this.getAngle() - 90; - a = a < 0 ? 360 + a : a; - return getFromAngle(a); + int a = this.getAngle() - 90; + a = a < 0 ? 360 + a : a; + return getFromAngle(a); } } diff --git a/src/com/Zrips/CMI/Containers/CMIEquipmentSlot.java b/src/com/Zrips/CMI/Containers/CMIEquipmentSlot.java index d73d233..7ba0c01 100644 --- a/src/com/Zrips/CMI/Containers/CMIEquipmentSlot.java +++ b/src/com/Zrips/CMI/Containers/CMIEquipmentSlot.java @@ -1,24 +1,41 @@ package com.Zrips.CMI.Containers; +import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; +import net.Zrips.CMILib.Version.Version; + public enum CMIEquipmentSlot { NONE, CHEST, FEET, HAND, HEAD, LEGS, OFF_HAND; public static CMIEquipmentSlot get(String name) { + for (CMIEquipmentSlot one : CMIEquipmentSlot.values()) { + if (one.toString().equalsIgnoreCase(name)) + return one; + } return null; } public static CMIEquipmentSlot get(EquipmentSlot slot) { - return null; + return get(slot.toString()); } public static CMIEquipmentSlot get(PlayerInteractAtEntityEvent event) { - return null; + if (Version.isCurrentEqualOrLower(Version.v1_8_R3)) + return CMIEquipmentSlot.HAND; + if (event.getHand() == null) + return CMIEquipmentSlot.HAND; + return get(event.getHand().toString()); } public static CMIEquipmentSlot get(PlayerInteractEvent event) { - return null; + if (event.getAction().equals(Action.PHYSICAL)) + return CMIEquipmentSlot.NONE; + if (Version.isCurrentEqualOrLower(Version.v1_8_R3)) + return CMIEquipmentSlot.HAND; + if (event.getHand() == null) + return CMIEquipmentSlot.HAND; + return get(event.getHand().toString()); } } diff --git a/src/com/Zrips/CMI/Containers/CMIEvent.java b/src/com/Zrips/CMI/Containers/CMIEvent.java index 0157a50..13b0c86 100644 --- a/src/com/Zrips/CMI/Containers/CMIEvent.java +++ b/src/com/Zrips/CMI/Containers/CMIEvent.java @@ -4,18 +4,28 @@ import org.bukkit.block.Sign; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; + +import net.Zrips.CMILib.Version.Version; public class CMIEvent { public static BlockPlaceEvent createSignEvent(Block block, Sign sign, Player player) { - return null; + if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) + return new BlockPlaceEvent(block, sign, block, new ItemStack(block.getType()), player, true, EquipmentSlot.HAND); + return new BlockPlaceEvent(block, sign, block, new ItemStack(block.getType()), player, true); } public static BlockPlaceEvent placeSignEvent(Block block, Sign sign, Player player) { - return null; + if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) + return new BlockPlaceEvent(block, sign, block, new ItemStack(block.getType()), player, true, EquipmentSlot.HAND); + return new BlockPlaceEvent(block, sign, block, new ItemStack(block.getType()), player, true); } public static BlockPlaceEvent placeBlockEvent(Block block, Player player) { - return null; + if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) + return new BlockPlaceEvent(block, block.getState(), block, new ItemStack(block.getType()), player, true, EquipmentSlot.HAND); + return new BlockPlaceEvent(block, block.getState(), block, new ItemStack(block.getType()), player, true); } } diff --git a/src/com/Zrips/CMI/Containers/CMIHitBox.java b/src/com/Zrips/CMI/Containers/CMIHitBox.java index 8e4b2d0..2afdc5b 100644 --- a/src/com/Zrips/CMI/Containers/CMIHitBox.java +++ b/src/com/Zrips/CMI/Containers/CMIHitBox.java @@ -1,5 +1,7 @@ package com.Zrips.CMI.Containers; +import java.util.HashMap; + import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Block; @@ -17,169 +19,173 @@ public class CMIHitBox { private World world; CMIHitBox(World world, Vector min, Vector max) { - this.world = world; - this.max = max; - this.min = min; + this.world = world; + this.max = max; + this.min = min; } public CMIHitBox(Block block) { - this.block = block; - world = block.getWorld(); - CMI.getInstance().getNMS().getBlockHitBox(this); - + this.block = block; + world = block.getWorld(); + CMI.getInstance().getNMS().getBlockHitBox(this); } public CMIHitBox(Entity ent) { - this.ent = ent; - if (ent != null) { - world = ent.getWorld(); - CMI.getInstance().getNMS().getEntityHitBox(this); - } + this.ent = ent; + if (ent != null) { + world = ent.getWorld(); + CMI.getInstance().getNMS().getEntityHitBox(this); + } } public Vector getMax() { - if (max == null) - max = new Vector(0, 0, 0); - return max; + if (max == null) + max = new Vector(0, 0, 0); + return max; } public Location getCenterLocation() { - Double width = this.getMaxGlobal().getX() - this.getMinGlobal().getX(); - Double length = this.getMaxGlobal().getZ() - this.getMinGlobal().getZ(); + Double width = this.getMaxGlobal().getX() - this.getMinGlobal().getX(); + Double length = this.getMaxGlobal().getZ() - this.getMinGlobal().getZ(); - return new Location(this.world, this.getMinGlobal().getX() + (width / 2D), this.getMinGlobal().getY(), this.getMinGlobal().getZ() + (length / 2D)); + return new Location(this.world, this.getMinGlobal().getX() + (width / 2D), this.getMinGlobal().getY(), this.getMinGlobal().getZ() + (length / 2D)); } public Double getHeightAtLocation(Location loc) { - - return 0D; + Double height = 0D; + return height; } public Vector getMaxGlobal() { - return new Vector(getMax().getX(), getMax().getY(), getMax().getZ()); + return new Vector(getMax().getX(), getMax().getY(), getMax().getZ()); } public Vector getMin() { - if (min == null) - min = new Vector(1, 1, 1); - return min; + if (min == null) + min = new Vector(1, 1, 1); + return min; } public double getHitBoxHeight() { - return Math.abs(this.getMax().getY() - this.getMin().getY()); + return Math.abs(this.getMax().getY() - this.getMin().getY()); } public double getHitBoxWidth() { - return Math.abs(this.getMax().getX() - this.getMin().getX()); + return Math.abs(this.getMax().getX() - this.getMin().getX()); } public double getHitBoxLength() { - return Math.abs(this.getMax().getZ() - this.getMin().getZ()); + return Math.abs(this.getMax().getZ() - this.getMin().getZ()); } public Vector getMinGlobal() { - return new Vector(getMin().getX(), getMin().getY(), getMin().getZ()); + return new Vector(getMin().getX(), getMin().getY(), getMin().getZ()); } public void byExactXYZ(double x, double y, double z) { - byExactXYZ(x, y, z, 0.2); + byExactXYZ(x, y, z, 0.2); + } + + private static HashMap getBlockStates(Block block) { + HashMap map = new HashMap(); + + return map; } public boolean byExactXYZ(double x, double y, double z, double tolerance) { - return false; + return false; } private boolean checkBlock(Block block, boolean resize) { - return false; + return false; } public boolean isPassable() { - return this.getMin().getBlockX() >= this.getMax().getBlockX(); + return this.getMin().getBlockX() >= this.getMax().getBlockX(); } public boolean isEmptySpace(Location loc) { - Double width = this.getMaxGlobal().getX() - this.getMinGlobal().getX(); - Double height = this.getMaxGlobal().getY() - this.getMinGlobal().getY(); - Double length = this.getMaxGlobal().getZ() - this.getMinGlobal().getZ(); - Vector mn = new Vector(loc.getX() - (width / 2D), loc.getY(), loc.getZ() - (length / 2D)); - Vector mx = new Vector(loc.getX() + (width / 2D), loc.getY() + height, loc.getZ() + (length / 2D)); - return isEmptySpace(loc.getWorld(), mn, mx, true); + Double width = this.getMaxGlobal().getX() - this.getMinGlobal().getX(); + Double height = this.getMaxGlobal().getY() - this.getMinGlobal().getY(); + Double length = this.getMaxGlobal().getZ() - this.getMinGlobal().getZ(); + Vector mn = new Vector(loc.getX() - (width / 2D), loc.getY(), loc.getZ() - (length / 2D)); + Vector mx = new Vector(loc.getX() + (width / 2D), loc.getY() + height, loc.getZ() + (length / 2D)); + return isEmptySpace(loc.getWorld(), mn, mx, true); } public boolean isEmptySpace() { - return isEmptySpace(this.world, this.getMinGlobal(), this.getMaxGlobal(), true); + return isEmptySpace(this.world, this.getMinGlobal(), this.getMaxGlobal(), true); } public boolean isEmptySpace(World world, Vector minimal, Vector maximum, boolean resize) { - return getCollidingdBlock(world, minimal, maximum, resize) == null; + return getCollidingdBlock(world, minimal, maximum, resize) == null; } public Block getCollidingdBlock() { - return getCollidingdBlock(this.world, this.getMinGlobal(), this.getMaxGlobal(), true); + return getCollidingdBlock(this.world, this.getMinGlobal(), this.getMaxGlobal(), true); } public Block getCollidingdBlock(World world, Vector minimal, Vector maximum) { - return getCollidingdBlock(world, minimal, maximum, true); + return getCollidingdBlock(world, minimal, maximum, true); } public Block getCollidingdBlock(World world, Vector minimal, Vector maximum, boolean resize) { - return null; + return null; } public boolean collides(Entity ent) { - if (ent == null) - return false; - CMIHitBox hitbox = new CMIHitBox(ent); + if (ent == null) + return false; + CMIHitBox hitbox = new CMIHitBox(ent); - if (hitbox.world == null || hitbox.min == null || hitbox.max == null) - return false; + if (hitbox.world == null || hitbox.min == null || hitbox.max == null) + return false; - if (world == null || min == null || max == null) - return false; + if (world == null || min == null || max == null) + return false; - CuboidArea cuboid = new CuboidArea(hitbox.world, hitbox.min, hitbox.max); - CuboidArea cuboid2 = new CuboidArea(world, min, max); + CuboidArea cuboid = new CuboidArea(hitbox.world, hitbox.min, hitbox.max); + CuboidArea cuboid2 = new CuboidArea(world, min, max); - return cuboid.checkCollision(cuboid2); + return cuboid.checkCollision(cuboid2); } public boolean canPlayerStand(Location loc) { - return true; - + return true; } public boolean collides(Vector position) { - return !(position.getX() < getMinGlobal().getX() || position.getX() > getMaxGlobal().getX() || - position.getY() < getMinGlobal().getY() || position.getY() > getMaxGlobal().getY() || - position.getZ() < getMinGlobal().getZ() || position.getZ() > getMaxGlobal().getZ()); + return !(position.getX() < getMinGlobal().getX() || position.getX() > getMaxGlobal().getX() || + position.getY() < getMinGlobal().getY() || position.getY() > getMaxGlobal().getY() || + position.getZ() < getMinGlobal().getZ() || position.getZ() > getMaxGlobal().getZ()); } public Block getBlock() { - return block; + return block; } public void setMax(Vector max) { - this.max = max; + this.max = max; } public void setMin(Vector min) { - this.min = min; + this.min = min; } public Entity getEntity() { - return ent; + return ent; } public void setEntity(Entity ent) { - this.ent = ent; + this.ent = ent; } public World getWorld() { - return world; + return world; } } diff --git a/src/com/Zrips/CMI/Containers/CMIInteractType.java b/src/com/Zrips/CMI/Containers/CMIInteractType.java index 3be43a6..1bae29e 100644 --- a/src/com/Zrips/CMI/Containers/CMIInteractType.java +++ b/src/com/Zrips/CMI/Containers/CMIInteractType.java @@ -1,8 +1,19 @@ package com.Zrips.CMI.Containers; +import org.bukkit.entity.Player; +import org.bukkit.event.block.Action; + public enum CMIInteractType { LeftClick, RightClick, LeftShiftClick, RightShiftClick; + public static CMIInteractType getByName(String name) { - return null; + return null; + } + + public static CMIInteractType getFromAction(Action action, Player player) { + + CMIInteractType type = CMIInteractType.LeftClick; + + return type; } } diff --git a/src/com/Zrips/CMI/Containers/CMIItemRepair.java b/src/com/Zrips/CMI/Containers/CMIItemRepair.java index acc363a..d201a9f 100644 --- a/src/com/Zrips/CMI/Containers/CMIItemRepair.java +++ b/src/com/Zrips/CMI/Containers/CMIItemRepair.java @@ -1,8 +1,19 @@ package com.Zrips.CMI.Containers; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.Repairable; + +import com.Zrips.CMI.CMI; +import net.Zrips.CMILib.Items.CMIMaterial; +import com.Zrips.CMI.Modules.Scavenger.ScavengeManager; +import com.Zrips.CMI.Modules.Worth.WorthEnchantment; +import com.Zrips.CMI.Modules.Worth.WorthItem; public class CMIItemRepair { @@ -14,59 +25,59 @@ public class CMIItemRepair { private static double enchantWorthPercentage = 10D; public static double getBaseCost() { - return baseCost; + return baseCost; } public static void setBaseCost(double c) { - CMIItemRepair.baseCost = c; + CMIItemRepair.baseCost = c; } public static boolean isCheckDurability() { - return checkDurability; + return checkDurability; } public static void setCheckDurability(boolean checkDurability) { - CMIItemRepair.checkDurability = checkDurability; + CMIItemRepair.checkDurability = checkDurability; } public static double getWorthPercentage() { - return worthPercentage; + return worthPercentage; } public static void setWorthPercentage(double worthPercentage) { - CMIItemRepair.worthPercentage = worthPercentage > 100 ? 100 : worthPercentage < 0 ? 0 : worthPercentage; + CMIItemRepair.worthPercentage = worthPercentage > 100 ? 100 : worthPercentage < 0 ? 0 : worthPercentage; } public static double getEnchantWorthPercentage() { - return enchantWorthPercentage; + return enchantWorthPercentage; } public static void setEnchantWorthPercentage(double enchantWorthPercentage) { - CMIItemRepair.enchantWorthPercentage = enchantWorthPercentage > 100 ? 100 : enchantWorthPercentage < 0 ? 0 : enchantWorthPercentage; + CMIItemRepair.enchantWorthPercentage = enchantWorthPercentage > 100 ? 100 : enchantWorthPercentage < 0 ? 0 : enchantWorthPercentage; } public static boolean isRepairCostsMoney() { - return repairCostsMoney; + return repairCostsMoney; } public static void setRepairCostsMoney(boolean repairCostsMoney) { - CMIItemRepair.repairCostsMoney = repairCostsMoney; + CMIItemRepair.repairCostsMoney = repairCostsMoney; } public static double getRepairCost(List items) { - double repairCost = 0D; - for (ItemStack one : items) { - repairCost += getRepairCost(one); - } - return format(repairCost); + double repairCost = 0D; + for (ItemStack one : items) { + repairCost += getRepairCost(one); + } + return format(repairCost); } public static double getRepairCost(ItemStack item) { - return 0D; + return 0D; } private static double format(double number) { - return (int) (number * 100) / 100D; + return (int) (number * 100) / 100D; } } diff --git a/src/com/Zrips/CMI/Containers/CMILwc.java b/src/com/Zrips/CMI/Containers/CMILwc.java new file mode 100644 index 0000000..a623a13 --- /dev/null +++ b/src/com/Zrips/CMI/Containers/CMILwc.java @@ -0,0 +1,9 @@ +package com.Zrips.CMI.Containers; + +public class CMILwc { + + public static boolean setupLWC() { + return false; + } + +} diff --git a/src/com/Zrips/CMI/Containers/CMINumber.java b/src/com/Zrips/CMI/Containers/CMINumber.java new file mode 100644 index 0000000..04c229b --- /dev/null +++ b/src/com/Zrips/CMI/Containers/CMINumber.java @@ -0,0 +1,14 @@ +package com.Zrips.CMI.Containers; + +public class CMINumber { + + public static double sum(double number1, double number2) { + return sum(number1, number2, 2); + } + + public static double sum(double number1, double number2, int precision) { + double decimals = (long) Math.pow(10, precision); + return ((long) (number1 * decimals) + (long) (number2 * decimals)) / decimals; + } + +} diff --git a/src/com/Zrips/CMI/Containers/CMIPlayerInventory.java b/src/com/Zrips/CMI/Containers/CMIPlayerInventory.java index ec5c610..48b4b62 100644 --- a/src/com/Zrips/CMI/Containers/CMIPlayerInventory.java +++ b/src/com/Zrips/CMI/Containers/CMIPlayerInventory.java @@ -4,10 +4,10 @@ import java.util.HashMap; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import net.Zrips.CMILib.CMILib; import net.Zrips.CMILib.Version.Version; public class CMIPlayerInventory { @@ -15,160 +15,148 @@ public class CMIPlayerInventory { private CMIUser user; public static enum CMIInventorySlot { - Armor(36, 39), Helmet(39), ChestPlate(38), Pants(37), Boots(36), OffHand(40), MainHand(-1), QuickBar(0, 8), PartInventory(9, 35), MainInventory(0, 35), CraftingIngredients(1, 4), CraftingResult(0); + Armor(36, 39), Helmet(39), ChestPlate(38), Pants(37), Boots(36), OffHand(40), MainHand(-1), QuickBar(0, 8), PartInventory(9, 35), MainInventory(0, 35), CraftingIngredients(1, 4), CraftingResult(0); - private List slot = new ArrayList(); + private List slot = new ArrayList(); - CMIInventorySlot(Integer from, Integer to) { - for (int i = from; i <= to; i++) { - this.slot.add(i); - } - } + CMIInventorySlot(Integer from, Integer to) { + for (int i = from; i <= to; i++) { + this.slot.add(i); + } + } - CMIInventorySlot(Integer slot) { - this.slot.add(slot); - } + CMIInventorySlot(Integer slot) { + this.slot.add(slot); + } - CMIInventorySlot(List slot) { - this.slot.addAll(slot); - } + CMIInventorySlot(List slot) { + this.slot.addAll(slot); + } - public List getSlots() { - return slot; - } + public List getSlots() { + return slot; + } - public Integer getSlot() { - return slot.get(0); - } + public Integer getSlot() { + return slot.get(0); + } } public CMIPlayerInventory(CMIUser user) { - this.user = user; + this.user = user; } public void setItem(CMIInventorySlot type, ItemStack item) { - Player player = user.getPlayer(); - if (type.equals(CMIInventorySlot.MainHand)) { - CMILib.getInstance().getReflectionManager().setItemInMainHand(user.getPlayer(), item); - } else { - for (Integer slot : type.getSlots()) { - player.getInventory().setItem(slot, item); - } - } } public static enum CMIFullInventoryAction { - Abort, Drop, Return; + Abort, Drop, Return; } public HashMap addItem(ItemStack item, int preferredSlot) { - return addItem(item, CMIFullInventoryAction.Drop, preferredSlot); + return addItem(item, CMIFullInventoryAction.Drop, preferredSlot); } public HashMap addItem(ItemStack item) { - return addItem(item, CMIFullInventoryAction.Drop, -1); + return addItem(item, CMIFullInventoryAction.Drop, -1); } public HashMap addItem(ItemStack item, CMIFullInventoryAction action) { - return addItem(item, action, -1); + return addItem(item, action, -1); } public HashMap addItem(ItemStack item, CMIFullInventoryAction action, int preferredSlot) { - - return null; + return null; } public enum itemCheckType { - name, lore, amount, nbt, material; + name, lore, amount, nbt, material; } public HashMap removeItemByCriteria(ItemStack item, itemCheckType... checkTypes) { - return null; + HashMap leftover = new HashMap(); + + return leftover; } public HashMap removeItem(ItemStack... items) { - - return null; + HashMap leftover = new HashMap(); + + return leftover; } public ItemStack getItem(int index) { - return this.user.getPlayer().getInventory().getItem(index); + return this.user.getPlayer().getInventory().getItem(index); } public void clear(int index) { - this.user.getPlayer().getInventory().setItem(index, null); + this.user.getPlayer().getInventory().setItem(index, null); } public void setItem(int index, ItemStack item) { - this.user.getPlayer().getInventory().setItem(index, item); + this.user.getPlayer().getInventory().setItem(index, item); } private ItemStack[] getStorageContents() { - if (Version.isCurrentEqualOrLower(Version.v1_9_R1)) - return this.user.getPlayer().getInventory().getContents(); - return this.user.getPlayer().getInventory().getStorageContents(); + if (Version.isCurrentEqualOrLower(Version.v1_9_R1)) + return this.user.getPlayer().getInventory().getContents(); + return this.user.getPlayer().getInventory().getStorageContents(); } private int check(ItemStack item, itemCheckType... checkTypes) { - return -1; + + return -1; } private static boolean check(ItemStack citem, ItemStack item, itemCheckType... checkTypes) { - - return true; + + return true; } private int first(ItemStack item, boolean withAmount) { - if (item == null) { - return -1; - } - ItemStack[] inventory = getStorageContents(); - for (int i = 0; i < inventory.length; i++) { - if (inventory[i] == null) - continue; - if (withAmount ? item.equals(inventory[i]) : isSimilar(item, inventory[i])) { - return i; - } - } - return -1; + return -1; } private static boolean isSimilar(ItemStack stack, ItemStack stack2) { - - return true; + + return stack2.getType().equals(stack.getType()) && stack2.getDurability() == stack.getDurability() && stack2.hasItemMeta() == stack.hasItemMeta() && (stack2.hasItemMeta() ? Bukkit.getItemFactory() + .equals(stack2.getItemMeta(), stack.getItemMeta()) : true); } - public boolean canFit(ItemStack... item) { - return false; + public boolean canFit(List item) { + return false; } + public boolean canFit(ItemStack... items) { + return false; + } public void removeItemFromMainHand(ItemStack item) { - + } public ItemStack getItem(CMIInventorySlot type) { - return null; + return null; } public List getItems(CMIInventorySlot type) { - Player player = user.getPlayer(); - List items = new ArrayList(); - return items; + Player player = user.getPlayer(); + List items = new ArrayList(); + + return items; } public int getFreeSlots() { - return getFreeSlots(CMIInventorySlot.MainInventory); + return getFreeSlots(CMIInventorySlot.MainInventory); } public int getFreeSlots(CMIInventorySlot place) { - return place.getSlots().size() - getItems(place).size(); + return place.getSlots().size() - getItems(place).size(); } public boolean contains(ItemStack item) { - - return false; + return true; } } diff --git a/src/com/Zrips/CMI/Containers/CMIRay.java b/src/com/Zrips/CMI/Containers/CMIRay.java index f75eed3..ca2b043 100644 --- a/src/com/Zrips/CMI/Containers/CMIRay.java +++ b/src/com/Zrips/CMI/Containers/CMIRay.java @@ -36,7 +36,7 @@ public double origin(int i) { return 0; } } - + public double direction(int i) { switch (i) { case 0: diff --git a/src/com/Zrips/CMI/Containers/CMIRayTrace.java b/src/com/Zrips/CMI/Containers/CMIRayTrace.java index 57651e5..8f74e85 100644 --- a/src/com/Zrips/CMI/Containers/CMIRayTrace.java +++ b/src/com/Zrips/CMI/Containers/CMIRayTrace.java @@ -45,9 +45,7 @@ public ArrayList getBlocks(double blocksAway) { } public ArrayList getBlocks(double blocksAway, double accuracy) { - ArrayList positions = traverse(blocksAway, accuracy); Set blocks = new LinkedHashSet(); - return new ArrayList(blocks); } diff --git a/src/com/Zrips/CMI/Containers/CMISpawner.java b/src/com/Zrips/CMI/Containers/CMISpawner.java index fbf57d6..95cb38e 100644 --- a/src/com/Zrips/CMI/Containers/CMISpawner.java +++ b/src/com/Zrips/CMI/Containers/CMISpawner.java @@ -24,213 +24,210 @@ public class CMISpawner { private CreatureSpawner spawner = null; public CMISpawner(Block block) { - this.block = block; - this.spawner = (CreatureSpawner) block.getState(); + this.block = block; + this.spawner = (CreatureSpawner) block.getState(); } public Block getBlock() { - return block; + return block; } public BlockData getBlockData() { - return block.getBlockData(); + return block.getBlockData(); } public byte getLightLevel() { - return spawner.getLightLevel(); + return spawner.getLightLevel(); } public Location getLocation() { - return block.getLocation(); + return block.getLocation(); } public Material getType() { - return block.getType(); + return block.getType(); } public World getWorld() { - return block.getWorld(); + return block.getWorld(); } public int getX() { - return block.getX(); + return block.getX(); } public int getY() { - return block.getY(); + return block.getY(); } public int getZ() { - return block.getZ(); + return block.getZ(); } public void setBlockData(BlockData data) { - block.setBlockData(data); + block.setBlockData(data); } public boolean update() { - return spawner.update(); + return spawner.update(); } public boolean update(boolean arg0) { - return spawner.update(arg0); + return spawner.update(arg0); } public boolean update(boolean arg0, boolean arg1) { - return spawner.update(arg0, arg1); + return spawner.update(arg0, arg1); } public List getMetadata(String arg0) { - return spawner.getMetadata(arg0); + return spawner.getMetadata(arg0); } public boolean hasMetadata(String arg0) { - return spawner.hasMetadata(arg0); + return spawner.hasMetadata(arg0); } public void removeMetadata(String arg0, Plugin arg1) { - spawner.removeMetadata(arg0, arg1); + spawner.removeMetadata(arg0, arg1); } public void setMetadata(String arg0, MetadataValue arg1) { - spawner.setMetadata(arg0, arg1); + spawner.setMetadata(arg0, arg1); } @Deprecated public String getCreatureTypeName() { - return spawner.getCreatureTypeName(); + return spawner.getCreatureTypeName(); } public int getDelay() { - if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { - return spawner.getDelay(); - } - return getValue("Delay"); + if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { + return spawner.getDelay(); + } + return getValue("Delay"); } public int getMaxNearbyEntities() { - if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { - return spawner.getMaxNearbyEntities(); - } - return getValue("MaxNearbyEntities"); + if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { + return spawner.getMaxNearbyEntities(); + } + return getValue("MaxNearbyEntities"); } public int getMaxSpawnDelay() { - if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { - return spawner.getMaxSpawnDelay(); - } - return getValue("MaxSpawnDelay"); + if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { + return spawner.getMaxSpawnDelay(); + } + return getValue("MaxSpawnDelay"); } public int getMinSpawnDelay() { - if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { - return spawner.getMinSpawnDelay(); - } - return getValue("MinSpawnDelay"); + if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { + return spawner.getMinSpawnDelay(); + } + return getValue("MinSpawnDelay"); } public int getRequiredPlayerRange() { - if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { - return spawner.getRequiredPlayerRange(); - } - return getValue("RequiredPlayerRange"); + if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { + return spawner.getRequiredPlayerRange(); + } + return getValue("RequiredPlayerRange"); } public int getSpawnCount() { - if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { - return spawner.getSpawnCount(); - } - return getValue("SpawnCount"); + if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { + return spawner.getSpawnCount(); + } + return getValue("SpawnCount"); } public int getSpawnRange() { - if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { - return spawner.getSpawnRange(); - } - return getValue("SpawnRange"); + if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { + return spawner.getSpawnRange(); + } + return getValue("SpawnRange"); } private int getValue(String path) { - Object v = new CMINBT(block).getShort(path); - if (v instanceof Short) - return (Short) v; - return 0; + Object v = new CMINBT(block).getShort(path); + if (v instanceof Short) + return (Short) v; + return 0; } public EntityType getSpawnedType() { - return spawner.getSpawnedType(); + return spawner.getSpawnedType(); } @Deprecated public void setCreatureTypeByName(String arg0) { - spawner.setCreatureTypeByName(arg0); + spawner.setCreatureTypeByName(arg0); } public void setDelay(int arg0) { - if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { - spawner.setDelay(arg0); - return; - } - updateValue("Delay", arg0); + if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { + spawner.setDelay(arg0); + return; + } + updateValue("Delay", arg0); } public void setMaxNearbyEntities(int arg0) { - if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { - spawner.setMaxNearbyEntities(arg0); - return; - } - updateValue("MaxNearbyEntities", arg0); + if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { + spawner.setMaxNearbyEntities(arg0); + return; + } + updateValue("MaxNearbyEntities", arg0); } public void setMaxSpawnDelay(int arg0) { - if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { - spawner.setMaxSpawnDelay(arg0); - return; - } - updateValue("MaxSpawnDelay", arg0); + if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { + spawner.setMaxSpawnDelay(arg0); + return; + } + updateValue("MaxSpawnDelay", arg0); } public void setMinSpawnDelay(int arg0) { - if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { - spawner.setMinSpawnDelay(arg0); - return; - } - updateValue("MinSpawnDelay", arg0); + if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { + spawner.setMinSpawnDelay(arg0); + return; + } + updateValue("MinSpawnDelay", arg0); } public void setRequiredPlayerRange(int arg0) { - if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { - spawner.setRequiredPlayerRange(arg0); - return; - } - updateValue("RequiredPlayerRange", arg0); + if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { + spawner.setRequiredPlayerRange(arg0); + return; + } + updateValue("RequiredPlayerRange", arg0); } public void setSpawnCount(int arg0) { - if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { - spawner.setSpawnCount(arg0); - return; - } - updateValue("SpawnCount", arg0); + if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { + spawner.setSpawnCount(arg0); + return; + } + updateValue("SpawnCount", arg0); } public void setSpawnRange(int arg0) { - if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { - spawner.setSpawnRange(arg0); - return; - } - updateValue("SpawnRange", arg0); + if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) { + spawner.setSpawnRange(arg0); + return; + } + updateValue("SpawnRange", arg0); } private void updateValue(String type, int val) { - Object tag = new CMINBT(block).setShort(type, (short) val); - CMILib.getInstance().getReflectionManager().updateTileEntity(this.getLocation(), tag); - spawner.update(); } public void setSpawnedType(EntityType arg0) { - spawner.setSpawnedType(arg0); + spawner.setSpawnedType(arg0); } } diff --git a/src/com/Zrips/CMI/Containers/CMISunMover.java b/src/com/Zrips/CMI/Containers/CMISunMover.java new file mode 100644 index 0000000..5bd637b --- /dev/null +++ b/src/com/Zrips/CMI/Containers/CMISunMover.java @@ -0,0 +1,22 @@ +package com.Zrips.CMI.Containers; + +public class CMISunMover { + private int timeMoverId = -1; + private String moving; + + public int getTimeMoverId() { + return timeMoverId; + } + + public void setTimeMoverId(int timeMoverId) { + this.timeMoverId = timeMoverId; + } + + public String getMoving() { + return moving; + } + + public void setMoving(String moving) { + this.moving = moving; + } +} diff --git a/src/com/Zrips/CMI/Containers/CMITabComplete.java b/src/com/Zrips/CMI/Containers/CMITabComplete.java index 17bd9db..b0be88a 100644 --- a/src/com/Zrips/CMI/Containers/CMITabComplete.java +++ b/src/com/Zrips/CMI/Containers/CMITabComplete.java @@ -8,50 +8,28 @@ public class CMITabComplete { public HashMap tabs = new HashMap(); - public List getTabCompleteList(String[] args) { - - StringBuilder str = new StringBuilder(); - for (int z = 0; z < args.length - 1; z++) { - if (!str.toString().isEmpty()) - str.append(" "); - str.append(args[z]); - } - - String comlpStr = getTabComplete(str.toString()); + public static final String externalSeparator = ","; + public static final String internalSeparator = "><"; - List argsList = new ArrayList(); - - return argsList; - } + public List getTabCompleteList(String[] args) { - private static boolean notRepeating(String word, String[] args) { + StringBuilder str = new StringBuilder(); + for (int z = 0; z < args.length - 1; z++) { + if (!str.toString().isEmpty()) + str.append(" "); + str.append(args[z]); + } - for (String one : args) { - if (one.equalsIgnoreCase(word)) - return false; - } - return true; + String comlpStr = getTabComplete(str.toString()); + List argsList = new ArrayList(); + return argsList; } public String getTabComplete(String tab) { - - - Object res = getTab(tab.toLowerCase(), tabs); - return res == null ? null : (String) res; - } - - private Object getTab(String tab, HashMap map) { - - return ""; + return ""; } public void addTabComplete(String tab) { - tab = tab.replace("%%", ","); - addTab(tab, tabs); - } - - private Object addTab(String tab, HashMap map) { - - return ""; + tab = tab.replace(internalSeparator, externalSeparator); } } diff --git a/src/com/Zrips/CMI/Containers/CMITextCleaner.java b/src/com/Zrips/CMI/Containers/CMITextCleaner.java new file mode 100644 index 0000000..139e97f --- /dev/null +++ b/src/com/Zrips/CMI/Containers/CMITextCleaner.java @@ -0,0 +1,20 @@ +package com.Zrips.CMI.Containers; + +import org.bukkit.entity.Player; + +import com.Zrips.CMI.commands.list.colorlimits.CMIColorTypes; + +public class CMITextCleaner { + + private static int cicles = 0; + + public static String cleanFromColorCodes(Object p, String msg, CMIColorTypes type, boolean clean) { + + return msg; + } + + private static boolean hasColorPermission(Player player, CMIColorTypes type, String color, boolean wildCard) { + + return true; + } +} diff --git a/src/com/Zrips/CMI/Containers/CMITreeType.java b/src/com/Zrips/CMI/Containers/CMITreeType.java index 9bcef3e..552cb01 100644 --- a/src/com/Zrips/CMI/Containers/CMITreeType.java +++ b/src/com/Zrips/CMI/Containers/CMITreeType.java @@ -5,7 +5,7 @@ import org.bukkit.TreeType; public enum CMITreeType { - + ACACIA("Acacia"), AZALEA("Azalea"), BIG_TREE("Large oak", "bigoak", "big", "bigtree"), @@ -25,7 +25,8 @@ public enum CMITreeType { TALL_BIRCH("Tall birch"), TALL_REDWOOD("Tall spruce", "bigspruce", "tallredwood", "tallsequoia", "tallsequoioideae"), TREE("Oak", "tree", "regular"), - WARPED_FUNGUS("Warped fungus"); + WARPED_FUNGUS("Warped fungus"), + MANGROVE("Mangrove"); private String name; private String[] identifiers; @@ -37,24 +38,20 @@ public enum CMITreeType { static HashMap map = new HashMap(); - static { - - } - public static CMITreeType getType(String name) { - - return null; + + return null; } public String getName() { - return name; + return name; } public String[] getIdentifiers() { - return identifiers; + return identifiers; } public TreeType getType() { - return type; + return type; } } diff --git a/src/com/Zrips/CMI/Containers/CMIUser.java b/src/com/Zrips/CMI/Containers/CMIUser.java index 41c39c2..bf1ca0c 100644 --- a/src/com/Zrips/CMI/Containers/CMIUser.java +++ b/src/com/Zrips/CMI/Containers/CMIUser.java @@ -5,6 +5,7 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -31,7 +32,6 @@ import org.bukkit.util.Vector; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Config; import com.Zrips.CMI.PlayerManager; import com.Zrips.CMI.Modules.Afk.AfkInfo; import com.Zrips.CMI.Modules.ChatFormat.CMIChatRoom; @@ -40,6 +40,7 @@ import com.Zrips.CMI.Modules.Economy.CMIEconomyAcount; import com.Zrips.CMI.Modules.Economy.EconomyManager; import com.Zrips.CMI.Modules.FlightCharge.FlightCharge; +import com.Zrips.CMI.Modules.GeoIP.IPLocation; import com.Zrips.CMI.Modules.Homes.CmiHome; import com.Zrips.CMI.Modules.Jail.CMIJail; import com.Zrips.CMI.Modules.Jail.CMIJailCell; @@ -53,6 +54,7 @@ import com.Zrips.CMI.Modules.PlayerCombat.EntityKillCount; import com.Zrips.CMI.Modules.PlayerCombat.PlayerKillCount; import com.Zrips.CMI.Modules.PlayerMeta.PlayerMeta; +import com.Zrips.CMI.Modules.PlayerOptions.PlayerOption; import com.Zrips.CMI.Modules.Ranks.CMIRank; import com.Zrips.CMI.Modules.SavedInv.SavedInventories; import com.Zrips.CMI.Modules.SpawnerCharge.PlayerCharge; @@ -109,28 +111,16 @@ public class CMIUser { private CmdCooldown CommandCooldown; private Long totemCooldown; private Long totemWarmup; - private Boolean showTotemBar; private Long tfly; private Long tgod; private Long teleportInvulnerability; - private Boolean tagSoundEnabled; - private Boolean shiftEditEnabled; - private Boolean spy; - private Boolean acceptingPM; - private Boolean commandSpy; - private Boolean signSpy; - private Boolean toggleCompass; private CMIVanish vanish; private Long mutedUntil; private Long shadowMutedUntil; private String mutedReason; - private Boolean teleportToggled; - private Boolean noPayToggle; - private ChatColor glow; -// private ChatColor tempGlow; private Boolean isFakeAccount; @@ -201,7 +191,7 @@ public class CMIUser { // ConcurrentHashMap barMap; - HashMap tempFlyModes = new HashMap(); + HashMap tempFlyModes = new HashMap(); private TreeMap lastDamage; @@ -211,88 +201,95 @@ public class CMIUser { private CMIPlayerCombat combat = null; + HashMap options = null; + public CMIUser(int id) { - this.id = id; - CMI.getInstance().getPlayerManager().addUser(this, id); + this.id = id; + CMI.getInstance().getPlayerManager().addUser(this, id); } public void cacheClear() { - + } public CMIUser(UUID uuid) { + } @Deprecated public CMIUser(UUID uuid, boolean updatePerm) { - + } public CMIUser(OfflinePlayer player) { + } public boolean isOnline() { - return Bukkit.getPlayer(this.uuid) != null; + return Bukkit.getPlayer(this.uuid) != null; } public Location getLogOutLocation() { - return logOutLocation; + return logOutLocation; } public Location getLocation() { - return this.getPlayer(true).getLocation(); + return this.getPlayer(true).getLocation(); } public void setLogOutLocation(Location logOutLocation) { - this.logOutLocation = logOutLocation; } public void saveIfOffline() { - if (!isOnline()) - addForDelayedSave(); } + Boolean fakeUser = null; + public void addForDelayedSave() { - CMI.getInstance().getDbManager().addForSave(this); + } public void addForPlayTimeRewardSave() { - CMI.getInstance().getDbManager().addForPlayTimeRewardSave(this); + CMI.getInstance().getDbManager().addForPlayTimeRewardSave(this); } public void setIps(LinkedHashMap ips) { - this.ips = ips; + this.ips = ips; } public HashMap getIps() { - return ips; + if (ips == null) + ips = new LinkedHashMap(); + return ips; } public boolean addIps(String ip) { - - return true; + return true; } public String getLastIp() { - - return ""; + String ip = null; + return ip; } public String getCountry() { - return ""; + IPLocation location = CMI.getInstance().getLookupService().getLocation(this.getLastIp()); + return location == null ? "N/A" : location.getCountryName(); } public String getCountryCode() { - return ""; + IPLocation location = CMI.getInstance().getLookupService().getLocation(this.getLastIp()); + return location == null ? "N/A" : location.getCountryCode(); } public String getCity() { - return ""; + IPLocation location = CMI.getInstance().getLookupService().getLocation(this.getLastIp()); + return location == null ? "N/A" : location.getCity(); } public boolean addAllIps(Map map) { - boolean added = false; - return added; + boolean added = false; + return added; } private Integer schedId; @@ -303,124 +300,132 @@ private void ScheduleDataClear() { } public Player getPlayer() { - return getPlayer(!this.isFakeAccount()); + return getPlayer(!this.isFakeAccount()); } public Player getPlayer(boolean loadOfflineObject) { - return null; + + return player; } public void setPlayer(Player player) { - this.player = player; + this.player = player; } public String getName() { - return getName(false); + return getName(false); } public OfflinePlayer getOfflinePlayer() { - if (this.isOnline()) { - return this.getPlayer(false); - } - if (this.getUniqueId() == null) - return null; - return Bukkit.getOfflinePlayer(this.getUniqueId()); + if (this.isOnline()) { + return this.getPlayer(false); + } + if (this.getUniqueId() == null) + return null; + return Bukkit.getOfflinePlayer(this.getUniqueId()); } public String getName(boolean update) { - - return name; + return name; } public void setName(String name) { - this.name = name; + this.name = name; } public long getLastLogin() { - return getLastLogin(false); + return getLastLogin(false); } public long getLastLogin(boolean forceUpdate) { - if (forceUpdate && (lastLogin == null || lastLogin == 0L) && getOfflinePlayer() != null) - lastLogin = getOfflinePlayer().getLastPlayed(); - return lastLogin == null ? 0L : lastLogin; + if (forceUpdate && (lastLogin == null || lastLogin == 0L) && getOfflinePlayer() != null) + lastLogin = getOfflinePlayer().getLastPlayed(); + return lastLogin == null ? 0L : lastLogin; } public void setLastLogin(long lastLogin) { - this.lastLogin = lastLogin; + this.lastLogin = lastLogin; } public long getLastLogoff() { - return getLastLogoff(false); + return getLastLogoff(false); } public long getLastLogoff(boolean forceUpdate) { - if (forceUpdate && (lastLogoff == null || lastLogoff == 0L) && getOfflinePlayer() != null) { - lastLogoff = getOfflinePlayer().getLastPlayed(); - this.addForDelayedSave(); - } - return lastLogoff == null ? 0L : lastLogoff; + if (forceUpdate && (lastLogoff == null || lastLogoff == 0L) && getOfflinePlayer() != null) { + lastLogoff = getOfflinePlayer().getLastPlayed(); + this.addForDelayedSave(); + } + return lastLogoff == null ? 0L : lastLogoff; } public Long getLastLogoffClean() { - return lastLogoff; + return lastLogoff; } public void setLastLogoff(long lastLogoff) { - this.lastLogoff = lastLogoff; + this.lastLogoff = lastLogoff; } public Location getDeathLoc() { - return DeathLoc; + return DeathLoc; } public void setDeathLoc(CMILocation deathLoc) { - DeathLoc = deathLoc; + DeathLoc = deathLoc; } @Deprecated public Location getTpLoc() { - return getLastTeleportLocation(); + return getLastTeleportLocation(); } public Location getLastTeleportLocation() { - return TpLoc; + return TpLoc; } @Deprecated public void setTpLoc(Location tpLoc) { - setLastTeleportLocation(tpLoc, true); + setLastTeleportLocation(tpLoc, true); } @Deprecated public void setTpLoc(Location tpLoc, boolean save) { - setLastTeleportLocation(tpLoc, save); + setLastTeleportLocation(tpLoc, save); } public void setLastTeleportLocation(Location tpLoc) { - setLastTeleportLocation(tpLoc, true); + setLastTeleportLocation(tpLoc, true); } public void setLastTeleportLocation(Location tpLoc, boolean save) { - TpLoc = tpLoc != null ? tpLoc.clone() : null; - if (save) - addForDelayedSave(); + TpLoc = tpLoc != null ? tpLoc.clone() : null; + if (save) + addForDelayedSave(); } @Deprecated public UUID getUuid() { - return getUniqueId(); + return getUniqueId(); } public UUID getUniqueId() { - return uuid; + return uuid; } public void setUuid(UUID uuid) { - updatePermissions(); + this.uuid = uuid; + player = Bukkit.getPlayer(this.uuid); + if (player != null) + name = player.getName(); + updatePermissions(); } public void setUuidNoPermUpdate(UUID uuid) { + this.uuid = uuid; + player = Bukkit.getPlayer(this.uuid); + if (player != null) + name = player.getName(); } Long time = null; @@ -429,11 +434,11 @@ public void updatePermissions() { } public void updateDisplayName() { - updateDisplayName(false); + updateDisplayName(false); } public void updateDisplayName(boolean force) { - + } public void updatePrefix() { @@ -443,198 +448,231 @@ public void updateSuffix() { } public void updateGroup() { + group = CMI.getInstance().getPermissionsManager().getMainGroup(this.getPlayer(false)); } public String getCleanDisplayName() { - return CMIChatColor.translate(nickName); + return CMIChatColor.translate(nickName); } public void setDisplayName(String displayName) { - if (displayName == null || !displayName.isEmpty()) - this.displayName = displayName; + if (displayName == null || !displayName.isEmpty()) + this.displayName = displayName; } public String getDisplayName() { - return getDisplayName(true); + return getDisplayName(true); } public String getDisplayName(boolean update) { - return CMIChatColor.translate(getDisplayNameClean(update)); + return CMIChatColor.translate(getDisplayNameClean(update)); } public String getDisplayNameClean(boolean update) { - - return nickName; + return nickName; } private enum updateType { - prefix, suffix, group, nameColor, displayname; + prefix, suffix, group, nameColor, displayname; } private boolean timeToUpdate(updateType type) { - - return false; + return false; } public String getGroupName() { - if (this.isOnline() && timeToUpdate(updateType.group)) - updateGroup(); - return group == null ? "" : group; + if (this.isOnline() && timeToUpdate(updateType.group)) + updateGroup(); + return group == null ? "" : group; } public String getNameColor() { - return this.nameColor; + return this.nameColor; } public String getPrefix() { - if (timeToUpdate(updateType.prefix)) - updatePrefix(); - - - return prefix == null ? "" : prefix; + return null; } public String getSuffix() { - return suffix == null ? "" : suffix; + return suffix == null ? "" : suffix; } public String getNickName() { - return nickName; + return nickName; } public void setNickName(String nickName, boolean save) { } public Long getpTime() { - return pTime == null ? -1L : pTime; + return pTime == null ? -1L : pTime; } public void setpTime(Long i) { - setpTime(i, true); + setpTime(i, true); } public void setpTime(Long pTime, boolean save) { - this.pTime = pTime; - if (save) - addForDelayedSave(); + this.pTime = pTime; + if (save) + addForDelayedSave(); } public boolean isCuffed() { - return cuffed == null ? false : cuffed; + return cuffed == null ? false : cuffed; } public void setCuffed(boolean cuffed) { - setCuffed(cuffed, true); + setCuffed(cuffed, true); } public void setCuffed(boolean cuffed, boolean save) { } public List getLockedIps() { - return lockedIps; + if (lockedIps == null) + lockedIps = new ArrayList(); + return lockedIps; } public void setLockedIps(List lockedIps) { - this.lockedIps = lockedIps; + this.lockedIps = lockedIps; } public void addLockedIps(String Ip) { + if (Ip == null) + return; + Ip = Ip.replace("_", "."); + if (!getLockedIps().contains(Ip)) + getLockedIps().add(Ip); + addForDelayedSave(); } public boolean removeLockedIps(String Ip) { - return false; + if (Ip == null) + return false; + boolean s = getLockedIps().remove(Ip); + addForDelayedSave(); + return s; } public boolean isJoinedCounter() { - return joinedCounter == null ? false : joinedCounter; + return joinedCounter == null ? false : joinedCounter; } public void setJoinedCounter(boolean joinedCounter) { - this.joinedCounter = joinedCounter; + this.joinedCounter = joinedCounter; } public HashMap getCounter() { - if (counter == null) - counter = new HashMap(); - return counter; + if (counter == null) + counter = new HashMap(); + return counter; } public Long getCounter(String cmd) { - return getCounter().get(cmd); + return getCounter().get(cmd); } public void addCounter(String cmd, Long time) { - getCounter().put(cmd, time); + getCounter().put(cmd, time); } public Long getAlertUntil() { - return alertUntil; + return alertUntil; } public void setAlertUntil(Long alertUntil) { - setAlertUntil(alertUntil, true); + setAlertUntil(alertUntil, true); } public void removeAlert() { } public void setAlertUntil(Long alertUntil, boolean save) { + if (alertUntil != null && alertUntil < System.currentTimeMillis()) { + return; + } + this.alertUntil = alertUntil; + + CMI.getInstance().getPlayerManager().addAlert(this.getUniqueId()); + + if (save) + addForDelayedSave(); } public String getAlertReason() { - return alertReason; + return alertReason; } public void setAlertReason(String alertReason) { - setAlertReason(alertReason, true); + setAlertReason(alertReason, true); } public void setAlertReason(String alertReason, boolean save) { - this.alertReason = alertReason; - if (save) - addForDelayedSave(); + this.alertReason = alertReason; + if (save) + addForDelayedSave(); } public Boolean isGod() { - return god == null ? false : god; + if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) { + Player p = getPlayer(false); + if (p == null) + return false; + god = p.isInvulnerable(); + + return god; + } + + god = CMI.getInstance().getNMS().getGodMode(getPlayer(false)); + return god == null ? false : god; } public void setGod(Boolean god) { - this.god = god; - addForDelayedSave(); + this.god = god; + addForDelayedSave(); } public Mirrors getMirror() { - if (mirror == null) - mirror = new Mirrors(); - return mirror; + if (mirror == null) + mirror = new Mirrors(); + return mirror; } public void setMirror(Mirrors mirror) { - this.mirror = mirror; + this.mirror = mirror; } public LinkedHashMap getKits() { - if (kits == null) - kits = new LinkedHashMap(); - return kits; + if (kits == null) + kits = new LinkedHashMap(); + return kits; } public HashMap getKitsAsMap() { - HashMap map = new HashMap(); - return map; + HashMap map = new HashMap(); + for (Entry one : getKits().entrySet()) { + map.put(one.getKey().getConfigName() + PlayerManager.multiSeparator + one.getValue().getUsedTimes(), one.getValue().getLastUsage()); + } + return map; } @Deprecated public void setKits(LinkedHashMap kits) { + getKits().clear(); + for (Entry one : kits.entrySet()) { + getKits().put(one.getKey(), new CMIKitUsage(one.getKey(), one.getValue().getLastUsage(), one.getValue().getUsedTimes())); + } } public void addKit(Kit kit, Long time) { - addKit(kit, time, true); + addKit(kit, time, true); } public void addKit(Kit kit, Long time, boolean save) { - addKit(kit, time, null, save); + addKit(kit, time, null, save); } public void addKit(Kit kit, Long time, Integer usedTimes, boolean save) { @@ -642,415 +680,446 @@ public void addKit(Kit kit, Long time, Integer usedTimes, boolean save) { } public Long getKitTime(Kit kit) { - return getKits().get(kit) == null ? null : getKits().get(kit).getLastUsage(); + return getKits().get(kit) == null ? null : getKits().get(kit).getLastUsage(); } public Long getKitUseTimeIn(Kit kit) { - return 0L; + return 0L; } public boolean canUseKit(Kit kit) { - - return false; + + return false; } public int getLeftKitUseTimes(Kit kit) { - return 0; + CMIKitUsage usage = getKits().get(kit); + if (usage == null) + return kit.getMaxUsages(); + if (kit.getMaxUsages() < 0) + return kit.getMaxUsages(); + return kit.getMaxUsages() - usage.getUsedTimes() < 0 ? 0 : kit.getMaxUsages() - usage.getUsedTimes(); } public int getKitUseTimes(Kit kit) { - return 0; + CMIKitUsage usage = getKits().get(kit); + if (usage == null) + return 0; + return usage.getUsedTimes(); } public CMIUser resetKitUseTimes(Kit kit) { - CMIKitUsage usage = getKits().get(kit); - if (usage == null) - return this; - usage.setUsedTimes(0); - return this; + CMIKitUsage usage = getKits().get(kit); + if (usage == null) + return this; + usage.setUsedTimes(0); + return this; } - public PlayerCharge getPCharge() { - return getPCharge(true); + return getPCharge(true); } public PlayerCharge getPCharge(boolean update) { - if (PCharge == null) - PCharge = new PlayerCharge(this, update); - return PCharge; + if (PCharge == null) + PCharge = new PlayerCharge(this, update); + return PCharge; } public HashMap getNotifications() { - if (notifications == null) - notifications = new HashMap(); - return notifications; + if (notifications == null) + notifications = new HashMap(); + return notifications; } public void addNotification(Notification notification) { - getNotifications().put(notification.getNotifyier(), notification); - addForDelayedSave(); + getNotifications().put(notification.getNotifyier(), notification); + addForDelayedSave(); } public long getTotalPlayTime() { - return getTotalPlayTime(true); + return getTotalPlayTime(true); } private static Statistic statCheck = null; - public long getTotalPlayTime(boolean update) { - return totalPlayTime == null ? 0L : totalPlayTime; + public long getTotalPlayTime(boolean update) { + return totalPlayTime == null ? 0L : totalPlayTime; } public long getTotalPlayTimeClean() { - return totalPlayTime == null ? 0L : totalPlayTime; + return totalPlayTime == null ? 0L : totalPlayTime; } public void setTotalPlayTime(long totalPlayTime) { - this.totalPlayTime = totalPlayTime; + this.totalPlayTime = totalPlayTime; } -// public void addTotalPlayTime() { -// this.totalPlayTime = totalPlayTime + (System.currentTimeMillis() - getLastLogin()); -// } - public CmdCooldown getCommandCooldowns() { - if (CommandCooldown == null) - CommandCooldown = new CmdCooldown(); - return CommandCooldown; + if (CommandCooldown == null) + CommandCooldown = new CmdCooldown(); + return CommandCooldown; } -// public void addCommandCooldown(String cmd, Long time) { -// CommandCooldown.addCooldown(cmd, time); -// } - public void addCommandCooldownByEndTime(String cmd, Long time, Long endTime) { - getCommandCooldowns().addCooldown(cmd, time, endTime - time); + getCommandCooldowns().addCooldown(cmd, time, endTime - time); } public Long getTotemCooldown() { - return totemCooldown == null ? 0L : totemCooldown; + return totemCooldown == null ? 0L : totemCooldown; } public void setTotemCooldown(Long totemCooldown) { - this.totemCooldown = totemCooldown; + this.totemCooldown = totemCooldown; } + @Deprecated public boolean isShowTotemBar() { - return showTotemBar == null ? true : showTotemBar; + return this.getOptionState(PlayerOption.totemBossBar); } + @Deprecated public void setShowTotemBar(boolean showTotemBar) { - this.showTotemBar = showTotemBar; + this.setOptionState(PlayerOption.totemBossBar, showTotemBar); } public Long getTotemWarmup() { - return totemWarmup == null ? 0L : totemWarmup; + return totemWarmup == null ? 0L : totemWarmup; } public void setTotemWarmup(Long totemWarmup) { - this.totemWarmup = totemWarmup; + this.totemWarmup = totemWarmup; } public Long getTfly() { - return tfly == null || tfly + 2000L < System.currentTimeMillis() ? null : tfly; + return tfly == null || tfly + 2000L < System.currentTimeMillis() ? null : tfly; } public void setTfly(Long tfly) { - setTfly(tfly, true); + setTfly(tfly, true); } public void setTfly(Long tfly, boolean save) { - this.tfly = tfly != null && (tfly == 0 || tfly < 0) ? null : tfly; + this.tfly = tfly != null && (tfly == 0 || tfly < 0) ? null : tfly; - if (save) - addForDelayedSave(); + if (save) + addForDelayedSave(); } public Long getTgod() { - return tgod == null || tgod + 2000L < System.currentTimeMillis() ? null : tgod; + return tgod == null || tgod + 2000L < System.currentTimeMillis() ? null : tgod; } public void setTgod(Long tgod) { - setTgod(tgod, true); + setTgod(tgod, true); } public void setTgod(Long tgod, boolean save) { - this.tgod = tgod != null && (tgod == 0 || tgod < 0) ? null : tgod; - if (save) - addForDelayedSave(); + this.tgod = tgod != null && (tgod == 0 || tgod < 0) ? null : tgod; + if (save) + addForDelayedSave(); } public LinkedHashMap getHomes() { - if (homes == null) - homes = new LinkedHashMap(); - return homes; + if (homes == null) + homes = new LinkedHashMap(); + return homes; + } + + public Set getHomesFromWorld(String worldName) { + Set temp = new HashSet(); + for (Entry one : getHomes().entrySet()) { + + if (!one.getValue().getLoc().getWorldName().equalsIgnoreCase(worldName)) + continue; + temp.add(one.getValue()); + } + return temp; } public int getValidHomeCount() { - if (homes == null) - homes = new LinkedHashMap(); - int count = 0; - return count; + if (homes == null) + homes = new LinkedHashMap(); + int count = 0; + for (CmiHome one : homes.values()) { + if (!one.getLoc().isValid()) + continue; + count++; + } + return count; } public int getLastHomeSlot() { - int i = 0; - for (Entry one : homes.entrySet()) { - if (one.getValue().getSlot() == null) - continue; - if (i < one.getValue().getSlot()) - i = one.getValue().getSlot(); - } - return i == 0 || i < getHomes().size() ? getHomes().size() : i; + int i = 0; + for (Entry one : homes.entrySet()) { + if (one.getValue().getSlot() == null) + continue; + if (i < one.getValue().getSlot()) + i = one.getValue().getSlot(); + } + return i == 0 || i < getHomes().size() ? getHomes().size() : i; } public Set getHomesBySlot(int slot) { - Set set = new HashSet(); - for (Entry one : homes.entrySet()) { - if (one.getValue().getSlot() == null) - continue; - if (one.getValue().getSlot() != slot) - continue; - set.add(one.getValue()); - } - return set; + Set set = new HashSet(); + return set; } public LinkedHashMap getHomesAsMap() { - LinkedHashMap hm = new LinkedHashMap(); - - return hm; + LinkedHashMap hm = new LinkedHashMap(); + return hm; } public ArrayList getHomesList() { - ArrayList list = new ArrayList(); - return list; + ArrayList list = new ArrayList(); + for (Entry one : getHomes().entrySet()) { + list.add(one.getKey()); + } + return list; } public CmiHome getHome(String name) { - return null; + return null; + } + + public CmiHome getBedHome() { + return null; } public void removeHome(CmiHome home) { - if (home != null) - getHomes().remove(home.getName()); + if (home != null) + getHomes().remove(home.getName()); } public void removeHome(String name) { - if (name == null) - return; - CmiHome home = getHome(name); - removeHome(home); + if (name == null) + return; + CmiHome home = getHome(name); + removeHome(home); } @Deprecated public void addHome(@SuppressWarnings("unused") String name, CmiHome home, boolean save) { - addHome(home, save); + addHome(home, save); } public void addHome(CmiHome home, boolean save) { - + getHomes().put(home.getName(), home); + if (home.getName().equals(CMI.getInstance().getHomeManager().getDefaultBedHomeName())) { + CMI.getInstance().getHomeManager().addBedHome(this, home); + } + if (save) + addForDelayedSave(); } public ChatColor getGlow() { - return glow; + return glow; } public void setGlow(ChatColor glow, boolean save) { - + } + @Deprecated public boolean isTeleportToggled() { - return teleportToggled == null ? false : teleportToggled; + return !this.getOptionState(PlayerOption.acceptingTPA); } + @Deprecated public void setTeleportToggled(boolean noTeleport, boolean save) { - this.teleportToggled = noTeleport; - if (save) - addForDelayedSave(); + this.setOptionState(PlayerOption.acceptingTPA, noTeleport); } public int getId() { - return id == null ? 0 : id; + return id == null ? 0 : id; } public void setId(int id) { - this.id = id; - CMI.getInstance().getPlayerManager().addUser(this, id); + this.id = id; + CMI.getInstance().getPlayerManager().addUser(this, id); } public int getInvId() { - return invId == null ? 0 : invId; + return invId == null ? 0 : invId; } public void setInvId(int invId) { - this.invId = invId; + this.invId = invId; } public int getPlayTimeId() { - return playTimeId == null ? 0 : playTimeId; + return playTimeId == null ? 0 : playTimeId; } public void setPlayTimeId(int playTimeId) { - this.playTimeId = playTimeId; + this.playTimeId = playTimeId; } public List getNotes() { - return getNotes(true); + return getNotes(true); } public List getNotes(boolean filterOldOut) { - - return notes; + return notes; } public void setNotes(List notes) { - this.notes = notes; + this.notes = notes; } public void addNote(PlayerNote note, boolean save) { - getNotes(save).add(note); - if (save) - addForDelayedSave(); + getNotes(save).add(note); + if (save) + addForDelayedSave(); } public void removeMail(PlayerMail mail) { - if (this.mail != null) - this.mail.remove(mail); + if (this.mail != null) + this.mail.remove(mail); } public void clearMails() { - if (mail != null) - mail.clear(); + if (mail != null) + mail.clear(); } public List getMails() { - return mail; + + return mail; } public void setMail(List mail) { - this.mail = mail; + this.mail = mail; } public void addMail(PlayerMail mail, boolean save) { - getMails().add(mail); - if (save) - addForDelayedSave(); + getMails().add(mail); + if (save) + addForDelayedSave(); } public Long getLastPatrol() { - return lastPatrol; + return lastPatrol; } public void setPatroled() { - this.lastPatrol = System.currentTimeMillis(); + this.lastPatrol = System.currentTimeMillis(); } public Long getStatistic(CMIStatistic stat) { - return getStatistic(stat, null); + return getStatistic(stat, null); } public Long getStatistic(CMIStatistic stat, Object thing) { - if (stats == null) - stats = new CMIStats(this); - return stats.getStat(stat, thing); + if (stats == null) + stats = new CMIStats(this); + return stats.getStat(stat, thing); } public CMIRank getNullRank() { - return rank; + return rank; } public CMIRank getRank() { - if (rank == null) { - rank = CMI.getInstance().getRankManager().getDefaultRank(this.getPlayer(false)); - } - return rank; + if (rank == null) { + rank = CMI.getInstance().getRankManager().getDefaultRank(this.getPlayer(false)); + } + return rank; } public CMIRank recalculateRank() { - return rank; + return rank; } public void setRank(CMIRank rank) { - this.rank = rank; + this.rank = rank; } + @Deprecated public boolean isTagSoundEnabled() { - return tagSoundEnabled == null ? true : tagSoundEnabled; + return this.getOptionState(PlayerOption.tagSound); } + @Deprecated public void setTagSoundEnabled(boolean tagEnabled) { - this.tagSoundEnabled = tagEnabled; + this.setOptionState(PlayerOption.tagSound, tagEnabled); } + @Deprecated public boolean isShiftEditEnabled() { - return shiftEditEnabled == null ? true : shiftEditEnabled; + return this.getOptionState(PlayerOption.shiftSignEdit); } + @Deprecated public void setShiftEditEnabled(boolean shiftEditEnabled) { - this.shiftEditEnabled = shiftEditEnabled; + this.setOptionState(PlayerOption.shiftSignEdit, shiftEditEnabled); } + @Deprecated public boolean isSpy() { - return spy == null ? false : spy; + return this.getOptionState(PlayerOption.chatSpy); } + @Deprecated public void setSpy(boolean spy) { + this.setOptionState(PlayerOption.chatSpy, spy); } + @Deprecated public boolean isCommandSpy() { - return commandSpy == null ? false : commandSpy; + return this.getOptionState(PlayerOption.cmdSpy); } + @Deprecated public void setCommandSpy(boolean spy, boolean save) { - + this.setOptionState(PlayerOption.cmdSpy, spy); } + @Deprecated public boolean isSignSpy() { - return signSpy == null ? false : signSpy; + return this.getOptionState(PlayerOption.signSpy); } + @Deprecated public void setSignSpy(boolean spy, boolean save) { - + this.setOptionState(PlayerOption.signSpy, spy); } public boolean isSame(CommandSender sender) { - if (sender instanceof Player) - return isSame((Player) sender); - return false; + if (sender instanceof Player) + return isSame((Player) sender); + return false; } public boolean isSame(Player player) { - return player.getUniqueId().equals(this.getUniqueId()); + return player.getUniqueId().equals(this.getUniqueId()); } public boolean isAfk() { - return getAfkInfo().getAfkFrom() != null; + return getAfkInfo().getAfkFrom() != null; } public AfkInfo getAfkInfo() { - if (afkInfo == null) - afkInfo = new AfkInfo(); - return afkInfo; + if (afkInfo == null) + afkInfo = new AfkInfo(); + return afkInfo; } public void setAfk(boolean afk) { - setAfk(afk, AfkType.manual); + setAfk(afk, AfkType.manual); } public void setAfk(boolean afk, AfkType type) { - setAfk(afk, type, true); + setAfk(afk, type, true); } public void setAfk(boolean afk, AfkType type, boolean performCommands) { - } - private void tunOnAfk(AfkType type, List cmds) { - + private void turnOnAfk(AfkType type, List cmds) { + } private void turnOffAfk(AfkType type, List cmds) { @@ -1058,123 +1127,135 @@ private void turnOffAfk(AfkType type, List cmds) { } public void setAfkReason(String reason) { - getAfkInfo().setReason(reason); + getAfkInfo().setReason(reason); } public String getAfkReason() { - return getAfkInfo().getReason(); + return getAfkInfo().getReason(); } public boolean isBanned() { - return false; + if (getBanEntry() != null) { + if (getBanEntry().getExpiration() == null) + return false; + if (getBanEntry().getExpiration() > System.currentTimeMillis()) + return true; + if (getBanEntry().getExpiration() == -1l) + return true; + } + return false; } public CMIUser setBanned() { - return setBanned(null, null, null, null); + return setBanned(null, null, null, null); } public CMIUser setBanned(String reason) { - return setBanned(reason, null, null, null); + return setBanned(reason, null, null, null); } public CMIUser setBanned(Date until) { - return setBanned(null, null, until, null); + return setBanned(null, null, until, null); } public CMIUser setBanned(String reason, Date until) { - return setBanned(reason, null, until, null); + return setBanned(reason, null, until, null); } public CMIUser setBanned(String reason, CommandSender by, Date until) { - if (by instanceof Player) - return setBanned(reason, CMI.getInstance().getPlayerManager().getUser((Player) by), until, new Date(System.currentTimeMillis())); - return setBanned(reason, null, until, new Date(System.currentTimeMillis())); + if (by instanceof Player) + return setBanned(reason, CMI.getInstance().getPlayerManager().getUser((Player) by), until, new Date(System.currentTimeMillis())); + return setBanned(reason, null, until, new Date(System.currentTimeMillis())); } public CMIUser setBanned(String reason, CMIUser by, Date until, Date when) { - - return this; + + return this; } public CMIUser unBan() { - - return this; + + return this; } public CMIBanEntry getBanEntryRaw() { - return this.ban; + return this.ban; } public CMIBanEntry getBanEntry() { - return getBanEntry(true); + return getBanEntry(true); } public void updateBanEntry(BanEntry entry) { - + } public CMIBanEntry getBanEntry(boolean update) { - - return this.ban; + + return this.ban; } public Set getIgnores() { - if (ignores == null) - ignores = new HashSet(); - return ignores; + if (ignores == null) + ignores = new HashSet(); + return ignores; } public String getIgnoresString() { - StringBuilder ig = new StringBuilder(); - - return ig.toString(); + StringBuilder ig = new StringBuilder(); + for (UUID one : getIgnores()) { + if (!ig.toString().isEmpty()) { + ig.append(PlayerManager.lineSeparator); + } + ig.append(one.toString()); + } + + return ig.toString(); } public void setIgnores(Set ignores) { - this.ignores = ignores; + this.ignores = ignores; } public void addIgnore(UUID ignore, boolean save) { - getIgnores().add(ignore); - if (save) - this.addForDelayedSave(); + getIgnores().add(ignore); + if (save) + this.addForDelayedSave(); } public void removeIgnore(UUID ignore) { - getIgnores().remove(ignore); + getIgnores().remove(ignore); } public boolean isIgnoring(UUID uuid) { - return getIgnores().contains(uuid) || getIgnores().contains(CMI.getInstance().getPlayerManager().getEmptyUserUUID()); + return getIgnores().contains(uuid) || getIgnores().contains(CMI.getInstance().getPlayerManager().getEmptyUserUUID()); } public boolean isSilenceMode() { - return silenceMode == null ? false : silenceMode; + return silenceMode == null ? false : silenceMode; } public void setSilenceMode(boolean silenceMode) { - this.silenceMode = silenceMode; + this.silenceMode = silenceMode; } public CMIVanish getVanish() { - if (vanish == null) - vanish = new CMIVanish(this); - return vanish; + if (vanish == null) + vanish = new CMIVanish(this); + return vanish; } public boolean isVanished() { - boolean vanished = isCMIVanished(); - - return vanished; + return false; } public boolean isCMIVanished() { - return false; + return false; } public void setVanished(boolean vanished) { - + } public void updateVanishMode() { @@ -1182,45 +1263,45 @@ public void updateVanishMode() { } public boolean isSitting() { - if (!this.isOnline()) - return false; - return CMI.getInstance().getAnimationManager().isSitting(getPlayer()); + if (!this.isOnline()) + return false; + return CMI.getInstance().getAnimationManager().isSitting(getPlayer()); } public String getMutedReason() { - if (!isMuted()) - return null; - return mutedReason; + if (!isMuted()) + return null; + return mutedReason; } public void setMutedReason(String reason) { - mutedReason = reason; + mutedReason = reason; } public Long getMutedUntil() { - return mutedUntil; + return mutedUntil; } public boolean isMuted() { - if (isShadowMuted()) - return true; - return mutedUntil == null || mutedUntil < System.currentTimeMillis() ? false : true; + if (isShadowMuted()) + return true; + return mutedUntil == null || mutedUntil < System.currentTimeMillis() ? false : true; } public void setMutedUntil(Long mutedUntil) { - this.mutedUntil = mutedUntil; + this.mutedUntil = mutedUntil; } public Long getShadowMutedUntil() { - return shadowMutedUntil; + return shadowMutedUntil; } public void setShadowMutedUntil(Long shadowMutedUntil) { - this.shadowMutedUntil = shadowMutedUntil; + this.shadowMutedUntil = shadowMutedUntil; } public boolean isShadowMuted() { - return shadowMutedUntil == null || shadowMutedUntil < System.currentTimeMillis() ? false : true; + return shadowMutedUntil == null || shadowMutedUntil < System.currentTimeMillis() ? false : true; } /** @@ -1228,20 +1309,20 @@ public boolean isShadowMuted() { * @param source only used to indicate from who money is deposited but doesn't deduct from it */ public Double deposit(Double balance, CMIUser source) { - return deposit(null, balance, source); + return deposit(null, balance, source); } public Double deposit(Double balance) { - return deposit(null, balance); + return deposit(null, balance); } public Double deposit(String worldName, Double balance) { - return deposit(worldName, balance, null); + return deposit(worldName, balance, null); } public Double deposit(String worldName, Double balance, CMIUser source) { - balance = balance == null ? 0D : balance; - return getEconomyAccount().deposit(worldName, balance, source); + balance = balance == null ? 0D : balance; + return getEconomyAccount().deposit(worldName, balance, source); } /** @@ -1249,495 +1330,501 @@ public Double deposit(String worldName, Double balance, CMIUser source) { * @param target only used to indicate who gets money but doesn't actually transfer to target player */ public Double withdraw(Double balance, CMIUser target) { - return withdraw(null, balance, target); + return withdraw(null, balance, target); } public Double withdraw(Double balance) { - return withdraw(null, balance); + return withdraw(null, balance); } public Double withdraw(String worldName, Double balance) { - return withdraw(worldName, balance, null); + return withdraw(worldName, balance, null); } public Double withdraw(String worldName, Double balance, CMIUser source) { - balance = balance == null ? 0D : balance; - return getEconomyAccount().withdraw(worldName, balance, source); + balance = balance == null ? 0D : balance; + return getEconomyAccount().withdraw(worldName, balance, source); } @Deprecated public boolean has(Double balance) { - return hasMoney(balance); + return hasMoney(balance); } public boolean hasMoney(Double balance) { - if (balance == 0D) - return true; - return has(null, balance); + if (balance == 0D) + return true; + return has(null, balance); } public boolean has(String worldName, Double balance) { - return getEconomyAccount().has(worldName, balance); + return getEconomyAccount().has(worldName, balance); } public Double getBalance() { - return getBalance(null); + return getBalance(null); } public Double getBalance(String worldName) { - return getEconomyAccount().getBalance(worldName); + return getEconomyAccount().getBalance(worldName); } public String getFormatedBalance() { - return getFormatedBalance(this.getWorld() == null ? EconomyManager.CMIDefaultWorld : this.getWorld().getName()); + return getFormatedBalance(this.getWorld() == null ? EconomyManager.CMIDefaultWorld : this.getWorld().getName()); } public String getFormatedBalance(boolean shorts) { - return getFormatedBalance(this.getWorld() == null ? EconomyManager.CMIDefaultWorld : this.getWorld().getName(), shorts); + return getFormatedBalance(this.getWorld() == null ? EconomyManager.CMIDefaultWorld : this.getWorld().getName(), shorts); } public String getFormatedBalance(String worldName) { - return getFormatedBalance(worldName, false); + return getFormatedBalance(worldName, false); } public String getFormatedBalance(String worldName, boolean shorts) { - return getEconomyAccount().getFormatedBalance(worldName, shorts); + return getEconomyAccount().getFormatedBalance(worldName, shorts); } public CMIEconomyAcount getEconomyAccount() { - if (this.economy == null) - this.economy = new CMIEconomyAcount(this); - return this.economy; + if (this.economy == null) + this.economy = new CMIEconomyAcount(this); + return this.economy; } public World getWorld() { - return this.getLogOutLocation() != null ? this.getLogOutLocation().getWorld() : null; + if (this.isOnline() && this.getPlayer() != null) + return this.getPlayer().getLocation().getWorld(); + return this.getLogOutLocation() != null ? this.getLogOutLocation().getWorld() : null; } public boolean respawn() { - - return true; + return true; } public void removeBossBar(String name) { - CMILib.getInstance().getBossBarManager().removeBossBar(this.getPlayer(false), name); + CMILib.getInstance().getBossBarManager().removeBossBar(this.getPlayer(false), name); } public void removeBossBar(BossBarInfo bossBar) { - CMILib.getInstance().getBossBarManager().removeBossBar(this.getPlayer(false), bossBar); + CMILib.getInstance().getBossBarManager().removeBossBar(this.getPlayer(false), bossBar); } public void addBossBar(BossBarInfo barInfo) { - CMILib.getInstance().getBossBarManager().addBossBar(this.getPlayer(false), barInfo); + if (this.getPlayer(false) == null || !this.getPlayer(false).isOnline()) + return; + CMILib.getInstance().getBossBarManager().addBossBar(this.getPlayer(false), barInfo); } public synchronized BossBarInfo getBossBar(String name) { - return CMILib.getInstance().getBossBarManager().getBossBar(this.getPlayer(false), name); + return CMILib.getInstance().getBossBarManager().getBossBar(this.getPlayer(false), name); } public synchronized ConcurrentHashMap getBossBarInfo() { - return CMILib.getInstance().getBossBarManager().getBossBarInfo(this.getPlayer(false)); + return CMILib.getInstance().getBossBarManager().getBossBarInfo(this.getPlayer(false)); } public synchronized void hideBossBars() { - CMILib.getInstance().getBossBarManager().hideBossBars(this.getPlayer(false)); + CMILib.getInstance().getBossBarManager().hideBossBars(this.getPlayer(false)); } public void clearBossMaps() { - CMILib.getInstance().getBossBarManager().clearBossMaps(this.getPlayer(false)); + CMILib.getInstance().getBossBarManager().clearBossMaps(this.getPlayer(false)); } public CMIPlayerInventory getInventory() { - return new CMIPlayerInventory(this); + return new CMIPlayerInventory(this); } public void updateInventory() { - if (this.isOnline()) - this.getPlayer().updateInventory(); + if (this.isOnline()) + this.getPlayer().updateInventory(); } public void setExp(int exp) { - + if (this.getPlayer() == null) + return; + exp = exp < 0 ? 0 : exp; + if (player == null) + return; + player.setLevel(0); + player.setExp(0); + player.setTotalExperience(0); + player.giveExp(exp); } public void addExp(int exp) { - if (this.getPlayer() == null) - return; - int old = getExp(); - setExp(old + exp); + if (this.getPlayer() == null) + return; + int old = getExp(); + setExp(old + exp); } public void takeExp(int exp) { - + if (this.getPlayer() == null) + return; + int old = getExp(); + setExp(old - exp); } public int getMissingExp() { - return 0; - + return 0; } public int getLevel() { - return 0; + if (this.getPlayer() == null) + return 0; + return this.getPlayer().getLevel(); } public int getExpForCurrentLevel() { - return 0; + return 0; } public int getExp() { - return 0; + return 0; } public int getExpToLevel(int level) { - return 0; + return 0; } public FlightCharge getFlightCharge() { - if (flightCharge == null) - flightCharge = new FlightCharge(); - return flightCharge; + if (flightCharge == null) + flightCharge = new FlightCharge(); + return flightCharge; } public boolean hasPermission(CMIPerm perm) { - return perm.hasPermission(this.getPlayer(false)); + return perm.hasPermission(this.getPlayer(false)); } public boolean hasSetPermission(CMIPerm perm) { - return perm.hasSetPermission(this.getPlayer(false)); + return perm.hasSetPermission(this.getPlayer(false)); } public boolean hasMeta() { - return getMeta().containsValues(); + return getMeta().containsValues(); } public PlayerMeta getMeta() { - if (PlayerMeta == null) - PlayerMeta = new PlayerMeta(); - return PlayerMeta; + if (PlayerMeta == null) + PlayerMeta = new PlayerMeta(); + return PlayerMeta; } public String getMeta(String Key) { - return getMeta().getValue(Key); + return getMeta().getValue(Key); } public boolean isAllowFlight() { - if (this.isOnline()) - return this.getPlayer().getAllowFlight(); - return AllowFlight == null ? false : AllowFlight; + if (this.isOnline()) + return this.getPlayer().getAllowFlight(); + return AllowFlight == null ? false : AllowFlight; } public void setAllowFlight(boolean allowFlight) { - AllowFlight = allowFlight; - if (this.isOnline()) { - this.getPlayer().setAllowFlight(allowFlight); - } } public void setGameMode(GameMode mode) { - CMI.getInstance().getReflectionManager().setGameMode(this.getPlayer(), mode); + CMI.getInstance().getReflectionManager().setGameMode(this.getPlayer(), mode); } public boolean wasFlying() { - return Flying == null ? false : Flying; + return Flying == null ? false : Flying; } public boolean hadAllowFlight() { - return hadAllowFlight == null ? false : hadAllowFlight; + return hadAllowFlight == null ? false : hadAllowFlight; } public void setHadAllowFlight(boolean allowFlight) { - hadAllowFlight = allowFlight; + hadAllowFlight = allowFlight; } public boolean setWasFlying(boolean flying) { - return Flying = flying; + return Flying = flying; } public boolean isFlying() { - if (this.isOnline()) - return this.getPlayer().isFlying(); - return Flying == null ? false : Flying; + if (this.isOnline()) + return this.getPlayer().isFlying(); + return Flying == null ? false : Flying; } public void setFlying(boolean flying) { - } public SavedInventories getSavedInventories() { - return CMI.getInstance().getSavedInventoryManager().getInventories(this); + return CMI.getInstance().getSavedInventoryManager().getInventories(this); } public int getVotifierVotes() { - return votifierVotes == null ? 0 : votifierVotes; + return votifierVotes == null ? 0 : votifierVotes; } public void setVotifierVotes(int votifierVotes) { - this.votifierVotes = votifierVotes; + this.votifierVotes = votifierVotes; } public boolean addVotifierVote() { - - return true; + return true; } public int getDailyVoteCount() { - return 0; + if (votifierVotesByTime == null || votifierVotesByTime.isEmpty()) + return 0; + + while (votifierVotesByTime.size() > CMI.getInstance().getVotifierManager().getMaxVotesInADay() + 1) { + votifierVotesByTime.remove(0); + } + + while (!votifierVotesByTime.isEmpty() && votifierVotesByTime.get(0) < System.currentTimeMillis() - (24 * 60 * 60 * 1000L)) { + votifierVotesByTime.remove(0); + } + return votifierVotesByTime.size(); } public Long getLastDailyVoteTime() { - return null; - + return null; } public boolean isJailed() { - return true; + return true; } public boolean jail(Long jailTimeSec, CMIJail jail, Integer cellId) { - return jail(jailTimeSec, jail, cellId, null); + return jail(jailTimeSec, jail, cellId, null); } public boolean jail(Long jailTimeSec, CMIJail jail, Integer cellId, String reason) { - this.jailedReason = reason; - boolean feed = CMI.getInstance().getJailManager().placePlayerIntoJail(this, jail, cellId, jailTimeSec * 1000); - if (feed) - setJailedForTime(jailTimeSec * 1000, true); - return feed; + this.jailedReason = reason; + boolean feed = CMI.getInstance().getJailManager().placePlayerIntoJail(this, jail, cellId, jailTimeSec * 1000); + if (feed) + setJailedForTime(jailTimeSec * 1000, true); + return feed; } public void unjail() { - CMI.getInstance().getJailManager().removePlayerFromJail(this); + CMI.getInstance().getJailManager().removePlayerFromJail(this); } public Long getJailedUntil() { - return System.currentTimeMillis() + getJailedForTime(); + return System.currentTimeMillis() + getJailedForTime(); } public void updateJailedTimeOnJoin() { - } public Long getJailedForTime() { - Long t = this.jailedForTime; - return t == null || t <= 0 ? 0 : t; + Long t = this.jailedForTime; + if (t != null && CMI.getInstance().getJailManager().isCountWhileOffline() && !this.isOnline() && this.getLastLogoff() > 0) { + t -= System.currentTimeMillis() - this.getLastLogoff(); + } + if (t != null && t <= 0) { + this.jailedForTime = null; + } + return t == null || t <= 0 ? 0 : t; } - public void setJailedForTime(Long jailedForTime) { - setJailedForTime(jailedForTime, false); + setJailedForTime(jailedForTime, false); } public void setJailedForTime(Long jailedForTime, boolean save) { - } public CMIJailCell getCell() { - return cell; + return cell; } public void setCell(CMIJailCell cell) { - if (this.cell != null) - this.cell.removeJailed(this.getUniqueId()); - if (cell != null) - cell.addJailed(this.getUniqueId()); - this.cell = cell; } public Boolean isFakeAccount() { -// if (recheck && isFakeAccount == null) -// isFakeAccount = CMI.getInstance().getPlayerManager().isFakeUUID(this.getUniqueId()); - return isFakeAccount == null ? false : isFakeAccount; + return isFakeAccount == null ? false : isFakeAccount; } public void setFakeAccount(Boolean isFakeAccount) { - this.isFakeAccount = isFakeAccount == null ? false : isFakeAccount; + this.isFakeAccount = isFakeAccount == null ? false : isFakeAccount; } public CMIPlayTime getCMIPlayTime() { - if (playTime == null) { - playTime = new CMIPlayTime(this); - } - return playTime; + if (playTime == null) { + playTime = new CMIPlayTime(this); + } + return playTime; } public void setCMIPlayTime(CMIPlayTime playTime) { - this.playTime = playTime; + this.playTime = playTime; } public void updatePlayTime() { - getCMIPlayTime().updatePlayTime(); + getCMIPlayTime().updatePlayTime(); } public Long getPlayTimeOptimizedOn() { - return PlayTimeOptimized == null ? 0L : PlayTimeOptimized; + return PlayTimeOptimized == null ? 0L : PlayTimeOptimized; } public void setPlayTimeOptimizedOn(Long playTimeOptimized) { - PlayTimeOptimized = playTimeOptimized; + PlayTimeOptimized = playTimeOptimized; } + @Deprecated public boolean isNoPayToggled() { - return noPayToggle == null ? false : noPayToggle; + return !this.getOptionState(PlayerOption.acceptingMoney); } + @Deprecated public void setNoPayToggled(boolean noPayToggle) { - this.noPayToggle = noPayToggle; + this.setOptionState(PlayerOption.acceptingMoney, noPayToggle); } public String getJailedReason() { - if (!this.isJailed()) - jailedReason = null; - return jailedReason; + if (!this.isJailed()) + jailedReason = null; + return jailedReason; } public void setJailedReason(String jailedReason) { - this.jailedReason = jailedReason; + this.jailedReason = jailedReason; } public ItemStack getItemInHand() { - return CMILib.getInstance().getReflectionManager().getItemInMainHand(this.getPlayer()); + return CMILib.getInstance().getReflectionManager().getItemInMainHand(this.getPlayer()); } public void setItemInHand(ItemStack item) { - if (getPlayer() != null) - getPlayer().getInventory().setItemInMainHand(item); + if (getPlayer() != null) + getPlayer().getInventory().setItemInMainHand(item); } public void setItemInOffHand(ItemStack item) { - if (getPlayer() != null && Version.isCurrentHigher(Version.v1_8_R3)) - getPlayer().getInventory().setItemInOffHand(item); + if (getPlayer() != null && Version.isCurrentHigher(Version.v1_8_R3)) + getPlayer().getInventory().setItemInOffHand(item); } public ItemStack getItemInOffHand() { - if (Version.isCurrentHigher(Version.v1_8_R3) && this.getPlayer() != null && this.getPlayer().getInventory() != null) - return this.getPlayer().getInventory().getItemInOffHand(); - return null; + if (Version.isCurrentHigher(Version.v1_8_R3) && this.getPlayer() != null && this.getPlayer().getInventory() != null) + return this.getPlayer().getInventory().getItemInOffHand(); + return null; } public boolean hasSetSkin() { - return skin != null; + return skin != null; } public String getSkin() { - return skin; + return skin; } public void setSkin(String skin) { - this.skin = skin; + this.skin = skin; } public int getPlayTimeRewardId() { - return playTimerewardId == null ? 0 : playTimerewardId; + return playTimerewardId == null ? 0 : playTimerewardId; } public void setPlayTimeRewardId(int playTimeRewardId) { - this.playTimerewardId = playTimeRewardId; + this.playTimerewardId = playTimeRewardId; } public String getPTRRString() { - String full = ""; - for (Entry one : getRepeatableRewards().entrySet()) { - if (!full.isEmpty()) - full += PlayerManager.lineSeparator; - full += one.getKey() + PlayerManager.mapKeySeparator + one.getValue(); - } - return full; + String full = ""; + return full; } public String getPTROString() { - String full = ""; - for (String one : getOneTimeRewards()) { - if (!full.isEmpty()) - full += PlayerManager.lineSeparator; - full += one; - } - return full; + String full = ""; + return full; } public HashMap getRepeatableRewards() { - if (repeatableRewards == null) - repeatableRewards = new HashMap(); - return repeatableRewards; + if (repeatableRewards == null) + repeatableRewards = new HashMap(); + return repeatableRewards; } public void addRepeatableReward(String name, long time) { - getRepeatableRewards().put(name.toLowerCase(), time); + getRepeatableRewards().put(name.toLowerCase(), time); } public Long getRepeatableRewardTime(String name) { - return getRepeatableRewards().get(name.toLowerCase()); + return getRepeatableRewards().get(name.toLowerCase()); } public Set getOneTimeRewards() { - if (oneTimeRewards == null) - oneTimeRewards = new HashSet(); - return oneTimeRewards; + if (oneTimeRewards == null) + oneTimeRewards = new HashSet(); + return oneTimeRewards; } public void addOneTimeReward(String name) { - getOneTimeRewards().add(name.toLowerCase()); + getOneTimeRewards().add(name.toLowerCase()); } public boolean isClaimedReward(PTROneTime reward) { - if (oneTimeRewards == null) - return false; + if (oneTimeRewards == null) + return false; - return oneTimeRewards.contains(reward.getName().toLowerCase()); + return oneTimeRewards.contains(reward.getName().toLowerCase()); } public void unloadData() { - if (this.player == null || this.isOnline()) - return; - CMI.getInstance().getNMS().unloadData(player); - this.player = null; - cacheClear(); + if (this.player == null || this.isOnline()) + return; + CMI.getInstance().getNMS().unloadData(player); + this.player = null; + cacheClear(); } public String getNamePlatePrefix() { - if (namePlatePrefix != null && Version.isCurrentEqualOrLower(Version.v1_15_R1) && namePlatePrefix.length() > 16) { - return namePlatePrefix.substring(0, 15); - } + if (namePlatePrefix != null && Version.isCurrentEqualOrLower(Version.v1_15_R1) && namePlatePrefix.length() > 16) { + return namePlatePrefix.substring(0, 15); + } - return namePlatePrefix; + return namePlatePrefix; } public void setNamePlatePrefix(String namePlatePrefix) { - this.namePlatePrefix = namePlatePrefix; - if (this.namePlatePrefix != null && this.namePlatePrefix.isEmpty()) - this.namePlatePrefix = null; + this.namePlatePrefix = namePlatePrefix; + if (this.namePlatePrefix != null && this.namePlatePrefix.isEmpty()) + this.namePlatePrefix = null; } public String getNamePlateSuffix() { - if (namePlateSuffix != null && Version.isCurrentEqualOrLower(Version.v1_15_R1) && namePlateSuffix.length() > 16) { - return namePlateSuffix.substring(0, 15); - } - return namePlateSuffix; + if (namePlateSuffix != null && Version.isCurrentEqualOrLower(Version.v1_15_R1) && namePlateSuffix.length() > 16) { + return namePlateSuffix.substring(0, 15); + } + return namePlateSuffix; } public void setNamePlateSuffix(String namePlateSuffix) { - this.namePlateSuffix = namePlateSuffix; - if (this.namePlateSuffix != null && this.namePlateSuffix.isEmpty()) - this.namePlateSuffix = null; + this.namePlateSuffix = namePlateSuffix; + if (this.namePlateSuffix != null && this.namePlateSuffix.isEmpty()) + this.namePlateSuffix = null; } public void setCollision(boolean state) { - collision = state; - applyCollision(); - if (collision) - collision = null; + collision = state; + applyCollision(); + if (collision) + collision = null; } public Boolean isCollidable() { - return collision == null ? true : collision; + return collision == null ? true : collision; } @Deprecated public Boolean getCollision() { - return isCollidable(); + return isCollidable(); } private void applyCollision() { @@ -1745,217 +1832,223 @@ private void applyCollision() { } public void reaplyNamePlate() { - + } public double getLookDirectionInDegrees() { - Location loc = this.getPlayer().getLocation(); - if (loc == null) - return 0; - return (int) (((loc.getYaw() + 540) % 360) * 100) / 100D; + Location loc = this.getPlayer().getLocation(); + if (loc == null) + return 0; + return (int) (((loc.getYaw() + 540) % 360) * 100) / 100D; } public CMIDirection getLookDirection() { - double deg = getLookDirectionInDegrees(); - return CMIDirection.getFromAngle(deg); + double deg = getLookDirectionInDegrees(); + return CMIDirection.getFromAngle(deg); } public List getWarnings() { - if (warnings == null) - warnings = new ArrayList(); - for (CMIPlayerWarning one : new ArrayList(warnings)) { - if (one.getGivenAt() + one.getCategory().getLifeTime() < System.currentTimeMillis()) - warnings.remove(one); - } - return warnings; + if (warnings == null) + warnings = new ArrayList(); + for (CMIPlayerWarning one : new ArrayList(warnings)) { + if (one.getGivenAt() + one.getCategory().getLifeTime() < System.currentTimeMillis()) + warnings.remove(one); + } + return warnings; } public void setWarnings(List warnings) { - this.warnings = warnings; + this.warnings = warnings; } public int getWarningPoints() { - int points = 0; - for (CMIPlayerWarning one : this.getWarnings()) { - points += one.getCategory().getPoints(); - } - return points; + int points = 0; + for (CMIPlayerWarning one : this.getWarnings()) { + points += one.getCategory().getPoints(); + } + return points; } public int removeWarning(CMIPlayerWarning warning) { - getWarnings().remove(warning); - return getWarningPoints(); + getWarnings().remove(warning); + return getWarningPoints(); } public CMIPlayerWarning addWarning(String source, String reason, CMIWarningCategory category) { - CMIPlayerWarning warning = new CMIPlayerWarning(); - return addWarning(warning); + CMIPlayerWarning warning = new CMIPlayerWarning(); + warning.setGivenAt(System.currentTimeMillis()); + warning.setGivenBy(source); + warning.setCategory(category == null ? CMI.getInstance().getWarningManager().getDefaultCategory() : category); + warning.setReason(reason.isEmpty() ? null : reason); + return addWarning(warning); } public CMIPlayerWarning addWarning(CMIPlayerWarning warning) { - getWarnings().add(warning); - return warning; + getWarnings().add(warning); + return warning; } public HashMap getWarningsAsMap() { - HashMap map = new HashMap(); - return map; + HashMap map = new HashMap(); + return map; } + @Deprecated public boolean isAcceptingPM() { - return acceptingPM == null ? true : acceptingPM; + return this.getOptionState(PlayerOption.acceptingPM); } + @Deprecated public void setAcceptingPM(boolean acceptingPM) { - this.acceptingPM = acceptingPM; + this.setOptionState(PlayerOption.acceptingPM, acceptingPM); } public Long getGotLastDamageAt() { - return combat == null ? null : combat.getGotLastDamageAt(); + return combat == null ? null : combat.getGotLastDamageAt(); } private CMIPlayerCombat getCombatRecord() { - if (combat == null) - combat = new CMIPlayerCombat(); - return combat; + if (combat == null) + combat = new CMIPlayerCombat(); + return combat; } public void setGotLastDamageAt(Long gotLastDamageAt) { - getCombatRecord().setGotLastDamageAt(gotLastDamageAt); + getCombatRecord().setGotLastDamageAt(gotLastDamageAt); } public boolean isInCombatWithPlayer() { - if (combat == null) - return false; - return combat.isInCombatWithPlayer(); + if (combat == null) + return false; + return combat.isInCombatWithPlayer(); } public Long getGotLastDamageFromPlayer() { - return combat == null ? 0L : combat.getGotLastDamageFromPlayer(); + return combat == null ? 0L : combat.getGotLastDamageFromPlayer(); } public void setGotLastDamageFromPlayer(Long gotLastDamageFromPlayer) { - if (!isInCombatWithPlayer()) - CMI.getInstance().getPlayerCombatManager().addPlayerIntoCombat(this); - getCombatRecord().setGotLastDamageFromPlayer(gotLastDamageFromPlayer); + if (!isInCombatWithPlayer()) + CMI.getInstance().getPlayerCombatManager().addPlayerIntoCombat(this); + getCombatRecord().setGotLastDamageFromPlayer(gotLastDamageFromPlayer); } public void setDidLastDamageToPlayer(Long didLastDamageToPlayer) { - if (!isInCombatWithPlayer()) - CMI.getInstance().getPlayerCombatManager().addPlayerIntoCombat(this); - getCombatRecord().setDidLastDamageToPlayer(didLastDamageToPlayer); + if (!isInCombatWithPlayer()) + CMI.getInstance().getPlayerCombatManager().addPlayerIntoCombat(this); + getCombatRecord().setDidLastDamageToPlayer(didLastDamageToPlayer); } public boolean isInCombatWithMob() { - if (combat == null) - return false; - return combat.isInCombatWithMob(); + if (combat == null) + return false; + return combat.isInCombatWithMob(); } public Long getGotLastDamageFromMob() { - return combat == null ? 0L : combat.getGotLastDamageFromMob(); + return combat == null ? 0L : combat.getGotLastDamageFromMob(); } public void setGotLastDamageFromMob(Long gotLastDamageFromMob) { - if (!isInCombatWithMob()) - CMI.getInstance().getPlayerCombatManager().addPlayerIntoMobCombat(this); - getCombatRecord().setGotLastDamageFromMob(gotLastDamageFromMob); + if (!isInCombatWithMob()) + CMI.getInstance().getPlayerCombatManager().addPlayerIntoMobCombat(this); + getCombatRecord().setGotLastDamageFromMob(gotLastDamageFromMob); } public void setDidLastDamageToEntity(Long didLastDamageToMob) { - if (!isInCombatWithMob()) { - CMI.getInstance().getPlayerCombatManager().addPlayerIntoMobCombat(this); - } - getCombatRecord().setDidLastDamageToMob(didLastDamageToMob); + if (!isInCombatWithMob()) { + CMI.getInstance().getPlayerCombatManager().addPlayerIntoMobCombat(this); + } + getCombatRecord().setDidLastDamageToMob(didLastDamageToMob); } public long getLeftCombatTime() { - if (combat == null) - return 0L; - return getCombatRecord().getLeftCombatTime(); + if (combat == null) + return 0L; + return getCombatRecord().getLeftCombatTime(); } public void sendMessage(String msg) { - if (this.isOnline()) - CMI.getInstance().sendMessage(this, msg); + if (this.isOnline()) + CMI.getInstance().sendMessage(this, msg); } public void sendMessage(String command, String shortPath, Object... variables) { - if (this.isOnline()) { - CMI.getInstance().info(command, this, shortPath, variables); - } + if (this.isOnline()) { + CMI.getInstance().info(command, this, shortPath, variables); + } } public boolean teleport(Entity ent) { - return teleport(ent.getLocation(), TeleportType.Unknown); + return teleport(ent.getLocation(), TeleportType.Unknown); } public boolean teleport(Location loc) { - return teleport(loc, TeleportType.Unknown); + return teleport(loc, TeleportType.Unknown); } public boolean teleport(Location loc, TeleportType type) { - type = type == null ? TeleportType.Unknown : type; - return CMI.getInstance().getTeleportations().teleport(this.getPlayer(), loc, type); + type = type == null ? TeleportType.Unknown : type; + return CMI.getInstance().getTeleportations().teleport(this.getPlayer(), loc, type); } public CompletableFuture teleportAsync(Location loc, TeleportType type) { - return CompletableFuture.supplyAsync(() -> CMI.getInstance().getTeleportations().getSafeLocationAsync(getPlayer(), loc, false, true, null)).thenApply(greeting -> { - try { - return CMI.getInstance().getTeleportations().teleportAsync(null, getPlayer(), true, greeting, type, true); - } catch (Throwable e) { - e.printStackTrace(); - } - return false; - }); + return CompletableFuture.supplyAsync(() -> CMI.getInstance().getTeleportations().getSafeLocationAsync(getPlayer(), loc, false, true, null)).thenApply(greeting -> { + try { + return CMI.getInstance().getTeleportations().teleportAsync(null, getPlayer(), true, greeting, type, true); + } catch (Throwable e) { + e.printStackTrace(); + } + return false; + }); } public Object getFakeEntity() { - return fakeEntity; + return fakeEntity; } public void setFakeEntity(Object fakeEntity) { - this.fakeEntity = fakeEntity; + this.fakeEntity = fakeEntity; } public HashMap getKills() { - if (kills == null) - kills = new HashMap(); - return kills; + if (kills == null) + kills = new HashMap(); + return kills; } public void addHeadDropCount(UUID uuid) { - PlayerKillCount killCount = getKills().get(uuid); - if (killCount == null) { - killCount = new PlayerKillCount(uuid); - getKills().put(uuid, killCount); - } - killCount.addHeadDropCount(); + PlayerKillCount killCount = getKills().get(uuid); + if (killCount == null) { + killCount = new PlayerKillCount(uuid); + getKills().put(uuid, killCount); + } + killCount.addHeadDropCount(); } public void addKill(UUID uuid) { - PlayerKillCount kill = getKills().get(uuid); - if (kill == null) { - kill = new PlayerKillCount(uuid); - getKills().put(uuid, kill); - } - kill.addKill(); + PlayerKillCount kill = getKills().get(uuid); + if (kill == null) { + kill = new PlayerKillCount(uuid); + getKills().put(uuid, kill); + } + kill.addKill(); } @Deprecated public double getHeadDropChance(UUID uuid) { - return getHeadDropChance(uuid, true); + return getHeadDropChance(uuid, true); } public double getHeadDropChance(UUID uuid, boolean addEnchantBonus) { - - return 0; + + return 0; } public HashMap getEntityKills() { - if (entityKills == null) - entityKills = new HashMap(); - return entityKills; + if (entityKills == null) + entityKills = new HashMap(); + return entityKills; } public void addEntityKill(EntityType type) { @@ -1963,150 +2056,185 @@ public void addEntityKill(EntityType type) { @Deprecated public double getEntityHeadDropChance(EntityType type) { - return getEntityHeadDropChance(type, true); + return getEntityHeadDropChance(type, true); } public double getEntityHeadDropChance(EntityType type, Boolean addEnchantBonus) { - return 0; + return 0; } public ChatColor getNamePlateNameColor() { - return namePlateNameColor; + return namePlateNameColor; } public void setNamePlateNameColor(ChatColor namePlateNameColor) { - this.namePlateNameColor = namePlateNameColor; + this.namePlateNameColor = namePlateNameColor; } public String getTagName() { - return tagName == null ? this.getName(false) : tagName; + return tagName == null ? this.getName(false) : tagName; } public void setTagName(String tagName) { - if (tagName.length() > 16) - tagName = tagName.substring(0, 15); - this.tagName = tagName; + if (tagName.length() > 16) + tagName = tagName.substring(0, 15); + this.tagName = tagName; } public Long getAfkImunityUntil() { - return afkImunity; + return afkImunity; + } + + public void addFlyToCache(String worldName, boolean state, boolean temp) { + tempFlyModes.put(worldName, new worldFlyState(state, temp)); } - public void addFlyToCache(String worldName, boolean state) { - tempFlyModes.put(worldName, state); + public worldFlyState getFlyCachedMode(String worldName) { + return tempFlyModes.get(worldName); } - public Boolean getFlyCachedMode(String worldName) { - return tempFlyModes.get(worldName); + public worldFlyState removeFlyCachedMode(String worldName) { + return tempFlyModes.remove(worldName); } public void clearCachedFlyModes() { - tempFlyModes.clear(); + tempFlyModes.clear(); } public Long getLastBlockLeave() { - return lastBlockLeave; + return lastBlockLeave; } public void setLastBlockLeave(Long lastBlockLeave) { - this.lastBlockLeave = lastBlockLeave; + this.lastBlockLeave = lastBlockLeave; } public CMIChatRoom getChatRoom() { - return chatRoom; + return chatRoom; } public boolean leaveChatRoom() { - if (this.chatRoom == null) - return false; - return this.chatRoom.removeUser(this); + if (this.chatRoom == null) + return false; + return this.chatRoom.removeUser(this); } public void joinChatRoom(String name) { - CMI.getInstance().getChatFormatManager().joinChatRoom(this, name); + CMI.getInstance().getChatFormatManager().joinChatRoom(this, name); } public void setChatRoom(CMIChatRoom cmiChatRoom) { - this.chatRoom = cmiChatRoom; - if (chatRoom != null && !chatRoom.getUsers().contains(this)) - chatRoom.getUsers().add(this); + this.chatRoom = cmiChatRoom; + if (chatRoom != null && !chatRoom.getUsers().contains(this)) + chatRoom.getUsers().add(this); } public void dropItemNearPlayer(ItemStack one) { - Location loc = this.getPlayer().getLocation(); - Vector direction = loc.getDirection().clone(); - direction.multiply(0.4); - this.getPlayer().getWorld().dropItem(loc.clone().add(0, 1, 0).add(direction), one); + Location loc = this.getPlayer().getLocation(); + Vector direction = loc.getDirection().clone(); + direction.multiply(0.4); + this.getPlayer().getWorld().dropItem(loc.clone().add(0, 1, 0).add(direction), one); } public void addItemDonationFrom(CMIItemDonations donation) { - if (donationsFrom == null) - donationsFrom = new HashMap(); - donationsFrom.put(donation.getDonor(), donation); + if (donationsFrom == null) + donationsFrom = new HashMap(); + donationsFrom.put(donation.getDonor(), donation); } public HashMap getPendingDonations() { - if (donationsFrom == null) - donationsFrom = new HashMap(); - return donationsFrom; + if (donationsFrom == null) + donationsFrom = new HashMap(); + return donationsFrom; } public Long getTeleportInvulnerability() { - return teleportInvulnerability; + return teleportInvulnerability; } public void setTeleportInvulnerability(Long teleportInvulnerability) { - this.teleportInvulnerability = teleportInvulnerability; + this.teleportInvulnerability = teleportInvulnerability; } public int getHungerSched() { - return hungerSched; + return hungerSched; } public void setHungerSched(int hungerSched) { - this.hungerSched = hungerSched; + this.hungerSched = hungerSched; } + @Deprecated public Boolean isToggledOffBBCompass() { - return toggleCompass == null ? !Config.CompassDefaultState : toggleCompass; + return this.getOptionState(PlayerOption.totemBossBar); } + @Deprecated public void setToggledOffBBCompass(Boolean toggleCompass) { - this.toggleCompass = toggleCompass; + this.setOptionState(PlayerOption.totemBossBar, toggleCompass); } public TreeMap getLastDamage() { - if (lastDamage == null) - lastDamage = new TreeMap(Collections.reverseOrder()); - return lastDamage; + if (lastDamage == null) + lastDamage = new TreeMap(Collections.reverseOrder()); + return lastDamage; } public damageInformation getLastDamage(damageInformation comparison) { - - return null; + return null; } public void addLastDamage(damageInformation lastDamage) { + + Iterator> iter = getLastDamage().entrySet().iterator(); + while (iter.hasNext()) { + Entry entry = iter.next(); + + if (entry.getKey() + CMI.getInstance().getPlayerCombatManager().getCombatTimer() * 1000L < System.currentTimeMillis()) { + iter.remove(); + } + } + getLastDamage().put(lastDamage.getTime(), lastDamage); } public void resetLastDamage() { - lastDamage = null; + lastDamage = null; } public static CMIUser getUser(String playerName) { - return CMI.getInstance().getPlayerManager().getUser(playerName); + return CMI.getInstance().getPlayerManager().getUser(playerName); } public static CMIUser getUser(OfflinePlayer player) { - return CMI.getInstance().getPlayerManager().getUser(player); + return CMI.getInstance().getPlayerManager().getUser(player); } public static CMIUser getUser(Player player) { - return CMI.getInstance().getPlayerManager().getUser(player); + return CMI.getInstance().getPlayerManager().getUser(player); } public static CMIUser getUser(UUID uuid) { - return CMI.getInstance().getPlayerManager().getUser(uuid); + return CMI.getInstance().getPlayerManager().getUser(uuid); + } + + public Boolean getOptionState(PlayerOption option) { + if (options == null) + return option.isEnabled(); + Boolean res = options.get(option); + return res == null ? option.isEnabled() : res; + } + + public HashMap getOptions() { + if (options == null) + options = new HashMap(); + return options; + } + + public void setOptionState(PlayerOption option, boolean state) { + + } + + public void setOptions(HashMap options) { } } diff --git a/src/com/Zrips/CMI/Containers/CMIVanish.java b/src/com/Zrips/CMI/Containers/CMIVanish.java index 88dc6e1..7462e9b 100644 --- a/src/com/Zrips/CMI/Containers/CMIVanish.java +++ b/src/com/Zrips/CMI/Containers/CMIVanish.java @@ -2,7 +2,6 @@ import java.util.HashMap; -import com.Zrips.CMI.CMI; import com.Zrips.CMI.commands.list.vanishedit.VanishAction; public class CMIVanish { @@ -12,62 +11,74 @@ public class CMIVanish { private HashMap map = new HashMap(); private Boolean wasCollidable = null; - + private Long vanishedFrom = null; + private Long playtimeAtVanishStart = null; + public void fromString(String line) { + } @Override public String toString() { - String line = ""; - return line; + String line = ""; + + return line; } private static String to(boolean state) { - return state ? "1" : "0"; + return state ? "1" : "0"; } private static boolean from(String state) { - return state.equals("1") ? true : false; + return state.equals("1") ? true : false; } public CMIVanish(CMIUser user) { - this.user = user; + this.user = user; } public CMIUser getUser() { - return user; + return user; } public void setUser(CMIUser user) { - this.user = user; + this.user = user; } public boolean is(VanishAction action) { - if (!map.containsKey(action) || map.get(action) == null) { - return action.isEnabled(); - } - return map.get(action); + if (!map.containsKey(action) || map.get(action) == null) { + return action.isEnabled(); + } + return map.get(action); } public void set(VanishAction action, boolean state) { - map.put(action, state); + map.put(action, state); } public Boolean getWasCollidable() { - return wasCollidable == null ? true : wasCollidable; + return wasCollidable == null ? true : wasCollidable; } public void setWasCollidable(Boolean wasCollidable) { - this.wasCollidable = wasCollidable; + this.wasCollidable = wasCollidable; } public Long getVanishedFrom() { - return vanishedFrom; + return vanishedFrom; } public void setVanishedFrom(Long vanishedFrom) { - this.vanishedFrom = vanishedFrom; + this.vanishedFrom = vanishedFrom; + } + + public Long getPlaytimeAtVanishStart() { + return playtimeAtVanishStart == null ? 0L : playtimeAtVanishStart; + } + + public void setPlaytimeAtVanishStart(Long playtimeAtAfkStart) { + this.playtimeAtVanishStart = playtimeAtAfkStart; } } diff --git a/src/com/Zrips/CMI/Containers/CommandAlias.java b/src/com/Zrips/CMI/Containers/CommandAlias.java index 0f7a2b8..1b1d446 100644 --- a/src/com/Zrips/CMI/Containers/CommandAlias.java +++ b/src/com/Zrips/CMI/Containers/CommandAlias.java @@ -1,15 +1,12 @@ package com.Zrips.CMI.Containers; import java.util.ArrayList; -import java.util.Arrays; +import java.util.HashSet; import java.util.List; -import java.util.regex.Matcher; +import java.util.Set; import java.util.regex.Pattern; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.Zrips.CMI.CMI; import net.Zrips.CMILib.Colors.CMIChatColor; @@ -22,10 +19,10 @@ public class CommandAlias { private boolean requiresPerm = false; private boolean tabComplete = true; private CommandAliasType type; - + private boolean overrideTab = false; private boolean addTabs = false; - + private boolean disableBase = false; private List customTabList = null; @@ -33,180 +30,217 @@ public class CommandAlias { private Boolean containsDynamic = null; -// public CommandAlias(String command, boolean state) { -// this.commands.add(command); -// this.state = state; -// } + private String fileName = null; + + private Set alternatives = new HashSet(); + private boolean alternative = false; + @Deprecated public CommandAlias(String alias, List commands, boolean state) { - this(alias, commands, state, null); + this(alias, commands, state, null); } + @Deprecated public CommandAlias(String alias, List commands, boolean state, CommandAliasType type) { - this(alias, commands, state, type, null); + this(alias, commands, state, type, null); } + @Deprecated public CommandAlias(String alias, List commands, boolean state, CommandAliasType type, String cmiCommandName) { - this.commands.addAll(commands); - this.state = state; - this.alias = CMIChatColor.stripColor(CMIChatColor.deColorize(alias)); - this.type = type; - this.cmiCommandName = cmiCommandName; + this.commands.addAll(commands); + this.state = state; + this.alias = CMIChatColor.stripColor(CMIChatColor.deColorize(alias)); + this.type = type; + this.cmiCommandName = cmiCommandName; + } + + public CommandAlias(String alias, String fileName, List commands, boolean state) { + this(alias, fileName, commands, state, null); + } + + public CommandAlias(String alias, String fileName, List commands, boolean state, CommandAliasType type) { + this(alias, fileName, commands, state, type, null); + } + + public CommandAlias(String alias, String fileName, List commands, boolean state, CommandAliasType type, String cmiCommandName) { + this.commands.addAll(commands); + this.state = state; + this.alias = CMIChatColor.stripColor(CMIChatColor.deColorize(alias)); + this.type = type; + this.cmiCommandName = cmiCommandName; + this.fileName = fileName; } public boolean getState() { - return state; + return state; } public void setState(boolean state) { - this.state = state; + this.state = state; } public String getCommand() { - if (commands.isEmpty()) - return ""; - return commands.get(0); + if (commands.isEmpty()) + return ""; + return commands.get(0); } public String getCleanCommand() { - return ""; + return ""; } public String getCommand(CommandSender sender, List args) { - return ""; - + return ""; + } public List getCommands() { - return commands; + return commands; } public String getCommandsForLore() { - - String lore = ""; - return lore; + String lore = ""; + return lore; } public String getAlias() { - return alias; + return alias; } Pattern patern = Pattern.compile("[$?][\\d][-]?"); public boolean containsDynamicVariables() { - if (containsDynamic == null) { - recalculateDynamicVariables(); - } - return containsDynamic == null ? false : containsDynamic; + if (containsDynamic == null) { + recalculateDynamicVariables(); + } + return containsDynamic == null ? false : containsDynamic; } public void recalculateDynamicVariables() { - containsDynamic = null; - for (String one : commands) { - Matcher match = patern.matcher(one); - if (match.find()) { - containsDynamic = true; - break; - } - } - if (containsDynamic == null) - containsDynamic = false; } public String getAliasBaseCommand() { - return alias.contains(" ") ? alias.split(" ")[0] : alias; + return alias.contains(" ") ? alias.split(" ")[0] : alias; } public String getAliasAsOneWord() { - return alias.replace(" ", "__"); + return alias.replace(" ", "__"); } public String getAliasAsOneWordNS() { - return alias.replace(" ", ""); + return alias.replace(" ", ""); } public void setAlias(String alias) { - this.alias = alias; + this.alias = alias; } public void setCommands(List commands) { - this.commands = commands; + this.commands = commands; } public boolean isRequiresPerm() { - return requiresPerm; + return requiresPerm; } public void setRequiresPerm(boolean requiresPerm) { - this.requiresPerm = requiresPerm; + this.requiresPerm = requiresPerm; } public CommandAliasType getType() { - return type == null ? CommandAliasType.custom : type; + return type == null ? CommandAliasType.custom : type; } public String getCmiCommandName() { - return cmiCommandName; - } + return cmiCommandName; + } public boolean isTabComplete() { - return tabComplete; + return tabComplete; } public void setTabComplete(boolean tabComplete) { - this.tabComplete = tabComplete; + this.tabComplete = tabComplete; } public List getCustomTabRawList() { - return customTabList; + return customTabList; } public CMITabComplete getCustomTab() { - return customTab; + return customTab; } public List getTabCompleteList(String[] args) { - if (customTab == null) - return new ArrayList(); - return customTab.getTabCompleteList(args); + if (customTab == null) + return new ArrayList(); + return customTab.getTabCompleteList(args); } public void recheckTabCompletes() { - this.customTab = new CMITabComplete(); - for (String tab : this.customTabList) { - this.customTab.addTabComplete(tab); - } + this.customTab = new CMITabComplete(); + for (String tab : this.customTabList) { + this.customTab.addTabComplete(tab); + } } public void setCustomTab(List customTab) { - this.customTab = new CMITabComplete(); - this.customTabList = customTab; - recheckTabCompletes(); + this.customTab = new CMITabComplete(); + this.customTabList = customTab; + recheckTabCompletes(); } public boolean isDisableBase() { - return disableBase; + return disableBase; } public void setDisableBase(boolean disableBase) { - this.disableBase = disableBase; + this.disableBase = disableBase; } public boolean isOverrideTab() { - return overrideTab; + return overrideTab; } public void setOverrideTab(boolean overrideTab) { - this.overrideTab = overrideTab; + this.overrideTab = overrideTab; } public boolean isAddTabs() { - return addTabs; + return addTabs; } public void setAddTabs(boolean addTabs) { - this.addTabs = addTabs; + this.addTabs = addTabs; + } + + public String getFileName() { + return fileName == null ? "CustomAlias" : fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public Set getAlternatives() { + return alternatives; + } + + public void setAlternatives(Set alternatives) { + this.alternatives = alternatives; + } + + public void addAlternative(String alternative) { + this.alternatives.add(alternative); + } + + public boolean isAlternative() { + return alternative; + } + + public void setAlternative(boolean alternative) { + this.alternative = alternative; } } diff --git a/src/com/Zrips/CMI/Containers/CommandReg.java b/src/com/Zrips/CMI/Containers/CommandReg.java index 94505dc..919339d 100644 --- a/src/com/Zrips/CMI/Containers/CommandReg.java +++ b/src/com/Zrips/CMI/Containers/CommandReg.java @@ -1,5 +1,6 @@ package com.Zrips.CMI.Containers; +import java.util.ArrayList; import java.util.List; import org.bukkit.command.Command; @@ -18,69 +19,72 @@ public abstract class CommandReg implements CommandExecutor, TabExecutor { private CommandAlias alias; public CommandReg(String command, CommandAlias alias) { - this.alias = alias; - this.command = command.toLowerCase(); + this.alias = alias; + this.command = command.toLowerCase(); } public boolean register() { - return register(null); + return register(null); } private static void unRegisterBukkitCommand(Command cmd) { - } public boolean register(String permission) { - - return false; + return true; } final static CommandMap getCommandMap() { - return cmap; + return cmap; } @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - return true; + return true; } @Override public List onTabComplete(CommandSender sender, Command cmd, String label, String[] args) { + if (!alias.isTabComplete()) + return new ArrayList(); + + if (alias.getType() == CommandAliasType.subbase) { + return CMI.getInstance().getTab().get(sender, alias.getCmiCommandName(), "cmi", args); + } - return CMI.getInstance().getTab().get(sender, command, "cmi", args); + return CMI.getInstance().getTab().get(sender, command, "cmi", args); } private final class ReflectCommand extends BukkitCommand { - private CommandReg exe = null; - private CommandAlias alias; - - protected ReflectCommand(String command, String permission, CommandAlias alias) { - super(command); - this.alias = alias; - if (permission != null) { - this.setPermission(permission); - } - } - - @Deprecated - protected ReflectCommand(String command) { - super(command); - } - - public void setExecutor(CommandReg exe) { - this.exe = exe; - } - - @Override - public boolean execute(CommandSender sender, String commandLabel, String[] args) { - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alais, String[] args) { - return null; - } + private CommandReg exe = null; + private CommandAlias alias; + + protected ReflectCommand(String command, String permission, CommandAlias alias) { + super(command); + this.alias = alias; + if (permission != null) { + this.setPermission(permission); + } + } + + @Deprecated + protected ReflectCommand(String command) { + super(command); + } + + public void setExecutor(CommandReg exe) { + this.exe = exe; + } + + @Override + public boolean execute(CommandSender sender, String commandLabel, String[] args) { + return true; + } + + @Override + public List tabComplete(CommandSender sender, String alais, String[] args) { + return null; + } } } diff --git a/src/com/Zrips/CMI/Containers/PlayerMail.java b/src/com/Zrips/CMI/Containers/PlayerMail.java index 407b3e3..dc19e33 100644 --- a/src/com/Zrips/CMI/Containers/PlayerMail.java +++ b/src/com/Zrips/CMI/Containers/PlayerMail.java @@ -4,12 +4,18 @@ public class PlayerMail { private String sender; private Long time; + private Long keepFor; private String message; - + public PlayerMail(String sender, Long time, String message) { + this(sender, time, message, 0L); + } + + public PlayerMail(String sender, Long time, String message, Long keepForSeconds) { this.sender = sender; this.time = time; this.message = message; + keepFor = keepForSeconds; } public String getSender() { @@ -36,4 +42,12 @@ public void setMessage(String message) { this.message = message; } + public Long getKeepFor() { + return keepFor == null ? 0L : keepFor; + } + + public void setKeepFor(Long keepFor) { + this.keepFor = keepFor; + } + } diff --git a/src/com/Zrips/CMI/Containers/RandomTeleport.java b/src/com/Zrips/CMI/Containers/RandomTeleport.java index 095c8d5..170edbc 100644 --- a/src/com/Zrips/CMI/Containers/RandomTeleport.java +++ b/src/com/Zrips/CMI/Containers/RandomTeleport.java @@ -3,112 +3,143 @@ import org.bukkit.Location; import org.bukkit.World; +import net.Zrips.CMILib.Container.CMILocation; + public class RandomTeleport { private boolean enabled = true; private int MaxDistance; private int MinDistance; - private Location loc; + private CMILocation loc; private boolean circle = false; private boolean ignoreWater = true; private boolean ignoreLava = true; + private boolean ignorePowderSnow = true; + private boolean surfaceOnly = false; private int MaxY = 256; private int MinY = 0; - public RandomTeleport(boolean enabled, World world, int MaxDistance, int MinDistance, int centerX, int centerZ) { - this.loc = new Location(world, centerX, world.getMaxHeight() / 2, centerZ); - this.MaxDistance = MaxDistance; - this.MinDistance = MinDistance; - this.enabled = enabled; + public RandomTeleport(boolean enabled, int MaxDistance, int MinDistance, CMILocation center) { + this.loc = center; + this.MaxDistance = MaxDistance; + this.MinDistance = MinDistance; + this.enabled = enabled; } public RandomTeleport(World world, int MaxDistance, int MinDistance, int centerX, int centerZ) { - this(true, world, MaxDistance, MinDistance, centerX, centerZ); + this(true, MaxDistance, MinDistance, new CMILocation(world, centerX, 63, centerZ)); } public RandomTeleport(World world) { - this(true, world, 100, 0, 0, 0); + this(true, 100, 0, new CMILocation(world, 0, 63, 0)); } public Location getCenter() { - return this.loc; + return this.loc; } @Deprecated public int getMaxCord() { - return this.MaxDistance; + return this.MaxDistance; } public int getMaxDistance() { - return this.MaxDistance; + return this.MaxDistance; } @Deprecated public int getMinCord() { - return this.MinDistance; + return this.MinDistance; } public int getMinDistance() { - return this.MinDistance; + return this.MinDistance; } public boolean isCircle() { - return circle; + return circle; } - public void setCircle(boolean circle) { - this.circle = circle; + public RandomTeleport setCircle(boolean circle) { + this.circle = circle; + return this; } public boolean isEnabled() { - return enabled; + return enabled; } - public void setEnabled(boolean enabled) { - this.enabled = enabled; + public RandomTeleport setEnabled(boolean enabled) { + this.enabled = enabled; + return this; } - public void setMinDistance(int minDistance) { - MinDistance = minDistance; + public RandomTeleport setMinDistance(int minDistance) { + MinDistance = minDistance; + return this; } - public void setMaxDistance(int maxDistance) { - MaxDistance = maxDistance; + public RandomTeleport setMaxDistance(int maxDistance) { + MaxDistance = maxDistance; + return this; } - public void setCenter(Location loc) { - this.loc = loc; + public RandomTeleport setCenter(CMILocation loc) { + this.loc = loc; + return this; } public boolean isIgnoreWater() { - return ignoreWater; + return ignoreWater; } - public void setIgnoreWater(boolean ignoreWater) { - this.ignoreWater = ignoreWater; + public RandomTeleport setIgnoreWater(boolean ignoreWater) { + this.ignoreWater = ignoreWater; + return this; } public boolean isIgnoreLava() { - return ignoreLava; + return ignoreLava; } - public void setIgnoreLava(boolean ignoreLava) { - this.ignoreLava = ignoreLava; + public RandomTeleport setIgnoreLava(boolean ignoreLava) { + this.ignoreLava = ignoreLava; + return this; } public int getMaxY() { - return MaxY; + return MaxY; } - public void setMaxY(int maxY) { - MaxY = maxY; + public RandomTeleport setMaxY(int maxY) { + MaxY = maxY; + return this; } public int getMinY() { - return MinY; + return MinY; + } + + public RandomTeleport setMinY(int minY) { + MinY = minY; + return this; + } + + public boolean isIgnorePowderedSnow() { + return ignorePowderSnow; + } + + public RandomTeleport setIgnorePowderSnow(boolean ignorePowderSnow) { + this.ignorePowderSnow = ignorePowderSnow; + return this; + } + + public boolean isSurfaceOnly() { + return surfaceOnly; } - public void setMinY(int minY) { - MinY = minY; + public RandomTeleport setSurfaceOnly(boolean surfaceOnly) { + this.surfaceOnly = surfaceOnly; + return this; } } diff --git a/src/com/Zrips/CMI/Containers/SleepStats.java b/src/com/Zrips/CMI/Containers/SleepStats.java index 20cd150..725f3a2 100644 --- a/src/com/Zrips/CMI/Containers/SleepStats.java +++ b/src/com/Zrips/CMI/Containers/SleepStats.java @@ -4,9 +4,7 @@ import org.bukkit.World; import org.bukkit.entity.Player; -import com.Zrips.CMI.CMI; import com.Zrips.CMI.Config; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; public class SleepStats { @@ -18,7 +16,6 @@ public class SleepStats { private int online; public SleepStats(World world) { - } public World getWorld() { @@ -43,6 +40,11 @@ public double getSleeping() { public int needToBeSleeping() { int min = Config.SleepingMinBeforeSpeeding; + if (Config.SleepingPercentage) { + double perc = min / 100D; + int needed = (int) Math.ceil(getTotal() * perc); + return needed; + } return min; } @@ -71,6 +73,12 @@ public int getOnline() { public int getWorldOnline() { int count = 0; + for (Player one : Bukkit.getOnlinePlayers()) { +// if (CMIPerm.sleepignore.hasSetPermission(one)) +// continue; + if (one.getWorld().equals(world)) + count++; + } return count; } diff --git a/src/com/Zrips/CMI/Containers/Snd.java b/src/com/Zrips/CMI/Containers/Snd.java index 91bf72e..dedd673 100644 --- a/src/com/Zrips/CMI/Containers/Snd.java +++ b/src/com/Zrips/CMI/Containers/Snd.java @@ -1,16 +1,11 @@ package com.Zrips.CMI.Containers; -import org.bukkit.Bukkit; -import org.bukkit.command.BlockCommandSender; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.command.RemoteConsoleCommandSender; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Logs.CMIDebug; - public class Snd { private Player sender; private String senderName; @@ -29,124 +24,139 @@ public Snd() { } public Snd(Player sender, Player target) { + this.sender = sender; + if (sender != null) + senderName = sender.getName(); + this.target = target; + if (target != null) + targetName = target.getName(); } public Player getPlayerSender() { - return sender; + return sender; } public ConsoleCommandSender getConsoleSender() { - return console; + return console; } public Snd setSender(Player sender) { - return this; + this.sender = sender; + if (sender != null) { + senderName = sender.getName(); + if (senderUser == null) + senderUser = CMI.getInstance().getPlayerManager().getUser(sender); + } + return this; } public Snd setSender(CMIUser user) { - return this; + this.senderUser = user; + if (senderUser != null) + senderName = senderUser.getName(); + return this; } public Snd setSender(CommandSender sender) { - return this; + return this; } public Snd setSender(ConsoleCommandSender console) { - this.console = console; - return this; + this.console = console; + return this; } public Player getPlayerTarget() { - return target; + return target; } public ConsoleCommandSender getConsoleTarget() { - return targetConsole; + return targetConsole; } public Snd setTarget(Player sender) { - return this; + return this; } public Snd setTarget(CMIUser user) { - this.targetUser = user; - return this; + this.targetUser = user; + return this; } public Snd setTarget(CommandSender sender) { - return this; + return this; } public Snd setTarget(ConsoleCommandSender console) { - this.targetConsole = console; - return this; + this.targetConsole = console; + return this; } public Player getPlayerSource() { - return source; + return source; } public ConsoleCommandSender getConsoleSource() { - return sourceConsole; + return sourceConsole; } public Snd setSource(Player sender) { - return this; + return this; } public Snd setSource(CMIUser user) { - this.sourceUser = user; - return this; + this.sourceUser = user; + return this; } public Snd setSource(CommandSender sender) { - return this; + return this; } public Snd setSource(ConsoleCommandSender console) { - this.sourceConsole = console; - return this; + this.sourceConsole = console; + return this; } public CMIUser getSenderUser() { - return senderUser; + return senderUser; } public void setSenderUser(CMIUser senderUser) { - this.senderUser = senderUser; + this.senderUser = senderUser; } public CMIUser getTargetUser() { - return targetUser; + return targetUser; } public void setTargetUser(CMIUser targetUser) { - this.targetUser = targetUser; + this.targetUser = targetUser; } public CMIUser getSourceUser() { - return sourceUser; + return sourceUser; } public void setSourceUser(CMIUser sourceUser) { - this.sourceUser = sourceUser; + this.sourceUser = sourceUser; } public String getSenderName() { - return senderName; + return senderName; } public Snd setSenderName(String senderName) { - this.senderName = senderName; - return this; + this.senderName = senderName; + return this; } public String getTargetName() { - return targetName; + return targetName; } public Snd setTargetName(String targetName) { - this.targetName = targetName; - return this; + this.targetName = targetName; + return this; } } diff --git a/src/com/Zrips/CMI/Containers/Speed.java b/src/com/Zrips/CMI/Containers/Speed.java index 9d38bfd..5fb3f88 100644 --- a/src/com/Zrips/CMI/Containers/Speed.java +++ b/src/com/Zrips/CMI/Containers/Speed.java @@ -4,18 +4,13 @@ import java.util.List; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; import net.Zrips.CMILib.BossBar.BossBarInfo; public class Speed { private BossBarInfo bb; private Player player; -// private Location loc; private boolean allowBoost = false; private boolean allowSuperBoost = false; @@ -33,105 +28,112 @@ public class Speed { private static int timeRange = (1000 / amount); public Speed(Player player) { - } private long getTime() { - - return this.time.get(0); + while (this.time.size() > amount) { + this.time.remove(0); + } + if (this.time.isEmpty()) + return System.currentTimeMillis(); + return this.time.get(0); } private Location getLocation() { - - return this.loc.get(0); + while (this.loc.size() > amount) { + this.loc.remove(0); + } + if (this.loc.isEmpty()) + return null; + return this.loc.get(0); } public double getSpeed() { - Location lc = getLocation(); - if (lc == null) - return 0D; + Location lc = getLocation(); + if (lc == null) + return 0D; - if (!player.getWorld().equals(lc.getWorld())) - return 0D; + if (!player.getWorld().equals(lc.getWorld())) + return 0D; - double dis = player.getLocation().distance(lc); - long time = System.currentTimeMillis() - getTime(); - return (int) (((dis / time) * 100D * 6 * 6) * 100) / 100D; + double dis = player.getLocation().distance(lc); + long time = System.currentTimeMillis() - getTime(); + return (int) (((dis / time) * 100D * 6 * 6) * 100) / 100D; } public void setLoc(Location loc) { - this.loc.add(loc); - while (this.loc.size() > amount) { - this.loc.remove(0); - } + this.loc.add(loc); + while (this.loc.size() > amount) { + this.loc.remove(0); + } } public boolean isGoodTime() { - if (time.isEmpty()) - return true; - return System.currentTimeMillis() - this.time.get(this.time.size() - 1) > timeRange; + if (time.isEmpty()) + return true; + return System.currentTimeMillis() - this.time.get(this.time.size() - 1) > timeRange; } public void setTime(Long time) { - this.time.add(time); - while (this.time.size() > amount) { - this.time.remove(0); - } + this.time.add(time); + while (this.time.size() > amount) { + this.time.remove(0); + } } public Long getBoost() { - return boost; + return boost; } public void setBoost(Long boost) { - this.boost = boost; + this.boost = boost; } public boolean isBoosting() { - return System.currentTimeMillis() - boost < 250; + return System.currentTimeMillis() - boost < 250; } public Long getSuperBoost() { - return superBoost; + return superBoost; } public void setSuperBoost(Long superBoost) { - this.superBoost = superBoost; + this.superBoost = superBoost; } public boolean isSuperBoosting() { - return System.currentTimeMillis() - superBoost < 1000; + return System.currentTimeMillis() - superBoost < 1000; } public boolean isAllowBoost() { - return allowBoost; + return allowBoost; } public boolean isAllowSuperBoost() { - return allowSuperBoost; + return allowSuperBoost; } public boolean isSpeedometer() { - return speedometer; + return speedometer; } public boolean isFree() { - return free; + return free; } public void setFree(boolean free) { - this.free = free; + this.free = free; } public BossBarInfo getBb() { - return bb; + return bb; } public void setBb(BossBarInfo bb) { - this.bb = bb; + this.bb = bb; } public boolean isShowDurability() { - return dura; + return dura; } } diff --git a/src/com/Zrips/CMI/Containers/worldFlyState.java b/src/com/Zrips/CMI/Containers/worldFlyState.java new file mode 100644 index 0000000..2e07260 --- /dev/null +++ b/src/com/Zrips/CMI/Containers/worldFlyState.java @@ -0,0 +1,30 @@ +package com.Zrips.CMI.Containers; + +public class worldFlyState { + + private boolean state = false; + private boolean temp = true; + + public worldFlyState( + boolean state, boolean temp) { + this.state = state; + this.temp = temp; + } + + public boolean isFlyEnabled() { + return state; + } + + public void setFlyEnabled(boolean state) { + this.state = state; + } + + public boolean isTemp() { + return temp; + } + + public void setTemp(boolean temp) { + this.temp = temp; + } + +} diff --git a/src/com/Zrips/CMI/CustomEventTrigers/AnvilLstener.java b/src/com/Zrips/CMI/CustomEventTrigers/AnvilLstener.java index e765337..b38bb0c 100644 --- a/src/com/Zrips/CMI/CustomEventTrigers/AnvilLstener.java +++ b/src/com/Zrips/CMI/CustomEventTrigers/AnvilLstener.java @@ -1,6 +1,9 @@ package com.Zrips.CMI.CustomEventTrigers; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; import com.Zrips.CMI.CMI; @@ -9,7 +12,16 @@ public class AnvilLstener implements Listener { private CMI plugin; public AnvilLstener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.NORMAL) + public void onitemRename(InventoryClickEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onItemRepair(InventoryClickEvent event) { + + } } \ No newline at end of file diff --git a/src/com/Zrips/CMI/Locale/CMILC.java b/src/com/Zrips/CMI/Locale/CMILC.java new file mode 100644 index 0000000..0c0a827 --- /dev/null +++ b/src/com/Zrips/CMI/Locale/CMILC.java @@ -0,0 +1,257 @@ +package com.Zrips.CMI.Locale; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Containers.CMIUser; + +import net.Zrips.CMILib.Messages.CMIMessages; + +public enum CMILC { + + info_Same("&cCan't open your own inventory for editing!"), + info_cantLoginWithDifCap("&cCan't login with different name capitalization! Old name: &e[oldName]&c. Current: &e[currentName]"), + info_Searching("&eSearching for player data, please wait, this can take some time to finish!"), + info_NoCommandWhileSleeping("&cCan't perform commands while sleeping!"), + info_PurgeNotEnabled("&cPurge function is not enabled in config file!"), + info_TeamManagementDisabled("&7This feature will have limited functionalaty while DisableTeamManagement is set to true!"), + info_NoGameMode("&cPlease use 0/1/2/3 or Survival/Creative/Adventure/Spectator or s/c/a/sp!"), + info_NameChange("&6[playerDisplayName] &elogged in, also known as: &6[namelist]"), + info_Cooldowns("&eThis command is on cooldown for another &6[time]"), + info_specializedCooldowns("&eCooldown in motion for this command, please wait &6[time]"), + info_specializedRunning("&eCommand still running, please wait &6[time]"), + info_CooldownOneTime("&eThis command can only be used once!"), + info_WarmUp_canceled("&eCommand was cancelled due to your movement"), + info_WarmUp_counter("!actionbar!&6--> Wait &e[time] &6seconds <--"), + info_WarmUp_DontMove("!title!&6Don't move!!subtitle!&7Wait &c[time] &7seconds"), + info_WarmUp_Boss_DontMove("&4Don't move for &7[autoTimeLeft] &4seconds!"), + info_WarmUp_Boss_WaitFor("&4Wait for &7[autoTimeLeft] &4seconds!"), + info_Spawner("&r[type] Spawner"), + info_FailedSpawnerMine("!actionbar!&cFailed to mine spawner. &7[percent]% &cdrop chance"), + info_ClickSpawner("!actionbar!&7[percent]% &eDrop chance"), + info_Elevator_created("&eCreated elevator sign"), + info_CantPlaceSpawner("&eCan't place spawner so close to another spawner (&6[range]&e)"), + info_ChunksLoading("&eWorld chunk data is still being loaded. Please wait a bit and try again."), + info_CantUseNonEncrypted("!actionbar!&cCommands on this item are not encrypted. Can't use them!"), + info_CantDecode("!actionbar!&cCan't decode message/command. Key file contains wrong key for this task. Inform server administration about this"), + info_CantTeleport("&eYou can't teleport because you have too many limited items. Scroll over this line to see the maximum amount of items allowed."), + info_BlackList("&e[material] [amount] &6Max: [max]"), + info_wrongPortal("&cYou are in incorrect area of effect"), + info_ItemWillBreak("!actionbar!&eYour item (&6[itemName]&e) will break soon! &e[current]&6/&e[max]"), + info_ArmorWillBreak("!actionbar!&eYour [itemName] will break soon! &e[current]&6/&e[max]"), + info_flyingToHigh("&cYou can't fly so high, max height is &6[max]&c!"), + info_specializedItemFail("&cCan't determine specialized item requirement by value: &7[value]"), + info_sunSpeeding("Sleeping [count] of [total] [hour] hour [speed]X speed"), + info_sleepersRequired("!actionbar!&f[sleeping] &7of &f[required] &7sleeping from required for night time speedup"), + info_sunSpeedingTitle("&7[hour]"), + info_skippingNight("!title!&7Skipping entire night"), + info_sunSpeedingSubTitle("&f[count]&7/&f[total] &7(&f[speed]X&7)"), + info_repairConfirm("&eClick to confirm &7[items] &eitem repair for &7[cost]"), + info_bookDate("&7Written at &f[date]"), + info_maintenance("&7Maintenance mode"), + info_mapLimit("&cCant go beyond 30 000 000 blocks"), + info_startedEditingPainting("&eYou started editing painting. Click any other block to cancel."), + info_canceledEditingPainting("&eYou canceled painting editing mode"), + info_changedPainting("!actionbar!&eChanged painting to &6[name] &ewith id of &6[id]"), + info_noSpam("!title!&cNo spamming!"), + info_noCmdSpam("!title!&cNo command spamming!"), + info_spamConsoleInform("&cPlayer (&7[playerName]&c) triggered (&7[rules]&c) chat filter with:&r [message]"), + info_FirstJoin("&eWelcome &6[playerDisplayName] &eto our server!", "This line can have extra variables: [totalUsers] [onlinePlayers]"), + info_LogoutCustom(" &6[playerDisplayName] &eleft the game"), + info_LoginCustom(" &6[playerDisplayName] &ejoined the game"), + info_deathlocation("&eYou died at x:&6[x]&e, y:&6[y]&e, z:&6[z]&e in &6[world]"), + info_book_exploit("&cYou cant create book with more than [amount] pages"), + info_combat_CantUseShulkerBox("&cCan't use shulker box while you are in combat with player. Wait: [time]"), + info_combat_CantUseCommand("!actionbar!&cCan't use command while in combat mode. Wait: [time]"), + info_combat_bossBarPvp("&cCombat mode [autoTimeLeft]"), + info_combat_bossBarPve("&2Combat mode [autoTimeLeft]"), + info_noSchedule("&cSchedule by this name is not found"), + info_totem_cooldown("&eTotem cooldown: [time]"), + info_totem_warmup("&eTotem effect: [time]"), + info_totem_cantConsume("&eTotem usage was denied due to its cooldown time"), + info_InventorySave_info("&8Info: &8[playerDisplayName]"), + info_InventorySave_saved("&e[time] &eInventory saved with id: &e[id]"), + info_InventorySave_NoSavedInv("&eThis player doesn't have any saved inventories"), + info_InventorySave_NoEntries("&4File exists, but no inventories were found!"), + info_InventorySave_CantFind("&eCan't find inventory with this id"), + info_InventorySave_TopLine("&e----------- &6[playerDisplayName] saved inventory &e-----------"), + info_InventorySave_List("&eid: &6[id]&e. &6[time]"), + info_InventorySave_KillerSymbol("&c \u2620"), + info_InventorySave_Click("&eClick to check ([id]) saved inventory"), + info_InventorySave_IdDontExist("&4This save Id doesn't exist!"), + info_InventorySave_Deleted("&eSaved inventory was successfully deleted!"), + info_InventorySave_Restored("&eYou have restored &e[sourcename] &einventory for &e[targetname] &euser."), + info_InventorySave_GotRestored("&eYour inventory was restored from &e[sourcename] &esaved inventory on &e[time]"), + info_InventorySave_LoadForSelf("&eLoad this inventory for your self"), + info_InventorySave_LoadForOwner("&eLoad this inventory for owner"), + info_InventorySave_NextInventory("&eNext inventory"), + info_InventorySave_PreviousInventory("&ePrevious inventory"), + info_InventorySave_Editable("&eEdit mode enabled"), + info_InventorySave_NonEditable("&eEdit mode disabled"), + info_vanishSymbolOn("&8[&7H&8]&r"), + info_vanishSymbolOff(""), + info_afkSymbolOn("&8[&7Afk&8]&r"), + info_afkSymbolOff(""), + info_beeinfo("!actionbar!&7Honey level: &e[level]&7/&e[maxlevel] &7Bees inside: &e[count]&7/&e[maxcount]"), + info_pvp_noGodDamage("!actionbar!&cYou can't damage players while being immortal"), + info_pve_noGodDamage("!actionbar!&cYou can't damage mobs while being immortal"), + info_InvEmpty_armor("&eYour armor slots should be empty!"), + info_InvEmpty_hand("&eYour hand should be empty!"), + info_InvEmpty_maininv("&eYour main inventory should be empty!"), + info_InvEmpty_maininvslots("&eYour main inventory should have atleast &6[count] &eempty slots!"), + info_InvEmpty_inv("&eYour inventory should be empty!"), + info_InvEmpty_offhand("&eYour offhand should be empty!"), + info_InvEmpty_quickbar("&eYour quick bar should be empty!"), + info_InvEmpty_quickbarslots("&eYour quick bar should have atleast &6[count] &eempty slots!"), + info_InvEmpty_subinv("&eYour sub inventory should be empty!"), + info_InvEmpty_subinvslots("&eYour sub inventory should have atleast &6[count] &eempty slots!"), + info_Relog("&eRelog might be needed for change to take effect"), + + info_time_days("&2[d]&7d:", "Mainly for placeholder playtime output", "Use + sign at the start of line to force include it even if specific and previous time values are 0", + "Use - sign at the start of line if you want to include it only if its value isn't 0. If entire output results into empty line, then we will output seconds value"), + info_time_hours("&2[h]&7h "), + info_time_minutes("&2[m]&7m "), + info_time_seconds("&2[s]&7s"), + + warp_list("&e[pos]. &6[warpName] &f- &7[worldName] ([x]:[y]:[z])"), + afk_off("&7Playing"), + afk_MayNotRespond("&ePlayer is AFK and may not respond"), + afk_MayNotRespondStaff("&eStaff member is AFK and may not respond. Try contacting us through discord"), + BossBar_hpBar("&f[victim] &e[current]&f/&e[max] &f(&c-[damage]&f)"), + Potion_Effects("&8Potion effects"), + Potion_List("&e[PotionName] [PotionAmplifier] &eDuration: &e[LeftDuration] &esec"), + Potion_NoPotions("&eNone"), + Information_Title("&8Players information"), + Information_Health("&eHealth: &6[Health]/[maxHealth]"), + Information_Hunger("&eHunger: &6[Hunger]"), + Information_Saturation("&eSaturation: &6[Saturation]"), + Information_Exp("&eExp: &6[Exp]"), + Information_NotEnoughExp("&eNot enough exp: &6[Exp]"), + Information_NotEnoughExpNeed("&eNot enough exp: &6[Exp]/[need]"), + Information_tooMuchExp("&eToo much exp: &6[Exp]/[need]"), + Information_NotEnoughVotes("&eNot enough votes: &6[votes]"), + Information_TooMuchVotes("&eToo many votes: &6[votes]"), + Information_BadGameMode("&cYou can't do this in your current game mode"), + Information_BadArea("&cYou can't perform this action in this area"), + Information_GameMode("&eGameMode: &6[GameMode]"), + Information_Flying("&eFlying: &6[Flying]"), + Information_Uuid("&6[uuid]"), + Information_FirstConnection("&eFirst connection: &6[time]"), + Information_Lastseen("&eLast seen: &6[time]"), + Information_Onlinesince("&eOnline since: &6[time]"), + Information_Money("&eBalance: &6[money]"), + Information_Group("&eGroup: &6[group]"), + econ_commandCost("&7This command cost is &6[cost] &7repeat it or click here to confirm"), + econ_disabled("&cCan't use this command while economy support is disabled"), + Elytra_Speed("&eSpeed: &6[speed]&ekm/h"), + Elytra_SpeedBoost(" &a+ "), + Elytra_SpeedSuperBoost(" &2+ "), + Elytra_CanUse("&cCan't equip elytra without permission!"), + Elytra_CantGlide("&cCan't use elytra here!"), + Elytra_Charging("&eCharging &f[percentage]&e%"), + NetherPortal_ToHigh("&cPortal is to big, max height is &6[max]&c!"), + NetherPortal_ToWide("&cPortal is to wide, max width is &6[max]&c!"), + NetherPortal_Creation("!actionbar!&7Created [height]x[width] nether portal!"), + NetherPortal_Disabled("&cPortal creation disabled!"), + Ender_Title("&7Open ender chest"), + Chat_localPrefix(""), + Chat_shoutPrefix("&c[S]&r"), + Chat_LocalNoOne("!actionbar!&cNobody hear you, write ! before message for global chat"), + Chat_shoutDeduction("!actionbar!&cDeducted &e[amount] &cfor shout"), + Chat_publicHover(Arrays.asList("&eSent time: &6%server_time_hh:mm:ss%"), "Use \\n to add new line"), + Chat_privateHover(Arrays.asList("&eSent time: &6%server_time_hh:mm:ss%")), + Chat_staffHover(Arrays.asList("&eSent time: &6%server_time_hh:mm:ss%")), + Chat_helpopHover(Arrays.asList("&eSent time: &6%server_time_hh:mm:ss%")), + Chat_link("&l&4[&7LINK&4]"), + Chat_item("&7[%cmi_iteminhand_realname%[amount]&7]"), + Chat_itemAmount(" x[amount]"), + Chat_itemEmpty("&7[Mighty fist]"), + + Spy_Chat_msg("&2Spy&7[&8[senderDisplayName] &7-> &8[playerDisplayName]&7]&f [message]"), + Spy_Chat_custom("&2Spy&8[senderDisplayName] &7-> &4|&8[place]&4|&f [message]"), + Spy_Command_msg("&5C&2Spy&7[&8[senderDisplayName]&7]&7: &f[command]"), + Spy_Sign_msg("&5Sign&2Spy&7[&8[senderDisplayName]&7]&7: &f[text]"), + + info_CommandFormat("&cIncorrect command format"), + info_ServerSwitchOut(" &6[playerDisplayName] &eswitched server to &6[serverName]"), + info_ServerSwitchIn(" &6[playerDisplayName] &ecame from &6[serverName] &eserver"), + + info_months("&e[months] &6months "), + info_oneMonth("&e[months] &6month "), + info_weeks("&e[weeks] &6weeks "), + info_oneWeek("&e[weeks] &6week "), + + ; + + private String text; + private List comments = new ArrayList(); + + private CMILC(String text) { + this(text, ""); + } + + private CMILC(String text, String... comment) { + this.text = text; + if (comment != null && comment.length > 0) + for (String one : comment) { + if (one.isEmpty()) + continue; + comments.add(one); + } + } + + private CMILC(List ls) { + this(ls, ""); + } + + private CMILC(List ls, String... comment) { + if (this.text == null) + this.text = ""; + for (String one : ls) { + if (!this.text.isEmpty()) + this.text += " /n"; + this.text += one; + } + + if (comment != null && comment.length > 0) + for (String one : comment) { + if (one.isEmpty()) + continue; + comments.add(one); + } + } + + public String getText() { + return text; + } + + public String getPt() { + return this.name().replace("_", "."); + } + + public List getComments() { + return comments; + } + + public String getLocale(Object... values) { + return getMsg(this, values); + } + + public void sendMessage(Object sender, Object... values) { + + if (sender instanceof CMIUser) { + CMIUser user = (CMIUser) sender; + if (!user.isOnline()) + return; + sender = user.getPlayer(); + } + + CMIMessages.sendMessage(sender, getLocale(values)); + } + + private static String getMsg(CMILC lc, Object... variables) { + return CMI.getInstance().getPlaceholderAPIManager().updatePlaceHolders(""); + } +} diff --git a/src/com/Zrips/CMI/Locale/Language.java b/src/com/Zrips/CMI/Locale/Language.java index 13db28a..6861d55 100644 --- a/src/com/Zrips/CMI/Locale/Language.java +++ b/src/com/Zrips/CMI/Locale/Language.java @@ -1,8 +1,10 @@ package com.Zrips.CMI.Locale; +import java.io.File; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.regex.Matcher; import org.bukkit.Location; import org.bukkit.configuration.file.FileConfiguration; @@ -13,6 +15,7 @@ import com.Zrips.CMI.Containers.Snd; import net.Zrips.CMILib.Colors.CMIChatColor; +import net.Zrips.CMILib.Locale.YmlMaker; public class Language { public FileConfiguration enlocale; @@ -21,17 +24,28 @@ public class Language { private CMI plugin; public Language(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } /** * Reloads the config */ public void reload() { + try { + Customlocale = new YmlMaker(plugin, "Translations" + File.separator + "Locale_" + plugin.getConfigManager().Lang + ".yml").getConfig(); + } catch (Exception ex) { + ex.printStackTrace(); + } } private FileConfiguration getEN() { - return enlocale; + if (enlocale == null) + try { + enlocale = new YmlMaker(plugin, "Translations" + File.separator + "Locale_EN.yml").getConfig(); + } catch (Exception ex) { + ex.printStackTrace(); + } + return enlocale; } /** @@ -41,46 +55,70 @@ private FileConfiguration getEN() { */ public String getMessage(String key, Object... variables) { - return CMIChatColor.translate(""); + return CMIChatColor.translate(""); } public String filterNewLine(String msg) { - return ""; + return msg; } public List updateSnd(Snd snd, List msg) { - return null; + for (int i = 0, l = msg.size(); i < l; ++i) { + msg.set(i, updateSnd(snd, msg.get(i))); + } + return msg; } public String updateSnd(Snd snd, String msg) { - return ""; + return msg; } @SuppressWarnings("deprecation") public String replacePlayer(String type, Player player, Player whoGets, String msg) { - return ""; + return msg; } public String replaceUser(String type, CMIUser user, String msg) { + return replaceUser(type, user, null, msg); + } + + public String replaceUser(String type, CMIUser user, Player whoGets, String msg) { - return ""; + return msg; } public String replacePlayer(String type, Location loc, String msg) { - return ""; + + return msg; } public String replacePlayer(Location loc, String msg) { - return ""; + return msg; + } + + private static String outReplace(String msg, Object what, Object with) { + if (what == null) + return msg; + if (with == null) + with = ""; + return msg.replace(String.valueOf(what), String.valueOf(with)); + } + + private static String replace(String msg, Object what, Object with) { + if (what == null) + return msg; + if (with == null) + with = ""; + return msg.replaceAll(String.valueOf("(?i)(\\[" + what + "\\])"), Matcher.quoteReplacement(String.valueOf(with))); } public String getDefaultMessage(String key) { - return CMIChatColor.translate(""); + return CMIChatColor.translate(""); } /** @@ -89,16 +127,19 @@ public String getDefaultMessage(String key) { * @return the message */ public List getMessageList(String key, Object... variables) { + String missing = "Missing locale for " + key + " "; + + List ls = null; - return null; + return ls; } public boolean isList(String key) { - if (Customlocale != null && Customlocale.contains(key)) - return Customlocale.isList(key); - if (getEN().contains(key)) - return getEN().isList(key); - return false; + if (Customlocale != null && Customlocale.contains(key)) + return Customlocale.isList(key); + if (getEN().contains(key)) + return getEN().isList(key); + return false; } /** @@ -107,16 +148,23 @@ public boolean isList(String key) { * @return true/false */ public boolean containsKey(String key) { - if (Customlocale != null && Customlocale.contains(key)) - return true; - return getEN().contains(key); + if (Customlocale != null && Customlocale.contains(key)) + return true; + return getEN().contains(key); } public boolean isString(String key) { - return getEN().isString(key); + return getEN().isString(key); } public Set getKeys(String path) { - return new HashSet(); + if (!plugin.getConfigManager().Lang.equalsIgnoreCase("EN") && Customlocale != null && Customlocale.isConfigurationSection(path)) { + return Customlocale.getConfigurationSection(path).getKeys(false); + } + if (getEN() != null && getEN().isConfigurationSection(path)) { + return getEN().getConfigurationSection(path).getKeys(false); + } + + return new HashSet(); } } diff --git a/src/com/Zrips/CMI/Modules/AStand/ArmorStandCopy.java b/src/com/Zrips/CMI/Modules/AStand/ArmorStandCopy.java index 0827c08..211a803 100644 --- a/src/com/Zrips/CMI/Modules/AStand/ArmorStandCopy.java +++ b/src/com/Zrips/CMI/Modules/AStand/ArmorStandCopy.java @@ -45,8 +45,6 @@ public Set getCopy() { } public void duplicateOn(ArmorStand stand) { - CMI.getInstance().getArmorStandManager().duplicate(this.stand, stand, getCopy()); - CMI.getInstance().getArmorStandManager().duplicateExtra(this.stand, stand, getExtraCopy()); } public Set getExtraCopy() { diff --git a/src/com/Zrips/CMI/Modules/AStand/ArmorStandListener.java b/src/com/Zrips/CMI/Modules/AStand/ArmorStandListener.java index 50e269c..192a789 100644 --- a/src/com/Zrips/CMI/Modules/AStand/ArmorStandListener.java +++ b/src/com/Zrips/CMI/Modules/AStand/ArmorStandListener.java @@ -3,7 +3,11 @@ import java.util.HashMap; import java.util.UUID; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; import com.Zrips.CMI.CMI; @@ -11,9 +15,24 @@ public class ArmorStandListener implements Listener { private CMI plugin; public ArmorStandListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public static HashMap acMap = new HashMap(); + @EventHandler + public void onBlockInteract(PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onArmorStandDeath(EntityDeathEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void armorStandSpawnEvent(final org.bukkit.event.entity.CreatureSpawnEvent event) { + + } + } diff --git a/src/com/Zrips/CMI/Modules/AStand/ArmorStandListener1_8.java b/src/com/Zrips/CMI/Modules/AStand/ArmorStandListener1_8.java index f47e679..3e2a9a7 100644 --- a/src/com/Zrips/CMI/Modules/AStand/ArmorStandListener1_8.java +++ b/src/com/Zrips/CMI/Modules/AStand/ArmorStandListener1_8.java @@ -1,6 +1,11 @@ package com.Zrips.CMI.Modules.AStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; import com.Zrips.CMI.CMI; @@ -11,4 +16,31 @@ public ArmorStandListener1_8(CMI plugin) { this.plugin = plugin; } + public static boolean checkInteract(Player player, Entity ent) { + return true; + } + + public static boolean checkManipulation(Player player, Entity ent) { + return true; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPlayerInteractAtEntityEvent(PlayerInteractAtEntityEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void PlayerInteractAtEntityEvent(PlayerInteractAtEntityEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void editorCheck(PlayerInteractAtEntityEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void vanillaBugFix(final PlayerInteractAtEntityEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/AStand/ArmorStandManager.java b/src/com/Zrips/CMI/Modules/AStand/ArmorStandManager.java index 848da4f..abf6ae0 100644 --- a/src/com/Zrips/CMI/Modules/AStand/ArmorStandManager.java +++ b/src/com/Zrips/CMI/Modules/AStand/ArmorStandManager.java @@ -1,6 +1,7 @@ package com.Zrips.CMI.Modules.AStand; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Set; import java.util.UUID; @@ -9,9 +10,11 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.EulerAngle; +import org.bukkit.util.Vector; import com.Zrips.CMI.CMI; +import net.Zrips.CMILib.FileHandler.ConfigReader; import net.Zrips.CMILib.GUI.CMIGui; import net.Zrips.CMILib.GUI.GUIManager.GUIClickType; @@ -20,114 +23,188 @@ public class ArmorStandManager { private CMI plugin; public ArmorStandManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } private static HashMap last = new HashMap(); private static HashMap editing = new HashMap(); + private LinkedHashMap savedArmorStands = new LinkedHashMap(); + + public static final String savedArmorStandLabel = "CMISavedArmorStand"; + + public static boolean ArmorStandsCheckBlockPlace = true; + public static boolean TemplatesSpecificPermission = true; + + public void loadConfig(ConfigReader cfg) { + + } + public enum armorStandPoseC { - x, y, z; + x, y, z; } public enum armorStandExtraActions { - updateitems, plate, size, visible, arms, gravity, glow, invulnerable, name, interactable; - - public static armorStandExtraActions getByName(String name) { - for (armorStandExtraActions one : armorStandExtraActions.values()) { - if (one.name().equalsIgnoreCase(name)) - return one; - } - return null; - } + updateitems, plate, size, visible, arms, gravity, glow, invulnerable, name, interactable; + + public static armorStandExtraActions getByName(String name) { + for (armorStandExtraActions one : armorStandExtraActions.values()) { + if (one.name().equalsIgnoreCase(name)) + return one; + } + return null; + } } public enum armorStandActions { - head, body, torso, leftArm, rightArm, leftLeg, rightLeg, pos; + head, body, torso, leftArm, rightArm, leftLeg, rightLeg, pos; + + public static armorStandActions getByName(String name) { + for (armorStandActions one : armorStandActions.values()) { + if (one.name().equalsIgnoreCase(name)) + return one; + } + return null; + } + } - public static armorStandActions getByName(String name) { - for (armorStandActions one : armorStandActions.values()) { - if (one.name().equalsIgnoreCase(name)) - return one; - } - return null; - } + public enum armorStandSaveOptions { + helmet, chest, offhand, mainhand, leggings, boots, + name, body, + plate, size, visible, arms, gravity, glow, invulnerable, interactable, + head(new Vector(-30, -50, -30), new Vector(30, 50, 30)), + torso(new Vector(-5, -20, -5), new Vector(5, 20, 5)), + leftArm(new Vector(-160, -35, -150), new Vector(20, 40, 5), new Vector(-10.0, 0.0, -10.0)), + rightArm(new Vector(-160, -40, -5), new Vector(20, 35, 150), new Vector(-14.99, 0.0, 10.0)), + leftLeg(new Vector(-85, -10, -35), new Vector(25, 10, 5), new Vector(-1.0, 0.0, -1.0)), + rightLeg(new Vector(-85, -10, -5), new Vector(25, 10, 35), new Vector(1.0, 0.0, 1.0)); + + private Vector defaults = new Vector(0D, 0D, 0D); + + private Vector min = new Vector(0, 0, 0); + private Vector max = new Vector(0, 0, 0); + + armorStandSaveOptions() { + + } + + armorStandSaveOptions(Vector min, Vector max, Vector defaults) { + this.min = min; + this.max = max; + this.defaults = defaults; + } + + armorStandSaveOptions(Vector min, Vector max) { + this.min = min; + this.max = max; + } + + public static armorStandSaveOptions getByName(String name) { + for (armorStandSaveOptions one : armorStandSaveOptions.values()) { + if (one.name().equalsIgnoreCase(name)) + return one; + } + return null; + } + + public Vector getDefault() { + return defaults; + } + + public Vector getMin() { + return min; + } + + public Vector getMax() { + return max; + } } public enum armorStandEditorSlots { - helmet(1), chest(10), offhand(11), mainhand(9), leggings(19), boots(28); + helmet(11), chest(20), offhand(21), mainhand(19), leggings(29), boots(38); - private int slot; + private int slot; - armorStandEditorSlots(int slot) { - this.slot = slot; - } + armorStandEditorSlots(int slot) { + this.slot = slot; + } - public int getSlot() { - return slot; - } + public int getSlot() { + return slot; + } - public static armorStandEditorSlots getBySlot(int slot) { - for (armorStandEditorSlots one : armorStandEditorSlots.values()) { - if (one.getSlot() == slot) - return one; - } - return null; - } + public static armorStandEditorSlots getBySlot(int slot) { + for (armorStandEditorSlots one : armorStandEditorSlots.values()) { + if (one.getSlot() == slot) + return one; + } + return null; + } } public Entity getLast(Player player) { - return null; + return null; } public boolean isBeingEdited(UUID uuid) { - return false; + return false; } public UUID getEditorOf(UUID uuid) { - return null; + return null; } public boolean isTooFar(Player player, Entity ent) { - Location loc1 = player.getLocation(); - Location loc2 = ent.getLocation(); + Location loc1 = player.getLocation(); + Location loc2 = ent.getLocation(); - if (!loc1.getWorld().equals(loc2.getWorld())) - return true; + if (!loc1.getWorld().equals(loc2.getWorld())) + return true; - return loc1.distance(loc2) > 20; + return loc1.distance(loc2) > 20; } public boolean openCopyWindow(Player player, ArmorStand armor) { - return true; + return true; + } + + public boolean openSaveWindow(Player player, Entity ent) { + + return true; } public boolean openEditor(Player player, Entity ent, boolean checkInteraction) { - return true; + return true; + } + + public boolean openPositionEditor(Player player, Entity ent) { + + return true; } private int getValue(GUIClickType type) { - switch (type) { - case Left: - return 1; - case LeftShift: - return 10; - case MiddleMouse: - return 0; - case Right: - return -1; - case RightShift: - return -10; - default: - break; - } - return 0; + switch (type) { + case Left: + return 1; + case LeftShift: + return 10; + case MiddleMouse: + case Q: + return 0; + case Right: + return -1; + case RightShift: + return -10; + default: + break; + } + return 0; } private void setAngleButtons(CMIGui gui, ArmorStand armor, armorStandActions pose, int startSlot) { @@ -136,12 +213,24 @@ private void setAngleButtons(CMIGui gui, ArmorStand armor, armorStandActions pos public boolean isOk(CMIGui gui) { - return true; + return true; } private static double getAngle(ArmorStand armor, armorStandActions apose, armorStandPoseC coord) { - return 0D; + return 0D; + } + + private static EulerAngle getEulerAngle(ArmorStand armor, armorStandActions apose, armorStandPoseC coord) { + EulerAngle pose = null; + + return pose; + } + + private static void duplicate(armorStandActions part, ArmorStand source, ArmorStand target) { + setAngle(target, part, armorStandPoseC.x, getEulerAngle(source, part, armorStandPoseC.x)); + setAngle(target, part, armorStandPoseC.y, getEulerAngle(source, part, armorStandPoseC.y)); + setAngle(target, part, armorStandPoseC.z, getEulerAngle(source, part, armorStandPoseC.z)); } public void duplicate(ArmorStand source, ArmorStand target, Set copy) { @@ -152,9 +241,14 @@ public void duplicateExtra(ArmorStand source, ArmorStand target, Set getSavedArmorStands() { + return savedArmorStands; + } + + public void removeSavedArmorStand(String name) { + savedArmorStands.remove(name.toLowerCase()); + } } diff --git a/src/com/Zrips/CMI/Modules/AStand/ArmorStandSave.java b/src/com/Zrips/CMI/Modules/AStand/ArmorStandSave.java new file mode 100644 index 0000000..b4d9766 --- /dev/null +++ b/src/com/Zrips/CMI/Modules/AStand/ArmorStandSave.java @@ -0,0 +1,107 @@ +package com.Zrips.CMI.Modules.AStand; + +import java.util.HashSet; +import java.util.Random; +import java.util.Set; + +import org.bukkit.Material; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.EulerAngle; + +import com.Zrips.CMI.Modules.AStand.ArmorStandManager.armorStandSaveOptions; + +public class ArmorStandSave { + + private Player player; + private ArmorStand stand; + private Set save = new HashSet(); + private String name = "ArmorStand_" + new Random().nextInt(); + private String serialized = ""; + + ArmorStandSave(Player player, ArmorStand stand, Set save) { + this.player = player; + this.stand = stand; + this.save = save; + } + + ArmorStandSave(String name, String serialized) { + this.name = name; + this.serialized = serialized; + } + + public Player getPlayer() { + return player; + } + + public void setPlayer(Player player) { + this.player = player; + } + + public ArmorStand getStand() { + return stand; + } + + public void setStand(ArmorStand stand) { + this.stand = stand; + } + + public Set getSaveOptions() { + return save; + } + + static String prefix = "{"; + static String suffix = "}"; + + private boolean valid(ItemStack item) { + if (item == null) + return false; + + if (item.getType() == Material.AIR) { + return false; + } + return true; + } + + public String serialize() { + + return ""; + } + + private static String getAngle(ArmorStand armor, armorStandSaveOptions apose) { + + return ""; + } + + private static EulerAngle getAngle(armorStandSaveOptions option, String value) { + + return null; + } + + public boolean apply(ArmorStand stand) { + + return true; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSerialized() { + return serialized; + } + + public void setSerialized(String serialized) { + this.serialized = serialized; + } + + public ItemStack createItem() { + + return null; + } +} diff --git a/src/com/Zrips/CMI/Modules/Advancements/AdvancementManager.java b/src/com/Zrips/CMI/Modules/Advancements/AdvancementManager.java index 6c551ab..acba648 100644 --- a/src/com/Zrips/CMI/Modules/Advancements/AdvancementManager.java +++ b/src/com/Zrips/CMI/Modules/Advancements/AdvancementManager.java @@ -11,67 +11,68 @@ public class AdvancementManager { static HashMap map = new HashMap(); public static CMIAdvancement getOld(String... key) { - String oneKey = ""; - for (String one : key) { - oneKey += one; - } - return map.get(oneKey); + String oneKey = ""; + for (String one : key) { + oneKey += one; + } + return map.get(oneKey); } public static void add(CMIAdvancement adv) { - map.put(adv.getId().getKey(), adv); + map.put(adv.getId().getKey(), adv); } public enum FrameType { - TASK("task"), - GOAL("goal"), - CHALLENGE("challenge"); - - private String name; - - FrameType(String name) { - this.name = name; - } - - public static FrameType getFromString(String frameType) { - try { - for (FrameType one : FrameType.values()) { - if (one.name.equalsIgnoreCase(frameType)) - return one; - } - } catch (EnumConstantNotPresentException e) { - } - return FrameType.TASK; - } - - @Override - public String toString() { - return name; - } + TASK("task"), + GOAL("goal"), + CHALLENGE("challenge"); + + private String name; + + FrameType(String name) { + this.name = name; + } + + public static FrameType getFromString(String frameType) { + try { + for (FrameType one : FrameType.values()) { + if (one.name.equalsIgnoreCase(frameType)) + return one; + } + } catch (EnumConstantNotPresentException e) { + } + return FrameType.TASK; + } + + @Override + public String toString() { + return name; + } } public class Condition { - protected String name; - protected JsonObject set; + protected String name; + protected JsonObject set; - public Condition(String name, JsonObject set) { - this.name = name; - this.set = set; - } + public Condition(String name, JsonObject set) { + this.name = name; + this.set = set; + } } public class ConditionBuilder { - private String name; - private JsonObject set; + private String name; + private JsonObject set; - ConditionBuilder() { - } + ConditionBuilder() { + } - public Condition build() { - return new Condition(name, set); - } + public Condition build() { + return new Condition(name, set); + } } public static void sendToast(Player player, String msg) { + } } diff --git a/src/com/Zrips/CMI/Modules/Advancements/CMIAdvancement.java b/src/com/Zrips/CMI/Modules/Advancements/CMIAdvancement.java index e2e704b..add034a 100644 --- a/src/com/Zrips/CMI/Modules/Advancements/CMIAdvancement.java +++ b/src/com/Zrips/CMI/Modules/Advancements/CMIAdvancement.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import com.Zrips.CMI.CMI; import com.Zrips.CMI.Modules.Advancements.AdvancementManager.FrameType; import com.google.gson.Gson; import com.google.gson.JsonElement; @@ -21,179 +22,191 @@ public class CMIAdvancement { private String title; private String description; private int data; + private int customModelData = 0; private FrameType frame; private boolean announce = true; private boolean toast = true; private boolean hidden = true; - private CMIAdvancement(NamespacedKey id, String parent, String icon, int data, String background, String title, String description, FrameType frame, boolean announce, boolean toast, boolean hidden) { - this.id = id; - this.parent = parent; - this.icon = icon; - this.data = data; - this.background = background; - this.title = title; - this.description = description; - this.frame = frame; - this.announce = announce; - this.toast = toast; - this.hidden = hidden; + private CMIAdvancement(NamespacedKey id, String parent, String icon, int data, String background, String title, String description, FrameType frame, boolean announce, boolean toast, boolean hidden, + int customModelData) { + this.id = id; + this.parent = parent; + this.icon = icon; + this.data = data; + this.background = background; + this.title = title; + this.description = description; + this.frame = frame; + this.announce = announce; + this.toast = toast; + this.hidden = hidden; + this.customModelData = customModelData; } public static AdvancementBuilder builder(NamespacedKey id) { - return new AdvancementBuilder().id(id); + return new AdvancementBuilder().id(id); } public String getJSON() { - return gson.toJson(""); + return ""; } public String getIcon() { - return this.icon; + return this.icon; } public int getData() { - return this.data; + return this.data; } - public static JsonElement getJsonFromComponent(String textComponent) { + public int getCustomModelData() { + return this.customModelData; + } - return gson.fromJson("\"" + textComponent + "\"", JsonElement.class); + public static JsonElement getJsonFromComponent(String textComponent) { + return null; } public String getTitle() { - return this.title; + return this.title; } public String getDescription() { - return this.description; + return this.description; } public String getBackground() { - return this.background; + return this.background; } public FrameType getFrame() { - return this.frame; + return this.frame; } public String getParent() { - return this.parent; + return this.parent; } public CMIAdvancement show(JavaPlugin plugin, final Player... players) { - - return this; + return this; } public CMIAdvancement add() { - - return this; + try { + CMI.getInstance().getNMS().loadAdvancement(id, getJSON()); + } catch (IllegalArgumentException e) { + } + return this; } public CMIAdvancement grant(Player... players) { - - return this; + return this; } public CMIAdvancement revoke(Player... players) { - - return this; + return this; } public Advancement getAdvancement() { - return Bukkit.getAdvancement(id); + return Bukkit.getAdvancement(id); } public NamespacedKey getId() { - return this.id; + return this.id; } public boolean isAnnounce() { - return this.announce; + return this.announce; } public boolean isToast() { - return this.toast; + return this.toast; } public boolean isHidden() { - return this.hidden; + return this.hidden; } public static class AdvancementBuilder { - private NamespacedKey id; - private String parent; - private String icon; - private String background; - private String title; - private String description; - private FrameType frame; - private boolean announce; - private boolean toast; - private boolean hidden; - private int data; - - AdvancementBuilder() { - } - - public AdvancementBuilder title(String title) { - this.title = title; - return this; - } - - public AdvancementBuilder description(String description) { - this.description = description; - return this; - } - - public AdvancementBuilder id(NamespacedKey id) { - this.id = id; - return this; - } - - public AdvancementBuilder parent(String parent) { - this.parent = parent; - return this; - } - - public AdvancementBuilder icon(String icon) { - this.icon = icon; - return this; - } - - public AdvancementBuilder data(int data) { - this.data = data; - return this; - } - - public AdvancementBuilder background(String background) { - this.background = background; - return this; - } - - public AdvancementBuilder frame(FrameType frame) { - this.frame = frame; - return this; - } - - public AdvancementBuilder announce(boolean announce) { - this.announce = announce; - return this; - } - - public AdvancementBuilder toast(boolean toast) { - this.toast = toast; - return this; - } - - public AdvancementBuilder hidden(boolean hidden) { - this.hidden = hidden; - return this; - } - - public CMIAdvancement build() { - return new CMIAdvancement(id, parent, icon, data, background, title, description, frame, announce, toast, hidden); - } + private NamespacedKey id; + private String parent; + private String icon; + private String background; + private String title; + private String description; + private FrameType frame; + private boolean announce; + private int modelData = 0; + private boolean toast; + private boolean hidden; + private int data; + + AdvancementBuilder() { + } + + public AdvancementBuilder title(String title) { + this.title = title; + return this; + } + + public AdvancementBuilder description(String description) { + this.description = description; + return this; + } + + public AdvancementBuilder id(NamespacedKey id) { + this.id = id; + return this; + } + + public AdvancementBuilder parent(String parent) { + this.parent = parent; + return this; + } + + public AdvancementBuilder icon(String icon) { + this.icon = icon; + return this; + } + + public AdvancementBuilder data(int data) { + this.data = data; + return this; + } + + public AdvancementBuilder background(String background) { + this.background = background; + return this; + } + + public AdvancementBuilder frame(FrameType frame) { + this.frame = frame; + return this; + } + + public AdvancementBuilder announce(boolean announce) { + this.announce = announce; + return this; + } + + public AdvancementBuilder toast(boolean toast) { + this.toast = toast; + return this; + } + + public AdvancementBuilder customModelData(int modelData) { + this.modelData = modelData; + return this; + } + + public AdvancementBuilder hidden(boolean hidden) { + this.hidden = hidden; + return this; + } + + public CMIAdvancement build() { + return new CMIAdvancement(id, parent, icon, data, background, title, description, frame, announce, toast, hidden, modelData); + } } } diff --git a/src/com/Zrips/CMI/Modules/Afk/AfkInfo.java b/src/com/Zrips/CMI/Modules/Afk/AfkInfo.java index 3005824..8b160b1 100644 --- a/src/com/Zrips/CMI/Modules/Afk/AfkInfo.java +++ b/src/com/Zrips/CMI/Modules/Afk/AfkInfo.java @@ -2,6 +2,8 @@ import com.Zrips.CMI.events.CMIAfkEnterEvent.AfkType; +import net.Zrips.CMILib.Container.CMIVectorInt3D; + public class AfkInfo { private Long afkFrom = null; @@ -9,62 +11,72 @@ public class AfkInfo { private AfkType type; private String reason; private Long playtimeAtAfkStart; - + + private CMIVectorInt3D afkAt = null; + private int kickOutIn = 0; public AfkInfo() { } public Long getAfkFrom() { - return afkFrom; + return afkFrom; } public void setAfkFrom(Long afkFrom) { - this.afkFrom = afkFrom; + this.afkFrom = afkFrom; } public int getKicksPerformed() { - return kicksPerformed; + return kicksPerformed; } public void setKicksPerformed(int kicksPerformed) { - this.kicksPerformed = kicksPerformed; + this.kicksPerformed = kicksPerformed; } public void addKicksPerformed() { - this.kicksPerformed++; + this.kicksPerformed++; } public AfkType getType() { - return type == null ? AfkType.auto : type; + return type == null ? AfkType.auto : type; } public void setType(AfkType type) { - this.type = type; + this.type = type; } public String getReason() { - return reason; + return reason; } public void setReason(String reason) { - this.reason = reason; + this.reason = reason; } public Long getPlaytimeAtAfkStart() { - return playtimeAtAfkStart == null ? 0L : playtimeAtAfkStart; + return playtimeAtAfkStart == null ? 0L : playtimeAtAfkStart; } public void setPlaytimeAtAfkStart(Long playtimeAtAfkStart) { - this.playtimeAtAfkStart = playtimeAtAfkStart; + this.playtimeAtAfkStart = playtimeAtAfkStart; } public int getKickOutInSec() { - return kickOutIn; + return kickOutIn; } public void setKickOutInSec(int kickOutIn) { - this.kickOutIn = kickOutIn; + this.kickOutIn = kickOutIn; + } + + public CMIVectorInt3D getAfkAt() { + return afkAt; + } + + public void setAfkAt(CMIVectorInt3D afkAt) { + this.afkAt = afkAt; } } diff --git a/src/com/Zrips/CMI/Modules/Afk/AfkListener.java b/src/com/Zrips/CMI/Modules/Afk/AfkListener.java index 156bd76..9631003 100644 --- a/src/com/Zrips/CMI/Modules/Afk/AfkListener.java +++ b/src/com/Zrips/CMI/Modules/Afk/AfkListener.java @@ -6,69 +6,190 @@ import java.util.UUID; import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIUser; +import com.Zrips.CMI.events.CMIAfkEnterEvent; +import com.Zrips.CMI.events.CMIAfkEnterEvent.AfkType; +import com.Zrips.CMI.events.CMIAfkKickEvent; +import com.Zrips.CMI.events.CMIAfkLeaveEvent; public class AfkListener implements Listener { private CMI plugin; public AfkListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerCommand(PlayerCommandPreprocessEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void CreatureSpawnEvent(org.bukkit.event.entity.CreatureSpawnEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerAliasCommand(PlayerCommandPreprocessEvent event) { + } private class previousLoc { - List locs = new ArrayList(); - private int jumpCount = 0; + List locs = new ArrayList(); + private int jumpCount = 0; - public Location addLoc(Location loc) { - locs.add(loc); - if (locs.size() > 2) - return locs.remove(0); - return null; - } + public Location addLoc(Location loc) { + locs.add(loc); + if (locs.size() > 2) + return locs.remove(0); + return null; + } - public int getJumpCount() { - return jumpCount; - } + public int getJumpCount() { + return jumpCount; + } - public void setJumpCount(int jumpCount) { - this.jumpCount = jumpCount; - } + public void setJumpCount(int jumpCount) { + this.jumpCount = jumpCount; + } - public void addJumpCount() { - this.jumpCount++; - } + public void addJumpCount() { + this.jumpCount++; + } } HashMap antiJump = new HashMap(); static HashMap pitchChange = new HashMap(); + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerTeleportEvent(PlayerTeleportEvent event) { + + } + HashMap antiPush = new HashMap(); + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMove(PlayerMoveEvent event) { + + } + public static boolean isSameDirection(CMIUser user) { - if (!CMI.getInstance().getAfkManager().isAntiAfkMachines()) - return false; - checkInfo directionChange = pitchChange.get(user.getUniqueId()); - if (!user.isOnline() || user.getPlayer() == null) - return false; - Location loc = user.getLocation(); - if (directionChange == null) { - directionChange = new checkInfo(loc); - pitchChange.put(user.getUniqueId(), directionChange); - } - if (directionChange.timeToCheck()) { - directionChange.updateTime(); - if (directionChange.isSameDirection(loc)) { - directionChange.updateLocation(loc); - return true; - } - directionChange.updateLocation(loc); - return false; - } - return true; + + return true; + } + + @SuppressWarnings("deprecation") + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void PlayerPickupItemEvent(PlayerPickupItemEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onFishingRodUse(PlayerFishEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerItemHeldEvent(PlayerItemHeldEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerInteractEvent(PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void InventoryClickEvent(InventoryClickEvent event) { + if (!plugin.getAfkManager().isDisableOnInventoryClick()) + return; + CMIUser user = plugin.getPlayerManager().getUser((Player) event.getWhoClicked()); + if (user == null) + return; + user.setAfk(false, AfkType.auto); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void PlayerToggleSneakEvent(PlayerToggleSneakEvent event) { + } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void EntityDamageEvent(EntityDamageEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH) + public void onAsyncPlayerChatEvent(final AsyncPlayerChatEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void CMIAfkEnterEvent(CMIAfkEnterEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void CMIAfkKickEvent(CMIAfkKickEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void CMIAfkLeaveEvent(CMIAfkLeaveEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerLoginEvent(PlayerLoginEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerQuitEvent(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void EntityTargetLivingEntityEvent(EntityTargetLivingEntityEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onItemDrop(PlayerDropItemEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onBlockBreakEvent(BlockBreakEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerRespawnEvent(PlayerRespawnEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Afk/AfkListener1_8.java b/src/com/Zrips/CMI/Modules/Afk/AfkListener1_8.java index 4f7953d..37bd17a 100644 --- a/src/com/Zrips/CMI/Modules/Afk/AfkListener1_8.java +++ b/src/com/Zrips/CMI/Modules/Afk/AfkListener1_8.java @@ -1,6 +1,9 @@ package com.Zrips.CMI.Modules.Afk; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; import com.Zrips.CMI.CMI; @@ -8,7 +11,11 @@ public class AfkListener1_8 implements Listener { private CMI plugin; public AfkListener1_8(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerInteractEntityEvent(PlayerInteractAtEntityEvent event) { } } diff --git a/src/com/Zrips/CMI/Modules/Afk/AfkManager.java b/src/com/Zrips/CMI/Modules/Afk/AfkManager.java index 83361c7..b72b159 100644 --- a/src/com/Zrips/CMI/Modules/Afk/AfkManager.java +++ b/src/com/Zrips/CMI/Modules/Afk/AfkManager.java @@ -6,7 +6,6 @@ import java.util.List; import java.util.Set; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; @@ -22,7 +21,7 @@ public class AfkManager { private CMI plugin; public AfkManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } private int sched = -1; @@ -53,6 +52,7 @@ public AfkManager(CMI plugin) { private boolean RepeatKickCommand = false; private boolean disableOnCommand = true; private boolean disableOnMove = true; + private boolean disableOnLookAround = true; private boolean disableItemPickup = false; private boolean disableFishing = true; private boolean PreventMobSpawning = false; @@ -65,14 +65,6 @@ public AfkManager(CMI plugin) { private boolean disableExpPickup = false; public void stop() { - if (sched != -1) { - Bukkit.getScheduler().cancelTask(sched); - sched = -1; - } - if (afkSched != -1) { - Bukkit.getScheduler().cancelTask(afkSched); - afkSched = -1; - } } public void loadConfig() { @@ -80,15 +72,23 @@ public void loadConfig() { } private void loadAfk() { - afkSubTitle = plugin.getIML("afk", "afkSubTitle"); - messageSize = afkSubTitle.size(); } int messageSize = -1; List afkSubTitle = new ArrayList(); - public void setUserToAfk(CMIUser user, List cmds) { + private void tasker() { + + } + + public void showTitle(CMIUser user, boolean fade) { + + } + + public void hideTitle(CMIUser user) { + } + public void setUserToAfk(CMIUser user, List cmds) { } public void removeUserFromAfk(CMIUser user, List cmds) { @@ -104,92 +104,91 @@ public void updateUser(CMIUser user) { } public void setLastAction(CMIUser user, long time) { - } public Long getLastAction(CMIUser user) { - Long action = this.lastAction.get(user); - return action; + Long action = this.lastAction.get(user); + return action; } public boolean isAfkEnabled() { - return AfkEnabled; + return AfkEnabled; } public boolean isDisableOnMove() { - return disableOnMove; + return disableOnMove; } public boolean isDisableOnFishing() { - return disableFishing; + return disableFishing; } public boolean isDisableOnInteract() { - return disableOnInteract; + return disableOnInteract; } public boolean isDisableOnInventoryClick() { - return DisableOnInventoryClick; + return DisableOnInventoryClick; } public boolean isDisableOnCommand() { - return disableOnCommand; + return disableOnCommand; } public boolean isDisableItemPickup() { - return disableItemPickup; + return disableItemPickup; } public boolean isDisableOnPublicChat() { - return disableOnPublicChat; + return disableOnPublicChat; } public boolean isDisableOnPrivateChat() { - return disableOnPrivateChat; + return disableOnPrivateChat; } public List getAwayTrigerCommands() { - return awayTrigerCommands; + return awayTrigerCommands; } public void setAwayTrigerCommands(List awayTrigerCommands) { - this.awayTrigerCommands = awayTrigerCommands; + this.awayTrigerCommands = awayTrigerCommands; } public boolean isPreventDamage() { - return PreventDamage; + return PreventDamage; } public boolean isPreventJumping() { - return PreventJumping; + return PreventJumping; } public List getLeaveTrigerCommands() { - return leaveTrigerCommands; + return leaveTrigerCommands; } public void setLeaveTrigerCommands(List leaveTrigerCommands) { - this.leaveTrigerCommands = leaveTrigerCommands; + this.leaveTrigerCommands = leaveTrigerCommands; } public boolean isSmartInteractCheck() { - return SmartInteractCheck; + return SmartInteractCheck; } public boolean isAntiAfkMachines() { - return AntiAfkMachines; + return AntiAfkMachines; } public int getCheckInterval() { - return interval; + return interval; } public boolean isStopPlayTime() { - return StopPlayTime; + return StopPlayTime; } public void setStopPlayTime(boolean stopPlayTime) { - StopPlayTime = stopPlayTime; + StopPlayTime = stopPlayTime; } private int afkSched = -1; @@ -197,16 +196,10 @@ public void setStopPlayTime(boolean stopPlayTime) { List afkList = new ArrayList(); public void removeFromAfkTimePreventer(CMIUser user) { - afkList.remove(user); + afkList.remove(user); } public void AddToAfkTimePreventer(CMIUser user) { -// if (user.isOnline() && this.isDisabledWorld(user.getLocation().getWorld())) { -// return; -// } - - afkList.add(user); - AfkTimePreventer(); } @SuppressWarnings("deprecation") @@ -215,68 +208,71 @@ private void AfkTimePreventer() { } public List getManualAwayTrigerCommands() { - return manualAwayTrigerCommands; + return manualAwayTrigerCommands; } public void setManualAwayTrigerCommands(List manualAwayTrigerCommands) { - this.manualAwayTrigerCommands = manualAwayTrigerCommands; + this.manualAwayTrigerCommands = manualAwayTrigerCommands; } public long getAwayTrigerTime() { - return awayTrigerTime; + return awayTrigerTime; } public boolean nearActivePlayer(Location loc, SpawnReason reason) { - return false; + return false; } public static Boolean isNear(Location loc1, Location loc2) { - - return true; + return true; } public boolean isDisableExpPickup() { - return disableExpPickup; + return disableExpPickup; } public boolean isDisableOnItemDrop() { - return DisableOnitemDrop; + return DisableOnitemDrop; } public boolean isDisabledWorld(World world) { - if (world == null) - return false; - return isDisabledWorld(world.getName()); + if (world == null) + return false; + return isDisabledWorld(world.getName()); } public boolean isDisabledWorld(String name) { - if (name == null) - return false; - return this.disabledWorlds.contains(name.toLowerCase()); + if (name == null) + return false; + return this.disabledWorlds.contains(name.toLowerCase()); } public boolean isPreventMobSpawning() { - return PreventMobSpawning; + return PreventMobSpawning; } public boolean isPreventMobSpawningNatural() { - return PreventMobSpawningNatural; + return PreventMobSpawningNatural; } public boolean isPreventMobSpawningSpawners() { - return PreventMobSpawningSpawners; + return PreventMobSpawningSpawners; } public boolean isPreventMobVillageDefence() { - return PreventMobVillageDefence; + return PreventMobVillageDefence; } public boolean isPreventPushing() { - return PreventPushing; + return PreventPushing; } public Set getAfkPlayers() { - return afkPlayers; + return afkPlayers; + } + + public boolean isDisableOnLookAround() { + return disableOnLookAround; } } diff --git a/src/com/Zrips/CMI/Modules/Afk/checkInfo.java b/src/com/Zrips/CMI/Modules/Afk/checkInfo.java index 2f628f6..842b09a 100644 --- a/src/com/Zrips/CMI/Modules/Afk/checkInfo.java +++ b/src/com/Zrips/CMI/Modules/Afk/checkInfo.java @@ -28,7 +28,7 @@ public boolean isOnlyPitchChange(Location loc) { } public boolean timeToCheck() { - return time + 1000 < System.currentTimeMillis(); + return time + 400L < System.currentTimeMillis(); } public Long getTime() { diff --git a/src/com/Zrips/CMI/Modules/Alias/AliasManager.java b/src/com/Zrips/CMI/Modules/Alias/AliasManager.java index 60de224..5ba288a 100644 --- a/src/com/Zrips/CMI/Modules/Alias/AliasManager.java +++ b/src/com/Zrips/CMI/Modules/Alias/AliasManager.java @@ -20,62 +20,54 @@ public class AliasManager { public LinkedHashMap defaultAliases = new LinkedHashMap(); public LinkedHashMap customAliases = new LinkedHashMap(); -// public LinkedHashMap fullList = new LinkedHashMap(); + public LinkedHashMap alternativeAliases = new LinkedHashMap(); public HashMap fromAliases = new HashMap(); -// private HashMap chatMap = new HashMap(); - public AliasManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } -// public boolean isChatEditing(Player player) { -// return chatMap.containsKey(player.getUniqueId()); -// } -// -// public void addChatEditor(Player player, String cmd) { -// chatMap.put(player.getUniqueId(), cmd); -// } - private static CommandAlias getFirst(String msg, CommandAlias compare, String key) { - return null; + + return null; } private static CommandAlias getSecond(String msg, CommandAlias secondAlias, CommandAlias firstAlias, CommandAlias compare, String key) { - return null; + return null; } Map cache = Collections.synchronizedMap(new HashMap()); public void clearCache() { - cache.clear(); + cache.clear(); } public CommandAlias getAliasForCommand(String msg) { - return null; + return null; } public List getAliasStartingWith(String msg) { - return getAliasStartingWith(msg, null); + return getAliasStartingWith(msg, null); } public List getAliasStartingWith(String msg, CommandAliasType type) { + return null; + } - return null; + private void register(CommandAlias ca) { } public void addDefault(CommandAlias ca) { - } public void addCustom(CommandAlias ca) { - + } public void removeCustom(String command) { - + } public void removeCustom(CommandAlias ca) { @@ -83,71 +75,78 @@ public void removeCustom(CommandAlias ca) { } public LinkedHashMap getCustom() { - return customAliases; + return customAliases; } public LinkedHashMap getDefaultAlias() { - return defaultAliases; + return defaultAliases; } public HashMap getAll() { - HashMap t = new HashMap(); - - return t; + HashMap t = new HashMap(); + t.putAll(this.defaultAliases); + t.putAll(this.customAliases); + return t; } public HashMap getFrom() { - return fromAliases; + return fromAliases; } private List convertCustom() { - List list = new ArrayList(); - for (Entry one : customAliases.entrySet()) { - list.add(one.getValue().getCommand() + "-" + one.getKey()); - } - return list; + List list = new ArrayList(); + for (Entry one : customAliases.entrySet()) { + list.add(one.getValue().getCommand() + "-" + one.getKey()); + } + return list; } public void save() { - plugin.getConfigManager().ChangeConfig("CustomAlias.List", convertCustom()); + plugin.getConfigManager().ChangeConfig("CustomAlias.List", convertCustom()); } public static Pattern patern = Pattern.compile("( |^|:|:\\/|\\S)(\\$(\\d{1,2})(-?))"); public List updateCommands(CommandAlias alias, List args, List commands) { - return commands; + ArrayList t = new ArrayList(); + + return t; } List CommentList = new ArrayList(Arrays.asList("", - "Edit custom variables in game if possible", - "Some extra variables can be used, like [playerName] will insert senders name automatically", - "All global variables should work, you can find full list in locale file", - "You can add delay between commands by inserting line like", - "delay! 5", - "This will delay next commands by defines time in seconds", - "If command is shortened and you need to provide some changing variables like target player name you need to define what and where it should be placed", - "Example: /cmi heal Zrips ", - "Can be shortened with custom alias to something like /h zrips by using alias command like", - "cmi heal $1", - "If you need to add more than one variable, use $1- format. Number represents variable place when used in alias command", - "Example: cmi tppos $1-", - "In case you want to print out help page if player enters wrong subcommand, use ? in alias", - "Example: ca ?", - "In this case if player performs /ca wrongsub or /ca anotherwrong", - "Commands under this alias will get executed. Exelent way to show help page and correct usage if needed")); + "Edit custom variables in game if possible", + "Some extra variables can be used, like [playerName] will insert senders name automatically", + "All global variables should work, you can find full list in locale file", + "You can add delay between commands by inserting line like", + "delay! 5", + "This will delay next commands by defines time in seconds", + "If command is shortened and you need to provide some changing variables like target player name you need to define what and where it should be placed", + "Example: /cmi heal Zrips ", + "Can be shortened with custom alias to something like /h zrips by using alias command like", + "cmi heal $1", + "If you need to add more than one variable, use $1- format. Number represents variable place when used in alias command", + "Example: cmi tppos $1-", + "In case you want to print out help page if player enters wrong subcommand, use ? in alias", + "Example: ca ?", + "In this case if player performs /ca wrongsub or /ca anotherwrong", + "Commands under this alias will get executed. Exelent way to show help page and correct usage if needed")); List temp = new ArrayList(); public void load() { - + } public void loadRegularAlias() { - + } public void saveNew() { - + + } + + public void saveNew(String fileName) { + } } diff --git a/src/com/Zrips/CMI/Modules/Alias/AliasTabCompListener_1_13_older.java b/src/com/Zrips/CMI/Modules/Alias/AliasTabCompListener_1_13_older.java index 9f75a81..e625edc 100644 --- a/src/com/Zrips/CMI/Modules/Alias/AliasTabCompListener_1_13_older.java +++ b/src/com/Zrips/CMI/Modules/Alias/AliasTabCompListener_1_13_older.java @@ -5,12 +5,9 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerChatTabCompleteEvent; -import net.Zrips.CMILib.Logs.CMIDebug; - public class AliasTabCompListener_1_13_older implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void PlayerChatTabCompleteEvent(PlayerChatTabCompleteEvent event) { -// TODO something } } diff --git a/src/com/Zrips/CMI/Modules/Alias/AliasTabCompListener_1_14_never.java b/src/com/Zrips/CMI/Modules/Alias/AliasTabCompListener_1_14_never.java index 7483c02..9be86ac 100644 --- a/src/com/Zrips/CMI/Modules/Alias/AliasTabCompListener_1_14_never.java +++ b/src/com/Zrips/CMI/Modules/Alias/AliasTabCompListener_1_14_never.java @@ -15,6 +15,6 @@ public void onPlayerCommandSendEvent(PlayerCommandSendEvent event) { @EventHandler(priority = EventPriority.HIGHEST) public void PlayerChatTabCompleteEvent(TabCompleteEvent event) { - + } } diff --git a/src/com/Zrips/CMI/Modules/Alias/onPreprocessCommand.java b/src/com/Zrips/CMI/Modules/Alias/onPreprocessCommand.java index 9eb44f0..9c0df61 100644 --- a/src/com/Zrips/CMI/Modules/Alias/onPreprocessCommand.java +++ b/src/com/Zrips/CMI/Modules/Alias/onPreprocessCommand.java @@ -1,7 +1,24 @@ package com.Zrips.CMI.Modules.Alias; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerQuitEvent; public class onPreprocessCommand implements Listener { + @EventHandler(priority = EventPriority.LOW) + public void onCommand(PlayerCommandPreprocessEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onCommandSpy(PlayerCommandPreprocessEvent event) { + } + + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerQuitEvent(PlayerQuitEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Alias/onServerPreprocessCommand.java b/src/com/Zrips/CMI/Modules/Alias/onServerPreprocessCommand.java index 85f47db..e3bf12a 100644 --- a/src/com/Zrips/CMI/Modules/Alias/onServerPreprocessCommand.java +++ b/src/com/Zrips/CMI/Modules/Alias/onServerPreprocessCommand.java @@ -1,7 +1,20 @@ package com.Zrips.CMI.Modules.Alias; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.server.RemoteServerCommandEvent; +import org.bukkit.event.server.ServerCommandEvent; public class onServerPreprocessCommand implements Listener { + @EventHandler(priority = EventPriority.NORMAL) + public void onConsoleCommand(ServerCommandEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void RemoteServerCommandEvent(RemoteServerCommandEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Animations/AnimationColoredArmorListener.java b/src/com/Zrips/CMI/Modules/Animations/AnimationColoredArmorListener.java index dddd92f..c1e8dfe 100644 --- a/src/com/Zrips/CMI/Modules/Animations/AnimationColoredArmorListener.java +++ b/src/com/Zrips/CMI/Modules/Animations/AnimationColoredArmorListener.java @@ -1,7 +1,5 @@ package com.Zrips.CMI.Modules.Animations; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -18,4 +16,11 @@ public AnimationColoredArmorListener(CMI plugin) { this.plugin = plugin; } + @EventHandler(priority = EventPriority.MONITOR) + public void leatherArmor(final CMIArmorChangeEvent event) { + } + + @EventHandler(priority = EventPriority.MONITOR) + public void leatherArmor(final PlayerJoinEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/Animations/AnimationListener.java b/src/com/Zrips/CMI/Modules/Animations/AnimationListener.java index 218527e..e2c830d 100644 --- a/src/com/Zrips/CMI/Modules/Animations/AnimationListener.java +++ b/src/com/Zrips/CMI/Modules/Animations/AnimationListener.java @@ -1,6 +1,9 @@ package com.Zrips.CMI.Modules.Animations; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; import com.Zrips.CMI.CMI; @@ -11,5 +14,17 @@ public class AnimationListener implements Listener { public AnimationListener(CMI plugin) { this.plugin = plugin; } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onPlayerQuit(PlayerQuitEvent event) { + } + + @EventHandler(priority = EventPriority.NORMAL) + public void VehicleExitEvent(org.spigotmc.event.entity.EntityDismountEvent event) { + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerMoveEvent(org.bukkit.event.vehicle.VehicleMoveEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/Animations/AnimationManager.java b/src/com/Zrips/CMI/Modules/Animations/AnimationManager.java index 47d60f2..39ff04f 100644 --- a/src/com/Zrips/CMI/Modules/Animations/AnimationManager.java +++ b/src/com/Zrips/CMI/Modules/Animations/AnimationManager.java @@ -20,6 +20,7 @@ import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIPlayerInventory.CMIInventorySlot; +import com.Zrips.CMI.Containers.CMIUser; public class AnimationManager { @@ -42,7 +43,7 @@ public class AnimationManager { private HashMap riding = new HashMap(); public AnimationManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void clearCache(UUID uuid) { @@ -60,37 +61,37 @@ public void clearCache(UUID uuid) { List armorTypes = new ArrayList(Arrays.asList(CMIInventorySlot.Helmet, CMIInventorySlot.ChestPlate, CMIInventorySlot.Pants, CMIInventorySlot.Boots)); public enum LeatherAnimationType { - Rainbow(1), Health(2), Biome(3), Day(4); + Rainbow(1), Health(2), Biome(3), Day(4); - private Integer id; + private Integer id; - LeatherAnimationType(Integer id) { - this.id = id; - } + LeatherAnimationType(Integer id) { + this.id = id; + } - public Integer getId() { - return id; - } + public Integer getId() { + return id; + } - public void setId(Integer id) { - this.id = id; - } + public void setId(Integer id) { + this.id = id; + } - public static LeatherAnimationType getById(int id) { - for (LeatherAnimationType one : values()) { - if (one.getId() == id) - return one; - } - return null; - } + public static LeatherAnimationType getById(int id) { + for (LeatherAnimationType one : values()) { + if (one.getId() == id) + return one; + } + return null; + } - public static LeatherAnimationType getByName(String name) { - for (LeatherAnimationType one : values()) { - if (one.name().equalsIgnoreCase(name)) - return one; - } - return null; - } + public static LeatherAnimationType getByName(String name) { + for (LeatherAnimationType one : values()) { + if (one.name().equalsIgnoreCase(name)) + return one; + } + return null; + } } @@ -101,23 +102,38 @@ public void addLeatherArmor(Player player) { private int autoTimerBukkitId = 0; public void stopLeatherUpdate() { - if (autoTimerBukkitId != 0) { - Bukkit.getScheduler().cancelTask(autoTimerBukkitId); - autoTimerBukkitId = 0; - } + } + + private Runnable autoTimer = new Runnable() { + @Override + public void run() { + try { + checkLeatherArmors(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }; + + private void checkLeatherArmors() { + + } + + private static void setColor(CMIUser user, LeatherAnimationType type, List slot, LeatherAnimation anim) { + } public static int getIntFromColor(int Red, int Green, int Blue) { - Red = (Red << 16) & 0x00FF0000; - Green = (Green << 8) & 0x0000FF00; - Blue = Blue & 0x000000FF; + Red = (Red << 16) & 0x00FF0000; + Green = (Green << 8) & 0x0000FF00; + Blue = Blue & 0x000000FF; - return 0xFF000000 | Red | Green | Blue; + return 0xFF000000 | Red | Green | Blue; } public boolean isDoubleClickWait(Player player) { - return false; + return false; } public void loadConfig() { @@ -125,90 +141,90 @@ public void loadConfig() { } public class Chair { - private Entity ent = null; - private Location ChairBlockLoc = null; - private Location armorStandLoc = null; - private long lastCheck = 0L; - private boolean persistent = false; + private Entity ent = null; + private Location ChairBlockLoc = null; + private Location armorStandLoc = null; + private long lastCheck = 0L; + private boolean persistent = false; - public Entity getEnt() { - return ent; - } + public Entity getEnt() { + return ent; + } - public Chair setEnt(Entity ent) { - this.ent = ent; - return this; - } + public Chair setEnt(Entity ent) { + this.ent = ent; + return this; + } - public Location getChairLoc() { - return ChairBlockLoc; - } + public Location getChairLoc() { + return ChairBlockLoc; + } - public Chair setChairLoc(Location chairLoc) { - this.ChairBlockLoc = chairLoc; - return this; - } + public Chair setChairLoc(Location chairLoc) { + this.ChairBlockLoc = chairLoc; + return this; + } - public Location getArmorStandLoc() { - return armorStandLoc; - } + public Location getArmorStandLoc() { + return armorStandLoc; + } - public Chair setArmorStandLoc(Location armorStandLoc) { - this.armorStandLoc = armorStandLoc; - return this; - } + public Chair setArmorStandLoc(Location armorStandLoc) { + this.armorStandLoc = armorStandLoc; + return this; + } - public long getLastCheck() { - return lastCheck; - } + public long getLastCheck() { + return lastCheck; + } - public void setLastCheck(long lastCheck) { - this.lastCheck = lastCheck; - } + public void setLastCheck(long lastCheck) { + this.lastCheck = lastCheck; + } - public boolean isPersistent() { - return persistent; - } + public boolean isPersistent() { + return persistent; + } - public void setPersistent(boolean persistent) { - this.persistent = persistent; - } + public void setPersistent(boolean persistent) { + this.persistent = persistent; + } } public boolean isValidChairBlock(Block block) { - return true; + return true; } public void sit(Player player) { - sit(player, false); + sit(player, false); } public void sit(Player player, boolean persistent) { - sit(player, player.getLocation(), persistent); + sit(player, player.getLocation(), persistent); } public void sit(Player player, Location location, boolean persistent) { - Chair chair = new Chair().setArmorStandLoc(location.clone().add(0.0D, -1.7D, 0.0D)).setChairLoc(location.clone().add(0, -1, 0)); - chair.setPersistent(persistent); - if (sit(player, chair)) { - chairLoc.put(plugin.getUtilManager().convertLocToStringShort(location.clone().add(0, -1, 0)), player.getUniqueId()); - } + Chair chair = new Chair().setArmorStandLoc(location.clone().add(0.0D, -1.7D, 0.0D)).setChairLoc(location.clone().add(0, -1, 0)); + chair.setPersistent(persistent); + if (sit(player, chair)) { + chairLoc.put(plugin.getUtilManager().convertLocToStringShort(location.clone().add(0, -1, 0)), player.getUniqueId()); + } } public boolean isSomeOneSittingHere(Block block) { - UUID who = chairLoc.get(plugin.getUtilManager().convertLocToStringShort(block.getLocation().clone())); - return who != null; + UUID who = chairLoc.get(plugin.getUtilManager().convertLocToStringShort(block.getLocation().clone())); + return who != null; } private static Vector getStairLedgeDirection(Block block) { - return new Vector(0, 0, 0); + return new Vector(0, 0, 0); } public void sit(Player player, Block block) { - sit(player, block, false); + sit(player, block, false); } public void sit(Player player, Block block, boolean persistent) { @@ -216,16 +232,16 @@ public void sit(Player player, Block block, boolean persistent) { } public boolean isSitting(Player player) { - if (map.isEmpty()) - return false; - return map.containsKey(player.getUniqueId()); + if (map.isEmpty()) + return false; + return map.containsKey(player.getUniqueId()); } public Entity getChair(Player player) { - if (map.isEmpty()) - return null; - Chair chair = map.get(player.getUniqueId()); - return chair == null ? null : chair.getEnt(); + if (map.isEmpty()) + return null; + Chair chair = map.get(player.getUniqueId()); + return chair == null ? null : chair.getEnt(); } public void sitOnPlayer(Player player, Player target) { @@ -234,38 +250,38 @@ public void sitOnPlayer(Player player, Player target) { private boolean sit(Player player, Chair chair) { - return true; + return true; } @Deprecated public void removePlayer(UUID uuid) { - Player player = Bukkit.getPlayer(uuid); - if (player != null) - removePlayer(player); + Player player = Bukkit.getPlayer(uuid); + if (player != null) + removePlayer(player); } @Deprecated public void removePlayer(final Player player) { - removePlayer(player, true); + removePlayer(player, true); } @Deprecated public void removePlayer(final Player player, boolean delay) { - removePlayerFromChair(player, delay, false); + removePlayerFromChair(player, delay, false); } public void removePlayerFromChair(UUID uuid) { - Player player = Bukkit.getPlayer(uuid); - if (player != null) - removePlayerFromChair(player); + Player player = Bukkit.getPlayer(uuid); + if (player != null) + removePlayerFromChair(player); } public void removePlayerFromChair(final Player player) { - removePlayerFromChair(player, true); + removePlayerFromChair(player, true); } public void removePlayerFromChair(final Player player, boolean delay) { - removePlayerFromChair(player, delay, false); + removePlayerFromChair(player, delay, false); } public void removePlayerFromChair(final Player player, boolean delay, boolean center) { @@ -281,72 +297,72 @@ private void updateSitTask() { } public boolean isSitOnStairs() { - return SitOnStairs; + return SitOnStairs; } public void setSitOnStairs(boolean sitOnStairs) { - SitOnStairs = sitOnStairs; + SitOnStairs = sitOnStairs; } public boolean isSlabsAsChairs() { - return SlabsAsChairs; + return SlabsAsChairs; } public boolean isStairsAsChairs() { - return StairsAsChairs; + return StairsAsChairs; } public UUID removeRiding(UUID uuid) { - return riding.remove(uuid); + return riding.remove(uuid); } public boolean isRiding(UUID uuid) { - return riding.containsKey(uuid); + return riding.containsKey(uuid); } public UUID isBeingRiden(UUID uuid) { - for (Entry one : riding.entrySet()) { - if (one.getValue().equals(uuid)) - return one.getKey(); - } - return null; + for (Entry one : riding.entrySet()) { + if (one.getValue().equals(uuid)) + return one.getKey(); + } + return null; } public void addRiding(UUID riding, UUID vehicle) { - this.riding.put(riding, vehicle); + this.riding.put(riding, vehicle); } public boolean isDoubleClick() { - return DoubleClick; + return DoubleClick; } public int getChairRange() { - return chairRange; + return chairRange; } public boolean isRemoveFromChairOnDamage() { - return RemoveFromChairOnDamage; + return RemoveFromChairOnDamage; } private class RotateStand extends BukkitRunnable { - private BukkitTask id = null; + private BukkitTask id = null; - public void stop() { - if (id != null) - id.cancel(); - } + public void stop() { + if (id != null) + id.cancel(); + } - public RotateStand() { - id = runTaskTimerAsynchronously(plugin, 0L, 1L); - } + public RotateStand() { + id = runTaskTimerAsynchronously(plugin, 0L, 1L); + } - private Method method = null; - private Field field = null; + private Method method = null; + private Field field = null; - @Override - public void run() { + @Override + public void run() { - } + } } } diff --git a/src/com/Zrips/CMI/Modules/Animations/AnimationRideListener.java b/src/com/Zrips/CMI/Modules/Animations/AnimationRideListener.java index 08b372c..82fec5e 100644 --- a/src/com/Zrips/CMI/Modules/Animations/AnimationRideListener.java +++ b/src/com/Zrips/CMI/Modules/Animations/AnimationRideListener.java @@ -1,12 +1,9 @@ package com.Zrips.CMI.Modules.Animations; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import com.Zrips.CMI.CMI; @@ -19,4 +16,11 @@ public AnimationRideListener(CMI plugin) { this.plugin = plugin; } + @EventHandler(priority = EventPriority.MONITOR) + public void EntityDamageEvent(EntityDamageEvent event) { + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void EntityDeathEvent(EntityDeathEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/Animations/AnimationSitListener.java b/src/com/Zrips/CMI/Modules/Animations/AnimationSitListener.java index 2798bb6..76d64a0 100644 --- a/src/com/Zrips/CMI/Modules/Animations/AnimationSitListener.java +++ b/src/com/Zrips/CMI/Modules/Animations/AnimationSitListener.java @@ -1,6 +1,16 @@ package com.Zrips.CMI.Modules.Animations; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityTeleportEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerTeleportEvent; import com.Zrips.CMI.CMI; @@ -12,4 +22,42 @@ public AnimationSitListener(CMI plugin) { this.plugin = plugin; } + @EventHandler(priority = EventPriority.LOWEST) + public void PlayerTeleportEvent(PlayerTeleportEvent event) { + plugin.getAnimationManager().removePlayerFromChair(event.getPlayer()); + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerTeleportEvent(PlayerDeathEvent event) { + plugin.getAnimationManager().removePlayerFromChair(event.getEntity()); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void PlayerTeleportEvent(PlayerQuitEvent event) { + plugin.getAnimationManager().removePlayerFromChair(event.getPlayer(), false); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void EntityTeleportEvent(EntityTeleportEvent event) { + } + + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerMoveEvent(PlayerMoveEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void BlockBreakEvent(BlockBreakEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void EntityDamageEvent(EntityDamageEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerTeleportEvent(PlayerInteractEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Anvil/AnvilColorRenameListener.java b/src/com/Zrips/CMI/Modules/Anvil/AnvilColorRenameListener.java index 47ae92c..11cf851 100644 --- a/src/com/Zrips/CMI/Modules/Anvil/AnvilColorRenameListener.java +++ b/src/com/Zrips/CMI/Modules/Anvil/AnvilColorRenameListener.java @@ -1,27 +1,13 @@ package com.Zrips.CMI.Modules.Anvil; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.List; - -import org.bukkit.Material; -import org.bukkit.entity.HumanEntity; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.inventory.PrepareAnvilEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; import com.Zrips.CMI.events.CMIAnvilItemRenameEvent; -import net.Zrips.CMILib.Colors.CMIChatColor; -import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.Logs.CMIDebug; -import net.Zrips.CMILib.Version.Version; - public class AnvilColorRenameListener implements Listener { private CMI plugin; @@ -29,4 +15,12 @@ public AnvilColorRenameListener(CMI plugin) { this.plugin = plugin; } + @EventHandler(priority = EventPriority.NORMAL) + public void CMIItemRenameEvent(CMIAnvilItemRenameEvent event) { + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PrepareAnvilEvent(final PrepareAnvilEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Anvil/AnvilManager.java b/src/com/Zrips/CMI/Modules/Anvil/AnvilManager.java index ca30de8..efdbd00 100644 --- a/src/com/Zrips/CMI/Modules/Anvil/AnvilManager.java +++ b/src/com/Zrips/CMI/Modules/Anvil/AnvilManager.java @@ -1,9 +1,6 @@ package com.Zrips.CMI.Modules.Anvil; -import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.Repairable; import com.Zrips.CMI.CMI; @@ -12,12 +9,11 @@ public class AnvilManager { CMI plugin; public AnvilManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public int getRepairCost(ItemStack source, ItemStack source2, ItemStack result) { - - return 0; + return 0; } } diff --git a/src/com/Zrips/CMI/Modules/Anvil/AnvilUnlimitedListener.java b/src/com/Zrips/CMI/Modules/Anvil/AnvilUnlimitedListener.java index 9073373..fb5ca72 100644 --- a/src/com/Zrips/CMI/Modules/Anvil/AnvilUnlimitedListener.java +++ b/src/com/Zrips/CMI/Modules/Anvil/AnvilUnlimitedListener.java @@ -14,7 +14,7 @@ public class AnvilUnlimitedListener implements Listener { HashMap instaBuild = new HashMap(); public AnvilUnlimitedListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } - + } diff --git a/src/com/Zrips/CMI/Modules/Anvil/CMIAnvilGUI.java b/src/com/Zrips/CMI/Modules/Anvil/CMIAnvilGUI.java index a07474d..5a65c8d 100644 --- a/src/com/Zrips/CMI/Modules/Anvil/CMIAnvilGUI.java +++ b/src/com/Zrips/CMI/Modules/Anvil/CMIAnvilGUI.java @@ -3,12 +3,21 @@ import java.lang.reflect.Field; import java.util.HashMap; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.PrepareAnvilEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import com.Zrips.CMI.CMI; + +import net.Zrips.CMILib.Version.Version; + public class CMIAnvilGUI { private boolean colorrename = false; @@ -33,114 +42,113 @@ public class CMIAnvilGUI { private void loadClasses() { - } public enum AnvilSlot { - INPUT_LEFT(0), INPUT_RIGHT(1), OUTPUT(2); + INPUT_LEFT(0), INPUT_RIGHT(1), OUTPUT(2); - private int slot; + private int slot; - private AnvilSlot(int Slot) { - slot = Slot; - } + private AnvilSlot(int Slot) { + slot = Slot; + } - public int getSlot() { - return slot; - } + public int getSlot() { + return slot; + } - public static AnvilSlot bySlot(int Slot) { + public static AnvilSlot bySlot(int Slot) { - for (AnvilSlot AS : values()) - if (AS.getSlot() == Slot) - return AS; + for (AnvilSlot AS : values()) + if (AS.getSlot() == Slot) + return AS; - return null; + return null; - } + } } public interface AnvilClickEventHandler { - public void onAnvilClick(AnvilClickEvent event); + public void onAnvilClick(AnvilClickEvent event); - public void onAnvilClose(InventoryCloseEvent event); + public void onAnvilClose(InventoryCloseEvent event); } public class AnvilClickEvent { - private AnvilSlot slot; - private ItemStack item; - private String text; + private AnvilSlot slot; + private ItemStack item; + private String text; - public AnvilClickEvent(AnvilSlot Slot, ItemStack Item, String Text) { - slot = Slot; - item = Item; - text = Text; - } + public AnvilClickEvent(AnvilSlot Slot, ItemStack Item, String Text) { + slot = Slot; + item = Item; + text = Text; + } - public AnvilSlot getSlot() { - return slot; - } + public AnvilSlot getSlot() { + return slot; + } - public ItemStack getItemStack() { - return item; - } + public ItemStack getItemStack() { + return item; + } - public void setItemStack(ItemStack Item) { - item = Item; - inventory.setItem(slot.getSlot(), item); - } + public void setItemStack(ItemStack Item) { + item = Item; + inventory.setItem(slot.getSlot(), item); + } - public boolean hasText() { - return text != null; - } + public boolean hasText() { + return text != null; + } - public String getText() { - return text != null ? text : defaulttext; - } + public String getText() { + return text != null ? text : defaulttext; + } } public boolean getColorRename() { - return colorrename; + return colorrename; } public void setColorRename(boolean ColorRename) { - colorrename = ColorRename; + colorrename = ColorRename; } public Player getPlayer() { - return player; + return player; } public String getTitle() { - return title; + return title; } public void setTitle(String Title) { - title = Title; + title = Title; } public String getDefaultText() { - return defaulttext; + return defaulttext; } public void setDefaultText(String DefaultText) { - defaulttext = DefaultText; + defaulttext = DefaultText; } public ItemStack getSlot(AnvilSlot Slot) { - return items.get(Slot); + return items.get(Slot); } public void setSlot(AnvilSlot Slot, ItemStack Item) { - items.put(Slot, Item); + items.put(Slot, Item); } public String getSlotName(AnvilSlot Slot) { - return ""; + return ""; } public void setSlotName(AnvilSlot Slot, String Name) { @@ -149,17 +157,71 @@ public void setSlotName(AnvilSlot Slot, String Name) { public CMIAnvilGUI(Player Player, final AnvilClickEventHandler Handler) { + loadClasses(); + + player = Player; + handler = Handler; + + listener = null; + + // PrepareAnvilEvent doesn't exist in older server versions + if (Version.isCurrentEqualOrLower(Version.v1_8_R3)) { + + listener = new Listener() { + + @EventHandler + public void ICE(InventoryClickEvent e) { + + } + + @EventHandler + public void ICE(InventoryCloseEvent e) { + + } + + @EventHandler + public void PQE(PlayerQuitEvent e) { + } + }; + + } else { + + listener = new Listener() { + + @EventHandler + public void ICE(InventoryClickEvent e) { + + } + + @EventHandler + public void PAE(PrepareAnvilEvent e) { + + } + + @EventHandler + public void ICE(InventoryCloseEvent e) { + + } + + @EventHandler + public void PQE(PlayerQuitEvent e) { + + } + }; + } + + Bukkit.getPluginManager().registerEvents(listener, CMI.getInstance()); } public void open() { - open(title); + open(title); } public Field getField(Class clazz, String fieldName) throws Exception { - Field field = clazz.getDeclaredField(fieldName); - field.setAccessible(true); - return field; + Field field = clazz.getDeclaredField(fieldName); + field.setAccessible(true); + return field; } public void open(String Title) { diff --git a/src/com/Zrips/CMI/Modules/ArmorEffects/ArmorEffectListener.java b/src/com/Zrips/CMI/Modules/ArmorEffects/ArmorEffectListener.java new file mode 100644 index 0000000..ee6c6db --- /dev/null +++ b/src/com/Zrips/CMI/Modules/ArmorEffects/ArmorEffectListener.java @@ -0,0 +1,33 @@ +package com.Zrips.CMI.Modules.ArmorEffects; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import com.Zrips.CMI.CMI; +import com.Zrips.CMI.events.CMIArmorChangeEvent; + +public class ArmorEffectListener implements Listener { + private CMI plugin; + + public ArmorEffectListener(CMI plugin) { + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onBlockInteract(CMIArmorChangeEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerLoginNameCheck(PlayerJoinEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerQuit(PlayerQuitEvent event) { + plugin.getArmorEffectManager().removePlayer(event.getPlayer().getUniqueId()); + } +} diff --git a/src/com/Zrips/CMI/Modules/ArmorEffects/ArmorEffectManager.java b/src/com/Zrips/CMI/Modules/ArmorEffects/ArmorEffectManager.java new file mode 100644 index 0000000..3a329e3 --- /dev/null +++ b/src/com/Zrips/CMI/Modules/ArmorEffects/ArmorEffectManager.java @@ -0,0 +1,59 @@ +package com.Zrips.CMI.Modules.ArmorEffects; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; + +import com.Zrips.CMI.CMI; +import com.Zrips.CMI.utils.CMIEncoder; + +import net.Zrips.CMILib.Logs.CMIDebug; +import net.Zrips.CMILib.NBT.CMINBT; + +public class ArmorEffectManager { + + private CMI plugin; + + public static final String NBTName = "CMIArmorEffects"; + + private Set players = new HashSet(); + + public ArmorEffectManager(CMI plugin) { + this.plugin = plugin; + } + + public void removePlayer(UUID uuid) { + players.remove(uuid); + if (players.isEmpty()) + onDisable(); + } + + public void addPlayer(UUID uuid) { + players.add(uuid); + } + + private int saveId = -1; + + public void onDisable() { + if (saveId != -1) { + Bukkit.getScheduler().cancelTask(saveId); + saveId = -1; + } + } + + public void tasker() { + } + + public boolean checkPlayerArmor(Player player) { + + return false; + } +} diff --git a/src/com/Zrips/CMI/Modules/AttachedCommands/CustomNBTListener.java b/src/com/Zrips/CMI/Modules/AttachedCommands/CustomNBTListener.java index 3810604..9d242ab 100644 --- a/src/com/Zrips/CMI/Modules/AttachedCommands/CustomNBTListener.java +++ b/src/com/Zrips/CMI/Modules/AttachedCommands/CustomNBTListener.java @@ -3,15 +3,25 @@ import java.util.HashMap; import java.util.UUID; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Containers.CMIEquipmentSlot; public class CustomNBTListener implements Listener { private CMI plugin; public CustomNBTListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } private static HashMap timer = new HashMap(); @@ -19,7 +29,29 @@ public CustomNBTListener(CMI plugin) { private static HashMap> cooldownMap = new HashMap>(); public static void clearCache(UUID uuid) { - timer.remove(uuid); + timer.remove(uuid); + } + + @EventHandler(priority = EventPriority.NORMAL) + public void playerInteractCommand(PlayerInteractEvent event) { + if (processInteract(event.getPlayer(), null, CMIEquipmentSlot.get(event), event.getAction(), event.getClickedBlock(), null)) { + event.setCancelled(true); + } + } + + static boolean processInteract(Player player, Player interactedPlayer, CMIEquipmentSlot hand, Action action, Block block, Entity ent) { + + return false; + } + + @EventHandler(priority = EventPriority.NORMAL) + public void playerConsumeEvent(PlayerItemConsumeEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void playerInteractAtEntityDamageCommand(EntityDamageByEntityEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/AttachedCommands/CustomNBTListener1_8.java b/src/com/Zrips/CMI/Modules/AttachedCommands/CustomNBTListener1_8.java index a603aa4..dfebece 100644 --- a/src/com/Zrips/CMI/Modules/AttachedCommands/CustomNBTListener1_8.java +++ b/src/com/Zrips/CMI/Modules/AttachedCommands/CustomNBTListener1_8.java @@ -1,21 +1,20 @@ package com.Zrips.CMI.Modules.AttachedCommands; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.CMIEquipmentSlot; public class CustomNBTListener1_8 implements Listener { private CMI plugin; public CustomNBTListener1_8(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.NORMAL) + public void playerInteractAtEntityCommand(PlayerInteractAtEntityEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/AttachedCommands/CustomNBTManager.java b/src/com/Zrips/CMI/Modules/AttachedCommands/CustomNBTManager.java index a66d291..24e48fd 100644 --- a/src/com/Zrips/CMI/Modules/AttachedCommands/CustomNBTManager.java +++ b/src/com/Zrips/CMI/Modules/AttachedCommands/CustomNBTManager.java @@ -14,8 +14,8 @@ public class CustomNBTManager { private CMI plugin; public enum CustomNBTType { - NBTCommands, CMILimitedUseCurrent, CMILimitedUseMax, CMISafeLimitedUse, CMILimitedLeftClick, CMIRepairMan, Add, Clear, Take, MoneyCheque, RandomId, @Deprecated - CooldownId, Cooldown, ItemCooldown + NBTCommands, CMILimitedUseCurrent, CMILimitedUseMax, CMISafeLimitedUse, CMILimitedLeftClick, CMIRepairMan, Add, Clear, Take, MoneyCheque, RandomId, @Deprecated + CooldownId, Cooldown, ItemCooldown } public static final String cdSpliter = ":"; @@ -27,35 +27,33 @@ public enum CustomNBTType { public static final String ignoreAction = "!ignore!"; public CustomNBTManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public ItemStack updateUsesLore(ItemStack item) { - Integer uses = new CMINBT(item).getInt(CustomNBTType.CMILimitedUseMax.name()); - if (uses == null) - return item; - return updateUsesLore(item, uses); + Integer uses = new CMINBT(item).getInt(CustomNBTType.CMILimitedUseMax.name()); + if (uses == null) + return item; + return updateUsesLore(item, uses); } public ItemStack clear(ItemStack iih) { - - return iih; + return iih; } public ItemStack updateRepairLore(ItemStack item, UUID uuid) { - - return item; + return item; } public ItemStack updateUsesLore(ItemStack item, int uses) { - return item; + return item; } public String handleConsoleCommand(Player player, String cmd) { - - return cmd; + + return cmd; } } diff --git a/src/com/Zrips/CMI/Modules/BungeeCord/BungeeCordListener.java b/src/com/Zrips/CMI/Modules/BungeeCord/BungeeCordListener.java index 7282896..02481ce 100644 --- a/src/com/Zrips/CMI/Modules/BungeeCord/BungeeCordListener.java +++ b/src/com/Zrips/CMI/Modules/BungeeCord/BungeeCordListener.java @@ -1,8 +1,6 @@ package com.Zrips.CMI.Modules.BungeeCord; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.UUID; import org.bukkit.Location; @@ -32,30 +30,30 @@ public class BungeeCordListener implements PluginMessageListener, Listener { String lastPrivateMessage = ""; class bungeePortal { - private Location loc; - private List cmds = new ArrayList(); - - public Location getLoc() { - return loc; - } - - public bungeePortal setLoc(Location loc) { - this.loc = loc; - return this; - } - - public List getCmds() { - return cmds; - } - - public bungeePortal setCmds(List cmds) { - this.cmds = cmds; - return this; - } - + private Location loc; +// private List cmds = new ArrayList(); + private long time = 0L; + + public bungeePortal() { + time = System.currentTimeMillis(); + } + + public Location getLoc() { + return loc; + } + + public bungeePortal setLoc(Location loc) { + this.loc = loc; + return this; + } + + public long getTime() { + return time; + } } public BungeeCordListener(CMI plugin) { + } @Override @@ -65,10 +63,11 @@ public void onPluginMessageReceived(String channel, Player player, byte[] bytes) @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerJoinEvent(PlayerJoinEvent event) { - + } @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerQuitEvent(PlayerQuitEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/BungeeCord/BungeeCordManager.java b/src/com/Zrips/CMI/Modules/BungeeCord/BungeeCordManager.java index 8d16f98..3f22eb8 100644 --- a/src/com/Zrips/CMI/Modules/BungeeCord/BungeeCordManager.java +++ b/src/com/Zrips/CMI/Modules/BungeeCord/BungeeCordManager.java @@ -1,7 +1,6 @@ package com.Zrips.CMI.Modules.BungeeCord; import java.util.HashMap; -import java.util.Map.Entry; import java.util.UUID; import org.bukkit.Bukkit; @@ -25,14 +24,10 @@ public class BungeeCordManager { public static final String PortalSetChannel = "CMIPortalSetSubChannel"; public static final String PortalConfirmedSetChannel = "CMIPortalCSetSubChannel"; public static final String PortalLocChannel = "CMIPortalLocSubChannel"; -// public static final String PlayerInfoChannel = "CMIPlayerInfoSubChannel"; -// public static final String PlayerInfoRequestChannel = "CMIPlayerInfoReqChannel"; public static final String PlayerListRequest = "CMIPlayerListRequest"; public static final String PlayerListFeedback = "CMIPlayerListFeedback"; -// public static final String PlayerRequest = "CMIPlayerRequest"; public static final String PlayerFeedback = "CMIPlayerFeedback"; public static final String ServerListRequest = "CMIServerListRequest"; -// public static final String PlayerCountChangeChannel = "CMIPlayerChangeChannel"; public static UUID localRangedMessage; public static long localRangedMessageTime; @@ -48,12 +43,11 @@ public class BungeeCordManager { private CMIBungeeCord bcord = null; public BungeeCordManager(CMI plugin) { - this.plugin = plugin; - bcord = CMIBungeeCord.of(plugin); + this.plugin = plugin; + bcord = CMIBungeeCord.of(plugin); } public void loadConfig() { - } public void initialize() { @@ -61,51 +55,56 @@ public void initialize() { } public boolean isCMIBPresent() { - return CMIBPresent; + return CMIBPresent; } public void setCMIBPresent(boolean cMIBPresent) { - if (cMIBPresent) { - plugin.consoleMessage("CMIB proxy plugin detected"); - } - CMIBPresent = cMIBPresent; + if (cMIBPresent) { + plugin.consoleMessage("CMIB proxy plugin detected"); + } + CMIBPresent = cMIBPresent; } @Deprecated public boolean isBungee() { - return isBungeeCord(); + return isBungeeCord(); } public void setBungeeCord(boolean state) { - isBungee = state; + isBungee = state; } public boolean isBungeeCord() { - return isBungee && enabledSupport; + return isBungee && enabledSupport; } public void addServer(BungeeCordServer server) { - gotServerList = true; - servers.put(server.getName().toLowerCase(), server); - server.update(); + gotServerList = true; + servers.put(server.getName().toLowerCase(), server); + server.update(); } Long time = 0L; public BungeeCordServer getServer(String server) { - if (System.currentTimeMillis() > time + 60000L) { - updateServers(); - } - return servers.get(server.toLowerCase()); + if (System.currentTimeMillis() > time + 60000L) { + updateServers(); + } + return servers.get(server.toLowerCase()); } public HashMap getServers() { - - return servers; + if (System.currentTimeMillis() > time + 60000L) { + updateServers(); + time = System.currentTimeMillis(); + } + return servers; } public void sendServerListRequest() { - + } + + public void sendPlayerListRequest() { } public void sendPlayerInfoRequest(String serverName) { @@ -113,81 +112,73 @@ public void sendPlayerInfoRequest(String serverName) { } private static Player getFirstPlayer() { - Player firstPlayer = Iterables.getFirst(Bukkit.getOnlinePlayers(), null); - return firstPlayer; + Player firstPlayer = Iterables.getFirst(Bukkit.getOnlinePlayers(), null); + return firstPlayer; } public BungeeCordServer getThisServer() { - if (thisServer == null) { - if (getThisServerName() != null) { - thisServer = this.getServer(getThisServerName()); - } - } - return thisServer; + if (thisServer == null) { + if (getThisServerName() != null) { + thisServer = this.getServer(getThisServerName()); + } + } + return thisServer; } public void setThisServer(BungeeCordServer thisServer) { - this.thisServer = thisServer; + this.thisServer = thisServer; } public String getThisServerName() { - if (thisServerName == null && thisServer != null) - thisServerName = thisServer.getName(); - return thisServerName == null ? CMILib.getInstance().getReflectionManager().getServerName() : thisServerName; + if (thisServerName == null && thisServer != null) + thisServerName = thisServer.getName(); + return thisServerName == null ? CMILib.getInstance().getReflectionManager().getServerName() : thisServerName; } private static final String spacer = "_20_"; public String getThisServerNameOneWord() { - if (thisServerName == null && thisServer != null) - thisServerName = thisServer.getName(); - return thisServerName == null ? CMILib.getInstance().getReflectionManager().getServerName().replace(" ", spacer) : thisServerName.replace(" ", spacer); + if (thisServerName == null && thisServer != null) + thisServerName = thisServer.getName(); + return thisServerName == null ? CMILib.getInstance().getReflectionManager().getServerName().replace(" ", spacer) : thisServerName.replace(" ", spacer); } public void setThisServerName(String thisServerName) { + this.thisServerName = thisServerName; + if (getThisServerName() != null) { + thisServer = this.getServer(getThisServerName()); + } } public BungeePlayer getBungeePlayer(String player) { - if (!enabledSupport) - return null; - for (Entry one : servers.entrySet()) { - BungeePlayer p = one.getValue().getPlayer(player); - if (p != null) - return p; - } - return null; + return null; } public BungeePlayer getBungeePlayer(UUID uuid) { - - return null; + return null; } public BungeeCordServer getPlayerServer(UUID uuid) { - - return null; + return null; } public BungeeCordServer getPlayerServer(String player) { - - return null; + return null; } public boolean anyPlayersOnServer(String serverName) { - if (!enabledSupport) - return false; - BungeeCordServer server = this.getServer(serverName); - if (server == null) - return false; - return server.getCurrentPlayers() > 0; + if (!enabledSupport) + return false; + BungeeCordServer server = this.getServer(serverName); + if (server == null) + return false; + return server.getCurrentPlayers() > 0; } public void updateServersInfo() { - } public void updateServersIp() { - } public void updateServers() { @@ -195,19 +186,17 @@ public void updateServers() { } public void connectToServer(Player player, String serverName) { - } public void connectOther(String playerName, String server) { - } public void connectToServer(String player, String server) { - connectToServer(Bukkit.getPlayer(player), server); + connectToServer(Bukkit.getPlayer(player), server); } public int getPlayersInServer(String serverName) { - return 0; + return 0; } public void sendPublicMessage(String server, String sender, String message) { @@ -224,7 +213,7 @@ public void sendStaffMessage(String server, String sender, String message) { @Deprecated public void sendMessage(String sender, String target, String message) { - sendPrivateMessage(sender, target, message); + sendPrivateMessage(sender, target, message); } public void sendPrivateMessage(String sender, String target, String message) { @@ -253,7 +242,7 @@ public void forward(String server, String channelName, byte[] data) { public boolean isPlayerOnAnotherServer(String player) { - return false; + return false; } public void sendNewPlayerInfoToNetwork(Player player) { @@ -265,10 +254,10 @@ public void sendNewPlayerInfoToNetwork(Player player, String server) { } public boolean isEnabledSupport() { - return enabledSupport; + return enabledSupport; } public CMIBungeeCord getBungeeCord() { - return bcord; + return bcord; } } diff --git a/src/com/Zrips/CMI/Modules/BungeeCord/BungeeCordServer.java b/src/com/Zrips/CMI/Modules/BungeeCord/BungeeCordServer.java index fe629da..300effe 100644 --- a/src/com/Zrips/CMI/Modules/BungeeCord/BungeeCordServer.java +++ b/src/com/Zrips/CMI/Modules/BungeeCord/BungeeCordServer.java @@ -20,73 +20,69 @@ public class BungeeCordServer { private ConcurrentHashMap playersMapName = new ConcurrentHashMap(); public BungeeCordServer(String name, String ip, Integer port) { - this.name = name; - this.ip = ip; - this.port = port; + this.name = name; + this.ip = ip; + this.port = port; } public String getName() { - return name; + return name; } public void setName(String name) { - this.name = name; + this.name = name; } public String getIp() { - return ip; + return ip; } public void setIp(String ip) { - this.ip = ip; + this.ip = ip; } public int getPort() { - return port; + return port; } public void setPort(int port) { - this.port = port; + this.port = port; } public String getMotd() { - return motd; + return motd; } public void setMotd(String motd) { - this.motd = motd; + this.motd = motd; } public int getMaxPlayers() { - return maxPlayers; + return maxPlayers; } public void setMaxPlayers(int maxPlayers) { - this.maxPlayers = maxPlayers; + this.maxPlayers = maxPlayers; } public int getCurrentPlayers() { - int total = 0; - Iterator> iter = playersMapUUID.entrySet().iterator(); - while (iter.hasNext()) { - BungeePlayer user = iter.next().getValue(); - if (user.getVanished()) - continue; - total++; - } - return total; + int total = 0; + Iterator> iter = playersMapUUID.entrySet().iterator(); + while (iter.hasNext()) { + BungeePlayer user = iter.next().getValue(); + if (user.getVanished()) + continue; + total++; + } + return total; } -// public void setCurrentPlayers(int currentPlayers) { -// this.currentPlayers = currentPlayers; -// } - public Long getNextCheck() { - return nextCheck; + return nextCheck; } public void setNextCheck(Long nextCheck) { - this.nextCheck = nextCheck; + this.nextCheck = nextCheck; } public void update() { @@ -94,39 +90,40 @@ public void update() { } public boolean isOnline() { - return online; + return online; } public void setOnline(boolean online) { - this.online = online; + this.online = online; } public ConcurrentHashMap getPlayersMapUUID() { - return playersMapUUID; + return playersMapUUID; } public BungeePlayer getPlayer(UUID uuid) { - return playersMapUUID.get(uuid.toString()); + return playersMapUUID.get(uuid.toString()); } public BungeePlayer getPlayer(String name) { - return playersMapName.get(name.toLowerCase()); + BungeePlayer p = playersMapName.get(name.toLowerCase()); + return p; } public void addPlayer(BungeePlayer player) { - this.playersMapUUID.put(player.getUniqueId().toString(), player); - this.playersMapName.put(player.getName().toLowerCase(), player); + this.playersMapUUID.put(player.getUniqueId().toString(), player); + this.playersMapName.put(player.getName().toLowerCase(), player); } public void removePlayer(UUID uuid, String name) { - this.playersMapUUID.remove(uuid.toString()); - this.playersMapName.remove(name.toLowerCase()); + this.playersMapUUID.remove(uuid.toString()); + this.playersMapName.remove(name.toLowerCase()); } public void clearPlayers() { - if (playersMapUUID != null) - this.playersMapUUID.clear(); - if (playersMapName != null) - this.playersMapName.clear(); + if (playersMapUUID != null) + this.playersMapUUID.clear(); + if (playersMapName != null) + this.playersMapName.clear(); } } diff --git a/src/com/Zrips/CMI/Modules/BungeeCord/BungeePlayer.java b/src/com/Zrips/CMI/Modules/BungeeCord/BungeePlayer.java index f5bb15a..6d225b9 100644 --- a/src/com/Zrips/CMI/Modules/BungeeCord/BungeePlayer.java +++ b/src/com/Zrips/CMI/Modules/BungeeCord/BungeePlayer.java @@ -10,6 +10,9 @@ public class BungeePlayer { private BungeeCordServer bungeeServer; private UUID uuid; private boolean vanished = false; + + private String previousServer = null; + private Long serverSwitchTime = 0L; public boolean getVanished() { return vanished; @@ -67,4 +70,20 @@ public void setNickName(String nickName) { this.nickName = nickName; } + public Long getServerSwitchTime() { + return serverSwitchTime; + } + + public void setServerSwitchTime(Long serverSwitchTime) { + this.serverSwitchTime = serverSwitchTime; + } + + public String getPreviousServer() { + return previousServer; + } + + public void setPreviousServer(String previousServer) { + this.previousServer = previousServer; + } + } diff --git a/src/com/Zrips/CMI/Modules/BungeeCord/CMIBungeeCord.java b/src/com/Zrips/CMI/Modules/BungeeCord/CMIBungeeCord.java index 251a40d..6443b56 100644 --- a/src/com/Zrips/CMI/Modules/BungeeCord/CMIBungeeCord.java +++ b/src/com/Zrips/CMI/Modules/BungeeCord/CMIBungeeCord.java @@ -1,16 +1,21 @@ package com.Zrips.CMI.Modules.BungeeCord; import java.net.InetSocketAddress; +import java.util.ArrayDeque; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Queue; import java.util.WeakHashMap; import java.util.concurrent.CompletableFuture; import java.util.function.BiFunction; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.messaging.Messenger; import org.bukkit.plugin.messaging.PluginMessageListener; import com.google.common.collect.Iterables; @@ -26,111 +31,286 @@ public class CMIBungeeCord { private Map forwardListeners; private ForwardConsumer globalForwardListener; + /** + * Get or create new BungeeChannelApi instance + * + * @param plugin the plugin instance. + * @return the BungeeChannelApi instance for the {@code plugin} + * @throws NullPointerException if the {@code plugin} is {@code null} + */ public synchronized static CMIBungeeCord of(Plugin plugin) { - return registeredInstances.compute(plugin, (k, v) -> { - if (v == null) - v = new CMIBungeeCord(plugin); - return v; - }); + return registeredInstances.compute(plugin, (k, v) -> { + if (v == null) + v = new CMIBungeeCord(plugin); + return v; + }); } public CMIBungeeCord(Plugin plugin) { - this.messageListener = null; - this.plugin = null; - this.callbackMap = null; + this.plugin = Objects.requireNonNull(plugin, "plugin cannot be null"); + this.callbackMap = new HashMap<>(); + + // Prevent dev's from registering multiple channel listeners, + // by unregistering the old instance. + synchronized (registeredInstances) { + registeredInstances.compute(plugin, (k, oldInstance) -> { + if (oldInstance != null) + oldInstance.unregister(); + return this; + }); + } + + this.messageListener = this::onPluginMessageReceived; + + Messenger messenger = Bukkit.getServer().getMessenger(); + messenger.registerOutgoingPluginChannel(plugin, "BungeeCord"); + messenger.registerIncomingPluginChannel(plugin, "BungeeCord", messageListener); } + /** + * Set a global listener for all 'forwarded' messages. + * + * @param globalListener the listener + * @see https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/#forward + */ public void registerForwardListener(ForwardConsumer globalListener) { - this.globalForwardListener = globalListener; + this.globalForwardListener = globalListener; } + /** + * Set a listener for all 'forwarded' messages in a specific subchannel. + * + * @param channelName the subchannel name + * @param listener the listener + * @see https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/#forward + */ public void registerForwardListener(String channelName, ForwardConsumer listener) { - + if (forwardListeners == null) { + forwardListeners = new HashMap<>(); + } + synchronized (forwardListeners) { + forwardListeners.put(channelName, listener); + } } + /** + * Get the amount of players on a certain server, or on ALL the servers. + * + * @param serverName the server name of the server to get the player count of, or ALL to get the global player count + * @return A {@link CompletableFuture} that, when completed, will return + * the amount of players on a certain server, or on ALL the servers. + * @throws IllegalArgumentException if there is no players online. + */ public CompletableFuture getPlayerCount(String serverName) { - - return null; + Player player = getFirstPlayer(); + + CompletableFuture future = new CompletableFuture<>(); + + return future; } + /** + * Get a list of players connected on a certain server, or on ALL the servers. + * + * @param serverName the name of the server to get the list of connected players, or ALL for global online player list + * @return A {@link CompletableFuture} that, when completed, will return a + * list of players connected on a certain server, or on ALL the servers. + * @throws IllegalArgumentException if there is no players online. + */ public CompletableFuture> getPlayerList(String serverName) { - return null; + Player player = getFirstPlayer(); + + CompletableFuture> future = new CompletableFuture<>(); + + return future; } + /** + * Get a list of server name strings, as defined in BungeeCord's config.yml. + * + * @return A {@link CompletableFuture} that, when completed, will return a + * list of server name strings, as defined in BungeeCord's config.yml. + * @throws IllegalArgumentException if there is no players online. + */ public CompletableFuture> getServers() { - return null; + Player player = getFirstPlayer(); + + CompletableFuture> future = new CompletableFuture<>(); + + return future; } + /** + * Connects a player to said subserver. + * + * @param player the player you want to teleport. + * @param serverName the name of server to connect to, as defined in BungeeCord config.yml. + */ public void connect(Player player, String serverName) { } + /** + * Connect a named player to said subserver. + * + * @param playerName name of the player to teleport. + * @param server name of server to connect to, as defined in BungeeCord config.yml. + * @throws IllegalArgumentException if there is no players online. + */ public void connectOther(String playerName, String server) { } + /** + * Get the (real) IP of a player. + * + * @param player The player you wish to get the IP of. + * @return A {@link CompletableFuture} that, when completed, will return the (real) IP of {@code player}. + */ public CompletableFuture getIp(Player player) { - return null; + CompletableFuture future = new CompletableFuture<>(); + + return future; } + /** + * Send a message (as in, a chat message) to the specified player. + * + * @param playerName the name of the player to send the chat message. + * @param message the message to send to the player. + * @throws IllegalArgumentException if there is no players online. + */ public void sendMessage(String playerName, String message) { } + /** + * Get this server's name, as defined in BungeeCord's config.yml + * + * @return A {@link CompletableFuture} that, when completed, will return + * the {@code server's} name, as defined in BungeeCord's config.yml. + * @throws IllegalArgumentException if there is no players online. + */ public CompletableFuture getServer() { - return null; + Player player = getFirstPlayer(); + CompletableFuture future = new CompletableFuture<>(); + + return future; } + /** + * Request the UUID of this player. + * + * @param player The player whose UUID you requested. + * @return A {@link CompletableFuture} that, when completed, will return the UUID of {@code player}. + */ public CompletableFuture getUUID(Player player) { - return null; + CompletableFuture future = new CompletableFuture<>(); + + return future; } + /** + * Request the UUID of any player connected to the BungeeCord proxy. + * + * @param playerName the name of the player whose UUID you would like. + * @return A {@link CompletableFuture} that, when completed, will return the UUID of {@code playerName}. + * @throws IllegalArgumentException if there is no players online. + */ public CompletableFuture getUUID(String playerName) { - return null; + Player player = getFirstPlayer(); + CompletableFuture future = new CompletableFuture<>(); + + return future; } + /** + * Request the IP of any server on this proxy. + * + * @param serverName the name of the server. + * @return A {@link CompletableFuture} that, when completed, will return the requested ip. + * @throws IllegalArgumentException if there is no players online. + */ public CompletableFuture getServerIp(String serverName) { - return null; + Player player = getFirstPlayer(); + CompletableFuture future = new CompletableFuture<>(); + + return future; } + /** + * Kick any player on this proxy. + * + * @param playerName the name of the player. + * @param kickMessage the reason the player is kicked with. + * @throws IllegalArgumentException if there is no players online. + */ public void kickPlayer(String playerName, String kickMessage) { } + /** + * Send a custom plugin message to said server. This is one of the most useful channels ever. + * Remember, the sending and receiving server(s) need to have a player online. + * + * @param server the name of the server to send to, + * ALL to send to every server (except the one sending the plugin message), + * or ONLINE to send to every server that's online (except the one sending the plugin message). + * + * @param channelName Subchannel for plugin usage. + * @param data data to send. + * @throws IllegalArgumentException if there is no players online. + */ public void forward(String server, String channelName, byte[] data) { - } + /** + * Send a custom plugin message to specific player. + * + * @param playerName the name of the player to send to. + * @param channelName Subchannel for plugin usage. + * @param data data to send. + * @throws IllegalArgumentException if there is no players online. + */ public void forwardToPlayer(String playerName, String channelName, byte[] data) { - } @SuppressWarnings("unchecked") private void onPluginMessageReceived(String channel, Player player, byte[] message) { - + } + /** + * Unregister message channels. + */ public void unregister() { - } private BiFunction>, Queue>> computeQueueValue(CompletableFuture queueValue) { - - return null; + return (key, value) -> { + if (value == null) + value = new ArrayDeque>(); + value.add(queueValue); + return value; + }; } private Player getFirstPlayer() { - - return null; + /** + * if Bukkit Version < 1.7.10 then Bukkit.getOnlinePlayers() will return + * a Player[] otherwise it'll return a Collection. + */ + + return getFirstPlayer0(Bukkit.getOnlinePlayers()); } @SuppressWarnings("unused") private Player getFirstPlayer0(Player[] playerArray) { - return playerArray.length > 0 ? playerArray[0] : null; + return playerArray.length > 0 ? playerArray[0] : null; } private Player getFirstPlayer0(Collection playerCollection) { - return Iterables.getFirst(playerCollection, null); + return Iterables.getFirst(playerCollection, null); } @FunctionalInterface public interface ForwardConsumer { - void accept(String channel, Player player, byte[] data); + void accept(String channel, Player player, byte[] data); } } \ No newline at end of file diff --git a/src/com/Zrips/CMI/Modules/BungeeCord/ServerListPing.java b/src/com/Zrips/CMI/Modules/BungeeCord/ServerListPing.java index 529fb40..1529518 100644 --- a/src/com/Zrips/CMI/Modules/BungeeCord/ServerListPing.java +++ b/src/com/Zrips/CMI/Modules/BungeeCord/ServerListPing.java @@ -16,209 +16,209 @@ public class ServerListPing { private Gson gson = new Gson(); public ServerListPing(String ip, int port) { - this.host = new InetSocketAddress(ip, port); + this.host = new InetSocketAddress(ip, port); } public ServerListPing(InetSocketAddress host) { - this.host = host; + this.host = host; } public InetSocketAddress getAddress() { - return this.host; + return this.host; } void setTimeout(int timeout) { - this.timeout = timeout; + this.timeout = timeout; } int getTimeout() { - return this.timeout; + return this.timeout; } public int readVarInt(DataInputStream in) throws IOException { - int i = 0; - return i; + int i = 0; + return i; } public void writeVarInt(DataOutputStream out, int paramInt) throws IOException { - + } public StatusResponse fetchData() throws IOException { - return null; + return null; } public class Description { - private String text; + private String text; - public String getText() { - return text; - } + public String getText() { + return text; + } } public class Description116 { - private Gson text; + private Gson text; - public Gson getText() { - return text; - } + public Gson getText() { + return text; + } } public class StatusResponse { - private String description; - private Players players; - private Version version; - private String favicon; - private int time; + private String description; + private Players players; + private Version version; + private String favicon; + private int time; - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public Players getPlayers() { - return players; - } + public Players getPlayers() { + return players; + } - public Version getVersion() { - return version; - } + public Version getVersion() { + return version; + } - public String getFavicon() { - return favicon; - } + public String getFavicon() { + return favicon; + } - public int getTime() { - return time; - } + public int getTime() { + return time; + } - public void setTime(int time) { - this.time = time; - } + public void setTime(int time) { + this.time = time; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public void setPlayers(Players players) { - this.players = players; - } + public void setPlayers(Players players) { + this.players = players; + } - public void setVersion(Version version) { - this.version = version; - } + public void setVersion(Version version) { + this.version = version; + } - public void setFavicon(String favicon) { - this.favicon = favicon; - } + public void setFavicon(String favicon) { + this.favicon = favicon; + } } public class StatusResponse19 { - private Description description; - private Players players; - private Version version; - private String favicon; - private int time; + private Description description; + private Players players; + private Version version; + private String favicon; + private int time; - public Description getDescription() { - return description; - } + public Description getDescription() { + return description; + } - public Players getPlayers() { - return players; - } + public Players getPlayers() { + return players; + } - public Version getVersion() { - return version; - } + public Version getVersion() { + return version; + } - public String getFavicon() { - return favicon; - } + public String getFavicon() { + return favicon; + } - public int getTime() { - return time; - } + public int getTime() { + return time; + } - public void setTime(int time) { - this.time = time; - } + public void setTime(int time) { + this.time = time; + } } public class StatusResponse116 { - private Description116 description; - private Players players; - private Version version; - private String favicon; - private int time; + private Description116 description; + private Players players; + private Version version; + private String favicon; + private int time; - public Description116 getDescription() { - return description; - } + public Description116 getDescription() { + return description; + } - public Players getPlayers() { - return players; - } + public Players getPlayers() { + return players; + } - public Version getVersion() { - return version; - } + public Version getVersion() { + return version; + } - public String getFavicon() { - return favicon; - } + public String getFavicon() { + return favicon; + } - public int getTime() { - return time; - } + public int getTime() { + return time; + } - public void setTime(int time) { - this.time = time; - } + public void setTime(int time) { + this.time = time; + } } public class Players { - private int max = 0; - private int online = 0; - private List sample = null; + private int max = 0; + private int online = 0; + private List sample = null; - public int getMax() { - return max; - } + public int getMax() { + return max; + } - public int getOnline() { - return online; - } + public int getOnline() { + return online; + } - public List getSample() { - return sample == null ? new ArrayList() : sample; - } + public List getSample() { + return sample == null ? new ArrayList() : sample; + } } public class Player { - private String name; - private String id; + private String name; + private String id; - public String getName() { - return name; - } + public String getName() { + return name; + } - public String getId() { - return id; - } + public String getId() { + return id; + } } public class Version { - private String name; - private String protocol; + private String name; + private String protocol; - public String getName() { - return name; - } + public String getName() { + return name; + } - public String getProtocol() { - return protocol; - } + public String getProtocol() { + return protocol; + } } } diff --git a/src/com/Zrips/CMI/Modules/ChatFilter/ChatFilterListener.java b/src/com/Zrips/CMI/Modules/ChatFilter/ChatFilterListener.java index 9fee3bc..3a14e9c 100644 --- a/src/com/Zrips/CMI/Modules/ChatFilter/ChatFilterListener.java +++ b/src/com/Zrips/CMI/Modules/ChatFilter/ChatFilterListener.java @@ -1,6 +1,11 @@ package com.Zrips.CMI.Modules.ChatFilter; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.SignChangeEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import com.Zrips.CMI.CMI; @@ -8,6 +13,31 @@ public class ChatFilterListener implements Listener { private CMI plugin; public ChatFilterListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.LOW) + public void capsFilter(final AsyncPlayerChatEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW) + public void AsyncPlayerChatEvent(final AsyncPlayerChatEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW) + public void spamFilter(AsyncPlayerChatEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW) + public void spamCommandFilter(PlayerCommandPreprocessEvent event) { + + } + + @EventHandler + public void onSignChangeEventAdvertisement(SignChangeEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/ChatFilter/ChatFilterManager.java b/src/com/Zrips/CMI/Modules/ChatFilter/ChatFilterManager.java index cbe722f..4e0658f 100644 --- a/src/com/Zrips/CMI/Modules/ChatFilter/ChatFilterManager.java +++ b/src/com/Zrips/CMI/Modules/ChatFilter/ChatFilterManager.java @@ -32,7 +32,7 @@ public class ChatFilterManager { private int douplicateCommandMinAmount = 5; private List douplicateCommandWhiteList = new ArrayList(); - private Boolean capsFilter; + private boolean capsFilter = true; private int capsIgnoreUnder; private int capsPercentage; @@ -43,55 +43,87 @@ public class ChatFilterManager { public final static String StringchatFilterFile = "chatfilter.yml"; public void clearCache(UUID uuid) { - spamMessages.remove(uuid); - spamCommands.remove(uuid); + spamMessages.remove(uuid); + spamCommands.remove(uuid); } public ChatFilterManager(CMI plugin) { - + } public boolean checkCaps(Player player, String message) { - return true; + return true; } public RuleResponce getCorrectMessage(Player player, String message) { - return getCorrectMessage(player, message, false); + return getCorrectMessage(player, message, false); } public RuleResponce getCorrectMessage(Player player, String message, boolean privateMessage) { - - return null; + + RuleResponce responce = new RuleResponce(message); + + return responce; } public boolean isSpamedCommand(Player player, String message) { - - return false; + + return false; } private boolean isWhiteListedCommand(String command) { - - return false; + + return false; } public boolean isSpam(Player player, String message) { - - return false; + + return false; } public static double similarity(String s1, String s2) { - return 1.0; - + String longer = s1, shorter = s2; + if (s1.length() < s2.length()) { + longer = s2; + shorter = s1; + } + int longerLength = longer.length(); + if (longerLength == 0) { + return 1.0; + } + return (longerLength - editDistance(longer, shorter)) / (double) longerLength; } public static int editDistance(String s1, String s2) { - - return 0; + s1 = s1.toLowerCase(); + s2 = s2.toLowerCase(); + int[] costs = new int[s2.length() + 1]; + for (int i = 0; i <= s1.length(); i++) { + int lastValue = i; + for (int j = 0; j <= s2.length(); j++) { + if (i == 0) + costs[j] = j; + else { + if (j > 0) { + int newValue = costs[j - 1]; + if (s1.charAt(i - 1) != s2.charAt(j - 1)) + newValue = Math.min(Math.min(newValue, lastValue), + costs[j]) + 1; + costs[j - 1] = lastValue; + lastValue = newValue; + } + } + } + if (i > 0) + costs[s2.length()] = lastValue; + } + return costs[s2.length()]; } private static ChatFilterBlockType getBlockType(String type) { - return ChatFilterBlockType.None; + + return ChatFilterBlockType.None; } public void load() { diff --git a/src/com/Zrips/CMI/Modules/ChatFilter/ChatFilterRule.java b/src/com/Zrips/CMI/Modules/ChatFilter/ChatFilterRule.java index d5777ec..a73c415 100644 --- a/src/com/Zrips/CMI/Modules/ChatFilter/ChatFilterRule.java +++ b/src/com/Zrips/CMI/Modules/ChatFilter/ChatFilterRule.java @@ -51,8 +51,8 @@ public ChatFilterRule setPattern(String list) { public void setPattern(List list) { pattern.clear(); - for (String one : list) { - pattern.add(Pattern.compile(one)); + for (String one : list) { + pattern.add(Pattern.compile(one, Pattern.UNICODE_CASE)); } } diff --git a/src/com/Zrips/CMI/Modules/ChatFilter/MessageLog.java b/src/com/Zrips/CMI/Modules/ChatFilter/MessageLog.java index 9380516..e8f9010 100644 --- a/src/com/Zrips/CMI/Modules/ChatFilter/MessageLog.java +++ b/src/com/Zrips/CMI/Modules/ChatFilter/MessageLog.java @@ -1,9 +1,6 @@ package com.Zrips.CMI.Modules.ChatFilter; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; -import java.util.Map.Entry; public class MessageLog { @@ -11,19 +8,19 @@ public class MessageLog { private int range = 5; public MessageLog(int range) { - this.range = range; + this.range = range; } public void addMessage(String message) { - messages.put(System.currentTimeMillis(), message); + messages.put(System.currentTimeMillis(), message); } private void removeOld() { } public HashMap getMessages() { - removeOld(); - return messages; + removeOld(); + return messages; } } diff --git a/src/com/Zrips/CMI/Modules/ChatFilter/RuleResponce.java b/src/com/Zrips/CMI/Modules/ChatFilter/RuleResponce.java index 1ecd4f3..ade29de 100644 --- a/src/com/Zrips/CMI/Modules/ChatFilter/RuleResponce.java +++ b/src/com/Zrips/CMI/Modules/ChatFilter/RuleResponce.java @@ -3,7 +3,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map.Entry; import net.Zrips.CMILib.Chat.ChatFilterBlockType; @@ -15,64 +14,56 @@ public class RuleResponce { private List bypass = new ArrayList(); public RuleResponce(String message) { - this.message = message; + this.message = message; } public String getMessage() { - return message; + return message; } public void setMessage(String message) { - this.message = message; + this.message = message; } public HashMap getRules() { - return rules; + return rules; } public String getRulesNamesAsString() { - String n = ""; - return n; + String n = ""; + return n; } public void addRule(ChatFilterRule rule) { - if (rule != null && !this.rules.containsKey(rule.getRuleName())) - this.rules.put(rule.getRuleName(), rule); } public ChatFilterBlockType getMaxFilterBlockType() { - ChatFilterBlockType type = ChatFilterBlockType.None; - return type; + ChatFilterBlockType type = ChatFilterBlockType.None; + return type; } public boolean isInformConsole() { - boolean inform = false; - for (Entry one : rules.entrySet()) { - if (isBypass(one.getValue().getGroup())) - continue; - if (one.getValue().isInformConsole()) - inform = true; - } - return inform; + boolean inform = false; + return inform; } public boolean isBypass(String bypass) { - return this.bypass.contains(bypass.toLowerCase()); + return this.bypass.contains(bypass.toLowerCase()); } public void addBypass(String bypass) { - if (!this.bypass.contains(bypass.toLowerCase())) - this.bypass.add(bypass.toLowerCase()); + if (!this.bypass.contains(bypass.toLowerCase())) + this.bypass.add(bypass.toLowerCase()); } public String getUpdatedMessage() { - if (updatedMessage == null) - return message; - return updatedMessage; + if (updatedMessage == null) + return message; + return updatedMessage; } public void setUpdatedMessage(String updatedMessage) { - this.updatedMessage = updatedMessage; + this.updatedMessage = updatedMessage; } } diff --git a/src/com/Zrips/CMI/Modules/ChatFormat/CMIChatRoom.java b/src/com/Zrips/CMI/Modules/ChatFormat/CMIChatRoom.java index 8d60dc1..22633b1 100644 --- a/src/com/Zrips/CMI/Modules/ChatFormat/CMIChatRoom.java +++ b/src/com/Zrips/CMI/Modules/ChatFormat/CMIChatRoom.java @@ -9,6 +9,7 @@ public class CMIChatRoom { private Set users = new HashSet(); + private Set watchers = new HashSet(); private String chatName; private UUID owner; private boolean priv = false; @@ -18,47 +19,67 @@ public class CMIChatRoom { private long keepAliveUntil = 0L; public CMIChatRoom(String chatName) { - this.chatName = chatName; + this.chatName = chatName; } public String getChatName() { - return chatName; + return chatName; } public void setChatName(String chatName) { - this.chatName = chatName; + this.chatName = chatName; } public Set getUsers() { - return users; + return users; + } + + public Set getWatchers() { + return watchers; + } + + public Set getWatchersUUID() { + Set uuids = new HashSet(); + for (CMIUser one : getWatchers()) { + uuids.add(one.getUniqueId()); + } + return uuids; } public void addUser(CMIUser user) { - this.users.add(user); - user.setChatRoom(this); - keepAliveUntil = 0L; + this.users.add(user); + user.setChatRoom(this); + keepAliveUntil = 0L; } public boolean removeUser(CMIUser user) { - user.setChatRoom(null); - boolean feed = users.remove(user); - if (users.isEmpty() && !persistent) - keepAliveUntil = System.currentTimeMillis() + (ChatFormatManager.ChatRoomLife * 1000L); - else - keepAliveUntil = System.currentTimeMillis() + (60 * 60 * 24 * 7 * 1000L); - return feed; + user.setChatRoom(null); + boolean feed = users.remove(user); + if (users.isEmpty() && !persistent) + keepAliveUntil = System.currentTimeMillis() + (ChatFormatManager.ChatRoomLife * 1000L); + else + keepAliveUntil = System.currentTimeMillis() + (60 * 60 * 24 * 7 * 1000L); + return feed; + } + + public void addWatcher(CMIUser user) { + this.watchers.add(user); + } + + public boolean removeWatcher(CMIUser user) { + return watchers.remove(user); } public void broadcastMessage(CMIUser sender, String msg) { - + } public void cleanOldUsers() { + } public void informLeave(CMIUser left) { - } public void informJoin(CMIUser joined) { @@ -66,72 +87,73 @@ public void informJoin(CMIUser joined) { } public UUID getOwner() { - return owner; + return owner; } public void setOwner(UUID owner) { - this.owner = owner; + this.owner = owner; } public boolean isOwner(UUID check) { - return owner.equals(check); + return owner.equals(check); } public boolean isPrivate() { - return priv; + return priv; } public void setPrivate(boolean priv) { - this.priv = priv; + this.priv = priv; } public boolean kick(CMIUser user) { - return true; + + return true; } public Set getInvitations() { - return invitations; + return invitations; } public boolean isInvited(UUID uuid) { - if (this.invitations == null) - return false; - return invitations.contains(uuid); + if (this.invitations == null) + return false; + return invitations.contains(uuid); } public void addInvitation(UUID uuid) { - if (this.invitations == null) - this.invitations = new HashSet(); - this.invitations.add(uuid); + if (this.invitations == null) + this.invitations = new HashSet(); + this.invitations.add(uuid); } public void removeInvitation(UUID uuid) { - if (this.invitations == null) - return; - this.invitations.remove(uuid); + if (this.invitations == null) + return; + this.invitations.remove(uuid); } public long getKeepAliveUntil() { - return keepAliveUntil; + return keepAliveUntil; } public void setKeepAliveUntil(long keepAliveUntil) { - this.keepAliveUntil = keepAliveUntil; + this.keepAliveUntil = keepAliveUntil; } public boolean isLocked() { - return locked; + return locked; } public void setLocked(boolean locked) { - this.locked = locked; + this.locked = locked; } public boolean isPersistent() { - return persistent; + return persistent; } public void setPersistent(boolean persistent) { - this.persistent = persistent; + this.persistent = persistent; } } diff --git a/src/com/Zrips/CMI/Modules/ChatFormat/ChatColorListener.java b/src/com/Zrips/CMI/Modules/ChatFormat/ChatColorListener.java index 700f9bf..4a3f3af 100644 --- a/src/com/Zrips/CMI/Modules/ChatFormat/ChatColorListener.java +++ b/src/com/Zrips/CMI/Modules/ChatFormat/ChatColorListener.java @@ -1,6 +1,9 @@ package com.Zrips.CMI.Modules.ChatFormat; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; import com.Zrips.CMI.CMI; @@ -8,6 +11,11 @@ public class ChatColorListener implements Listener { private CMI plugin; public ChatColorListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.NORMAL) + public void cleanPublicChatFromColors(AsyncPlayerChatEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/ChatFormat/ChatFormatListener.java b/src/com/Zrips/CMI/Modules/ChatFormat/ChatFormatListener.java index 455ccfc..e47dba7 100644 --- a/src/com/Zrips/CMI/Modules/ChatFormat/ChatFormatListener.java +++ b/src/com/Zrips/CMI/Modules/ChatFormat/ChatFormatListener.java @@ -1,6 +1,12 @@ package com.Zrips.CMI.Modules.ChatFormat; +import java.util.HashMap; +import java.util.UUID; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; import com.Zrips.CMI.CMI; @@ -8,8 +14,29 @@ public class ChatFormatListener implements Listener { private CMI plugin; public ChatFormatListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + public static HashMap shouts = new HashMap(); + + @EventHandler(priority = EventPriority.NORMAL) + public void AsyncPlayerChatEvent(final AsyncPlayerChatEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void AsyncPlayerChatEventMute(AsyncPlayerChatEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void AsyncPlayerChatEventShadowMute(AsyncPlayerChatEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void AsyncPlayerChatEventPersonalMute(AsyncPlayerChatEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/ChatFormat/ChatFormatManager.java b/src/com/Zrips/CMI/Modules/ChatFormat/ChatFormatManager.java index e8499b3..9824642 100644 --- a/src/com/Zrips/CMI/Modules/ChatFormat/ChatFormatManager.java +++ b/src/com/Zrips/CMI/Modules/ChatFormat/ChatFormatManager.java @@ -5,9 +5,11 @@ import java.util.Iterator; import java.util.Map.Entry; import java.util.Set; +import java.util.TreeMap; import java.util.UUID; import java.util.regex.Matcher; +import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -40,29 +42,28 @@ public void clearCache(UUID uuid) { } public ChatFormatManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public enum chatReplySuggestion { - pubmsg, privmsg, staffmsg, helpop, chatroom, discord; + pubmsg, privmsg, staffmsg, helpop, chatroom, discord; - private String sug = "/msg [playerNickName] "; + private String sug = "/msg [playerNickName] "; - public String getSuggestion(CMIUser user) { - if (user == null) - return sug; - return getSuggestion(user.getName(false), user.getDisplayName(false), user.getNickName()); - } + public String getSuggestion(CMIUser user) { + if (user == null) + return sug; + return getSuggestion(user.getName(false), user.getDisplayName(false), user.getNickName()); + } - public String getSuggestion(String playerName, String playerDisplayName, String playerNickName) { - + public String getSuggestion(String playerName, String playerDisplayName, String playerNickName) { - return ""; - } + return ""; + } - public void setSuggestion(String sug) { - this.sug = sug; - } + public void setSuggestion(String sug) { + this.sug = sug; + } } private String ChatGeneralFormat = ""; @@ -72,190 +73,206 @@ public void setSuggestion(String sug) { private Integer ChatShoutCost = 0; public static int ChatRoomLife = 3600; public static String ChatRoomShout = "!"; + + public static TreeMap chatDynamicRange = new TreeMap(); + ChatFilterRule rule = new ChatFilterRule(); ChatFilterRule itemRule = new ChatFilterRule(); private boolean ChatTranslateLink = true; private boolean hoverItems = false; public void loadConfig(ConfigReader cfg) { - - + } private String getChatGeneralFormat() { - return ChatGeneralFormat; + return ChatGeneralFormat; } public String getGroupFormat(Player player) { - String group = getChatGeneralFormat(); - - return group; + return ""; } public String getGroupMessageFormat(Player player) { - String group = ChatMessageGeneralFormat; - - return group; + + return ""; } public Long getChatMutedUntil() { - return chatMutedUntil; + return chatMutedUntil; } public void setChatMutedUntil(Long chatMutedUntil) { - this.chatMutedUntil = chatMutedUntil; + this.chatMutedUntil = chatMutedUntil; } public void broadcastBungeeMessage(String sender, String message) { } - public void sendMessage(String sender, String Target, String message) { - + public void sendMessage(String sender, String targetName, String message) { + } public void sendMessage(CommandSender sender, Player Target, String message) { - sendMessage(sender, sender != null ? sender.getName() : null, Target, Target != null ? Target.getName() : null, message, true); + sendMessage(sender, sender != null ? sender.getName() : null, Target, Target != null ? Target.getName() : null, message, true); } public void sendMessage(CommandSender sender, Player Target, String message, boolean showToReceiver) { - sendMessage(sender, sender != null ? sender.getName() : null, Target, Target != null ? Target.getName() : null, message, showToReceiver); + sendMessage(sender, sender != null ? sender.getName() : null, Target, Target != null ? Target.getName() : null, message, showToReceiver); } public void sendMessage(CommandSender sender, String senderName, Player Target, String targetname, String message) { - sendMessage(sender, senderName, Target, targetname, message, true); + sendMessage(sender, senderName, Target, targetname, message, true); } public void sendMessage(CommandSender sender, String senderName, Player Target, String targetname, String message, boolean showToReceiver) { - + } public String updateUrl(String message) { - return message; + + return ""; } public boolean containsUrl(String message) { - Matcher matcher = rule.getMatcher(message); - boolean url = false; - if (matcher != null) - url = matcher.find(); + Matcher matcher = rule.getMatcher(message); + boolean url = false; + if (matcher != null) + url = matcher.find(); - Matcher matcherI = itemRule.getMatcher(message); - boolean item = false; - if (matcherI != null) - item = matcherI.find(); + Matcher matcherI = itemRule.getMatcher(message); + boolean item = false; + if (matcherI != null) + item = matcherI.find(); - return url || item; + return url || item; } public RawMessage convertHoverOver(RawMessage rm, String message, Player player) { - return convertHoverOver(rm, message, player, false); + return convertHoverOver(rm, message, player, false); } public RawMessage convertHoverOver(RawMessage rm, String message, Player player, boolean itemReplaced) { - return null; + return null; } public StringBuilder convertHoverItem(StringBuilder str, String message, Player player, boolean itemReplaced) { - return null; + return null; } public boolean isBungeeMessages() { - return BungeeMessages; - } - - public int getChatGeneralRange() { - return ChatGeneralRange; + return BungeeMessages; } public void setChatGeneralRange(int chatGeneralRange) { - ChatGeneralRange = chatGeneralRange; + ChatGeneralRange = chatGeneralRange; } public int getChatShoutRange() { - return ChatShoutRange; + return ChatShoutRange; } public void setChatShoutRange(int chatShoutRange) { - ChatShoutRange = chatShoutRange; + ChatShoutRange = chatShoutRange; } public Integer getChatShoutCost() { - return ChatShoutCost; + return ChatShoutCost; } public void setChatShoutCost(int chatShoutCost) { - ChatShoutCost = chatShoutCost; + ChatShoutCost = chatShoutCost; } public Set getStaffChats() { - return staffChats; + return staffChats; } public boolean isBungeePublicMessages() { - return BungeePublicMessages; + return BungeePublicMessages; } public boolean isBungeeStaffMessages() { - return BungeeStaffMessages; + return BungeeStaffMessages; } public HashMap getChatRooms() { - Iterator> iter = chatRooms.entrySet().iterator(); - - return chatRooms; + Iterator> iter = chatRooms.entrySet().iterator(); + while (iter.hasNext()) { + Entry roome = iter.next(); + CMIChatRoom room = roome.getValue(); + if (room.isPersistent()) + continue; + if (!room.getUsers().isEmpty()) + continue; + if (room.getKeepAliveUntil() == 0L || room.getKeepAliveUntil() > System.currentTimeMillis()) + continue; + iter.remove(); + } + + return chatRooms; } public CMIChatRoom getChatRoom(String name) { - if (name == null) - return null; - return getChatRooms().get(name.toLowerCase()); + if (name == null) + return null; + return getChatRooms().get(name.toLowerCase()); } public boolean joinChatRoom(CMIUser user, String name) { - CMIChatRoom old = this.getChatRooms().get(name.toLowerCase()); - if (old == null) { - return false; - } - old.addUser(user); - return true; + CMIChatRoom old = this.getChatRooms().get(name.toLowerCase()); + if (old == null) { + return false; + } + old.addUser(user); + old.removeWatcher(user); + return true; } @Deprecated public boolean createChatRoom(CMIUser user, String name, boolean priv) { - return createChatRoom(user, name, priv, false, false); + return createChatRoom(user, name, priv, false, false); } public boolean createChatRoom(CMIUser user, String name, boolean priv, boolean locked, boolean persistent) { - return true; + return true; } public void load() { - } public void save() { - + } @Deprecated public void leaveChatRoom(CMIUser user) { - user.leaveChatRoom(); + user.leaveChatRoom(); } public String getChatMutedReason() { - return chatMutedReason; + return chatMutedReason; } public void setChatMutedReason(String chatMutedReason) { - if (chatMutedReason == null || chatMutedReason.isEmpty()) - chatMutedReason = null; - else - this.chatMutedReason = chatMutedReason; + if (chatMutedReason == null || chatMutedReason.isEmpty()) + chatMutedReason = null; + else + this.chatMutedReason = chatMutedReason; + } + + public int getChatGeneralRange() { + return getChatGeneralRange(null); + } + + public int getChatGeneralRange(World world) { + + return 0; } } diff --git a/src/com/Zrips/CMI/Modules/ChatTag/TagListener.java b/src/com/Zrips/CMI/Modules/ChatTag/TagListener.java index 33ef1ad..e7f56c8 100644 --- a/src/com/Zrips/CMI/Modules/ChatTag/TagListener.java +++ b/src/com/Zrips/CMI/Modules/ChatTag/TagListener.java @@ -1,6 +1,10 @@ package com.Zrips.CMI.Modules.ChatTag; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerChatTabCompleteEvent; import com.Zrips.CMI.CMI; @@ -8,8 +12,17 @@ public class TagListener implements Listener { private CMI plugin; public TagListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerChatTabCompleteEvent(PlayerChatTabCompleteEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH) + public void AsyncPlayerChatEvent(AsyncPlayerChatEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/ChatTag/TagManager.java b/src/com/Zrips/CMI/Modules/ChatTag/TagManager.java index 9b73ef6..aab20d8 100644 --- a/src/com/Zrips/CMI/Modules/ChatTag/TagManager.java +++ b/src/com/Zrips/CMI/Modules/ChatTag/TagManager.java @@ -14,7 +14,7 @@ public class TagManager { private CMI plugin; public TagManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } private boolean ChatTagEnabled; @@ -28,28 +28,32 @@ public void load() { } + @Deprecated public String tag(Player player, String msg, String format) { + return tag(player, msg, format, true); + } - return ""; + public String tag(Player player, String msg, String format, boolean performCmds) { + return ""; } public String getChatTagColor() { - return CMIChatColor.translate(ChatTagColor); + return CMIChatColor.translate(ChatTagColor); } public boolean isChatTagRemoveEta() { - return ChatTagRemoveEta; + return ChatTagRemoveEta; } public boolean isChatTagEnabled() { - return ChatTagEnabled; + return ChatTagEnabled; } public boolean isHardCoreMode() { - return HardCoreMode; + return HardCoreMode; } public void setHardCoreMode(boolean hardCoreMode) { - HardCoreMode = hardCoreMode; + HardCoreMode = hardCoreMode; } } diff --git a/src/com/Zrips/CMI/Modules/ChunkPreview/ChunkPreview.java b/src/com/Zrips/CMI/Modules/ChunkPreview/ChunkPreview.java index e0b1857..3a5b8fb 100644 --- a/src/com/Zrips/CMI/Modules/ChunkPreview/ChunkPreview.java +++ b/src/com/Zrips/CMI/Modules/ChunkPreview/ChunkPreview.java @@ -12,18 +12,17 @@ public class ChunkPreview { private CMI plugin; public ChunkPreview(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } - - + public void clearCache(UUID uuid) { - Info.remove(uuid); + Info.remove(uuid); } public void loadRegionFile(ChunkPreviewInfo scan) { - if (scan.getStartTime() == 0L) - scan.setShowInfo(System.currentTimeMillis()); - loadChunk(scan); + if (scan.getStartTime() == 0L) + scan.setShowInfo(System.currentTimeMillis()); + loadChunk(scan); } private void loadChunk(final ChunkPreviewInfo scan) { diff --git a/src/com/Zrips/CMI/Modules/CmdCooldown/CooldownListener.java b/src/com/Zrips/CMI/Modules/CmdCooldown/CooldownListener.java index 206d91b..a32a8fb 100644 --- a/src/com/Zrips/CMI/Modules/CmdCooldown/CooldownListener.java +++ b/src/com/Zrips/CMI/Modules/CmdCooldown/CooldownListener.java @@ -1,6 +1,9 @@ package com.Zrips.CMI.Modules.CmdCooldown; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import com.Zrips.CMI.CMI; @@ -9,6 +12,16 @@ public class CooldownListener implements Listener { private CMI plugin; public CooldownListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + + @EventHandler(priority = EventPriority.NORMAL) + public void onCommandLowest(PlayerCommandPreprocessEvent event) { + } + + // Needs to be above NORMAL due to alias listener modifying command + @EventHandler(priority = EventPriority.HIGH) + public void onCommand(PlayerCommandPreprocessEvent event) { + } + } diff --git a/src/com/Zrips/CMI/Modules/CmdCooldown/CooldownManager.java b/src/com/Zrips/CMI/Modules/CmdCooldown/CooldownManager.java index 0d50e0a..ff74a5c 100644 --- a/src/com/Zrips/CMI/Modules/CmdCooldown/CooldownManager.java +++ b/src/com/Zrips/CMI/Modules/CmdCooldown/CooldownManager.java @@ -15,52 +15,60 @@ public class CooldownManager { CMI plugin; public CooldownManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public int getCooldownCount() { - return cooldowns.size(); + return cooldowns.size(); } @Deprecated public void addCD(String cmd, Long seconds) { - addCooldown(new CMICmdCooldown(cmd, seconds.intValue())); + addCooldown(new CMICmdCooldown(cmd, seconds.intValue())); } public void addCooldown(String cmd, int seconds) { - addCooldown(new CMICmdCooldown(cmd, seconds)); + addCooldown(new CMICmdCooldown(cmd, seconds)); } public void addCooldown(CMICmdCooldown cooldown) { - cooldowns.put(cooldown.getCommand().toLowerCase(), cooldown); + cooldowns.put(cooldown.getCommand().toLowerCase(), cooldown); } private CMICmdCooldown getCooldown(String cmd) { - - return null; + return null; } private static Long getUsedTime(String cmd, CmdCooldown userCooldowns) { - return null; + return getUsedTime(cmd, userCooldowns, false); + } + + private static Long getUsedTime(String cmd, CmdCooldown userCooldowns, boolean exact) { + + return null; } private static String getCommandMatch(String cmd, CmdCooldown userCooldowns) { - return null; + return getCommandMatch(cmd, userCooldowns, false); + } + + private static String getCommandMatch(String cmd, CmdCooldown userCooldowns, boolean exact) { + return null; } public boolean removeCooldown(CommandSender sender, String cmd) { - - return true; + + return true; } public boolean isCmdInCooldown(CommandSender sender, String cmd) { - - return false; + + return false; } public boolean canUseCmd(CommandSender sender, String cmd) { - return true; + return true; } HashMap playerCustomCooldowns = new HashMap(); @@ -69,16 +77,16 @@ public boolean canUseCmd(CommandSender sender, String cmd) { public boolean canUseSpecCommandGlobal(CommandSender sender, SpecCMDCooldown cooldown, boolean inform) { - return true; + return true; } public boolean canUseSpecCommand(Player player, SpecCMDCooldown cooldown, boolean inform) { - - return true; + + return true; } public HashMap getCooldowns() { - return cooldowns; + return cooldowns; } } diff --git a/src/com/Zrips/CMI/Modules/CmdCost/CMICommandCost.java b/src/com/Zrips/CMI/Modules/CmdCost/CMICommandCost.java index 0fb7924..2867a93 100644 --- a/src/com/Zrips/CMI/Modules/CmdCost/CMICommandCost.java +++ b/src/com/Zrips/CMI/Modules/CmdCost/CMICommandCost.java @@ -3,7 +3,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import com.Zrips.CMI.CMI; +import com.Zrips.CMI.commands.CommandsHandler; public class CMICommandCost { @@ -32,7 +32,7 @@ public double getCost() { } public String getSubCommand() { - return command.startsWith(CMI.getInstance().getCommandManager().getLabel() + " ") ? command.substring(CMI.getInstance().getCommandManager().getLabel().length() + 1) : command; + return command.startsWith(CommandsHandler.getLabel() + " ") ? command.substring(CommandsHandler.getLabel().length() + 1) : command; } public void setCost(double cost) { diff --git a/src/com/Zrips/CMI/Modules/CmdCost/CMICommandCostManager.java b/src/com/Zrips/CMI/Modules/CmdCost/CMICommandCostManager.java index 77cfa89..160b642 100644 --- a/src/com/Zrips/CMI/Modules/CmdCost/CMICommandCostManager.java +++ b/src/com/Zrips/CMI/Modules/CmdCost/CMICommandCostManager.java @@ -1,10 +1,22 @@ package com.Zrips.CMI.Modules.CmdCost; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; +import java.util.Map.Entry; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Containers.CMIUser; +import com.Zrips.CMI.Locale.CMILC; +import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; +import com.Zrips.CMI.commands.CommandsHandler; + +import net.Zrips.CMILib.FileHandler.ConfigReader; +import net.Zrips.CMILib.Locale.LC; +import net.Zrips.CMILib.RawMessages.RawMessage; public class CMICommandCostManager { private HashMap costs = new HashMap(); @@ -12,41 +24,38 @@ public class CMICommandCostManager { CMI plugin; public CMICommandCostManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public int getCommandCostCount() { - return costs.size(); + return costs.size(); } public void addCost(String cmd, double cost) { - costs.put(cmd.toLowerCase(), new CMICommandCost(cmd, cost)); + costs.put(cmd.toLowerCase(), new CMICommandCost(cmd, cost)); } public CMICommandCost getCost(String cmd) { - return null; + return null; } public CMICommandCostUsage canUseCmd(CommandSender sender, String cmd) { - return CMICommandCostUsage.Can; - + return CMICommandCostUsage.Can; } public boolean isContinueCommand(CommandSender sender, String cmd) { - return true; + return true; } public boolean loadConfig(boolean isReload) { - - return true; + + return true; } private static CMICommandCost get(String line) { - String[] split = line.split(":"); - CMICommandCost cost = null; - - return cost; + + return null; } } diff --git a/src/com/Zrips/CMI/Modules/CmdWarmUp/CmdWarmUp.java b/src/com/Zrips/CMI/Modules/CmdWarmUp/CmdWarmUp.java index 41b19ca..52f268f 100644 --- a/src/com/Zrips/CMI/Modules/CmdWarmUp/CmdWarmUp.java +++ b/src/com/Zrips/CMI/Modules/CmdWarmUp/CmdWarmUp.java @@ -1,54 +1,65 @@ package com.Zrips.CMI.Modules.CmdWarmUp; import com.Zrips.CMI.Modules.Particl.ParticleManager.CMIPresetAnimations; +import com.Zrips.CMI.commands.CommandsHandler; public class CmdWarmUp { - private Long WU = 0L; + private Long warmUpTime = 0L; private boolean move = true; private String command; private CMIPresetAnimations animation; - public CmdWarmUp(String command, Long WU, boolean move) { - this.command = command; - this.WU = WU; - this.move = move; + public CmdWarmUp(String command, Long warmUpTime, boolean move) { + this.command = command; + this.warmUpTime = warmUpTime; + this.move = move; } + @Deprecated public Long getWU() { - return WU; + return getTime(); } - public void setWU(Long WU) { - this.WU = WU; + @Deprecated + public void setWU(Long warmUpTime) { + setTime(warmUpTime); + } + + public Long getTime() { + return warmUpTime; + } + + public void setTime(Long warmUpTime) { + this.warmUpTime = warmUpTime; } public boolean isMove() { - return move; + return move; } public void setMove(boolean move) { - this.move = move; + this.move = move; } public String getCommand() { - return command; + return command; } public String getSubCommand() { - return command.startsWith("cmi ") ? command.substring(4) : command; + return command.startsWith(CommandsHandler.getLabel() + " ") ? command.substring(4) : command; } public void setCommand(String command) { - this.command = command; + this.command = command; } public CMIPresetAnimations getAnimation() { - return animation; + return animation; } public void setAnimation(CMIPresetAnimations animation) { - this.animation = animation; + this.animation = animation; } } diff --git a/src/com/Zrips/CMI/Modules/CmdWarmUp/WarmUpListener.java b/src/com/Zrips/CMI/Modules/CmdWarmUp/WarmUpListener.java index d3f6efb..5f5e16d 100644 --- a/src/com/Zrips/CMI/Modules/CmdWarmUp/WarmUpListener.java +++ b/src/com/Zrips/CMI/Modules/CmdWarmUp/WarmUpListener.java @@ -1,6 +1,12 @@ package com.Zrips.CMI.Modules.CmdWarmUp; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; import com.Zrips.CMI.CMI; @@ -9,7 +15,23 @@ public class WarmUpListener implements Listener { private CMI plugin; public WarmUpListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onCommand(PlayerCommandPreprocessEvent event) { + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerMove(PlayerMoveEvent event) { + } + + @EventHandler(priority = EventPriority.LOWEST) + public void PlayerQuitEvent(final PlayerQuitEvent event) { + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerDamage(EntityDamageEvent event) { } } diff --git a/src/com/Zrips/CMI/Modules/CmdWarmUp/WarmUpManager.java b/src/com/Zrips/CMI/Modules/CmdWarmUp/WarmUpManager.java index 3cb90a3..10258ce 100644 --- a/src/com/Zrips/CMI/Modules/CmdWarmUp/WarmUpManager.java +++ b/src/com/Zrips/CMI/Modules/CmdWarmUp/WarmUpManager.java @@ -17,75 +17,73 @@ public class WarmUpManager { CMI plugin; public WarmUpManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public boolean isOnWarmUp(Player player) { - return isOnWarmUp(player.getUniqueId()); + return isOnWarmUp(player.getUniqueId()); } public boolean isOnWarmUp(UUID uuid) { - return counter.containsKey(uuid); + return counter.containsKey(uuid); } public void addWU(String cmd, CmdWarmUp warmup) { - warmups.put(cmd.toLowerCase(), warmup); + warmups.put(cmd.toLowerCase(), warmup); } private CmdWarmUp getTime(String cmd) { - - return null; + + return null; } public boolean canMove(Player player) { - return canMove(player.getUniqueId()); + return canMove(player.getUniqueId()); } public boolean canMove(UUID uuid) { - - return true; + + return true; } public boolean canMoveByCmd(String cmd) { - - return true; + + return true; } @Deprecated public boolean startTeleportUsage(Player player, Location loc) { - return startTeleportUsage(TpAction.tp, player, loc); + return startTeleportUsage(TpAction.tp, player, loc); } private final static String bossBarName = "CMICmdWarmupBar"; public boolean startTeleportUsage(TpAction action, Player player, Location loc) { - - return true; + return true; } - public boolean startCmdUsage(CommandSender sender, String cmd) { - + public boolean isWarmupCommand(CommandSender sender, String cmd) { - return true; + return true; } - private void performCmd(UUID uuid) { - + public boolean startCmdUsage(CommandSender sender, String cmd) { + return true; } private void performCmd(Player player, WarmUpInfo info) { - + } private void count(UUID uuid) { - + } public boolean cancel(UUID uuid) { - - return false; + + return false; } boolean InformOnNoMove; diff --git a/src/com/Zrips/CMI/Modules/CustomText/CText.java b/src/com/Zrips/CMI/Modules/CustomText/CText.java index 78c9f95..0f9ab8e 100644 --- a/src/com/Zrips/CMI/Modules/CustomText/CText.java +++ b/src/com/Zrips/CMI/Modules/CustomText/CText.java @@ -1,69 +1,59 @@ package com.Zrips.CMI.Modules.CustomText; -import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; -import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BookMeta; - -import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.CommandAlias; -import com.Zrips.CMI.Containers.Snd; - -import net.Zrips.CMILib.Colors.CMIChatColor; -import net.Zrips.CMILib.RawMessages.RawMessage; public class CText { private HashMap> pages = new HashMap>(); private String name; private boolean autoPage = true; + private boolean hidden = false; private boolean autoAlias = true; private boolean requirePermission = false; public CText(String name) { - this.name = name; + this.name = name; } public String getName() { - return name; + return name; } public int getTotalPages() { - return pages.size(); + return pages.size(); } public int getTotalLines() { - int i = 0; - for (Entry> one : pages.entrySet()) { - i += one.getValue().size(); - } - return i; + int i = 0; + for (Entry> one : pages.entrySet()) { + i += one.getValue().size(); + } + return i; } public void setName(String name) { - this.name = name; + this.name = name; } public HashMap> getPages() { - return pages; + return pages; } public List getPage(Integer page) { - return this.pages.get(page); + return this.pages.get(page); } public void setPages(HashMap> pages) { - this.pages = pages; + this.pages = pages; } public void addPage(Integer page, List lines) { - this.pages.put(page, lines); + this.pages.put(page, lines); } public void removePage(int page) { @@ -82,15 +72,15 @@ public void addLine(Integer page, String line) { } public boolean isAutoPage() { - return autoPage; + return autoPage; } public void setAutoPage(boolean autoPage) { - this.autoPage = autoPage; + this.autoPage = autoPage; } public boolean isAutoAlias() { - return autoAlias; + return autoAlias; } public void setAutoAlias(boolean autoAlias, boolean save) { @@ -98,15 +88,23 @@ public void setAutoAlias(boolean autoAlias, boolean save) { } public boolean isRequirePermission() { - return requirePermission; + return requirePermission; } public void setRequirePermission(boolean requirePermission) { - this.requirePermission = requirePermission; + this.requirePermission = requirePermission; } public ItemStack convertToBook(Player player) { - return null; + return null; + } + + public boolean isHidden() { + return hidden; + } + + public void setHidden(boolean hidden) { + this.hidden = hidden; } } diff --git a/src/com/Zrips/CMI/Modules/CustomText/CTextEditorListener.java b/src/com/Zrips/CMI/Modules/CustomText/CTextEditorListener.java index f15e129..7f4c6a0 100644 --- a/src/com/Zrips/CMI/Modules/CustomText/CTextEditorListener.java +++ b/src/com/Zrips/CMI/Modules/CustomText/CTextEditorListener.java @@ -1,6 +1,10 @@ package com.Zrips.CMI.Modules.CustomText; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import com.Zrips.CMI.CMI; @@ -8,7 +12,17 @@ public class CTextEditorListener implements Listener { private CMI plugin; public CTextEditorListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.LOWEST) + public void AsyncPlayerChatEvent(final AsyncPlayerChatEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onShadowCommand(PlayerCommandPreprocessEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/CustomText/CTextManager.java b/src/com/Zrips/CMI/Modules/CustomText/CTextManager.java index 200418d..063eb7a 100644 --- a/src/com/Zrips/CMI/Modules/CustomText/CTextManager.java +++ b/src/com/Zrips/CMI/Modules/CustomText/CTextManager.java @@ -1,20 +1,43 @@ package com.Zrips.CMI.Modules.CustomText; +import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map.Entry; import java.util.Set; import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Config; import com.Zrips.CMI.Containers.CMIUser; - +import com.Zrips.CMI.Containers.Snd; + +import net.Zrips.CMILib.Chat.ChatMessageListEdit; +import net.Zrips.CMILib.Chat.ChatMessageListEdit.ChatEditType; +import net.Zrips.CMILib.Colors.CMIChatColor; +import net.Zrips.CMILib.Container.PageInfo; +import net.Zrips.CMILib.Images.CMIImage; +import net.Zrips.CMILib.Locale.LC; +import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.RawMessages.RawMessage; +import net.Zrips.CMILib.Shadow.ShadowCommand; +import net.Zrips.CMILib.Shadow.ShadowCommandType; public class CTextManager { @@ -24,90 +47,88 @@ public class CTextManager { private CMI plugin; public CTextManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public HashMap getAll() { - return map; + return map; } public void deleteCText(String name) { - map.remove(name.toLowerCase()); + map.remove(name.toLowerCase()); } public CText getCText(String name) { - if (name == null) - return null; - return map.get(name.toLowerCase()); + if (name == null) + return null; + return map.get(name.toLowerCase()); } public boolean isChatEditing(Player player) { - return chatMap.containsKey(player.getUniqueId()); + return chatMap.containsKey(player.getUniqueId()); } public void addChatEditor(Player player, String cmd) { - if (player == null) - return; - if (!cmd.endsWith(" ")) - cmd += " "; - chatMap.put(player.getUniqueId(), cmd); + if (player == null) + return; + if (!cmd.endsWith(" ")) + cmd += " "; + chatMap.put(player.getUniqueId(), cmd); } public void removeChatEditor(Player player) { - chatMap.remove(player.getUniqueId()); + chatMap.remove(player.getUniqueId()); } public String getChatEditorCmd(Player player) { - return chatMap.get(player.getUniqueId()); + return chatMap.get(player.getUniqueId()); } public CText addNewCText(String name) { - CText cText = new CText(name); - map.put(name.toLowerCase(), cText); - return cText; + CText cText = new CText(name); + map.put(name.toLowerCase(), cText); + return cText; } public void load() { - + } public CText getCTextFromFile(File file) { - - return null; + return null; } public void save(CText cText) { - } public void delete(CText cText) { - + } public void removeCTextLine(CText cText, Integer page, Integer line) { - + } public List move(List list, int place, int direction) { - - return null; + + return list; } public void showCTextEditor(CommandSender sender, CText cText, Integer page) { - + } public void showCText(CommandSender sender, CText cText, Integer page) { - showCText(sender, null, cText, page); + showCText(sender, null, cText, page); } public void showCText(CommandSender sender, CMIUser source, CText cText, Integer page) { - if (!(sender instanceof Player)) - return; - Set senders = new HashSet(); - senders.add((Player) sender); - showCText(senders, source, cText, page); + if (!(sender instanceof Player)) + return; + Set senders = new HashSet(); + senders.add((Player) sender); + showCText(senders, source, cText, page); } public void showCText(Set senders, CMIUser source, CText cText, Integer page) { @@ -115,16 +136,16 @@ public void showCText(Set senders, CMIUser source, CText cText, Integer } public RawMessage translateRaw(String textLine) { - return translateRaw(null, null, textLine); + return translateRaw(null, null, textLine); } public RawMessage translateRaw(CommandSender sender, RawMessage rm, String textLine) { - return translateRaw(sender, rm, textLine, false); + return translateRaw(sender, rm, textLine, false); } public RawMessage translateRaw(CommandSender sender, RawMessage rm, String textLine, boolean book) { - - return null; + + return null; } } diff --git a/src/com/Zrips/CMI/Modules/DataBase/DBConnectionPool.java b/src/com/Zrips/CMI/Modules/DataBase/DBConnectionPool.java index 3ae4cdd..0e824e2 100644 --- a/src/com/Zrips/CMI/Modules/DataBase/DBConnectionPool.java +++ b/src/com/Zrips/CMI/Modules/DataBase/DBConnectionPool.java @@ -21,11 +21,15 @@ public DBConnectionPool(String driverName, String url, String username, String p } public synchronized DBConnection getConnection() throws SQLException { - return connection; } public synchronized void closeConnection() { - + if (connection != null) { + try { + connection.closeConnection(); + } catch (SQLException e) { + } + } } } diff --git a/src/com/Zrips/CMI/Modules/DataBase/DBDAO.java b/src/com/Zrips/CMI/Modules/DataBase/DBDAO.java index 0e0ba9a..9180bad 100644 --- a/src/com/Zrips/CMI/Modules/DataBase/DBDAO.java +++ b/src/com/Zrips/CMI/Modules/DataBase/DBDAO.java @@ -31,304 +31,322 @@ public abstract class DBDAO { private static DataBaseType dbType = DataBaseType.SqLite; public enum TablesFieldsType { - decimal("double"), - number("int"), - longtext("longtext"), - text("text"), - stringList("text"), - stringLongMap("text"), - stringIntMap("text"), - stringDoubleMap("text"), - stringStringMap("text"), - locationMap("text"), - state("boolean"), - location("text"), - longNumber("bigint"); - - private String type; - - TablesFieldsType(String type) { - this.type = type; - } - - public static TablesFieldsType getByname(String name) { - for (TablesFieldsType one : TablesFieldsType.values()) { - if (one.name().equalsIgnoreCase(name)) - return one; - } - return null; - } - - public String getType() { - return type; - } + decimal("double"), + number("int"), + longtext("longtext"), + text("text"), + stringList("text"), + stringLongMap("text"), + stringIntMap("text"), + stringDoubleMap("text"), + stringStringMap("text"), + locationMap("text"), + state("boolean"), + location("text"), + longNumber("bigint"); + + private String type; + + TablesFieldsType(String type) { + this.type = type; + } + + public static TablesFieldsType getByname(String name) { + for (TablesFieldsType one : TablesFieldsType.values()) { + if (one.name().equalsIgnoreCase(name)) + return one; + } + return null; + } + + public String getType() { + return type; + } } public enum UserTablesFields { - player_uuid("text", TablesFieldsType.text), - username("text", TablesFieldsType.text), - nickname("text", TablesFieldsType.text), - LogOutLocation("text", TablesFieldsType.location), - DeathLocation("text", TablesFieldsType.location), - TeleportLocation("text", TablesFieldsType.location), - teleportToggled("boolean", TablesFieldsType.state), - Homes("text", TablesFieldsType.locationMap), - LastLoginTime("bigint", TablesFieldsType.longNumber), - LastLogoffTime("bigint", TablesFieldsType.longNumber), - TotalPlayTime("bigint", TablesFieldsType.longNumber), - tFly("bigint", TablesFieldsType.longNumber), - tGod("bigint", TablesFieldsType.longNumber), - Glow("text", TablesFieldsType.text), - Ips("text", TablesFieldsType.stringIntMap), - Cuffed("boolean", TablesFieldsType.state), - AlertUntil("bigint", TablesFieldsType.longNumber), - AlertReason("text", TablesFieldsType.text), - JoinedCounter("boolean", TablesFieldsType.state), - LockedIps("text", TablesFieldsType.stringList), - pTime("bigint", TablesFieldsType.longNumber), - Kits("text", TablesFieldsType.stringLongMap), - Charges("text", TablesFieldsType.text), - Cooldowns("longtext", TablesFieldsType.text), - Balance("double", TablesFieldsType.decimal), - Notes("text", TablesFieldsType.stringList), - Rank("text", TablesFieldsType.text), - TagSound("boolean", TablesFieldsType.state), - SignShiftEdit("boolean", TablesFieldsType.state), - Spy("boolean", TablesFieldsType.state), - CommandSpy("boolean", TablesFieldsType.state), - BannedUntil("bigint", TablesFieldsType.longNumber), - BannedAt("bigint", TablesFieldsType.longNumber), - BannedBy("text", TablesFieldsType.text), - BanReason("text", TablesFieldsType.text), - Ignores("text", TablesFieldsType.text), - Vanish("text", TablesFieldsType.text), - Economy("text", TablesFieldsType.stringDoubleMap), - Mail("text", TablesFieldsType.stringList), - FlightCharge("double", TablesFieldsType.decimal), - UserMeta("text", TablesFieldsType.stringStringMap), - Flying("boolean", TablesFieldsType.state), - Votifier("int", TablesFieldsType.number), - Jail("text", TablesFieldsType.text), - JailedUntil("bigint", TablesFieldsType.longNumber), - FakeAccount("boolean", TablesFieldsType.state), - PlaytimeOptimized("bigint", TablesFieldsType.longNumber), - flightChargeEnabled("boolean", TablesFieldsType.state), - noPayToggled("boolean", TablesFieldsType.state), - JailReason("text", TablesFieldsType.text), - Skin("text", TablesFieldsType.text), - SignSpy("boolean", TablesFieldsType.state), - Collision("boolean", TablesFieldsType.state), - NamePrefix("text", TablesFieldsType.text), - NameSuffix("text", TablesFieldsType.text), - Warnings("text", TablesFieldsType.stringLongMap), - msgToggle("boolean", TablesFieldsType.state), - NameColor("text", TablesFieldsType.text), - Muted("text", TablesFieldsType.text), - ToggleBBCompassOff("boolean", TablesFieldsType.state), - AFRecharge("text", TablesFieldsType.text), - DisplayName("text", TablesFieldsType.text); - - // Always add new collumns to the end - - private String type; - private TablesFieldsType fieldType; - - UserTablesFields(String type, TablesFieldsType fieldType) { - this.type = type; - this.fieldType = fieldType; - } - - public String getCollumn() { - return this.name(); - } - - public String getType() { - return type; - } - - public TablesFieldsType getFieldType() { - return fieldType; - } + player_uuid("text", TablesFieldsType.text), + username("text", TablesFieldsType.text), + nickname("text", TablesFieldsType.text), + LogOutLocation("text", TablesFieldsType.location), + DeathLocation("text", TablesFieldsType.location), + TeleportLocation("text", TablesFieldsType.location), + Homes("text", TablesFieldsType.locationMap), + LastLoginTime("bigint", TablesFieldsType.longNumber), + LastLogoffTime("bigint", TablesFieldsType.longNumber), + TotalPlayTime("bigint", TablesFieldsType.longNumber), + tFly("bigint", TablesFieldsType.longNumber), + tGod("bigint", TablesFieldsType.longNumber), + Glow("text", TablesFieldsType.text), + Ips("text", TablesFieldsType.stringIntMap), + Cuffed("boolean", TablesFieldsType.state), + AlertUntil("bigint", TablesFieldsType.longNumber), + AlertReason("text", TablesFieldsType.text), + JoinedCounter("boolean", TablesFieldsType.state), + LockedIps("text", TablesFieldsType.stringList), + pTime("bigint", TablesFieldsType.longNumber), + Kits("text", TablesFieldsType.stringLongMap), + Charges("text", TablesFieldsType.text), + Cooldowns("longtext", TablesFieldsType.text), + Balance("double", TablesFieldsType.decimal), + Notes("text", TablesFieldsType.stringList), + Rank("text", TablesFieldsType.text), + BannedUntil("bigint", TablesFieldsType.longNumber), + BannedAt("bigint", TablesFieldsType.longNumber), + BannedBy("text", TablesFieldsType.text), + BanReason("text", TablesFieldsType.text), + Ignores("text", TablesFieldsType.text), + Vanish("text", TablesFieldsType.text), + Economy("text", TablesFieldsType.stringDoubleMap), + Mail("text", TablesFieldsType.stringList), + FlightCharge("double", TablesFieldsType.decimal), + UserMeta("text", TablesFieldsType.stringStringMap), + Flying("boolean", TablesFieldsType.state), + Votifier("int", TablesFieldsType.number), + Jail("text", TablesFieldsType.text), + JailedUntil("bigint", TablesFieldsType.longNumber), + FakeAccount("boolean", TablesFieldsType.state), + PlaytimeOptimized("bigint", TablesFieldsType.longNumber), + flightChargeEnabled("boolean", TablesFieldsType.state), + JailReason("text", TablesFieldsType.text), + Skin("text", TablesFieldsType.text), + Collision("boolean", TablesFieldsType.state), + NamePrefix("text", TablesFieldsType.text), + NameSuffix("text", TablesFieldsType.text), + Warnings("text", TablesFieldsType.stringLongMap), + NameColor("text", TablesFieldsType.text), + Muted("text", TablesFieldsType.text), + AFRecharge("text", TablesFieldsType.text), + DisplayName("text", TablesFieldsType.text), + Options("text", TablesFieldsType.text); + + // Always add new collumns to the end + + private String type; + private TablesFieldsType fieldType; + + UserTablesFields(String type, TablesFieldsType fieldType) { + this.type = type; + this.fieldType = fieldType; + } + + public String getCollumn() { + return this.name(); + } + + public String getType() { + return type; + } + + public TablesFieldsType getFieldType() { + return fieldType; + } } public enum PlaytimeTablesFields { - player_id(TablesFieldsType.number), - date(TablesFieldsType.number), - h0(0, TablesFieldsType.longNumber), - h1(1, TablesFieldsType.longNumber), - h2(2, TablesFieldsType.longNumber), - h3(3, TablesFieldsType.longNumber), - h4(4, TablesFieldsType.longNumber), - h5(5, TablesFieldsType.longNumber), - h6(6, TablesFieldsType.longNumber), - h7(7, TablesFieldsType.longNumber), - h8(8, TablesFieldsType.longNumber), - h9(9, TablesFieldsType.longNumber), - h10(10, TablesFieldsType.longNumber), - h11(11, TablesFieldsType.longNumber), - h12(12, TablesFieldsType.longNumber), - h13(13, TablesFieldsType.longNumber), - h14(14, TablesFieldsType.longNumber), - h15(15, TablesFieldsType.longNumber), - h16(16, TablesFieldsType.longNumber), - h17(17, TablesFieldsType.longNumber), - h18(18, TablesFieldsType.longNumber), - h19(19, TablesFieldsType.longNumber), - h20(20, TablesFieldsType.longNumber), - h21(21, TablesFieldsType.longNumber), - h22(22, TablesFieldsType.longNumber), - h23(23, TablesFieldsType.longNumber); - - private TablesFieldsType fieldType; - private int hour = 0; - - PlaytimeTablesFields(TablesFieldsType fieldType) { - this.fieldType = fieldType; - } - - PlaytimeTablesFields(int hour, TablesFieldsType fieldType) { - this.fieldType = fieldType; - this.hour = hour; - } - - public String getCollumn() { - return this.name(); - } - - public String getType() { - return fieldType.getType(); - } - - public TablesFieldsType getFieldType() { - return fieldType; - } - - public boolean isTimeField() { - return this.name().startsWith("h") && this.name().length() < 4; - } - - public int getHour() { - return hour; - } + player_id(TablesFieldsType.number), + date(TablesFieldsType.number), + h0(0, TablesFieldsType.longNumber), + h1(1, TablesFieldsType.longNumber), + h2(2, TablesFieldsType.longNumber), + h3(3, TablesFieldsType.longNumber), + h4(4, TablesFieldsType.longNumber), + h5(5, TablesFieldsType.longNumber), + h6(6, TablesFieldsType.longNumber), + h7(7, TablesFieldsType.longNumber), + h8(8, TablesFieldsType.longNumber), + h9(9, TablesFieldsType.longNumber), + h10(10, TablesFieldsType.longNumber), + h11(11, TablesFieldsType.longNumber), + h12(12, TablesFieldsType.longNumber), + h13(13, TablesFieldsType.longNumber), + h14(14, TablesFieldsType.longNumber), + h15(15, TablesFieldsType.longNumber), + h16(16, TablesFieldsType.longNumber), + h17(17, TablesFieldsType.longNumber), + h18(18, TablesFieldsType.longNumber), + h19(19, TablesFieldsType.longNumber), + h20(20, TablesFieldsType.longNumber), + h21(21, TablesFieldsType.longNumber), + h22(22, TablesFieldsType.longNumber), + h23(23, TablesFieldsType.longNumber); + + private TablesFieldsType fieldType; + private int hour = 0; + + PlaytimeTablesFields(TablesFieldsType fieldType) { + this.fieldType = fieldType; + } + + PlaytimeTablesFields(int hour, TablesFieldsType fieldType) { + this.fieldType = fieldType; + this.hour = hour; + } + + public String getCollumn() { + return this.name(); + } + + public String getType() { + return fieldType.getType(); + } + + public TablesFieldsType getFieldType() { + return fieldType; + } + + public boolean isTimeField() { + return this.name().startsWith("h") && this.name().length() < 4; + } + + public int getHour() { + return hour; + } } public enum PlaytimeRewardTablesFields { - player_id(TablesFieldsType.number), - repeatable(TablesFieldsType.stringLongMap), - onetime(TablesFieldsType.stringList); + player_id(TablesFieldsType.number), + repeatable(TablesFieldsType.stringLongMap), + onetime(TablesFieldsType.stringList); - private TablesFieldsType fieldType; + private TablesFieldsType fieldType; - PlaytimeRewardTablesFields(TablesFieldsType fieldType) { - this.fieldType = fieldType; - } + PlaytimeRewardTablesFields(TablesFieldsType fieldType) { + this.fieldType = fieldType; + } - public String getCollumn() { - return this.name(); - } + public String getCollumn() { + return this.name(); + } - public String getType() { - return fieldType.getType(); - } + public String getType() { + return fieldType.getType(); + } - public TablesFieldsType getFieldType() { - return fieldType; - } + public TablesFieldsType getFieldType() { + return fieldType; + } } public enum InventoryTablesFields { - player_id("player_id", "int", TablesFieldsType.number), - inventories("inventories", "longtext", TablesFieldsType.longtext); + player_id("player_id", "int", TablesFieldsType.number), + inventories("inventories", "longtext", TablesFieldsType.longtext); - private String collumn; - private String type; - private TablesFieldsType fieldType; + private String collumn; + private String type; + private TablesFieldsType fieldType; - InventoryTablesFields(String collumn, String type, TablesFieldsType fieldType) { - this.collumn = collumn; - this.type = type; - this.fieldType = fieldType; - } + InventoryTablesFields(String collumn, String type, TablesFieldsType fieldType) { + this.collumn = collumn; + this.type = type; + this.fieldType = fieldType; + } - public String getCollumn() { - return collumn; - } + public String getCollumn() { + return collumn; + } - public String getType() { - return type; - } + public String getType() { + return type; + } - public TablesFieldsType getFieldType() { - return fieldType; - } + public TablesFieldsType getFieldType() { + return fieldType; + } } public enum DBTables { - UserTable("users", - "CREATE TABLE `[tableName]` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY[fields]);", - "CREATE TABLE `[tableName]` (`id` INTEGER PRIMARY KEY AUTOINCREMENT[fields]);"), - InvTable("inventories", - "CREATE TABLE `[tableName]` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY[fields]);", - "CREATE TABLE `[tableName]` (`id` INTEGER PRIMARY KEY AUTOINCREMENT[fields]);"), - PlayTime("playtime", - "CREATE TABLE `[tableName]` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY[fields]);", - "CREATE TABLE `[tableName]` (`id` INTEGER PRIMARY KEY AUTOINCREMENT[fields]);"), - PlayTimeReward("playtimereward", - "CREATE TABLE `[tableName]` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY[fields]);", - "CREATE TABLE `[tableName]` (`id` INTEGER PRIMARY KEY AUTOINCREMENT[fields]);"); - - private String mySQL; - private String sQlite; - private String tableName; - - DBTables(String tableName, String MySQL, String SQlite) { - this.tableName = tableName; - this.mySQL = MySQL; - this.sQlite = SQlite; - } - - private String getQR() { - switch (dbType) { - case MySQL: - return this.mySQL.replace("[tableName]", prefix + this.tableName); - case SqLite: - return this.sQlite.replace("[tableName]", this.tableName); - } - return ""; - } - - public String getQuery() { - return getQR().replace("[fields]", ""); - - } - - public String getUpdateQuery() { - - return ""; - } - - public String getInsertQuery() { - - return ""; - } - - public String getTableName() { - return prefix + tableName; - } + UserTable("users", + "CREATE TABLE `[tableName]` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY[fields]);", + "CREATE TABLE `[tableName]` (`id` INTEGER PRIMARY KEY AUTOINCREMENT[fields]);"), + InvTable("inventories", + "CREATE TABLE `[tableName]` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY[fields]);", + "CREATE TABLE `[tableName]` (`id` INTEGER PRIMARY KEY AUTOINCREMENT[fields]);"), + PlayTime("playtime", + "CREATE TABLE `[tableName]` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY[fields]);", + "CREATE TABLE `[tableName]` (`id` INTEGER PRIMARY KEY AUTOINCREMENT[fields]);"), + PlayTimeReward("playtimereward", + "CREATE TABLE `[tableName]` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY[fields]);", + "CREATE TABLE `[tableName]` (`id` INTEGER PRIMARY KEY AUTOINCREMENT[fields]);"); + + private String mySQL; + private String sQlite; + private String tableName; + + DBTables(String tableName, String MySQL, String SQlite) { + this.tableName = tableName; + this.mySQL = MySQL; + this.sQlite = SQlite; + } + + private String getQR() { + switch (dbType) { + case MySQL: + return this.mySQL.replace("[tableName]", prefix + this.tableName); + case SqLite: + return this.sQlite.replace("[tableName]", this.tableName); + } + return ""; + } + + public String getQuery() { + String rp = ""; + return getQR().replace("[fields]", rp); + } + + public String getUpdateQuery() { + + return ""; + } + + public String getInsertQuery() { + String rp = ""; + return rp; + } + + public String getTableName() { + return prefix + tableName; + } } public enum mysqltypes { - old, MySQL, MariaDB; + old, MySQL, MariaDB; } public static mysqltypes Format = mysqltypes.MySQL; protected DBDAO(CMI plugin, String driverName, String url, String username, String password, String pr) { - + this.plugin = plugin; + prefix = pr; + try { + pool = new DBConnectionPool(driverName, url, username, password); + } catch (Exception e) { + e.printStackTrace(); + } + + try { + pool.getConnection(); + + } catch (Throwable e) { + try { + pool = new DBConnectionPool(driverName, url.replace("utf8mb4_unicode_ci", "utf-8"), username, password); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + try { + CMI.getInstance().consoleMessage(pool.getConnection().getMetaData().getDatabaseProductVersion() + " data base type detected"); + if (pool.getConnection().getMetaData().getDatabaseProductVersion().toLowerCase().contains("mariadb")) { + Format = mysqltypes.MariaDB; + } + } catch (Error | Exception e) { + e.printStackTrace(); + } } public final synchronized void setUp() throws SQLException { - + } public abstract Statement prepareStatement(String query) throws SQLException; @@ -352,17 +370,17 @@ public final synchronized void setUp() throws SQLException { public abstract boolean convertTableRowFormat(DBTables table); public String getPrefix() { - return prefix; + return prefix; } // sync public void updateUUID(int id, UUID uuid) { - + } // sync public void updateUserName(int id, String name) { - + } /** @@ -371,11 +389,15 @@ public void updateUserName(int id, String name) { * @throws SQLException */ public void executeSQL(String sql) throws SQLException { - + } public boolean isConnected() { - return true; + try { + return pool.getConnection() != null && !pool.getConnection().isClosed(); + } catch (Error | Exception e) { + return false; + } } /** @@ -384,42 +406,58 @@ public boolean isConnected() { * @throws SQLException */ protected DBConnection getConnection() { - return null; + try { + return pool.getConnection(); + } catch (Error | Exception e) { + plugin.consoleMessage("&cUnable to connect to the database: " + e.getMessage()); + return null; + } } /** * Close all active database handles */ public synchronized void closeConnections() { - pool.closeConnection(); + pool.closeConnection(); } public void close(ResultSet res) { - + if (res != null) + try { + res.close(); + } catch (Error | Exception e) { + e.printStackTrace(); + } } public void close(Statement stmt) { + if (stmt != null) + try { + stmt.close(); + } catch (Error | Exception e) { + e.printStackTrace(); + } } // async public boolean updatePlayer(CMIUser user) { - - return true; + + return true; } // async public void updatePlayerPlayTime(CMIUser user) { - + } // async public void updatePlayerInventory(CMIUser user, String string) { - + } // async public void updatePlayerPlayTimeRewards(CMIUser user) { - + } private PreparedStatement updateBatch = null; @@ -447,152 +485,144 @@ public void updatePlayerPlayTimeRewards(CMIUser user) { private boolean locked = false; public void setAutoCommit(boolean state) { - try { -// if (autoCommit != state) { - getConnection().setAutoCommit(state); - autoCommit = state; -// } - } catch (Throwable e) { - e.printStackTrace(); - } + } boolean ignoredFirst = false; public boolean executeTempBatch() { - - return true; + return true; } public void prepareTempBatch() { - if (locked) { - return; - } - setAutoCommit(false); + if (locked) { + return; + } + setAutoCommit(false); } // async irelevant child method public int getInvId(int iid) { - - return 1; + return 0; } // async irelevant child method private int getPlayTimeId(CMIPlayDay playDay, CMIUser user) { - - return 1; + return 0; } // async irelevant child method private int getPlayTimeRewardId(CMIUser user) { - - return 1; + + return 0; } // async irelevant child method private int getId(String uuid) { - - return 1; + return 0; } // sync priority public String getInv(CMIUser user) { - - return ""; + return ""; } // sync irelevant public void loadUser(UUID uuid) { - + } public void loadUser(int id) { - + } // sync irelevant public void loadAllUsers() { - + } // sync irelevant public void loadPlayTimes() { - + } // sync irelevant public LinkedHashSet getLastLogOffList(int from, int to) { - - - return null; + DBConnection conn = getConnection(); + LinkedHashSet users = new LinkedHashSet<>(); + return users; } // sync irelevant public void loadPlayTimes(CMIUser user) { - } // sync irelevant public void loadPlayerPlayTimeRewards() { - + } // async public void getUserIds(HashMap users) { - + } // async public void getUserPlayTimeIds(HashMap getPlayerPlayTimeId) { - + } // async public void getUserInvIds(HashMap users) { - + } // async public void getUserPlayTimeRewardIds(HashMap users) { - + } // sync no priority public boolean removeUser(int id) { - - return true; + + return false; } private boolean createDefaultTable(DBTables table) { - return false; + + return false; } private boolean checkDefaultUserCollumns() { - return true; + + return true; } private boolean checkDefaultInvCollumns() { - return true; + + return true; } private boolean checkDefaultPlayTimeCollumns() { - return true; + + return true; } private boolean checkDefaultPlayTimeRewardCollumns() { - return true; + + return true; } public DataBaseType getDbType() { - return dbType; + return dbType; } public void setDbType(DataBaseType dabType) { - dbType = dabType; + dbType = dabType; } public boolean isLocked() { - return locked; + return locked; } } diff --git a/src/com/Zrips/CMI/Modules/DataBase/DBManager.java b/src/com/Zrips/CMI/Modules/DataBase/DBManager.java index bb62eb2..f5e9d17 100644 --- a/src/com/Zrips/CMI/Modules/DataBase/DBManager.java +++ b/src/com/Zrips/CMI/Modules/DataBase/DBManager.java @@ -1,19 +1,25 @@ package com.Zrips.CMI.Modules.DataBase; +import java.io.File; import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.scheduler.BukkitTask; import com.Zrips.CMI.CMI; import com.Zrips.CMI.PlayerManager; import com.Zrips.CMI.Containers.CMIUser; +import net.Zrips.CMILib.FileHandler.ConfigReader; import com.Zrips.CMI.Modules.DataBase.DBDAO.UserTablesFields; -import com.Zrips.CMI.Modules.PlayTime.CMIPlayDay; - +import com.Zrips.CMI.Modules.Homes.CmiHome; import net.Zrips.CMILib.Logs.CMIDebug; +import com.Zrips.CMI.Modules.PlayTime.CMIPlayDay; public class DBManager { private DBDAO dao; @@ -21,18 +27,34 @@ public class DBManager { private DataBaseType DbType = DataBaseType.SqLite; public enum DataBaseType { - MySQL, SqLite + MySQL, SqLite } public DBManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public DBDAO getDB() { - return dao; + return dao; } public void switchDataBase() { + if (dao != null) + dao.closeConnections(); + plugin.setFullyLoaded(false); + switch (DbType) { + case MySQL: + DbType = DataBaseType.SqLite; + dao = startSqlite(false); + dao.setDbType(DbType); + break; + case SqLite: + DbType = DataBaseType.MySQL; + dao = startMysql(false); + dao.setDbType(DbType); + break; + } + plugin.setFullyLoaded(true); } int autoSaveInterval = 15; @@ -50,26 +72,26 @@ public void switchDataBase() { private boolean verifyServerCertificate = true; public void load() { - + } private synchronized DBMySQL startMysql(boolean reload) { - - return null; + + return null; } private synchronized DBSQLite startSqlite(boolean reload) { - if (reload && dao != null) - return (DBSQLite) dao; + if (reload && dao != null) + return (DBSQLite) dao; - DBSQLite data = new DBSQLite(plugin, plugin.getDataFolder()); - data.initialize(); - return data; + DBSQLite data = new DBSQLite(plugin, plugin.getDataFolder()); + data.initialize(); + return data; } public DataBaseType getDbType() { - return DbType; + return DbType; } private Set invToSave = ConcurrentHashMap.newKeySet(); @@ -79,59 +101,79 @@ public DataBaseType getDbType() { int autosaveBukkitId = -1; public void stop() { + if (autosaveBukkitId != -1) { + CMIDebug.d("Stopped auto save task", autosaveBukkitId); + Bukkit.getScheduler().cancelTask(autosaveBukkitId); + } + if (task != null) + Bukkit.getScheduler().cancelTask(task.getTaskId()); } class InvSave { - private CMIUser user; - private String inv; + private CMIUser user; + private String inv; - public InvSave(CMIUser user, String inv) { - this.user = user; - this.inv = inv; - } + public InvSave(CMIUser user, String inv) { + this.user = user; + this.inv = inv; + } - public String getInv() { - return inv; - } + public String getInv() { + return inv; + } - public CMIUser getUser() { - return user; - } + public CMIUser getUser() { + return user; + } } public void start() { + int autosaveInt = autoSaveInterval; + if (oldRapidvalue != null) + autosaveInt = 1; + if (autosaveInt < 1) { + autosaveInt = 1; + } + + autosaveInt = autosaveInt * 20; + stop(); + + autosaveBukkitId = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, autoSave, autosaveInt, autosaveInt); } public void addForSave(CMIUser user) { +// if (user.getName() != null && user.getName().equalsIgnoreCase(plugin.getPlayerManager().getFakeUserName())) +// return; + playerListToSave.add(user); } public void addForPlayTimeRewardSave(CMIUser user) { - playerPlayTimeRewardToSave.add(user); + playerPlayTimeRewardToSave.add(user); } public void addForSave(CMIUser user, String inventory) { - InvSave inv = new InvSave(user, inventory); + InvSave inv = new InvSave(user, inventory); - invToSave.add(inv); + invToSave.add(inv); } -// public void addForSave(ResidencePlayer player) { -// playerListToSave.add(player); -// } - public void clear() { + getPlayerId.clear(); + getPlayerInvId.clear(); + getPlayerPlayTimeId.clear(); + getPlayerPlayTimeRewardId.clear(); } BukkitTask task = null; Long startedAt = 0L; private Runnable autoSave = new Runnable() { - @Override - public void run() { - - } + @Override + public void run() { + + } }; HashMap getPlayerId = new HashMap(); @@ -139,47 +181,65 @@ public void run() { HashMap getPlayerPlayTimeId = new HashMap(); HashMap getPlayerPlayTimeRewardId = new HashMap(); - + private synchronized HashSet getFirstPlayersForSave(boolean all) { + HashSet temp = new HashSet(); + + return temp; + } Boolean all = false; public void saveAllInNextCicle() { - all = true; + all = true; } public void saveBatchAsync(boolean allEntries) { - + if (task != null && startedAt + (60 * 1000) < System.currentTimeMillis()) { + Bukkit.getScheduler().cancelTask(task.getTaskId()); + task = null; + } + if (task == null) { + startedAt = System.currentTimeMillis(); + task = Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { + @Override + public void run() { + saveBatch(allEntries); + all = false; + return; + } + }); + } } Integer oldRapidvalue = null; public void startRapidSave() { - oldRapidvalue = autoSaveInterval; - autoSaveInterval = 1; - all = false; + oldRapidvalue = autoSaveInterval; + autoSaveInterval = 1; + all = false; } boolean startingDb = false; public void saveBatch(boolean all) { - + } public boolean isRapidModeEnabled() { - return oldRapidvalue != null; + return oldRapidvalue != null; } private void showStats() { - for (Entry one : PlayerManager.timer.entrySet()) { - CMIDebug.d(one.getKey() + " : " + (one.getValue() / PlayerManager.timesProcessed)); - } + for (Entry one : PlayerManager.timer.entrySet()) { + CMIDebug.d(one.getKey() + " : " + (one.getValue() / PlayerManager.timesProcessed)); + } } public boolean isForceSaveOnLogOut() { - return ForceSaveOnLogOut; + return ForceSaveOnLogOut; } public boolean isForceLoadOnLogIn() { - return ForceLoadOnLogIn; + return ForceLoadOnLogIn; } } diff --git a/src/com/Zrips/CMI/Modules/DataBase/DBMySQL.java b/src/com/Zrips/CMI/Modules/DataBase/DBMySQL.java index 08600dc..fadeddc 100644 --- a/src/com/Zrips/CMI/Modules/DataBase/DBMySQL.java +++ b/src/com/Zrips/CMI/Modules/DataBase/DBMySQL.java @@ -1,5 +1,6 @@ package com.Zrips.CMI.Modules.DataBase; +import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; @@ -14,78 +15,87 @@ public class DBMySQL extends DBDAO { static { - try { - Class.forName("com.mysql.cj.jdbc.Driver"); - path = "com.mysql.cj.jdbc.Driver"; - } catch (Throwable e) { - path = "com.mysql.jdbc.Driver"; - } - - String major = ""; - - String[] javaVersionElements = System.getProperty("java.runtime.version").split("\\.|_|-b"); - try { - major = javaVersionElements[0]; - } catch (Throwable e) { - String d = System.getProperty("java.version"); - String[] s = d.split("_")[0].split("."); - major = s[1]; - } - CMI.getInstance().consoleMessage("Detected Java" + major); + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + path = "com.mysql.cj.jdbc.Driver"; + } catch (Throwable e) { + path = "com.mysql.jdbc.Driver"; + } + + String major = ""; + + String[] javaVersionElements = System.getProperty("java.runtime.version").split("\\.|_|-b"); + try { + major = javaVersionElements[0]; + } catch (Throwable e) { + String d = System.getProperty("java.version"); + String[] s = d.split("_")[0].split("."); + major = s[1]; + } + CMI.getInstance().consoleMessage("Detected Java" + major); } public DBMySQL(CMI plugin, String hostname, String database, String username, String password, String prefix, boolean autoReconnect, boolean certificate, boolean ssl) { - super(plugin, path, "jdbc:mysql://" + hostname + "/" + database + "?autoReconnect=" + autoReconnect + "&useSSL=" + ssl + - "&verifyServerCertificate=" + certificate + - "&useUnicode=true&characterEncoding=utf8mb4_unicode_ci", username, - password, prefix); - this.plugin = plugin; - this.database = database; - this.setDbType(DataBaseType.MySQL); + super(plugin, path, "jdbc:mysql://" + hostname + "/" + database + "?autoReconnect=" + autoReconnect + "&useSSL=" + ssl + + "&verifyServerCertificate=" + certificate + + "&useUnicode=true&characterEncoding=utf8mb4_unicode_ci", username, + password, prefix); + this.plugin = plugin; + this.database = database; + this.setDbType(DataBaseType.MySQL); } public void initialize() { - try { - setUp(); - } catch (SQLException e) { - e.printStackTrace(); - } + try { + setUp(); + } catch (SQLException e) { + e.printStackTrace(); + } } public DBMySQL initialize(CMI plugin, String hostname, String database, String username, String password, String prefix, boolean autoReconnect, boolean certificate, boolean ssl) { - this.plugin = plugin; - DBMySQL dao = new DBMySQL(plugin, hostname, database, username, password, prefix, autoReconnect, certificate, ssl); - try { - dao.setUp(); - } catch (SQLException e) { - e.printStackTrace(); - } - return dao; + this.plugin = plugin; + DBMySQL dao = new DBMySQL(plugin, hostname, database, username, password, prefix, autoReconnect, certificate, ssl); + try { + dao.setUp(); + } catch (SQLException e) { + e.printStackTrace(); + } + return dao; } @Override public Statement prepareStatement(String query) throws SQLException { - return null; + DBConnection conn = getConnection(); + if (conn == null) + return null; + PreparedStatement prest = null; + try { + prest = conn.prepareStatement(query); + } catch (SQLException | NumberFormatException e) { + e.printStackTrace(); + } + return prest; } @SuppressWarnings("resource") @Override public boolean createTable(String query) { - return true; + + return true; } @SuppressWarnings("resource") @Override public boolean isTable(String table) { - return false; + return false; } @SuppressWarnings("resource") @Override public boolean isCollumn(String table, String collumn) { - - return false; + return false; } @@ -93,7 +103,7 @@ public boolean isCollumn(String table, String collumn) { @Override public boolean addCollumn(String table, String collumn, String type) { - return false; + return false; } @@ -101,35 +111,33 @@ public boolean addCollumn(String table, String collumn, String type) { @Override public boolean truncate(String table) { - return false; + return false; } @Override public String getTableCharSet(DBTables table) { - return null; + return null; } @Override public String getTableRowFormat(DBTables table) { - return null; + return null; } @Override public boolean convertTableToUTF8(DBTables table) { - return false; - + return true; } @Override public boolean convertTableRowFormat(DBTables table) { - return false; - + return true; } } diff --git a/src/com/Zrips/CMI/Modules/DataBase/DBSQLite.java b/src/com/Zrips/CMI/Modules/DataBase/DBSQLite.java index 7be4e77..4bb9e1a 100644 --- a/src/com/Zrips/CMI/Modules/DataBase/DBSQLite.java +++ b/src/com/Zrips/CMI/Modules/DataBase/DBSQLite.java @@ -11,80 +11,75 @@ import com.Zrips.CMI.Modules.DataBase.DBManager.DataBaseType; public class DBSQLite extends DBDAO { -// private CMI plugin; public void initialize() { - try { - this.setUp(); - } catch (SQLException e) { - e.printStackTrace(); - } } DBSQLite(CMI plugin, File file) { - super(plugin, "org.sqlite.JDBC", "jdbc:sqlite:" + new File(file, "cmi.sqlite.db").getPath(), null, null, ""); - if (!file.exists()) - file.mkdirs(); - this.setDbType(DataBaseType.SqLite); + super(plugin, "org.sqlite.JDBC", "jdbc:sqlite:" + new File(file, "cmi.sqlite.db").getPath(), null, null, ""); + if (!file.exists()) + file.mkdirs(); + this.setDbType(DataBaseType.SqLite); } @Override public Statement prepareStatement(String query) throws SQLException { - DBConnection conn = getConnection(); - if (conn == null) - return null; - PreparedStatement prest = null; - return prest; + DBConnection conn = getConnection(); + if (conn == null) + return null; + PreparedStatement prest = null; + return prest; } @SuppressWarnings("resource") @Override public boolean createTable(String query) { + return false; - return false; } @Override public boolean isTable(String table) { + return false; - return false; } @Override public boolean isCollumn(String table, String collumn) { - return true; + return false; } @SuppressWarnings("resource") @Override public boolean addCollumn(String table, String collumn, String type) { - return true; + + return false; } @SuppressWarnings("resource") @Override public boolean truncate(String table) { - return false; + return false; } @Override public String getTableCharSet(DBTables table) { - return null; + return null; } @Override public boolean convertTableToUTF8(DBTables table) { - return true; + return true; } @Override public String getTableRowFormat(DBTables table) { - return null; + return null; } @Override public boolean convertTableRowFormat(DBTables table) { - return true; + return true; } } diff --git a/src/com/Zrips/CMI/Modules/DeathMessages/CMIDeathMsgInfo.java b/src/com/Zrips/CMI/Modules/DeathMessages/CMIDeathMsgInfo.java new file mode 100644 index 0000000..e377354 --- /dev/null +++ b/src/com/Zrips/CMI/Modules/DeathMessages/CMIDeathMsgInfo.java @@ -0,0 +1,75 @@ +package com.Zrips.CMI.Modules.DeathMessages; + +import java.util.UUID; + +class CMIDeathMsgInfo { + + private UUID uuid = null; + + private CMIKillerInfo killerInfo; + private CMIKillerInfo PreviousDamageInfo; + private String prefixPath = null; + private String suffixPath = null; + + private String basePath = null; + + private String message = null; + + public CMIDeathMsgInfo(UUID uuid, CMIKillerInfo killerInfo) { + this.uuid = uuid; + this.killerInfo = killerInfo; + } + + public CMIKillerInfo getKillerInfo() { + return killerInfo; + } + + public void setKillerInfo(CMIKillerInfo killerInfo) { + this.killerInfo = killerInfo; + } + + public String getPrefixPath() { + return prefixPath; + } + + public void setPrefixPath(String prefixPath) { + this.prefixPath = prefixPath; + } + + public String getSuffixPath() { + return suffixPath; + } + + public void setSuffixPath(String suffixPath) { + this.suffixPath = suffixPath; + } + + public CMIKillerInfo getPreviousDamageInfo() { + return PreviousDamageInfo; + } + + public void setPreviousDamageInfo(CMIKillerInfo previousDamageInfo) { + PreviousDamageInfo = previousDamageInfo; + } + + public String getBasePath() { + return basePath; + } + + public void setBasePath(String basePath) { + this.basePath = basePath; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public UUID getUniqueId() { + return uuid; + } + +} diff --git a/src/com/Zrips/CMI/Modules/DeathMessages/CMIDeathType.java b/src/com/Zrips/CMI/Modules/DeathMessages/CMIDeathType.java index 7c48bdb..3021fbe 100644 --- a/src/com/Zrips/CMI/Modules/DeathMessages/CMIDeathType.java +++ b/src/com/Zrips/CMI/Modules/DeathMessages/CMIDeathType.java @@ -11,6 +11,7 @@ public enum CMIDeathType { FallingBlocks, Fire, FireBall, + EndCrystal, FireworkRockets, Lava, Lightning, @@ -27,5 +28,6 @@ public enum CMIDeathType { SplashPotion, Void, WitherEffect, - Custom; + Custom, + Suicide; } diff --git a/src/com/Zrips/CMI/Modules/DeathMessages/CMIKillerInfo.java b/src/com/Zrips/CMI/Modules/DeathMessages/CMIKillerInfo.java new file mode 100644 index 0000000..3896caf --- /dev/null +++ b/src/com/Zrips/CMI/Modules/DeathMessages/CMIKillerInfo.java @@ -0,0 +1,70 @@ +package com.Zrips.CMI.Modules.DeathMessages; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; + +import net.Zrips.CMILib.Items.CMIItemStack; + +class CMIKillerInfo { + private damageInformation damage; + + private Entity killer = null; + private Block killerBlock = null; + + private CMIDeathType type = CMIDeathType.Custom; + + private CMIItemStack killerItem = null; + private List path = new ArrayList(); + + public CMIKillerInfo(damageInformation lastDamage) { + damage = lastDamage; + } + + public Entity getKiller() { + return killer; + } + + public void setKiller(Entity killer) { + this.killer = killer; + } + + public List getPath() { + return path; + } + + public void setPath(List path) { + this.path = path; + } + + public damageInformation getDamage() { + return damage; + } + + public Block getKillerBlock() { + return killerBlock; + } + + public void setKillerBlock(Block killerBlock) { + this.killerBlock = killerBlock; + } + + public CMIItemStack getKillerItem() { + return killerItem; + } + + public void setKillerItem(CMIItemStack killerItem) { + this.killerItem = killerItem; + } + + public CMIDeathType getType() { + return type; + } + + public void setType(CMIDeathType type) { + this.type = type; + } + +} \ No newline at end of file diff --git a/src/com/Zrips/CMI/Modules/DeathMessages/DeathMessageListener.java b/src/com/Zrips/CMI/Modules/DeathMessages/DeathMessageListener.java index f06eeef..9cd9b64 100644 --- a/src/com/Zrips/CMI/Modules/DeathMessages/DeathMessageListener.java +++ b/src/com/Zrips/CMI/Modules/DeathMessages/DeathMessageListener.java @@ -1,9 +1,12 @@ package com.Zrips.CMI.Modules.DeathMessages; +import java.util.regex.Pattern; + import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.PlayerDeathEvent; import com.Zrips.CMI.CMI; @@ -11,13 +14,43 @@ public class DeathMessageListener implements Listener { private CMI plugin; public DeathMessageListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } - static boolean enabled = false; - @EventHandler(priority = EventPriority.NORMAL) public void playerDamageEvent(EntityDamageEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void PlayerCombatEvent(EntityDamageEvent event) { + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onQuit(PlayerDeathEvent event) { + } + + private void processEvent(EntityDamageEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerDeathEvent(PlayerDeathEvent event) { + } - + + private static CMIDeathMsgInfo temp = null; + + Pattern pattern = Pattern.compile("(\\[)([^\"^\\[^\\]^ ]+)(\\])"); + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onPlayerDeathEventHighest(PlayerDeathEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerDeathEventMonitor(PlayerDeathEvent event) { + + } + } diff --git a/src/com/Zrips/CMI/Modules/DeathMessages/DeathMessageManager.java b/src/com/Zrips/CMI/Modules/DeathMessages/DeathMessageManager.java index ec83570..b100a1a 100644 --- a/src/com/Zrips/CMI/Modules/DeathMessages/DeathMessageManager.java +++ b/src/com/Zrips/CMI/Modules/DeathMessages/DeathMessageManager.java @@ -1,32 +1,51 @@ package com.Zrips.CMI.Modules.DeathMessages; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.UUID; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; +import net.Zrips.CMILib.RawMessages.RawMessage; + public class DeathMessageManager { private CMI plugin; HashMap messages = new HashMap(); + private List playerHover = new ArrayList(); + private List killerHover = new ArrayList(); + + private List disabledWorlds = new ArrayList(); + private List mutedWorlds = new ArrayList(); + private List ignoredPlayers = new ArrayList(); + + private long spamTimeRange = 30 * 1000L; + private int spamCount = 3; + + private HashMap> spamProtection = new HashMap>(); + public DeathMessageManager(CMI plugin) { - this.plugin = plugin; - if (DeathMessageListener.enabled) - load(); + this.plugin = plugin; } - boolean Enabled = false; + private boolean enabled = false; + private int autoHideFrom = -1; + private int range = -1; public void load() { - if (DeathMessageListener.enabled) { - loadConfig(); - loadLocale(); - } + loadConfig(); + loadLocale(); } private void loadConfig() { + } private void loadLocale() { @@ -34,10 +53,65 @@ private void loadLocale() { } private void addMessages(String path, List ls) { - messages.put(path, new DeathMessages(path, ls)); + messages.put(path, new DeathMessages(path, ls)); } public String getDeathMessage(String path) { - return null; + return null; + } + + private List getPlayersFromRange(Location loc, int range) { + List list = new ArrayList(); + + return list; + } + + public boolean broadcastDeathMessage(Player player, RawMessage rm) { + + return false; + } + + private void addSpamRecord(UUID uuid) { + + } + + private boolean isUnderSpamCooldown(UUID uuid) { + return true; + } + + public boolean isEnabled() { + return enabled; + } + + public int getAutoHideFrom() { + return autoHideFrom; + } + + public List getPlayerHover() { + return new ArrayList(playerHover); + } + + public List getKillerHover() { + return new ArrayList(killerHover); + } + + private boolean isInMutedWorld(World world) { + if (world == null || world.getName() == null) + return false; + return isInMutedWorld(world.getName()); + } + + private boolean isInMutedWorld(String worldName) { + return mutedWorlds.contains(worldName.toLowerCase()); + } + + private boolean isInDisabledWorld(World world) { + if (world == null || world.getName() == null) + return false; + return isInDisabledWorld(world.getName()); + } + + private boolean isInDisabledWorld(String worldName) { + return disabledWorlds.contains(worldName.toLowerCase()); } } diff --git a/src/com/Zrips/CMI/Modules/DiscordSRV/DiscordSRVManager.java b/src/com/Zrips/CMI/Modules/DiscordSRV/DiscordSRVManager.java index 68342c7..4d8b641 100644 --- a/src/com/Zrips/CMI/Modules/DiscordSRV/DiscordSRVManager.java +++ b/src/com/Zrips/CMI/Modules/DiscordSRV/DiscordSRVManager.java @@ -11,14 +11,18 @@ public class DiscordSRVManager { private String channelName = null; public DiscordSRVManager(CMI plugin) { - + } public boolean enabled() { - return false; + return false; + } + + public void sendDiscordDeathMessage(Player player, String deathMessage) { + } public void sendDiscordMessage(Player player, String message) { - + } } diff --git a/src/com/Zrips/CMI/Modules/DynMap/DynMapListener.java b/src/com/Zrips/CMI/Modules/DynMap/DynMapListener.java index 0c4f85c..ca1968a 100644 --- a/src/com/Zrips/CMI/Modules/DynMap/DynMapListener.java +++ b/src/com/Zrips/CMI/Modules/DynMap/DynMapListener.java @@ -1,13 +1,11 @@ package com.Zrips.CMI.Modules.DynMap; -import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerLoginEvent; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Logs.CMIDebug; import com.Zrips.CMI.events.CMIPlayerUnVanishEvent; import com.Zrips.CMI.events.CMIPlayerVanishEvent; @@ -15,6 +13,21 @@ public class DynMapListener implements Listener { private CMI plugin; public DynMapListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void CMIPlayerUnVanishEvent(CMIPlayerUnVanishEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void CMIPlayerVanishEvent(CMIPlayerVanishEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerLoginEvent(PlayerLoginEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/DynMap/DynMapManager.java b/src/com/Zrips/CMI/Modules/DynMap/DynMapManager.java index 96af07c..2f5d833 100644 --- a/src/com/Zrips/CMI/Modules/DynMap/DynMapManager.java +++ b/src/com/Zrips/CMI/Modules/DynMap/DynMapManager.java @@ -10,21 +10,20 @@ public class DynMapManager { private CMI plugin; public DynMapManager(CMI plugin) { - } public boolean enabled() { - return false; + return false; } public void processPlayer(Player player) { - processPlayer(plugin.getPlayerManager().getUser(player)); + processPlayer(plugin.getPlayerManager().getUser(player)); } public void processPlayer(CMIUser user) { + } public void sentMessage(Player player, String message) { - } } diff --git a/src/com/Zrips/CMI/Modules/DynamicSigns/CMISign.java b/src/com/Zrips/CMI/Modules/DynamicSigns/CMISign.java index 7295782..d58e2fa 100644 --- a/src/com/Zrips/CMI/Modules/DynamicSigns/CMISign.java +++ b/src/com/Zrips/CMI/Modules/DynamicSigns/CMISign.java @@ -1,9 +1,11 @@ package com.Zrips.CMI.Modules.DynamicSigns; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.bukkit.World; +import org.bukkit.block.Block; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -17,7 +19,7 @@ public class CMISign { private CuboidArea area; - private String[] lines = new String[0]; + private List lines = new ArrayList(); private Sign sign; private double updateIntervalSec = 5; @@ -31,122 +33,117 @@ public class CMISign { private CMILocation loc; public CMISign(CMILocation loc) { - this.loc = loc; + this.loc = loc; } -// public String getName() { -// return name; -// } -// -// public void setName(String name) { -// this.name = name; -// } - public World getWorld() { - return loc.getWorld(); + return loc.getWorld(); } public CMILocation getLoc() { - return loc; + return loc; } - public String[] getLines() { - return lines; + public List getLines() { + return lines; } public String getLine(int place) { - return lines.length - 1 < place || place < 0 ? "" : lines[place] == null ? "" : lines[place]; + return lines.size() - 1 < place || place < 0 ? "" : lines.get(place) == null ? "" : lines.get(place); } public List getLinesAsList() { - List ls = new ArrayList(); - for (String one : lines) { - ls.add(one); - } - return ls; + List ls = new ArrayList(); + for (String one : lines) { + ls.add(one); + } + return ls; } public void setLines(List l) { - lines = new String[l.size()]; - for (int i = 0; i < l.size(); i++) { - lines[i] = l.get(i); - } - for (int i = 0; i < lines.length; i++) { - if (lines[i] == null) - lines[i] = ""; - } + this.lines = l; } public void setLines(String[] lines) { - this.lines = lines; - for (int i = 0; i < lines.length; i++) { - if (lines[i] == null) - lines[i] = ""; - } + this.lines = Arrays.asList(lines); } public CuboidArea getArea() { - - return null; + + return null; } public void setArea(CuboidArea area) { - this.area = area; + this.area = area; } public Sign getSign() { - return sign; + if (sign == null) { + Block block = loc.getBlock(); + if (!(block.getState() instanceof Sign)) { + return sign; + } + sign = (Sign) block.getState(); + } + return sign; } public void setSign(Sign sign) { - this.sign = sign; + this.sign = sign; } public boolean isTimeToUpdate() { - return this.lastUpdate + (this.updateIntervalSec * 1000L) <= System.currentTimeMillis(); + return this.lastUpdate + (this.updateIntervalSec * 1000L) - 10L <= System.currentTimeMillis(); } public void setAsUpdated() { - this.lastUpdate = System.currentTimeMillis(); + this.lastUpdate = System.currentTimeMillis(); } public void update() { - update(null); + update(null); } public void update(final Player player) { - + } public double getUpdateIntervalSec() { - return updateIntervalSec; + return updateIntervalSec; } public void setUpdateIntervalSec(double updateIntervalSec) { - this.updateIntervalSec = updateIntervalSec; - if (this.updateIntervalSec < 0) - this.updateIntervalSec = 0; + this.updateIntervalSec = updateIntervalSec; + if (this.updateIntervalSec < 0) + this.updateIntervalSec = 0; } public boolean isPersonal() { - return personal; + return personal; } public void setPersonal(boolean personal) { - this.personal = personal; + this.personal = personal; } public int getActivationRange() { - return activationRange; + return activationRange; } public void setActivationRange(int activationRange) { - this.activationRange = activationRange; - if (this.activationRange < 1) - this.activationRange = 1; + this.activationRange = activationRange; + if (this.activationRange < 1) + this.activationRange = 1; } public void updateCurrentLine() { + if (lines.size() > 4) { + currentLine++; + } + if (currentLine >= lines.size()) + currentLine = 0; + if (lines.size() <= 4) + currentLine = 0; } } diff --git a/src/com/Zrips/CMI/Modules/DynamicSigns/SignListener.java b/src/com/Zrips/CMI/Modules/DynamicSigns/SignListener.java index 5ee2c4f..1e752d7 100644 --- a/src/com/Zrips/CMI/Modules/DynamicSigns/SignListener.java +++ b/src/com/Zrips/CMI/Modules/DynamicSigns/SignListener.java @@ -4,7 +4,14 @@ import java.util.Map; import java.util.UUID; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerTeleportEvent; import com.Zrips.CMI.CMI; @@ -14,8 +21,31 @@ public class SignListener implements Listener { protected Map lastUpdateRange; public SignListener(CMI plugin) { - this.plugin = plugin; - lastUpdateRange = new HashMap(); + this.plugin = plugin; + lastUpdateRange = new HashMap(); } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMoveExtendedRnage(PlayerMoveEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMoveExtendedRnage(PlayerTeleportEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMoveExtendedRnage(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMoveExtendedRnage(BlockBreakEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMoveExtendedRnage(PlayerJoinEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/DynamicSigns/SignManager.java b/src/com/Zrips/CMI/Modules/DynamicSigns/SignManager.java index 46e64ee..a1b4cf8 100644 --- a/src/com/Zrips/CMI/Modules/DynamicSigns/SignManager.java +++ b/src/com/Zrips/CMI/Modules/DynamicSigns/SignManager.java @@ -1,21 +1,36 @@ package com.Zrips.CMI.Modules.DynamicSigns; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Modules.ModuleHandling.CMIModule; import com.Zrips.CMI.Modules.Portals.CuboidArea.ChunkRef; +import com.Zrips.CMI.Modules.Worlds.CMIWorldListener; +import com.Zrips.CMI.Modules.Worlds.UpdateOnWorldLoad; import net.Zrips.CMILib.Colors.CMIChatColor; +import net.Zrips.CMILib.Container.CMIList; +import net.Zrips.CMILib.Container.CMILocation; +import net.Zrips.CMILib.FileHandler.ConfigReader; +import net.Zrips.CMILib.GUI.CMIGui; +import net.Zrips.CMILib.GUI.CMIGuiButton; import net.Zrips.CMILib.GUI.GUIManager.GUIClickType; +import net.Zrips.CMILib.GUI.GUIManager.GUIRows; +import net.Zrips.CMILib.Items.CMIMaterial; +import net.Zrips.CMILib.Logs.CMIDebug; public class SignManager { @@ -37,27 +52,33 @@ public SignManager(CMI plugin) { private int sched = -1; public void stop() { - + } public void addSign(CMISign sign) { + signs.add(sign); + recalculateChunks(sign); } public void recalculateChunks() { + chunkSignsRange.clear(); + for (CMISign one : this.signs) { + recalculateChunks(one); + } } public void recalculateChunks(CMISign sign) { - + } public CMISign getByLoc(Location loc) { - - return null; + + return null; } public Set getAllInRangeByLoc(Location loc) { - - return null; + Set sign = new HashSet(); + return sign; } public void handleSignUpdates(Player player, Location locto) { @@ -65,58 +86,49 @@ public void handleSignUpdates(Player player, Location locto) { } private static List getChunks(CMISign res) { - List chunks = new ArrayList<>(); - return chunks; + List chunks = new ArrayList<>(); + chunks.addAll(res.getArea().getChunks()); + return chunks; } + private List signEditBlackList = new ArrayList(); public void loadConfig() { - - - + } public void load() { - + } public void save() { - if (saveId != null) - return; - saveId = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - @Override - public void run() { - saveSigns(); - saveId = null; - } - }, 20L * 5); + if (saveId != null) + return; + saveId = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override + public void run() { + saveSigns(); + saveId = null; + } + }, 20L * 5); } boolean saving = false; private void saveSigns() { - + } public void removeLastSignInRange(CMISign sign, UUID uuid) { - Set ls = lastSignInRange.get(sign); - if (ls == null) - return; - ls.remove(uuid); - if (ls.isEmpty()) { - lastSignInRange.remove(sign); - return; - } - lastSignInRange.put(sign, ls); } public void addLastSignInRange(CMISign sign, UUID uuid) { - + } public void removeLastSignInRange(UUID uuid) { - + } private void tasker() { @@ -127,48 +139,55 @@ public void addPlayersNearSign(CMISign sign) { } + private static void updateSign(Player player, CMISign sign) { + + } + + private void updateSign(CMISign sign) { + + } + + private static void updateSign(CMISign sign, Set list) { + + } public Set getSigns() { - return signs; + return signs; } public List getSignsByDistance(Location loc) { - return null; + List sortedList = new ArrayList(); + + return sortedList; } public void removeSign(CMISign sign) { - signs.remove(sign); - lastSignInRange.remove(sign); - this.recalculateChunks(); - this.save(); + signs.remove(sign); + lastSignInRange.remove(sign); + this.recalculateChunks(); + this.save(); } public int getSignCheckInterval() { - return SignRangeCheckInterval; + return SignRangeCheckInterval; } public boolean isNearSign(UUID uuid) { - Set ls = playerNearSigns.get(uuid); - return ls != null && !ls.isEmpty(); + Set ls = playerNearSigns.get(uuid); + return ls != null && !ls.isEmpty(); } public void addNearSign(UUID uuid, CMISign sign) { + } public void removeNearSign(UUID uuid, CMISign sign) { - Set ls = playerNearSigns.get(uuid); - if (ls == null) - return; - - ls.remove(sign); - if (ls.isEmpty()) - playerNearSigns.remove(uuid); } public void removeNearSign(UUID uuid) { - playerNearSigns.remove(uuid); + playerNearSigns.remove(uuid); } public void openGui(Player player, CMISign sign) { @@ -176,28 +195,27 @@ public void openGui(Player player, CMISign sign) { } public static void changeIndividual(Player player, CMISign sign) { - sign.setPersonal(!sign.isPersonal()); - CMI.getInstance().getSignManager().openGui(player, sign); - CMI.getInstance().getSignManager().save(); + } public static void changeRange(Player player, GUIClickType click, CMISign sign) { + } public static void changeInterval(Player player, GUIClickType click, CMISign sign) { - + } public HashMap getColorChange() { - return colorChange; + return colorChange; } public void setColorChange(HashMap colorChange) { - this.colorChange = colorChange; + this.colorChange = colorChange; } public List getSignEditBlackList() { - return signEditBlackList; + return signEditBlackList; } } diff --git a/src/com/Zrips/CMI/Modules/Economy/CMIEconomyAcount.java b/src/com/Zrips/CMI/Modules/Economy/CMIEconomyAcount.java index 3aa4098..d30df6e 100644 --- a/src/com/Zrips/CMI/Modules/Economy/CMIEconomyAcount.java +++ b/src/com/Zrips/CMI/Modules/Economy/CMIEconomyAcount.java @@ -1,7 +1,9 @@ package com.Zrips.CMI.Modules.Economy; +import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import org.bukkit.World; @@ -13,39 +15,48 @@ public class CMIEconomyAcount { private Map balances = null; private CMIUser user = null; + private int balTopPos = 0; public CMIEconomyAcount(CMIUser user) { - this.user = user; + this.user = user; + balances = Collections.synchronizedMap(new HashMap()); + for (WorldGroup one : CMI.getInstance().getEconomyManager().getWorldGroups()) { + balances.put(one, null); + } } public WorldGroup getCurrentWorldGroup() { - World world = user.getWorld(); - WorldGroup group = world == null ? CMI.getInstance().getEconomyManager().getWorldGroup(EconomyManager.CMIDefaultWorld) : CMI.getInstance().getEconomyManager().getWorldGroup(world.getName()); - return group; + World world = user.getWorld(); + WorldGroup group = world == null ? CMI.getInstance().getEconomyManager().getWorldGroup(EconomyManager.CMIDefaultWorld) : CMI.getInstance().getEconomyManager().getWorldGroup(world.getName()); + return group; } public String getCurrentWorldGroupName() { - World world = user.getWorld(); - String name = world == null ? EconomyManager.CMIDefaultWorld : world.getName(); - return name; + World world = user.getWorld(); + String name = world == null ? EconomyManager.CMIDefaultWorld : world.getName(); + return name; } public Double setBalance(double amount) { - WorldGroup defaultGroup = CMI.getInstance().getEconomyManager().getDefaultGroup(); - return setBalance(defaultGroup, amount); + WorldGroup defaultGroup = CMI.getInstance().getEconomyManager().getDefaultGroup(); + return setBalance(defaultGroup, amount); } public Double setBalance(WorldGroup defaultGroup, double amount) { - return setBalance(defaultGroup, amount, true); + return setBalance(defaultGroup, amount, true); } public Double setBalance(WorldGroup defaultGroup, double amount, boolean save) { - return setBalance(defaultGroup, amount, save, false); + return setBalance(defaultGroup, amount, save, false); } public Double setBalance(WorldGroup defaultGroup, double amount, boolean save, boolean reloading) { - Double balance = balances.put(defaultGroup, amount); - return balance; + if (CMI.getInstance().isFullyLoaded()) + fireEvent(this.user, balances.get(defaultGroup) == null ? defaultGroup.getStartingAmount() : balances.get(defaultGroup), amount, reloading ? "setBalanceReload" : "setBalance", null); + Double balance = balances.put(defaultGroup, amount); + if (save) + this.user.saveIfOffline(); + return balance; } private static void fireEvent(final CMIUser user, final Double from, final Double to, String type, CMIUser source) { @@ -53,41 +64,41 @@ private static void fireEvent(final CMIUser user, final Double from, final Doubl } public Double getBalance() { - return getBalance(null); + return getBalance(null); } public Double getBalance(String worldName) { - return 0D; + + return 0D; + } public String getFormatedBalance() { - return getFormatedBalance(null); + return getFormatedBalance(null); } public String getFormatedBalance(boolean shorts) { - return getFormatedBalance(null, shorts); + return getFormatedBalance(null, shorts); } public String getFormatedBalance(String worldName) { - return getFormatedBalance(worldName, false); + return getFormatedBalance(worldName, false); } public String getFormatedBalance(String worldName, boolean shorts) { - - return ""; + return ""; } - public static String format(double number, HashMap hashMap, String worldName) { - - return ""; + public static String format(double number, HashMap hashMap, String worldName) { + return ""; } public Double deposit(double amount) { - return deposit(null, amount); + return deposit(null, amount); } public Double deposit(String worldName, double amount) { - return deposit(worldName, amount, null); + return deposit(worldName, amount, null); } /** @@ -95,18 +106,15 @@ public Double deposit(String worldName, double amount) { * @param source only used to indicate from who money is deposited but doesn't deduct from it */ public Double deposit(String worldName, double amount, CMIUser source) { - - return 0D; + return 0D; } public Double withdraw(double amount) { - // Update for multiworld support -// return withdraw(getCurrentWorldGroupName(), amount); - return withdraw(null, amount); + return withdraw(null, amount); } public Double withdraw(String worldName, double amount) { - return withdraw(worldName, amount, null); + return withdraw(worldName, amount, null); } /** @@ -114,29 +122,46 @@ public Double withdraw(String worldName, double amount) { * @param target only used to indicate who gets money but doesn't actually transfer to target player */ public Double withdraw(String worldName, double amount, CMIUser target) { - - return 0D; + return 0D; } public boolean has(double amount) { - return has(null, amount); + return has(null, amount); } public boolean has(String worldName, double amount) { - return false; + return true; } public Map getBalances() { - return balances; + return balances; } public HashMap getWorldGroupBalancesRounded() { - HashMap map = new HashMap(); - return map; + HashMap map = new HashMap(); + return map; } public HashMap getWorldGroupBalances() { - HashMap map = new HashMap(); - return map; + HashMap map = new HashMap(); + for (Entry one : balances.entrySet()) { + map.put(one.getKey().getName(), one.getValue()); + } + return map; + } + + public int updateBalTopPosition() { + balTopPos = CMI.getInstance().getEconomyManager().getBalTopPlace(user.getUniqueId()); + return balTopPos; + } + + public int getBalTopPosition() { + if (balTopPos == 0) + balTopPos = CMI.getInstance().getEconomyManager().getBalTopPlace(user.getUniqueId()); + return balTopPos; + } + + public void setBalTopPosition(int balTopPos) { + this.balTopPos = balTopPos; } } diff --git a/src/com/Zrips/CMI/Modules/Economy/Economy.java b/src/com/Zrips/CMI/Modules/Economy/Economy.java index e42caf4..dd58057 100644 --- a/src/com/Zrips/CMI/Modules/Economy/Economy.java +++ b/src/com/Zrips/CMI/Modules/Economy/Economy.java @@ -1,20 +1,13 @@ package com.Zrips.CMI.Modules.Economy; -import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; -import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIUser; -import com.Zrips.CMI.Modules.Economy.EconomyManager.CMIMoneyLogType; -import com.Zrips.CMI.Modules.Economy.EconomyManager.WorldGroup; -//import net.Zrips.CMILib.Locale.LC; -import com.Zrips.CMI.events.CMIUserBalanceChangeEvent; -import net.Zrips.CMILib.Logs.CMIDebug; import net.milkbowl.vault.economy.EconomyResponse; public class Economy { @@ -24,273 +17,231 @@ public class Economy { private static final String ecoName = "CMIEconomy"; public Economy(CMI pl) { - plugin = pl; + plugin = pl; } public boolean isEnabled() { - return plugin != null; + return plugin != null; } public static String getName() { - return ecoName; + return ecoName; } private static String TrA(double amount) { - - return ""; + return ""; } public static String format(double amount) { - return TrA(amount); + return TrA(amount); } public static String currencyNameSingular() { - return ""; + return ""; } public static String currencyNamePlural() { - return ""; + return ""; } public static double getBalance(String playerName) { - - return 0D; + return 0D; } public static double getBalance(OfflinePlayer offlinePlayer) { - if (plugin == null) - return 0D; - CMIUser user = plugin.getPlayerManager().getUser(offlinePlayer); - return getAccountBalance(user); + if (plugin == null) + return 0D; + CMIUser user = plugin.getPlayerManager().getUser(offlinePlayer); + return getAccountBalance(user); } private static double getAccountBalance(CMIUser user) { - if (user == null) - return 0.0D; - return user.getBalance().doubleValue(); + return 0.0D; } public static EconomyResponse withdrawPlayer(String playerName, double amount) { - if (plugin == null) - return new EconomyResponse(0.0D, 0D, EconomyResponse.ResponseType.FAILURE, "Plugin is not loaded"); - if (plugin.getEconomyManager().isTownyAccount(playerName)) { - - CMIUser user = plugin.getPlayerManager().getUser(playerName, false, true, true, true); - return withdraw(user, amount); - } - - CMIUser user = plugin.getPlayerManager().getUser(playerName, false, true, false, true); - return withdraw(user, amount); + CMIUser user = plugin.getPlayerManager().getUser(playerName, false, true, false, true); + return withdraw(user, amount); } public static EconomyResponse withdrawPlayer(OfflinePlayer offlinePlayer, double amount) { - if (plugin == null) - return new EconomyResponse(0.0D, 0D, EconomyResponse.ResponseType.FAILURE, "Plugin is not loaded"); - CMIUser user = plugin.getPlayerManager().getUser(offlinePlayer); - return withdraw(user, amount); + if (plugin == null) + return new EconomyResponse(0.0D, 0D, EconomyResponse.ResponseType.FAILURE, "Plugin is not loaded"); + CMIUser user = plugin.getPlayerManager().getUser(offlinePlayer); + return withdraw(user, amount); } private static EconomyResponse withdraw(CMIUser user, double amount) { - if (user == null) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.FAILURE, "Account doesn't exist"); - } - if (amount < 0.0D) { - return new EconomyResponse(0.0D, user.getBalance(), EconomyResponse.ResponseType.FAILURE, "Cannot withdraw negative funds"); - } - if (user.hasMoney(amount)) { -// Double before = user.getBalance(); - user.withdraw(amount); -// fireEvent(user, before, user.getBalance(), "Withdraw"); - return new EconomyResponse(amount, user.getBalance(), EconomyResponse.ResponseType.SUCCESS, ""); - } - return new EconomyResponse(0.0D, user.getBalance(), EconomyResponse.ResponseType.FAILURE, "Insufficient funds"); + + return new EconomyResponse(0.0D, user.getBalance(), EconomyResponse.ResponseType.FAILURE, "Insufficient funds"); } public static EconomyResponse depositPlayer(String playerName, double amount) { - if (plugin == null) - return new EconomyResponse(0.0D, 0D, EconomyResponse.ResponseType.FAILURE, "Plugin is not loaded"); - if (plugin.getEconomyManager().isTownyAccount(playerName)) { - CMIUser user = plugin.getPlayerManager().getUser(playerName, false, true, true, true); - return deposit(user, amount); - } - CMIUser user = plugin.getPlayerManager().getUser(playerName, false, true, false, true); - return deposit(user, amount); + CMIUser user = plugin.getPlayerManager().getUser(playerName, false, true, false, true); + return deposit(user, amount); } public static EconomyResponse depositPlayer(OfflinePlayer offlinePlayer, double amount) { - if (plugin == null) - return new EconomyResponse(0.0D, 0D, EconomyResponse.ResponseType.FAILURE, "Plugin is not loaded"); - CMIUser user = plugin.getPlayerManager().getUser(offlinePlayer); - return deposit(user, amount); + if (plugin == null) + return new EconomyResponse(0.0D, 0D, EconomyResponse.ResponseType.FAILURE, "Plugin is not loaded"); + CMIUser user = plugin.getPlayerManager().getUser(offlinePlayer); + return deposit(user, amount); } private static EconomyResponse deposit(CMIUser user, double amount) { - if (user == null) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.FAILURE, "Account doesn't exist"); - } - if (amount < 0.0D) { - return new EconomyResponse(0.0D, user.getBalance(), EconomyResponse.ResponseType.FAILURE, "Cannot deposit negative funds"); - } - - Double before = user.getBalance(); - user.deposit(amount); + if (user == null) { + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.FAILURE, "Account doesn't exist"); + } + if (amount < 0.0D) { + return new EconomyResponse(0.0D, user.getBalance(), EconomyResponse.ResponseType.FAILURE, "Cannot deposit negative funds"); + } + + Double before = user.getBalance(); + user.deposit(amount); // fireEvent(user, before, user.getBalance(), "Deposit"); - return new EconomyResponse(amount, user.getBalance(), EconomyResponse.ResponseType.SUCCESS, ""); + return new EconomyResponse(amount, user.getBalance(), EconomyResponse.ResponseType.SUCCESS, ""); } public static boolean has(String playerName, double amount) { - return getBalance(playerName) >= amount; + return getBalance(playerName) >= amount; } public static boolean has(OfflinePlayer offlinePlayer, double amount) { - return getBalance(offlinePlayer) >= amount; + return getBalance(offlinePlayer) >= amount; } public static EconomyResponse createBank(String name, String player) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } public static EconomyResponse createBank(String name, OfflinePlayer offlinePlayer) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } public static EconomyResponse deleteBank(String name) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } public static EconomyResponse bankHas(String name, double amount) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } public static EconomyResponse bankWithdraw(String name, double amount) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } public static EconomyResponse bankDeposit(String name, double amount) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } public static EconomyResponse isBankOwner(String name, String playerName) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } public static EconomyResponse isBankOwner(String name, OfflinePlayer offlinePlayer) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } public static EconomyResponse isBankMember(String name, String playerName) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } public static EconomyResponse isBankMember(String name, OfflinePlayer offlinePlayer) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } public static EconomyResponse bankBalance(String name) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } public static List getBanks() { - return new ArrayList(); + return new ArrayList(); } public static boolean hasBankSupport() { - return false; + return false; } public static boolean hasAccount(String playerName) { - return plugin.getPlayerManager().getUser(playerName) != null; + return plugin.getPlayerManager().getUser(playerName) != null; } public static boolean hasAccount(OfflinePlayer offlinePlayer) { - return plugin.getPlayerManager().getUser(offlinePlayer) != null; + return plugin.getPlayerManager().getUser(offlinePlayer) != null; } @Deprecated public static boolean createPlayerAccount(String playerName) { - if (plugin == null) - return false; + if (plugin == null) + return false; - if (hasAccount(playerName)) - return true; + if (hasAccount(playerName)) { + return true; + } - CMIUser u = CMI.getInstance().getPlayerManager().getUser(playerName, true, false, true, true); + CMIUser u = CMI.getInstance().getPlayerManager().getUser(playerName, true, false, true, true); - return u != null; + return u != null; } public static boolean createPlayerAccount(OfflinePlayer offlinePlayer) { - if (plugin == null) - return false; - return plugin.getPlayerManager().getUser(offlinePlayer) != null; + if (plugin == null) + return false; + return plugin.getPlayerManager().getUser(offlinePlayer) != null; } public static int fractionalDigits() { - return -1; + return -1; } public static boolean hasAccount(String playerName, String worldName) { - return hasAccount(playerName); + return hasAccount(playerName); } public static boolean hasAccount(OfflinePlayer offlinePlayer, String worldName) { - return hasAccount(offlinePlayer); + return hasAccount(offlinePlayer); } public static double getBalance(String playerName, String worldName) { - return getBalance(playerName); + return getBalance(playerName); } public static double getBalance(OfflinePlayer offlinePlayer, String worldName) { - return getBalance(offlinePlayer); + return getBalance(offlinePlayer); } public static boolean has(String playerName, String worldName, double amount) { - return has(playerName, amount); + return has(playerName, amount); } public static boolean has(OfflinePlayer offlinePlayer, String worldName, double amount) { - return has(offlinePlayer, amount); + return has(offlinePlayer, amount); } public static EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) { - return withdrawPlayer(playerName, amount); + return withdrawPlayer(playerName, amount); } public static EconomyResponse withdrawPlayer(OfflinePlayer offlinePlayer, String worldName, double amount) { - return withdrawPlayer(offlinePlayer, amount); + return withdrawPlayer(offlinePlayer, amount); } public static EconomyResponse depositPlayer(String playerName, String worldName, double amount) { - return depositPlayer(playerName, amount); + return depositPlayer(playerName, amount); } public static EconomyResponse depositPlayer(OfflinePlayer offlinePlayer, String worldName, double amount) { - return depositPlayer(offlinePlayer, amount); + return depositPlayer(offlinePlayer, amount); } public static boolean createPlayerAccount(String playerName, String worldName) { - return createPlayerAccount(playerName); + return createPlayerAccount(playerName); } public static boolean createPlayerAccount(OfflinePlayer offlinePlayer, String worldName) { - return createPlayerAccount(offlinePlayer); - } - -// private static void fireEvent(final CMIUser user, final Double from, final Double to, String type) { -// if (!CMI.getInstance().isFullyLoaded()) -// return; -// Bukkit.getScheduler().runTaskAsynchronously(CMI.getInstance(), new Runnable() { -// @Override -// public void run() { -// CMIUserBalanceChangeEvent e = new CMIUserBalanceChangeEvent(user, from, to, type); -// Bukkit.getServer().getPluginManager().callEvent(e); -// CMI.getInstance().getEconomyManager().moneyLog(user, null, to - from, CMIMoneyLogType.Unknown, type); -// return; -// } -// }); -// } + return createPlayerAccount(offlinePlayer); + } } diff --git a/src/com/Zrips/CMI/Modules/Economy/EconomyManager.java b/src/com/Zrips/CMI/Modules/Economy/EconomyManager.java index 2f8681e..4a97dd6 100644 --- a/src/com/Zrips/CMI/Modules/Economy/EconomyManager.java +++ b/src/com/Zrips/CMI/Modules/Economy/EconomyManager.java @@ -1,14 +1,17 @@ package com.Zrips.CMI.Modules.Economy; import java.io.File; -import java.io.IOException; import java.io.Writer; +import java.math.RoundingMode; import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; @@ -31,6 +34,7 @@ public class EconomyManager { private boolean ChequePaper; private boolean ChequePermission; private boolean BalTopIncludeFakes; + private long ExcludeInactive; private boolean BalTopDisplayWithShorts; private List BalTopExclude; private List BalTopExcludeStartingWith; @@ -52,7 +56,7 @@ public class EconomyManager { private VaultManager vmanager = null; public EconomyManager(CMI plugin) { - + } SortedMap balTop = Collections.synchronizedSortedMap(new TreeMap(Collections.reverseOrder())); @@ -62,27 +66,62 @@ public EconomyManager(CMI plugin) { Long lastRecalculated = null; public void setForBalTopRecalculation() { - lastRecalculated = null; + lastRecalculated = null; } public String format(Double money) { - if (money == null) - return "0"; - if (vmanager == null) - return String.valueOf(money); - return vmanager.format(money); + if (money == null) + return "0"; + if (vmanager == null) + return String.valueOf(money); + return vmanager.format(money); } public boolean isVaultEnabled() { - return vmanager != null && vmanager.getVaultEconomy() != null; + return vmanager != null && vmanager.getVaultEconomy() != null; } boolean locked = false; + class baltopUpdateCache { + private long time = 0; + private int shedID = -1; + + public long getTime() { + return time; + } + + public baltopUpdateCache setTime(long time) { + this.time = time; + return this; + } + + public int getShedID() { + return shedID; + } + + public baltopUpdateCache setShedID(int shedID) { + this.shedID = shedID; + return this; + } + } + + Map balanceUpdateCache = Collections.synchronizedMap(new HashMap()); + + public void removeFromUpdateCache(UUID uuid) { + balanceUpdateCache.remove(uuid); + } + + int updateDelay = 15; + public synchronized void updateBalTop(final CMIUser user) { } + private void forceUpdateBalTop(CMIUser user) { + + } + BukkitTask recTask = null; public void recalculateBalTop() { @@ -90,52 +129,93 @@ public void recalculateBalTop() { } private boolean startsWithExcluded(String name) { - name = name.toLowerCase(); - for (String one : BalTopExcludeStartingWith) { - if (name.startsWith(one)) - return true; - } - return false; + name = name.toLowerCase(); + for (String one : BalTopExcludeStartingWith) { + if (name.startsWith(one)) + return true; + } + return false; } public SortedMap getBalTopMap() { - - return balTop; + + return balTop; } - public Set getWorldGroups() { - Set groups = new HashSet(); + public int getBalTopPlace(UUID uuid) { + SortedMap map = getBalTopMap(); + Double current = balTopUsers.get(uuid); + if (current == null) + return plugin.getPlayerManager().getTotalUserCount(); - return groups; + return map.headMap(current).size() + 1; } - public Set getWorlds(WorldGroup worldGroup) { - Set groups = new HashSet(); + public Set getWorldGroups() { + Set groups = new HashSet(); + for (Entry one : this.groups.entrySet()) { + if (this.CustomWorldsEnabled && one.getKey().equals(CMIDefaultWorld)) + continue; + groups.add(one.getValue()); + } + return groups; + } - return groups; + public Set getWorlds(WorldGroup worldGroup) { + Set groups = new HashSet(); + for (Entry one : this.groups.entrySet()) { + if (!one.getValue().getName().equals(worldGroup.getName())) + continue; + groups.add(one.getKey()); + } + return groups; } public WorldGroup getWorldGroup(String name) { - - return groups.get(name); + if (name == null) + return groups.get(CMIDefaultWorld); + if (!groups.containsKey(name)) { + for (Entry one : groups.entrySet()) { + if (one.getValue().getName().equals(name)) + return one.getValue(); + } + return groups.get(CMIDefaultWorld); + } + return groups.get(name); } public DecimalFormat getMoneyFormat() { - return getMoneyFormat(null); + return getMoneyFormat(null); } public Double translateMoney(String value) { - - return 0D; + + return 0D; } - public DecimalFormat getMoneyFormat(String worldName) { + DecimalFormat defaultFormat; - WorldGroup group = getDefaultGroup(); + DecimalFormat shortDefaultFormat; + public DecimalFormat getShortMoneyFormat() { + return shortDefaultFormat; + } - return new DecimalFormat(group.getCurrencyFormat()); - + public DecimalFormat getMoneyFormat(String worldName) { + if (defaultFormat != null) + return defaultFormat; + // Update for multiworld +// WorldGroup group = CMI.getInstance().getEconomyManager().getWorldGroup(worldName); + WorldGroup group = getDefaultGroup(); + try { + if (group.isSwitchPlaces()) + defaultFormat = new DecimalFormat(group.getCurrencyFormat(), new DecimalFormatSymbols(Locale.GERMANY)); + else + defaultFormat = new DecimalFormat(group.getCurrencyFormat(), new DecimalFormatSymbols(Locale.ENGLISH)); + } catch (Exception e) { + } + defaultFormat.setRoundingMode(RoundingMode.FLOOR); + return defaultFormat; } public void loadConfig() { @@ -143,47 +223,47 @@ public void loadConfig() { } public boolean isCustomWorldsEnabled() { - return CustomWorldsEnabled; + return CustomWorldsEnabled; } public boolean isEnabled() { - return Enabled; + return Enabled; } public void setEnabled(boolean enabled) { - Enabled = enabled; + Enabled = enabled; } public VaultManager getVaultManager() { - return vmanager; + return vmanager; } public boolean isConfirmation() { - return Confirmation; + return Confirmation; } public List getBalTopExclude() { - return BalTopExclude; + return BalTopExclude; } public void setBalTopExclude(List balTopExclude) { - BalTopExclude = balTopExclude; + BalTopExclude = balTopExclude; } public Boolean isRecalculatingTop() { - return recalculatingTop; + return recalculatingTop; } public void setRecalculatingTop(boolean recalculatingTop) { - this.recalculatingTop = recalculatingTop; + this.recalculatingTop = recalculatingTop; } public Double getMaxChequeValue() { - return MaxChequeValue; + return MaxChequeValue; } public Double getTotalServerMoney() { - return totalServerMoney; + return totalServerMoney; } // public String getGlobalPlacing() { @@ -191,209 +271,198 @@ public Double getTotalServerMoney() { // } public WorldGroup getDefaultGroup() { - return defaultGroup; + return defaultGroup; } public enum EconResponseType { - SUCCESS, FAILURE, NOT_IMPLEMENTED; + SUCCESS, FAILURE, NOT_IMPLEMENTED; } public class CMIEconomyResponse { - private double amount; - private double balance; - private EconResponseType type; + private double amount; + private double balance; + private EconResponseType type; - public CMIEconomyResponse(double amount, double balance, EconResponseType type) { - this.amount = amount; - this.balance = balance; - this.type = type; - } + public CMIEconomyResponse(double amount, double balance, EconResponseType type) { + this.amount = amount; + this.balance = balance; + this.type = type; + } - public double getAmount() { - return amount; - } + public double getAmount() { + return amount; + } - public double getBalance() { - return balance; - } + public double getBalance() { + return balance; + } - public EconResponseType getType() { - return type; - } + public EconResponseType getType() { + return type; + } } public class WorldGroup { - private Double StartingAmount = 0D; - private Double MinimalAmount = 0D; - private Double MaximumAmount = 100D; - private Double MinimalPay = 0.5D; - private String CurrencyName = "Euro"; - private String CurrencySymbol = "€"; - private String CurrencyFormat = "###,##0.00"; - private String Placing = "[money][symbol]"; - private boolean switchPlaces = false; - private boolean UseShortNumbers = false; - private boolean fractions = true; - private HashMap ShortNumbersSuffixes = new HashMap(); - private String name; - - public WorldGroup(String name) { - this.name = name; - } - - public Double getStartingAmount() { - return StartingAmount; - } - - public WorldGroup setStartingAmount(Double startingAmount) { - StartingAmount = startingAmount; - return this; - } - - public Double getMinimalAmount() { - return MinimalAmount; - } - - public WorldGroup setMinimalAmount(Double minimalAmount) { - MinimalAmount = minimalAmount; - return this; - } - - public Double getMaximumAmount() { - return MaximumAmount; - } - - public WorldGroup setMaximumAmount(Double maximumAmount) { - if (maximumAmount == -1) - MaximumAmount = Double.MAX_VALUE; - else - MaximumAmount = maximumAmount; - return this; - } - - public String getCurrencyName() { - return CurrencyName; - } - - public WorldGroup setCurrencyName(String currencyName) { - CurrencyName = currencyName; - return this; - } - - public String getCurrencySymbol() { - return CurrencySymbol; - } - - public WorldGroup setCurrencySymbol(String currencySymbol) { - CurrencySymbol = currencySymbol; - return this; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getCurrencyFormat() { - return CurrencyFormat; - } - - public WorldGroup setCurrencyFormat(String currencyFormat) { - CurrencyFormat = currencyFormat; - return this; - } - - public boolean isSwitchPlaces() { - return switchPlaces; - } - - public WorldGroup setSwitchPlaces(boolean switchPlaces) { - this.switchPlaces = switchPlaces; - return this; - } - - public String getPlacing() { - return Placing; - } - - public WorldGroup setPlacing(String Placing) { - this.Placing = Placing; - return this; - } - - public boolean isUseShortNumbers() { - return UseShortNumbers; - } - - public WorldGroup setUseShortNumbers(boolean useShortNumners) { - UseShortNumbers = useShortNumners; - return this; - } - - public HashMap getShortNumbersSuffixes() { - return ShortNumbersSuffixes; - } - - public WorldGroup setShortNumbersSuffixes(HashMap shortNumbersSuffixes) { - ShortNumbersSuffixes = shortNumbersSuffixes; - return this; - } - - public Double getMinimalPay() { - return MinimalPay; - } - - public WorldGroup setMinimalPay(Double minimalPay) { - MinimalPay = minimalPay; - return this; - } - - public boolean isFractions() { - return fractions; - } - - public WorldGroup setFractions(boolean fractions) { - this.fractions = fractions; - return this; - } + private Double StartingAmount = 0D; + private Double MinimalAmount = 0D; + private Double MaximumAmount = 100D; + private Double MinimalPay = 0.5D; + private String CurrencyName = "Euro"; + private String CurrencySymbol = "€"; + private String CurrencyFormat = "###,##0.00"; + private String Placing = "[money][symbol]"; + private boolean switchPlaces = false; + private boolean UseShortNumbers = false; + private boolean fractions = true; + private HashMap ShortNumbersSuffixes = new HashMap(); + private String name; + + public WorldGroup(String name) { + this.name = name; + } + + public Double getStartingAmount() { + return StartingAmount; + } + + public WorldGroup setStartingAmount(Double startingAmount) { + StartingAmount = startingAmount; + return this; + } + + public Double getMinimalAmount() { + return MinimalAmount; + } + + public WorldGroup setMinimalAmount(Double minimalAmount) { + MinimalAmount = minimalAmount; + return this; + } + + public Double getMaximumAmount() { + return MaximumAmount; + } + + public WorldGroup setMaximumAmount(Double maximumAmount) { + if (maximumAmount == -1) + MaximumAmount = Double.MAX_VALUE; + else + MaximumAmount = maximumAmount; + return this; + } + + public String getCurrencyName() { + return CurrencyName; + } + + public WorldGroup setCurrencyName(String currencyName) { + CurrencyName = currencyName; + return this; + } + + public String getCurrencySymbol() { + return CurrencySymbol; + } + + public WorldGroup setCurrencySymbol(String currencySymbol) { + CurrencySymbol = currencySymbol; + return this; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCurrencyFormat() { + return CurrencyFormat; + } + + public WorldGroup setCurrencyFormat(String currencyFormat) { + CurrencyFormat = currencyFormat; + return this; + } + + public boolean isSwitchPlaces() { + return switchPlaces; + } + + public WorldGroup setSwitchPlaces(boolean switchPlaces) { + this.switchPlaces = switchPlaces; + return this; + } + + public String getPlacing() { + return Placing; + } + + public WorldGroup setPlacing(String Placing) { + this.Placing = Placing; + return this; + } + + public boolean isUseShortNumbers() { + return UseShortNumbers; + } + + public WorldGroup setUseShortNumbers(boolean useShortNumners) { + UseShortNumbers = useShortNumners; + return this; + } + + public HashMap getShortNumbersSuffixes() { + return ShortNumbersSuffixes; + } + + public WorldGroup setShortNumbersSuffixes(HashMap shortNumbersSuffixes) { + ShortNumbersSuffixes = shortNumbersSuffixes; + return this; + } + + public Double getMinimalPay() { + return MinimalPay; + } + + public WorldGroup setMinimalPay(Double minimalPay) { + MinimalPay = minimalPay; + return this; + } + + public boolean isFractions() { + return fractions; + } + + public WorldGroup setFractions(boolean fractions) { + this.fractions = fractions; + return this; + } } File file = null; Writer writer = null; public void closeStream() { - if (writer != null) { - try { - writer.flush(); - } catch (IOException e1) { - e1.printStackTrace(); - } - try { - writer.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } + } public enum CMIMoneyLogType { - Unknown, Transfer; + Unknown, Transfer; - private boolean enabled; + private boolean enabled; - CMIMoneyLogType() { - } + CMIMoneyLogType() { + } - public boolean isEnabled() { - return enabled; - } + public boolean isEnabled() { + return enabled; + } - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } } boolean checkedOldFile = false; @@ -404,60 +473,60 @@ public void moneyLog(CMIUser targetUser, CMIUser sourceUser, double change, CMIM } public boolean isTownyPresent() { - return townyPresent; + return townyPresent; } public String getTownyTownPrefix() { - return townyTownPrefix; + return townyTownPrefix; } public void setTownyTownPrefix(String townyTownPrefix) { - this.townyTownPrefix = townyTownPrefix; + this.townyTownPrefix = townyTownPrefix; } public String getTownyNationPrefix() { - return townyNationPrefix; + return townyNationPrefix; } public void setTownyNationPrefix(String townyNationPrefix) { - this.townyNationPrefix = townyNationPrefix; + this.townyNationPrefix = townyNationPrefix; } public boolean isBalTopIncludeFakes() { - return BalTopIncludeFakes; + return BalTopIncludeFakes; } public boolean isTownyAccount(String playerName) { - if (playerName == null) - return false; + if (playerName == null) + return false; - return plugin.getEconomyManager().isTownyPresent() && (playerName.startsWith(plugin.getEconomyManager().getTownyTownPrefix()) || - playerName.startsWith(plugin.getEconomyManager().getTownyNationPrefix()) || - playerName.startsWith(plugin.getEconomyManager().getTownyDebtPrefix()) || - playerName.equalsIgnoreCase(plugin.getEconomyManager().getTownyClosedEconomyName())); + return plugin.getEconomyManager().isTownyPresent() && (playerName.startsWith(plugin.getEconomyManager().getTownyTownPrefix()) || + playerName.startsWith(plugin.getEconomyManager().getTownyNationPrefix()) || + playerName.startsWith(plugin.getEconomyManager().getTownyDebtPrefix()) || + playerName.equalsIgnoreCase(plugin.getEconomyManager().getTownyClosedEconomyName())); } public String getTownyClosedEconomyName() { - return townyClosed_economy; + return townyClosed_economy; } public boolean isBalTopDisplayWithShorts() { - return BalTopDisplayWithShorts; + return BalTopDisplayWithShorts; } public String getTownyDebtPrefix() { - return townyDebtPrefix; + return townyDebtPrefix; } public void setTownyDebtPrefix(String townyDebtPrefix) { - this.townyDebtPrefix = townyDebtPrefix; + this.townyDebtPrefix = townyDebtPrefix; } public boolean isChequePaperRequired() { - return ChequePaper; + return ChequePaper; } public boolean isChequeRequiresPermission() { - return ChequePermission; + return ChequePermission; } } diff --git a/src/com/Zrips/CMI/Modules/Economy/VaultHandler.java b/src/com/Zrips/CMI/Modules/Economy/VaultHandler.java index e979767..6f9eb10 100644 --- a/src/com/Zrips/CMI/Modules/Economy/VaultHandler.java +++ b/src/com/Zrips/CMI/Modules/Economy/VaultHandler.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.List; -import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -17,7 +16,6 @@ import com.Zrips.CMI.Containers.CMIUser; import net.milkbowl.vault.economy.AbstractEconomy; -import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.EconomyResponse; public class VaultHandler extends AbstractEconomy { @@ -27,339 +25,300 @@ public class VaultHandler extends AbstractEconomy { public VaultHandler(CMI plugin) { - if (cmi == null) { - this.cmi = plugin; - EconomyServerListener listener = new EconomyServerListener(this); - Bukkit.getServer().getPluginManager().registerEvents(listener, plugin); - } -// plugin.log("Vault support enabled."); } public VaultHandler(Plugin plugin) { - this.plugin = plugin; - Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin); - - // Load Plugin in case it was loaded before - if (cmi == null) { - Plugin cm = plugin.getServer().getPluginManager().getPlugin("CMI"); - if (cm != null && cm.isEnabled()) { - cmi = (CMI) cm; - CMI.getInstance().consoleMessage(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name)); - } - } } public void setCMI(CMI cmi) { - this.cmi = cmi; + this.cmi = cmi; } @Override public boolean isEnabled() { - return this.cmi != null; + return this.cmi != null; } @Override public String getName() { - return "CMIEconomy"; + return "CMIEconomy"; } public String TrA(double amount) { - DecimalFormat decimalFormat = CMI.getInstance().getEconomyManager().getMoneyFormat(); - return decimalFormat.format(amount); + DecimalFormat decimalFormat = CMI.getInstance().getEconomyManager().getMoneyFormat(); + return decimalFormat.format(amount); } @Override public String format(double amount) { - return TrA(amount); + return TrA(amount); } @Override public String currencyNameSingular() { - return ""; + return ""; } @Override public String currencyNamePlural() { - return ""; + return ""; } @Override public double getBalance(String playerName) { - CMIUser user = cmi.getPlayerManager().getUser(playerName, false, true, false, true); - return getAccountBalance(user); + CMIUser user = cmi.getPlayerManager().getUser(playerName, false, true, false, true); + return getAccountBalance(user); } @Override public double getBalance(OfflinePlayer offlinePlayer) { - CMIUser user = cmi.getPlayerManager().getUser(offlinePlayer); - return getAccountBalance(user); + CMIUser user = cmi.getPlayerManager().getUser(offlinePlayer); + return getAccountBalance(user); } private static double getAccountBalance(CMIUser user) { - if (user == null) - return 0.0D; - return user.getBalance().doubleValue(); + if (user == null) + return 0.0D; + return user.getBalance().doubleValue(); } @Override public EconomyResponse withdrawPlayer(String playerName, double amount) { - CMIUser user = cmi.getPlayerManager().getUser(playerName, false, true, false, true); - return withdraw(user, amount); + CMIUser user = cmi.getPlayerManager().getUser(playerName, false, true, false, true); + return withdraw(user, amount); } @Override public EconomyResponse withdrawPlayer(OfflinePlayer offlinePlayer, double amount) { - CMIUser user = cmi.getPlayerManager().getUser(offlinePlayer); - return withdraw(user, amount); + CMIUser user = cmi.getPlayerManager().getUser(offlinePlayer); + return withdraw(user, amount); } private static EconomyResponse withdraw(CMIUser user, double amount) { - if (user == null) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.FAILURE, "Account doesn't exist"); - } - if (amount < 0.0D) { - return new EconomyResponse(0.0D, user.getBalance(), EconomyResponse.ResponseType.FAILURE, "Cannot withdraw negative funds"); - } - if (user.hasMoney(amount)) { - Double before = user.getBalance(); - user.withdraw(amount); -// fireEvent(user, before, user.getBalance(), "Withdraw"); - return new EconomyResponse(amount, user.getBalance(), EconomyResponse.ResponseType.SUCCESS, ""); - } - return new EconomyResponse(0.0D, user.getBalance(), EconomyResponse.ResponseType.FAILURE, "Insufficient funds"); + return new EconomyResponse(0.0D, user.getBalance(), EconomyResponse.ResponseType.FAILURE, "Insufficient funds"); } @Override public EconomyResponse depositPlayer(String playerName, double amount) { - CMIUser user = cmi.getPlayerManager().getUser(playerName, false, true, false, true); - return deposit(user, amount); + CMIUser user = cmi.getPlayerManager().getUser(playerName, false, true, false, true); + return deposit(user, amount); } @Override public EconomyResponse depositPlayer(OfflinePlayer offlinePlayer, double amount) { - CMIUser user = cmi.getPlayerManager().getUser(offlinePlayer); - return deposit(user, amount); + CMIUser user = cmi.getPlayerManager().getUser(offlinePlayer); + return deposit(user, amount); } private static EconomyResponse deposit(CMIUser user, double amount) { - if (user == null) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.FAILURE, "Account doesn't exist"); - } - if (amount < 0.0D) { - return new EconomyResponse(0.0D, user.getBalance(), EconomyResponse.ResponseType.FAILURE, "Cannot deposit negative funds"); - } - - Double before = user.getBalance(); - user.deposit(amount); -// fireEvent(user, before, user.getBalance(), "Deposit"); - return new EconomyResponse(amount, user.getBalance(), EconomyResponse.ResponseType.SUCCESS, ""); + return new EconomyResponse(amount, user.getBalance(), EconomyResponse.ResponseType.SUCCESS, ""); } @Override public boolean has(String playerName, double amount) { - return getBalance(playerName) >= amount; + return getBalance(playerName) >= amount; } @Override public boolean has(OfflinePlayer offlinePlayer, double amount) { - return getBalance(offlinePlayer) >= amount; + return getBalance(offlinePlayer) >= amount; } @Override public EconomyResponse createBank(String name, String player) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } @Override public EconomyResponse createBank(String name, OfflinePlayer offlinePlayer) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } @Override public EconomyResponse deleteBank(String name) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } @Override public EconomyResponse bankHas(String name, double amount) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } @Override public EconomyResponse bankWithdraw(String name, double amount) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } @Override public EconomyResponse bankDeposit(String name, double amount) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } @Override public EconomyResponse isBankOwner(String name, String playerName) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } @Override public EconomyResponse isBankOwner(String name, OfflinePlayer offlinePlayer) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } @Override public EconomyResponse isBankMember(String name, String playerName) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } @Override public EconomyResponse isBankMember(String name, OfflinePlayer offlinePlayer) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } @Override public EconomyResponse bankBalance(String name) { - return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); + return new EconomyResponse(0.0D, 0.0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "CMI currently don't support bank's"); } @Override public List getBanks() { - return new ArrayList(); + return new ArrayList(); } @Override public boolean hasBankSupport() { - return false; + return false; } @Override public boolean hasAccount(String playerName) { - return CMI.getInstance().getPlayerManager().getUser(playerName) != null; + return CMI.getInstance().getPlayerManager().getUser(playerName) != null; } @Override public boolean hasAccount(OfflinePlayer offlinePlayer) { - return CMI.getInstance().getPlayerManager().getUser(offlinePlayer) != null; + return CMI.getInstance().getPlayerManager().getUser(offlinePlayer) != null; } @Override public boolean createPlayerAccount(String playerName) { - if (hasAccount(playerName)) - return true; - return cmi.getPlayerManager().getUser(playerName, true, false, true, true) != null; + if (hasAccount(playerName)) + return true; + return cmi.getPlayerManager().getUser(playerName, true, false, true, true) != null; } @Override public boolean createPlayerAccount(OfflinePlayer offlinePlayer) { - if (hasAccount(offlinePlayer)) - return true; - return cmi.getPlayerManager().getUser(offlinePlayer) != null; + if (hasAccount(offlinePlayer)) + return true; + return cmi.getPlayerManager().getUser(offlinePlayer) != null; } @Override public int fractionalDigits() { - return -1; + return -1; } @Override public boolean hasAccount(String playerName, String worldName) { - return hasAccount(playerName); + return hasAccount(playerName); } @Override public boolean hasAccount(OfflinePlayer offlinePlayer, String worldName) { - return hasAccount(offlinePlayer); + return hasAccount(offlinePlayer); } @Override public double getBalance(String playerName, String worldName) { - return getBalance(playerName); + return getBalance(playerName); } @Override public double getBalance(OfflinePlayer offlinePlayer, String worldName) { - return getBalance(offlinePlayer); + return getBalance(offlinePlayer); } @Override public boolean has(String playerName, String worldName, double amount) { - return has(playerName, amount); + return has(playerName, amount); } @Override public boolean has(OfflinePlayer offlinePlayer, String worldName, double amount) { - return has(offlinePlayer, amount); + return has(offlinePlayer, amount); } @Override public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) { - return withdrawPlayer(playerName, amount); + return withdrawPlayer(playerName, amount); } @Override public EconomyResponse withdrawPlayer(OfflinePlayer offlinePlayer, String worldName, double amount) { - return withdrawPlayer(offlinePlayer, amount); + return withdrawPlayer(offlinePlayer, amount); } @Override public EconomyResponse depositPlayer(String playerName, String worldName, double amount) { - return depositPlayer(playerName, amount); + return depositPlayer(playerName, amount); } @Override public EconomyResponse depositPlayer(OfflinePlayer offlinePlayer, String worldName, double amount) { - return depositPlayer(offlinePlayer, amount); + return depositPlayer(offlinePlayer, amount); } @Override public boolean createPlayerAccount(String playerName, String worldName) { - return createPlayerAccount(playerName); + return createPlayerAccount(playerName); } @Override public boolean createPlayerAccount(OfflinePlayer offlinePlayer, String worldName) { - return createPlayerAccount(offlinePlayer); + return createPlayerAccount(offlinePlayer); } public class EconomyServerListener implements Listener { - VaultHandler economy = null; - - public EconomyServerListener(VaultHandler economy) { - this.economy = economy; - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPluginEnable(PluginEnableEvent event) { - if (economy.cmi == null) { - Plugin cm = event.getPlugin(); - - if (cm.getDescription().getName().equals("CMI")) { - CMI cmi = (CMI) cm; - if (cmi.getEconomyManager().isEnabled()) { - economy.cmi = cmi; - CMI.getInstance().consoleMessage("&2" + String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name)); - } else { - plugin.getServer().getServicesManager().unregister(Economy.class, economy); - if (CMI.getInstance().getEconomyManager().getVaultManager() != null) - CMI.getInstance().getEconomyManager().getVaultManager().setupVault(); - } - } - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPluginDisable(PluginDisableEvent event) { - if (economy.cmi != null) { - if (event.getPlugin().getDescription().getName().equals("CMI")) { - try { - plugin.getServer().getServicesManager().unregister(Economy.class, economy); - } catch (Exception e) { - } - economy.cmi = null; - try { - CMI.getInstance().consoleMessage("&2" + String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name)); - } catch (Exception e) { - } - } - } - } + VaultHandler economy = null; + + public EconomyServerListener(VaultHandler economy) { + this.economy = economy; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPluginEnable(PluginEnableEvent event) { + if (economy.cmi == null) { + Plugin cm = event.getPlugin(); + + if (cm.getDescription().getName().equals("CMI")) { + CMI cmi = (CMI) cm; + if (cmi.getEconomyManager().isEnabled()) { + economy.cmi = cmi; + CMI.getInstance().consoleMessage("&2" + String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name)); + } else { + plugin.getServer().getServicesManager().unregister(Economy.class, economy); + if (CMI.getInstance().getEconomyManager().getVaultManager() != null) + CMI.getInstance().getEconomyManager().getVaultManager().setupVault(); + } + } + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPluginDisable(PluginDisableEvent event) { + if (economy.cmi != null) { + if (event.getPlugin().getDescription().getName().equals("CMI")) { + try { + plugin.getServer().getServicesManager().unregister(Economy.class, economy); + } catch (Exception e) { + } + economy.cmi = null; + try { + CMI.getInstance().consoleMessage("&2" + String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name)); + } catch (Exception e) { + } + } + } + } } } diff --git a/src/com/Zrips/CMI/Modules/Economy/VaultManager.java b/src/com/Zrips/CMI/Modules/Economy/VaultManager.java index 3295161..e8db6f5 100644 --- a/src/com/Zrips/CMI/Modules/Economy/VaultManager.java +++ b/src/com/Zrips/CMI/Modules/Economy/VaultManager.java @@ -1,10 +1,5 @@ package com.Zrips.CMI.Modules.Economy; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.RegisteredServiceProvider; - import com.Zrips.CMI.CMI; import net.milkbowl.vault.economy.Economy; @@ -16,7 +11,7 @@ public class VaultManager { private boolean supportsCmi = false; public VaultManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } // private Economy vaultHandler = null; @@ -24,35 +19,34 @@ public VaultManager(CMI plugin) { private Economy economy = null; public enum EconomySetupResponse { - Vault, NoVault, NoVaultEconomy, CMI; + Vault, NoVault, NoVaultEconomy, CMI; } public EconomySetupResponse setupVault() { - - return economy != null ? EconomySetupResponse.Vault : EconomySetupResponse.NoVaultEconomy; + return economy != null ? EconomySetupResponse.Vault : EconomySetupResponse.NoVaultEconomy; } public Economy getVaultEconomy() { - return economy; + return economy; } public boolean isVaultEnabled() { - return economy != null; + return economy != null; } public String format(Double money) { - if (money == null) - return "0"; - if (this.economy == null) - return String.valueOf(money); - return this.economy.format(money); + if (money == null) + return "0"; + if (this.economy == null) + return String.valueOf(money); + return this.economy.format(money); } public String getVersion() { - return version; + return version; } public boolean isSupportsCmi() { - return supportsCmi; + return supportsCmi; } } diff --git a/src/com/Zrips/CMI/Modules/Elytra/ElytraBoostListener.java b/src/com/Zrips/CMI/Modules/Elytra/ElytraBoostListener.java index 5ef1d43..29a5595 100644 --- a/src/com/Zrips/CMI/Modules/Elytra/ElytraBoostListener.java +++ b/src/com/Zrips/CMI/Modules/Elytra/ElytraBoostListener.java @@ -4,10 +4,18 @@ import java.util.UUID; import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Particle; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityToggleGlideEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.Speed; +import com.Zrips.CMI.events.CMIArmorChangeEvent; public class ElytraBoostListener implements Listener { @@ -18,10 +26,62 @@ public class ElytraBoostListener implements Listener { HashMap speedMap = new HashMap(); public ElytraBoostListener(CMI plugin) { - this.plugin = plugin; - for (Effect one : Effect.values()) { - if (one.name().equalsIgnoreCase("ENDERDRAGON_SHOOT")) - eff = one; - } + this.plugin = plugin; + for (Effect one : Effect.values()) { + if (one.name().equalsIgnoreCase("ENDERDRAGON_SHOOT")) + eff = one; + } + } + + @EventHandler + public void onPlayerSpeed(PlayerMoveEvent event) { + + } + + @EventHandler + public void onInventoryClick(CMIArmorChangeEvent event) { + + } + + public static double xPosYaw(double time, double radius, double yaw) { + return Math.sin(time) * radius * Math.cos(Math.PI / 180 * yaw); + } + + public static double yPosYaw(double time, double radius) { + return Math.cos(time) * radius; + } + + public static double zPosYaw(double time, double radius, double yaw) { + return Math.sin(time) * radius * Math.sin(Math.PI / 180 * yaw); + } + + public double zPosPitch2(double time, double radius, double pitch) { + return Math.sin(time) * radius * Math.sin(Math.PI / 180 * pitch); + } + + public void spawnCircle(final Player player) { + spawnCircle(player.getLocation()); + } + + public static void spawnCircle(Location loc) { + + } + + @EventHandler + public void EntityToggleGlideEvent(EntityToggleGlideEvent event) { + + } + + @EventHandler + public void onElytraFlight(PlayerInteractEvent event) { + + } + + private static void setVel(Player player, double multy) { + player.setVelocity(player.getVelocity().add(player.getLocation().getDirection().multiply(multy))); + } + + private static void showParticle(Player player, Particle particle) { + player.getWorld().spawnParticle(particle, player.getLocation(), 1, 0, 0, 0, 0); } } \ No newline at end of file diff --git a/src/com/Zrips/CMI/Modules/Elytra/ElytraExploitListener.java b/src/com/Zrips/CMI/Modules/Elytra/ElytraExploitListener.java index 20b61b2..b38d9a8 100644 --- a/src/com/Zrips/CMI/Modules/Elytra/ElytraExploitListener.java +++ b/src/com/Zrips/CMI/Modules/Elytra/ElytraExploitListener.java @@ -1,6 +1,10 @@ package com.Zrips.CMI.Modules.Elytra; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; import com.Zrips.CMI.CMI; @@ -9,7 +13,16 @@ public class ElytraExploitListener implements Listener { private CMI plugin; public ElytraExploitListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.HIGHEST) + public void onElytraFlightTrident(PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void DamageEvent(EntityDamageByEntityEvent event) { + + } } \ No newline at end of file diff --git a/src/com/Zrips/CMI/Modules/Elytra/ElytraLaunchListener.java b/src/com/Zrips/CMI/Modules/Elytra/ElytraLaunchListener.java index a1de48c..de782c1 100644 --- a/src/com/Zrips/CMI/Modules/Elytra/ElytraLaunchListener.java +++ b/src/com/Zrips/CMI/Modules/Elytra/ElytraLaunchListener.java @@ -3,7 +3,11 @@ import java.util.HashMap; import java.util.UUID; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; import com.Zrips.CMI.CMI; @@ -12,38 +16,44 @@ public class ElytraLaunchListener implements Listener { private CMI plugin; public ElytraLaunchListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } private class CMILaunch { - private Long started; - private Long lastCharge; - - public Long getStarted() { - return started; - } - - public Long getLastCharge() { - return lastCharge; - } - - public void setLastCharge() { - if (started == null) - started = System.currentTimeMillis(); - if (this.lastCharge != null && this.lastCharge + 333 < System.currentTimeMillis()) { - started = System.currentTimeMillis(); - } else - this.lastCharge = System.currentTimeMillis(); - } - - public boolean isFullyCharged() { - if (started == null || lastCharge == null) - return false; - return started + (plugin.getConfigManager().ElytraLaunchTime * 1000) < System.currentTimeMillis(); - } + private Long started; + private Long lastCharge; + + public Long getStarted() { + return started; + } + + public Long getLastCharge() { + return lastCharge; + } + + public void setLastCharge() { + + } + + public boolean isFullyCharged() { + return false; + } } HashMap map = new HashMap(); + @EventHandler + public void onSneakEnd(PlayerToggleSneakEvent event) { + + } + + @EventHandler + public void onMoveRemove(PlayerMoveEvent event) { + + } + + @EventHandler + public void onElytraLaunch(PlayerInteractEvent event) { + } } \ No newline at end of file diff --git a/src/com/Zrips/CMI/Modules/Enchants/EnchantListener.java b/src/com/Zrips/CMI/Modules/Enchants/EnchantListener.java index 17c87e4..cef07ed 100644 --- a/src/com/Zrips/CMI/Modules/Enchants/EnchantListener.java +++ b/src/com/Zrips/CMI/Modules/Enchants/EnchantListener.java @@ -1,6 +1,11 @@ package com.Zrips.CMI.Modules.Enchants; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.enchantment.PrepareItemEnchantEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; import com.Zrips.CMI.CMI; @@ -8,8 +13,21 @@ public class EnchantListener implements Listener { private CMI plugin; public EnchantListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.MONITOR) + public void PrepareItemEnchantEvent(PrepareItemEnchantEvent event) { + } + + @EventHandler(priority = EventPriority.MONITOR) + public void InventoryCloseEvent(InventoryCloseEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerInteractEntityEvent(PlayerInteractAtEntityEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Enchants/EnchantManager.java b/src/com/Zrips/CMI/Modules/Enchants/EnchantManager.java index 48bc86c..bd0e9fc 100644 --- a/src/com/Zrips/CMI/Modules/Enchants/EnchantManager.java +++ b/src/com/Zrips/CMI/Modules/Enchants/EnchantManager.java @@ -2,7 +2,6 @@ import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; import org.bukkit.enchantments.Enchantment; @@ -19,59 +18,77 @@ public class EnchantManager { private boolean enchantLimitEnabled = false; public EnchantManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void loadConfig() { - - } + } public Integer getMaxLevel(Enchantment enchant) { - - return 0; + return 0; } public void reEnableEnchantsOnDisable() { - for (Entry one : disabled.entrySet()) { - plugin.getRef().manageEnchantment(one.getValue(), false); - } } public void disableEnchantsOnLoad() { - for (Entry one : disabled.entrySet()) { - plugin.getRef().manageEnchantment(one.getValue(), true); - } } public HashMap getDisabled() { - return disabled; + return disabled; + } + + public boolean isDisabled(Enchantment disabled) { + String name = disabled.getName(); + if (name == null) + return false; + if (name.isEmpty()) + return false; + if (name == " ") + return false; + return this.disabled.containsKey(disabled.getName()); } public void addDisabled(Enchantment disabled) { - + String name = disabled.getName(); + if (name == null) + return; + if (name.isEmpty()) + return; + if (name == " ") + return; + this.disabled.put(disabled.getName(), disabled); } public void removeDisabled(Enchantment disabled) { + String name = disabled.getName(); + if (name == null) + return; + if (name.isEmpty()) + return; + if (name == " ") + return; + this.disabled.remove(disabled.getName()); } private void loadDisabledEnchants() { - + } public void updateConfig() { - + } public boolean isRequireSpecificPermission() { - return RequireSpecificPermission; + return RequireSpecificPermission; } public boolean isPermissionLevelLimit() { - return PermissionLevelLimit; + return PermissionLevelLimit; } public boolean isEnchantLimitEnabled() { - return enchantLimitEnabled; + return enchantLimitEnabled; } } diff --git a/src/com/Zrips/CMI/Modules/EventActions/EventActionListener.java b/src/com/Zrips/CMI/Modules/EventActions/EventActionListener.java index 0e88b11..bee9572 100644 --- a/src/com/Zrips/CMI/Modules/EventActions/EventActionListener.java +++ b/src/com/Zrips/CMI/Modules/EventActions/EventActionListener.java @@ -1,13 +1,119 @@ package com.Zrips.CMI.Modules.EventActions; +import java.util.HashMap; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerBedEnterEvent; +import org.bukkit.event.player.PlayerBedLeaveEvent; +import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerGameModeChangeEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.player.PlayerLevelChangeEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerTeleportEvent; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Modules.EventActions.EventActionManager.eventAction; +import com.Zrips.CMI.Modules.Worlds.CMIWorld; +import com.Zrips.CMI.events.CMIPlayerBanEvent; +import com.Zrips.CMI.events.CMIPvPEndEventAsync; +import com.Zrips.CMI.events.CMIPvPStartEventAsync; public class EventActionListener implements Listener { private CMI plugin; public EventActionListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void CMIPvPEndEventAsync(CMIPvPEndEventAsync event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void CMIPvPStartEventAsync(CMIPvPStartEventAsync event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerFirstJoinEvent(PlayerJoinEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerJoinEvent(PlayerJoinEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerDeathEvent(PlayerDeathEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerRespawnEvent(PlayerRespawnEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerQuitEvent(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerTeleportEvent(PlayerTeleportEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerBedEnterEvent(PlayerBedEnterEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerBedLeaveEvent(PlayerBedLeaveEvent event) { + + } + + HashMap last = new HashMap(); + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerVoidFallEvent(PlayerMoveEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerChangedWorldEvent(PlayerChangedWorldEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerGameModeChangeEvent(PlayerGameModeChangeEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerKickEvent(PlayerKickEvent event) { + plugin.getEventActionManager().performCommands(eventAction.playerKick, event.getPlayer()); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void CMIPlayerBanEvent(CMIPlayerBanEvent event) { + plugin.getEventActionManager().performCommands(eventAction.playerBan, Bukkit.getPlayer(event.getBanned())); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerLevelChangeEvent(PlayerLevelChangeEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/EventActions/EventActionListener19.java b/src/com/Zrips/CMI/Modules/EventActions/EventActionListener19.java index a347252..1f513c0 100644 --- a/src/com/Zrips/CMI/Modules/EventActions/EventActionListener19.java +++ b/src/com/Zrips/CMI/Modules/EventActions/EventActionListener19.java @@ -1,8 +1,13 @@ package com.Zrips.CMI.Modules.EventActions; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityToggleGlideEvent; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Modules.EventActions.EventActionManager.eventAction; public class EventActionListener19 implements Listener { private CMI plugin; @@ -10,4 +15,9 @@ public class EventActionListener19 implements Listener { public EventActionListener19(CMI plugin) { this.plugin = plugin; } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void EntityToggleGlideEvent(EntityToggleGlideEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/EventActions/EventActionManager.java b/src/com/Zrips/CMI/Modules/EventActions/EventActionManager.java index c813842..38d4091 100644 --- a/src/com/Zrips/CMI/Modules/EventActions/EventActionManager.java +++ b/src/com/Zrips/CMI/Modules/EventActions/EventActionManager.java @@ -1,11 +1,17 @@ package com.Zrips.CMI.Modules.EventActions; +import java.io.File; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Containers.Snd; +import net.Zrips.CMILib.FileHandler.ConfigReader; +import com.Zrips.CMI.events.CMIEventCommandEvent; public class EventActionManager { @@ -29,6 +35,7 @@ public enum eventAction { playerPreWorldChange, playerGameModeChange, playerKick, + playerBan, playerLevelChange, voidFall, elytraStartGlide, @@ -73,8 +80,6 @@ public boolean isIncludeSource() { } } -//bossbar still shows after finish - public void performCommands(eventAction action, Player player) { performCommands(action, player, null); } diff --git a/src/com/Zrips/CMI/Modules/FindBiome/FindBiomeManager.java b/src/com/Zrips/CMI/Modules/FindBiome/FindBiomeManager.java index 201e2cb..c75550b 100644 --- a/src/com/Zrips/CMI/Modules/FindBiome/FindBiomeManager.java +++ b/src/com/Zrips/CMI/Modules/FindBiome/FindBiomeManager.java @@ -14,18 +14,21 @@ public class FindBiomeManager { // private static Integer count = 0; public FindBiomeManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public boolean stop(Player player) { - return false; + + return false; } public void start(FindBiomeInfo scan) { + } @SuppressWarnings("deprecation") private void loadChunk(final FindBiomeInfo scan) { } + } diff --git a/src/com/Zrips/CMI/Modules/FlightCharge/FlightCharge.java b/src/com/Zrips/CMI/Modules/FlightCharge/FlightCharge.java index ba5ac31..2d64ba1 100644 --- a/src/com/Zrips/CMI/Modules/FlightCharge/FlightCharge.java +++ b/src/com/Zrips/CMI/Modules/FlightCharge/FlightCharge.java @@ -14,63 +14,62 @@ public FlightCharge() { } public Double getCharge() { - return charge; + return charge; } public Double getSafeCharge() { - return charge == null ? 0D : charge; + return charge == null ? 0D : charge; } public void setCharge(Double charge) { + } public void addCharge(Double charge) { + } public void takeCharge(Double charge) { + } public Integer getMax() { - return CMI.getInstance().getFlightChargeManager().getMaxChargeLevel(); + return CMI.getInstance().getFlightChargeManager().getMaxChargeLevel(); } -// public void setMax(Integer max) { -// this.max = max; -// } - public Double getLastChange() { - return lastChange; + return lastChange; } public boolean isEnabled() { - return enabled; + return enabled; } public void setEnabled(boolean enabled) { - this.enabled = enabled; + this.enabled = enabled; } public Boolean isAutoRecharge() { - return autoRecharge == null ? false : autoRecharge; + return autoRecharge == null ? false : autoRecharge; } public void setAutoRecharge(Boolean autoRecharge) { - this.autoRecharge = autoRecharge; + this.autoRecharge = autoRecharge; } public void setAutoMoneyRecharge() { - moneyRecharge = true; + moneyRecharge = true; } public void setAutoExpRecharge() { - moneyRecharge = false; + moneyRecharge = false; } public boolean isMoneyAutoRecharge() { - return moneyRecharge == null || moneyRecharge; + return moneyRecharge == null || moneyRecharge; } public boolean isExpAutoRecharge() { - return moneyRecharge != null && !moneyRecharge; + return moneyRecharge != null && !moneyRecharge; } } diff --git a/src/com/Zrips/CMI/Modules/FlightCharge/FlightChargeManager.java b/src/com/Zrips/CMI/Modules/FlightCharge/FlightChargeManager.java index 5d3c9a1..0e6d730 100644 --- a/src/com/Zrips/CMI/Modules/FlightCharge/FlightChargeManager.java +++ b/src/com/Zrips/CMI/Modules/FlightCharge/FlightChargeManager.java @@ -12,7 +12,7 @@ public class FlightChargeManager { CMI plugin; public FlightChargeManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } // private boolean Enabled = false; @@ -34,11 +34,16 @@ public FlightChargeManager(CMI plugin) { private double autoRechargeAmount = 0; public void load() { - } public void process(Player player, Integer take) { + traveledDistance dinfo = FlightListener.distanceMap.get(player.getUniqueId()); + if (dinfo == null) { + dinfo = new traveledDistance(plugin.getPlayerManager().getUser(player)); + FlightListener.distanceMap.put(player.getUniqueId(), dinfo); + } + process(dinfo, take); } public void process(traveledDistance dinfo, Integer take) { @@ -52,7 +57,7 @@ private void autorecharge(CMIUser user) { public static final String flightChargeBossBar = "CMIFlightChargeBossBar"; public void updateBossBar(CMIUser user) { - + } private void updateBossBar(traveledDistance dinfo) { @@ -60,95 +65,95 @@ private void updateBossBar(traveledDistance dinfo) { } public double getExpRechargeCost() { - return ExpRechargeCost; + return ExpRechargeCost; } public void setExpRechargeCost(double expRechargeCost) { - ExpRechargeCost = expRechargeCost; + ExpRechargeCost = expRechargeCost; } public double getMoneyRechargeCost() { - return MoneyRechargeCost; + return MoneyRechargeCost; } public void setMoneyRechargeCost(double moneyRechargeCost) { - MoneyRechargeCost = moneyRechargeCost; + MoneyRechargeCost = moneyRechargeCost; } public int getMaxChargeLevel() { - return MaxChargeLevel; + return MaxChargeLevel; } public void setMaxChargeLevel(int maxChargeLevel) { - MaxChargeLevel = maxChargeLevel; + MaxChargeLevel = maxChargeLevel; } public int getDeductOnFallMulti() { - return DeductOnFallMulti; + return DeductOnFallMulti; } public void setDeductOnFallMulti(int deductOnFallMulti) { - DeductOnFallMulti = deductOnFallMulti; + DeductOnFallMulti = deductOnFallMulti; } public boolean isDamageOnFall() { - return DamageOnFall; + return DamageOnFall; } public void setDamageOnFall(boolean damageOnFall) { - DamageOnFall = damageOnFall; + DamageOnFall = damageOnFall; } public boolean isDamageOnToggle() { - return DamageOnToggle; + return DamageOnToggle; } public void setDamageOnToggle(boolean damageOnToggle) { - DamageOnToggle = damageOnToggle; + DamageOnToggle = damageOnToggle; } public boolean isKillOnFall() { - return KillOnFall; + return KillOnFall; } public void setKillOnFall(boolean killOnFall) { - KillOnFall = killOnFall; + KillOnFall = killOnFall; } public double getDeductOnIdling() { - return DeductOnIdling; + return DeductOnIdling; } public void setDeductOnIdling(int deductOnIdling) { - DeductOnIdling = deductOnIdling; + DeductOnIdling = deductOnIdling; } public boolean isFlightChargeEnabledByDefault() { - return FlightChargeEnabledByDefault; + return FlightChargeEnabledByDefault; } public void setFlightChargeEnabledByDefault(boolean flightChargeEnabledByDefault) { - FlightChargeEnabledByDefault = flightChargeEnabledByDefault; + FlightChargeEnabledByDefault = flightChargeEnabledByDefault; } public boolean isFlightChargeAutoSwitch() { - return FlightChargeAutoSwitch; + return FlightChargeAutoSwitch; } public CMIChatColor getGlowColor() { - return GlowColor; + return GlowColor; } public void setGlowColor(CMIChatColor glowColor) { - GlowColor = glowColor; + GlowColor = glowColor; } public double getAutoRechargeFrom() { - return autoRechargeFrom; + return autoRechargeFrom; } public double getAutoRechargeAmount() { - return autoRechargeAmount; + return autoRechargeAmount; } } diff --git a/src/com/Zrips/CMI/Modules/FlightCharge/FlightListener.java b/src/com/Zrips/CMI/Modules/FlightCharge/FlightListener.java index a0aaaca..99bbdaa 100644 --- a/src/com/Zrips/CMI/Modules/FlightCharge/FlightListener.java +++ b/src/com/Zrips/CMI/Modules/FlightCharge/FlightListener.java @@ -3,18 +3,83 @@ import java.util.HashMap; import java.util.UUID; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerGameModeChangeEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.PlayerToggleFlightEvent; import com.Zrips.CMI.CMI; +import net.Zrips.CMILib.BossBar.CMIBossBarHideEvent; + public class FlightListener implements Listener { private CMI plugin; static HashMap distanceMap = new HashMap(); public FlightListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerToggleFlightEvent(PlayerToggleFlightEvent event) { + + } + + public static HashMap fallDistanceMap = new HashMap(); + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerMoveEvent2(PlayerMoveEvent event) { + } + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerTeleportEvent(PlayerTeleportEvent event) { + + distanceMap.remove(event.getPlayer().getUniqueId()); + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerMoveEvent(PlayerMoveEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerQuitEvent(PlayerQuitEvent event) { + + } + @EventHandler(priority = EventPriority.HIGHEST) + public void PlayerJoinEvent(PlayerJoinEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerJoinEvent(PlayerChangedWorldEvent event) { + + } + + HashMap informed = new HashMap(); + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void PlayerGameModeChangeEvent(PlayerGameModeChangeEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void CMIBossBarHideEvent(CMIBossBarHideEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onRespawn(PlayerRespawnEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/FlightCharge/traveledDistance.java b/src/com/Zrips/CMI/Modules/FlightCharge/traveledDistance.java index 8e0dfa2..18eed30 100644 --- a/src/com/Zrips/CMI/Modules/FlightCharge/traveledDistance.java +++ b/src/com/Zrips/CMI/Modules/FlightCharge/traveledDistance.java @@ -11,29 +11,29 @@ public class traveledDistance { private Long time = 0L; traveledDistance(CMIUser user) { - this.user = user; - if (user.isOnline()) - updateLocation(); + this.user = user; + if (user.isOnline()) + updateLocation(); } public boolean toSoonToCheck() { - return System.currentTimeMillis() - time < 1000; + return System.currentTimeMillis() - time < 1000; } public void updateLocation() { + } public Double getDistanceTraveled() { - - return 0D; + return 0D; } public Long sinceLastUpdate() { - return System.currentTimeMillis() - time; + return System.currentTimeMillis() - time; } public CMIUser getUser() { - return user; + return user; } } diff --git a/src/com/Zrips/CMI/Modules/GeoIP/LookupService.java b/src/com/Zrips/CMI/Modules/GeoIP/LookupService.java index b1b4615..6a27dd7 100644 --- a/src/com/Zrips/CMI/Modules/GeoIP/LookupService.java +++ b/src/com/Zrips/CMI/Modules/GeoIP/LookupService.java @@ -24,6 +24,8 @@ import java.io.IOException; import java.io.RandomAccessFile; import java.net.InetAddress; +import java.nio.ByteBuffer; +import java.nio.charset.CharacterCodingException; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.util.concurrent.ConcurrentHashMap; @@ -113,101 +115,15 @@ public class LookupService { private static final int FULL_RECORD_LENGTH = 60; - private static final String[] countryCode = { "--", "AP", "EU", "AD", "AE", - "AF", "AG", "AI", "AL", "AM", "CW", "AO", "AQ", "AR", "AS", "AT", - "AU", "AW", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", - "BJ", "BM", "BN", "BO", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", - "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", - "CO", "CR", "CU", "CV", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", - "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ", - "FK", "FM", "FO", "FR", "SX", "GA", "GB", "GD", "GE", "GF", "GH", - "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", - "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IN", - "IO", "IQ", "IR", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", - "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", - "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", - "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", - "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", - "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", - "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", - "PY", "QA", "RE", "RO", "RU", "RW", "SA", "SB", "SC", "SD", "SE", - "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "ST", - "SV", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TM", - "TN", "TO", "TL", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", - "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", - "WS", "YE", "YT", "RS", "ZA", "ZM", "ME", "ZW", "A1", "A2", "O1", - "AX", "GG", "IM", "JE", "BL", "MF", "BQ", "SS", "O1" }; - - private static final String[] countryName = { "N/A", "Asia/Pacific Region", - "Europe", "Andorra", "United Arab Emirates", "Afghanistan", - "Antigua and Barbuda", "Anguilla", "Albania", "Armenia", "Curacao", - "Angola", "Antarctica", "Argentina", "American Samoa", "Austria", - "Australia", "Aruba", "Azerbaijan", "Bosnia and Herzegovina", - "Barbados", "Bangladesh", "Belgium", "Burkina Faso", "Bulgaria", - "Bahrain", "Burundi", "Benin", "Bermuda", "Brunei Darussalam", - "Bolivia", "Brazil", "Bahamas", "Bhutan", "Bouvet Island", - "Botswana", "Belarus", "Belize", "Canada", - "Cocos (Keeling) Islands", "Congo, The Democratic Republic of the", - "Central African Republic", "Congo", "Switzerland", - "Cote D'Ivoire", "Cook Islands", "Chile", "Cameroon", "China", - "Colombia", "Costa Rica", "Cuba", "Cape Verde", "Christmas Island", - "Cyprus", "Czech Republic", "Germany", "Djibouti", "Denmark", - "Dominica", "Dominican Republic", "Algeria", "Ecuador", "Estonia", - "Egypt", "Western Sahara", "Eritrea", "Spain", "Ethiopia", - "Finland", "Fiji", "Falkland Islands (Malvinas)", - "Micronesia, Federated States of", "Faroe Islands", "France", - "Sint Maarten (Dutch part)", "Gabon", "United Kingdom", "Grenada", - "Georgia", "French Guiana", "Ghana", "Gibraltar", "Greenland", - "Gambia", "Guinea", "Guadeloupe", "Equatorial Guinea", "Greece", - "South Georgia and the South Sandwich Islands", "Guatemala", - "Guam", "Guinea-Bissau", "Guyana", "Hong Kong", - "Heard Island and McDonald Islands", "Honduras", "Croatia", - "Haiti", "Hungary", "Indonesia", "Ireland", "Israel", "India", - "British Indian Ocean Territory", "Iraq", - "Iran, Islamic Republic of", "Iceland", "Italy", "Jamaica", - "Jordan", "Japan", "Kenya", "Kyrgyzstan", "Cambodia", "Kiribati", - "Comoros", "Saint Kitts and Nevis", - "Korea, Democratic People's Republic of", "Korea, Republic of", - "Kuwait", "Cayman Islands", "Kazakhstan", - "Lao People's Democratic Republic", "Lebanon", "Saint Lucia", - "Liechtenstein", "Sri Lanka", "Liberia", "Lesotho", "Lithuania", - "Luxembourg", "Latvia", "Libya", "Morocco", "Monaco", - "Moldova, Republic of", "Madagascar", "Marshall Islands", - "Macedonia", "Mali", "Myanmar", "Mongolia", "Macau", - "Northern Mariana Islands", "Martinique", "Mauritania", - "Montserrat", "Malta", "Mauritius", "Maldives", "Malawi", "Mexico", - "Malaysia", "Mozambique", "Namibia", "New Caledonia", "Niger", - "Norfolk Island", "Nigeria", "Nicaragua", "Netherlands", "Norway", - "Nepal", "Nauru", "Niue", "New Zealand", "Oman", "Panama", "Peru", - "French Polynesia", "Papua New Guinea", "Philippines", "Pakistan", - "Poland", "Saint Pierre and Miquelon", "Pitcairn Islands", - "Puerto Rico", "Palestinian Territory", "Portugal", "Palau", - "Paraguay", "Qatar", "Reunion", "Romania", "Russian Federation", - "Rwanda", "Saudi Arabia", "Solomon Islands", "Seychelles", "Sudan", - "Sweden", "Singapore", "Saint Helena", "Slovenia", - "Svalbard and Jan Mayen", "Slovakia", "Sierra Leone", "San Marino", - "Senegal", "Somalia", "Suriname", "Sao Tome and Principe", - "El Salvador", "Syrian Arab Republic", "Swaziland", - "Turks and Caicos Islands", "Chad", "French Southern Territories", - "Togo", "Thailand", "Tajikistan", "Tokelau", "Turkmenistan", - "Tunisia", "Tonga", "Timor-Leste", "Turkey", "Trinidad and Tobago", - "Tuvalu", "Taiwan", "Tanzania, United Republic of", "Ukraine", - "Uganda", "United States Minor Outlying Islands", "United States", - "Uruguay", "Uzbekistan", "Holy See (Vatican City State)", - "Saint Vincent and the Grenadines", "Venezuela", - "Virgin Islands, British", "Virgin Islands, U.S.", "Vietnam", - "Vanuatu", "Wallis and Futuna", "Samoa", "Yemen", "Mayotte", - "Serbia", "South Africa", "Zambia", "Montenegro", "Zimbabwe", - "Anonymous Proxy", "Satellite Provider", "Other", "Aland Islands", - "Guernsey", "Isle of Man", "Jersey", "Saint Barthelemy", - "Saint Martin", "Bonaire, Saint Eustatius and Saba", "South Sudan", - "Other" }; + private static final String[] countryCode = { "--" }; + + private static final String[] countryName = { "N/A" }; /* init the hashmap once at startup time */ static { - if (countryCode.length != countryName.length) { - throw new AssertionError("countryCode.length!=countryName.length"); - } + if (countryCode.length != countryName.length) { + throw new AssertionError("countryCode.length!=countryName.length"); + } } /** @@ -225,7 +141,11 @@ public class LookupService { */ public LookupService(File databaseFile, int options) throws IOException { - this.databaseFile = null; + this.databaseFile = databaseFile; + if (databaseFile.isFile()) + file = new RandomAccessFile(databaseFile, "r"); + dboptions = options; + init(); } /** @@ -250,24 +170,104 @@ synchronized void _check_mtime() { } public IPLocation getLocation(InetAddress addr) { - return null; + if (!this.databaseFile.isFile()) { + return getEmpty(); + } + return getLocation(bytesToLong(addr.getAddress())); } public IPLocation getLocation(String str) { - return null; + + return null; + } private synchronized IPLocation getLocation(long ipnum) { - return null; + int seekCountry; + + if (!this.databaseFile.isFile()) { + return getEmpty(); + } + + try { + seekCountry = seekCountry(ipnum); + return readCityRecord(seekCountry); + } catch (IOException e) { + } + + return getEmpty(); } private static IPLocation getEmpty() { - return null; + IPLocation record = new IPLocation(); + record.setCountryCode("--"); + record.setCountryName("N/A"); + return record; } private IPLocation readCityRecord(int seekCountry) throws IOException { - - return null; + + return null; + } + + private ByteBuffer readRecordBuf(int seek, int maxLength) throws IOException { + + return null; + } + + private String readString(ByteBuffer buffer) throws CharacterCodingException { + int start = buffer.position(); + int oldLimit = buffer.limit(); + + while (buffer.hasRemaining() && buffer.get() != 0) { + } + + int end = buffer.position() - 1; + String str = null; + if (end > start) { + buffer.position(start); + buffer.limit(end); + str = charsetDecoder.decode(buffer).toString(); + buffer.limit(oldLimit); + } + buffer.position(end + 1); + return str; } + /** + * Finds the country index value given an IP address. + * + * @param ipAddress + * the ip address to find in long format. + * @return the country index. + */ + private synchronized int seekCountry(long ipAddress) { + return 0; + } + + private void readNode(byte[] buf, int[] x, int offset) { + } + + /** + * Returns the long version of an IP address given an InetAddress object. + * + * @param address + * the InetAddress. + * @return the long form of the IP address. + */ + private static long bytesToLong(byte[] address) { + long ipnum = 0; + for (int i = 0; i < 4; ++i) { + long y = address[i]; + if (y < 0) { + y += 256; + } + ipnum += y << ((3 - i) * 8); + } + return ipnum; + } + + private static int unsignedByteToInt(byte b) { + return (int) b & 0xFF; + } } \ No newline at end of file diff --git a/src/com/Zrips/CMI/Modules/Holograms/CMIDataWatcher.java b/src/com/Zrips/CMI/Modules/Holograms/CMIDataWatcher.java index d06348c..4651fa0 100644 --- a/src/com/Zrips/CMI/Modules/Holograms/CMIDataWatcher.java +++ b/src/com/Zrips/CMI/Modules/Holograms/CMIDataWatcher.java @@ -1,10 +1,8 @@ package com.Zrips.CMI.Modules.Holograms; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.entity.Player; -import com.Zrips.CMI.CMI; import net.Zrips.CMILib.Items.CMIItemStack; public class CMIDataWatcher { @@ -18,73 +16,67 @@ public class CMIDataWatcher { private boolean updatingHead = false; -// @Deprecated -// public CMIDataWatcher(Integer id, Object stand) { -// this.stand = stand; -// this.id = id; -// } - public CMIDataWatcher(Integer id, Object stand, CMIHoloLineType type) { - this.stand = stand; - this.id = id; - this.type = type; + this.stand = stand; + this.id = id; + this.type = type; } public CMIDataWatcher(Integer id, Integer secid, Object stand, CMIHoloLineType type) { - this.stand = stand; - this.id = id; - this.secId = secid; - this.type = type; + this.stand = stand; + this.id = id; + this.secId = secid; + this.type = type; } public Object getStand() { - return stand; + return stand; } public void setStand(Object watcher) { - this.stand = watcher; + this.stand = watcher; } public Integer getId() { - return id; + return id; } public void setId(Integer id) { - this.id = id; + this.id = id; } public void remove(Player player) { } public Location getLoc() { - return loc; + return loc; } public void setLoc(Location loc) { - this.loc = loc; + this.loc = loc; } public CMIHoloLineType getType() { - return type; + return type; } public void setType(CMIHoloLineType type) { - this.type = type; + this.type = type; } public CMIItemStack getItem() { - return item; + return item; } public void setItem(CMIItemStack item) { - this.item = item; + this.item = item; } public boolean isUpdatingHead() { - return updatingHead; + return updatingHead; } public void setUpdatingHead(boolean updatingHead) { - this.updatingHead = updatingHead; + this.updatingHead = updatingHead; } } diff --git a/src/com/Zrips/CMI/Modules/Holograms/CMIFont.java b/src/com/Zrips/CMI/Modules/Holograms/CMIFont.java new file mode 100644 index 0000000..138219d --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Holograms/CMIFont.java @@ -0,0 +1,138 @@ +package com.Zrips.CMI.Modules.Holograms; + +import net.Zrips.CMILib.Colors.CMIChatColor; + +public enum CMIFont { + + A('A', 5), + a('a', 5), + B('B', 5), + b('b', 5), + C('C', 5), + c('c', 5), + D('D', 5), + d('d', 5), + E('E', 5), + e('e', 5), + F('F', 5), + f('f', 4), + G('G', 5), + g('g', 5), + H('H', 5), + h('h', 5), + I('I', 3), + i('i', 1), + J('J', 5), + j('j', 5), + K('K', 5), + k('k', 4), + L('L', 5), + l('l', 1), + M('M', 5), + m('m', 5), + N('N', 5), + n('n', 5), + O('O', 5), + o('o', 5), + P('P', 5), + p('p', 5), + Q('Q', 5), + q('q', 5), + R('R', 5), + r('r', 5), + S('S', 5), + s('s', 5), + T('T', 5), + t('t', 4), + U('U', 5), + u('u', 5), + V('V', 5), + v('v', 5), + W('W', 5), + w('w', 5), + X('X', 5), + x('x', 5), + Y('Y', 5), + y('y', 5), + Z('Z', 5), + z('z', 5), + NUM_1('1', 5), + NUM_2('2', 5), + NUM_3('3', 5), + NUM_4('4', 5), + NUM_5('5', 5), + NUM_6('6', 5), + NUM_7('7', 5), + NUM_8('8', 5), + NUM_9('9', 5), + NUM_0('0', 5), + EXCLAMATION_POINT('!', 1), + AT_SYMBOL('@', 6), + NUM_SIGN('#', 5), + DOLLAR_SIGN('$', 5), + PERCENT('%', 5), + UP_ARROW('^', 5), + AMPERSAND('&', 5), + ASTERISK('*', 5), + LEFT_PARENTHESIS('(', 4), + RIGHT_PERENTHESIS(')', 4), + MINUS('-', 5), + UNDERSCORE('_', 5), + PLUS_SIGN('+', 5), + EQUALS_SIGN('=', 5), + LEFT_CURL_BRACE('{', 4), + RIGHT_CURL_BRACE('}', 4), + LEFT_BRACKET('[', 3), + RIGHT_BRACKET(']', 3), + COLON(':', 1), + SEMI_COLON(';', 1), + DOUBLE_QUOTE('"', 3), + SINGLE_QUOTE('\'', 1), + LEFT_ARROW('<', 4), + RIGHT_ARROW('>', 4), + QUESTION_MARK('?', 5), + SLASH('/', 5), + BACK_SLASH('\\', 5), + LINE('|', 1), + TILDE('~', 5), + TICK('`', 2), + PERIOD('.', 1), + COMMA(',', 1), + SPACE(' ', 3), + DEFAULT('a', 4); + + private char character; + private int length; + + CMIFont(char character, int length) { + this.character = character; + this.length = length; + } + + public char getCharacter() { + return this.character; + } + + public int getLength() { + return this.length; + } + + public int getBoldLength() { + if (this == CMIFont.SPACE) + return this.getLength(); + return this.length + 1; + } + + public static CMIFont getDefaultFontInfo(char c) { + for (CMIFont dFI : CMIFont.values()) { + if (dFI.getCharacter() == c) + return dFI; + } + return CMIFont.DEFAULT; + } + + public static int getWidth(String text) { + + return 0; + } +} diff --git a/src/com/Zrips/CMI/Modules/Holograms/CMIHologram.java b/src/com/Zrips/CMI/Modules/Holograms/CMIHologram.java index 14ab023..46d560e 100644 --- a/src/com/Zrips/CMI/Modules/Holograms/CMIHologram.java +++ b/src/com/Zrips/CMI/Modules/Holograms/CMIHologram.java @@ -13,13 +13,17 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIInteractType; import com.Zrips.CMI.Modules.Packets.FakeInfo; +import com.Zrips.CMI.Modules.Portals.CMIVector3D; import com.Zrips.CMI.Modules.Portals.CuboidArea; import net.Zrips.CMILib.Container.CMILocation; +import net.Zrips.CMILib.Effects.CMIEffect; +import net.Zrips.CMILib.Effects.CMIEffectManager.CMIParticle; public class CMIHologram { @@ -49,14 +53,17 @@ public class CMIHologram { private int updateRange = HologramManager.defaultUpdateRange; private int showRange = HologramManager.defaultViewRange; - private Double spacing = 0.25; - private Double iconSpacing = 0.5D; + private double spacing = 0.25; + private double iconSpacing = 0.5D; private boolean downOrder = HologramManager.defaultsPlaceUp; private CMILocation loc; + private Vector centerLocation = null; + private boolean interactable = false; + private boolean bigButton = true; private boolean showParticle = true; private boolean requestPermission = false; @@ -72,6 +79,8 @@ public class CMIHologram { private List oldLines = new ArrayList(); private boolean changedLines = false; private ConcurrentHashMap inPage = new ConcurrentHashMap(); + private ConcurrentHashMap hoveringLine = new ConcurrentHashMap(); +// private ConcurrentHashMap oldHoveringLine = new ConcurrentHashMap(); private ConcurrentHashMap pages = new ConcurrentHashMap(); private ConcurrentHashMap oldPages = new ConcurrentHashMap(); @@ -80,226 +89,279 @@ public class CMIHologram { private boolean uSync = true; + //Interaction area + private boolean newIneractionMethod = true; + private int hoverOverSchedId = -1; + private double extraInteractionHeight = 0D; + private double extraInteractionWidth = 0D; + + //Particles + private short particlePosition = 0; + private double particleSpacing = 0D; + private int particleCount = 1; + private CMIEffect effect = new CMIEffect(CMIParticle.SMALL_SMOKE); + + private boolean showHoverParticle = true; + private boolean stabilizedHoverParticles = false; + private double extraParticleHeight = 0D; + private double extraParticleWidth = 0D; + + private double particleOffsetX = 0D; + private double particleOffsetY = 0D; + @Deprecated public CMIHologram(String name, Location loc) { - this.name = name; - this.loc = new CMILocation(loc); - updatePages(); + this.name = name; + this.loc = new CMILocation(loc); + updatePages(); } public CMIHologram(String name, CMILocation loc) { - this.name = name; - this.loc = loc; - updatePages(); + this.name = name; + this.loc = loc; + updatePages(); } - + + /** + * Triggered on player interaction with interactable hologram * + */ public void onInteraction(Player player, CMIInteractType type) { } - + public List getCommands() { - return commands; + return commands; } public List getCommands(Player player) { - return getCommands(player, null); + return getCommands(player, null); } public void goToNextPage(UUID uuid) { - } Set skipPageChange = new HashSet(); private void goToNextPageAuto(UUID uuid) { - + } public Integer getPlayerPage(UUID uuid) { - Integer page = inPage.get(uuid); - return page == null ? 1 : page; + Integer page = inPage.get(uuid); + return page == null ? 1 : page; } public void goToPrevPage(UUID uuid) { - + } public void goToPage(UUID uuid, int page) { - + } private void checkPageChange(UUID uuid, Integer oldPage, Integer newPage) { - + } private List getCommandsByPlayerPage(UUID uuid) { - return null; + + return null; } private List getLinesByPlayerPage(Player player) { - return null; + Integer page = inPage.get(player.getUniqueId()); + + if (page == null) { + page = 1; + } + + page = pages.size() < page ? 1 : page; + + if (pages.isEmpty()) + return null; + + CMIHologramPage p = pages.get(page); + + // Fallback to first page + if (p == null) + return pages.values().iterator().next().getLines(); + + return p.getLines(); } public void updatePages() { - + } public List getCommands(Player player, CMIInteractType type) { - - return null; + + List cmd = new ArrayList(); + + return cmd; } public void setCommands(List commands) { - if (this.commands == null) - this.commands = new ArrayList(); - this.commands.addAll(commands); + if (this.commands == null) + this.commands = new ArrayList(); + this.commands.addAll(commands); } public World getWorld() { - return loc.getWorld(); + return loc.getWorld(); } @Deprecated public Location getLoc() { - return loc; + return getLocation(); } public CMILocation getLocation() { - return loc; + return loc; } public void setLoc(Location loc) { + } public List getLines() { - return lines; + return lines; } public String getLine(int place) { - return lines.size() - 1 < place || place < 0 ? "" : lines.get(place) == null ? "" : lines.get(place); + return lines.size() - 1 < place || place < 0 ? "" : lines.get(place) == null ? "" : lines.get(place); } public void setLines(List l) { - + } public void addLine(String line) { - + } public void setLine(int place, String line) { - + oldLines.clear(); + oldLines.addAll(lines); + + while (lines.size() <= place) { + lines.add(""); + } + + lines.set(place, line); + recheckLines(); } public void removeLine(int line) { - + } public boolean isChangedLine() { - return changedLines; + return changedLines; } private void recheckLines() { + } public CuboidArea getArea() { - return null; + if (area == null) { + area = new CuboidArea(getLoc().clone().add(-updateRange, -updateRange, -updateRange), getLoc().clone().add(updateRange, updateRange, updateRange)); + } + return area; } public CuboidArea getAreaExtra() { - return null; + if (areaExtra == null) { + areaExtra = new CuboidArea(getLoc().clone().add(-this.showRange, -this.showRange, -this.showRange), + getLoc().clone().add(this.showRange, this.showRange, this.showRange)); + } + return areaExtra; } public void setArea(CuboidArea area) { - this.area = area; + this.area = area; } public void setAreaExtra(CuboidArea area) { - this.areaExtra = area; + this.areaExtra = area; } - public void update() { + } @Deprecated public void hide(Player player) { - if (player == null) - return; - hide(player.getUniqueId()); + } public void refresh() { - this.hide(); - this.updatePages(); - this.update(); + } public void hide() { - for (Player one : Bukkit.getOnlinePlayers()) { - removeFromCache(one.getUniqueId()); - } + } public void hide(UUID uuid) { - if (uuid == null) - return; - removeFromCache(uuid); + } public double getHeight() { - double offset = 0; - - return offset; + double offset = 0; + + return offset; + } + + private double getHeight(List l) { + double offset = getSpacing() / 2; + + return offset; + } + + public Vector getCenterVector() { + if (this.centerLocation != null) + return this.centerLocation.clone(); + this.centerLocation = getCenterLocation().toVector(); + return this.centerLocation.clone(); } public Location getCenterLocation() { - double h = getHeight(); - Location l = this.getLocation().clone(); - l.add(0, 0.25, 0); - if (isDownOrder()) { - l.add(0, -(h / 2D), 0); - } else { - l.add(0, h / 2D, 0); - } - return l; + double h = getHeight(); + Location l = this.getLocation().clone(); + + return l; } ConcurrentHashMap changed = new ConcurrentHashMap(); List changedPages = new ArrayList(); private void recalcualteChangedLines() { + } private void recalcualteChangedPages() { } - public void superficialMoveTo(final Player player, Location loc) { - + public void update(final Player player) { + update(player, false); } - private Double processLineDown(Player player, CMIHologramLine one, int i, Location targetLoc, Double offset) { - - - return .0; - } + ConcurrentHashMap nextUpdate = new ConcurrentHashMap(); + List stillUpdating = Collections.synchronizedList(new ArrayList<>()); - private Double processLineUp(Player player, CMIHologramLine one, int i, Location targetLoc, Double offset, int size) { - return .0; - } + private List getLocation(Player player, int parts) { - public void update(final Player player) { - update(player, false); + return null; } - ConcurrentHashMap nextUpdate = new ConcurrentHashMap(); - List stillUpdating = Collections.synchronizedList(new ArrayList<>()); + public void checkHoverPosition(Player player) { -// private boolean stillUpdating = false; + } public void update(final Player player, boolean oneTime) { - + } ConcurrentHashMap> cache = new ConcurrentHashMap>(); @@ -315,278 +377,404 @@ private void clearIconLines(UUID uuid, CMIHologramPage newHPage) { } public void removeFromCache(UUID uuid, int size) { - + } private void updateCache(UUID uuid, int place, CMIDataWatcher w) { - + } private CMIDataWatcher getCache(UUID uuid, int place) { - - return null; + List old = cache.get(uuid); + + if (old == null) { + old = new ArrayList(); + cache.put(uuid, old); + } + + return old.size() - 1 < place ? null : old.get(place); } public double getUpdateIntervalSec() { - return updateIntervalSec; + return updateIntervalSec; } public void setUpdateIntervalSec(double d) { + this.updateIntervalSec = Math.ceil((int) (d * 100D)) / 100D; + if (this.updateIntervalSec <= 0) + this.updateIntervalSec = -1; } public int getUpdateRange() { - updateRange = updateRange > this.showRange ? this.showRange : updateRange; - return updateRange; + updateRange = updateRange > this.showRange ? this.showRange : updateRange; + return updateRange; } public void setUpdateRange(int activationRange) { + this.updateRange = activationRange; + if (this.updateRange < 1) + this.updateRange = 1; + if (this.updateRange > 64) + this.updateRange = 64; + if (this.updateRange > showRange) + updateRange = this.showRange; } public String getName() { - return name; + return name; } public void setName(String name) { - this.name = name; + this.name = name; } public int getShowRange() { - showRange = showRange < this.updateRange ? this.updateRange : showRange; - return showRange; + showRange = showRange < this.updateRange ? this.updateRange : showRange; + return showRange; } public void setShowRange(int showRange) { - + this.showRange = showRange; + if (this.showRange < 1) + this.showRange = 1; + if (this.showRange > 64) + this.showRange = 64; + if (this.showRange < updateRange) + showRange = this.updateRange; } public Double getIconSpacing() { - return iconSpacing; + return iconSpacing; } public void setIconSpacing(Double iconSpacing) { - this.iconSpacing = iconSpacing; + this.iconSpacing = iconSpacing; + updatePages(); } public Double getSpacing() { - return spacing; + return spacing; } public void setSpacing(Double spacing) { - this.spacing = spacing; + this.spacing = spacing; + updatePages(); } public Boolean isDownOrder() { - return downOrder; + return downOrder; } public void setDownOrder(Boolean downOrder) { - this.hide(); - this.update(); - this.downOrder = downOrder; + this.hide(); + this.update(); + this.downOrder = downOrder; } public boolean isInteractable() { - return interactable; + return interactable; } public void setInteractable(boolean interactable) { - this.interactable = interactable; + this.interactable = interactable; } public boolean isShowParticle() { - return showParticle; + return showParticle; } public void setShowParticle(boolean showParticle) { - this.showParticle = showParticle; + this.showParticle = showParticle; } public boolean isBigButton() { - return bigButton; + return bigButton; } public void setBigButton(boolean bigButton) { - this.bigButton = bigButton; + this.bigButton = bigButton; } public int getSchedId() { - return schedId; + return schedId; } public void setId(int schedId) { - this.schedId = schedId; + this.schedId = schedId; } public void stop() { - if (lineOfSightSchedId != -1) { - Bukkit.getScheduler().cancelTask(lineOfSightSchedId); - lineOfSightSchedId = -1; - } - if (schedId != -1) { - Bukkit.getScheduler().cancelTask(schedId); - schedId = -1; - } - if (pageSchedId != -1) { - Bukkit.getScheduler().cancelTask(pageSchedId); - pageSchedId = -1; - } + } private void tasker() { - + } @SuppressWarnings("deprecation") private void lineOfSightTasker() { - + } private void pageTasker() { - + + } + + private void hoverOverTasker() { + } Set skipPlayers = Collections.synchronizedSet(new HashSet()); private void updateHolo() { - + } public Set getLastHoloInRange() { - return lastHoloInRange; + return lastHoloInRange; } public void addLastHoloInRange(UUID uuid) { - this.lastHoloInRange.add(uuid); - tasker(); - lineOfSightTasker(); - pageTasker(); + } public void removeLastHoloInRange(UUID uuid) { - this.lastHoloInRange.remove(uuid); - tasker(); - lineOfSightTasker(); - pageTasker(); + } public Set getLastHoloInRangeExtra() { - return lastHoloInRangeExtra; + return lastHoloInRangeExtra; } public void addLastHoloInRangeExtra(UUID uuid) { - this.lastHoloInRangeExtra.add(uuid); - lineOfSightTasker(); - update(Bukkit.getPlayer(uuid)); + this.lastHoloInRangeExtra.add(uuid); + lineOfSightTasker(); + update(Bukkit.getPlayer(uuid)); } public void removeLastHoloInRangeExtra(UUID uuid) { - this.lastHoloInRangeExtra.remove(uuid); - lineOfSightTasker(); - hide(uuid); + this.lastHoloInRangeExtra.remove(uuid); + lineOfSightTasker(); + hide(uuid); } public boolean isuSync() { - return uSync; + return uSync; } public void setuSync(boolean uSync) { - this.uSync = uSync; + this.uSync = uSync; } public void disable() { - enabled = false; - this.hide(); + enabled = false; + this.hide(); } public void enable() { - enabled = true; - this.update(); + enabled = true; + this.update(); } public boolean isSaveToFile() { - return saveToFile; + return saveToFile; } public void setSaveToFile(boolean saveToFile) { - this.saveToFile = saveToFile; + this.saveToFile = saveToFile; } public void makePersistent() { - this.saveToFile = true; + this.saveToFile = true; } public boolean isEnabled() { - return enabled; + return enabled; } public int getPageCount() { - return this.pages.size(); + return this.pages.size(); } public CMIHologramPage getPage(int page) { - return this.pages.get(page); + return this.pages.get(page); } public boolean isRequiresPermission() { - return requestPermission; + return requestPermission; } public void setPermissionRequirement(boolean requestPermission) { - this.requestPermission = requestPermission; + this.requestPermission = requestPermission; } public double getPageChangeIntervalSec() { - return pageChangeIntervalSec; + return pageChangeIntervalSec; } public void setPageChangeIntervalSec(double pageChangeIntervalSec) { - boolean update = false; - if (this.pageChangeIntervalSec != pageChangeIntervalSec) - update = true; - this.pageChangeIntervalSec = Math.ceil((int) (pageChangeIntervalSec * 100D)) / 100D; - if (this.pageChangeIntervalSec <= 0) - this.pageChangeIntervalSec = 0; - if (update) - pageTasker(); + boolean update = false; + if (this.pageChangeIntervalSec != pageChangeIntervalSec) + update = true; + this.pageChangeIntervalSec = Math.ceil((int) (pageChangeIntervalSec * 100D)) / 100D; + if (this.pageChangeIntervalSec <= 0) + this.pageChangeIntervalSec = 0; + if (update) + pageTasker(); } public void remove() { - CMI.getInstance().getHologramManager().removeHolo(this); + CMI.getInstance().getHologramManager().removeHolo(this); } public boolean isSticky() { - return sticky; + return sticky; } public void setSticky(boolean sticky) { - this.sticky = sticky; + this.sticky = sticky; } public boolean isCheckLineOfSight() { - return LOSupdateIntervalSec > 0; + return LOSupdateIntervalSec > 0; } public void setLOSInterval(double LOSupdateIntervalSec) { - if (LOSupdateIntervalSec < 0) - LOSupdateIntervalSec = 0; - this.LOSupdateIntervalSec = Math.ceil((int) (LOSupdateIntervalSec * 100D)) / 100D; + if (LOSupdateIntervalSec < 0) + LOSupdateIntervalSec = 0; + this.LOSupdateIntervalSec = Math.ceil((int) (LOSupdateIntervalSec * 100D)) / 100D; } public double getLOSupdateIntervalSec() { - return LOSupdateIntervalSec; + return LOSupdateIntervalSec; } public boolean isFollowPlayer() { - return LOSupdateIntervalSec > 0; + return LOSupdateIntervalSec > 0; } public void setFollowPlayer(double followPlayer) { - if (followPlayer < 0) - followPlayer = 0; - this.followPlayer = Math.ceil((int) (followPlayer * 100D)) / 100D; + if (followPlayer < 0) + followPlayer = 0; + this.followPlayer = Math.ceil((int) (followPlayer * 100D)) / 100D; } public double getFollowPlayer() { - return followPlayer; + return followPlayer; + } + + public int getHoveringLine(UUID uuid) { + return hoveringLine.getOrDefault(uuid, 0); + } + + public boolean isShowHoverParticle() { + return showHoverParticle; + } + + public void setShowHoverParticle(boolean showHoverParticle) { + this.showHoverParticle = showHoverParticle; + } + + public boolean isNewIneractionMethod() { + return newIneractionMethod; + } + + public void setNewIneractionMethod(boolean newIneractionMethod) { + this.newIneractionMethod = newIneractionMethod; + } + + public int getParticleCount() { + return particleCount; + } + + public void setParticleCount(int particleCount) { + particleCount = Math.max(1, particleCount); + particleCount = Math.min(10, particleCount); + + this.particleCount = particleCount; + } + + public double getParticleSpacing() { + return particleSpacing; + } + + public void setParticleSpacing(double particleSpacing) { + particleSpacing = Math.max(0, particleSpacing); + particleSpacing = Math.min(1, particleSpacing); + this.particleSpacing = particleSpacing; + } + + public double getExtraParticleHeight() { + return extraParticleHeight; + } + + public void setExtraParticleHeight(double extraParticleHeight) { + + extraParticleHeight = Math.max(-this.getHeight() / 2, extraParticleHeight); + extraParticleHeight = Math.min(3, extraParticleHeight); + + this.extraParticleHeight = extraParticleHeight; + } + + public double getExtraParticleWidth() { + return extraParticleWidth; + } + + public void setExtraParticleWidth(double extraParticleWidth) { + + extraParticleWidth = Math.max(-3, extraParticleWidth); + extraParticleWidth = Math.min(3, extraParticleWidth); + + this.extraParticleWidth = extraParticleWidth; + } + + public double getExtraInteractionHeight() { + return extraInteractionHeight; + } + + public void setExtraInteractionHeight(double extraInteractionHeight) { + this.extraInteractionHeight = extraInteractionHeight; + } + + public double getExtraInteractionWidth() { + return extraInteractionWidth; + } + + public void setExtraInteractionWidth(double extraInteractionWidth) { + this.extraInteractionWidth = extraInteractionWidth; + } + + public CMIEffect getHoverEffect() { + return effect; + } + + public void setHoverEffect(CMIParticle effect) { + this.effect = new CMIEffect(effect); + this.effect.setAmount(0); + this.effect.setSpeed(1); + } + + public double getParticleOffsetX() { + return particleOffsetX; + } + + public void setParticleOffsetX(double particleOffsetX) { + this.particleOffsetX = particleOffsetX; + } + + public double getParticleOffsetY() { + return particleOffsetY; + } + + public void setParticleOffsetY(double particleOffsetY) { + this.particleOffsetY = particleOffsetY; + } + + public boolean isStabilizedHoverParticles() { + return stabilizedHoverParticles; + } + + public void setStabilizedHoverParticles(boolean stabilizedHoverParticles) { + this.stabilizedHoverParticles = stabilizedHoverParticles; } } diff --git a/src/com/Zrips/CMI/Modules/Holograms/CMIHologramClickEvent.java b/src/com/Zrips/CMI/Modules/Holograms/CMIHologramClickEvent.java new file mode 100644 index 0000000..1152360 --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Holograms/CMIHologramClickEvent.java @@ -0,0 +1,69 @@ +package com.Zrips.CMI.Modules.Holograms; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import com.Zrips.CMI.Containers.CMIInteractType; +import com.Zrips.CMI.Modules.Portals.CMIVector3D; +import com.Zrips.CMI.events.EventAnnotation; + +public final class CMIHologramClickEvent extends Event implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; + private Player player; + private CMIHologram hologram; + private int line; + private CMIVector3D pos; + private CMIInteractType actionType; + + public CMIHologramClickEvent(Player player, CMIHologram holo, int line, CMIVector3D pos, CMIInteractType actionType) { + this.player = player; + this.hologram = holo; + this.line = line; + this.pos = pos; + this.actionType = actionType; + } + + public final static HandlerList getHandlerList() { + return handlers; + } + + @Override + @EventAnnotation(info = "Fired when player click on hologram line") + public final HandlerList getHandlers() { + return handlers; + } + + @Override + public final void setCancelled(final boolean cancel) { + this.cancel = cancel; + } + + @Override + public final boolean isCancelled() { + return cancel; + } + + public Player getPlayer() { + return player; + } + + public CMIHologram getHologram() { + return hologram; + } + + public int getLineNumber() { + return line; + } + + public CMIVector3D getPos() { + return pos; + } + + public CMIInteractType getActionType() { + return actionType; + } +} diff --git a/src/com/Zrips/CMI/Modules/Holograms/CMIHologramLine.java b/src/com/Zrips/CMI/Modules/Holograms/CMIHologramLine.java index 8782637..171fed0 100644 --- a/src/com/Zrips/CMI/Modules/Holograms/CMIHologramLine.java +++ b/src/com/Zrips/CMI/Modules/Holograms/CMIHologramLine.java @@ -3,31 +3,23 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Random; import java.util.concurrent.CompletableFuture; -import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Config; -import net.Zrips.CMILib.CMILib; -import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Images.CMIImage; import net.Zrips.CMILib.Items.CMIAsyncHead; import net.Zrips.CMILib.Items.CMIItemStack; -import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.NBT.CMINBT; -import net.Zrips.CMILib.Version.Version; public class CMIHologramLine { private CMIHoloLineType type = CMIHoloLineType.plainText; private String text; + private String hoverText; + private String command; private CMIItemStack item; private boolean itemInHand = false; private boolean staticText = true; @@ -37,6 +29,8 @@ public class CMIHologramLine { private Boolean randomU = null; private Float hue = null; + private double globalY = -999D; + private List image = null; private static final String regex = "(%)(?i)(CustomModelData:)(\\d+)(%)"; @@ -44,100 +38,138 @@ public class CMIHologramLine { @Override public CMIHologramLine clone() { - CMIHologramLine clone = new CMIHologramLine(); - return clone; + CMIHologramLine clone = new CMIHologramLine(); + clone.type = type; + if (item != null) + clone.item = item.clone(); + clone.itemInHand = itemInHand; + clone.staticText = staticText; + clone.enchanted = enchanted; + clone.modelData = modelData; + clone.randomU = randomU; + clone.hoverText = hoverText; + clone.command = command; + return clone; } public CMIHologramLine(String text) { - this.text = text; - recheck(); + this.text = text; + recheck(); } public CMIHologramLine() { } private void recheck() { - + } public CMIItemStack getItem(Player player) { - return getItem(player, null); + return getItem(player, null); } public CMIItemStack getItem(Player player, CMIAsyncHead ahead) { - return null; + return null; } public boolean isStaticText() { - return staticText; + return staticText; } public void setStaticText(boolean staticText) { - this.staticText = staticText; + this.staticText = staticText; } public boolean isItemInHand() { - return itemInHand; + return itemInHand; } public void setItemInHand(boolean itemInHand) { - this.itemInHand = itemInHand; + this.itemInHand = itemInHand; } public String getText() { - return text; + return text; } public String getText(Player player) { - - return null; + return checkText(player, text); + } + + public String getHoverText(Player player) { + return checkText(player, getHoverText()); + } + + private String checkText(Player player, String copy) { + + return null; } public CMIItemStack getItem() { - return item; + return item; } public void setItem(CMIItemStack item) { - this.item = item; + this.item = item; } public CMIHoloLineType getType() { - return type; + return type; } public boolean isIcon() { - return type == CMIHoloLineType.icon || type == CMIHoloLineType.staticIcon; + return type == CMIHoloLineType.icon || type == CMIHoloLineType.staticIcon; } public void setType(CMIHoloLineType type) { - this.type = type; + this.type = type; } public Boolean isRandomU() { - return randomU == null ? false : randomU; + return randomU == null ? false : randomU; } public boolean isGlowing() { - return glowing; + return glowing; } public void setGlowing(boolean glowing) { - this.glowing = glowing; + this.glowing = glowing; } public List getPlainImage() { - return image; + return image; } public CompletableFuture> getImage(Player player) { - if (!this.staticText) { - return CMIImage.convertLines(player, CMI.getInstance().getDataFolder().getPath(), new ArrayList(Arrays.asList(text)), true); - } - return CompletableFuture.supplyAsync(() -> image); + if (!this.staticText) { + return CMIImage.convertLines(player, CMI.getInstance().getDataFolder().getPath(), new ArrayList(Arrays.asList(text)), true); + } + return CompletableFuture.supplyAsync(() -> image); } public void setImage(List image) { - this.image = image; + this.image = image; + } + + public String getHoverText() { + return hoverText; + } + + public void setHoverText(String hoverText) { + this.hoverText = hoverText; + } + + public String getCommand() { + return command; + } + + public double getGlobalY() { + return globalY; + } + + public void setGlobalY(double globalY) { + this.globalY = globalY; } } diff --git a/src/com/Zrips/CMI/Modules/Holograms/CMIHologramPage.java b/src/com/Zrips/CMI/Modules/Holograms/CMIHologramPage.java index 0d5c0e8..1f0c462 100644 --- a/src/com/Zrips/CMI/Modules/Holograms/CMIHologramPage.java +++ b/src/com/Zrips/CMI/Modules/Holograms/CMIHologramPage.java @@ -3,37 +3,64 @@ import java.util.ArrayList; import java.util.List; +import com.Zrips.CMI.CMI; + +import net.Zrips.CMILib.Colors.CMIChatColor; + public class CMIHologramPage { private int page = -1; private List lines = new ArrayList(); private List commands = new ArrayList(); + private double height = 0D; + private int width = 0; public CMIHologramPage() { } public List getLines() { - return lines; + return lines; } public void setLines(List lines) { - this.lines = lines; + this.lines = lines; + calculateWidth(); } public List getCommands() { - return commands; + return commands; } public void setCommands(List commands) { - this.commands = commands; - } + this.commands = commands; + } public int getPage() { - return page; + return page; } public void setPage(int page) { - this.page = page; + this.page = page; + } + + public double getHeight() { + return height; + } + + public void setHeight(double height) { + this.height = height; + } + + public int getWidth() { + return width; + } + + public void setWidth(int width) { + this.width = width; + } + + public void calculateWidth() { + } } diff --git a/src/com/Zrips/CMI/Modules/Holograms/HologramListener.java b/src/com/Zrips/CMI/Modules/Holograms/HologramListener.java index 703f338..e7d480c 100644 --- a/src/com/Zrips/CMI/Modules/Holograms/HologramListener.java +++ b/src/com/Zrips/CMI/Modules/Holograms/HologramListener.java @@ -4,20 +4,69 @@ import java.util.Map; import java.util.UUID; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerTeleportEvent; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.events.CMIPlayerFakeEntityInteractEvent; public class HologramListener implements Listener { private CMI plugin; protected Map lastUpdateRange; protected Map stickyLastUpdate; +// protected Map interactCache; public HologramListener(CMI plugin) { - this.plugin = plugin; - lastUpdateRange = new HashMap(); - stickyLastUpdate = new HashMap(); + this.plugin = plugin; + lastUpdateRange = new HashMap(); + stickyLastUpdate = new HashMap(); } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMoveExtendedRnage(PlayerMoveEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMoveExtendedRnage(PlayerTeleportEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerQuitEvent(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerJoinEvent(PlayerJoinEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onInteract(PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onInteract(CMIHologramClickEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void CMIPlayerFakeEntityInteractEvent(CMIPlayerFakeEntityInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerRespawnEvent(PlayerRespawnEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Holograms/HologramManager.java b/src/com/Zrips/CMI/Modules/Holograms/HologramManager.java index 0dbf6ba..6c62c47 100644 --- a/src/com/Zrips/CMI/Modules/Holograms/HologramManager.java +++ b/src/com/Zrips/CMI/Modules/Holograms/HologramManager.java @@ -1,17 +1,21 @@ package com.Zrips.CMI.Modules.Holograms; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Modules.Particl.CMIPEAnimationInterface; +import com.Zrips.CMI.Modules.Portals.CMIVector3D; import com.Zrips.CMI.Modules.Portals.CuboidArea.ChunkRef; public class HologramManager { @@ -23,7 +27,44 @@ public class HologramManager { private static Map> playerNearHoloUpdate; private static Map> playerNearHoloExtra; -// private Map> playerNearSticky; + + private ConcurrentHashMap aimingAt = new ConcurrentHashMap(); + + class CMIAiming { + private String name; + private CMIVector3D pos; + private CMIPEAnimationInterface eff; + + public CMIAiming(String name, CMIVector3D pos) { + this.name = name; + this.pos = pos; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public CMIVector3D getPos() { + return pos; + } + + public void setPos(CMIVector3D pos) { + this.pos = pos; + } + + public CMIPEAnimationInterface getEff() { + return eff; + } + + public void setEff(CMIPEAnimationInterface eff) { + this.eff = eff; + } + + } private int HoloRangeCheckInterval = 1000; @@ -32,29 +73,21 @@ public class HologramManager { private CMI plugin; public void clearCache(UUID uuid) { - playerNearHoloUpdate.remove(uuid); - playerNearHoloExtra.remove(uuid); -// playerNearSticky.remove(uuid); } public HologramManager(CMI plugin) { } - private int sched = -1; - public void stop() { - if (saveId != null) { - Bukkit.getScheduler().cancelTask(saveId); - this.saveHolograms(); - } - if (sched == -1) - return; - Bukkit.getScheduler().cancelTask(sched); - sched = -1; + if (saveId != null) { + Bukkit.getScheduler().cancelTask(saveId); + this.saveHolograms(); + } + } public void addHologram(CMIHologram holo) { - addHologram(holo, true); + addHologram(holo, true); } public void addHologram(CMIHologram holo, boolean checkForPlayers) { @@ -62,53 +95,55 @@ public void addHologram(CMIHologram holo, boolean checkForPlayers) { } public void recalculateChunks() { - + } public void removeChunkRecords(CMIHologram holo) { - + } public void recalculateChunks(CMIHologram holo) { - + } public void recalculateChunksExtra(CMIHologram holo) { - + } public CMIHologram getByName(String name) { - if (name == null) - return null; - return holograms.get(name.toLowerCase()); + if (name == null) + return null; + return holograms.get(name.toLowerCase()); } public CMIHologram getByLoc(Location loc) { - - return null; + + return null; } public CMIHologram getByLocExtra(Location loc) { - - return null; + + return null; } public Set getAllInRangeByLoc(Location loc) { - - return null; + Set holo = new HashSet(); + return holo; } public Set getAllInRangeByLocExtra(Location loc) { - - return null; + Set holo = new HashSet(); + if (loc == null) + return holo; + return holo; } public void handleHoloUpdates(Player player, Location locto) { - + } public void handleHoloRangeUpdates(Player player, Location locto) { - + } public static int defaultViewRange = 8; @@ -118,91 +153,82 @@ public void handleHoloRangeUpdates(Player player, Location locto) { public static boolean defaultsPlaceUp = true; public void loadConfig() { - } public void load() { - + } public void save() { - if (saveId != null) - return; - saveId = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - @Override - public void run() { - saveHolograms(); - saveId = null; - } - }, 20L * 15); + } private void saveHolograms() { - + } public void removeLastHologramInRange(UUID uuid) { - + } public void hideHoloForAllPlayers(CMIHologram holo) { - + } public void resetHoloForAllPlayers(CMIHologram holo) { - + } public void addPlayersNearHolo(CMIHologram holo, boolean forceUpdate) { - + } public void addPlayersNearHoloExtra(CMIHologram holo, boolean forceUpdate) { - + } public HashMap getHolograms() { - return holograms; + return holograms; } public List getHologramsByDistance(Location loc) { - return null; + return null; } public void removeHolo(CMIHologram holo) { - + } public int getHoloCheckInterval() { - return HoloRangeCheckInterval; + return HoloRangeCheckInterval; } public boolean isNearHolo(UUID uuid) { - Set ls = playerNearHoloUpdate.get(uuid); - return ls != null && !ls.isEmpty(); + Set ls = playerNearHoloUpdate.get(uuid); + return ls != null && !ls.isEmpty(); } public boolean rechecInteractableHolograms(UUID uuid) { - return recheckInteractableHolograms(Bukkit.getPlayer(uuid)); + return recheckInteractableHolograms(Bukkit.getPlayer(uuid)); } public boolean recheckInteractableHolograms(Player player) { - - return true; + + return true; } public void addNearHolo(UUID uuid, CMIHologram holo) { - + } public void removeNearHolo(UUID uuid, CMIHologram holo) { - + } public void addNearHoloExtra(UUID uuid, CMIHologram holo) { - + } public void removeNearHoloExtra(UUID uuid, CMIHologram holo) { @@ -214,16 +240,25 @@ public void openGui(Player player, CMIHologram holo) { } public void hideAllHolograms() { - for (Entry one : HologramManager.holograms.entrySet()) { - this.hideHoloForAllPlayers(one.getValue()); - } + for (Entry one : HologramManager.holograms.entrySet()) { + this.hideHoloForAllPlayers(one.getValue()); + } } public Set getPlayerActiveHolograms(UUID uuid) { - return playerNearHoloUpdate.get(uuid); + return playerNearHoloUpdate.get(uuid); + } + + public void addAimAt(UUID uuid, String name, CMIVector3D pos) { + aimingAt.put(uuid, new CMIAiming(name, pos)); + } + + public CMIAiming getAimAt(UUID uuid) { + return aimingAt.get(uuid); + } + + public void removeAimAt(UUID uuid) { + CMIAiming removed = aimingAt.remove(uuid); } -// public Map> getFakeEntities() { -// return fakeEntities; -// } } diff --git a/src/com/Zrips/CMI/Modules/Homes/CmiHome.java b/src/com/Zrips/CMI/Modules/Homes/CmiHome.java index c6f5ffd..cf745f9 100644 --- a/src/com/Zrips/CMI/Modules/Homes/CmiHome.java +++ b/src/com/Zrips/CMI/Modules/Homes/CmiHome.java @@ -1,5 +1,10 @@ package com.Zrips.CMI.Modules.Homes; +import java.math.BigInteger; + +import com.Zrips.CMI.CMI; +import net.Zrips.CMILib.Version.Version; +import net.Zrips.CMILib.CMILib; import net.Zrips.CMILib.Container.CMILocation; import net.Zrips.CMILib.Items.CMIMaterial; @@ -8,62 +13,71 @@ public class CmiHome { private CMILocation loc; private String name; private boolean privateH = false; + private boolean bed = false; private Integer slot; private CMIMaterial material; public CmiHome(String name, CMILocation loc) { - this.name = name; - this.loc = loc; + this.name = name; + this.loc = loc; } public CmiHome(String name, CMILocation loc, boolean privateH) { - this.name = name; - this.loc = loc; - this.privateH = privateH; + this.name = name; + this.loc = loc; + this.privateH = privateH; } public CMILocation getLoc() { - loc.recheck(); - return loc; + loc.recheck(); + return loc; } public String getName() { - return name; + return name; } public boolean isPrivate() { - return privateH; + return privateH; } public void setPrivate(boolean privateH) { - this.privateH = privateH; + this.privateH = privateH; } public CMIMaterial getIconMaterial() { - return null; + return null; } public CMIMaterial getMaterial() { - return material; + return material; } public void setMaterial(CMIMaterial material) { - if (material != null && (material == CMIMaterial.NONE || material.isAir())) - return; - this.material = material; + if (material != null && (material == CMIMaterial.NONE || material.isAir())) + return; + this.material = material; } public Integer getSlot() { - return slot; + return slot; } public void setSlot(Integer slot) { - if (slot != null && slot < 0) - this.slot = null; - else - this.slot = slot; + if (slot != null && slot <= 0) + this.slot = null; + else + this.slot = slot; + } + + public boolean isBed() { + return bed; + } + + public void setBed(boolean bed) { + this.bed = bed; } } diff --git a/src/com/Zrips/CMI/Modules/Homes/HomeListener.java b/src/com/Zrips/CMI/Modules/Homes/HomeListener.java index 44b6961..759dea2 100644 --- a/src/com/Zrips/CMI/Modules/Homes/HomeListener.java +++ b/src/com/Zrips/CMI/Modules/Homes/HomeListener.java @@ -1,6 +1,10 @@ package com.Zrips.CMI.Modules.Homes; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.player.PlayerInteractEvent; import com.Zrips.CMI.CMI; @@ -8,7 +12,16 @@ public class HomeListener implements Listener { private CMI plugin; public HomeListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onEnderChestClick(final PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void bedBreak(BlockBreakEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Homes/HomeManager.java b/src/com/Zrips/CMI/Modules/Homes/HomeManager.java index 347edbf..6a7a976 100644 --- a/src/com/Zrips/CMI/Modules/Homes/HomeManager.java +++ b/src/com/Zrips/CMI/Modules/Homes/HomeManager.java @@ -11,20 +11,59 @@ import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIUser; +import net.Zrips.CMILib.Items.CMIItemStack; + public class HomeManager { private CMI plugin; HashMap homeGroups = new HashMap(); + private HashMap homeLimits = new HashMap(); + private boolean checkBlockbreak = false; private boolean pickRealBlock = false; + private boolean homesWorldLimits = false; private boolean confirmation = true; private String defaultHomeName = "Home"; private String defaultBedHomeName = "Home"; private String homeNameRegex = "/([\\p{L}-]+)/ug"; private int respawnImmortality = 0; + private int HomesMaxGuiSlots = 99; private boolean HomesGui = true; + private boolean HomesGuiComplex = true; + private boolean guiExpanded = false; + + private CMIItemStack guiBorder = null; + private CMIItemStack guiInfill = null; +// private CMISound guiSound = null; + + private boolean guiInfoButton = true; + private int guiInfoButtonSlot = 45; + private CMIItemStack guiInfoButtonItem = null; + private List guiInfoButtonCommands = null; + + private boolean guiCloseButton = true; + private int guiCloseButtonSlot = 45; + private CMIItemStack guiCloseButtonItem = null; + private List guiCloseButtonCommands = null; + + private boolean guiBedButton = true; + private int guiBedButtonSlot = 45; + private CMIItemStack guiBedButtonItem = null; + + private boolean guiHomeButton = true; + private int guiHomeButtonSlot = 45; + private CMIItemStack guiHomeButtonItem = null; + + private boolean guiDeathButton = true; + private int guiDeathButtonSlot = 45; + private CMIItemStack guiDeathButtonItem = null; + + private int guiPrevButtonSlot = 49; + private int guiMiddleButtonSlot = 50; + private int guiNextButtonSlot = 51; + private boolean HomesBedInteraction = true; private boolean onlyShiftBed = false; private boolean RemoveBedLocationOnBedBreak = true; @@ -32,126 +71,182 @@ public class HomeManager { private HashMap> bedHomes = new HashMap>(); public HomeManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void addHomeGroup(String group, int amount) { - homeGroups.put(group, amount); + homeGroups.put(group, amount); } public enum RespawnPriority { - anchor, bedLocation, spawn, homeLocation, worldSpawn; - - public static RespawnPriority getByName(String name) { - for (RespawnPriority one : RespawnPriority.values()) { - if (one.name().equalsIgnoreCase(name)) - return one; - } - return null; - } - - public static List getAsStringList() { - List list = new ArrayList(); - return list; - } - - public static String getAsString() { - String list = ""; - return list; - } + anchor, bedLocation, spawn, homeLocation, worldSpawn; + + public static RespawnPriority getByName(String name) { + for (RespawnPriority one : RespawnPriority.values()) { + if (one.name().equalsIgnoreCase(name)) + return one; + } + return null; + } + + public static List getAsStringList() { + List list = new ArrayList(); + for (RespawnPriority one : RespawnPriority.values()) { + list.add(one.name()); + } + return list; + } + + public static String getAsString() { + String list = ""; + for (RespawnPriority one : RespawnPriority.values()) { + if (!list.isEmpty()) + list += ", "; + list += one.name(); + } + return list; + } } public int getMaxHomes(CommandSender sender) { - if (sender instanceof Player) - return getMaxHomes((Player) sender); - return 999; + return 999; } public int getMaxHomes(Player player) { - int homes = 1; - - return homes; + return 9999; } public void loadConfig() { - } public boolean isHomesBedInteraction() { - return HomesBedInteraction; + return HomesBedInteraction; } public Location getReSpawnLocation(Player player) { - return getReSpawnLocation(player, null); + return getReSpawnLocation(player, null); } public Location getReSpawnLocation(Player player, Location respawnLoc) { - - return null; + return null; } public boolean isCheckBlockbreak() { - return checkBlockbreak; + return checkBlockbreak; } public String getDefaultHomeName() { - return defaultHomeName; + return defaultHomeName; } public String getDefaultBedHomeName() { - return defaultBedHomeName; + return defaultBedHomeName; } public HashMap> getBedHomes() { - return bedHomes; + return bedHomes; } public void addBedHome(CMIUser user, CmiHome bedHome) { - + // Only bedhomes will have exact 0.5 as x coordinates + + if (Math.abs(bedHome.getLoc().getX() % 1) != 0.5 && Math.abs(bedHome.getLoc().getZ() % 1) != 0.5) + return; + + String l = plugin.getPlayerManager().convertBlockLocToString(bedHome.getLoc()); + HashMap m = new HashMap(); + m.put(user, bedHome); + bedHome.setBed(true); + this.bedHomes.put(l, m); } public boolean removeBedHome(Location loc) { - - return false; + + return false; } public boolean isRemoveBedLocationOnBedBreak() { - return RemoveBedLocationOnBedBreak; + return RemoveBedLocationOnBedBreak; } - public boolean openHomeGui(Player player, CMIUser user, int page) { - - return true; + if (this.isHomesGuiComplex()) + return openComplexHomeGui(player, user, page); + return openSimpleHomeGui(player, user, page); + } + + public boolean openComplexHomeGui(Player player, CMIUser user, int page) { + + return true; + } + + public boolean openSimpleHomeGui(Player player, CMIUser user, int page) { + + return true; } public boolean isHomesGui() { - return HomesGui; + return HomesGui; } public int getRespawnImmortality() { - return respawnImmortality; + return respawnImmortality; } public String getHomeNameRegex() { - return homeNameRegex; + return homeNameRegex; } public void setHomeNameRegex(String homeNameRegex) { - this.homeNameRegex = homeNameRegex; + this.homeNameRegex = homeNameRegex; } public boolean isPickRealBlock() { - return pickRealBlock; + return pickRealBlock; } public boolean isOnlyShiftBed() { - return onlyShiftBed; + return onlyShiftBed; } public boolean isConfirmation() { - return confirmation; + return confirmation; + } + + public boolean isHomesWorldLimits() { + return homesWorldLimits; + } + + public void setHomesWorldLimits(boolean homesWorldLimits) { + this.homesWorldLimits = homesWorldLimits; + } + + public int getWorldLimit(String worldName) { + HomeWorldLimit limit = getWorldLimitObject(worldName); + if (limit == null) + return -1; + return limit.getLimit(); + } + + public HomeWorldLimit getWorldLimitObject(String worldName) { + return homeLimits.get(worldName.toLowerCase()); + } + + public boolean isHomesGuiComplex() { + return HomesGuiComplex; + } + + public int getGuiCloseButtonSlot() { + return guiCloseButtonSlot; + } + + public CMIItemStack getGuiCloseButtonItem() { + return guiCloseButtonItem; + } + + public int getHomesMaxGuiSlots() { + return HomesMaxGuiSlots; } } diff --git a/src/com/Zrips/CMI/Modules/Homes/HomeWorldLimit.java b/src/com/Zrips/CMI/Modules/Homes/HomeWorldLimit.java new file mode 100644 index 0000000..6be908d --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Homes/HomeWorldLimit.java @@ -0,0 +1,29 @@ +package com.Zrips.CMI.Modules.Homes; + +import java.util.ArrayList; +import java.util.List; + +public class HomeWorldLimit { + + private List worlds = new ArrayList(); + private int limit = 0; + + public List getWorlds() { + return worlds; + } + + public void setWorlds(List worlds) { + this.worlds = worlds; + } + + public int getLimit() { + return limit; + } + + public void setLimit(int limit) { + if (limit < -1) + limit = -1; + this.limit = limit; + } + +} diff --git a/src/com/Zrips/CMI/Modules/HpBar/HpBarListener.java b/src/com/Zrips/CMI/Modules/HpBar/HpBarListener.java index 7743077..9f783c0 100644 --- a/src/com/Zrips/CMI/Modules/HpBar/HpBarListener.java +++ b/src/com/Zrips/CMI/Modules/HpBar/HpBarListener.java @@ -1,6 +1,11 @@ package com.Zrips.CMI.Modules.HpBar; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; import com.Zrips.CMI.CMI; @@ -8,7 +13,15 @@ public class HpBarListener implements Listener { private CMI plugin; public HpBarListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void EntityDamageEntityEvent(EntityDamageByEntityEvent event) { + + } + + private void show(Player player, Entity victim, double damage) { + + } } diff --git a/src/com/Zrips/CMI/Modules/InteractiveCommand/CMIInteractiveCommand.java b/src/com/Zrips/CMI/Modules/InteractiveCommand/CMIInteractiveCommand.java index 260012b..8519e49 100644 --- a/src/com/Zrips/CMI/Modules/InteractiveCommand/CMIInteractiveCommand.java +++ b/src/com/Zrips/CMI/Modules/InteractiveCommand/CMIInteractiveCommand.java @@ -4,11 +4,11 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map.Entry; import java.util.Set; import java.util.UUID; import org.bukkit.block.Block; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; @@ -23,179 +23,216 @@ public class CMIInteractiveCommand { private boolean publicIc = false; private boolean signRequiresPerm = true; private Set loc = new HashSet(); + private HashMap uuid = new HashMap(); - private Set CitizensIds = new HashSet(); - private Entity ent; - private List commands = new ArrayList(); + private Set citizensCache = new HashSet(); + private List commands = new ArrayList(); private List signLines = new ArrayList(); public CMIInteractiveCommand(String name) { - this.name = name; + this.name = name; - signLines.add(" "); - signLines.add(" "); - signLines.add(" "); - signLines.add(" "); + signLines.add(" "); + signLines.add(" "); + signLines.add(" "); + signLines.add(" "); } public List getCommands(Player player) { - Snd snd = new Snd(); - snd.setSender(player); - snd.setTarget(player); - return CMI.getInstance().getLM().updateSnd(snd, new ArrayList(commands)); + Snd snd = new Snd(); + snd.setSender(player); + snd.setTarget(player); + return CMI.getInstance().getLM().updateSnd(snd, new ArrayList(commands)); } public List getCommandsOriginal() { - return commands; + return commands; } public List getCommands() { - List cmd = new ArrayList(); - for (String one : commands) { - cmd.add(CMIChatColor.deColorize(one)); - } - return cmd; + List cmd = new ArrayList(); + for (String one : commands) { + cmd.add(CMIChatColor.deColorize(one)); + } + return cmd; } public void setCommands(List commands) { - this.commands = new ArrayList(commands); + this.commands = new ArrayList(commands); } public void addCommand(String commands) { - this.commands.add(commands); + this.commands.add(commands); } public Set getLocList() { - return loc; + return loc; } public List getLocListAsString() { - List ls = new ArrayList(); - for (CMILocation one : loc) { - ls.add(CMI.getInstance().getPlayerManager().convertLocToStringShort(one)); - } - return ls; + List ls = new ArrayList(); + for (CMILocation one : loc) { + ls.add(CMI.getInstance().getPlayerManager().convertLocToStringShort(one)); + } + return ls; } public void setLoc(List loc) { - this.loc.clear(); - this.loc.addAll(loc); + this.loc.clear(); + this.loc.addAll(loc); } public void addLoc(CMILocation loc) { - if (loc == null) - return; - this.loc.add(loc); + if (loc == null) + return; + this.loc.add(loc); } public HashMap getUUIDMap() { - return uuid; + return uuid; } public Set getUUIDList() { - Set ls = new HashSet(); - return ls; + Set ls = new HashSet(); + for (Entry one : uuid.entrySet()) { + ls.add(one.getKey()); + } + return ls; } + @Deprecated public List getIDList() { - List ls = new ArrayList(); - return ls; + List ls = new ArrayList(); + for (Entry one : uuid.entrySet()) { + if (one.getValue().getId() != null) + ls.add(one.getValue().getId()); + } + return ls; + } + + public List getNPCList() { + List ls = new ArrayList(); + for (Entry one : uuid.entrySet()) { + if (one.getValue().getId() != null && one.getValue().getId() >= 0) + ls.add(one.getValue()); + } + return ls; } public List getUUIDStringList() { - List ls = new ArrayList(); - return ls; + List ls = new ArrayList(); + for (UUID one : getUUIDList()) { + ls.add(one.toString()); + } + return ls; } public List getUUIDStringListSave() { - List ls = new ArrayList(); - return ls; + List ls = new ArrayList(); + for (Entry one : this.uuid.entrySet()) { + if (one.getValue().getId() == null || one.getValue().getId() < 0) + ls.add(one.getKey().toString()); + } + return ls; } public void setUUIDList(HashMap uuid) { - this.uuid.clear(); - this.uuid.putAll(uuid); + this.uuid.clear(); + this.uuid.putAll(uuid); } public boolean hasUUID(UUID uuid) { - return this.uuid.containsKey(uuid); + return this.uuid.containsKey(uuid); } public void addUUID(UUID uuid, Integer id) { - this.uuid.putIfAbsent(uuid, (new CMINPC(uuid)).setId(id)); + addUUID(uuid, null, id); } - public String getName() { - return name; + public void addUUID(UUID uuid, UUID secondaryUUID, Integer id) { + this.uuid.putIfAbsent(uuid, new CMINPC(uuid).setId(id).setSecondaryUUID(secondaryUUID)); } - public void setName(String name) { - this.name = name; - } - - public Entity getEnt() { - return ent; + public String getName() { + return name; } - public void setEnt(Entity ent) { - this.ent = ent; + public void setName(String name) { + this.name = name; } public boolean isPublic() { - return publicIc; + return publicIc; } public void setPublic(boolean publicIc) { - this.publicIc = publicIc; + this.publicIc = publicIc; } public boolean containsSigntext() { - return false; + for (String one : this.getSignLines()) { + if (one != null && !one.isEmpty() && !one.equalsIgnoreCase(" ")) + return true; + } + return false; } public List getSignLines() { - return signLines; + while (signLines.size() < 4) { + signLines.add(" "); + } + while (signLines.size() > 4) { + signLines.remove(signLines.size() - 1); + } + return signLines; } public boolean isSignLinesEmpty() { - return true; + for (String one : signLines) { + if (one != null && one.length() > 0 && !one.equalsIgnoreCase(" ")) + return false; + } + return true; } public void updateSignText(final Block block) { - } public void setSignLines(List signLines) { - this.signLines = signLines; + this.signLines = signLines; + } + + public Set getCitizensCache() { + return citizensCache; } - public Set getCitizensIds() { - return CitizensIds; + public void setCitizensCache(Set citizensCache) { + this.citizensCache = citizensCache; } - public void setCitizensIds(Set citizensIds) { - CitizensIds = citizensIds; + public void addCitizensCache(CMINPC citizen) { + this.citizensCache.add(citizen); } public CMIInteractiveCommand removeEntity(UUID uuid) { - if (uuid != null) - CMI.getInstance().getInteractiveCommandManager().removeEntity(uuid); - return this; + if (uuid != null) + CMI.getInstance().getInteractiveCommandManager().removeEntity(uuid); + return this; } public CMIInteractiveCommand removeLoc(CMILocation loc) { - if (loc != null) - CMI.getInstance().getInteractiveCommandManager().removeLoc(loc); - return this; + if (loc != null) + CMI.getInstance().getInteractiveCommandManager().removeLoc(loc); + return this; } public boolean isSignRequiresPerm() { - return signRequiresPerm; + return signRequiresPerm; } public void setSignRequiresPerm(boolean signRequiresPerm) { - this.signRequiresPerm = signRequiresPerm; + this.signRequiresPerm = signRequiresPerm; } } diff --git a/src/com/Zrips/CMI/Modules/InteractiveCommand/CMINPC.java b/src/com/Zrips/CMI/Modules/InteractiveCommand/CMINPC.java index bdcc347..b37e602 100644 --- a/src/com/Zrips/CMI/Modules/InteractiveCommand/CMINPC.java +++ b/src/com/Zrips/CMI/Modules/InteractiveCommand/CMINPC.java @@ -6,27 +6,41 @@ public class CMINPC { private UUID uuid = null; private Integer id = null; + private UUID secondaryUuid = null; + + public CMINPC(int id) { + this.id = id; + } public CMINPC(UUID uuid) { - this.uuid = uuid; + this.uuid = uuid; } public UUID getUuid() { - return uuid; + return uuid; } public CMINPC setUuid(UUID uuid) { - this.uuid = uuid; - return this; + this.uuid = uuid; + return this; } public Integer getId() { - return id; + return id; } public CMINPC setId(Integer id) { - this.id = id; - return this; + this.id = id; + return this; + } + + public UUID getSecondaryUUID() { + return secondaryUuid; + } + + public CMINPC setSecondaryUUID(UUID secondaryUuid) { + this.secondaryUuid = secondaryUuid; + return this; } } diff --git a/src/com/Zrips/CMI/Modules/InteractiveCommand/CitizensManager.java b/src/com/Zrips/CMI/Modules/InteractiveCommand/CitizensManager.java index 4bd7139..f3786ec 100644 --- a/src/com/Zrips/CMI/Modules/InteractiveCommand/CitizensManager.java +++ b/src/com/Zrips/CMI/Modules/InteractiveCommand/CitizensManager.java @@ -6,37 +6,39 @@ import com.Zrips.CMI.CMI; - public class CitizensManager { private CMI plugin; public CitizensManager(CMI plugin) { - this.plugin = plugin; + } public boolean isCitizen(Entity ent) { - return false; + return false; } public UUID getCitizenPrivateUUID(UUID uuid) { - return null; + return null; } public Integer getEntityId(Entity ent) { - return null; + return null; } public Integer getEntityId(UUID uuid) { - - return null; + return null; } public UUID getEntityUUID(Entity ent) { - return null; + return null; } public UUID getEntityUUID(int id) { - return null; + return null; + } + + public UUID getEntityRealUUID(int id) { + return null; } } diff --git a/src/com/Zrips/CMI/Modules/InteractiveCommand/InteractiveCommandListener.java b/src/com/Zrips/CMI/Modules/InteractiveCommand/InteractiveCommandListener.java index 06f890c..ec1018f 100644 --- a/src/com/Zrips/CMI/Modules/InteractiveCommand/InteractiveCommandListener.java +++ b/src/com/Zrips/CMI/Modules/InteractiveCommand/InteractiveCommandListener.java @@ -1,6 +1,15 @@ package com.Zrips.CMI.Modules.InteractiveCommand; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.SignChangeEvent; +import org.bukkit.event.player.PlayerInteractEvent; import com.Zrips.CMI.CMI; @@ -9,7 +18,31 @@ public class InteractiveCommandListener implements Listener { private CMI plugin; public InteractiveCommandListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + +// Pattern patern = Pattern.compile("(^| )\\$\\d(-)?($| )"); + + private static int MAX_ENTRIES = 50; + public static LinkedHashMap limit = new LinkedHashMap(MAX_ENTRIES + 1, .75F, false) { + @Override + protected boolean removeEldestEntry(Map.Entry eldest) { + return size() > MAX_ENTRIES; + } + }; + + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerInteractEvent(final PlayerInteractEvent event) { + } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void blockBreak(BlockBreakEvent event) { + + } + + @EventHandler + public void onSignChangeEvent(SignChangeEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/InteractiveCommand/InteractiveCommandListener1_8.java b/src/com/Zrips/CMI/Modules/InteractiveCommand/InteractiveCommandListener1_8.java index 7c7a801..e72d7a1 100644 --- a/src/com/Zrips/CMI/Modules/InteractiveCommand/InteractiveCommandListener1_8.java +++ b/src/com/Zrips/CMI/Modules/InteractiveCommand/InteractiveCommandListener1_8.java @@ -1,6 +1,9 @@ package com.Zrips.CMI.Modules.InteractiveCommand; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; import com.Zrips.CMI.CMI; @@ -9,7 +12,11 @@ public class InteractiveCommandListener1_8 implements Listener { private CMI plugin; public InteractiveCommandListener1_8(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.NORMAL) + public void PlayerInteractAtEntityEvent(final PlayerInteractAtEntityEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/InteractiveCommand/InteractiveCommandManager.java b/src/com/Zrips/CMI/Modules/InteractiveCommand/InteractiveCommandManager.java index 46d885e..2504ec2 100644 --- a/src/com/Zrips/CMI/Modules/InteractiveCommand/InteractiveCommandManager.java +++ b/src/com/Zrips/CMI/Modules/InteractiveCommand/InteractiveCommandManager.java @@ -8,7 +8,6 @@ import java.util.Set; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Entity; @@ -23,76 +22,86 @@ public class InteractiveCommandManager { private boolean checkCitizens = false; public InteractiveCommandManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } HashMap>> map = new HashMap>>(); - HashMap entMap = new HashMap(); + + HashMap entMap = new HashMap(); HashMap citiznesMap = new HashMap(); LinkedHashMap nameMap = new LinkedHashMap(); public Entity getEntityByUUID(UUID uuid) { - return null; + return null; } public void deleteIC(CMIInteractiveCommand cmib) { + } public void clearLocationsFromIC(CMIInteractiveCommand cmib) { + } public void addEntity(UUID uuid, CMIInteractiveCommand cmib) { + } public CMIInteractiveCommand addInteractiveCommand(CMIInteractiveCommand cmib) { - return addInteractiveCommand(cmib, true); + return addInteractiveCommand(cmib, true); } - public CMIInteractiveCommand addInteractiveCommand(CMIInteractiveCommand cmib, boolean save) { - return cmib; + public CMIInteractiveCommand addInteractiveCommand(CMIInteractiveCommand cmib, boolean save) { + + return cmib; } public Set getFullList() { - Set ls = new HashSet(); - - return ls; + return new HashSet(nameMap.values()); } public Set getSortedByDistance(Location loc) { - - return null; + return null; } public CMIInteractiveCommand getByUUID(UUID uuid) { - return null; + if (this.checkCitizens) { + checkCitizens(); + this.checkCitizens = false; + } + return entMap.get(uuid); } public CMIInteractiveCommand getByCitizensId(Integer id) { - return null; + if (id == null) + return null; + if (this.checkCitizens) { + checkCitizens(); + this.checkCitizens = false; + } + return citiznesMap.get(id); } private void checkCitizens() { - + } public CMIInteractiveCommand getByName(String name) { - return nameMap.get(name.toLowerCase()); + return nameMap.get(name.toLowerCase()); } public CMIInteractiveCommand removeLoc(CMILocation loc) { - - return null; + return null; } public CMIInteractiveCommand removeEntity(UUID uuid) { - - return null; + return null; } public CMIInteractiveCommand getByLoc(Location loc) { - - return null; + + return null; } private int saveId = -1; @@ -103,7 +112,7 @@ public void save() { boolean saving = false; public void forceSave() { - + } public void load() { @@ -111,6 +120,6 @@ public void load() { } public int getSaveId() { - return saveId; + return saveId; } } diff --git a/src/com/Zrips/CMI/Modules/InvEndEditor/EnderChestListener.java b/src/com/Zrips/CMI/Modules/InvEndEditor/EnderChestListener.java index f08f076..7300f6b 100644 --- a/src/com/Zrips/CMI/Modules/InvEndEditor/EnderChestListener.java +++ b/src/com/Zrips/CMI/Modules/InvEndEditor/EnderChestListener.java @@ -1,6 +1,13 @@ package com.Zrips.CMI.Modules.InvEndEditor; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; import com.Zrips.CMI.CMI; @@ -8,7 +15,31 @@ public class EnderChestListener implements Listener { private CMI plugin; public EnderChestListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onEnderChestClick(InventoryClickEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerLoginEnder(PlayerLoginEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerQuitEnder(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onEnderChestDrag(InventoryDragEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onNormalInventoryClose(InventoryCloseEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/InvEndEditor/EnderChestManager.java b/src/com/Zrips/CMI/Modules/InvEndEditor/EnderChestManager.java index 7894677..194a7f7 100644 --- a/src/com/Zrips/CMI/Modules/InvEndEditor/EnderChestManager.java +++ b/src/com/Zrips/CMI/Modules/InvEndEditor/EnderChestManager.java @@ -15,37 +15,37 @@ public class EnderChestManager { private CMI plugin; public EnderChestManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void removeWatcher(Player player) { - EndWatcher ers = WatcherList.remove(player.getUniqueId()); - if (ers != null) - WatchedList.remove(ers.getTarget().getUniqueId()); + EndWatcher ers = WatcherList.remove(player.getUniqueId()); + if (ers != null) + WatchedList.remove(ers.getTarget().getUniqueId()); } public boolean isWatching(Player player) { - return WatcherList.containsKey(player.getUniqueId()); + return WatcherList.containsKey(player.getUniqueId()); } public boolean isBeingWatched(Player player) { - return WatchedList.containsKey(player.getUniqueId()); + return WatchedList.containsKey(player.getUniqueId()); } public EndWatcher getWatcher(Player player) { - return WatcherList.get(player.getUniqueId()); + return WatcherList.get(player.getUniqueId()); } public EndWatcher getSlave(Player player) { - return WatchedList.get(player.getUniqueId()); + return WatchedList.get(player.getUniqueId()); } public boolean openEnderChest(Player player, Player target) { - return false; + return false; } public boolean updateTargetEnderChest(Player player) { - return false; + return true; } } diff --git a/src/com/Zrips/CMI/Modules/InvRegEditor/CMIInvSee.java b/src/com/Zrips/CMI/Modules/InvRegEditor/CMIInvSee.java new file mode 100644 index 0000000..dc60533 --- /dev/null +++ b/src/com/Zrips/CMI/Modules/InvRegEditor/CMIInvSee.java @@ -0,0 +1,80 @@ +package com.Zrips.CMI.Modules.InvRegEditor; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class CMIInvSee { + Player watcher = null; + Player target = null; + private int schedID; + private ItemStack[] contents; + private ItemStack[] armor; + private ItemStack offHand; + private ItemStack cursor; + + public CMIInvSee(Player watcher, Player target) { + this.watcher = watcher; + this.target = target; + } + + public Player getWatcher() { + return this.watcher; + } + + public CMIInvSee setWatcher(Player watcher) { + this.watcher = watcher; + return this; + } + + public Player getTarget() { + if (Bukkit.getPlayer(target.getUniqueId()) != null) + return Bukkit.getPlayer(target.getUniqueId()); + return this.target; + } + + public CMIInvSee setTarget(Player target) { + this.target = target; + return this; + } + + public void setSchedId(int scheduleSyncRepeatingTask) { + this.schedID = scheduleSyncRepeatingTask; + } + + public int getSchedID() { + return schedID; + } + + public void setTargetContents(ItemStack[] contents) { + this.contents = contents; + } + + public void setTargetArmorContents(ItemStack[] armor) { + this.armor = armor; + } + + public ItemStack[] getContents() { + return contents; + } + + public ItemStack[] getArmorContents() { + return armor; + } + + public void setOffHand(ItemStack offHand) { + this.offHand = offHand; + } + + public ItemStack getOffHand() { + return this.offHand; + } + + public ItemStack getCursor() { + return cursor; + } + + public void setCursor(ItemStack cursor) { + this.cursor = cursor; + } +} \ No newline at end of file diff --git a/src/com/Zrips/CMI/Modules/InvRegEditor/RegChestListener.java b/src/com/Zrips/CMI/Modules/InvRegEditor/RegChestListener.java index 0254c7e..6150d23 100644 --- a/src/com/Zrips/CMI/Modules/InvRegEditor/RegChestListener.java +++ b/src/com/Zrips/CMI/Modules/InvRegEditor/RegChestListener.java @@ -1,14 +1,39 @@ package com.Zrips.CMI.Modules.InvRegEditor; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.events.CMIPlayerUnVanishEvent; +import com.Zrips.CMI.events.CMIPlayerVanishEvent; public class RegChestListener implements Listener { CMI plugin; public RegChestListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerLoginEnder(PlayerLoginEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerQuitEnder(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onCMIPlayerVanishEvent(CMIPlayerVanishEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onCMIPlayerUnVanishEvent(CMIPlayerUnVanishEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/InvRegEditor/RegChestListener19.java b/src/com/Zrips/CMI/Modules/InvRegEditor/RegChestListener19.java deleted file mode 100644 index 334e376..0000000 --- a/src/com/Zrips/CMI/Modules/InvRegEditor/RegChestListener19.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.Zrips.CMI.Modules.InvRegEditor; - -import org.bukkit.event.Listener; - -import com.Zrips.CMI.CMI; - -public class RegChestListener19 implements Listener { - CMI plugin; - - public RegChestListener19(CMI plugin) { - this.plugin = plugin; - } - -} diff --git a/src/com/Zrips/CMI/Modules/InvRegEditor/RegChestManager.java b/src/com/Zrips/CMI/Modules/InvRegEditor/RegChestManager.java index 26ee1e0..e6e53aa 100644 --- a/src/com/Zrips/CMI/Modules/InvRegEditor/RegChestManager.java +++ b/src/com/Zrips/CMI/Modules/InvRegEditor/RegChestManager.java @@ -1,122 +1,91 @@ package com.Zrips.CMI.Modules.InvRegEditor; import java.util.HashMap; +import java.util.UUID; import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import com.Zrips.CMI.CMI; +import net.Zrips.CMILib.GUI.CMIGui; +import net.Zrips.CMILib.GUI.GUIManager.GUIClickType; + public class RegChestManager { - private HashMap WatcherList = new HashMap(); + private HashMap watcherList = new HashMap(); + private HashMap slaveList = new HashMap(); private CMI plugin; public RegChestManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public boolean isWatching(Player player) { - return WatcherList.containsKey(player.getName()); - } - - public RegWatcher getWatcher(Player player) { - return WatcherList.get(player.getName()); - } - - public void ReopenNormalChest(final Player player, final Player Target) { - } - - public void removeWatcher(Player player) { - - } - - public boolean isThisSlave(Player player) { - - return false; - } - - public RegWatcher getWatcherInfoBySlave(Player player) { - - return null; - } - - public boolean CheckInvClick(Player player, int slot, String actionName) { - - return false; - } - - public boolean openInventory(Player player, Player Target) { - return true; - } - - public void UpdateSlaveContents(final Player player, ItemStack[] MasterContents) { - - } - - public void UpdateMaster(Player player) { - + return watcherList.containsKey(player.getUniqueId()); } - public void UpdateMasterContents(final Player player) { - UpdateMasterContents(player, true); + public CMIInvSee getInformation(Player player) { + CMIInvSee info = watcherList.get(player.getUniqueId()); + if (info == null) + info = slaveList.get(player.getUniqueId()); + return info; } - public void UpdateMasterContents(final Player player, boolean delay) { - + public void remove(Player player) { } - private void updateMaster(Player player) { - + public CMIInvSee removeWatcher(Player player) { + return watcherList.remove(player.getUniqueId()); } - public void UpdateMasterCrafting(final Player player) { - + public CMIInvSee removeSlave(Player player) { + return slaveList.remove(player.getUniqueId()); } - @Deprecated - public void UpdateSlaveCrafting(final Player player) { + public boolean isSlave(Player player) { + if (slaveList.isEmpty()) + return false; + return slaveList.containsKey(player.getUniqueId()); } - @Deprecated - public void UpdateMasterCraftingResult(final Player player) { + public boolean openInventory(Player watcher, Player target) { + return true; } - public void UpdateMasterArmor(final Player player) { + private void updateWatcherInventory(Player watcher) { } - public void UpdateMasterItemInHand(final Player player) { - + enum sectionType { + inventory, armor, offhand, cursor, crafting; } - public void UpdateSlaveItemInHand(final Player player, ItemStack[] masterContents) { + private boolean invClick(GUIClickType type, sectionType sectionType, UUID uuid, int slot, int realSlot) { + return true; } - public void UpdateMasterOffHand(final Player player) { + private void addInventoryButton(CMIGui gui, ItemStack item, int slot, int realSlot) { } - public void UpdateSlaveOffHand(final Player player, ItemStack[] MasterContents) { - + private double cleanNumber(double number) { + return number * 100 / 100D; } - public void UpdateSlaveArmor(final Player player, ItemStack[] MasterContents) { + public CMIGui createGui(Player watcher, Player target) { + return null; } - @SuppressWarnings("deprecation") - public Inventory CreateGui(Player source, Player player) { + private ItemStack[] getCraftingInventory(Player player) { - return null; - } + ItemStack[] targetContents = player.getOpenInventory().getTopInventory().getContents(); - public ItemStack SlaveCraftInv(Player player, int Slot) { + ItemStack[] contents = new ItemStack[5]; - return null; + return contents; } - } diff --git a/src/com/Zrips/CMI/Modules/InvRegEditor/RegWatcher.java b/src/com/Zrips/CMI/Modules/InvRegEditor/RegWatcher.java deleted file mode 100644 index f63a577..0000000 --- a/src/com/Zrips/CMI/Modules/InvRegEditor/RegWatcher.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.Zrips.CMI.Modules.InvRegEditor; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -public class RegWatcher { - Player master = null; - Player target = null; - - private int schedId = 0; - private ItemStack[] contents = new ItemStack[64]; - - private int actionSchedId = 0; - - public RegWatcher(Player player1, Player target) { - this.master = player1; - this.target = target; - } - - public Player getMaster() { - return this.master; - } - - public void setMaster(Player player) { - this.master = player; - } - - public Player getTarget() { - return this.target; - } - - public void setTarget(Player target) { - this.target = target; - } - - public int getSchedId() { - return schedId; - } - - public void setSchedId(int schedId) { - this.schedId = schedId; - } - - public ItemStack[] getContents() { - return contents; - } - - public void setContents(ItemStack[] contents) { - } - - public int getActionSchedId() { - return actionSchedId; - } - - public void setActionSchedId(int actionSchedId) { - this.actionSchedId = actionSchedId; - } -} \ No newline at end of file diff --git a/src/com/Zrips/CMI/Modules/Ips/IpManager.java b/src/com/Zrips/CMI/Modules/Ips/IpManager.java index 6929c3e..bfeaa4c 100644 --- a/src/com/Zrips/CMI/Modules/Ips/IpManager.java +++ b/src/com/Zrips/CMI/Modules/Ips/IpManager.java @@ -15,24 +15,26 @@ public class IpManager { private static final Pattern ALTPATTERN = Pattern.compile("^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\_){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"); public boolean ipIsOk(final String ip) { - return PATTERN.matcher(ip).matches(); + return PATTERN.matcher(ip).matches(); } public boolean alternateIpIsOk(final String ip) { - return ALTPATTERN.matcher(ip).matches(); + return ALTPATTERN.matcher(ip).matches(); } public IpManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void addIp(HashMap map, CMIUser user) { + } public void addIp(String ip, CMIUser user) { + } public Set getUsers(String ip) { - return ips.get(ip); + return ips.get(ip); } } diff --git a/src/com/Zrips/CMI/Modules/Jail/CMIJail.java b/src/com/Zrips/CMI/Modules/Jail/CMIJail.java index b20991c..b86743e 100644 --- a/src/com/Zrips/CMI/Modules/Jail/CMIJail.java +++ b/src/com/Zrips/CMI/Modules/Jail/CMIJail.java @@ -20,85 +20,93 @@ public class CMIJail { private HashMap cells = new HashMap(); public CMIJail() { - area = new CuboidArea(null); + area = new CuboidArea(null); } public boolean containsLoc(Location loc) { - return area.containsLoc(loc); + return area.containsLoc(loc); } public boolean containsLoc(Location loc, int range) { - return area.containsLoc(loc, range); + return area.containsLoc(loc, range); } public CuboidArea getArea() { - return area; + return area; } public String getName() { - return name; + return name; } public void setName(String name) { - this.name = name; + this.name = name; } public boolean checkCollision(CuboidArea area) { - if (this.area != null && area != null) { - if (this.area.checkCollision(area)) { - return true; - } - } - return false; + if (this.area != null && area != null) { + if (this.area.checkCollision(area)) { + return true; + } + } + return false; } public CuboidArea loadBounds(String root) throws Exception { - return null; + + return null; } public void setArea(CuboidArea area) { - this.area = area; + this.area = area; } public Location getOutsideLocation() { - return safeLoc; + return safeLoc; } @Deprecated public void setOutsideLocation(Location safeLoc) { - if (safeLoc != null) - this.safeLoc = new CMILocation(safeLoc); + if (safeLoc != null) + this.safeLoc = new CMILocation(safeLoc); } public void setOutsideLocation(CMILocation safeLoc) { - this.safeLoc = safeLoc; + this.safeLoc = safeLoc; } public HashMap getCells() { - return cells; + return cells; } public void setCells(HashMap cells) { - this.cells = cells; + this.cells = cells; } public void addCell(CMIJailCell cell) { - if (cell.getId() == null) - cell.setId(this.getNextCellId()); - this.cells.put(cell.getId(), cell); + if (cell.getId() == null) + cell.setId(this.getNextCellId()); + this.cells.put(cell.getId(), cell); } public int getCountInCells() { - if (this.cells.isEmpty()) - return 0; - int i = 0; - return i; + if (this.cells.isEmpty()) + return 0; + int i = 0; + for (Entry one : this.cells.entrySet()) { + i += one.getValue().getJailed().size(); + } + return i; } public int getNextCellId() { - if (this.cells.isEmpty()) - return 1; - int i = 1; - return i; + if (this.cells.isEmpty()) + return 1; + int i = 1; + for (Entry one : this.cells.entrySet()) { + if (one.getKey() >= i) + i = one.getKey() + 1; + } + return i; } } diff --git a/src/com/Zrips/CMI/Modules/Jail/CMIJailCell.java b/src/com/Zrips/CMI/Modules/Jail/CMIJailCell.java index f6c68d6..d8ec545 100644 --- a/src/com/Zrips/CMI/Modules/Jail/CMIJailCell.java +++ b/src/com/Zrips/CMI/Modules/Jail/CMIJailCell.java @@ -1,6 +1,7 @@ package com.Zrips.CMI.Modules.Jail; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import java.util.UUID; @@ -14,65 +15,63 @@ public class CMIJailCell { private Integer id; private CMILocation teleportInLocation; private World world; - private Set jailedOnes = new HashSet(); + private Set jailedOnes = new LinkedHashSet(); private CMIJail jail; public CMIJailCell(CMIJail jail) { - this.jail = jail; + this.jail = jail; } public Integer getId() { - return id; + return id; } public void setId(int id) { - this.id = id; + this.id = id; } - public void loadJailed(String root) throws Exception { - } public CMILocation getTeleportInLocation() { - return teleportInLocation; + return teleportInLocation; } @Deprecated public void setTeleportInLocation(Location safeLoc) { - if (safeLoc != null) - this.teleportInLocation = new CMILocation(safeLoc); + if (safeLoc != null) + this.teleportInLocation = new CMILocation(safeLoc); } public void setTeleportInLocation(CMILocation safeLoc) { - this.teleportInLocation = safeLoc; + this.teleportInLocation = safeLoc; } public World getWorld() { - return world; + return world; } public void setWorld(World world) { - this.world = world; + this.world = world; } public Set getJailed() { - return jailedOnes; + return jailedOnes; } public void setJailed(HashSet jailedOnes) { - this.jailedOnes = jailedOnes; + this.jailedOnes = jailedOnes; } public void addJailed(UUID uuid) { - this.jailedOnes.add(uuid); + this.jailedOnes.add(uuid); } public void removeJailed(UUID uuid) { - this.jailedOnes.remove(uuid); + this.jailedOnes.remove(uuid); } public CMIJail getJail() { - return jail; + return jail; } } diff --git a/src/com/Zrips/CMI/Modules/Jail/JailListener.java b/src/com/Zrips/CMI/Modules/Jail/JailListener.java index 7dac806..480c6a0 100644 --- a/src/com/Zrips/CMI/Modules/Jail/JailListener.java +++ b/src/com/Zrips/CMI/Modules/Jail/JailListener.java @@ -4,9 +4,24 @@ import java.util.Map; import java.util.UUID; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.events.CMIAfkEnterEvent; +import com.Zrips.CMI.events.CMIAfkLeaveEvent; public class JailListener implements Listener { private CMI plugin; @@ -14,8 +29,73 @@ public class JailListener implements Listener { protected Map lastUpdate; public JailListener(CMI plugin) { - this.plugin = plugin; - lastUpdate = new HashMap(); + this.plugin = plugin; + lastUpdate = new HashMap(); } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onFoodChange(FoodLevelChangeEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMove(PlayerMoveEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerQuitEvent(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerJoinEvent(PlayerJoinEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onPlayerInteract(InventoryClickEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onPlayerInteract(PlayerDropItemEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onHit(EntityDamageByEntityEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onPlayerDamage(EntityDamageEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onPlayerMove(PlayerCommandPreprocessEvent event) { + + } + + @SuppressWarnings("deprecation") + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void PlayerPickupItemEvent(PlayerPickupItemEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW) + public void AsyncPlayerChatEvent(AsyncPlayerChatEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void CMIAfkEnterEvent(CMIAfkEnterEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void CMIAfkEnterEvent(CMIAfkLeaveEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Jail/JailManager.java b/src/com/Zrips/CMI/Modules/Jail/JailManager.java index 945e115..df353b1 100644 --- a/src/com/Zrips/CMI/Modules/Jail/JailManager.java +++ b/src/com/Zrips/CMI/Modules/Jail/JailManager.java @@ -1,12 +1,19 @@ package com.Zrips.CMI.Modules.Jail; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.SortedMap; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; @@ -14,6 +21,8 @@ import com.Zrips.CMI.Modules.Portals.CuboidArea; import com.Zrips.CMI.Modules.Portals.CuboidArea.ChunkRef; +import net.Zrips.CMILib.Time.CMITimeManager; + public class JailManager { private SortedMap jails; @@ -28,66 +37,98 @@ public class JailManager { private boolean NoAfk = false; private boolean PreventDamage = true; private boolean noHunger = true; + private List cmdsOnUnJail; + private List cmdsOnJail; private List whiteList; private CMI plugin; public JailManager(CMI plugin) { + } private int sched = -1; public void recheckAllOnline() { + } public void stop() { + } private void tasker() { + } public boolean anyJailedOnline() { - return !onlineInjail.isEmpty(); + return !onlineInjail.isEmpty(); } public void removeOnline(CMIUser user) { + if (user == null) + return; + onlineInjail.remove(user); } public void addOnline(CMIUser user) { + if (user == null) + return; + + onlineInjail.add(user); + tasker(); } public void addJail(CMIJail jail) { + jails.put(jail.getName().toLowerCase(), jail); + recalculateChunks(jail); } public void recalculateChunks() { + chunkJails.clear(); + for (Entry one : this.jails.entrySet()) { + recalculateChunks(one.getValue()); + } } public void recalculateChunks(CMIJail jail) { + } public CMIJail getByName(String name) { - if (name == null) - return null; - return jails.get(name.toLowerCase()); + if (name == null) + return null; + return jails.get(name.toLowerCase()); } public CMIJail getByLoc(Location loc) { - return null; + return null; } public CMIJail collidesWithJail(CuboidArea newarea) { - return collidesWithJail(newarea, null); + return collidesWithJail(newarea, null); } public CMIJail collidesWithJail(CuboidArea newarea, CMIJail ignore) { - return null; + Set> set = jails.entrySet(); + for (Entry entry : set) { + CMIJail check = entry.getValue(); + if (check.checkCollision(newarea)) { + if (ignore != null && ignore.equals(check)) + continue; + return entry.getValue(); + } + } + return null; } private static List getChunks(CMIJail jail) { - return jail.getArea().getChunks(); + return jail.getArea().getChunks(); } private static List getChunks(CMIJail jail, int range) { - return null; + List chunks = new ArrayList<>(); + chunks.addAll(jail.getArea().getChunks(range)); + return chunks; } public void loadConfig() { @@ -95,115 +136,165 @@ public void loadConfig() { } public void load() { - + Long time = System.currentTimeMillis(); + jails.clear(); + chunkJails.clear(); + + File file = new File(plugin.getDataFolder(), "jails.yml"); + + if (!file.exists()) { + try { + file.createNewFile(); + } catch (IOException e) { + } + return; + } + + YamlConfiguration k = null; + try { + k = YamlConfiguration.loadConfiguration(file); + } catch (Exception e) { + return; + } + + if (k.getKeys(false).isEmpty()) + return; + + Map root = k.getValues(false); + + for (Entry world : root.entrySet()) { + Map jaillist = k.getValues(false); + if (jaillist != null) { + try { + loadMap(jaillist); + } catch (Exception ex) { + plugin.sendMessage(Bukkit.getConsoleSender(), ChatColor.RED + "Error in loading jails file for world: " + world.getKey()); + } + } + } + plugin.loadMessage(jails.size(), "jails", System.currentTimeMillis() - time); } public void loadMap(Map root) throws Exception { - + } public void save() { - + } public SortedMap getJails() { - return jails; + return jails; } public List getJailsByDistance(Location loc) { - return null; + List sortedList = new ArrayList(); + + return sortedList; } public void removeJail(CMIJail jail) { - jails.remove(jail.getName().toLowerCase()); - this.recalculateChunks(); - this.save(); + jails.remove(jail.getName().toLowerCase()); + this.recalculateChunks(); + this.save(); } public int getJailsCheckInterval() { - return JailCheckInterval; + return JailCheckInterval; } private boolean isCellOk(CMIJailCell cell) { - - return true; + return true; } private boolean isJailOk(CMIJail jail) { - - return true; + if (jail == null) + return false; + if (this.getByName(jail.getName()) == null) + return false; + return true; } public CMIJailCell getValidCell(CMIUser user) { - return getValidCell(user, null, null); + return getValidCell(user, null, null); } public CMIJailCell getValidCell(CMIUser user, CMIJail j, Integer cellId) { - - return null; + + return null; } public void removePlayerFromJail(CMIUser user) { - + } public void placePlayerIntoJail(CMIUser user) { - placePlayerIntoJail(user, null, null, user.getJailedForTime()); + placePlayerIntoJail(user, null, null, user.getJailedForTime()); } public boolean placePlayerIntoJail(CMIUser user, CMIJail jail, Integer cellId, Long jailedFor) { - - return true; + return true; } public void informAboutLeftTime(Player player) { - informAboutLeftTime(plugin.getPlayerManager().getUser(player)); + informAboutLeftTime(plugin.getPlayerManager().getUser(player)); } public void informAboutLeftTime(CMIUser user) { - + if (!user.isJailed()) + return; + + long left = user.getJailedForTime(); + + plugin.sendMessage(user, plugin.getIM("jail", "leftTime", "[time]", CMITimeManager.to24hourShort(left))); } public boolean canUseCommand(String command) { - - return false; + command = command.toLowerCase(); + if (command.contains("/")) + command = command.substring(1); + for (String one : whiteList) { + if (command.startsWith(one)) + return true; + } + return false; } public Integer getDefaultTime() { - return DefaultTime; + return DefaultTime; } public void setDefaultTime(int defaultTime) { - DefaultTime = defaultTime; + DefaultTime = defaultTime; } public Integer getJailChatRange() { - return JailChatRange; + return JailChatRange; } public void setJailChatRange(Integer jailChatRange) { - JailChatRange = jailChatRange; + JailChatRange = jailChatRange; } public boolean isNoAfk() { - return NoAfk; + return NoAfk; } public boolean isCountWhileOffline() { - return CountWhileOffline; + return CountWhileOffline; } public void setCountWhileOffline(boolean countWhileOffline) { - CountWhileOffline = countWhileOffline; + CountWhileOffline = countWhileOffline; } public boolean isPreventDamage() { - return PreventDamage; + return PreventDamage; } public boolean isNoHunger() { - return noHunger; + return noHunger; } } diff --git a/src/com/Zrips/CMI/Modules/Kits/Clickery.java b/src/com/Zrips/CMI/Modules/Kits/Clickery.java index c8a827d..6e450d9 100644 --- a/src/com/Zrips/CMI/Modules/Kits/Clickery.java +++ b/src/com/Zrips/CMI/Modules/Kits/Clickery.java @@ -10,7 +10,7 @@ public Clickery() { this.time = System.currentTimeMillis(); } - private void addClick() { + private void addClick() { } public int getSpeed() { diff --git a/src/com/Zrips/CMI/Modules/Kits/Kit.java b/src/com/Zrips/CMI/Modules/Kits/Kit.java index 080cea7..dcd76f3 100644 --- a/src/com/Zrips/CMI/Modules/Kits/Kit.java +++ b/src/com/Zrips/CMI/Modules/Kits/Kit.java @@ -8,11 +8,11 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BookMeta; -import org.bukkit.inventory.meta.ItemMeta; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Colors.CMIChatColor; import com.Zrips.CMI.Containers.CMIPlayerInventory.CMIInventorySlot; + +import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Items.CMIMaterial; public class Kit { @@ -37,6 +37,7 @@ public class Kit { private String cmdName = null; private Integer slot = null; + private Integer page = null; private int maxUsages = -1; private boolean showDespiteUsage = false; @@ -45,303 +46,339 @@ public class Kit { private boolean dropItems = true; public Kit(String name) { - this.name = CMIChatColor.stripColor(name); - reset(); + this.name = CMIChatColor.stripColor(name); + reset(); } public void reset() { } public ItemStack getFirstNotNullItem() { - return null; + for (ItemStack one : item) { + checkBook(one); + if (one != null && one.getType() != Material.AIR) + return one; + } + return null; } public List getItems() { - return null; + for (ItemStack one : item) { + checkBook(one); + } + return item; } public List getItems(Player player) { - - return null; + List t = new ArrayList(); + + return t; } private ItemStack checkBook(ItemStack book) { - - return null; + if (book == null || book.getItemMeta() == null || !(book.getItemMeta() instanceof BookMeta)) + return book; + return book; } public void setItem(List item) { - } public void setItem(int slot, ItemStack item) { - } public void addItem(ItemStack item) { - } public List getCommands(Player player) { - - return null; + List t = new ArrayList(); + return t; } public List getCommands() { - return commands; + return commands; } public void setCommands(List commands) { - this.commands = commands; + this.commands = commands; } public double getCost() { - return cost; + return cost; } public void setCost(double cost) { - this.cost = cost; + this.cost = cost; } public int getExpCost() { - return expCost; + return expCost; } public void setExpCost(int expCost) { - this.expCost = expCost; + this.expCost = expCost; } public long getDelay() { - return delay; + return delay; } public void setDelay(long delay) { - this.delay = delay; + this.delay = delay; } -// public boolean isOneTimeUse() { -// return this.delay <= -1; -// } - public List getConditions() { - return conditions; + return conditions; } public void setConditions(List conditions) { - this.conditions = conditions; + this.conditions = conditions; } public String getConfigName() { - return name; + return name; } public void setName(String name) { - this.name = CMIChatColor.stripColor(name); + this.name = CMIChatColor.stripColor(name); } public List getDescription(Player player) { - return null; + List t = new ArrayList(); + for (String one : this.Description) { + t.add(CMI.getInstance().getKitsManager().processText(one, player, this)); + } + return t; } public List getDescription() { - return Description; + return Description; } public void setDescription(List description) { - Description = description; + Description = description; } public String getGroup() { - return group; + return group; } public void setGroup(String group) { - if (group.equalsIgnoreCase("na") || group.equalsIgnoreCase("none")) - this.group = null; - else - this.group = group; + if (group.equalsIgnoreCase("na") || group.equalsIgnoreCase("none")) + this.group = null; + else + this.group = group; } public boolean isEnabled() { - return enabled; + return enabled; } public void setEnabled(boolean enabled) { - this.enabled = enabled; + this.enabled = enabled; } public int getWeight() { - return weight; + return weight; } public void setWeight(int weight) { - this.weight = weight; + this.weight = weight; } public String getCommandName() { - if (cmdName == null) - cmdName = this.getConfigName(); - return cmdName; + if (cmdName == null) + cmdName = this.getConfigName(); + return cmdName; } public void setCommandName(String CommandName) { - this.cmdName = CommandName; + this.cmdName = CommandName; } public ItemStack getExtraItem(CMIInventorySlot slot) { - return extraItems.get(slot); + return extraItems.get(slot); } public ItemStack getExtraItem(Player player, CMIInventorySlot slot) { - return null; + ItemStack item = getExtraItem(slot); + + return item; } public void setExtraItem(CMIInventorySlot slot, ItemStack item) { - if (item != null) - extraItems.put(slot, item.clone()); - else - extraItems.put(slot, null); + if (item != null) + extraItems.put(slot, item.clone()); + else + extraItems.put(slot, null); } @Deprecated public ItemStack getHelmet() { - return extraItems.get(CMIInventorySlot.Helmet); + return extraItems.get(CMIInventorySlot.Helmet); } @Deprecated public void setHelmet(ItemStack helmet) { - if (helmet != null) - extraItems.put(CMIInventorySlot.Helmet, helmet.clone()); + if (helmet != null) + extraItems.put(CMIInventorySlot.Helmet, helmet.clone()); } @Deprecated public ItemStack getChest() { - return extraItems.get(CMIInventorySlot.ChestPlate); + return extraItems.get(CMIInventorySlot.ChestPlate); } @Deprecated public void setChest(ItemStack chest) { - if (chest != null) - extraItems.put(CMIInventorySlot.ChestPlate, chest.clone()); + if (chest != null) + extraItems.put(CMIInventorySlot.ChestPlate, chest.clone()); } @Deprecated public ItemStack getLegs() { - return extraItems.get(CMIInventorySlot.Pants); + return extraItems.get(CMIInventorySlot.Pants); } @Deprecated public void setLegs(ItemStack legs) { - if (legs != null) - extraItems.put(CMIInventorySlot.Pants, legs.clone()); + if (legs != null) + extraItems.put(CMIInventorySlot.Pants, legs.clone()); } @Deprecated public ItemStack getBoots() { - return extraItems.get(CMIInventorySlot.Boots); + return extraItems.get(CMIInventorySlot.Boots); } @Deprecated public void setBoots(ItemStack boots) { - if (boots != null) - extraItems.put(CMIInventorySlot.Boots, boots.clone()); + if (boots != null) + extraItems.put(CMIInventorySlot.Boots, boots.clone()); } @Deprecated public ItemStack getOffHand() { - return extraItems.get(CMIInventorySlot.OffHand); + return extraItems.get(CMIInventorySlot.OffHand); } @Deprecated public void setOffHand(ItemStack offHand) { - if (offHand != null) - extraItems.put(CMIInventorySlot.OffHand, offHand.clone()); + if (offHand != null) + extraItems.put(CMIInventorySlot.OffHand, offHand.clone()); } public Integer getSlot() { - return slot; + return slot; } public void setSlot(Integer slot) { - this.slot = slot; + if (slot == null) { + this.slot = slot; + return; + } + + if (slot > 27) + this.slot = 27; + else if (slot < 0) + this.slot = null; + else + this.slot = slot; } public ItemStack getSafeIcon() { - if (Icon != null) - return Icon.clone(); - return this.item.isEmpty() ? CMIMaterial.WHITE_WOOL.newItemStack() : getFirstNotNullItem() != null ? getFirstNotNullItem() : CMIMaterial.WHITE_WOOL.newItemStack(); + if (Icon != null) + return Icon.clone(); + return this.item.isEmpty() ? CMIMaterial.WHITE_WOOL.newItemStack() : getFirstNotNullItem() != null ? getFirstNotNullItem() : CMIMaterial.WHITE_WOOL.newItemStack(); } public ItemStack getIcon() { - if (Icon != null) - return Icon.clone(); - return Icon; + if (Icon != null) + return Icon.clone(); + return Icon; } public void setIcon(ItemStack icon) { - Icon = icon; + Icon = icon; } public ItemStack getSafeIconOff() { - if (IconOff != null) - return IconOff.clone(); - return getSafeIcon(); + if (IconOff != null) + return IconOff.clone(); + return getSafeIcon(); } public ItemStack getIconOff() { - if (IconOff != null) - return IconOff.clone(); - return getIcon(); + if (IconOff != null) + return IconOff.clone(); + return getIcon(); } public void setIconOff(ItemStack iconOff) { - IconOff = iconOff; + IconOff = iconOff; } public int getMaxUsages() { - return maxUsages; + return maxUsages; } public void setMaxUsages(int maxUsages) { - this.maxUsages = maxUsages; + this.maxUsages = maxUsages; } public boolean isLimitedUse() { - return this.maxUsages > 0; + return this.maxUsages > 0; } public boolean isShowDespiteWeight() { - return showDespiteWeight; + return showDespiteWeight; } public void setShowDespiteWeight(boolean showDespiteWeight) { - this.showDespiteWeight = showDespiteWeight; + this.showDespiteWeight = showDespiteWeight; } public boolean isDropItems() { - return dropItems; + return dropItems; } public void setDropItems(boolean dropItems) { - this.dropItems = dropItems; + this.dropItems = dropItems; } public String getDisplayName() { - return displayName == null ? getCommandName() : displayName; + return displayName == null ? getCommandName() : displayName; } public void setDisplayName(String displayName) { - this.displayName = displayName; + this.displayName = displayName; } public boolean isShowDespiteUsage() { - return showDespiteUsage; + return showDespiteUsage; } public void setShowDespiteUsage(boolean showDespiteUsage) { - this.showDespiteUsage = showDespiteUsage; + this.showDespiteUsage = showDespiteUsage; + } + + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + + if (page == null) { + this.page = page; + return; + } + + if (page < 1) + this.page = null; + else + this.page = page; } } diff --git a/src/com/Zrips/CMI/Modules/Kits/KitListener.java b/src/com/Zrips/CMI/Modules/Kits/KitListener.java index 7163715..ea46e8e 100644 --- a/src/com/Zrips/CMI/Modules/Kits/KitListener.java +++ b/src/com/Zrips/CMI/Modules/Kits/KitListener.java @@ -1,7 +1,5 @@ package com.Zrips.CMI.Modules.Kits; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -13,6 +11,10 @@ public class KitListener implements Listener { private CMI plugin; public KitListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerFirstLogin(PlayerJoinEvent event) { } } diff --git a/src/com/Zrips/CMI/Modules/Kits/KitsManager.java b/src/com/Zrips/CMI/Modules/Kits/KitsManager.java index b221019..3c3577d 100644 --- a/src/com/Zrips/CMI/Modules/Kits/KitsManager.java +++ b/src/com/Zrips/CMI/Modules/Kits/KitsManager.java @@ -1,8 +1,10 @@ package com.Zrips.CMI.Modules.Kits; +import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map.Entry; import java.util.UUID; import org.bukkit.Bukkit; @@ -10,10 +12,14 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIUser; +import net.Zrips.CMILib.FileHandler.ConfigReader; +import net.Zrips.CMILib.Items.CMIItemStack; + public class KitsManager { private LinkedHashMap map = new LinkedHashMap(); @@ -21,282 +27,360 @@ public class KitsManager { // private HashMap chatMap = new HashMap(); private static HashMap> cloneCache = new HashMap>(); + private String NewbieKitName; private Kit NewbieKit; private CMI plugin; + private boolean KitsGUI = true; +// private boolean complexGui = true; + private boolean KitsGUIFillEmptyFields = true; + private boolean allowKitPreview = true; + + HashMap kitButtons = new HashMap(); + + private boolean guiCloseButton; + private int guiCloseButtonSlot; + private CMIItemStack guiCloseButtonItem; + private List guiCloseButtonCommands; + + private boolean guiInfoButton; + private int guiInfoButtonSlot; + private CMIItemStack guiInfoButtonItem; + private List guiInfoButtonCommands; + public void clearCache(UUID uuid) { - clickeryMap.remove(uuid); - cloneCache.remove(uuid); + clickeryMap.remove(uuid); + cloneCache.remove(uuid); // chatMap.remove(uuid); } public void onDisable() { + if (saveId != -1) { + Bukkit.getScheduler().cancelTask(saveId); + saveId = -1; + save(); + } } public KitsManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + public void loadConfig(ConfigReader cfg) { + + } public void addKit(Kit kit) { - map.put(kit.getConfigName().toLowerCase(), kit); + map.put(kit.getConfigName().toLowerCase(), kit); } public boolean removeKit(String name) { - return map.remove(name.toLowerCase()) != null; + return map.remove(name.toLowerCase()) != null; } public void renameKitConfigName(Kit kit, String newName) { - map.remove(kit.getConfigName().toLowerCase()); - kit.setName(newName); - map.put(kit.getConfigName().toLowerCase(), kit); - save(); + map.remove(kit.getConfigName().toLowerCase()); + kit.setName(newName); + map.put(kit.getConfigName().toLowerCase(), kit); + save(); } public void renameKitCommandName(Kit kit, String newName) { - kit.setCommandName(newName); - save(); + kit.setCommandName(newName); + save(); } public HashMap> getValidKitsForPlayer(Player player, boolean includePreview) { - return null; + return null; } public Kit getKit(Player player, String name) { - return getKit(player, name, false); + return getKit(player, name, false); } public Kit getKit(Player player, String name, boolean ignorePerm) { - return getKit(player, name, ignorePerm, false); + return getKit(player, name, ignorePerm, false); } public Kit getKit(Player player, String name, boolean ignorePerm, boolean includePreview) { - - return null; + Kit kit = null; + + return kit; } public Kit getKit(String name, boolean getdisabled) { - - return null; + if (name == null) + return null; + Kit kit = map.get(name.toLowerCase()); + if (kit != null && !kit.isEnabled()) { + if (getdisabled) + return kit; + return null; + } + return kit; } public List getKitsByCommandName(Kit kit) { - - return null; + List l = new ArrayList(); + for (Entry one : map.entrySet()) { + if (one.getValue().getCommandName().equalsIgnoreCase(kit.getCommandName())) + l.add(one.getValue()); + } + return l; } public List getGroupedKits(Kit kit) { - - return null; + List l = new ArrayList(); + + return l; } public LinkedHashMap getKitMap() { - return map; + return map; } public void setKits(LinkedHashMap map) { - this.map = map; + this.map = map; } public void load() { - + } private int saveId = -1; public void safeSave() { - if (saveId != -1) - return; + if (saveId != -1) + return; - saveId = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CMI.getInstance(), new Runnable() { - @Override - public void run() { - save(); - saveId = -1; - } - }, 60 * 20); + saveId = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CMI.getInstance(), new Runnable() { + @Override + public void run() { + save(); + saveId = -1; + } + }, 60 * 20); } public void save() { - + } private static Material getMaterial(String val) { - - return null; + + return null; } private static Integer getData(String val) { - return 0; + + return 0; } public ItemStack updateItemStackLore(ItemStack item, Player player, Kit kit) { - - return null; + ItemMeta meta = item.getItemMeta(); + + if (meta.hasDisplayName()) { + meta.setDisplayName(processText(meta.getDisplayName(), player, kit)); + } + if (meta.hasLore()) { + List lore = new ArrayList(); + for (String oneL : meta.getLore()) { + lore.add(processText(oneL, player, kit)); + } + meta.setLore(lore); + } + item.setItemMeta(meta); + return item; } public String processText(String text, Player player, Kit kit) { - - return null; + + return text; } public void listPlayersKits(Player player) { - listPlayersKits(null, player, 1); + listPlayersKits(null, player, 1); } public void listPlayersKits(CommandSender sender, Player player, int page) { - } private List getLoreForButton(CMIUser user, Kit kit) { - - return null; + Long time = user.getKitTime(kit); + List lore = new ArrayList(); + + return lore; + } + + private int slotToGUIrelativeSlot(int slot) { + return 9 + (((slot) / 7) * 2 + 1) + slot; + } + + public void listPlayersKitsInComplexGUI(Player player, int page) { + } public void listPlayersKitsInGUI(Player player) { - listPlayersKitsInGUI(player, 1); + listPlayersKitsInGUI(player, 1); } public void listPlayersKitsInGUI(Player player, int page) { +// if (complexGui) + listPlayersKitsInComplexGUI(player, page); +// else +// listPlayersKitsInSimpleGUI(player, page); + } + + @Deprecated + public void listPlayersKitsInSimpleGUI(Player player, int page) { } public void listPlayersKitsForEditing(Player player, Integer page) { - + } public boolean startChatKitAdd(Player player, String kitName) { - return true; + return true; } public boolean startChatKitRename(Player player, Kit kit) { - - return true; + + return true; } public boolean startChatKitCommandRename(Player player, Kit kit) { - - return true; + + return true; } public boolean startChatKitGroupRename(Player player, Kit kit) { - - return true; + + return true; } public void startChatKitRemove(Player player, Kit kit, boolean confirmed) { - + } - private static int min = 36; public void giveKit(Player player, Kit kit) { - giveKit(player, kit, true); + giveKit(player, kit, true); } public void giveKit(Player player, Kit kit, boolean giveItems) { } - String newbieKitName; - public Kit getNewbieKit() { - if (NewbieKit == null) - this.NewbieKit = this.getKit(newbieKitName, true); - return NewbieKit; - } - - public void setNewbieKit(String name) { - newbieKitName = name; + if (NewbieKit == null) + this.NewbieKit = this.getKit(NewbieKitName, true); + return NewbieKit; } public enum CMIKitGUILayout { - Separator(-1), - OffHand(11), - Helmet(0), - Chest(9), - Legs(1), - Boots(10), - Clone(4), + Separator(-1), + OffHand(11), + Helmet(0), + Chest(9), + Legs(1), + Boots(10), + Clone(4), - configName(39), - commandName(40), - displayName(49), + configName(39), + commandName(40), + displayName(49), - ShowDespiteWeight(36), - Weight(37), - Group(28), + ShowDespiteWeight(36), + Weight(37), + Group(28), - Slot(15), + Slot(15), + Page(6), - DropItems(35), + DropItems(35), - Icon(12), - IconCD(13), + Icon(12), + IconCD(13), - Delay(10), + Delay(10), - Money(21), - Exp(22), - Back(9), + Money(21), + Exp(22), + Back(9), - Commands(33), - Conditions(42), - ShowWithoutUsage(18), - Usages(19), - Description(24), - Enabled(8), - Settings(17), - MainMenu(17); + Commands(33), + Conditions(42), + ShowWithoutUsage(18), + Usages(19), + Description(24), + Enabled(8), + Settings(17), + MainMenu(17); - private Integer slots; + private Integer slots; - CMIKitGUILayout(Integer slot) { - this.slots = slot; - } + CMIKitGUILayout(Integer slot) { + this.slots = slot; + } - public Integer getSlot() { - return slots; - } + public Integer getSlot() { + return slots; + } - public static CMIKitGUILayout getButton(int slot) { - for (CMIKitGUILayout one : CMIKitGUILayout.values()) { - if (one.getSlot() == slot) - return one; - } - return null; - } + public static CMIKitGUILayout getButton(int slot) { + for (CMIKitGUILayout one : CMIKitGUILayout.values()) { + if (one.getSlot() == slot) + return one; + } + return null; + } } public void openGuiEditorMain(Kit kit, Player player, boolean editor) { - + } public static void saveOnClose() { - CMI.getInstance().getKitsManager().save(); + CMI.getInstance().getKitsManager().save(); } public static void ItemClickInGui(final Player player, final Kit kit) { - + } public static void openGuiEditorSettingsPreview(Player player, Kit kit) { - CMI.getInstance().getKitsManager().openGuiEditorSettings(kit, player, false); + CMI.getInstance().getKitsManager().openGuiEditorSettings(kit, player, false); } public void openGuiEditorSettings(final Kit kit, final Player player, final boolean editor) { - + } private static int getSpeed(UUID uuid) { - Clickery clickery = clickeryMap.get(uuid); - int speed = 1; - return speed; + Clickery clickery = clickeryMap.get(uuid); + int speed = 1; + if (clickery == null) { + clickeryMap.put(uuid, new Clickery()); + } else + speed = clickery.getSpeed(); + return speed; } + public CMIItemStack getKitPreviewIcon(CMIKitGUILayout type) { + return kitButtons.get(type) == null ? new CMIItemStack(new ItemStack(Material.STONE)) : kitButtons.get(type); + } + + public boolean isKitsGUI() { + return KitsGUI; + } + + public boolean isKitsGUIFillEmptyFields() { + return KitsGUIFillEmptyFields; + } } diff --git a/src/com/Zrips/CMI/Modules/LightFix/LightFix.java b/src/com/Zrips/CMI/Modules/LightFix/LightFix.java index c72cf32..e173e8c 100644 --- a/src/com/Zrips/CMI/Modules/LightFix/LightFix.java +++ b/src/com/Zrips/CMI/Modules/LightFix/LightFix.java @@ -1,18 +1,9 @@ package com.Zrips.CMI.Modules.LightFix; -import java.util.ArrayList; -import java.util.List; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.World; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Modules.Region.CMIRegion; -import com.Zrips.CMI.Modules.Region.WorldInfo; - -import net.Zrips.CMILib.ActionBar.CMIActionBar; public class LightFix { @@ -20,13 +11,13 @@ public class LightFix { private CMI plugin; public LightFix(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void start(LightFixInfo scan) { - if (scan.getStartTime() == 0L) - scan.setShowInfo(System.currentTimeMillis()); - loadChunk(scan); + if (scan.getStartTime() == 0L) + scan.setShowInfo(System.currentTimeMillis()); + loadChunk(scan); } private void loadChunk(final LightFixInfo info) { diff --git a/src/com/Zrips/CMI/Modules/Mirror/MirrorListener.java b/src/com/Zrips/CMI/Modules/Mirror/MirrorListener.java index c2f10e0..e13d3ca 100644 --- a/src/com/Zrips/CMI/Modules/Mirror/MirrorListener.java +++ b/src/com/Zrips/CMI/Modules/Mirror/MirrorListener.java @@ -14,7 +14,16 @@ public class MirrorListener implements Listener { private CMI plugin; public MirrorListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.MONITOR) + public void BlockPlaceEvent(BlockPlaceEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void BlockBreakEvent(BlockBreakEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Mirror/MirrorManager.java b/src/com/Zrips/CMI/Modules/Mirror/MirrorManager.java index cf520c8..d1953bc 100644 --- a/src/com/Zrips/CMI/Modules/Mirror/MirrorManager.java +++ b/src/com/Zrips/CMI/Modules/Mirror/MirrorManager.java @@ -1,84 +1,66 @@ package com.Zrips.CMI.Modules.Mirror; -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Map.Entry; import java.util.Set; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.BlockState; import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.FixedMetadataValue; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.CMIBlock; -import com.Zrips.CMI.Containers.CMIBlock.FlipDirection; -import com.Zrips.CMI.Containers.CMIEvent; import com.Zrips.CMI.Containers.CMIUser; -import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.GUI.CMIGui; -import net.Zrips.CMILib.GUI.CMIGuiButton; -import net.Zrips.CMILib.GUI.GUIManager.GUIClickType; -import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Version.Version; +import net.Zrips.CMILib.Container.CMIBlock; public class MirrorManager { public enum MirrorAction { - X("&eMirrors by &6X &eaxis", 1), - Y("&eMirrors by &6Y &eaxis", 3), - Z("&eMirrors by &6Z &eaxis", 5), - - XY("&eMirrors by &6X &eto &6Y &eaxis", 11), - ZY("&eMirrors by &6Z &eto &6Y &eaxis", 13), - XZ("&eMirrors by &6X &eto &6Z &eaxis", 20), - ZX("&eMirrors by &6Z &eto &6Y &eaxis", 22), - Rotate90V("&eRotates up", 28), - Rotate90H("&eRotates &690 &edegrees clock wise", 29), - Rotate90HC("&eRotates &690 &edegrees counter clock wise", 31), - Rotate180H("&eRotates &6180 &edegrees", 32), - Pause("&ePauses mirroring", 16), - Location("&eSets mirroring center location", 34); - - private int slot; - private String desc; - private String name; - - private MirrorAction(String desc, int slot) { - this.slot = slot; - this.desc = desc; - } - - public int getSlot() { - return this.slot; - } - - public String getDesc() { - return this.desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } + X("&eMirrors by &6X &eaxis", 1), + Y("&eMirrors by &6Y &eaxis", 3), + Z("&eMirrors by &6Z &eaxis", 5), + + XY("&eMirrors by &6X &eto &6Y &eaxis", 11), + ZY("&eMirrors by &6Z &eto &6Y &eaxis", 13), + XZ("&eMirrors by &6X &eto &6Z &eaxis", 20), + ZX("&eMirrors by &6Z &eto &6Y &eaxis", 22), + Rotate90V("&eRotates up", 28), + Rotate90H("&eRotates &690 &edegrees clock wise", 29), + Rotate90HC("&eRotates &690 &edegrees counter clock wise", 31), + Rotate180H("&eRotates &6180 &edegrees", 32), + Pause("&ePauses mirroring", 16), + Location("&eSets mirroring center location", 34); + + private int slot; + private String desc; + private String name; + + private MirrorAction(String desc, int slot) { + this.slot = slot; + this.desc = desc; + } + + public int getSlot() { + return this.slot; + } + + public String getDesc() { + return this.desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } HashMap map = new HashMap(); @@ -86,237 +68,265 @@ public void setName(String name) { private CMI plugin; public MirrorManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public boolean isMirroring(Player player) { - return map.containsKey(player.getUniqueId()); + return map.containsKey(player.getUniqueId()); } public boolean addMirroring(Player player) { - CMIUser user = plugin.getPlayerManager().getUser(player); - if (user != null) - return map.put(player.getUniqueId(), user) != null; - return false; + CMIUser user = plugin.getPlayerManager().getUser(player); + if (user != null) + return map.put(player.getUniqueId(), user) != null; + return false; } public void removeMirroring(Player player) { - map.remove(player.getUniqueId()); + map.remove(player.getUniqueId()); } class blockInfo { - private Location loc; - private Object data; + private Location loc; + private Object data; - blockInfo(Location loc, Object data) { - this.loc = loc; - this.data = data; - } + blockInfo(Location loc, Object data) { + this.loc = loc; + this.data = data; + } - public Location getLoc() { - return loc; - } + public Location getLoc() { + return loc; + } - public void setLoc(Location loc) { - this.loc = loc; - } + public void setLoc(Location loc) { + this.loc = loc; + } - public Object getData() { - return data; - } + public Object getData() { + return data; + } - public void setData(Object data) { - this.data = data; - } + public void setData(Object data) { + this.data = data; + } } private static String toString(Location loc) { - return loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ(); + return loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ(); } private HashMap getMapLocations(Mirrors mirror, Location loc, Block b) { - return null; + + return null; } private static Set getLocations(Mirrors mirror, Location loc) { - - return null; + + return null; } private boolean inRange(Location center, Location location) { - return false; + if (!center.getWorld().getName().equalsIgnoreCase(location.getWorld().getName())) + return false; + + int difx = getXdif(center, location); + int dify = getYdif(center, location); + int difz = getZdif(center, location); + + difx = difx < 0 ? -difx : difx; + dify = dify < 0 ? -dify : dify; + difz = difz < 0 ? -difz : difz; + + int range = plugin.getConfigManager().MirrorMaxRange; + return difx < range && dify < range && difz < range; } public enum mirrorShift { - north(0, 0, -1), - northEast(1, 0, -1), - east(1, 0, 0), - southEast(1, 0, 1), - south(0, 0, 1), - southWest(-1, 0, 1), - west(-1, 0, 0), - northWest(-1, 0, -1); - - private int x; - private int y; - private int z; - - private int offset; - - mirrorShift(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - public Location modifyLocation(Location loc) { - loc.add(this.x * offset, this.y * offset, this.z * offset); - return loc; - } - - public int getOffset() { - return offset; - } - - public mirrorShift setOffset(int offset) { - this.offset = offset; - return this; - } + north(0, 0, -1), + northEast(1, 0, -1), + east(1, 0, 0), + southEast(1, 0, 1), + south(0, 0, 1), + southWest(-1, 0, 1), + west(-1, 0, 0), + northWest(-1, 0, -1); + + private int x; + private int y; + private int z; + + private int offset; + + mirrorShift(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + public Location modifyLocation(Location loc) { + loc.add(this.x * offset, this.y * offset, this.z * offset); + return loc; + } + + public int getOffset() { + return offset; + } + + public mirrorShift setOffset(int offset) { + this.offset = offset; + return this; + } } private HashMap offset(Mirrors mirror, Block block, mirrorShift shift) { - return null; + Location blockLoc = shift.modifyLocation(block.getLocation().clone()); + HashMap locs = new HashMap(getMapLocations(mirror.clone().setCenter(shift.modifyLocation(mirror.getCenter().clone())), blockLoc, block)); + locs.put(toString(blockLoc), new blockInfo(blockLoc, (new CMIBlock(block)).getData())); + return locs; } private HashMap combineMaps(HashMap locs, HashMap shiftedLocs) { - - return null; + for (Entry one : shiftedLocs.entrySet()) { + if (locs.containsKey(one.getKey())) + continue; + locs.put(one.getKey(), one.getValue()); + } + return locs; } public void MirrorPlace(Player player, Block block) { - + } public void MirrorBreak(Player player, Block block) { - } private Location rotate90horClockWise(Mirrors mirror, Location loc) { - - return null; + Location n = loc.clone(); + + return n; } private Location rotate90horCounterClockWise(Mirrors mirror, Location loc) { - - return null; + Location n = loc.clone(); + + return n; } private static Location rotate90hor(Mirrors mirror, Location loc, boolean clock) { - - return null; + Location n = loc.clone(); + + return n; } private static Location rotate180hor(Mirrors mirror, Location loc) { - - return null; + Location n = loc.clone(); + + return n; } private static Location rotate90vert(Mirrors mirror, Location loc) { - return null; + Location n = loc.clone(); + + return n; } private HashMap getMirroredXZMap(Mirrors mirror, Block block, Object data, Location loc, int repeat, HashMap map) { - return null; + return null; } private HashMap getMirroredZXMap(Mirrors mirror, Block block, Object data, Location loc, int repeat, HashMap map) { - - return null; + + return null; } private static Set getMirroredXZ(Mirrors mirror, Location loc, int repeat) { - - return null; + Set list = new HashSet(); + + return list; } private static Set getMirroredZX(Mirrors mirror, Location loc, int repeat) { - - return null; + Set list = new HashSet(); + + return list; } private HashMap getMirroredZYMap(Mirrors mirror, Block block, Object data, Location loc, int repeat, HashMap map) { - - return null; + return null; } private HashMap getMirroredXYMap(Mirrors mirror, Block block, Object data, Location loc, int repeat, HashMap map) { - return null; + return null; } private static Set getMirroredZY(Mirrors mirror, Location loc, int repeat) { - - return null; + Set list = new HashSet(); + return list; } private static Set getMirroredXY(Mirrors mirror, Location loc, int repeat) { - - return null; + Set list = new HashSet(); + return list; } private HashMap getMirroredLocMap(Mirrors mirror, Location loc) { - return null; + return null; } private static Set getMirroredLocs(Mirrors mirror, Location loc) { - return null; + Set list = new HashSet(); + + return list; } private static int getX(Location center, Location loc) { - int c = center.getBlockX(); - int b = loc.getBlockX(); - int dif = c - b; - int newValue = c + dif; - return newValue; + int c = center.getBlockX(); + int b = loc.getBlockX(); + int dif = c - b; + int newValue = c + dif; + return newValue; } private static int getY(Location center, Location loc) { - int c = center.getBlockY(); - int b = loc.getBlockY(); - int dif = c - b; - int newValue = c + dif; - return newValue; + int c = center.getBlockY(); + int b = loc.getBlockY(); + int dif = c - b; + int newValue = c + dif; + return newValue; } private static int getZ(Location center, Location loc) { - int c = center.getBlockZ(); - int b = loc.getBlockZ(); - int dif = c - b; - int newValue = c + dif; - return newValue; + int c = center.getBlockZ(); + int b = loc.getBlockZ(); + int dif = c - b; + int newValue = c + dif; + return newValue; } private static int getXdif(Location center, Location loc) { - return center.getBlockX() - loc.getBlockX(); + return center.getBlockX() - loc.getBlockX(); } private static int getYdif(Location center, Location loc) { - return center.getBlockY() - loc.getBlockY(); + return center.getBlockY() - loc.getBlockY(); } private static int getZdif(Location center, Location loc) { - return center.getBlockZ() - loc.getBlockZ(); + return center.getBlockZ() - loc.getBlockZ(); } public void openNewGui(CMIUser user) { - + } } diff --git a/src/com/Zrips/CMI/Modules/ModuleHandling/CMIModule.java b/src/com/Zrips/CMI/Modules/ModuleHandling/CMIModule.java index 9a442e9..2243fa7 100644 --- a/src/com/Zrips/CMI/Modules/ModuleHandling/CMIModule.java +++ b/src/com/Zrips/CMI/Modules/ModuleHandling/CMIModule.java @@ -19,6 +19,7 @@ import com.Zrips.CMI.Modules.Animations.AnimationRideListener; import com.Zrips.CMI.Modules.Animations.AnimationSitListener; import com.Zrips.CMI.Modules.Anvil.AnvilColorRenameListener; +import com.Zrips.CMI.Modules.ArmorEffects.ArmorEffectListener; import com.Zrips.CMI.Modules.AttachedCommands.CustomNBTListener; import com.Zrips.CMI.Modules.AttachedCommands.CustomNBTListener1_8; import com.Zrips.CMI.Modules.ChatTag.TagListener; @@ -58,7 +59,6 @@ import com.Zrips.CMI.Modules.TimedCommands.TimedCommandListener; import com.Zrips.CMI.Modules.Totems.ResurectionListener; import com.Zrips.CMI.Modules.Vanish.VanishListener; -import com.Zrips.CMI.Modules.Votifier.VotifierListener; import net.Zrips.CMILib.Version.Version; @@ -80,6 +80,7 @@ public enum CMIModule { warmup("Handling of command warmups", new CMIModuleClass(WarmUpListener.class)), interactiveCommands("Handling of interactive commands", new CMIModuleClass(InteractiveCommandListener.class), new CMIModuleClass(InteractiveCommandListener1_8.class, Version.v1_8_R1)), attachedCommands("Handling of attached commands", new CMIModuleClass(CustomNBTListener.class), new CMIModuleClass(CustomNBTListener1_8.class, Version.v1_8_R1)), + armorEffects("Handling of armor effects", new CMIModuleClass(ArmorEffectListener.class)), playerChatTag("Handling of player tagging in chat and tabcomplete with @", new CMIModuleClass(TagListener.class)), tablist("Handling of tablist", new CMIModuleClass(TabListListener.class)), paintingEditor("Handling of painting editing with shift+right click", new CMIModuleClass(PaintingListener.class)), @@ -94,7 +95,7 @@ public enum CMIModule { coloredArmor("Handles leather armor which has dynamic colors", new CMIModuleClass(AnimationColoredArmorListener.class)), noTarget("Handles entity target prevention on player /cmi notarget", new CMIModuleClass(NoTargetListener.class)), ranks("Handles rankup system"), - votifier("Handles votifier system", new CMIModuleClass(VotifierListener.class)), + votifier("Handles votifier system"), playerCombat("Handles player combat system", new CMIModuleClass(PlayerCombatListener.class)), headDrop("Handles head drops system", new CMIModuleClass(HeadDropListener.class)), kits("Handles kit listener, mainly to give out new player kit", new CMIModuleClass(KitListener.class)), @@ -107,7 +108,7 @@ public enum CMIModule { selection("Handles selection areas. While this is disabled, command can still be used", new CMIModuleClass(SelectionListener.class)), hpBossBar("Handles mob and player hp bars as boss bar", new CMIModuleClass(HpBarListener.class, Version.v1_9_R1)), afk("Handling of afk feature. This will disable any checks related to afk and players will never get into afk mode", new CMIModuleClass(AfkListener.class), new CMIModuleClass(AfkListener1_8.class, - Version.v1_8_R1)), + Version.v1_8_R1)), timedCommands("Handling timed commands like tfly and tgod", new CMIModuleClass(TimedCommandListener.class)), eventCommands("Handling of eventCommands.yml feature ", new CMIModuleClass(EventActionListener.class), new CMIModuleClass(EventActionListener19.class, Version.v1_9_R1)), disabledEnchants("Handling of disabled enchants in inventory", new CMIModuleClass(EnchantListener.class)), @@ -130,49 +131,49 @@ public enum CMIModule { private String desc; CMIModule(String desc, CMIModuleClass... listener) { - this.desc = desc; - this.listeners = listener; + this.desc = desc; + this.listeners = listener; } public static CMIModule getByName(String name) { - return null; + return null; } public static boolean isEnabled(String name) { - return true; + return true; } public Version getFromVersion() { - Version from = Version.v1_7_R4; - return from; + Version from = Version.v1_7_R4; + return from; } public Version getToVersion() { - Version to = null; - return to; + Version to = null; + return to; } public void setEnabled(boolean enabled) { - this.enabled = enabled; + this.enabled = enabled; } public boolean isEnabled() { - return enabled; + return enabled; } public void registerListener() { - + } public String getDesc() { - return desc; + return desc; } public void setDesc(String desc) { - this.desc = desc; + this.desc = desc; } public CMIModuleClass[] getListeners() { - return listeners; + return listeners; } } diff --git a/src/com/Zrips/CMI/Modules/ModuleHandling/CMIModuleManager.java b/src/com/Zrips/CMI/Modules/ModuleHandling/CMIModuleManager.java index f4aafcd..6f1c69a 100644 --- a/src/com/Zrips/CMI/Modules/ModuleHandling/CMIModuleManager.java +++ b/src/com/Zrips/CMI/Modules/ModuleHandling/CMIModuleManager.java @@ -1,18 +1,5 @@ package com.Zrips.CMI.Modules.ModuleHandling; -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Map.Entry; -import java.util.Set; - -import org.bukkit.configuration.file.YamlConfiguration; - -import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.FileHandler.ConfigReader; -import com.Zrips.CMI.commands.CMICommand; - public class CMIModuleManager { public static void load() { diff --git a/src/com/Zrips/CMI/Modules/MoneyCheque/MoneyChequeListener.java b/src/com/Zrips/CMI/Modules/MoneyCheque/MoneyChequeListener.java index 87c5061..ca098b8 100644 --- a/src/com/Zrips/CMI/Modules/MoneyCheque/MoneyChequeListener.java +++ b/src/com/Zrips/CMI/Modules/MoneyCheque/MoneyChequeListener.java @@ -1,31 +1,27 @@ package com.Zrips.CMI.Modules.MoneyCheque; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.EquipmentSlot; -import org.bukkit.inventory.ItemStack; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.NBT.CMINBT; -import com.Zrips.CMI.Containers.CMIUser; -import com.Zrips.CMI.Modules.AttachedCommands.CustomNBTManager.CustomNBTType; - -import net.Zrips.CMILib.CMILib; -import net.Zrips.CMILib.Items.CMIMaterial; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; import com.Zrips.CMI.events.CMIAnvilItemRenameEvent; -import net.Zrips.CMILib.Version.Version; public class MoneyChequeListener implements Listener { private CMI plugin; public MoneyChequeListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void playerInteractOneTime(PlayerInteractEvent event) { + } + @EventHandler(priority = EventPriority.MONITOR) + public void playerInteractOneTime(CMIAnvilItemRenameEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/NickName/NickNameListener.java b/src/com/Zrips/CMI/Modules/NickName/NickNameListener.java index 00324b1..8e7961f 100644 --- a/src/com/Zrips/CMI/Modules/NickName/NickNameListener.java +++ b/src/com/Zrips/CMI/Modules/NickName/NickNameListener.java @@ -1,6 +1,11 @@ package com.Zrips.CMI.Modules.NickName; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerLoginEvent; import com.Zrips.CMI.CMI; @@ -8,7 +13,30 @@ public class NickNameListener implements Listener { private CMI plugin; public NickNameListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerLoginEvent(PlayerLoginEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW) + public void cleanPublicChatFromColors(AsyncPlayerChatEvent event) { + + } + + public static String processGradientChat(Player player, String message) { + return ""; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void AsyncPlayerChatEventRawConverter(AsyncPlayerChatEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void AsyncPlayerChatEventExtra(AsyncPlayerChatEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/NickName/NickNameManager.java b/src/com/Zrips/CMI/Modules/NickName/NickNameManager.java index 9255e53..1deb041 100644 --- a/src/com/Zrips/CMI/Modules/NickName/NickNameManager.java +++ b/src/com/Zrips/CMI/Modules/NickName/NickNameManager.java @@ -1,5 +1,6 @@ package com.Zrips.CMI.Modules.NickName; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.UUID; @@ -41,7 +42,8 @@ public UUID whoUsesName(String nick) { } public List getNickNamesStartingWith(Player player, String nick) { - return null; + List ls = new ArrayList(); + return ls; } private String NickNameFormat; @@ -53,6 +55,7 @@ public List getNickNamesStartingWith(Player player, String nick) { private String NickNamePrefix; private Boolean PrefixWhenDifferent; private Boolean IncludeInTabComplete; + private Boolean IncludeRealName; private Boolean ColorsNickName; public void load() { @@ -105,4 +108,8 @@ public boolean isDisplayNameChange() { public boolean isIncludeNickNameInTabComplete() { return IncludeInTabComplete; } + + public Boolean isIncludeRealNameInTabComplete() { + return IncludeRealName; + } } diff --git a/src/com/Zrips/CMI/Modules/Packets/FakeInfo.java b/src/com/Zrips/CMI/Modules/Packets/FakeInfo.java index b9fff53..5537834 100644 --- a/src/com/Zrips/CMI/Modules/Packets/FakeInfo.java +++ b/src/com/Zrips/CMI/Modules/Packets/FakeInfo.java @@ -7,6 +7,7 @@ public class FakeInfo { private int id = -1; private Player player; private Object obj; + private Object entity; public Player getPlayer() { return player; @@ -35,4 +36,12 @@ public FakeInfo setId(int id) { return this; } + public Object getEntity() { + return entity; + } + + public void setEntity(Object entity) { + this.entity = entity; + } + } diff --git a/src/com/Zrips/CMI/Modules/Packets/PacketHandler.java b/src/com/Zrips/CMI/Modules/Packets/PacketHandler.java deleted file mode 100644 index f92e628..0000000 --- a/src/com/Zrips/CMI/Modules/Packets/PacketHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.Zrips.CMI.Modules.Packets; - -import java.util.HashMap; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - -import org.bukkit.entity.Player; - -import io.netty.channel.ChannelDuplexHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelPromise; - -public class PacketHandler extends ChannelDuplexHandler { - private Player p; - private ToolBarLoad toolBarAction = new ToolBarLoad(); - - public PacketHandler(final Player p) { - this.p = p; - } - -// HashMap map = new HashMap(); - static ConcurrentHashMap> map = new ConcurrentHashMap>(); - public static ConcurrentHashMap fakeEntities = new ConcurrentHashMap(); - - private enum packetNames { - PacketPlayInSetCreativeSlot, PacketPlayInUseEntity, PacketPlayOutPlayerInfo, PacketPlayOutEntityVelocity, PacketPlayOutEntityTeleport, PacketPlayOutLookAt, PacketPlayOutCamera, - PacketPlayOutEntityHeadRotation, PacketStatusOutServerInfo, PacketPlayOutScoreboardTeam, PacketPlayOutChat, PacketHandshakingInSetProtocol; - - static Class packet = null; - - public static packetNames get(String name) { - - return null; - } - - public Class getPacket() { - return packet; - } - } - - @Override - public void write(ChannelHandlerContext ctx, Object m, ChannelPromise promise) throws Exception { - super.write(ctx, m, promise); - return; - - } - - @Override - public void channelRead(ChannelHandlerContext c, Object m) throws Exception { - super.channelRead(c, m); - } -} \ No newline at end of file diff --git a/src/com/Zrips/CMI/Modules/Packets/PacketInjector.java b/src/com/Zrips/CMI/Modules/Packets/PacketInjector.java deleted file mode 100644 index 1ea92d1..0000000 --- a/src/com/Zrips/CMI/Modules/Packets/PacketInjector.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.Zrips.CMI.Modules.Packets; - -import java.lang.reflect.Field; - -import org.bukkit.entity.Player; - -import io.netty.channel.Channel; - -public class PacketInjector { - - private Field EntityPlayer_playerConnection; - private Class PlayerConnection; - private Field PlayerConnection_networkManager; - - private Class NetworkManager; - private Field channel; - - public PacketInjector() { - - } - - public Field getField(Class clazz, String fieldName) throws Exception { - return null; - } - - @Deprecated - private Class getClass(String classname) { - - return null; - } - - public void addPlayer(Player p) { - - } - - public void removePlayer(Player p) { - - } - - private Object getNetworkManager(Object ep) { - return null; - } - - private Channel getChannel(Object networkManager) { - - return null; - } -} \ No newline at end of file diff --git a/src/com/Zrips/CMI/Modules/Packets/PacketPlayerListeners.java b/src/com/Zrips/CMI/Modules/Packets/PacketPlayerListeners.java index c55f354..58a534d 100644 --- a/src/com/Zrips/CMI/Modules/Packets/PacketPlayerListeners.java +++ b/src/com/Zrips/CMI/Modules/Packets/PacketPlayerListeners.java @@ -1,6 +1,10 @@ package com.Zrips.CMI.Modules.Packets; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; import com.Zrips.CMI.CMI; @@ -8,7 +12,15 @@ public class PacketPlayerListeners implements Listener { private CMI plugin; public PacketPlayerListeners(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPacketPlayerLogin(PlayerJoinEvent event) { + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPacketPlayerQuit(PlayerQuitEvent event) { } } diff --git a/src/com/Zrips/CMI/Modules/Painting/PaintingListener.java b/src/com/Zrips/CMI/Modules/Painting/PaintingListener.java index 1c1af39..2e4514c 100644 --- a/src/com/Zrips/CMI/Modules/Painting/PaintingListener.java +++ b/src/com/Zrips/CMI/Modules/Painting/PaintingListener.java @@ -1,36 +1,43 @@ package com.Zrips.CMI.Modules.Painting; -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Art; -import org.bukkit.Bukkit; -import org.bukkit.block.Block; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Painting; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.EquipmentSlot; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.CMIEvent; -import net.Zrips.CMILib.Locale.LC; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; public class PaintingListener implements Listener { private CMI plugin; public PaintingListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.HIGHEST) + public void onPaintingBreak(PlayerQuitEvent event) { + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPaintingBreak(HangingBreakEvent event) { + } + + @EventHandler + public void onSignInteractShift(PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPlayerInteractPaiting(PlayerInteractEntityEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onItemHeldChange(PlayerItemHeldEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Painting/PaintingManager.java b/src/com/Zrips/CMI/Modules/Painting/PaintingManager.java index 31b58f6..d89b1b2 100644 --- a/src/com/Zrips/CMI/Modules/Painting/PaintingManager.java +++ b/src/com/Zrips/CMI/Modules/Painting/PaintingManager.java @@ -1,7 +1,6 @@ package com.Zrips.CMI.Modules.Painting; import java.util.HashMap; -import java.util.Map.Entry; import java.util.UUID; import org.bukkit.entity.Entity; @@ -14,26 +13,26 @@ public class PaintingManager { private CMI plugin; public PaintingManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } HashMap map = new HashMap(); public boolean isEditing(UUID uuid) { - return map.containsKey(uuid); + return map.containsKey(uuid); } public void addEditor(UUID uuid, Entity ent) { - map.put(uuid, ent); + map.put(uuid, ent); } public Painting getPainting(UUID uuid) { - Entity ent = map.get(uuid); - return ent instanceof Painting ? (Painting) ent : null; + Entity ent = map.get(uuid); + return ent instanceof Painting ? (Painting) ent : null; } public void removeEditor(UUID uuid) { - map.remove(uuid); + map.remove(uuid); } public void removeEditor(Entity entity) { diff --git a/src/com/Zrips/CMI/Modules/Particl/CMIPEAnimation.java b/src/com/Zrips/CMI/Modules/Particl/CMIPEAnimation.java index c344ad4..99164a3 100644 --- a/src/com/Zrips/CMI/Modules/Particl/CMIPEAnimation.java +++ b/src/com/Zrips/CMI/Modules/Particl/CMIPEAnimation.java @@ -7,16 +7,19 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import net.Zrips.CMILib.Colors.CMIChatColor; +import net.Zrips.CMILib.Effects.CMIEffect; import net.Zrips.CMILib.Effects.CMIEffectManager.CMIParticle; - +import net.Zrips.CMILib.Logs.CMIDebug; public class CMIPEAnimation implements CMIPEAnimationInterface { protected Location center; protected boolean fixedLocation = false; - protected CMIParticle effect = CMIParticle.COLOURED_DUST; - protected Color color = new Color(0, 0, 0); + + protected CMIEffect effect = new CMIEffect(CMIParticle.COLOURED_DUST); protected Vector offset = new Vector(0, 0, 0); + protected int updateTimes = 0; protected double duration = 5; private Player playerMove; @@ -35,10 +38,14 @@ public void setPlayerMove(Player playerMove) { this.playerMove = playerMove; } - public CMIPEAnimation(CMIParticle effect) { + public CMIPEAnimation(CMIEffect effect) { this.effect = effect; } + public CMIPEAnimation(CMIParticle effect) { + this.effect.setParticle(effect); + } + @Override public boolean render(List players) { return true; @@ -62,21 +69,49 @@ public void setOffset(Vector offset) { this.offset = offset; } - public CMIParticle getEffect() { + public CMIEffect getCMIEffect() { return effect; } - public void setEffect(CMIParticle effect) { + public void setCMIEffect(CMIEffect effect) { this.effect = effect; } - public Color getColor() { - return color; + @Deprecated + public CMIParticle getEffect() { + return getParticle(); + } + + @Deprecated + public void setEffect(CMIParticle particle) { + setParticle(particle); + } + + public CMIParticle getParticle() { + return this.effect.getParticle(); + } + + public void setParticle(CMIParticle particle) { + this.effect.setParticle(particle); + } + + public org.bukkit.Color getColor() { + return this.effect.getColor(); } @Override public void setColor(Color color) { - this.color = color; + this.effect.setColor(org.bukkit.Color.fromRGB(color.getRed(), color.getGreen(), color.getBlue())); + } + + @Override + public void setColor(org.bukkit.Color color) { + this.effect.setColor(color); + } + + @Override + public void setColor(CMIChatColor color) { + this.effect.setColor(org.bukkit.Color.fromRGB(color.getRed(), color.getGreen(), color.getBlue())); } @Override diff --git a/src/com/Zrips/CMI/Modules/Particl/CMIPEAnimationInterface.java b/src/com/Zrips/CMI/Modules/Particl/CMIPEAnimationInterface.java index 3ad8d86..31c2808 100644 --- a/src/com/Zrips/CMI/Modules/Particl/CMIPEAnimationInterface.java +++ b/src/com/Zrips/CMI/Modules/Particl/CMIPEAnimationInterface.java @@ -6,6 +6,8 @@ import org.bukkit.Location; import org.bukkit.entity.Player; +import net.Zrips.CMILib.Colors.CMIChatColor; + public interface CMIPEAnimationInterface { public boolean render(List players); @@ -22,6 +24,10 @@ public interface CMIPEAnimationInterface { public void setColor(Color color); + public void setColor(org.bukkit.Color color); + + public void setColor(CMIChatColor color); + public void show(); Player getPlayerMove(); @@ -29,6 +35,5 @@ public interface CMIPEAnimationInterface { int getInterval(); boolean isHideWithVanish(); - - + } diff --git a/src/com/Zrips/CMI/Modules/Particl/CMIPECircle.java b/src/com/Zrips/CMI/Modules/Particl/CMIPECircle.java index b29c4cb..7ea401a 100644 --- a/src/com/Zrips/CMI/Modules/Particl/CMIPECircle.java +++ b/src/com/Zrips/CMI/Modules/Particl/CMIPECircle.java @@ -1,11 +1,13 @@ package com.Zrips.CMI.Modules.Particl; +import java.util.ArrayList; import java.util.List; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import net.Zrips.CMILib.Effects.CMIEffect; import net.Zrips.CMILib.Effects.CMIEffectManager.CMIParticle; public class CMIPECircle extends CMIPEAnimation { @@ -19,7 +21,8 @@ public class CMIPECircle extends CMIPEAnimation { private double radiusChange = 0D; private double radius = 1D; private double maxRadius = 2D; - private boolean followDirection = false; + private boolean followPitch = false; + private boolean followYaw = false; private double pitch = 0D; private double pitchAdjust = 0D; @@ -31,161 +34,207 @@ public class CMIPECircle extends CMIPEAnimation { private boolean raindbowColor = false; private boolean raindbowColorFromStart = false; + private short startingAngle = 0; + public CMIPECircle() { } + public CMIPECircle(CMIEffect effect) { + this.setCMIEffect(effect); + } + + @Deprecated public CMIPECircle(CMIParticle effect) { - this.effect = effect; + this.setParticle(effect); } @Override public boolean render(List players) { - return true; + return true; } private List getLocations(Location location, double radius, double yaw, double pitch) { - return null; + List locs = new ArrayList(); + + return locs; + } + + private static Vector rotateX(Vector v, double a) { + double Y = Math.cos(a) * v.getY() - Math.sin(a) * v.getZ(); + double Z = Math.sin(a) * v.getY() + Math.cos(a) * v.getZ(); + return v.setY(Y).setZ(Z); + } + + private static Vector rotateY(Vector v, double a) { + double X = Math.cos(a) * v.getX() + Math.sin(a) * v.getZ(); + double Z = -Math.sin(a) * v.getX() + Math.cos(a) * v.getZ(); + return v.setX(X).setZ(Z); } public double xPosYaw(double time, double radius, double yaw) { - return Math.sin(time) * radius * Math.cos(Math.PI / 180 * yaw); + return Math.sin(time) * radius * Math.cos(Math.PI / 180 * yaw); } public double yPosYaw(double time, double radius) { - return Math.cos(time) * radius; + return Math.cos(time) * radius; } public double zPosYaw(double time, double radius, double yaw) { - return Math.sin(time) * radius * Math.sin(Math.PI / 180 * yaw); + return Math.sin(time) * radius * Math.sin(Math.PI / 180 * yaw); } public boolean isRotating() { - return circling; + return circling; } public void setRotating(boolean circling) { - this.circling = circling; + this.circling = circling; } public int getTimes() { - return times; + return times; } public void setTimes(int times) { - this.times = times; + this.times = times; } public Vector getMove() { - return move; + return move; } public void setMove(Vector move) { - this.move = move; + this.move = move; } public double getRadius() { - return radius; + return radius; } public void setRadius(double radius) { - this.radius = radius; + this.radius = radius; } public double getRadiusChange() { - return radiusChange; + return radiusChange; } public void setRadiusChange(double radiusChange) { - this.radiusChange = radiusChange; + this.radiusChange = radiusChange; } public boolean isFollowDirection() { - return followDirection; + return followPitch && followYaw; } public void setFollowDirection(boolean followDirection) { - this.followDirection = followDirection; + this.followPitch = followDirection; + this.followYaw = followDirection; } public double getMaxRadius() { - return maxRadius; + return maxRadius; } public void setMaxRadius(double maxRadius) { - this.maxRadius = maxRadius; + this.maxRadius = maxRadius; } public double getMaxMoveDistance() { - return MaxMoveDistance; + return MaxMoveDistance; } public void setMaxMoveDistance(double MaxMoveDistance) { - this.MaxMoveDistance = MaxMoveDistance; + this.MaxMoveDistance = MaxMoveDistance; } public double getPitchAdjust() { - return pitchAdjust; + return pitchAdjust; } public void setPitchAdjust(double pitchAdjust) { - this.pitchAdjust = pitchAdjust; + this.pitchAdjust = pitchAdjust; } public double getPitch() { - return pitch; + return pitch; } public void setPitch(double pitch) { - this.pitch = pitch; + this.pitch = pitch; } public double getYaw() { - return yaw; + return yaw; } public void setYaw(double yaw) { - this.yaw = yaw; + this.yaw = yaw; } public double getYawAdjust() { - return yawAdjust; + return yawAdjust; } public void setYawAdjust(double yawAdjust) { - this.yawAdjust = yawAdjust; + this.yawAdjust = yawAdjust; } public boolean isRaindbowColorStatic() { - return raindbowColorStatic; + return raindbowColorStatic; } public void setRaindbowColorStatic(boolean raindbowColorStatic) { - this.raindbowColorStatic = raindbowColorStatic; + this.raindbowColorStatic = raindbowColorStatic; } public boolean isRaindbowColor() { - return raindbowColor; + return raindbowColor; } public void setRaindbowColor(boolean raindbowColor) { - this.raindbowColor = raindbowColor; + this.raindbowColor = raindbowColor; } public boolean isRaindbowColorFromStart() { - return raindbowColorFromStart; + return raindbowColorFromStart; } public void setRaindbowColorFromStart(boolean raindbowColorFromStart) { - this.raindbowColorFromStart = raindbowColorFromStart; + this.raindbowColorFromStart = raindbowColorFromStart; } public Double getMoveMulty() { - return moveMulty; + return moveMulty; } public void setMoveMulty(Double moveMulty) { - this.moveMulty = moveMulty; + this.moveMulty = moveMulty; + } + + public short getStartingAngle() { + return startingAngle; + } + + public void setStartingAngle(short startingAngle) { + this.startingAngle = startingAngle; + } + + public boolean isFollowPitch() { + return followPitch; + } + + public void setFollowPitch(boolean followPitch) { + this.followPitch = followPitch; + } + + public boolean isFollowYaw() { + return followYaw; + } + + public void setFollowYaw(boolean followYaw) { + this.followYaw = followYaw; } } diff --git a/src/com/Zrips/CMI/Modules/Particl/CMIPEFireWork.java b/src/com/Zrips/CMI/Modules/Particl/CMIPEFireWork.java index 0a58938..5a1519e 100644 --- a/src/com/Zrips/CMI/Modules/Particl/CMIPEFireWork.java +++ b/src/com/Zrips/CMI/Modules/Particl/CMIPEFireWork.java @@ -3,17 +3,9 @@ import java.lang.reflect.Method; import java.util.List; -import org.bukkit.Bukkit; import org.bukkit.Color; -import org.bukkit.FireworkEffect; -import org.bukkit.FireworkEffect.Builder; import org.bukkit.FireworkEffect.Type; -import org.bukkit.Location; -import org.bukkit.entity.Firework; import org.bukkit.entity.Player; -import org.bukkit.inventory.meta.FireworkMeta; - -import com.Zrips.CMI.CMI; public class CMIPEFireWork extends CMIPEAnimation { @@ -28,60 +20,53 @@ public class CMIPEFireWork extends CMIPEAnimation { private Boolean trail = null; public CMIPEFireWork() { - this.setDuration(0); + this.setDuration(0); } @Override public boolean render(List players) { - return true; - } - - private static void ShotFirework(Location loc, FireworkEffect fe) throws Exception { - - } - private static Method getMethod(Class cl, String method) { - return null; + return true; } public Color getFadeFrom() { - return fadeFrom; + return fadeFrom; } public void setFadeFrom(Color fadeFrom) { - this.fadeFrom = fadeFrom; + this.fadeFrom = fadeFrom; } public Color getFadeTo() { - return fadeTo; + return fadeTo; } public void setFadeTo(Color fadeTo) { - this.fadeTo = fadeTo; + this.fadeTo = fadeTo; } public Type getType() { - return type; + return type; } public void setType(Type type) { - this.type = type; + this.type = type; } public Boolean getFlicker() { - return flicker; + return flicker; } public void setFlicker(Boolean flicker) { - this.flicker = flicker; + this.flicker = flicker; } public Boolean getTrail() { - return trail; + return trail; } public void setTrail(Boolean trail) { - this.trail = trail; + this.trail = trail; } } diff --git a/src/com/Zrips/CMI/Modules/Particl/CMIVisualEffect.java b/src/com/Zrips/CMI/Modules/Particl/CMIVisualEffect.java index 854c746..69f3a24 100644 --- a/src/com/Zrips/CMI/Modules/Particl/CMIVisualEffect.java +++ b/src/com/Zrips/CMI/Modules/Particl/CMIVisualEffect.java @@ -3,12 +3,11 @@ import java.util.ArrayList; import java.util.List; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Logs.CMIDebug; +import com.Zrips.CMI.Modules.Particl.ParticleManager.CMIPresetAnimations; public class CMIVisualEffect { @@ -18,109 +17,45 @@ public class CMIVisualEffect { int id = -1; private int interval = 1; - private Long until; - private CMIPEAnimationInterface effectAnimation; + private Long until = null; + private CMIPEAnimationInterface effectAnimation = null; List players = new ArrayList(); Long nextPlayerUpdate; + public CMIVisualEffect(Player targetPlayer, CMIPresetAnimations effect) { + this(targetPlayer, effect.getInter(targetPlayer)); + } + public CMIVisualEffect(Player targetPlayer, CMIPEAnimationInterface effect) { - if (effect.getCenter() != null) { - loc = effect.getCenter().clone(); - } - this.setTargetPlayer(targetPlayer); - this.effectAnimation = effect; - interval = effect.getInterval(); + } public CMIVisualEffect(Location loc, CMIPEAnimationInterface effect) { - this.loc = loc; - this.effectAnimation = effect; - interval = effect.getInterval(); + } private Location getLocation() { - if (loc != null) - return loc; - return getTargetPlayer() != null ? getTargetPlayer().isOnline() ? getTargetPlayer().getLocation() : null : null; + if (loc != null) + return loc; + return getTargetPlayer() != null ? getTargetPlayer().isOnline() ? getTargetPlayer().getLocation() : null : null; } @SuppressWarnings("deprecation") public void show() { -// Bukkit.getScheduler().runTaskAsynchronously(CMI.getInstance(), new Runnable() { -// @Override -// public void run() { - - id = Bukkit.getScheduler().scheduleAsyncRepeatingTask(CMI.getInstance(), new Runnable() { - @Override - public void run() { - Location location = getLocation(); - if (location == null) { - stop(); - return; - } - - if (nextPlayerUpdate == null || nextPlayerUpdate < System.currentTimeMillis()) { - players = CMI.getInstance().getUtilManager().getPlayersFromRange(getEffect().isHideWithVanish() ? getTargetPlayer() : null, location, 16); - nextPlayerUpdate = System.currentTimeMillis() + 1000; - } - if (!effectAnimation.isFixedLocation() || effectAnimation.getCenter() == null) - effectAnimation.setCenter(location); - visualize(); - - if (until == null || until < System.currentTimeMillis()) { - stop(); - return; - } - } - }, 0L, interval); - -// return; -// } -// -// }); } + @SuppressWarnings("deprecation") public void show(Player player) { - players.clear(); - if (player != null) - players.add(player); - visualize(); + } private void visualize() { - Bukkit.getScheduler().runTaskAsynchronously(CMI.getInstance(), new Runnable() { - @Override - public void run() { - Location location = getLocation(); - if (location == null) { - stop(); - return; - } - if (effectAnimation == null) { - stop(); - return; - } - - if (!effectAnimation.render(new ArrayList(players))) { - stop(); - return; - } - return; - } - }); - -// players.clear(); - } public void stop() { - if (id != -1) { - Bukkit.getScheduler().cancelTask(id); - id = -1; - CMI.getInstance().getParticleManager().removePlayerEffects(this); - } + } public void pause() { @@ -132,37 +67,37 @@ public void continueAnimation() { } public CMIPEAnimationInterface getEffect() { - return effectAnimation; + return effectAnimation; } public void setEffect(CMIPEAnimationInterface effect) { - this.effectAnimation = effect; + this.effectAnimation = effect; } public Player getTargetPlayer() { - return targetPlayerLocation; + return targetPlayerLocation; } public void setTargetPlayer(Player targetPlayer) { - this.targetPlayerLocation = targetPlayer; - if (loc == null) - CMI.getInstance().getParticleManager().addPlayerEffect(this); + this.targetPlayerLocation = targetPlayer; + if (loc == null) + CMI.getInstance().getParticleManager().addPlayerEffect(this); } public Long getUntil() { - return until; + return until; } public void setUntil(Long until) { - this.until = until; + this.until = until; } public int getInterval() { - return interval; + return interval; } public void setInterval(int interval) { - this.interval = interval; + this.interval = interval; } } diff --git a/src/com/Zrips/CMI/Modules/Particl/ParticleManager.java b/src/com/Zrips/CMI/Modules/Particl/ParticleManager.java index 19763df..1551269 100644 --- a/src/com/Zrips/CMI/Modules/Particl/ParticleManager.java +++ b/src/com/Zrips/CMI/Modules/Particl/ParticleManager.java @@ -1,33 +1,23 @@ package com.Zrips.CMI.Modules.Particl; -import java.awt.Color; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Bukkit; -import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; -import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.util.Vector; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Colors.CMIChatColor; -import net.Zrips.CMILib.Effects.CMIEffectManager.CMIParticle; - -import com.Zrips.CMI.Containers.CMIUser; import com.Zrips.CMI.Containers.Snd; -import net.Zrips.CMILib.Logs.CMIDebug; + +import net.Zrips.CMILib.Effects.CMIEffect; +import net.Zrips.CMILib.Effects.CMIEffectManager.CMIParticle; public class ParticleManager { @@ -36,199 +26,192 @@ public class ParticleManager { Map> playerEffects = Collections.synchronizedMap(new ConcurrentHashMap>()); public ParticleManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public synchronized boolean addPlayerEffect(CMIVisualEffect effect) { - return true; + return true; } public synchronized boolean removePlayerEffects(CMIVisualEffect effect) { - return true; + return true; } public synchronized boolean removePlayerEffects(UUID uuid) { - return true; + return true; } public synchronized boolean removeAllPlayerEffects() { - return true; + return true; } + @Deprecated public void drawLine(Player player, Location loc1, Location loc2, CMIParticle effect, boolean center) { - drawLine(loc1, loc2, effect, center, Arrays.asList(player)); } + @Deprecated public void drawLine(Location loc1, Location loc2, CMIParticle effect, boolean center, Player player) { } + @Deprecated public void drawLine(Location loc1, Location loc2, CMIParticle effect, boolean center, List players) { - drawLine(loc1, loc2, effect, center, players, 5000L); + drawLine(loc1, loc2, effect, center, players, 5000L); } + @Deprecated public void drawLine(Location loc1, Location loc2, CMIParticle effect, boolean center, List players, Long keepFor) { - drawLine(loc1, loc2, effect, center, players, keepFor, 0.3); + drawLine(loc1, loc2, new CMIEffect(effect), center, players, keepFor, 0.3); } - public void drawLine(Location loc1, Location loc2, CMIParticle effect, boolean center, List players, Long keepFor, Double speed) { - ArrayList primaryLocations = getLineLocations(loc1, loc2, center, speed); - drawShed(primaryLocations, effect, players, keepFor); - } - - private static ArrayList getLineLocations(Location loc1, Location loc2, boolean center, Double speed) { - - return null; - } - - private void drawShed(final ArrayList primaryLocations, final CMIParticle effect, final List players, final Long keepFor) { - + public void drawLine(Location loc1, Location loc2, CMIEffect effect, boolean center, List players, Long keepFor, Double speed) { } private class taskCancel { - private int id = -1; + private int id = -1; - taskCancel(int id) { - this.id = id; - } + taskCancel(int id) { + this.id = id; + } - public int getId() { - return id; - } + public int getId() { + return id; + } - public void setId(int id) { - this.id = id; - } + public void setId(int id) { + this.id = id; + } - public void cancel() { - if (id > 0) - Bukkit.getScheduler().cancelTask(id); - } + public void cancel() { + if (id > 0) + Bukkit.getScheduler().cancelTask(id); + } } - private void markBlockShed(final Location o, final CMIParticle effect, final Long until, final List players) { - } + private void markBlockShed(final Location o, final CMIEffect effect, final Long until, final List players) { - private void markBlock(Location o, CMIParticle effect, final List players) { + } + private static void markBlock(Location o, CMIEffect effect, final List players) { } private static List remakePlotLineInRange(Double rowSpacing, int range, Vector p1, Vector p2, Location loc) { - - return null; + ArrayList vectors = new ArrayList(); + + return vectors; } private static boolean inRange(Location loc, Location loc2, Integer range) { - - return true; + return true; } private static Vectors shortenVectors(Double rowSpacing, Integer range, Vector p1, Vector p2, Location loc) { - return null; + Vectors v = new Vectors(); + + return v; } private static final String customPreset = "circle;effect:reddust;dur:5;pitchc:5;part:10;offset:0,1,0;radius:1;yawc:4"; public enum CMIPresetAnimations { -// Rotator2("circle;effect:reddust;dur:5;pitchc:5;part:10;offset:0,1.7,0;radius:1;yawc:5;color:rs"), - TotemHalo("circle;effect:reddust;c:255,255,10;twist;part:3;offset:0,2,0;pitch:90;radius:0.3;interval:2"), -// STwister2("circle;effect:redstonedust;part:4;radius:0.75;color:rfs;yaw:[playerName];pitch:[playerName];move:[playerName],0.5;twist;rc:-0.02;mmdist:30;offset:0,1.5,0;fixed"), -// CTree2("circle;effect:flame;part:4;radius:0.75;color:rs;pitch:90;move:0,0.1,0;twist;rc:-0.04;mmdist:2"), - Healing("circle;effect:heart;dur:0.1;part:1;offset:0,1.7,0;radius:0.3"), - GlyphHead("circle;effect:flying_glyph;dur:5;pitchc:15;part:10;offset:0,1.7,0;radius:0.5;yawc:12;color:rs;pitch:90"), - tpaWarmup("circle;effect:flying_glyph;dur:5;pitchc:15;part:10;offset:0,1.7,0;radius:0.5;yawc:12;color:rs;pitch:90"), - GColumn("circle;c:0,255,0;twist;part:5;r:0.75;pitch:90;move:0,0.1,0;rc:-0.02"), - SmallBoop("circle;effect:flying_glyph;yaw:[playerName];pitch:[playerName];r:0.1;part:3;rc:0.03;mr:0.3;twist"), - HologramInteraction("circle;effect:flying_glyph;yaw:[playerName];pitch:[playerName];r:0.1;part:3;rc:0.03;mr:0.3;twist"), - TpUp("circle;c:200,50,210;twist;part:5;r:0.5;pitch:90;move:0,0.33,0;offset:0,-0.2,0"), - TpDown("circle;c:150,50,10;part:5;r:0.5;pitch:90;move:0,-0.33,0;offset:0,2.2,0"), - custom1(customPreset), - custom2(customPreset), - custom3(customPreset), - custom4(customPreset), - custom5(customPreset), - custom6(customPreset), - custom7(customPreset), - custom8(customPreset), - custom9(customPreset), - custom10(customPreset), - custom11(customPreset), - custom12(customPreset), - custom13(customPreset), - custom14(customPreset), - custom15(customPreset), - custom16(customPreset), - custom17(customPreset), - custom18(customPreset), - custom19(customPreset), - custom20(customPreset), - custom21(customPreset), - custom22(customPreset), - custom23(customPreset), - custom24(customPreset), - custom25(customPreset), - custom26(customPreset), - custom27(customPreset), - custom28(customPreset), - custom29(customPreset), - custom30(customPreset); - - private String string = ""; - private boolean enabled = true; - - CMIPresetAnimations(String anim) { - string = anim; - } - - public CMIPEAnimationInterface getInter() { - return CMI.getInstance().getParticleManager().getParticleAnimation(string); - } - - public CMIPEAnimationInterface getInter(Player player) { - Snd snd = new Snd(player, player); - String s = CMI.getInstance().getLM().updateSnd(snd, string); - return CMI.getInstance().getParticleManager().getParticleAnimation(s); - } - - - public void show(Location loc) { - CMI.getInstance().getParticleManager().show(CMI.getInstance().getParticleManager().getParticleAnimation(string), loc); - } - - public void show(Player player) { - } - - public static CMIPresetAnimations getByName(String name) { - for (CMIPresetAnimations one : CMIPresetAnimations.values()) { - if (one.toString().equalsIgnoreCase(name)) - return one; - } - return null; - } - - public void setAnimString(String string) { - this.string = string; - } - - public String getAnimString() { - return string; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } + TotemHalo("circle;effect:reddust;c:255,255,10;twist;part:3;offset:0,2,0;pitch:90;radius:0.3;interval:2"), + Healing("circle;effect:heart;dur:0.1;part:1;offset:0,1.7,0;radius:0.3"), + GlyphHead("circle;effect:flying_glyph;dur:5;pitchc:15;part:10;offset:0,1.7,0;radius:0.5;yawc:12;color:rs;pitch:90"), + tpaWarmup("circle;effect:flying_glyph;dur:5;pitchc:15;part:10;offset:0,1.7,0;radius:0.5;yawc:12;color:rs;pitch:90"), + GColumn("circle;c:0,255,0;twist;part:5;r:0.75;pitch:90;move:0,0.1,0;rc:-0.02"), + SmallBoop("circle;effect:flying_glyph;yaw:[playerName];pitch:[playerName];r:0.1;part:3;rc:0.03;mr:0.3;twist"), + HologramInteraction("circle;effect:flying_glyph;yaw:[playerName];pitch:[playerName];r:0.1;part:3;rc:0.03;mr:0.3;twist"), + HologramNewInteraction("circle;effect:reddust;r:0;part:2;rc:0.2;mr:1;color:rs;yaw:[playerName];a:90"), + HologramHover("circle;effect:crit;r:0;part:1;"), + TpUp("circle;c:200,50,210;twist;part:5;r:0.5;pitch:90;move:0,0.33,0;offset:0,-0.2,0"), + TpDown("circle;c:150,50,10;part:5;r:0.5;pitch:90;move:0,-0.33,0;offset:0,2.2,0"), + custom1(customPreset), + custom2(customPreset), + custom3(customPreset), + custom4(customPreset), + custom5(customPreset), + custom6(customPreset), + custom7(customPreset), + custom8(customPreset), + custom9(customPreset), + custom10(customPreset), + custom11(customPreset), + custom12(customPreset), + custom13(customPreset), + custom14(customPreset), + custom15(customPreset), + custom16(customPreset), + custom17(customPreset), + custom18(customPreset), + custom19(customPreset), + custom20(customPreset), + custom21(customPreset), + custom22(customPreset), + custom23(customPreset), + custom24(customPreset), + custom25(customPreset), + custom26(customPreset), + custom27(customPreset), + custom28(customPreset), + custom29(customPreset), + custom30(customPreset); + + private String string = ""; + private boolean enabled = true; + + CMIPresetAnimations(String anim) { + string = anim; + } + + public CMIPEAnimationInterface getInter() { + return CMI.getInstance().getParticleManager().getParticleAnimation(string); + } + + public CMIPEAnimationInterface getInter(Player player) { + Snd snd = new Snd(player, player); + String s = CMI.getInstance().getLM().updateSnd(snd, string); + return CMI.getInstance().getParticleManager().getParticleAnimation(this.isEnabled() ? s : ""); + } + + public void show(Location loc) { + CMI.getInstance().getParticleManager().show(CMI.getInstance().getParticleManager().getParticleAnimation(string), loc); + } + + public void show(Player player) { + + } + + public static CMIPresetAnimations getByName(String name) { + for (CMIPresetAnimations one : CMIPresetAnimations.values()) { + if (one.toString().equalsIgnoreCase(name)) + return one; + } + return null; + } + + public void setAnimString(String string) { + this.string = string; + } + + public String getAnimString() { + return string; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } } public void show(final String a, final Player player) { - CMIPEAnimationInterface animation = getParticleAnimation(a); - show(animation, player); + CMIPEAnimationInterface animation = getParticleAnimation(a); + show(animation, player); } public void show(final CMIPEAnimationInterface animation, final Location loc) { @@ -238,7 +221,8 @@ public void show(final CMIPEAnimationInterface animation, final Player player) { } public CMIPEAnimationInterface getParticleAnimation(String string) { - return null; + + return null; } diff --git a/src/com/Zrips/CMI/Modules/Patrol/PatrolManager.java b/src/com/Zrips/CMI/Modules/Patrol/PatrolManager.java index bb86bd2..776d269 100644 --- a/src/com/Zrips/CMI/Modules/Patrol/PatrolManager.java +++ b/src/com/Zrips/CMI/Modules/Patrol/PatrolManager.java @@ -1,26 +1,19 @@ package com.Zrips.CMI.Modules.Patrol; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIUser; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; public class PatrolManager { private CMI plugin; public PatrolManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } - public CMIUser getNextUser() { - return null; + public CMIUser getNextUser() { + CMIUser user = null; + return user; } diff --git a/src/com/Zrips/CMI/Modules/Permissions/BPermissionsHandler.java b/src/com/Zrips/CMI/Modules/Permissions/BPermissionsHandler.java new file mode 100644 index 0000000..304b48e --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Permissions/BPermissionsHandler.java @@ -0,0 +1,43 @@ +package com.Zrips.CMI.Modules.Permissions; + +import java.util.UUID; + +import org.bukkit.entity.Player; + +public class BPermissionsHandler implements PermissionInterface { + + @Override + public String getMainGroup(Player player) { + return null; + } + + @Override + public String getPrefix(Player player) { + return null; + } + + @Override + public String getSufix(Player player) { + return null; + } + + @Override + public String getMainGroup(String world, UUID uuid) { + return null; + } + + @Override + public String getPrefix(UUID uuid) { + return null; + } + + @Override + public String getSufix(UUID uuid) { + return null; + } + + @Override + public String getNameColor(Player player) { + return null; + } +} diff --git a/src/com/Zrips/CMI/Modules/Permissions/GroupManagerXHandler.java b/src/com/Zrips/CMI/Modules/Permissions/GroupManagerXHandler.java new file mode 100644 index 0000000..463ad26 --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Permissions/GroupManagerXHandler.java @@ -0,0 +1,48 @@ +package com.Zrips.CMI.Modules.Permissions; + +import java.util.UUID; + +import org.bukkit.entity.Player; + +import com.Zrips.CMI.CMI; + +public class GroupManagerXHandler implements PermissionInterface { + + public GroupManagerXHandler(CMI plugin) { + } + + @Override + public String getMainGroup(Player player) { + return null; + } + + @Override + public String getPrefix(Player player) { + return null; + } + + @Override + public String getSufix(Player player) { + return null; + } + + @Override + public String getMainGroup(String world, UUID uuid) { + return null; + } + + @Override + public String getPrefix(UUID uuid) { + return null; + } + + @Override + public String getSufix(UUID uuid) { + return null; + } + + @Override + public String getNameColor(Player player) { + return null; + } +} diff --git a/src/com/Zrips/CMI/Modules/Permissions/LuckPermsHandler4.java b/src/com/Zrips/CMI/Modules/Permissions/LuckPermsHandler4.java new file mode 100644 index 0000000..b23607b --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Permissions/LuckPermsHandler4.java @@ -0,0 +1,47 @@ +package com.Zrips.CMI.Modules.Permissions; + +import java.util.UUID; + +import org.bukkit.entity.Player; + +public class LuckPermsHandler4 implements PermissionInterface { + + public LuckPermsHandler4() { + } + + @Override + public String getMainGroup(Player player) { + return null; + } + + @Override + public String getPrefix(Player player) { + return null; + } + + @Override + public String getNameColor(Player player) { + return null; + } + + @Override + public String getSufix(Player player) { + return null; + } + + @Override + public String getMainGroup(String world, UUID uuid) { + return null; + } + + @Override + public String getPrefix(UUID uuid) { + return null; + } + + @Override + public String getSufix(UUID uuid) { + return null; + } + +} diff --git a/src/com/Zrips/CMI/Modules/Permissions/LuckPermsHandler5.java b/src/com/Zrips/CMI/Modules/Permissions/LuckPermsHandler5.java new file mode 100644 index 0000000..ef065f0 --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Permissions/LuckPermsHandler5.java @@ -0,0 +1,47 @@ +package com.Zrips.CMI.Modules.Permissions; + +import java.util.UUID; + +import org.bukkit.entity.Player; + +public class LuckPermsHandler5 implements PermissionInterface { + + public LuckPermsHandler5() { + } + + @Override + public String getMainGroup(Player player) { + return null; + } + + @Override + public String getPrefix(Player player) { + return null; + } + + @Override + public String getNameColor(Player player) { + return null; + } + + @Override + public String getSufix(Player player) { + return null; + } + + @Override + public String getMainGroup(String world, UUID uuid) { + return null; + } + + @Override + public String getPrefix(UUID uuid) { + return null; + } + + @Override + public String getSufix(UUID uuid) { + return null; + } + +} diff --git a/src/com/Zrips/CMI/Modules/Permissions/PEXHandler.java b/src/com/Zrips/CMI/Modules/Permissions/PEXHandler.java new file mode 100644 index 0000000..43ef597 --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Permissions/PEXHandler.java @@ -0,0 +1,47 @@ +package com.Zrips.CMI.Modules.Permissions; + +import java.util.UUID; + +import org.bukkit.entity.Player; + +public class PEXHandler implements PermissionInterface { + + public PEXHandler() { + + } + + @Override + public String getMainGroup(Player player) { + return null; + } + + @Override + public String getPrefix(Player player) { + return null; + } + + @Override + public String getSufix(Player player) { + return null; + } + + @Override + public String getMainGroup(String world, UUID uuid) { + return null; + } + + @Override + public String getPrefix(UUID uuid) { + return null; + } + + @Override + public String getSufix(UUID uuid) { + return null; + } + + @Override + public String getNameColor(Player player) { + return null; + } +} diff --git a/src/com/Zrips/CMI/Modules/Permissions/PermissionsManager.java b/src/com/Zrips/CMI/Modules/Permissions/PermissionsManager.java index 0604d4a..e007cdb 100644 --- a/src/com/Zrips/CMI/Modules/Permissions/PermissionsManager.java +++ b/src/com/Zrips/CMI/Modules/Permissions/PermissionsManager.java @@ -1,25 +1,16 @@ package com.Zrips.CMI.Modules.Permissions; import java.util.HashMap; -import java.util.Map.Entry; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.permissions.PermissionDefault; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginManager; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.Snd; -import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.RawMessages.RawMessage; import com.Zrips.CMI.Modules.tp.Teleportations.TpCondition; -import com.Zrips.CMI.commands.CommandsHandler; public class PermissionsManager { @@ -27,582 +18,580 @@ public class PermissionsManager { private PermissionInterface perm = null; - public PermissionsManager(CMI plugin, String label) { - this.plugin = plugin; - this.label = label; - checkPermissions(); + public PermissionsManager(CMI plugin) { + this.plugin = plugin; + checkPermissions(); } public enum CMIPerm { - security_admin("Sets players security level"), - buttonteleport("Allows to teleport to target location when clicking on inventory edit GUI on location icon"), - enderedit("Allows to edit ender chest of some one else"), - bedhome("Allows to set home location on interaction"), - actionbar_colors("Allows to use colors in actionbarmsg command"), - elevator_use("Allows to use elevator based on signs"), - elevator_create("Allows to create elevator signs"), - bossbar_colors("Allows to use colors in bossbarmsg command"), - bossbar_hpbar("Allows to see hp boss bar when dealing damage to entity. Rechecks every minute."), -// me_colors("Allows to use colors in me command"), - dynmap_hidden("Hides player from dynmap map"), - prewards_notification("Allows to see playtime rewards notifications"), - prewards_$1("Allows to get particular playtime reward", "preward"), - anvil_colors("Allows to use colors when renaming item"), - title_colors("Allows to use colors in titlemsg command"), - tag_color("Tagged player name gets colorized"), - colors_$1_$star("Allows all color usage in particular areas", "type"), - colors_$1_$2("Allows color usage in particular areas. Types: publicmessage, privatemessage, nickname, signs, books, me", "type", "colorName/hex"), - seevanished("Allows to see vanished people"), - messages_disablelogin("Disables login message"), - messages_disablequit("Disables logout message"), - scrollpainting("Allows to modify paintings"), - autorespawn("Allows to respawn automatically"), - elytralaunch("Allows to use elytra launch feature"), - permisiononerror("Allows to see missing permission on error message"), - invedit("Allow to edit players inventory"), - book_colors("Allows to colorize books"), - book_pages_$1("Defines max pages you can create in a book","20to100"), - damagecontrol_$1("Defines damage multiplier by group", "groupName"), - chorusteleport("Allows to use chorus to teleport around"), - teleport_with_$1("Allows teleportation with defined mount", "entityType"), - randomteleport_cooldownbypass("Allows to bypass random teleport cooldown"), - fullserver_bypass("Allows to join full server"), - signs_shiftedit("Allows to edit signs with shift right click"), - signs_shifteditbypass("Allows to edit signs on protected land"), - netherportalbypass("Allows nether portal creation when its disabled in config file"), - silentchest_editing("Allows to edit chests while in silent open mode"), - interactivesign_$1("Allows to create interactive signs when using [ic:[icName]] as top line of sign", "icName"), - versioncheck("Allows to see new version message on login"), - worldlimit_gamemode_bypass("Allows to bypass game mode limitations by worlds"), - worldlimit_fly_bypass("Allows to bypass fly mode limitations by worlds"), - worldlimit_elytra_bypass("Allows to bypass elytra mode limitations by worlds"), - worldlimit_fly_aboveroof("Allows to fly over world build limit. Feature should be enabled in config file"), - worldlimit_god_bypass("Allows to bypass god mode limitations by worlds"), - spawners_charge_bypass("Allows to bypass charge limitations"), - namehistory("Allows to see previous players names"), - inventoryhat("Allows to put block on head from inventory"), - minecart_change_$1("Allows to change minecart type by right clicking with appropriate item", "minecartType"), - hologram_$1("Allows to see hologram", "hologramName"), - kit_$1("Allows to use kit", "kitName"), - kit_$1_preview("Allows to preview kit without having access to kit", "kitName"), - kit_bypass_money("Allows to bypass kit money requirement"), - kit_bypass_exp("Allows to bypass kit exp requirement"), - kit_bypass_time("Allows to bypass kit time limitations"), - kit_bypass_onetimeuse("Allows to bypass kit onetimeuse limitations"), - - pvp_cmdBypass("Allows to use commands durring combat mode"), - pvp_godBypass("Allows to damage player while being in god mode"), - pve_godBypass("Allows to damage mobs while being in god mode"), - pvp_PFlyBypass("Allows to keep flying while entering combat mode by player"), - pvp_MFlyBypass("Allows to keep flying while entering combat mode by monster"), - - spawnonjoin_bypass("Allows to bypass spawnOnJoin option"), - spawngroup_$1("Defines player individual spawn point", "spawnGroup"), - respawngroup_$1("Defines player individual respawn point", "respawnGroup"), - - rank_$1("Defines default player rank", "rankName"), - select("Allows to select with selection tool"), - - chatgroup_$1("Defines player custom chat group for public message format", "groupNumber"), - chatmessagegroup_$1("Defines player custom chat message group for public message format", "groupNumber"), - chat_shout("Allows to send messges over greater distances"), - chat_rangebypass("Allows to send messages over greater distances"), - chat_rangespy("Allows to see all messages over greater distances"), - tablist_$1("Defines player custom tab list group", "groupNumber"), - - elytra("Allows to equip elytra"), - elytra_boost("Allows to use basic elytra boost. Right click"), - elytra_superboost("Allows to use elytra super boost. +Shift click"), - elytra_speedometer("Allows to see speedometer while flying with elytra"), - elytra_freeflight("Allows to see elytra boost for free"), - - hunger_keepafterdeath("Prevents from hunger to be replenished after death"), - -// hunger_max_$1("Defines max amount of hunger player can have", "value"), -// hunger_rate_$1("Defines mhow fast hunger is depleating, default rate is 1.0", "value"), - - anvil_itemrename_bypass("Allows to rename items with black listed names. /itemanem and physical anvil"), -// anvil_nolimits("Allows repair items without level limitations"), - - sleepignore("Players with this permission node will be ignored when checking how many players are sleeping in the world to speed up time"), - - chatfilter_inform("Informs player when some one breaks chat filter rules"), - chatfilter_bypass_$1("Allows to bypass particular chat filter group", "groupName"), - commandfilter_bypass("Allows to bypass command spam filter"), - chatfilter_spambypass("Allows to bypass chat spam filter"), - chatfilter_capbypass("Allows to bypass chat caps filter"), - deathlocation("Allows to see death location after death"), - saveinv("Saves player inventory on death to be restored if needed later on"), - scheduler_exclude("Excludes player from scheduler random player list"), - openshulker("Allows to use shulkerbox as backpack"), - openshulker_shift("Allows to use shulkerbox as backpack with shift right click"), - safeteleport("Prevents teleportation to unsafe locations"), - safeteleport_bypass_$1("Allows to teleport into unsafe location without confirmation", TpCondition.getBadLocations()), - - viewrange("Allows to have custom view range"), - viewrange_$1("Defines custom view range", "range(1-15)"), - -// specialized_target("Allows to channge ptarget in specialized commands while performing command"), - - dropspawner("Allows for spawner to be dropped after its being broken"), - dropspawner_$1("Allows for spawner to be dropped after its being broken by defined type", "entityType"), - dropspawner_nosilk("Drops spawner without silk touch"), - dropspawner_basedropchance_$1("Defines base drop chance. Used in case its higher than defined one in config file", "positiveValue"), - spawners_proximity_bypass("Bypass spawner place range limitations"), - spawners_charge_$1("Defines spawner charge group", "groupName"), - - keepinventory("Allows to keep inventory after death"), - keepexp("Allows to keep exp after death"), - - informDurability("Player will be informed when durability reaches threshold"), - - egginteract_$1("Allows to change spawner by interacting with egg", "entityType"), - placespawner("Allows to place spawner and keep its type"), - placespawner_$1("Allows to place spawner by particular type and keep its type", "entityType"), - - teleport_bypassblacklist("Allows to bypass protection from teleporting with blacklisted items"), - teleport_currentlocation("Allows to initiate teleportation to the current player location"), - - armorstand_hands("Allows to spawn armorstand with hands"), - armorstand_offhand("Allows to manipulate armorstand off hand items"), - bungee_publicmessages_$1("Allows to send public messages to target server", "serverName"), - - warmupbypass_$1("Allows to bypass particular CMI command warmup", "commandName"), - - command("Gives access to base usage of commands"), - -// command_speccommand_$1_cooldownbypass("Allows to bypass specialised command cooldown"), - command_jump_$1("Defines max jump distance", "[distance]"), - costbypass_$1("Allows to bypass command cost", "commandName"), - cooldownbypass_$1("Allows to bypass command cooldown", "commandName"), - cooldown_$1_$2("Defines command cooldown for player. Spaces need to be separate with _", "some_command", "timer"), - command_armorstand_$1("Allows to access particular armor stand editor features", - "updateitems/plate/size/visible/arms/gravity/glow/invulnerable/name/interactable/head/body/leftArm/rightArm/leftLeg/rightLeg/pos/torso"), - command_armorstand_movebypass("Allows to move armor stand where you cant build. Can help to bypass AntiCheat plugin restrictions"), - - command_donate_bypass("Prevents you from getting items with donate command"), - command_donate_accept("Allows you to accept items sent throw donate command"), - command_donate_send("Allows you to send items throw donate command"), - - command_portal_$1("Allows to use portal", "portalName"), -// command_portalparticles_$1("Allows to see portal particles when requirement is enabled", "portalName"), - - command_kill_byforce("Allows to kill player independent of protection plugins"), - - command_kiteditor_admin("Allows to define more dangerous aspects of kits, like commands"), - - command_world_$1("Allows to teleport to particular world with command", "worldName"), - command_skin_perm_$1("Allows to change skin to particular player", "skinName"), - command_point_$1("Allows to change particle type", "particleType"), - command_ender_preventmodify("Prevents ender chest modification by some one else"), - command_ender_preventmodify_bypass("Bypass for ender chest modification protection"), - command_inv_preventmodify("Prevent inventory modifications by others"), - command_inv_location("Shows target player location in GUI"), - command_inv_information("Shows target player information in GUI"), - command_inv_preventmodify_bypass("Bypass for regular inventory modification protection"), - command_give_max_$1("Max item stack size player can use", "number"), -// command_tgod_give("Allows to give tgod for some one else"), -// command_tfly_give("Allows to give tfly for some one else"), - command_tfly_admin("Allows to manage tfly for players"), - command_tfly_maxtime_$1("Defines max amount of time player can have with tfly command", "seconds"), - command_spawner_shiftclick("Allows to use spawner set GUI on shift clicking it"), - command_spawner_$1("Allows to change spawner with command to defined type", "entityType"), - command_repair_$1("Allows to repair specific area", "hand/armor/all"), - command_head_othersource("Allows to get head of another player"), - command_note_add("Allows to add notes"), - command_note_remove("Allows to remove or clear notes"), - command_gm_$1("Allows to change game mode to particular type", "gameType"), - command_replaceblock_speed("Allows to adjust replaceblock speed"), - command_scan_speed("Allows to adjust scan speed"), - command_fixchunk_speed("Allows to adjust chunk fix speed"), - command_enchant_bypasslimit("Allows to bypass enchant limitations"), - command_enchant_bypassinvalid("Allows to enchant items with enchants which usualy are not possible on items"), - enchantments_$1("Allows to enchant items with specific enchant"), - enchantments_$1_$2("Allows to enchant items with specific enchant to specific max level"), - command_attachcommand_cc("Allows to attach console command to item"), - command_attachcommand_silent("Allows to attach silent commands"), - command_sendall_bypass("Prevents player from being sent to target server"), - command_heal_all("Allows to heal every online player"), - command_feed_all("Allows to feed every online player"), - command_$1_others("Allows to perform command on another player", "commandName"), - command_prewards_others_claim("Allows to claim rewards for others"), - command_$1_others_$2("Allows to perform command on another player", "commandName", "extra"), - command_msg_vanish("Allows to send private messages to vanished players"), - command_msg_togglebypass("Allows to send private messages even if player has pm toggled off"), - command_msg_$1_send("Allows to send private messages to specific player groups", "mainGroupName"), - command_bossbarmsg_admin("Allows to use commands in bossbar automated messages"), - command_sell_$1("Allows to sell items not only from your hand", "blocks/all"), - - command_patrol_bypass("Player with permission will not be included into patrol list"), - - command_afk_auto("Places player into afk mode autoamticaly"), - command_afk_staffinform("Uses different afk auto response message"), - command_afk_kickbypass("Prevents player from being kicked out of server when afk mode triggers event"), - command_afk_kickOutIn_$1("Defines time in seconds when player needs to be kicked after he enter afk mode", "[seconds]"), - - command_cheque_admin("Allows to give out cheque with money amount directly to target player without requiring paper"), - command_cheque_withdraw("Allows to withdraw cheque balance when option in config file is enabled"), - - command_invcheck_edit("Allows to edit saved inventory"), - - command_warp_$1("Allows to use particular warp if warp requires permission node", "warpName"), - command_warp_showlist("Allows to see warp list in chat or gui"), - command_warp_redefine("Allows to redefine warps"), - command_warp_specificlocation("Allows to define warps specific location"), - command_warp_diffdisplayname("Allows to define different warp display name"), - - command_setwarp_multiloc("Allows to set more than one location for warp point"), - command_setwarp_unlimited("Allows to have unlimited amount of warps"), - command_setwarp_$1("Allows to have defined amount of warps", "anyPositiveNumber"), - command_removewarp_bypass("Allows to remove warps which belong to anoher player"), - - command_counter_autojoin("Players will automatically join counter group on server join"), - - command_tpa_warmupbypass("Allows to bypass tpa command warmup"), - command_tpahere_warmupbypass("Allows to bypass tpahere command warmup"), - - command_home_bypassprivate("Allows to teleport to private another player home location"), - command_homes_range("Allows to see homes by range from you"), - command_sethome_unlimited("Allows to have unlimited amount of homes"), - command_sethome_$1("Allows to have defined amount of homes", "anyPositiveNumber"), - command_sethome_customloc("Allows to define custom location for new home"), - command_sethome_iconpicker("Allows to see icon picker after using command"), - command_sethome_overwrite("Allows to overwrite existing home location"), - command_sethome_bypass("Allows to bypass block break protection"), - - - command_mail_read("Allows to read mail"), - command_mail_clear("Allows to clear mail"), - command_mail_send("Allows to send mail"), - - command_glow_color_$1("Allows to change glow color", "colorName"), - command_walkspeed_$1("Defines max walkspeed player can set", "range0-10"), - command_tptoggle_bypass("Allows teleportation to players with disabled teleportations"), - command_sudo_bypass("Prevents player from using sudo on player with permission"), - command_repair_repairshare_bypass("Allows to bypass repair share being applied on item"), - command_nick_bypassblacklist("Allows to bypass nick name black list"), - command_nick_bypass_length("Allows to bypass nick name length limitations"), - command_nick_bypassinuse("Allows to bypass limitationn in using already existing name"), - command_nick_different("Allows to set nick name to different one than original"), - command_msg_clean("Allows to send clean messages to player by using ! at beginning"), - command_msg_noreply("Allows to send clean messages to player by using !- at beginning without option to reply"), - command_ignore_bypass("Allows to perform commands on who ignores you"), - command_silence_bypass("Allows to send messages who is in silence mode"), - command_more_oversize("Allows to get oversized stacks"), - command_list_admin("Places player into admin group in list"), - command_list_staff("Places player into staff group in list"), - command_list_hidden("Allows to see hidden players in player list"), - command_list_group_$1("Assigns player to defined group", "groupNumber"), - command_checkban_seereason("Allows to see players ban reason"), - command_mirror_nodeduct("Will not use blocks when placing them in survival and in mirror mode"), - command_lfix_admin("Allows to fix light in area bigger than you can see"), - command_commandspy_hide("Hides performed commands from commandspy"), - command_commandspy_bypass("Bypasses blacklisted command spy commands"), - command_signspy_hide("Hides created signs from signspy"), - command_socialspy_hide("Hides social messages from social spy"), - command_mute_max_$1("Allows to temp mute for defined max time", "anyPositiveNumber"), - command_mute_bypass("Bypass personal public chat mute"), - command_mutechat_bypass("Bypass public chat mute"), - command_money_admin("Allows to manipulate player balance"), - command_money_betweenworldgroups("Allows money transfer between worlds"), - command_time_$1("Allows to manipulate time", "freeze/unfreeze/day/morning/night/dusk/add/take/realtime/autorealtime"), - command_weather_$1_$2("Allows to define max length player can change weather to", "sun/rain", "maxValue"), - command_back_ondeath("Allows returning to death location by using back command after death"), - command_back_worldbypass("Allows returning to blacklisted worlds"), - command_flightcharge_admin("Allows to edit flight charges for players"), - command_kick_bypass("Prevent player from being kicked from server"), - command_ride_$1("Allow to ride entity", "entityType"), - command_sit_stairs("Allows to sit on stairs automatically"), - command_sit_persistent("Allows to sit with persistent mode"), - command_sit_location("Allows to sit in specific location"), - command_maintenance_bypass("Allows to bypass maintenance mode"), - command_alert_inform("Player will get notification on player join with alert"), - command_helpop_inform("Players with permission gets helpop messages"), - command_fly_safelogin("Safely lands player after relog if he is in air"), - command_cuff_bypass("Allows command usage while cuffed"), - command_jail_bypasscmd("Allows command usage while jailed"), - command_jail_bypass("Prevents player from being jailed"), - command_jail_maxtime_$1("Defines max amount of time player can jail someone", "seconds"), - command_near_hide("Hides player from being shown in near command"), - command_near_max_$1("Defines max distance for near command to override default", "blocks"), - command_silent("Allows to use -s variable in commands to avoid sending feedback messages to target player"), - command_warn_bypass("Prevents player from being warned"), - command_ban_bypass("Prevents player from being banned"), - command_banip_bypass("Prevents player from being banned by ip"), - command_tempban_bypass("Prevents player from being tempbanned"), - command_tempban_max_unlimited("Allows to temp ban for more than config allows"), - command_tempban_max_$1("Allows to temp ban for defined max time", "anyPositiveNumber"), - command_broadcast_colors("Allows to use colors in broadcast messages"), - command_charges_edit("Allows to edit players spawner charges"), - command_checkaccount_showip("Allows to see players ip in check account"), - command_info_ip("Allows to see players ip in info page"), - command_info_pos("Allows to see pos location in info page"), - command_info_bed("Allows to see bed location in info page"), - command_info_back("Allows to see back location in info page"), - command_info_deathlocation("Allows to see death location in info page"), - command_clearchat_bypass("Players chat with permission will not be cleared"), - command_counter_force("Allows to force counter message on surrounding players"), - command_counter_time("Allows to change counter default time"), - command_counter_range("Allows to change counter default range"), - command_counter_center("Allows to use counter custom location"), - command_counter_msg("Allows to change counter default message"), - command_ctext_$1("Allows to see defined custom message", "ctextName"), - command_flyspeed_$1("Defines max flight speed player can set", "range1-10"), - command_shoot_$1("Allows to shoot specific type of entity", "type"), - - command_chat_kick("Allows to kick players from chat room"), - command_chat_force("Allows to force join player into chat room"), - command_chat_create("Allows to create chatroom"), - command_chat_create_private("Allows to create private chatrooms"), - command_chat_create_locked("Allows to create locked chatrooms"), - command_chat_leave_locked("Allows to leave locked chatrooms"), - command_chat_create_persistent("Allows to create persistent chatrooms"), - command_chat_invite("Allows to intite player into chatroom"), - command_chat_joinbypass("Allows to join private chat room without invitation"), - command_chat_list("Allows to list players in chat room"), - command_chat_listrooms("Allows to list all chat rooms"), - - customalias_$1("Allows to use particular alias if it requires permission", "alias"), - - command_repair("", false), - command_$1("", false); - - private Boolean show = true; - private String desc; - private String[] wars; - - CMIPerm(String desc, Boolean show) { - this.desc = desc; - this.show = show; - } - - CMIPerm(String desc) { - this.desc = desc; - } - - CMIPerm(String desc, String... wars) { - this.desc = desc; - this.wars = wars; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public String getPermissionForShow() { - return getPermissionForShow(false); - } - - public String getPermissionForShow(boolean cmd) { - return null; - } - - public String getPermission() { - return getPermission(""); - } - - public String getPermission(String... extra) { - return null; - } - - public boolean hasPermission(CommandSender sender) { - return hasPermission(sender, false); - } - - public boolean hasPermission(CommandSender sender, Integer... extra) { - String[] ex = new String[extra.length]; - for (int i = 0; i < extra.length; i++) { - ex[i] = String.valueOf(extra[i]); - } - return hasPermission(sender, false, ex); - } - - public boolean hasPermission(CommandSender sender, String... extra) { - return hasPermission(sender, false, extra); - } - - public boolean hasPermission(CommandSender sender, Long delay, String... extra) { - return hasPermission(sender, false, true, delay, extra); - } - - public boolean hasPermission(CommandSender sender, boolean inform, String... extra) { - return hasPermission(sender, inform, true, extra); - } - - public boolean hasPermission(CommandSender sender, boolean inform, boolean informConsole, String... extra) { - return hasPermission(sender, inform, informConsole, null, extra); - } - - public boolean hasPermission(CommandSender sender, boolean inform, Long delayInMiliSeconds) { - return hasPermission(sender, inform, true, delayInMiliSeconds); - } - - public boolean hasPermission(CommandSender sender, boolean inform, boolean informConsole, Long delay, String... extra) { - return true; - } - - private static void informConsole(CommandSender sender, String permission, boolean informConsole) { - } - - public boolean hasSetPermission(CommandSender sender, String... extra) { - return hasSetPermission(sender, false, extra); - } - - public boolean hasSetPermission(CommandSender sender, boolean inform, String... extra) { - return hasSetPermission(sender, this.getPermission(extra), inform); - } - - public static boolean hasSetPermission(CommandSender sender, String perm, boolean inform) { - PermissionAttachmentInfo has = CMI.getInstance().getPermissionsManager().getSetPermission(sender, perm); - - return has == null ? false : has.getValue(); - } + security_admin("Sets players security level"), + buttonteleport("Allows to teleport to target location when clicking on inventory edit GUI on location icon"), + enderedit("Allows to edit ender chest of some one else"), + bedhome("Allows to set home location on interaction"), + actionbar_colors("Allows to use colors in actionbarmsg command"), + elevator_use("Allows to use elevator based on signs"), + elevator_create("Allows to create elevator signs"), + bossbar_colors("Allows to use colors in bossbarmsg command"), + bossbar_hpbar("Allows to see hp boss bar when dealing damage to entity. Rechecks every minute."), + dynmap_hidden("Hides player from dynmap map"), + prewards_notification("Allows to see playtime rewards notifications"), + prewards_$1("Allows to get particular playtime reward", "preward"), + anvil_colors("Allows to use colors when renaming item"), + title_colors("Allows to use colors in titlemsg command"), + tag_color("Tagged player name gets colorized"), + colors_$1_$star("Allows all color usage in particular areas", "type"), + colors_$1_$2("Allows color usage in particular areas. Types: publicmessage, privatemessage, nickname, signs, books, me", "type", "colorName/hex"), + seevanished("Allows to see vanished people"), + messages_disablelogin("Disables login message"), + messages_disablequit("Disables logout message"), + scrollpainting("Allows to modify paintings"), + autorespawn("Allows to respawn automatically"), + elytralaunch("Allows to use elytra launch feature"), + permisiononerror("Allows to see missing permission on error message"), + invedit("Allow to edit players inventory"), + book_colors("Allows to colorize books"), + book_pages_$1("Defines max pages you can create in a book", "20to100"), + damagecontrol_$1("Defines damage multiplier by group", "groupName"), + chorusteleport("Allows to use chorus to teleport around"), + teleport_with_$1("Allows teleportation with defined mount", "entityType"), + randomteleport_cooldownbypass("Allows to bypass random teleport cooldown"), + fullserver_bypass("Allows to join full server"), + signs_shiftedit("Allows to edit signs with shift right click"), + signs_shifteditbypass("Allows to edit signs on protected land"), + netherportalbypass("Allows nether portal creation when its disabled in config file"), + silentchest_editing("Allows to edit chests while in silent open mode"), + interactivesign_$1("Allows to create interactive signs when using [ic:[icName]] as top line of sign", "icName"), + versioncheck("Allows to see new version message on login"), + worldlimit_gamemode_bypass("Allows to bypass game mode limitations by worlds"), + worldlimit_fly_bypass("Allows to bypass fly mode limitations by worlds"), + worldlimit_elytra_bypass("Allows to bypass elytra mode limitations by worlds"), + worldlimit_fly_aboveroof("Allows to fly over world build limit. Feature should be enabled in config file"), + worldlimit_god_bypass("Allows to bypass god mode limitations by worlds"), + spawners_charge_bypass("Allows to bypass charge limitations"), + namehistory("Allows to see previous players names"), + inventoryhat("Allows to put block on head from inventory"), + minecart_change_$1("Allows to change minecart type by right clicking with appropriate item", "minecartType"), + hologram_$1("Allows to see hologram", "hologramName"), + kit_$1("Allows to use kit", "kitName"), + kit_$1_preview("Allows to preview kit without having access to kit", "kitName"), + kit_bypass_money("Allows to bypass kit money requirement"), + kit_bypass_exp("Allows to bypass kit exp requirement"), + kit_bypass_time("Allows to bypass kit time limitations"), + kit_bypass_onetimeuse("Allows to bypass kit onetimeuse limitations"), + + pvp_cmdBypass("Allows to use commands during combat mode"), + pvp_godBypass("Allows to damage player while being in god mode"), + pve_godBypass("Allows to damage mobs while being in god mode"), + pvp_PFlyBypass("Allows to keep flying while entering combat mode by player"), + pvp_MFlyBypass("Allows to keep flying while entering combat mode by monster"), + + spawnonjoin_bypass("Allows to bypass spawnOnJoin option"), + spawngroup_$1("Defines player individual spawn point", "spawnGroup"), + respawngroup_$1("Defines player individual respawn point", "respawnGroup"), + + rank_$1("Defines default player rank", "rankName"), + select("Allows to select with selection tool"), + + chatgroup_$1("Defines player custom chat group for public message format", "groupNumber"), + chatmessagegroup_$1("Defines player custom chat message group for public message format", "groupNumber"), + chat_shout("Allows to send messges over greater distances"), + chat_rangebypass("Allows to send messages over greater distances"), + chat_rangespy("Allows to see all messages over greater distances"), + tablist_$1("Defines player custom tab list group", "groupNumber"), + + elytra("Allows to equip elytra"), + elytra_boost("Allows to use basic elytra boost. Right click"), + elytra_superboost("Allows to use elytra super boost. +Shift click"), + elytra_speedometer("Allows to see speedometer while flying with elytra"), + elytra_freeflight("Allows to use elytra boost for free"), + + hunger_keepafterdeath("Prevents from hunger to be replenished after death"), + + anvil_itemrename_bypass("Allows to rename items with black listed names. /itemanem and physical anvil"), + + sleepignore("Players with this permission node will be ignored when checking how many players are sleeping in the world to speed up time"), + + chatfilter_inform("Informs player when some one breaks chat filter rules"), + chatfilter_bypass_$1("Allows to bypass particular chat filter group", "groupName"), + commandfilter_bypass("Allows to bypass command spam filter"), + chatfilter_spambypass("Allows to bypass chat spam filter"), + chatfilter_capbypass("Allows to bypass chat caps filter"), + deathlocation("Allows to see death location after death"), + saveinv("Saves player inventory on death to be restored if needed later on"), + scheduler_exclude("Excludes player from scheduler random player list"), + openshulker("Allows to use shulkerbox as backpack"), + openshulker_shift("Allows to use shulkerbox as backpack with shift right click"), + safeteleport("Prevents teleportation to unsafe locations"), + safeteleport_bypass_$1("Allows to teleport into unsafe location without confirmation", TpCondition.getBadLocations()), + + viewrange("Allows to have custom view range"), + viewrange_$1("Defines custom view range", "range(1-15)"), + + dropspawner("Allows for spawner to be dropped after its being broken"), + dropspawner_$1("Allows for spawner to be dropped after its being broken by defined type", "entityType"), + dropspawner_nosilk("Drops spawner without silk touch"), + dropspawner_basedropchance_$1("Defines base drop chance. Used in case its higher than defined one in config file", "positiveValue"), + spawners_proximity_bypass("Bypass spawner place range limitations"), + spawners_charge_$1("Defines spawner charge group", "groupName"), + + keepinventory("Allows to keep inventory after death"), + keepexp("Allows to keep exp after death"), + + informDurability("Player will be informed when durability reaches threshold"), + + egginteract_$1("Allows to change spawner by interacting with egg", "entityType"), + placespawner("Allows to place spawner and keep its type"), + placespawner_$1("Allows to place spawner by particular type and keep its type", "entityType"), + + teleport_bypassblacklist("Allows to bypass protection from teleporting with blacklisted items"), + teleport_currentlocation("Allows to initiate teleportation to the current player location"), + + armorstand_hands("Allows to spawn armorstand with hands"), + armorstand_offhand("Allows to manipulate armorstand off hand items"), + bungee_publicmessages_$1("Allows to send public messages to target server", "serverName"), + + warmupbypass_$1("Allows to bypass particular CMI command warmup", "commandName"), + warmuptime_$1("Allows to set warmup time. Lower is prioritized", "commandName"), + + command("Gives access to base usage of commands"), + + command_options_$1("Allows to modify specific options", "visibleHolograms/shiftSignEdit/totemBossBar/bassBarCompass/tagSound/chatSpy/cmdSpy/signSpy/acceptingPM/acceptingTPA/acceptingMoney"), + command_jump_$1("Defines max jump distance", "[distance]"), + costbypass_$1("Allows to bypass command cost", "commandName"), + cooldownbypass_$1("Allows to bypass command cooldown", "commandName"), + cooldown_$1_$2("Defines command cooldown for player. Spaces need to be separate with _", "some_command", "timer"), + command_armorstand_$1("Allows to access particular armor stand editor features", + "updateitems/plate/size/visible/arms/gravity/glow/invulnerable/name/interactable/head/body/leftArm/rightArm/leftLeg/rightLeg/pos/torso"), + command_armorstand_movebypass("Allows to move armor stand where you cant build. Can help to bypass AntiCheat plugin restrictions"), + command_armorstand_admin("Allows to save/load/deleted saved armor stands"), + command_armorstand_template_$1("Allows to deploy saved armor stands", "[templateName]"), + + command_donate_bypass("Prevents you from getting items with donate command"), + command_donate_accept("Allows you to accept items sent throw donate command"), + command_donate_send("Allows you to send items throw donate command"), + + command_portal_$1("Allows to use portal", "portalName"), + + command_kill_byforce("Allows to kill player independent of protection plugins"), + + command_kiteditor_admin("Allows to define more dangerous aspects of kits, like commands"), + + command_world_$1("Allows to teleport to particular world with command", "worldName"), + command_skin_perm_$1("Allows to change skin to particular player", "skinName"), + command_point_$1("Allows to change particle type", "particleType"), + command_ender_preventmodify("Prevents ender chest modification by some one else"), + command_ender_preventmodify_bypass("Bypass for ender chest modification protection"), + command_inv_preventmodify("Prevent inventory modifications by others"), + command_inv_location("Shows target player location in GUI"), + command_inv_information("Shows target player information in GUI"), + command_inv_preventmodify_bypass("Bypass for regular inventory modification protection"), + command_give_max_$1("Max item stack size player can use", "number"), + command_tfly_admin("Allows to manage tfly for players"), + command_tfly_maxtime_$1("Defines max amount of time player can have with tfly command", "seconds"), + command_spawner_shiftclick("Allows to use spawner set GUI on shift clicking it"), + command_spawner_$1("Allows to change spawner with command to defined type", "entityType"), + command_repair_$1("Allows to repair specific area", "hand/armor/all"), + command_head_othersource("Allows to get head of another player"), + command_note_add("Allows to add notes"), + command_note_remove("Allows to remove or clear notes"), + command_gm_$1("Allows to change game mode to particular type", "gameType"), + command_replaceblock_speed("Allows to adjust replaceblock speed"), + command_scan_speed("Allows to adjust scan speed"), + command_fixchunk_speed("Allows to adjust chunk fix speed"), + command_enchant_bypasslimit("Allows to bypass enchant limitations"), + command_enchant_bypassinvalid("Allows to enchant items with enchants which usually are not possible on items"), + enchantments_$1("Allows to enchant items with specific enchant"), + enchantments_$1_$2("Allows to enchant items with specific enchant to specific max level"), + command_attachcommand_cc("Allows to attach console command to item"), + command_attachcommand_silent("Allows to attach silent commands"), + command_sendall_bypass("Prevents player from being sent to target server"), + command_heal_all("Allows to heal every online player"), + command_feed_all("Allows to feed every online player"), + command_$1_others("Allows to perform command on another player", "commandName"), + command_prewards_others_claim("Allows to claim rewards for others"), + command_$1_others_$2("Allows to perform command on another player", "commandName", "extra"), + command_msg_vanish("Allows to send private messages to vanished players"), + command_msg_togglebypass("Allows to send private messages even if player has pm toggled off"), + command_msg_$1_send("Allows to send private messages to specific player groups", "mainGroupName"), + command_bossbarmsg_admin("Allows to use commands in bossbar automated messages"), + command_sell_$1("Allows to sell items not only from your hand", "blocks/all"), + + command_patrol_bypass("Player with permission will not be included into patrol list"), + + command_afk_auto("Places player into afk mode automatically"), + command_afk_staffinform("Uses different afk auto response message"), + command_afk_kickbypass("Prevents player from being kicked out of server when afk mode triggers event"), + command_afk_kickOutIn_$1("Defines time in seconds when player needs to be kicked after he enter afk mode", "[seconds]"), + + command_cheque_admin("Allows to give out cheque with money amount directly to target player without requiring paper"), + command_cheque_withdraw("Allows to withdraw cheque balance when option in config file is enabled"), + + command_invcheck_edit("Allows to edit saved inventory"), + + command_warp_$1("Allows to use particular warp if warp requires permission node", "warpName"), + command_warp_showlist("Allows to see warp list in chat or gui"), + command_warp_redefine("Allows to redefine warps"), + command_warp_specificlocation("Allows to define warps specific location"), + command_warp_diffdisplayname("Allows to define different warp display name"), + + command_setwarp_multiloc("Allows to set more than one location for warp point"), + command_setwarp_unlimited("Allows to have unlimited amount of warps"), + command_setwarp_$1("Allows to have defined amount of warps", "anyPositiveNumber"), + command_removewarp_bypass("Allows to remove warps which belong to anoher player"), + + command_counter_autojoin("Players will automatically join counter group on server join"), + + command_tpa_warmupbypass("Allows to bypass tpa command warmup"), + command_tpahere_warmupbypass("Allows to bypass tpahere command warmup"), + + command_home_bypassprivate("Allows to teleport to private another player home location"), + command_homes_range("Allows to see homes by range from you"), + command_sethome_unlimited("Allows to have unlimited amount of homes"), + command_sethome_$1("Allows to have defined amount of homes", "anyPositiveNumber"), + command_sethome_customloc("Allows to define custom location for new home"), + command_sethome_iconpicker("Allows to see icon picker after using command"), + command_sethome_overwrite("Allows to overwrite existing home location"), + command_sethome_bypass("Allows to bypass block break protection"), + command_sethome_bypasslimit("Allows to bypass limits by worlds"), + + command_mail_read("Allows to read mail"), + command_mail_clear("Allows to clear mail"), + command_mail_send("Allows to send mail"), + command_mail_sendtemp("Allows to send timed mail"), + + command_glow_color_$1("Allows to change glow color", "colorName"), + command_walkspeed_$1("Defines max walkspeed player can set", "range0-10"), + command_tptoggle_bypass("Allows teleportation to players with disabled teleportations"), + command_sudo_bypass("Prevents player from using sudo on player with permission"), + command_repair_repairshare_bypass("Allows to bypass repair share being applied on item"), + command_repair_bypass("Allows to bypass repair cost on item"), + command_nick_bypassblacklist("Allows to bypass nick name black list"), + command_nick_bypass_length("Allows to bypass nick name length limitations"), + command_nick_bypassinuse("Allows to bypass limitationn in using already existing name"), + command_nick_different("Allows to set nick name to different one than original"), + command_msg_clean("Allows to send clean messages to player by using ! at beginning"), + command_msg_noreply("Allows to send clean messages to player by using !- at beginning without option to reply"), + command_ignore_bypass("Allows to perform commands on who ignores you"), + command_silence_bypass("Allows to send messages who is in silence mode"), + command_more_oversize("Allows to get oversized stacks"), + command_recipe_admin("Allows to enable/disable recipes"), + command_list_admin("Places player into admin group in list"), + command_list_staff("Places player into staff group in list"), + command_list_hidden("Allows to see hidden players in player list"), + command_list_group_$1("Assigns player to defined group", "groupNumber"), + command_checkban_seereason("Allows to see players ban reason"), + command_mirror_nodeduct("Will not use blocks when placing them in survival and in mirror mode"), + command_lfix_admin("Allows to fix light in area bigger than you can see"), + command_commandspy_hide("Hides performed commands from commandspy"), + command_commandspy_bypass("Bypasses blacklisted command spy commands"), + command_signspy_hide("Hides created signs from signspy"), + command_socialspy_hide("Hides social messages from social spy"), + command_mute_max_$1("Allows to temp mute for defined max time", "anyPositiveNumber"), + command_mute_bypass("Bypass personal public chat mute"), + command_mutechat_bypass("Bypass public chat mute"), + command_money_admin("Allows to manipulate player balance"), + command_money_betweenworldgroups("Allows money transfer between worlds"), + command_time_$1("Allows to manipulate time", "freeze/unfreeze/day/morning/night/dusk/add/take/realtime/autorealtime"), + command_weather_$1_$2("Allows to define max length player can change weather to", "sun/rain", "maxValue"), + command_pweather_$1("Allows to change personal weather to specific state", "sun/rain/reset"), + command_back_ondeath("Allows returning to death location by using back command after death"), + command_back_worldbypass("Allows returning to blacklisted worlds"), + command_flightcharge_admin("Allows to edit flight charges for players"), + command_nameplate_admin("Allows to edit nameplates for players"), + command_kick_bypass("Prevent player from being kicked from server"), + command_ride_$1("Allow to ride entity", "entityType"), + command_sit_stairs("Allows to sit on stairs automatically"), + command_sit_persistent("Allows to sit with persistent mode"), + command_sit_location("Allows to sit in specific location"), + command_maintenance_bypass("Allows to bypass maintenance mode"), + command_alert_inform("Player will get notification on player join with alert"), + command_helpop_inform("Players with permission gets helpop messages"), + command_fly_safelogin("Safely lands player after relog if he is in air"), + command_cuff_bypass("Allows command usage while cuffed"), + command_jail_bypasscmd("Allows command usage while jailed"), + command_jail_bypass("Prevents player from being jailed"), + command_jail_maxtime_$1("Defines max amount of time player can jail someone", "seconds"), + command_near_hide("Hides player from being shown in near command"), + command_near_max_$1("Defines max distance for near command to override default", "blocks"), + command_silent("Allows to use -s variable in commands to avoid sending feedback messages to target player"), + command_warn_bypass("Prevents player from being warned"), + command_ban_bypass("Prevents player from being banned"), + command_banip_bypass("Prevents player from being banned by ip"), + command_tempban_bypass("Prevents player from being tempbanned"), + command_tempban_max_unlimited("Allows to temp ban for more than config allows"), + command_tempban_max_$1("Allows to temp ban for defined max time", "anyPositiveNumber"), + command_broadcast_colors("Allows to use colors in broadcast messages"), + command_broadcast_clean("Allows to use ! to send clean broadcast messages"), + command_charges_edit("Allows to edit players spawner charges"), + command_checkaccount_showip("Allows to see players ip in check account"), + command_info_ip("Allows to see players ip in info page"), + command_info_pos("Allows to see pos location in info page"), + command_info_bed("Allows to see bed location in info page"), + command_info_back("Allows to see back location in info page"), + command_info_deathlocation("Allows to see death location in info page"), + command_clearchat_bypass("Players chat with permission will not be cleared"), + command_counter_force("Allows to force counter message on surrounding players"), + command_counter_time("Allows to change counter default time"), + command_counter_range("Allows to change counter default range"), + command_counter_center("Allows to use counter custom location"), + command_counter_msg("Allows to change counter default message"), + command_ctext_$1("Allows to see defined custom message", "ctextName"), + command_flyspeed_$1("Defines max flight speed player can set", "range1-10"), + command_shoot_$1("Allows to shoot specific type of entity", "type"), + + command_chat_kick("Allows to kick players from chat room"), + command_chat_see("Allows to see messages in chat room"), + command_chat_force("Allows to force join player into chat room"), + command_chat_create("Allows to create chatroom"), + command_chat_create_private("Allows to create private chatrooms"), + command_chat_create_locked("Allows to create locked chatrooms"), + command_chat_leave_locked("Allows to leave locked chatrooms"), + command_chat_create_persistent("Allows to create persistent chatrooms"), + command_chat_invite("Allows to initiate player into chatroom"), + command_chat_joinbypass("Allows to join private chat room without invitation"), + command_chat_seebypass("Allows to see private chat room"), + command_chat_list("Allows to list players in chat room"), + command_chat_listrooms("Allows to list all chat rooms"), + + customalias_$1("Allows to use particular alias if it requires permission", "alias"), + + command_repair("", false), + command_$1("", false); + + private Boolean show = true; + private String desc; + private String[] wars; + + CMIPerm(String desc, Boolean show) { + this.desc = desc; + this.show = show; + } + + CMIPerm(String desc) { + this.desc = desc; + } + + CMIPerm(String desc, String... wars) { + this.desc = desc; + this.wars = wars; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getPermissionForShow() { + return getPermissionForShow(false); + } + + public String getPermissionForShow(boolean cmd) { + return null; + } + + public String getPermission() { + return getPermission(""); + } + + public String getPermission(String... extra) { + return null; + } + + public boolean hasPermission(CommandSender sender) { + return hasPermission(sender, false); + } + + public boolean hasPermission(CommandSender sender, Integer... extra) { + String[] ex = new String[extra.length]; + for (int i = 0; i < extra.length; i++) { + ex[i] = String.valueOf(extra[i]); + } + return hasPermission(sender, false, ex); + } + + public boolean hasPermission(CommandSender sender, String... extra) { + return hasPermission(sender, false, extra); + } + + public boolean hasPermission(CommandSender sender, Long delay, String... extra) { + return hasPermission(sender, false, true, delay, extra); + } + + public boolean hasPermission(CommandSender sender, boolean inform, String... extra) { + return hasPermission(sender, inform, true, extra); + } + + public boolean hasPermission(CommandSender sender, boolean inform, boolean informConsole, String... extra) { + return hasPermission(sender, inform, informConsole, null, extra); + } + + public boolean hasPermission(CommandSender sender, boolean inform, Long delayInMiliSeconds) { + return hasPermission(sender, inform, true, delayInMiliSeconds); + } + + public boolean hasPermission(CommandSender sender, boolean inform, boolean informConsole, Long delay, String... extra) { + return false; + } + + private static void informConsole(CommandSender sender, String permission, boolean informConsole) { + } + + public boolean hasSetPermission(CommandSender sender, String... extra) { + return hasSetPermission(sender, false, extra); + } + + public boolean hasSetPermission(CommandSender sender, boolean inform, String... extra) { + return hasSetPermission(sender, this.getPermission(extra), inform); + } + + public static boolean hasSetPermission(CommandSender sender, String perm, boolean inform) { + return false; + } + + public String[] getWars() { + return wars; + } + + public void setWars(String[] wars) { + this.wars = wars; + } + + public Boolean getShow() { + return show; + } + + public void setShow(Boolean show) { + this.show = show; + } + + public static boolean hasPermission(CommandSender sender, String permision, Boolean output) { + return hasPermission(sender, permision, output, true); + } + + public static boolean hasPermission(CommandSender sender, String permision, Boolean output, boolean informConsole) { + return false; + } + + public PermissionInfo getPermissionInfo(Player player, String... extra) { + return CMI.getInstance().getPermissionsManager().getPermissionInfo(player, this, extra); + } - public String[] getWars() { - return wars; - } - - public void setWars(String[] wars) { - this.wars = wars; - } - - public Boolean getShow() { - return show; - } - - public void setShow(Boolean show) { - this.show = show; - } - - public static boolean hasPermission(CommandSender sender, String permision, Boolean output) { - return hasPermission(sender, permision, output, true); - } - - public static boolean hasPermission(CommandSender sender, String permision, Boolean output, boolean informConsole) { - return true; - - } } private void permissionMessage(String permissionPlugin) { - plugin.consoleMessage("Permission plugin: &5" + permissionPlugin); + plugin.consoleMessage("Permission plugin: &5" + permissionPlugin); } public void checkPermissions() { - } public String getMainGroup(Player player) { - if (player == null) - return ""; - String group = perm.getMainGroup(player); - return group == null ? "" : group; + if (player == null) + return ""; + String group = perm.getMainGroup(player); + return group == null ? "" : group; } public String getPrefix(UUID uuid) { - String prefix = perm.getPrefix(uuid); - return prefix == null ? "" : prefix; + String prefix = perm.getPrefix(uuid); + return prefix == null ? "" : prefix; } public String getSufix(UUID uuid) { - String sufix = perm.getSufix(uuid); - return sufix == null ? "" : sufix; + String sufix = perm.getSufix(uuid); + return sufix == null ? "" : sufix; } public String getPrefix(Player player) { - String prefix = perm.getPrefix(player); - return prefix == null ? "" : prefix; + String prefix = perm.getPrefix(player); + return prefix == null ? "" : prefix; } public String getSufix(Player player) { - String sufix = perm.getSufix(player); - return sufix == null ? "" : sufix; + String sufix = perm.getSufix(player); + return sufix == null ? "" : sufix; } public String getNameColor(Player player) { - String sufix = perm.getNameColor(player); - return sufix == null ? "" : sufix; + String sufix = perm.getNameColor(player); + return sufix == null ? "" : sufix; } - private String label = ""; - public PermissionAttachmentInfo getSetPermission(CommandSender sender, String perm) { - if (sender instanceof Player) - for (PermissionAttachmentInfo permission : ((Player) sender).getEffectivePermissions()) { - if (permission.getPermission().equalsIgnoreCase(perm)) { - return permission; - } - } - return null; + if (sender instanceof Player) + for (PermissionAttachmentInfo permission : ((Player) sender).getEffectivePermissions()) { + if (permission.getPermission().equalsIgnoreCase(perm)) { + return permission; + } + } + return null; } public boolean isSetPermission(CommandSender sender, String perm) { - if (sender instanceof Player) - return isSetPermission((Player) sender, perm); - return true; + if (sender instanceof Player) + return isSetPermission((Player) sender, perm); + return true; } public boolean isSetPermission(Player player, String perm) { - return player.hasPermission(new Permission(perm, PermissionDefault.FALSE)); - + return player.hasPermission(new Permission(perm, PermissionDefault.FALSE)); } private static HashMap getAll(Player player, String pref) { - pref = pref.endsWith(".") ? pref : pref + "."; - HashMap mine = new HashMap(); - for (PermissionAttachmentInfo permission : player.getEffectivePermissions()) { - if (permission.getPermission().startsWith(pref)) - mine.put(permission.getPermission(), permission.getValue()); - } - return mine; + pref = pref.endsWith(".") ? pref : pref + "."; + HashMap mine = new HashMap(); + for (PermissionAttachmentInfo permission : player.getEffectivePermissions()) { + if (permission.getPermission().startsWith(pref)) + mine.put(permission.getPermission(), permission.getValue()); + } + return mine; } private HashMap> cache = new HashMap>(); public void removeFromCache(Player player) { - cache.remove(player.getUniqueId()); + cache.remove(player.getUniqueId()); } public PermissionInfo getFromCache(Player player, String perm) { - return null; + return null; } public PermissionInfo addToCache(Player player, String perm, boolean has, Long delayInMiliseconds) { - return null; + return null; } public PermissionInfo getPermissionInfo(Player player, String perm, Long delayInMiliseconds) { - return getPermissionInfo(player, perm, false, delayInMiliseconds); + return getPermissionInfo(player, perm, false, delayInMiliseconds); + } + + public PermissionInfo getPermissionInfo(Player player, CMIPerm perm, String... extra) { + String permString = perm.getPermission(extra); + return getPermissionInfo(player, permString, 1000L); } public PermissionInfo getPermissionInfo(Player player, CMIPerm perm) { - return getPermissionInfo(player, perm, 1000L); + return getPermissionInfo(player, perm, 1000L); } public PermissionInfo getPermissionInfo(Player player, CMIPerm perm, Long delayInMiliseconds) { - String permission = perm.getPermission(" "); - if (permission.endsWith(" ")) - permission = permission.replace(" ", ""); - if (permission.endsWith(".")) - permission = permission.substring(0, permission.length() - 1); - return getPermissionInfo(player, permission, false, delayInMiliseconds); + return null; } @Deprecated public PermissionInfo getPermissionInfo(Player player, String perm) { - return getPermissionInfo(player, perm, false, 1000L); + return getPermissionInfo(player, perm, false, 1000L); } public PermissionInfo getPermissionInfo(Player player, String perm, boolean force) { - return getPermissionInfo(player, perm, force, 1000L); + return getPermissionInfo(player, perm, force, 1000L); } public PermissionInfo getPermissionInfo(Player player, String perm, boolean force, Long delay) { - - return null; + + return null; } } diff --git a/src/com/Zrips/CMI/Modules/Permissions/PowerfullPermsHandler.java b/src/com/Zrips/CMI/Modules/Permissions/PowerfullPermsHandler.java new file mode 100644 index 0000000..17a2da4 --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Permissions/PowerfullPermsHandler.java @@ -0,0 +1,47 @@ +package com.Zrips.CMI.Modules.Permissions; + +import java.util.UUID; + +import org.bukkit.entity.Player; + +public class PowerfullPermsHandler implements PermissionInterface { + + public PowerfullPermsHandler() { + + } + + @Override + public String getMainGroup(Player player) { + return this.getMainGroup(player.getWorld().getName(), player.getUniqueId()); + } + + @Override + public String getPrefix(Player player) { + return this.getPrefix(player.getUniqueId()); + } + + @Override + public String getSufix(Player player) { + return this.getSufix(player.getUniqueId()); + } + + @Override + public String getMainGroup(String world, UUID uuid) { + return null; + } + + @Override + public String getPrefix(UUID uuid) { + return null; + } + + @Override + public String getSufix(UUID uuid) { + return null; + } + + @Override + public String getNameColor(Player player) { + return null; + } +} diff --git a/src/com/Zrips/CMI/Modules/Permissions/PowerfullPermsgustav9797Handler.java b/src/com/Zrips/CMI/Modules/Permissions/PowerfullPermsgustav9797Handler.java new file mode 100644 index 0000000..090f61d --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Permissions/PowerfullPermsgustav9797Handler.java @@ -0,0 +1,47 @@ +package com.Zrips.CMI.Modules.Permissions; + +import java.util.UUID; + +import org.bukkit.entity.Player; + +public class PowerfullPermsgustav9797Handler implements PermissionInterface { + + public PowerfullPermsgustav9797Handler() { + + } + + @Override + public String getMainGroup(Player player) { + return this.getMainGroup(player.getWorld().getName(), player.getUniqueId()); + } + + @Override + public String getPrefix(Player player) { + return this.getPrefix(player.getUniqueId()); + } + + @Override + public String getSufix(Player player) { + return this.getSufix(player.getUniqueId()); + } + + @Override + public String getMainGroup(String world, UUID uuid) { + return null; + } + + @Override + public String getPrefix(UUID uuid) { + return null; + } + + @Override + public String getSufix(UUID uuid) { + return null; + } + + @Override + public String getNameColor(Player player) { + return null; + } +} diff --git a/src/com/Zrips/CMI/Modules/Permissions/UltraPermissions3Handler.java b/src/com/Zrips/CMI/Modules/Permissions/UltraPermissions3Handler.java new file mode 100644 index 0000000..677403c --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Permissions/UltraPermissions3Handler.java @@ -0,0 +1,51 @@ +package com.Zrips.CMI.Modules.Permissions; + +import java.util.UUID; + +import org.bukkit.entity.Player; + +public class UltraPermissions3Handler implements PermissionInterface { + + public UltraPermissions3Handler() { + + } + + @Override + public String getMainGroup(Player player) { + return null; + } + + @Override + public String getMainGroup(String world, UUID uuid) { + return null; + } + + @Override + public String getPrefix(Player player) { + if (player == null) + return ""; + return getPrefix(player.getUniqueId()); + } + + @Override + public String getPrefix(UUID uuid) { + return null; + } + + @Override + public String getSufix(Player player) { + if (player == null) + return ""; + return getSufix(player.getUniqueId()); + } + + @Override + public String getSufix(UUID uuid) { + return null; + } + + @Override + public String getNameColor(Player player) { + return null; + } +} diff --git a/src/com/Zrips/CMI/Modules/Permissions/VaultHandler.java b/src/com/Zrips/CMI/Modules/Permissions/VaultHandler.java index ee6462a..051398d 100644 --- a/src/com/Zrips/CMI/Modules/Permissions/VaultHandler.java +++ b/src/com/Zrips/CMI/Modules/Permissions/VaultHandler.java @@ -3,69 +3,48 @@ import java.util.UUID; import org.bukkit.entity.Player; -import org.bukkit.plugin.RegisteredServiceProvider; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.CMIUser; - -import net.milkbowl.vault.permission.Permission; public class VaultHandler implements PermissionInterface { private CMI plugin; - private Permission perms; public VaultHandler(CMI plugin) { - this.plugin = plugin; - RegisteredServiceProvider rsp = this.plugin.getServer().getServicesManager().getRegistration(Permission.class); - perms = rsp.getProvider(); } @Override public String getMainGroup(Player player) { - try { - return perms.getPrimaryGroup(player); - } catch (Exception | Error e) { - } - return null; + return null; } @Override public String getPrefix(Player player) { - return null; + return null; } @Override public String getSufix(Player player) { - return null; + return null; } @Override public String getMainGroup(String world, UUID uuid) { - try { - CMIUser u = plugin.getPlayerManager().getUser(uuid); - if (!u.isOnline()) - return null; - Player player = u.getPlayer(); - if (player != null && world != null) - return perms.getPrimaryGroup(world, player); - } catch (Exception | Error e) { - } - return null; + return null; } @Override public String getPrefix(UUID uuid) { - return null; + return null; } @Override public String getSufix(UUID uuid) { - return null; + return null; } @Override public String getNameColor(Player player) { - return null; + return null; } } diff --git a/src/com/Zrips/CMI/Modules/Permissions/ZPermissionsHandler.java b/src/com/Zrips/CMI/Modules/Permissions/ZPermissionsHandler.java new file mode 100644 index 0000000..02f5b0b --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Permissions/ZPermissionsHandler.java @@ -0,0 +1,48 @@ +package com.Zrips.CMI.Modules.Permissions; + +import java.util.UUID; + +import org.bukkit.entity.Player; + +public class ZPermissionsHandler implements PermissionInterface { + + public ZPermissionsHandler() { + + } + + @Override + public String getMainGroup(Player player) { + return null; + } + + @Override + public String getPrefix(Player player) { + return null; + } + + @Override + public String getSufix(Player player) { + return null; + } + + @Override + public String getMainGroup(String world, UUID uuid) { + return null; + } + + @Override + public String getPrefix(UUID uuid) { + return null; + } + + @Override + public String getSufix(UUID uuid) { + return null; + } + + @Override + public String getNameColor(Player player) { + return null; + } + +} diff --git a/src/com/Zrips/CMI/Modules/Placeholders/MVdWPlaceholderAPIHook.java b/src/com/Zrips/CMI/Modules/Placeholders/MVdWPlaceholderAPIHook.java new file mode 100644 index 0000000..1119fdc --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Placeholders/MVdWPlaceholderAPIHook.java @@ -0,0 +1,13 @@ +package com.Zrips.CMI.Modules.Placeholders; + +import com.Zrips.CMI.CMI; + +public class MVdWPlaceholderAPIHook { + + public MVdWPlaceholderAPIHook(CMI plugin) { + } + + private static boolean isMetaPlaceHolder(String identifier) { + return identifier.startsWith("user_meta_"); + } +} diff --git a/src/com/Zrips/CMI/Modules/Placeholders/Placeholder.java b/src/com/Zrips/CMI/Modules/Placeholders/Placeholder.java index 3b30689..4f4bada 100644 --- a/src/com/Zrips/CMI/Modules/Placeholders/Placeholder.java +++ b/src/com/Zrips/CMI/Modules/Placeholders/Placeholder.java @@ -5,6 +5,7 @@ import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import java.util.Random; import java.util.UUID; import java.util.regex.Pattern; @@ -22,346 +23,403 @@ public class Placeholder { private CMI plugin; Pattern placeholderKeepPatern = Pattern.compile("(\\%\\%)([^\\\"^\\%^ ]+)(\\%\\%)(\\B)"); Pattern placeholderOthersKeepPatern = Pattern.compile("(?i)(\\%parseother_)((\\{)([^\\\"^\\%^ ^\\{^\\}]+)(\\}))([^(\\}\\%).]+)(\\}\\%)"); - Pattern placeholderPatern = Pattern.compile("(%)([^\"^%^ ]+)(%)"); + Pattern placeholderPatern = Pattern.compile("(%)([^% \"]+)(%)"); Pattern placeholderPatern2 = Pattern.compile("(\\{)([^\"^%^ ^{^}]+)(\\})"); private static ChatFilterRule numericalRule = new ChatFilterRule().setPattern("(\\$)(\\d)"); public Placeholder(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } Random random = new Random(System.nanoTime()); public enum CMIPlaceHolders { - cmi_user_charges_left("Remaining count of spawner charges"), - cmi_user_charges_max("Maximum allowed amount of spawner charges"), - cmi_user_charges_time("Time until next spawner charge"), - cmi_user_charges_cooldown("Spawner charge cooldown"), - cmi_user_display_name("Formatted players display name"), - cmi_user_cleannickname("Players nick name if set or players name otherwise. No color codes"), - cmi_user_nickname("Players nick name if set or players name otherwise"), - cmi_user_name("Original players name"), - cmi_user_uuid("Player uuid"), - cmi_user_deathloc("Players last death location"), - cmi_user_cuffed("Identification if player is cuffed"), - cmi_user_muted("Identification if player is muted"), - cmi_user_inpvp("Identification if player is in pvp mode"), - cmi_user_god("Identification if player has god mode enabled"), - cmi_user_mail_count("Amount of mails player have"), - cmi_user_warning_count("Amount of warnings player have"), - cmi_user_warning_points("Amount of warning points player have"), - cmi_user_afk("Afk state"), - cmi_user_afk_symbol("Afk symbool"), - cmi_user_afk_msg("Afk message if present"), - cmi_user_afk_for("Time for how long player is in afk mode"), - cmi_user_afk_in("Time when player enters auto afk mode"), - cmi_user_spy("Spy state"), - cmi_user_cmdspy("Command spy state"), - cmi_user_signspy("Sign spy state"), - cmi_user_joinedcounter("Indication if player is joined counter"), - cmi_user_banned("Indication if player is banned"), - cmi_user_maxhomes("Max amount of homes player can have"), - cmi_user_homeamount("Amount of homes player has"), - cmi_user_missingexp("Missing exp amount until next level"), - cmi_user_missingexpp("Missing exp in percentage until next level"), - cmi_user_exp("Current exp amount for current level"), - cmi_user_expp("Current exp in percentage for current level"), - cmi_user_totalexp("Total amount of exp player have"), - cmi_user_level("Players level"), - cmi_user_ping("Ping"), - cmi_user_gamemode("Game mode"), - cmi_user_op("OP state"), - cmi_user_pweather("Player weather"), - cmi_user_weather("Weather at players world"), - cmi_user_weatherduration("Weather duration at players world"), - cmi_user_canfly("Players ability to fly"), - cmi_user_flying("Is player currently flying"), - cmi_user_vanished_symbol("Vanish symbol"), - cmi_user_balance_formated(true), - cmi_user_balance_formatted("Formatted users balance"), - cmi_user_balance("Clean users balance"), - cmi_user_prefix("Players prefix set by permission plugin"), - cmi_user_suffix("Players suffix set by permission plugin"), - cmi_user_group("Players main permission group name"), - cmi_user_nameplate_prefix("Players nameplate prefix"), - cmi_user_nameplate_suffix("Players nameplate suffix"), - cmi_user_tfly("Left temp fly amount in seconds"), - cmi_user_tfly_formated(true), - cmi_user_tfly_formatted("Formatted temp fly amount"), - cmi_user_flightcharge("Flight charge amount"), - cmi_user_tgod("Time in seconds for temp god mode"), - cmi_user_tgod_formated(true), - cmi_user_tgod_formatted("Formatted time for temp god mode"), - cmi_user_votecount("Amount of votes"), - cmi_user_dailyvotecount("Daily vote count"), - cmi_user_rank(true), - cmi_user_rank_displayname("Current rank display name"), - cmi_user_rank_name("Current rank name"), - cmi_user_nextranks("List of next ranks"), - cmi_user_nextrankpercent("Percentage done for next rank"), - cmi_user_nextvalidranks("Rank list to which player can rank up to"), - cmi_user_canrankup("Returns true if player can rank up"), - cmi_user_country("Users country from geoip feature. Example: Germany"), - cmi_user_country_code("Users country code from geoip feature. Example: UK"), - cmi_user_city("Users city name from geoip feature"), - cmi_user_name_colorcode("Bukkit color code from nameplate command and -c: variable"), - cmi_user_glow_code("Bukkit color code from glow command."), - cmi_user_glow_name("Color name from glow command. Example: Red"), - cmi_user_jailed("True or false if player is jailed"), - cmi_user_jailname("Jail name user currently is in. Example: Prison"), - cmi_user_jailcell("Jail cell id user currently is in. Example: 1"), - cmi_user_jailtime("Left jail time. Example: 1hour 5minutes"), - cmi_user_jailreason("Jailed reason"), - cmi_user_bungeeserver("Bungee server name"), - cmi_user_playtime_formatted("Formatted playtime"), - cmi_user_playtime_days("Playtime in days"), - cmi_user_playtime_dayst("Playtime in days with fraction"), - cmi_user_playtime_hours("Playtime in hours"), - cmi_user_playtime_hoursf("Total playtime in hours"), - cmi_user_playtime_hourst("Total playtime in hours with fraction"), - cmi_user_playtime_minutes("Playtime in minutes"), - cmi_user_playtime_minutest("Total playtime in minutes"), - cmi_user_playtime_seconds("Playtime in minutes"), - cmi_user_playtime_secondst("Total playtime in minutes"), - cmi_user_world_formatted("Current players world name by using custom identification"), - cmi_user_online("Returns player online status"), - cmi_user_itemcount_$1("Number of items in players inventory by provided material", "itemIdName(:data)"), - cmi_user_maxperm_$1_$2("Maximum value by provided permission node, and if it doesn't exist, returns default value", "corePerm", "defaultValue"), - cmi_user_toggle_$1("Outputs 1 or 0 if defined feature is toggled on or off", "msg|pay|tp|compass|sospy|sispy|cospy|schest|autoflightrecharge|totem|shiftedit"), - cmi_user_togglename_$1("Outputs formatted True or False if defined feature is toggled on or off", "msg|pay|tp|compass|sospy|sispy|cospy|schest|autoflightrecharge|totem|shiftedit"), - cmi_equation_$1("Result of provided mathematical equation with fraction", "equation"), - cmi_equationint_$1("Result of provided mathematical equation without fraction", "equation"), - - cmi_color_$1("Colorizes text, replace spaces with _, underscore can be added by doubling it like __", "text"), - - cmi_iteminhand_displayname("Items in main hand display name or formatted material name"), - cmi_iteminhand_realname("Items in main hand formatted material name"), - cmi_iteminhand_type("Items in main hand material name"), - cmi_iteminhand_itemdata("Items in main hand data value. As of 1.13+ returns 0"), - cmi_iteminhand_amount("Amount of items in main hand"), - cmi_iteminhand_durability("Items in main hand left durability"), - cmi_iteminhand_worth("Returns total worth value of items in main hand"), - cmi_iteminhand_worth_one("Returns worth value of one item from main hand"), - cmi_iteminhand_worthc("Returns total worth value of items in main hand without formatting"), - cmi_iteminhand_worthc_one("Returns worth value of one item from main hand without formatting"), -// Complex placeholders cant have more than 3 - cmi_schedule_nextin_$1("Left time until next schedule trigger", "schedName"), - cmi_schedule_endat_$1("Left time until scheduler triggers last command", "schedName"), - cmi_baltop_name_$1("Name of player from a provided place in a list", "1-10"), - cmi_baltop_money_$1("Balance of player from a provided place in a list", "1-10"), - cmi_baltop_shortmoney_$1("Balance of player from a provided place in a list", "1-10"), - cmi_playtimetop_name_$1("Name of player from a provided place in a list", "1-10"), - cmi_playtimetop_time_$1("Playtime of player from a provided place in a list", "1-10"), - cmi_votetop_$1("Name of player from a provided place in a list", "1-10"), - cmi_votetopcount_$1("Vote count of player from a provided place in a list", "1-10"), - cmi_worth_buy_$1("Value of the item", "itemIdName(:data)"), - cmi_worth_sell_$1("Sell value of the item", "itemIdName(:data)"), - cmi_worthc_buy_$1("Value of the item without formatting", "itemIdName(:data)"), - cmi_worthc_sell_$1("Sell value of the item without formatting", "itemIdName(:data)"), - cmi_bungee_total_$1("Total allowed amount of players in defined server", "serverName"), - cmi_bungee_current_$1("Current amount of players in defined server", "serverName"), - cmi_bungee_motd_$1("Motd of defined server", "serverName"), - cmi_bungee_onlinestatus_$1("True/false of servers online status", "serverName"), - cmi_tps_1("Ttps from last 1 second"), - cmi_tps_60("Tps from last 60 seconds"), - cmi_tps_300("Tps from last 5 minutes"), - cmi_tps_$1_colored("Tps from defined range", "range"), - cmi_random_player_name("Returns random online player name"), -// cmi_random_player_name_$1("Returns random online player name while not repeating by provided amount of unique players", "1-10"), - cmi_lastrandom_player_name("Returns last random online player name"), - cmi_random_$1_$2("Random number from defined range", "from", "to"), - cmi_lastrandom_$1("Last random number assigned to player from random placeholder", "playerName"), - cmi_user_rank_percent_$1("Percentage of defined rank rankup progress", "rankName"), - cmi_user_meta_$1("Players metadate by defined key", "key"), - cmi_user_metaint_$1("Players metadate by defined key as number", "key"), - - cmi_chatmute_time("Provides left time for global chat mute"), - cmi_chatmute_reason("Provides reason for global chat mute"), - - cmi_user_stats_$1("Player statistics", "mainStat(:optionalSubStat)"), - - cmi_user_kitcd_$1("Cooldown of defined kit", "kitName"), - cmi_user_kit_available_$1("True/false if kit is available", "kitName"), - cmi_user_kit_hasaccess_$1("True/false if user can use this kit", "kitName"), - - cmi_jail_time_$1_$2("Time of a jail cell", "jailName", "cellId"), - cmi_jail_username_$1_$2("Name of user who is jailed in particular cell", "jailName", "cellId"), - cmi_jail_reason_$1_$2("Reason of particular jail cell", "jailName", "cellId"), - - cmi_weather_$1("World weather", "worldName"), - cmi_weatherduration_$1("World weather duration", "worldName"), - - cmi_afk_count("Number of afk players"), - - cmi_maintenance_state("Maintenance state"), - cmi_maintenance_message("Maintenance message"), - - player_world("Current players world name"), - player_x("Current players x position"), - player_y("Current players y position"), - player_z("Current players z position"), - player_biome("Current players biome name"), - vault_eco_balance_formatted("Formatted players balance. Deprecated"), - cmi_server_online("Online player count"), - cmi_server_uptime("How long server is running"), - cmi_server_uptime_seconds("How long server is running in seconds"), - cmi_server_worlds("List of all existing worlds on server in a list format"), - server_online("Online player amount"), - server_max_players("Max allowed players"), - cmi_server_online_$1("Online amount in particular world. Don't use _ in world name", "worldName"), - server_online_$1("Online amount in particular world. Don't use _ in world name", "worldName"), - server_unique_joins("Unique player joins to the server"), - onlineplayers_names("Formatted list of online players"), - onlineplayers_displaynames("Formatted list of online players by using their display names if possible"), - - server_time_$1_$2("Time of server by defined format and timezone", "timeFormat", "timeZone"), - server_time_$1("Local server time", "timeFormat"), - world_time12_$1("World time in 12 hour format", "worldName"), - world_time24_$1("World time in 24 hour format", "worldName"); - - static LinkedHashMap byNameStatic = new LinkedHashMap(); -// static HashMap>> byNameComplex = new HashMap>>(); - static LinkedHashMap> byNameComplex = new LinkedHashMap>(); - - static { - for (CMIPlaceHolders one : CMIPlaceHolders.values()) { - String fullName = one.toString(); - if (!one.isComplex()) { - byNameStatic.put(fullName.toLowerCase(), one); - continue; - } - String[] split = fullName.split("_"); - String first = split[0] + "_" + split[1]; - LinkedHashSet old = byNameComplex.getOrDefault(first, new LinkedHashSet()); - old.add(one); - byNameComplex.put(first, old); - } - } - - private String[] vars; - private List groups = new ArrayList(); - private ChatFilterRule rule = null; - private boolean hidden = false; - private String desc = null; - - CMIPlaceHolders() { - } - - CMIPlaceHolders(boolean hideen) { - this(null, hideen); - } - - CMIPlaceHolders(String desc, String... vars) { - this(desc, false, vars); - } - - CMIPlaceHolders(String desc, boolean hidden, String... vars) { - } - - public static CMIPlaceHolders getByName(String name) { - return null; - } - - public static CMIPlaceHolders getByNameExact(String name) { - return getByName(name); - } - - public String getFull() { - return null; - } - - public String getMVdW() { - return null; - } - - public List getComplexRegexMatchers(String text) { - - return null; - } - - public List getComplexValues(String text) { - - return null; - } - - public boolean isComplex() { - return rule != null; - } - - public ChatFilterRule getRule() { - return rule; - } - - public void setRule(ChatFilterRule rule) { - this.rule = rule; - } - - public boolean isHidden() { - return hidden; - } - - public String getDescription() { - return desc; - } + cmi_user_charges_left("Remaining count of spawner charges"), + cmi_user_charges_max("Maximum allowed amount of spawner charges"), + cmi_user_charges_time("Time until next spawner charge"), + cmi_user_charges_cooldown("Spawner charge cooldown"), + cmi_user_display_name("Formatted players display name"), + cmi_p_$1_display_name("Formatted target players display name", "playerName"), + cmi_user_cleannickname("Players nick name if set or players name otherwise. No color codes"), + cmi_user_nickname("Players nick name if set or players name otherwise"), + cmi_user_name("Original players name"), + cmi_user_uuid("Player uuid"), + cmi_user_deathloc("Players last death location"), + cmi_user_backloc("Players back location"), + cmi_user_cuffed("Identification if player is cuffed"), + cmi_user_muted("Identification if player is muted"), + cmi_user_inpvp("Identification if player is in pvp mode"), + cmi_user_god("Identification if player has god mode enabled"), + cmi_user_mail_count("Amount of mails player have"), + cmi_user_warning_count("Amount of warnings player have"), + cmi_user_warning_points("Amount of warning points player have"), + cmi_user_afk("Afk state"), + cmi_user_afk_symbol("Afk symbool"), + cmi_user_afk_msg("Afk message if present"), + cmi_user_afk_for("Time for how long player is in afk mode"), + cmi_user_afk_in("Time when player enters auto afk mode"), + cmi_user_spy("Spy state"), + cmi_user_cmdspy("Command spy state"), + cmi_user_signspy("Sign spy state"), + cmi_user_joinedcounter("Indication if player is joined counter"), + cmi_user_banned("Indication if player is banned"), + cmi_user_maxhomes("Max amount of homes player can have"), + cmi_user_homeamount("Amount of homes player has"), + cmi_user_missingexp("Missing exp amount until next level"), + cmi_user_missingexpp("Missing exp in percentage until next level"), + cmi_user_exp("Current exp amount for current level"), + cmi_user_expp("Current exp in percentage for current level"), + cmi_user_totalexp("Total amount of exp player have"), + cmi_user_level("Players level"), + cmi_user_ping("Ping"), + cmi_user_gamemode("Game mode"), + cmi_user_op("OP state"), + cmi_user_pweather("Player weather"), + cmi_user_weather("Weather at players world"), + cmi_user_weatherduration("Weather duration at players world"), + cmi_user_canfly("Players ability to fly"), + cmi_user_flying("Is player currently flying"), + cmi_user_vanished_symbol("Vanish symbol"), + cmi_user_balance_formated(true), + cmi_user_balance_formatted("Formatted users balance"), + cmi_user_balance("Clean users balance"), + cmi_user_prefix("Players prefix set by permission plugin"), + cmi_user_suffix("Players suffix set by permission plugin"), + cmi_user_group("Players main permission group name"), + cmi_user_nameplate_prefix("Players nameplate prefix"), + cmi_user_nameplate_suffix("Players nameplate suffix"), + cmi_user_tfly("Left temp fly amount in seconds"), + cmi_user_tfly_formated(true), + cmi_user_tfly_formatted("Formatted temp fly amount"), + cmi_user_flightcharge("Flight charge amount"), + cmi_user_tgod("Time in seconds for temp god mode"), + cmi_user_tgod_formated(true), + cmi_user_tgod_formatted("Formatted time for temp god mode"), + cmi_user_votecount("Amount of votes"), + cmi_user_dailyvotecount("Daily vote count"), + cmi_user_rank(true), + cmi_user_rank_displayname("Current rank display name"), + cmi_user_rank_name("Current rank name"), + cmi_user_nextranks("List of next ranks"), + cmi_user_nextrankpercent("Percentage done for next rank"), + cmi_user_nextvalidranks("Rank list to which player can rank up to"), + cmi_user_canrankup("Returns true if player can rank up"), + cmi_user_country("Users country from geoip feature. Example: Germany"), + cmi_user_country_code("Users country code from geoip feature. Example: UK"), + cmi_user_city("Users city name from geoip feature"), + cmi_user_name_colorcode("Bukkit color code from nameplate command and -c: variable"), + cmi_user_glow_code("Bukkit color code from glow command."), + cmi_user_glow_name("Color name from glow command. Example: Red"), + cmi_user_jailed("True or false if player is jailed"), + cmi_user_jailname("Jail name user currently is in. Example: Prison"), + cmi_user_jailcell("Jail cell id user currently is in. Example: 1"), + cmi_user_jailtime("Left jail time. Example: 1hour 5minutes"), + cmi_user_jailreason("Jailed reason"), + cmi_user_bungeeserver("Bungee server name"), + cmi_user_playtime_formatted("Formatted playtime"), + cmi_user_playtime_days("Playtime in days"), + cmi_user_playtime_dayst("Playtime in days with fraction"), + cmi_user_playtime_hours("Playtime in hours"), + cmi_user_playtime_hoursf("Total playtime in hours"), + cmi_user_playtime_hourst("Total playtime in hours with fraction"), + cmi_user_playtime_minutes("Playtime in minutes"), + cmi_user_playtime_minutest("Total playtime in minutes"), + cmi_user_playtime_seconds("Playtime in minutes"), + cmi_user_playtime_secondst("Total playtime in minutes"), + cmi_user_world_formatted("Current players world name by using custom identification"), + cmi_user_online("Returns player online status"), + cmi_user_itemcount_$1("Number of items in players inventory by provided material", "itemIdName(:data)"), + cmi_user_maxperm_$1_$2("Maximum value by provided permission node, and if it doesn't exist, returns default value", "corePerm", "defaultValue"), + cmi_user_toggle_$1("Outputs 1 or 0 if defined feature is toggled on or off", "msg|pay|tp|compass|sospy|sispy|cospy|schest|autoflightrecharge|totem|shiftedit|tagsound"), + cmi_user_togglename_$1("Outputs formatted True or False if defined feature is toggled on or off", "msg|pay|tp|compass|sospy|sispy|cospy|schest|autoflightrecharge|totem|shiftedit|tagsound"), + cmi_equation_$1("Result of provided mathematical equation with fraction", "equation"), + cmi_equationint_$1("Result of provided mathematical equation without fraction", "equation"), + + cmi_color_$1("Colorizes text, replace spaces with _, underscore can be added by doubling it like __", "text"), + + cmi_iteminhand_displayname("Items in main hand display name or formatted material name"), + cmi_iteminhand_realname("Items in main hand formatted material name"), + cmi_iteminhand_type("Items in main hand material name"), + cmi_iteminhand_itemdata("Items in main hand data value. As of 1.13+ returns 0"), + cmi_iteminhand_amount("Amount of items in main hand"), + cmi_iteminhand_durability("Items in main hand left durability"), + cmi_iteminhand_worth("Returns total worth value of items in main hand"), + cmi_iteminhand_worth_one("Returns worth value of one item from main hand"), + cmi_iteminhand_worthc("Returns total worth value of items in main hand without formatting"), + cmi_iteminhand_worthc_one("Returns worth value of one item from main hand without formatting"), + + cmi_schedule_nextin_$1("Left time until next schedule trigger", "schedName"), + cmi_schedule_endat_$1("Left time until scheduler triggers last command", "schedName"), + cmi_baltop_name_$1("Name of player from a provided place in a list", "1-10"), + cmi_baltop_money_$1("Balance of player from a provided place in a list", "1-10"), + cmi_baltop_shortmoney_$1("Balance of player from a provided place in a list", "1-10"), + cmi_playtimetop_name_$1("Name of player from a provided place in a list", "1-10"), + cmi_playtimetop_time_$1("Playtime of player from a provided place in a list", "1-10"), + cmi_votetop_$1("Name of player from a provided place in a list", "1-10"), + cmi_votetopcount_$1("Vote count of player from a provided place in a list", "1-10"), + cmi_worth_buy_$1("Value of the item", "itemIdName(:data)"), + cmi_worth_sell_$1("Sell value of the item", "itemIdName(:data)"), + cmi_worthc_buy_$1("Value of the item without formatting", "itemIdName(:data)"), + cmi_worthc_sell_$1("Sell value of the item without formatting", "itemIdName(:data)"), + cmi_bungee_total_$1("Total allowed amount of players in defined server", "serverName"), + cmi_bungee_current_$1("Current amount of players in defined server", "serverName"), + cmi_bungee_motd_$1("Motd of defined server", "serverName"), + cmi_bungee_onlinestatus_$1("True/false of servers online status", "serverName"), + cmi_tps_1("Ttps from last 1 second"), + cmi_tps_60("Tps from last 60 seconds"), + cmi_tps_300("Tps from last 5 minutes"), + cmi_tps_$1_colored("Tps from defined range", "range"), + cmi_random_player_name("Returns random online player name", false), + cmi_lastrandom_player_name("Returns last random online player name", false), + cmi_random_$1_$2("Random number from defined range", false, "from", "to"), + cmi_lastrandom_$1("Last random number assigned to player from random placeholder", false, "playerName"), + cmi_user_rank_percent_$1("Percentage of defined rank rankup progress", "rankName"), + cmi_user_meta_$1("Players metadate by defined key", "key"), + cmi_user_metaint_$1("Players metadate by defined key as number", "key"), + + cmi_chatmute_time("Provides left time for global chat mute"), + cmi_chatmute_reason("Provides reason for global chat mute"), + + cmi_user_baltop("Player position in baltop"), + + cmi_user_stats_$1("Player statistics", "mainStat(:optionalSubStat)"), + + cmi_user_kitcd_$1("Cooldown of defined kit", "kitName"), + cmi_user_kit_available("Amount of kits you can claim"), + cmi_user_kit_available_$1("True/false if kit is available", "kitName"), + cmi_user_kit_hasaccess_$1("True/false if user can use this kit", "kitName"), + + cmi_jail_time_$1_$2("Time of a jail cell", "jailName", "cellId"), + cmi_jail_username_$1_$2("Name of user who is jailed in particular cell", "jailName", "cellId"), + cmi_jail_reason_$1_$2("Reason of particular jail cell", "jailName", "cellId"), + + cmi_weather_$1("World weather", "worldName"), + cmi_weatherduration_$1("World weather duration", "worldName"), + + cmi_afk_count("Number of afk players"), + + cmi_maintenance_state("Maintenance state"), + cmi_maintenance_message("Maintenance message"), + + cmi_chat_range("Range for chat messages"), + + cmi_server_uptime("How long server is running"), + cmi_server_uptime_seconds("How long server is running in seconds"), + cmi_server_worlds("List of all existing worlds on server in a list format"), + cmi_server_vanished("Online vanished player count"), + cmi_server_users("Recorder user count"), + + player_world("Current players world name", true), + cmi_player_world("Current players world name"), + player_x("Current players x position", true), + cmi_player_x("Current players x position"), + player_y("Current players y position", true), + cmi_player_y("Current players y position"), + player_z("Current players z position", true), + cmi_player_z("Current players z position"), + player_biome("Current players biome name", true), + cmi_player_biome("Current players biome name"), + vault_eco_balance_formatted("Formatted players balance. Deprecated", true), + + server_online("Online player amount", true), + cmi_server_online("Online player count"), + server_max_players("Max allowed players", true), + cmi_server_max_players("Max allowed players"), + server_online_$1("Online amount in particular world. Don't use _ in world name", true, true, "worldName"), + cmi_server_online_$1("Online amount in particular world. Don't use _ in world name", "worldName"), + server_unique_joins("Unique player joins to the server", true), + cmi_server_unique_joins("Unique player joins to the server"), + onlineplayers_names("Formatted list of online players", true), + cmi_onlineplayers_names("Formatted list of online players"), + onlineplayers_displaynames("Formatted list of online players by using their display names if possible", true), + cmi_onlineplayers_displaynames("Formatted list of online players by using their display names if possible"), + + server_time_$1_$2("Time of server by defined format and timezone", true, true, "timeFormat", "timeZone"), + cmi_server_time_$1_$2("Time of server by defined format and timezone", "timeFormat", "timeZone"), + server_time_$1("Local server time", true, true, "timeFormat"), + cmi_server_time_$1("Local server time", "timeFormat"), + world_time12_$1("World time in 12 hour format", true, true, "worldName"), + cmi_world_time12_$1("World time in 12 hour format", "worldName"), + world_time24_$1("World time in 24 hour format", true, true, "worldName"), + cmi_world_time24_$1("World time in 24 hour format", "worldName"); + + static LinkedHashMap byNameStatic = new LinkedHashMap(); + static LinkedHashMap> byNameComplex = new LinkedHashMap>(); + + private static int count = 0; + + private int MAX_ENTRIES = 20; + LinkedHashMap map = new LinkedHashMap(MAX_ENTRIES + 1, .75F, false) { + @Override + protected boolean removeEldestEntry(Map.Entry eldest) { + return size() > MAX_ENTRIES; + } + }; + + private String[] vars; + private List groups = new ArrayList(); + private ChatFilterRule rule = null; + private boolean hidden = false; + private boolean cache = true; + private String desc = null; + + CMIPlaceHolders() { + } + + CMIPlaceHolders(String desc, boolean cache, String... vars) { + this(desc, false, cache, vars); + } + + CMIPlaceHolders(boolean hideen) { + this(null, hideen, true); + } + + CMIPlaceHolders(String desc, String... vars) { + this(desc, false, true, vars); + } + + CMIPlaceHolders(String desc, boolean hidden, boolean cache, String... vars) { + + } + + public static int getCount() { + return count; + } + + public Object getCachedValue(UUID uuid) { + if (!this.isCache() || this.isComplex() || uuid == null) + return null; + PlaceholderCache cache = map.get(uuid); + if (cache == null || System.currentTimeMillis() > cache.getValidUntil()) + return null; + return cache.getValue(); + } + + public void addCachedValue(UUID uuid, String value, int validForMiliSeconds) { + PlaceholderCache cache = map.get(uuid); + if (cache == null) { + cache = new PlaceholderCache(); + } + cache.setValue(value); + cache.setValidUntil(System.currentTimeMillis() + validForMiliSeconds); + map.put(uuid, cache); + } + + public static CMIPlaceHolders getByName(String name) { + + return null; + } + + public static CMIPlaceHolders getByNameExact(String name) { + return getByName(name); + } + + public String getFull() { + return null; + } + + public String getMVdW() { + return null; + } + + public List getComplexRegexMatchers(String text) { + return null; + } + + public List getComplexValues(String text) { + return null; + } + + public boolean isComplex() { + return rule != null; + } + + public ChatFilterRule getRule() { + return rule; + } + + public void setRule(ChatFilterRule rule) { + this.rule = rule; + } + + public boolean isHidden() { + return hidden; + } + + public String getDescription() { + return desc; + } + + public boolean isCache() { + return cache; + } } public List updatePlaceHolders(Player player, List messages) { - return null; + return null; } public enum CMIPlaceholderType { - CMI, PAPI, MVdW; + CMI, PAPI, MVdW; } public CMIPlaceholderType getPlaceHolderType(Player player, String placeholder) { - - return null; + return null; } public String updatePlaceHolders(UUID uuid, String message) { - - return null; + return null; } public String updatePlaceHolders(String message) { - UUID uuid = null; - return updatePlaceHolders(uuid, message); + UUID uuid = null; + return updatePlaceHolders(uuid, message); } public String updatePlaceHolders(Player player, String message) { - return null; + return null; } public boolean hasMetaValue(CMIUser user, String key) { - return user.getMeta().getMap().containsKey(key.toLowerCase()); + return user.getMeta().getMap().containsKey(key.toLowerCase()); } public boolean containsPlaceHolder(String msg) { - return false; + return false; + } + + public String replacePlaceHolders(String msg, String with) { + + return null; } public String coolDownPlaceHolders(String msg, Player player) { - - return null; + + return null; + } + + public String coolDownPlaceHolders(String msg) { + + return null; } public String translateOwnPlaceHolder(Player player, String message) { - return translateOwnPlaceHolder(player == null ? null : player.getUniqueId(), message); + return translateOwnPlaceHolder(player == null ? null : player.getUniqueId(), message); } private int maxDepth = 4; private String matchInception(UUID uuid, String message, int depth) { - return null; + return null; } public String translateOwnPlaceHolder(UUID uuid, String message) { - - return null; + + return null; } private HashMap randomCache = new HashMap(); @@ -371,21 +429,23 @@ public String translateOwnPlaceHolder(UUID uuid, String message) { private HashMap randomPlayers = new HashMap(); public String getValue(Player player, CMIPlaceHolders placeHolder) { - return getValue(player, placeHolder, null); + return getValue(player, placeHolder, null); } public String getValue(Player player, CMIPlaceHolders placeHolder, String value) { - return getValue(player != null ? player.getUniqueId() : null, placeHolder, value); + return getValue(player != null ? player.getUniqueId() : null, placeHolder, value); } public String getValue(UUID uuid, CMIPlaceHolders placeHolder, String value) { - return null; + + return null; } private void informFailed(String value) { + plugin.consoleMessage("&cInccorrect placeholder format for " + value); } private String variable(Boolean state) { - return null; + return state ? plugin.getMsg(LC.info_variables_True) : plugin.getMsg(LC.info_variables_False); } } diff --git a/src/com/Zrips/CMI/Modules/Placeholders/PlaceholderCache.java b/src/com/Zrips/CMI/Modules/Placeholders/PlaceholderCache.java new file mode 100644 index 0000000..e1599cc --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Placeholders/PlaceholderCache.java @@ -0,0 +1,22 @@ +package com.Zrips.CMI.Modules.Placeholders; + +public class PlaceholderCache { + private Long validUntil; + private String value; + + public Long getValidUntil() { + return validUntil; + } + + public void setValidUntil(Long validUntil) { + this.validUntil = validUntil; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/src/com/Zrips/CMI/Modules/PlayTime/CMIPlayDay.java b/src/com/Zrips/CMI/Modules/PlayTime/CMIPlayDay.java index 4e36dcb..380be97 100644 --- a/src/com/Zrips/CMI/Modules/PlayTime/CMIPlayDay.java +++ b/src/com/Zrips/CMI/Modules/PlayTime/CMIPlayDay.java @@ -13,55 +13,62 @@ public class CMIPlayDay { private Integer id = 0; public CMIPlayDay(CMIUser user, int date) { - this.user = user; - this.date = date; + this.user = user; + this.date = date; } public Long getLastUpdate() { - return lastUpdate; + return lastUpdate; } public Long getTotalTime() { - Long total = 0L; - for (int i = 0; i < 24; i++) { - total += getHourPlaytime(i); - } - return total; + Long total = 0L; + for (int i = 0; i < 24; i++) { + total += getHourPlaytime(i); + } + return total; } public void setLastUpdate(Long lastUpdate) { - this.lastUpdate = lastUpdate; + this.lastUpdate = lastUpdate; } private final static Long maxValue = 3600000L; public void updatePlayTime() { + } public void checkPreviousHour(int hour) { + } public Long getCurrentHourPlaytime() { - return getHourPlaytime(PlaytimeRange.thishour.getStartTime()); + return getHourPlaytime(PlaytimeRange.thishour.getStartTime()); } public Long getHourPlaytime(int hour) { - return null; + Long current = map[hour]; + return current == null ? 0L : current; } public void setHourPlaytime(int hour, Long playTime, boolean overTime) { + if (!overTime) + playTime = playTime > maxValue ? maxValue : playTime; + playTime = playTime <= 0 ? null : playTime; + map[hour] = playTime; } public int getDate() { - return date; + return date; } public Integer getId() { - return id; + return id; } public void setId(Integer id) { - this.id = id; + this.id = id; } } diff --git a/src/com/Zrips/CMI/Modules/PlayTime/CMIPlayTime.java b/src/com/Zrips/CMI/Modules/PlayTime/CMIPlayTime.java index 4160169..267dcbc 100644 --- a/src/com/Zrips/CMI/Modules/PlayTime/CMIPlayTime.java +++ b/src/com/Zrips/CMI/Modules/PlayTime/CMIPlayTime.java @@ -6,7 +6,6 @@ import java.util.Set; import java.util.TreeMap; -import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIUser; import com.Zrips.CMI.Modules.PlayTime.PlayTimeManager.PlaytimeRange; @@ -22,50 +21,54 @@ public class CMIPlayTime { Integer dayBack = null; public CMIPlayTime(CMIUser user) { - this.user = user; + this.user = user; } public TreeMap getDays() { - return map; + return map; } public CMIPlayDay getPlayDay(Integer date) { - return null; + CMIPlayDay playDay = map.get(date); + if (playDay == null) { + playDay = new CMIPlayDay(user, date); + map.put(date, playDay); + } + return playDay; } public CMIPlayDay getPlayDayOfToday() { - return null; + return null; } private void checkYestarday() { } public void addDayForSave(CMIPlayDay playDay) { - forSave.add(playDay); + forSave.add(playDay); } public void updatePlayTime() { - updatePlayTime(true); + updatePlayTime(true); } public void updatePlayTime(boolean checkForOnline) { - } public Long getPlayTime(PlaytimeRange range) { - return null; + return 0L; } public Long getTotalPlayTime() { - Long total = 0L; - for (Entry one : map.entrySet()) { - total += one.getValue().getTotalTime(); - } - return total; + Long total = 0L; + for (Entry one : map.entrySet()) { + total += one.getValue().getTotalTime(); + } + return total; } public Set getForSave() { - return forSave; + return forSave; } } diff --git a/src/com/Zrips/CMI/Modules/PlayTime/CMIPlayTimeFormat.java b/src/com/Zrips/CMI/Modules/PlayTime/CMIPlayTimeFormat.java new file mode 100644 index 0000000..33ba114 --- /dev/null +++ b/src/com/Zrips/CMI/Modules/PlayTime/CMIPlayTimeFormat.java @@ -0,0 +1,27 @@ +package com.Zrips.CMI.Modules.PlayTime; + +public class CMIPlayTimeFormat { + enum showType { + full, partial, normal; + } + + static showType forceShowDays = showType.normal; + static showType forceShowHours = showType.normal; + static showType forceShowMinutes = showType.normal; + static showType forceShowSeconds = showType.normal; + + static String daysFormat = ""; + static String hoursFormat = ""; + static String minutesFormat = ""; + static String secondsFormat = ""; + + public static void update() { + + } + + public static String formatPlaytimePlaceholder(long ticks) { + + return null; + } + +} diff --git a/src/com/Zrips/CMI/Modules/PlayTime/PlayTimeListener.java b/src/com/Zrips/CMI/Modules/PlayTime/PlayTimeListener.java index 5c70ea7..b0a9498 100644 --- a/src/com/Zrips/CMI/Modules/PlayTime/PlayTimeListener.java +++ b/src/com/Zrips/CMI/Modules/PlayTime/PlayTimeListener.java @@ -1,6 +1,5 @@ package com.Zrips.CMI.Modules.PlayTime; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -8,13 +7,21 @@ import org.bukkit.event.player.PlayerQuitEvent; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.CMIUser; public class PlayTimeListener implements Listener { private CMI plugin; public PlayTimeListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMoveExtendedRnage(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMoveExtendedRnage(PlayerJoinEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/PlayTime/PlayTimeManager.java b/src/com/Zrips/CMI/Modules/PlayTime/PlayTimeManager.java index 9b1a4ad..e008441 100644 --- a/src/com/Zrips/CMI/Modules/PlayTime/PlayTimeManager.java +++ b/src/com/Zrips/CMI/Modules/PlayTime/PlayTimeManager.java @@ -6,98 +6,95 @@ import java.util.HashMap; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.CMIUser; + import net.Zrips.CMILib.Items.CMIMaterial; -import com.Zrips.CMI.Modules.ModuleHandling.CMIModule; public class PlayTimeManager { public static enum PlaytimeRange { - thishour(10, false, CMIMaterial.LIME_WOOL), - hourback(19, false, CMIMaterial.GREEN_WOOL), - today(11, true, CMIMaterial.LIGHT_GRAY_WOOL), - yesterday(20, true, CMIMaterial.GRAY_WOOL), - thisweek(13, true, CMIMaterial.YELLOW_WOOL), - week(22, true, CMIMaterial.BROWN_WOOL), - thismonth(15, true, CMIMaterial.PINK_WOOL), - month(24, true, CMIMaterial.RED_WOOL), - thisyear(16, false, CMIMaterial.LIGHT_BLUE_WOOL), - year(25, false, CMIMaterial.BLUE_WOOL), - total(40, false, CMIMaterial.WHITE_WOOL); - private Integer StartTime; - - private HashMap cache = new HashMap(); - private HashMap cacheLastUpdate = new HashMap(); - - private int slot; - - private boolean detailed; - - private CMIMaterial color; - - PlaytimeRange(int slot, boolean detailed, CMIMaterial color) { - this.slot = slot; - this.detailed = detailed; - this.color = color; - } - - public void update() { - - } - - public Integer getStartTime() { - if (StartTime == null) - update(); - return StartTime; - } - - public Long getCache(UUID uuid) { - return cache.get(uuid); - } - - public void setCache(UUID uuid, Long cache) { - this.cache.put(uuid, cache); - } - - public Integer getCacheLastUpdate(UUID uuid) { - return cacheLastUpdate.get(uuid); - } - - public void setCacheLastUpdate(UUID uuid, Integer cacheLastUpdate) { - this.cacheLastUpdate.put(uuid, cacheLastUpdate); - } - - public static PlaytimeRange getByName(String name) { - for (PlaytimeRange one : PlaytimeRange.values()) { - if (one.name().equalsIgnoreCase(name)) - return one; - } - return null; - } - - public int getSlot() { - return slot; - } - - public void setSlot(int slot) { - this.slot = slot; - } - - public boolean isDetailed() { - return detailed; - } - - public CMIMaterial getColor() { - return color; - } - - public void setColor(CMIMaterial color) { - this.color = color; - } + thishour(10, false, CMIMaterial.LIME_WOOL), + hourback(19, false, CMIMaterial.GREEN_WOOL), + today(11, true, CMIMaterial.LIGHT_GRAY_WOOL), + yesterday(20, true, CMIMaterial.GRAY_WOOL), + thisweek(13, true, CMIMaterial.YELLOW_WOOL), + week(22, true, CMIMaterial.BROWN_WOOL), + thismonth(15, true, CMIMaterial.PINK_WOOL), + month(24, true, CMIMaterial.RED_WOOL), + thisyear(16, false, CMIMaterial.LIGHT_BLUE_WOOL), + year(25, false, CMIMaterial.BLUE_WOOL), + total(40, false, CMIMaterial.WHITE_WOOL); + + private Integer StartTime; + + private HashMap cache = new HashMap(); + private HashMap cacheLastUpdate = new HashMap(); + + private int slot; + + private boolean detailed; + + private CMIMaterial color; + + PlaytimeRange(int slot, boolean detailed, CMIMaterial color) { + this.slot = slot; + this.detailed = detailed; + this.color = color; + } + + public void update() { + + } + + public Integer getStartTime() { + if (StartTime == null) + update(); + return StartTime; + } + + public Long getCache(UUID uuid) { + return cache.get(uuid); + } + + public void setCache(UUID uuid, Long cache) { + this.cache.put(uuid, cache); + } + + public Integer getCacheLastUpdate(UUID uuid) { + return cacheLastUpdate.get(uuid); + } + + public void setCacheLastUpdate(UUID uuid, Integer cacheLastUpdate) { + this.cacheLastUpdate.put(uuid, cacheLastUpdate); + } + + public static PlaytimeRange getByName(String name) { + for (PlaytimeRange one : PlaytimeRange.values()) { + if (one.name().equalsIgnoreCase(name)) + return one; + } + return null; + } + + public int getSlot() { + return slot; + } + + public void setSlot(int slot) { + this.slot = slot; + } + + public boolean isDetailed() { + return detailed; + } + + public CMIMaterial getColor() { + return color; + } + + public void setColor(CMIMaterial color) { + this.color = color; + } } private int autoTimerBukkitId = 0; @@ -107,71 +104,66 @@ public void setColor(CMIMaterial color) { public static final Long checkIntervalMs = 1000 * 60L; public PlayTimeManager(CMI plugin) { - this.plugin = plugin; - if (CMIModule.cmiPlaytime.isEnabled()) - autoTimerBukkitId = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, autoTimer, 0L, checkIntervalMs / 50L); + } public void stop() { - if (autoTimerBukkitId != 0) { - Bukkit.getScheduler().cancelTask(autoTimerBukkitId); - autoTimerBukkitId = 0; - } } SimpleDateFormat formatter = new SimpleDateFormat("yyMMdd"); Calendar calendar = Calendar.getInstance(); private Integer getTodaysDate() { - return null; + return null; } private Integer getYeastardayDate() { - return null; + return null; } Integer getWeekStartDate() { - return null; + return null; } Integer getMonthStartDate() { - return null; + return null; } private static int currentHour() { - Date date = new Date(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - return calendar.get(Calendar.HOUR_OF_DAY); + Date date = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + return calendar.get(Calendar.HOUR_OF_DAY); } static Integer hourBack(int back) { - return null; + return null; } Integer getYearStartDate() { - return null; + return null; } public Integer getDaysBackDate(int i) { - return null; + return null; } private Runnable autoTimer = new Runnable() { - @Override - public void run() { - try { - updatePlayTimes(); - } catch (Exception e) { - e.printStackTrace(); - } - } + @Override + public void run() { + try { + updatePlayTimes(); + } catch (Exception e) { + e.printStackTrace(); + } + } }; public void updatePlayTimes() { } public String formatDate(int date) { - return null; + return null; } + } diff --git a/src/com/Zrips/CMI/Modules/PlayTimeRewards/PlayTimeReward.java b/src/com/Zrips/CMI/Modules/PlayTimeRewards/PlayTimeReward.java index 2ea6784..76b0460 100644 --- a/src/com/Zrips/CMI/Modules/PlayTimeRewards/PlayTimeReward.java +++ b/src/com/Zrips/CMI/Modules/PlayTimeRewards/PlayTimeReward.java @@ -54,10 +54,6 @@ public void setCommands(List commands) { } public void performCommands(Player player){ - Snd snd = new Snd(); - snd.setTarget(player); - List cmds = CMI.getInstance().getLM().updateSnd(snd, new ArrayList(getCommands())); - CMI.getInstance().getSpecializedCommandManager().processCmds(cmds, player); } public boolean isAutoClaim() { diff --git a/src/com/Zrips/CMI/Modules/PlayTimeRewards/PlayTimeRewardsListener.java b/src/com/Zrips/CMI/Modules/PlayTimeRewards/PlayTimeRewardsListener.java index ca13b02..ddf1e46 100644 --- a/src/com/Zrips/CMI/Modules/PlayTimeRewards/PlayTimeRewardsListener.java +++ b/src/com/Zrips/CMI/Modules/PlayTimeRewards/PlayTimeRewardsListener.java @@ -8,7 +8,7 @@ public class PlayTimeRewardsListener implements Listener { private CMI plugin; public PlayTimeRewardsListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } } diff --git a/src/com/Zrips/CMI/Modules/PlayTimeRewards/PlayTimeRewardsManager.java b/src/com/Zrips/CMI/Modules/PlayTimeRewards/PlayTimeRewardsManager.java index bbee995..1da0644 100644 --- a/src/com/Zrips/CMI/Modules/PlayTimeRewards/PlayTimeRewardsManager.java +++ b/src/com/Zrips/CMI/Modules/PlayTimeRewards/PlayTimeRewardsManager.java @@ -1,23 +1,14 @@ package com.Zrips.CMI.Modules.PlayTimeRewards; -import java.io.File; -import java.io.IOException; import java.util.HashMap; -import java.util.List; -import java.util.Map.Entry; -import java.util.Set; import java.util.TreeMap; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIUser; -import net.Zrips.CMILib.FileHandler.ConfigReader; -import net.Zrips.CMILib.Logs.CMIDebug; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; public class PlayTimeRewardsManager { @@ -28,12 +19,12 @@ public class PlayTimeRewardsManager { private TreeMap oneTimeRewardsByName = new TreeMap(); public PlayTimeRewardsManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } private int sched = -1; - private int interval = 60; + private int interval = 1; private int OneTimeAmount = 1; private Long RewardInform = 1000L; private boolean Enabled = false; @@ -41,10 +32,10 @@ public PlayTimeRewardsManager(CMI plugin) { public static boolean RequiresPermission = false; public void stop() { - if (sched == -1) - return; - Bukkit.getScheduler().cancelTask(sched); - sched = -1; + if (sched == -1) + return; + Bukkit.getScheduler().cancelTask(sched); + sched = -1; } public void loadConfig() { @@ -54,15 +45,19 @@ public void loadConfig() { private HashMap lastAction = new HashMap(); public void removeFromAfkAction(CMIUser user) { - lastAction.remove(user); + lastAction.remove(user); } public void updateAfkAction(CMIUser user) { - lastAction.put(user, System.currentTimeMillis()); + lastAction.put(user, System.currentTimeMillis()); } public Long getAfkAction(CMIUser user) { - return lastAction.get(user); + return lastAction.get(user); + } + + private void tasker() { + } HashMap informMap = new HashMap(); @@ -75,38 +70,38 @@ public void load() { } public HashMap getRepeatableRewards() { - return repeatableRewards; + return repeatableRewards; } public void setRepeatableRewards(HashMap repeatableRewards) { - this.repeatableRewards = repeatableRewards; + this.repeatableRewards = repeatableRewards; } public TreeMap getOneTimeRewards() { - return oneTimeRewards; + return oneTimeRewards; } public void setOneTimeRewards(TreeMap oneTimeRewards) { - this.oneTimeRewards = oneTimeRewards; + this.oneTimeRewards = oneTimeRewards; } public PTROneTime getOneTimeRewardByName(String name) { - return oneTimeRewardsByName.get(name.toLowerCase()); + return oneTimeRewardsByName.get(name.toLowerCase()); } public PTRRepeat getRepeatingRewardByName(String name) { - return repeatableRewards.get(name.toLowerCase()); + return repeatableRewards.get(name.toLowerCase()); } public int getOneTimeAmount() { - return OneTimeAmount; + return OneTimeAmount; } public void setOneTimeAmount(int oneTimeAmount) { - OneTimeAmount = oneTimeAmount; + OneTimeAmount = oneTimeAmount; } public boolean isExcludeAfk() { - return ExcludeAfk; + return ExcludeAfk; } } diff --git a/src/com/Zrips/CMI/Modules/PlayerCombat/CMIPlayerCombat.java b/src/com/Zrips/CMI/Modules/PlayerCombat/CMIPlayerCombat.java index 02047ca..c012072 100644 --- a/src/com/Zrips/CMI/Modules/PlayerCombat/CMIPlayerCombat.java +++ b/src/com/Zrips/CMI/Modules/PlayerCombat/CMIPlayerCombat.java @@ -13,55 +13,51 @@ public class CMIPlayerCombat { private long didLastDamageToEntity = 0L; public Long getGotLastDamageAt() { - return gotLastDamageAt; + return gotLastDamageAt; } public void setGotLastDamageAt(Long gotLastDamageAt) { - this.gotLastDamageAt = gotLastDamageAt; + this.gotLastDamageAt = gotLastDamageAt; } public boolean isInCombatWithPlayer() { - return false; + + return false; } public long getGotLastDamageFromPlayer() { - return gotLastDamageFromPlayer; + return gotLastDamageFromPlayer; } public void setGotLastDamageFromPlayer(Long gotLastDamageFromPlayer) { - this.gotLastDamageFromPlayer = gotLastDamageFromPlayer; + this.gotLastDamageFromPlayer = gotLastDamageFromPlayer; } public void setDidLastDamageToPlayer(Long didLastDamageToPlayer) { - this.didLastDamageToPlayer = didLastDamageToPlayer; + this.didLastDamageToPlayer = didLastDamageToPlayer; } public boolean isInCombat() { - return isInCombatWithMob() || isInCombatWithPlayer(); + return isInCombatWithMob() || isInCombatWithPlayer(); } public boolean isInCombatWithMob() { - return false; + return false; } public long getGotLastDamageFromMob() { - return gotLastDamageFromEntity; + return gotLastDamageFromEntity; } public void setGotLastDamageFromMob(Long gotLastDamageFromEntity) { - this.gotLastDamageFromEntity = gotLastDamageFromEntity; + this.gotLastDamageFromEntity = gotLastDamageFromEntity; } public void setDidLastDamageToMob(Long didLastDamageToEntity) { - this.didLastDamageToEntity = didLastDamageToEntity; + this.didLastDamageToEntity = didLastDamageToEntity; } public long getLeftCombatTime() { - if (CMI.getInstance().getPlayerCombatManager().getCombatTimer() <= 0) - return 0; - long m = Math.max(Math.max(gotLastDamageFromPlayer, didLastDamageToPlayer), Math.max(gotLastDamageFromEntity, didLastDamageToEntity)); - if (m == 0 || m + (CMI.getInstance().getPlayerCombatManager().getCombatTimer() * 1000L) < System.currentTimeMillis()) - return 0; - return m + (CMI.getInstance().getPlayerCombatManager().getCombatTimer() * 1000L) - System.currentTimeMillis(); + return 0L; } } diff --git a/src/com/Zrips/CMI/Modules/PlayerCombat/EntityHeadDrop.java b/src/com/Zrips/CMI/Modules/PlayerCombat/EntityHeadDrop.java index 1a2ea34..a977ad9 100644 --- a/src/com/Zrips/CMI/Modules/PlayerCombat/EntityHeadDrop.java +++ b/src/com/Zrips/CMI/Modules/PlayerCombat/EntityHeadDrop.java @@ -1,28 +1,15 @@ package com.Zrips.CMI.Modules.PlayerCombat; -import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map.Entry; -import java.util.Random; import java.util.Set; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Colors.CMIChatColor; -import net.Zrips.CMILib.Entities.CMIEntitySubType; import net.Zrips.CMILib.Entities.CMIEntityType; -import net.Zrips.CMILib.Entities.MobHeadInfo; - -import com.Zrips.CMI.Containers.CMIUser; -import com.Zrips.CMI.Containers.Snd; -import net.Zrips.CMILib.Items.CMIItemStack; -import net.Zrips.CMILib.Logs.CMIDebug; public class EntityHeadDrop { private CMIEntityType type; @@ -32,56 +19,56 @@ public class EntityHeadDrop { private Set ls = new HashSet(); public EntityHeadDrop(CMIEntityType type) { - this.type = type; + this.type = type; } public HashMap getHeads() { - return heads; + return heads; } public void setHeads(HashMap heads) { - this.heads = heads; - ls.clear(); - for (Entry one : heads.entrySet()) { - ls.add(one.getKey()); - } + this.heads = heads; + ls.clear(); + for (Entry one : heads.entrySet()) { + ls.add(one.getKey()); + } } public void addHead(String texture, Double chance) { - this.heads.put(texture, chance); - ls.add(texture); + this.heads.put(texture, chance); + ls.add(texture); } public ItemStack getHead() { - return null; + return null; } public ItemStack getHead(Entity ent) { - return getHead(null, ent); + return getHead(null, ent); } public ItemStack getHead(Player player, Entity ent) { - return null; + return null; } public double getBaseDropChance() { - return baseDropChance; + return baseDropChance; } public void setBaseDropChance(double baseDropChance) { - this.baseDropChance = baseDropChance; + this.baseDropChance = baseDropChance; } public double getBaseLowerAmount() { - return baseLowerAmount; + return baseLowerAmount; } public void setBaseLowerAmount(double baseLowerAmount) { - this.baseLowerAmount = baseLowerAmount; + this.baseLowerAmount = baseLowerAmount; } public CMIEntityType getType() { - return type; + return type; } } diff --git a/src/com/Zrips/CMI/Modules/PlayerCombat/HeadDropListener.java b/src/com/Zrips/CMI/Modules/PlayerCombat/HeadDropListener.java index 0cae88c..9cd6f44 100644 --- a/src/com/Zrips/CMI/Modules/PlayerCombat/HeadDropListener.java +++ b/src/com/Zrips/CMI/Modules/PlayerCombat/HeadDropListener.java @@ -1,40 +1,43 @@ package com.Zrips.CMI.Modules.PlayerCombat; -import java.util.Random; -import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.bukkit.block.Block; -import org.bukkit.block.Skull; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.NBT.CMINBT; -import com.Zrips.CMI.Containers.CMIUser; -import com.Zrips.CMI.Modules.Totems.ResurectionListener; - -import net.Zrips.CMILib.CMILib; -import net.Zrips.CMILib.Entities.CMIEntityType; -import net.Zrips.CMILib.Entities.MobHeadInfo; -import net.Zrips.CMILib.Items.CMIMaterial; public class HeadDropListener implements Listener { private CMI plugin; public HeadDropListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerCombatEvent(EntityDamageEvent event) { + } + String HEX_PATTERN = "([a-zA-Z0-9+/]{32,}+={0,2})"; + Pattern pattern = Pattern.compile(HEX_PATTERN); + + @EventHandler(priority = EventPriority.HIGHEST) + public void BlockBreakEvent(BlockBreakEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onEntityDeath(EntityDeathEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerDeath(EntityDeathEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/PlayerCombat/PlayerCombatListener.java b/src/com/Zrips/CMI/Modules/PlayerCombat/PlayerCombatListener.java index f7a3871..1f5b894 100644 --- a/src/com/Zrips/CMI/Modules/PlayerCombat/PlayerCombatListener.java +++ b/src/com/Zrips/CMI/Modules/PlayerCombat/PlayerCombatListener.java @@ -4,17 +4,86 @@ import java.util.Set; import java.util.UUID; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.events.CMIPvEEndEventAsync; +import com.Zrips.CMI.events.CMIPvEStartEventAsync; +import com.Zrips.CMI.events.CMIPvPEndEventAsync; +import com.Zrips.CMI.events.CMIPvPStartEventAsync; public class PlayerCombatListener implements Listener { private CMI plugin; public PlayerCombatListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } Set ignoreFall = new HashSet(); + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerQuitEvent(final PlayerQuitEvent event) { + } + + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerJoinEvent(final PlayerJoinEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onPlayerMove(PlayerCommandPreprocessEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void CMIPvPEndEventAsync(CMIPvPEndEventAsync event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void CMIPvPStartEventAsync(CMIPvPStartEventAsync event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void CMIPvPStartEventAsync(CMIPvEStartEventAsync event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void CMIPvEEndEventAsync(CMIPvEEndEventAsync event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void playerDamageEvent(EntityDamageEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void entityCombatEvent(EntityDamageEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void PlayerForceCombatEvent(EntityDamageEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerCombatEvent(EntityDamageEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerDeath(EntityDeathEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/PlayerCombat/PlayerCombatManager.java b/src/com/Zrips/CMI/Modules/PlayerCombat/PlayerCombatManager.java index 683bd3a..2e05298 100644 --- a/src/com/Zrips/CMI/Modules/PlayerCombat/PlayerCombatManager.java +++ b/src/com/Zrips/CMI/Modules/PlayerCombat/PlayerCombatManager.java @@ -1,14 +1,11 @@ package com.Zrips.CMI.Modules.PlayerCombat; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map.Entry; import java.util.Set; import java.util.UUID; -import java.util.regex.Matcher; import java.util.regex.Pattern; import org.bukkit.Bukkit; @@ -19,17 +16,6 @@ import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIUser; -import net.Zrips.CMILib.FileHandler.ConfigReader; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; -import com.Zrips.CMI.events.CMIPvEEndEventAsync; -import com.Zrips.CMI.events.CMIPvEStartEventAsync; -import com.Zrips.CMI.events.CMIPvPEndEventAsync; -import com.Zrips.CMI.events.CMIPvPStartEventAsync; -import net.Zrips.CMILib.Version.Version; -import net.Zrips.CMILib.Container.CMIList; -import net.Zrips.CMILib.Entities.CMIEntitySubType; -import net.Zrips.CMILib.Entities.CMIEntityType; -import net.Zrips.CMILib.Entities.MobHeadInfo; public class PlayerCombatManager { @@ -68,20 +54,22 @@ public class PlayerCombatManager { private double LowerChanceWithEachKill = 50D; private int CombatTimer = 15; + private List PlayerHeadLore = new ArrayList(); + Pattern lorePattern = Pattern.compile("(lore\\{(\"|'))(.+)((\"|')\\})"); public PlayerCombatManager(CMI plugin) { - this.plugin = plugin; - tasker(); + this.plugin = plugin; + tasker(); } private int sched = -1; public void stop() { - if (sched != -1) { - Bukkit.getScheduler().cancelTask(sched); - sched = -1; - } + if (sched != -1) { + Bukkit.getScheduler().cancelTask(sched); + sched = -1; + } } public void loadConfig() { @@ -89,56 +77,55 @@ public void loadConfig() { } public void loadHeads() { - } public void removePlayerFromCombat(CMIUser user) { - + } public void addPlayerIntoCombat(CMIUser user) { - + } public void addPlayerIntoMobCombat(CMIUser user) { - + } private void tasker() { - + } public Boolean isDropPlayerHead() { - return dropHead; + return dropHead; } public Boolean isDropEntityHead() { - return dropEntityHead; + return dropEntityHead; } public double getLowerChanceWithEachKill() { - return LowerChanceWithEachKill; + return LowerChanceWithEachKill; } public double getPlayerDropHeadPercentage() { - return DropHeadPercentage; + return DropHeadPercentage; } public double getEntityDropHeadPercentage(EntityType type) { - EntityHeadDrop c = entityHeadDropChance.get(type); - return c == null ? 0D : c.getBaseDropChance(); + EntityHeadDrop c = entityHeadDropChance.get(type); + return c == null ? 0D : c.getBaseDropChance(); } public double getEntityHeadDropChanceLowering(EntityType type) { - EntityHeadDrop c = entityHeadDropChance.get(type); - return c == null ? 0D : c.getBaseLowerAmount(); + EntityHeadDrop c = entityHeadDropChance.get(type); + return c == null ? 0D : c.getBaseLowerAmount(); } @Deprecated public ItemStack tryToGetEntityHead(EntityType type) { - EntityHeadDrop c = entityHeadDropChance.get(type); - return c == null ? null : c.getHead(); + EntityHeadDrop c = entityHeadDropChance.get(type); + return c == null ? null : c.getHead(); } // public ItemStack tryToGetEntityHead(Entity ent) { @@ -146,110 +133,123 @@ public ItemStack tryToGetEntityHead(EntityType type) { // } public ItemStack tryToGetEntityHead(Player player, Entity ent) { - EntityHeadDrop c = entityHeadDropChance.get(ent.getType()); - return c == null ? null : c.getHead(player, ent); + EntityHeadDrop c = entityHeadDropChance.get(ent.getType()); + return c == null ? null : c.getHead(player, ent); } public HashMap getEntityHeadDropChance() { - return entityHeadDropChance; + return entityHeadDropChance; } public int getCombatTimer() { - return CombatTimer; + return CombatTimer; } public void setCombatTimer(int combatTimer) { - CombatTimer = combatTimer; + CombatTimer = combatTimer; } public Boolean isIncludeVictim() { - return IncludeVictim; + return IncludeVictim; } public HashMap getLootMobBonus() { - return lootMobBonus; + return lootMobBonus; } public HashMap getLootPlayerBonus() { - return lootPlayerBonus; + return lootPlayerBonus; } public Boolean isPVPNoGodDamage() { - return pvpNoGodDamage; + return pvpNoGodDamage; } public Boolean isPVPNoGodDamageInform() { - return pvpNoGodDamageInform; + return pvpNoGodDamageInform; } public Boolean isPVENoGodDamage() { - return pveNoGodDamage; + return pveNoGodDamage; } public Boolean isPVENoGodDamageInform() { - return pveNoGodDamageInform; + return pveNoGodDamageInform; } - + public Boolean isPDisableFlight() { - return PDisableFlight; + return PDisableFlight; } public Boolean isMDisableFlight() { - return MDisableFlight; + return MDisableFlight; } public boolean isAllowedPlayerCommand(String command) { - for (String one : PlayerAllowedCommands) { - if (command.equalsIgnoreCase(one.toLowerCase()) || command.startsWith(one.toLowerCase() + " ")) { - return !PlayerMakeBlackList; - } - } - return PlayerMakeBlackList; + for (String one : PlayerAllowedCommands) { + if (command.equalsIgnoreCase(one.toLowerCase()) || command.startsWith(one.toLowerCase() + " ")) { + return !PlayerMakeBlackList; + } + } + return PlayerMakeBlackList; } public boolean isAllowedMobCommand(String command) { - for (String one : MobAllowedCommands) { - if (command.equalsIgnoreCase(one.toLowerCase()) || command.startsWith(one.toLowerCase() + " ")) { - return !MobMakeBlackList; - } - } - return MobMakeBlackList; + for (String one : MobAllowedCommands) { + if (command.equalsIgnoreCase(one.toLowerCase()) || command.startsWith(one.toLowerCase() + " ")) { + return !MobMakeBlackList; + } + } + return MobMakeBlackList; } public boolean isPlayerShowBossBar() { - return PlayerShowBossBar; + return PlayerShowBossBar; } public boolean isMobShowBossBar() { - return MobShowBossBar; + return MobShowBossBar; } public boolean isPlayerBlockCommands() { - return PlayerBlockCommands; + return PlayerBlockCommands; } public boolean isMobBlockCommands() { - return MobBlockCommands; + return MobBlockCommands; } public boolean isPDisableFallDamage() { - return PDisableFallDamage; + return PDisableFallDamage; } public boolean isMDisableFallDamage() { - return MDisableFallDamage; + return MDisableFallDamage; } public List getMobWorlds() { - return mobWorlds; + return mobWorlds; } public List getPlayerWorlds() { - return playerWorlds; + return playerWorlds; } public boolean isSafeZoneDamage() { - return safeZoneDamage; + return safeZoneDamage; } + public List getPlayerHeadLore() { + return new ArrayList(PlayerHeadLore); + } + +// public boolean isPlayerMakeCMDBlackList() { +// return PlayerMakeBlackList; +// } +// +// public boolean isMobMakeCMDBlackList() { +// return MobMakeBlackList; + +// } + } diff --git a/src/com/Zrips/CMI/Modules/PlayerMeta/PlayerMeta.java b/src/com/Zrips/CMI/Modules/PlayerMeta/PlayerMeta.java index 1c62b65..fd7111d 100644 --- a/src/com/Zrips/CMI/Modules/PlayerMeta/PlayerMeta.java +++ b/src/com/Zrips/CMI/Modules/PlayerMeta/PlayerMeta.java @@ -1,63 +1,63 @@ package com.Zrips.CMI.Modules.PlayerMeta; import java.util.HashMap; -import java.util.Map.Entry; public class PlayerMeta { private HashMap map = new HashMap(); public class metaValues { - private String value; - private String defaultV = null; + private String value; + private String defaultV = null; - public String getValue() { - return value; - } + public String getValue() { + return value; + } - public void setValue(String value) { - this.value = value; - } + public void setValue(String value) { + this.value = value; + } - public String getDefaultV() { - return defaultV == null ? getValue() : defaultV; - } + public String getDefaultV() { + return defaultV == null ? getValue() : defaultV; + } - public void setDefaultV(String defaultV) { - this.defaultV = defaultV; - } + public void setDefaultV(String defaultV) { + this.defaultV = defaultV; + } } public PlayerMeta() { } public void add(String key, String value) { - add(key, value, null); + add(key, value, null); } public void add(String key, String value, String defaultV) { } public void remove(String key) { - map.remove(key.toLowerCase()); + map.remove(key.toLowerCase()); } public String getValue(String key) { - metaValues v = map.get(key.toLowerCase()); - if (v == null) - return ""; - return v.getValue(); + metaValues v = map.get(key.toLowerCase()); + if (v == null) + return ""; + return v.getValue(); } public boolean containsValues() { - return !map.isEmpty(); + return !map.isEmpty(); } public HashMap getMap() { - return map; + return map; } public HashMap getMapForSave() { - return null; + HashMap m = new HashMap(); + return m; } } diff --git a/src/com/Zrips/CMI/Modules/PlayerOptions/PlayerOption.java b/src/com/Zrips/CMI/Modules/PlayerOptions/PlayerOption.java new file mode 100644 index 0000000..1c0ad59 --- /dev/null +++ b/src/com/Zrips/CMI/Modules/PlayerOptions/PlayerOption.java @@ -0,0 +1,110 @@ +package com.Zrips.CMI.Modules.PlayerOptions; + +import java.util.HashMap; + +import org.bukkit.inventory.ItemStack; + +import net.Zrips.CMILib.Items.CMIMaterial; + +public enum PlayerOption { + + // Add new entry to the end, ALWAYS. + visibleHolograms(10, true, "&eVisible holograms", CMIMaterial.BLACK_STAINED_GLASS), + shiftSignEdit(10, true, "&eSign shift edit", CMIMaterial.OAK_SIGN), + totemBossBar(10, true, "&eTotem BossBar", CMIMaterial.TOTEM_OF_UNDYING), + bassBarCompass(10, true, "&eCompass BossBar", CMIMaterial.COMPASS), + tagSound(10, true, "&eChat tagging sound", CMIMaterial.PAPER), + chatSpy(10, false, "&eChat spy", CMIMaterial.BUCKET), + cmdSpy(10, false, "&eCommand spy", CMIMaterial.WATER_BUCKET), + signSpy(10, false, "&eSign spy", CMIMaterial.LAVA_BUCKET), + acceptingPM(10, true, "&eAccepting private messages", CMIMaterial.MAP), + acceptingTPA(10, true, "&eAccepting teleportations to you", CMIMaterial.CLOCK), + acceptingMoney(10, true, "&eAccepting money payments", CMIMaterial.KNOWLEDGE_BOOK); + // Add new entry to the end, ALWAYS. + + private int slot; + private boolean defaults = true; + private boolean globalEnabled = true; + private ItemStack icon; + private String desc; + + PlayerOption(int slot, boolean defaults, String desc, CMIMaterial icon) { + this.slot = slot; + this.defaults = defaults; + this.desc = desc; + this.icon = icon.newItemStack(); + } + + public int getUISlot() { + return slot; + } + + public boolean isEnabled() { + return defaults; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + void setEnabled(Boolean state) { + defaults = state; + } + + private static HashMap cache = new HashMap(); + + static { + for (PlayerOption one : PlayerOption.values()) { + cache.put(one.toString().toLowerCase(), one); + } + } + + public static PlayerOption get(String name) { + return cache.get(name.toLowerCase()); + } + + private static String to(boolean state) { + return state ? "1" : "0"; + } + + private static boolean from(String state) { + return state.equals("1") ? true : false; + } + + public static HashMap fromString(String line) { + HashMap map = new HashMap(); + return map; + } + + public static String toString(HashMap map) { + StringBuilder line = new StringBuilder(); + return line.toString(); + } + + public static String defaultString = ""; + + public static String toDefaultValueString() { + + return PlayerOptionsManager.defaultString; + } + + public boolean isGlobalEnabled() { + return globalEnabled; + } + + public void setGlobalEnabled(boolean globalEnabled) { + this.globalEnabled = globalEnabled; + } + + public ItemStack getIcon() { + return icon; + } + + public void setIcon(ItemStack icon) { + this.icon = icon; + } +} diff --git a/src/com/Zrips/CMI/Modules/PlayerOptions/PlayerOptionsManager.java b/src/com/Zrips/CMI/Modules/PlayerOptions/PlayerOptionsManager.java new file mode 100644 index 0000000..a80b8b6 --- /dev/null +++ b/src/com/Zrips/CMI/Modules/PlayerOptions/PlayerOptionsManager.java @@ -0,0 +1,36 @@ +package com.Zrips.CMI.Modules.PlayerOptions; + +import java.util.List; + +import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Containers.CMIUser; + +import net.Zrips.CMILib.Items.CMIItemStack; + +public class PlayerOptionsManager { + private CMI plugin; + + private Boolean guiCloseButton; + private int guiCloseButtonSlot; + private CMIItemStack guiCloseButtonItem; + private List guiCloseButtonCommands; + + private boolean guiInfoButton; + private int guiInfoButtonSlot; + private CMIItemStack guiInfoButtonItem; + private List guiInfoButtonCommands; + + public PlayerOptionsManager(CMI plugin) { + this.plugin = plugin; + } + + public static String defaultString = ""; + + public void loadConfig() { + + } + + public void openOptionGUI(CMIUser user) { + + } +} diff --git a/src/com/Zrips/CMI/Modules/Portals/CMIPlaneIntersection.java b/src/com/Zrips/CMI/Modules/Portals/CMIPlaneIntersection.java index 8366fe0..341be25 100644 --- a/src/com/Zrips/CMI/Modules/Portals/CMIPlaneIntersection.java +++ b/src/com/Zrips/CMI/Modules/Portals/CMIPlaneIntersection.java @@ -10,32 +10,60 @@ public class CMIPlaneIntersection { private CMIVector2D localLoc; public static CompletableFuture get(Vector rayVector, Vector rayPoint, Vector planeNormal, CMIPlane plane) { - return CompletableFuture.supplyAsync(() -> get(new CMIVector3D(rayVector), new CMIVector3D(rayPoint), new CMIVector3D(planeNormal), plane)); + return CompletableFuture.supplyAsync(() -> get(new CMIVector3D(rayVector), new CMIVector3D(rayPoint), new CMIVector3D(planeNormal), plane)); } private static CMIPlaneIntersection get(CMIVector3D lookDirection, CMIVector3D fromLocation, CMIVector3D planeDirection, CMIPlane cmiPlane) { - return null; + return null; + + } + + private final static double _HPI = Math.PI / 180; + + public static CMIVector3D rotateAroundCenter(double lx, double ly, double yaw, double pitch) { + return null; + } + + public static double xPosYaw(double time, double radius, double yaw) { + return Math.sin(time) * radius * Math.cos(_HPI * yaw); + } + + public static double yPosYaw(double time, double radius) { + return Math.cos(time) * radius; + } + + public static double zPosYaw(double time, double radius, double yaw) { + return Math.sin(time) * radius * Math.sin(_HPI * yaw); + } + + private static CMIVector3D rotateX(CMIVector3D v, double a) { + return null; + } + + private static CMIVector3D rotateY(CMIVector3D v, double a) { + return null; } private static CMIVector3D intersectPoint(CMIVector3D rayVector, CMIVector3D rayPoint, CMIVector3D planeNormal, CMIPlane plane) { - return null; + + return null; } public CMIVector3D getGlobalLoc() { - return globalLoc; + return globalLoc; } public void setGlobalLoc(CMIVector3D globalLoc) { - this.globalLoc = globalLoc; + this.globalLoc = globalLoc; } public CMIVector2D getLocalLoc() { - return localLoc; + return localLoc; } public void setLocalLoc(CMIVector2D localLoc) { - this.localLoc = localLoc; + this.localLoc = localLoc; } -} +} \ No newline at end of file diff --git a/src/com/Zrips/CMI/Modules/Portals/CMIPortal.java b/src/com/Zrips/CMI/Modules/Portals/CMIPortal.java index cdd8a30..47c7ace 100644 --- a/src/com/Zrips/CMI/Modules/Portals/CMIPortal.java +++ b/src/com/Zrips/CMI/Modules/Portals/CMIPortal.java @@ -6,18 +6,14 @@ import java.util.Set; import java.util.UUID; -import org.bukkit.Bukkit; +import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.Snd; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; -import com.Zrips.CMI.Modules.tp.Teleportations.TeleportType; -import com.Zrips.CMI.events.CMIPortalUseEvent; -import net.Zrips.CMILib.Container.CMIList; +import net.Zrips.CMILib.Effects.CMIEffect; import net.Zrips.CMILib.Effects.CMIEffectManager.CMIParticle; public class CMIPortal { @@ -43,7 +39,8 @@ public class CMIPortal { private int percentToHide = 0; private int activationRange = 16; - private CMIParticle effect = CMIParticle.COLOURED_DUST; + private CMIEffect cmiEffect = null; + private List commands = null; private String name; @@ -52,236 +49,253 @@ public class CMIPortal { private Set particleForPlayers = new HashSet(); public CMIPortal() { - area = new CuboidArea(null); + area = new CuboidArea(null); } public boolean containsLoc(Location loc) { - return area.containsLoc(loc); + return area.containsLoc(loc); } public boolean containsLoc(Location loc, int range) { - return area.containsLoc(loc, range); + return area.containsLoc(loc, range); } public CuboidArea getArea() { - return area; + return area; } public String getName() { - return name; + return name; } public void setName(String name) { - this.name = name; + this.name = name; } public World getWorld() { - if (world == null && this.getWorldName() != null) - return CMI.getInstance().getUtilManager().getWorld(this.worldName); - return world; + if (world == null && this.getWorldName() != null) + return CMI.getInstance().getUtilManager().getWorld(this.worldName); + return world; } public void setWorld(World world) { - this.world = world; - if (world != null) - this.worldName = world.getName(); + this.world = world; + if (world != null) + this.worldName = world.getName(); } public boolean checkCollision(CuboidArea area) { - if (this.area != null) { - if (this.area.checkCollision(area)) { - return true; - } - } - return false; + if (this.area != null) { + if (this.area.checkCollision(area)) { + return true; + } + } + return false; } public boolean teleport(Player player) { - - return false; - + return false; } public Location loadTpLoc(Object root) throws Exception { - tpLoc = (Location) root; - return tpLoc; + return null; } public CuboidArea loadBounds(String root) throws Exception { - return null; + return null; } public Location getTpLoc() { - return tpLoc; + return tpLoc; } public void setTpLoc(Location tpLoc) { - this.tpLoc = tpLoc; + this.tpLoc = tpLoc; } public void setArea(CuboidArea area, boolean recalculatePart) { } public boolean isEnabled() { - return enabled; + return enabled; } public void setEnabled(boolean enabled) { - this.enabled = enabled; + this.enabled = enabled; } public boolean isShowParticles() { - return showParticles; + return showParticles; } public void setShowParticles(boolean showParticles) { - this.showParticles = showParticles; + this.showParticles = showParticles; } public int getParticleAmount() { - return particleAmount; + return particleAmount; } public void setParticleAmount(int particleAmount) { } public int getPercentToHide() { - return percentToHide; + return percentToHide; } public void setPercentToHide(int percentToHide) { } public int getActivationRange() { - return activationRange; + return activationRange; } public void setActivationRange(int activationRange) { } - public CMIParticle getEffect() { - if (effect == null) - effect = CMIParticle.COLOURED_DUST; - return effect; - } - - public void setEffect(CMIParticle effect) { - this.effect = effect; - } - public List getCommands() { - return null; + return null; } public List getCommands(Player player) { - return null; + return null; } public void setCommands(List commands) { + if (this.commands == null) + this.commands = new ArrayList(); + this.commands.addAll(commands); } public boolean getPerformCommandsWithoutTp() { - return performCommandsWithoutTp; + return performCommandsWithoutTp; } public void setPerformCommandsWithoutTp(boolean performCommandsWithoutTp) { - this.performCommandsWithoutTp = performCommandsWithoutTp; + this.performCommandsWithoutTp = performCommandsWithoutTp; } public String getBungeeServer() { - return bungeeServer; + return bungeeServer; } public void setBungeeServer(String bungeeServer) { - this.bungeeServer = bungeeServer; + this.bungeeServer = bungeeServer; } public String getBungeeLocation() { - return bungeeLocation; + return bungeeLocation; } public void setBungeeLocation(String bungeeLocation) { - this.bungeeLocation = bungeeLocation; + this.bungeeLocation = bungeeLocation; } public Location getSafeLoc() { - return safeLoc; + return safeLoc; } public void setSafeLoc(Location safeLoc) { - this.safeLoc = safeLoc; + this.safeLoc = safeLoc; } public boolean isToExactBungeeLocation() { - return toExactBungeeLocation; + return toExactBungeeLocation; } public void setToExactBungeeLocation(boolean toExactBungeeLocation) { - this.toExactBungeeLocation = toExactBungeeLocation; + this.toExactBungeeLocation = toExactBungeeLocation; } public boolean isRequiresPermission() { - return requiresPermission; + return requiresPermission; } public void setRequiresPermission(boolean requiresPermission) { - this.requiresPermission = requiresPermission; + this.requiresPermission = requiresPermission; } public boolean isInformOnMissingPerm() { - return informOnMissingPerm; + return informOnMissingPerm; } public void setInformOnMissingPerm(boolean informOnMissingPerm) { - this.informOnMissingPerm = informOnMissingPerm; + this.informOnMissingPerm = informOnMissingPerm; } public String getWorldName() { - if (worldName == null && world != null) - return world.getName(); - return worldName; + if (worldName == null && world != null) + return world.getName(); + return worldName; } public void setWorldName(String worldName) { - this.worldName = worldName; - this.world = CMI.getInstance().getUtilManager().getWorld(worldName); + this.worldName = worldName; + this.world = CMI.getInstance().getUtilManager().getWorld(worldName); } public Set getParticleForPlayers() { - return particleForPlayers; + return particleForPlayers; } public void setParticleForPlayers(Set particleForPlayers) { - this.particleForPlayers = particleForPlayers; + this.particleForPlayers = particleForPlayers; } public Set removeParticleLimitations(Player player) { - return removeParticleLimitations(player.getUniqueId()); + return removeParticleLimitations(player.getUniqueId()); } public Set removeParticleLimitations(UUID uuid) { - particleForPlayers.remove(uuid); - return particleForPlayers; + particleForPlayers.remove(uuid); + return particleForPlayers; } public Set updateParticleLimitations(Player player) { - return null; + return null; } public boolean isParticlesByPermission() { - return particlesByPermission; + return particlesByPermission; } public void setParticlesByPermission(boolean particlesByPermission) { - this.particlesByPermission = particlesByPermission; + this.particlesByPermission = particlesByPermission; } public boolean isKickBack() { - return this.kickBack; + return this.kickBack; } public void setKickBack(boolean kickBack) { - this.kickBack = kickBack; + this.kickBack = kickBack; + } + + @Deprecated + public CMIParticle getEffect() { + return getCMIEffect().getParticle(); } + + public void setEffect(CMIParticle effect) { + getCMIEffect().setParticle(effect); + } + + public CMIEffect getCMIEffect() { + if (cmiEffect == null) { + cmiEffect = new CMIEffect(CMIParticle.COLOURED_DUST); + cmiEffect.setColor(org.bukkit.Color.fromRGB(125, 125, 125)); + } + return cmiEffect; + } + + public void setCMIEffect(CMIEffect cmiEffect) { + this.cmiEffect = cmiEffect; + } + + public CMIPortal setEffectColor(Color color) { + getCMIEffect().setColor(color); + return this; + } + } diff --git a/src/com/Zrips/CMI/Modules/Portals/CMIVector3D.java b/src/com/Zrips/CMI/Modules/Portals/CMIVector3D.java index a67bcc5..fbe4b9d 100644 --- a/src/com/Zrips/CMI/Modules/Portals/CMIVector3D.java +++ b/src/com/Zrips/CMI/Modules/Portals/CMIVector3D.java @@ -1,5 +1,7 @@ package com.Zrips.CMI.Modules.Portals; +import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.util.Vector; public class CMIVector3D { @@ -28,7 +30,7 @@ public CMIVector3D minus(CMIVector3D v) { } public CMIVector3D minus(Vector v) { - return new CMIVector3D(x - v.getX(), y - v.getY(), z - v.getBlockZ()); + return new CMIVector3D(x - v.getX(), y - v.getY(), z - v.getZ()); } public CMIVector3D times(double s) { @@ -48,23 +50,30 @@ public double getX() { return x; } - public void setX(double x) { + public CMIVector3D setX(double x) { this.x = x; + return this; } public double getY() { return y; } - public void setY(double y) { + public CMIVector3D setY(double y) { this.y = y; + return this; } public double getZ() { return z; } - public void setZ(double z) { + public CMIVector3D setZ(double z) { this.z = z; + return this; + } + + public Location toLocation(World world) { + return new Location(world, this.getX(), this.getY(), this.getZ()); } } diff --git a/src/com/Zrips/CMI/Modules/Portals/CuboidArea.java b/src/com/Zrips/CMI/Modules/Portals/CuboidArea.java index d2661ba..6c50270 100644 --- a/src/com/Zrips/CMI/Modules/Portals/CuboidArea.java +++ b/src/com/Zrips/CMI/Modules/Portals/CuboidArea.java @@ -1,19 +1,13 @@ package com.Zrips.CMI.Modules.Portals; -import java.util.ArrayList; import java.util.List; -import java.util.Random; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.World; -import org.bukkit.World.Environment; -import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.util.Vector; import net.Zrips.CMILib.Container.CMILocation; -import net.Zrips.CMILib.Items.CMIMaterial; public class CuboidArea { private Vector p1; @@ -30,485 +24,312 @@ public CuboidArea(World world, Vector startLoc, Vector endLoc) { public CuboidArea(CMILocation startLoc, CMILocation endLoc) { } - + public CuboidArea(Location startLoc, Location endLoc) { } @Override public CuboidArea clone() { - return null; + return null; } private void recheck() { - } public boolean valid() { - return p1 != null && p2 != null; + return p1 != null && p2 != null; } -// public CuboidArea() { -// } - public CuboidArea(World world) { - this.world = world; + this.world = world; } public boolean isAreaWithinArea(CuboidArea area) { - return (this.containsLoc(area.highPoints) && this.containsLoc(area.lowPoints)); + return (this.containsLoc(area.highPoints) && this.containsLoc(area.lowPoints)); } public Location getOutsideFreeLoc() { - return null; + return null; } public boolean containsLoc(Location loc) { - if (loc == null) - return false; + if (loc == null) + return false; - if (loc.getWorld() == null) - return false; + if (loc.getWorld() == null) + return false; - if (!loc.getWorld().equals(world)) - return false; + if (!loc.getWorld().equals(world)) + return false; - return containsLoc(loc.toVector(), 0); + return containsLoc(loc.toVector(), 0); } public boolean containsLoc(Vector vector) { - return containsLoc(vector, 0); + return containsLoc(vector, 0); } public boolean containsLoc(Location loc, int extraRange) { - if (loc == null) - return false; + if (loc == null) + return false; - if (!loc.getWorld().equals(world)) - return false; - return containsLoc(loc.toVector(), extraRange); + if (!loc.getWorld().equals(world)) + return false; + return containsLoc(loc.toVector(), extraRange); } public boolean containsLoc(Vector vector, int extraRange) { - return true; + + return true; } public boolean checkCollision(CuboidArea area) { - if (area.getWorld() == null || this.getWorld() == null) - return false; - if (!area.getWorld().equals(this.getWorld())) { - return false; - } + if (area.getWorld() == null || this.getWorld() == null) + return false; + if (!area.getWorld().equals(this.getWorld())) { + return false; + } - if (!this.valid()) - return false; + if (!this.valid()) + return false; - if (area.containsLoc(lowPoints) || area.containsLoc(highPoints) || this.containsLoc(area.highPoints) || this.containsLoc(area.lowPoints)) { - return true; - } - return advCuboidCheckCollision(highPoints, lowPoints, area.highPoints, area.lowPoints); + if (area.containsLoc(lowPoints) || area.containsLoc(highPoints) || this.containsLoc(area.highPoints) || this.containsLoc(area.lowPoints)) { + return true; + } + return advCuboidCheckCollision(highPoints, lowPoints, area.highPoints, area.lowPoints); } private static boolean advCuboidCheckCollision(Vector A1High, Vector A1Low, Vector A2High, Vector A2Low) { - - return false; + return false; } public long getSize() { - return 0; + if (!this.valid()) + return 0; + int xsize = (highPoints.getBlockX() - lowPoints.getBlockX()) + 1; + int zsize = (highPoints.getBlockZ() - lowPoints.getBlockZ()) + 1; + int ysize = (highPoints.getBlockY() - lowPoints.getBlockY()) + 1; + return xsize * ysize * zsize; } public int getXSize() { - if (!this.valid()) - return 0; - return (highPoints.getBlockX() - lowPoints.getBlockX()) + 1; + if (!this.valid()) + return 0; + return (highPoints.getBlockX() - lowPoints.getBlockX()) + 1; } public int getYSize() { - if (!this.valid()) - return 0; - return (highPoints.getBlockY() - lowPoints.getBlockY()) + 1; + if (!this.valid()) + return 0; + return (highPoints.getBlockY() - lowPoints.getBlockY()) + 1; } public int getZSize() { - if (!this.valid()) - return 0; - return (highPoints.getBlockZ() - lowPoints.getBlockZ()) + 1; + if (!this.valid()) + return 0; + return (highPoints.getBlockZ() - lowPoints.getBlockZ()) + 1; } @Deprecated public Location getHighLoc() { - if (!this.valid()) - return null; - return new CMILocation(this.getWorld(), highPoints.getBlockX(), highPoints.getBlockY(), highPoints.getBlockZ()); + if (!this.valid()) + return null; + return new CMILocation(this.getWorld(), highPoints.getBlockX(), highPoints.getBlockY(), highPoints.getBlockZ()); } public Vector getHighPoint() { - return highPoints; + return highPoints; } @Deprecated public Location getLowLoc() { - if (!this.valid()) - return null; - return new CMILocation(this.getWorld(), lowPoints.getBlockX(), lowPoints.getBlockY(), lowPoints.getBlockZ()); + if (!this.valid()) + return null; + return new CMILocation(this.getWorld(), lowPoints.getBlockX(), lowPoints.getBlockY(), lowPoints.getBlockZ()); } public Vector getLowPoint() { - return lowPoints; + return lowPoints; } public World getWorld() { - return this.world; + return this.world; } public List getChunks() { - return getChunks(0); + return getChunks(0); } public List getChunks(int range) { - - return null; + return null; } public void setArea(CuboidArea area) { } public void setHighLocation(Location highLocation) { - if (highLocation == null) - return; - world = highLocation.getWorld(); - setHighPoint(highLocation.toVector()); + if (highLocation == null) + return; + world = highLocation.getWorld(); + setHighPoint(highLocation.toVector()); } public void setHighPoint(Vector highLocation) { - this.p1 = highLocation; - recheck(); + this.p1 = highLocation; + recheck(); } public void setLowLocation(Location lowLocation) { - if (lowLocation == null) - return; - world = lowLocation.getWorld(); - setLowPoint(lowLocation.toVector()); + if (lowLocation == null) + return; + world = lowLocation.getWorld(); + setLowPoint(lowLocation.toVector()); } public void setLowPoint(Vector lowPoint) { - this.p2 = lowPoint; - recheck(); + this.p2 = lowPoint; + recheck(); } public void setWorld(World world) { - this.world = world; + this.world = world; } public void setLocation(Location location) { - if (location == null) - return; - world = location.getWorld(); - setPoint(location.toVector()); + if (location == null) + return; + world = location.getWorld(); + setPoint(location.toVector()); } public void setPoint(Vector vector) { - if (vector == null) - return; - if (this.p1 == null) - this.p1 = vector; - else - this.p2 = vector; - recheck(); + if (vector == null) + return; + if (this.p1 == null) + this.p1 = vector; + else + this.p2 = vector; + recheck(); } -// public void setWorld(World world) { -// this.world = world; -// } - @Deprecated public Location getMiddleLocation() { - if (!this.valid()) - return null; - return new Location(this.world, - (this.getLowPoint().getX() + this.getHighPoint().getX()) / 2, - (this.getLowPoint().getY() + this.getHighPoint().getY()) / 2, - (this.getLowPoint().getZ() + this.getHighPoint().getZ()) / 2); + return null; } public Vector getMiddlePoint() { - if (!this.valid()) - return null; - return new Vector( - (this.getLowPoint().getX() + this.getHighPoint().getX()) / 2, - (this.getLowPoint().getY() + this.getHighPoint().getY()) / 2, - (this.getLowPoint().getZ() + this.getHighPoint().getZ()) / 2); + return null; } @Override public String toString() { - if (!this.valid()) - return null; - StringBuilder sb = new StringBuilder(); - sb.append(this.lowPoints.getX()).append(":").append(this.lowPoints.getY()).append(":").append(this.lowPoints.getZ()).append(":") - .append(this.highPoints.getX()).append(":").append(this.highPoints.getY()).append(":").append(this.highPoints.getZ()); - return sb.toString(); + return null; } public static final class ChunkRef { - public static int getChunkCoord(final int val) { - return val >> 4; - } - - private final int z; - private final int x; - - public ChunkRef(Location loc) { - this.x = getChunkCoord(loc.getBlockX()); - this.z = getChunkCoord(loc.getBlockZ()); - } - - public ChunkRef(int x, int z) { - this.x = x; - this.z = z; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ChunkRef other = (ChunkRef) obj; - return this.x == other.x && this.z == other.z; - } - - @Override - public int hashCode() { - return x ^ z; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("{ x: ").append(x).append(", z: ").append(z).append(" }"); - return sb.toString(); - } + public static int getChunkCoord(final int val) { + return val >> 4; + } + + private final int z; + private final int x; + + public ChunkRef(Location loc) { + this.x = getChunkCoord(loc.getBlockX()); + this.z = getChunkCoord(loc.getBlockZ()); + } + + public ChunkRef(int x, int z) { + this.x = x; + this.z = z; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ChunkRef other = (ChunkRef) obj; + return this.x == other.x && this.z == other.z; + } + + @Override + public int hashCode() { + return x ^ z; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{ x: ").append(x).append(", z: ").append(z).append(" }"); + return sb.toString(); + } } public boolean shift(Player player, double amount) { - return shift(getDirection(player), amount); + return shift(getDirection(player), amount); } public boolean shift(Direction d, double amount) { - if (!valid()) { - return false; - } - if (d == null) { - return false; - } - switch (d) { - case DOWN: - double oldy = getLowPoint().getBlockY() - amount; - if (oldy < MIN_HEIGHT) { - oldy = MIN_HEIGHT; - } - getLowPoint().setY(oldy); - getHighPoint().setY(getHighPoint().getBlockY() - amount); - break; - case MINUSX: - getLowPoint().setX(getLowPoint().getBlockX() - amount); - getHighPoint().setX(getHighPoint().getBlockX() - amount); - break; - case MINUSZ: - getLowPoint().setZ(getLowPoint().getBlockZ() - amount); - getHighPoint().setZ(getHighPoint().getBlockZ() - amount); - break; - case PLUSX: - getHighPoint().setX(getHighPoint().getBlockX() + amount); - getLowPoint().setX(getLowPoint().getBlockX() + amount); - break; - case PLUSZ: - getHighPoint().setZ(getHighPoint().getBlockZ() + amount); - getLowPoint().setZ(getLowPoint().getBlockZ() + amount); - break; - case UP: - oldy = getHighPoint().getBlockY() + amount; - if (oldy > getMaxWorldHeight()) { - oldy = getMaxWorldHeight(); - } - getHighPoint().setY(oldy); - getLowPoint().setY(getLowPoint().getBlockY() + amount); - break; - default: - break; - } - return true; + + return true; } public boolean expand(Player player, double amount) { - return expand(getDirection(player), amount); + return expand(getDirection(player), amount); } public boolean expand(Direction d, double amount) { - if (!valid()) { - return false; - } - - if (d == null) { - return false; - } - - switch (d) { - case DOWN: - double oldy = getLowPoint().getBlockY() - amount; - if (oldy < MIN_HEIGHT) { - oldy = MIN_HEIGHT; - } - getLowPoint().setY(oldy); - break; - case MINUSX: - getLowPoint().setX(getLowPoint().getBlockX() - amount); - break; - case MINUSZ: - getLowPoint().setZ(getLowPoint().getBlockZ() - amount); - break; - case PLUSX: - getHighPoint().setX(getHighPoint().getBlockX() + amount); - break; - case PLUSZ: - getHighPoint().setZ(getHighPoint().getBlockZ() + amount); - break; - case UP: - oldy = getHighPoint().getBlockY() + amount; - if (oldy > getMaxWorldHeight()) { - oldy = getMaxWorldHeight(); - } - getHighPoint().setY(oldy); - break; - default: - break; - } - return true; + + return true; } public boolean contract(Player player, double amount) { - if (!this.valid()) { - return false; - } - return contract(getDirection(player), amount); + if (!this.valid()) { + return false; + } + return contract(getDirection(player), amount); } public boolean contract(Direction d, double amount) { - if (!this.valid()) { - return false; - } - if (d == null) { - return false; - } - - switch (d) { - case DOWN: - double oldy = getHighPoint().getBlockY() - amount; - if (oldy > getMaxWorldHeight()) { - oldy = getMaxWorldHeight(); - } - - oldy = getHighPoint().getBlockY() - amount; - oldy = getLowPoint().getY() > oldy ? getLowPoint().getY() : oldy; - - - - getHighPoint().setY(oldy); - break; - case MINUSX: - double res = getHighPoint().getBlockX() - amount; - res = getLowPoint().getX() > res ? getLowPoint().getX() : res; - getHighPoint().setX(res); - break; - case MINUSZ: - res = getHighPoint().getBlockZ() - amount; - res = getLowPoint().getZ() > res ? getLowPoint().getZ() : res; - getHighPoint().setZ(res); - break; - case PLUSX: - res = getLowPoint().getBlockX() + amount; - res = getHighPoint().getX() < res ? getHighPoint().getX() : res; - getLowPoint().setX(res); - break; - case PLUSZ: - res = getLowPoint().getBlockZ() + amount; - res = getHighPoint().getZ() < res ? getHighPoint().getZ() : res; - getLowPoint().setZ(res); - break; - case UP: - oldy = getLowPoint().getBlockY() + amount; - if (oldy < MIN_HEIGHT) { - oldy = MIN_HEIGHT; - } - oldy = getLowPoint().getBlockY() + amount; - oldy = getHighPoint().getY() < oldy ? getHighPoint().getY() : oldy; - getLowPoint().setY(oldy); - break; - default: - break; - } - - return true; + + return true; } private int getMaxWorldHeight() { - if (this.getWorld() == null) - return 256; - switch (this.getWorld().getEnvironment()) { - case NETHER: - return 128; - case NORMAL: - case THE_END: - return 256; - default: - break; - } + if (this.getWorld() == null) + return 256; + switch (this.getWorld().getEnvironment()) { + case NETHER: + return 128; + case NORMAL: + case THE_END: + return 256; + default: + break; + } - return 256; + return 256; } private static Direction getDirection(Player player) { - int yaw = (int) player.getLocation().getYaw(); - - if (yaw < 0) - yaw += 360; - - yaw += 45; - yaw %= 360; - - int facing = yaw / 90; - - float pitch = player.getLocation().getPitch(); - if (pitch < -50) - return Direction.UP; - if (pitch > 50) - return Direction.DOWN; - if (facing == 1) // east - return Direction.MINUSX; - if (facing == 3) // west - return Direction.PLUSX; - if (facing == 2) // north - return Direction.MINUSZ; - if (facing == 0) // south - return Direction.PLUSZ; - return null; + return null; } public String getWorldName() { - return world == null ? worldName : world.getName(); + return world == null ? worldName : world.getName(); } public enum Direction { - UP, DOWN, PLUSX, PLUSZ, MINUSX, MINUSZ + UP, DOWN, PLUSX, PLUSZ, MINUSX, MINUSZ } } diff --git a/src/com/Zrips/CMI/Modules/Portals/PortalListener.java b/src/com/Zrips/CMI/Modules/Portals/PortalListener.java index d97a43d..6f42c18 100644 --- a/src/com/Zrips/CMI/Modules/Portals/PortalListener.java +++ b/src/com/Zrips/CMI/Modules/Portals/PortalListener.java @@ -4,7 +4,17 @@ import java.util.Map; import java.util.UUID; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.vehicle.VehicleEnterEvent; +import org.bukkit.event.vehicle.VehicleMoveEvent; import com.Zrips.CMI.CMI; @@ -15,8 +25,48 @@ public class PortalListener implements Listener { protected Map lastUpdateRange; public PortalListener(CMI plugin) { - this.plugin = plugin; - lastUpdate = new HashMap(); - lastUpdateRange = new HashMap(); + this.plugin = plugin; + lastUpdate = new HashMap(); + lastUpdateRange = new HashMap(); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onVehicleMove(VehicleMoveEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onVehicleMove(VehicleEnterEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onPlayerMove(PlayerMoveEvent event) { + + } + + private boolean processMove(Player player, Location locfrom, Location locto) { + + return true; + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMoveExtendedRange(PlayerMoveEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerMoveExtendedRnage(PlayerTeleportEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerQuitEvent(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerJoinEvent(PlayerJoinEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/Portals/PortalManager.java b/src/com/Zrips/CMI/Modules/Portals/PortalManager.java index 037d8d9..a7ccd4c 100644 --- a/src/com/Zrips/CMI/Modules/Portals/PortalManager.java +++ b/src/com/Zrips/CMI/Modules/Portals/PortalManager.java @@ -1,38 +1,20 @@ package com.Zrips.CMI.Modules.Portals; -import java.io.File; -import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Random; import java.util.Set; import java.util.SortedMap; -import java.util.TreeMap; import java.util.UUID; -import java.util.logging.Level; -import java.util.logging.Logger; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.configuration.MemorySection; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.FileHandler.ConfigReader; -import net.Zrips.CMILib.Effects.CMIEffect; -import net.Zrips.CMILib.Effects.CMIEffectManager.CMIParticle; import com.Zrips.CMI.Modules.Portals.CuboidArea.ChunkRef; -import com.Zrips.CMI.Modules.Worlds.CMIWorldListener; -import com.Zrips.CMI.Modules.Worlds.UpdateOnWorldLoad; -import net.Zrips.CMILib.Version.Version; public class PortalManager { @@ -53,30 +35,37 @@ public class PortalManager { private CMI plugin; public PortalManager(CMI plugin) { + } private int sched = -1; public void stop() { - if (sched == -1) - return; - Bukkit.getScheduler().cancelTask(sched); - sched = -1; + if (sched == -1) + return; + Bukkit.getScheduler().cancelTask(sched); + sched = -1; } private void tasker() { - + } private static void showParticlesForPortal(CMIPortal portal) { - } public void addPortal(CMIPortal portal) { + portals.put(portal.getName().toLowerCase(), portal); + recalculateChunks(portal); } public void recalculateChunks() { + chunkPortals.clear(); + chunkPortalsRange1.clear(); + for (Entry one : this.portals.entrySet()) { + recalculateChunks(one.getValue()); + } } public void recalculateChunks(CMIPortal portal) { @@ -84,137 +73,159 @@ public void recalculateChunks(CMIPortal portal) { } public CMIPortal getByName(String name) { - if (name == null) - return null; - return portals.get(name.toLowerCase()); + if (name == null) + return null; + return portals.get(name.toLowerCase()); } public CMIPortal getByLoc(Location loc) { - - return null; + + return null; } public Set getByLocList(Location loc) { - - return null; + + return null; } public Set getByLocExtended(Location loc) { - - return null; + + return null; } public CMIPortal collidesWithPortal(CuboidArea newarea) { - - return null; + + return null; } private static List getChunks(CMIPortal res) { - - return null; + List chunks = new ArrayList<>(); + chunks.addAll(res.getArea().getChunks()); + return chunks; } private static List getChunks(CMIPortal portal, int range) { - return null; + List chunks = new ArrayList<>(); + chunks.addAll(portal.getArea().getChunks(range)); + return chunks; } public void loadConfig() { + } public void load() { - + } public void loadMap(String world, Map root) throws Exception { - + } public void handlePortalVisualizerUpdates() { - for (Player one : Bukkit.getOnlinePlayers()) { - handlePortalVisualizerUpdates(one, null, one.getLocation()); - } + for (Player one : Bukkit.getOnlinePlayers()) { + handlePortalVisualizerUpdates(one, null, one.getLocation()); + } } public boolean handlePortalVisualizerUpdates(Player player, Location locfrom, Location locto) { - boolean success = true; - - return success; + return false; } public void savePortals() { - + if (id != null) + return; + id = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CMI.getInstance(), new Runnable() { + @Override + public void run() { + CMI.getInstance().getPortalManager().save(); + id = null; + } + }, 20 * 10L); } private Integer id = null; private boolean saving = false; private void save() { - + } public void removeLastPortalInRange(CMIPortal portal, UUID uuid) { - + } public void removeLastPortalInRange(UUID uuid) { - + } public void addLastPortalInRange(CMIPortal portal, UUID uuid) { - + } public SortedMap getPortals() { - return portals; + return portals; } public List getPortalsByDistance(Location loc) { - return null; + return null; } public void removePortal(CMIPortal portal) { - portals.remove(portal.getName().toLowerCase()); - lastPortalInRange.remove(portal); - this.recalculateChunks(); - this.savePortals(); + portals.remove(portal.getName().toLowerCase()); + lastPortalInRange.remove(portal); + this.recalculateChunks(); + this.savePortals(); } public int getPortalsCheckInterval() { - return PortalsCheckInterval; + return PortalsCheckInterval; } public int getPortalsCheckParticleInterval() { - return PortalsCheckParticleInterval; + return PortalsCheckParticleInterval; } public List getCommandsOnTeleport() { - return commandsOnTeleport; + return commandsOnTeleport; } public boolean isNearPortal(UUID uuid) { - return false; + if (playerNearPortals.isEmpty()) + return false; + if (uuid == null) + return false; + Set ls = playerNearPortals.get(uuid); + return ls != null && !ls.isEmpty(); } public void addNearPortal(UUID uuid, CMIPortal portal) { + Set ls = playerNearPortals.get(uuid); + if (ls == null) + ls = new HashSet(); + ls.add(portal); + portal.updateParticleLimitations(Bukkit.getPlayer(uuid)); + playerNearPortals.put(uuid, ls); } public void removeNearPortal(UUID uuid, CMIPortal portal) { + } public void removeNearPortal(UUID uuid) { - Set rem = playerNearPortals.remove(uuid); - if (rem != null) - for (CMIPortal one : rem) { - one.removeParticleLimitations(uuid); - } + Set rem = playerNearPortals.remove(uuid); + if (rem != null) + for (CMIPortal one : rem) { + one.removeParticleLimitations(uuid); + } } public void forceUpdate(CMIPortal portal) { - for (Player one : Bukkit.getOnlinePlayers()) { - forceUpdate(one.getUniqueId(), portal); - } + for (Player one : Bukkit.getOnlinePlayers()) { + forceUpdate(one.getUniqueId(), portal); + } } public void forceUpdate(UUID uuid, CMIPortal portal) { diff --git a/src/com/Zrips/CMI/Modules/Ranks/AureliumManager.java b/src/com/Zrips/CMI/Modules/Ranks/AureliumManager.java new file mode 100644 index 0000000..e65fe9d --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Ranks/AureliumManager.java @@ -0,0 +1,33 @@ +package com.Zrips.CMI.Modules.Ranks; + +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.Zrips.CMI.CMI; + +public class AureliumManager { + + static boolean enabled = false; + + public static boolean setup() { + if (!Bukkit.getServer().getPluginManager().isPluginEnabled("AureliumSkills")) + return false; + enabled = true; + CMI.getInstance().consoleMessage("AureliumSkills found."); + return true; + } + + public static boolean isSkillCorrect(String name) { + return false; + } + + public static String getRealSkillName(CommandSender sender, String name) { + return null; + } + + public static int getSkillLevel(Player player, String skill) { + return 0; + } + +} diff --git a/src/com/Zrips/CMI/Modules/Ranks/CMIRank.java b/src/com/Zrips/CMI/Modules/Ranks/CMIRank.java index 38613da..41610b4 100644 --- a/src/com/Zrips/CMI/Modules/Ranks/CMIRank.java +++ b/src/com/Zrips/CMI/Modules/Ranks/CMIRank.java @@ -3,24 +3,14 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map.Entry; - -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Colors.CMIChatColor; -import net.Zrips.CMILib.Entities.CMIEntityType; - import com.Zrips.CMI.Containers.CMIUser; -import com.Zrips.CMI.Containers.Snd; -import net.Zrips.CMILib.Items.CMIItemStack; -import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; -import com.Zrips.CMI.Modules.Particl.ParticleManager.CMIPresetAnimations; import com.Zrips.CMI.Modules.Ranks.RankManager.rankupFailType; import com.Zrips.CMI.Modules.Statistics.StatsManager.CMIStatistic; -import com.Zrips.CMI.Modules.Statistics.StatsManager.CMIType; + +import net.Zrips.CMILib.Colors.CMIChatColor; +import net.Zrips.CMILib.Items.CMIItemStack; public class CMIRank { @@ -37,6 +27,7 @@ public class CMIRank { private LinkedHashMap> statRequirements; private LinkedHashMap permRequirements; private LinkedHashMap mcmmoRequirements; + private LinkedHashMap aureliumRequirements; private LinkedHashMap JobsRequirements; private LinkedHashMap ItemRequirements; private double moneyCost; @@ -46,146 +37,164 @@ public class CMIRank { private int weight = 0; public void reset() { + enabled = false; + defaultRank = false; + AutoRankup = false; + rankUpConfirmation = false; + nextRanks = new ArrayList(); + nextRanksT = new ArrayList(); + Commands = new ArrayList(); + CommandsOnRankDown = new ArrayList(); + statRequirements = new LinkedHashMap>(); + permRequirements = new LinkedHashMap(); + mcmmoRequirements = new LinkedHashMap(); + aureliumRequirements = new LinkedHashMap(); + JobsRequirements = new LinkedHashMap(); + ItemRequirements = new LinkedHashMap(); + moneyCost = 0D; + expCost = 0D; + votes = 0; } public CMIRank(String name) { - this.name = name; - reset(); + this.name = name; + reset(); } public String getName() { - return name; + return name; } public void setName(String name) { - this.name = name; + this.name = name; } public boolean isEnabled() { - return enabled; + return enabled; } public void setEnabled(boolean enabled) { - this.enabled = enabled; + this.enabled = enabled; } public boolean isDefaultRank() { - return defaultRank; + return defaultRank; } public void setDefaultRank(boolean defaultRank) { - this.defaultRank = defaultRank; + this.defaultRank = defaultRank; } public boolean isRankUpConfirmation() { - return rankUpConfirmation; + return rankUpConfirmation; } public void setRankUpConfirmation(boolean rankUpConfirmation) { - this.rankUpConfirmation = rankUpConfirmation; + this.rankUpConfirmation = rankUpConfirmation; } public List getNextRanks() { - return nextRanks; + return nextRanks; } public List getNextValidRankUps(CMIUser user) { - return null; + return null; } public boolean isOnSamePathWith(CMIRank rank2) { - return false; + return false; } private boolean checkPrevious(CMIRank rank1, CMIRank rank2) { - return false; + return false; } private boolean checkNext(CMIRank rank1, CMIRank rank2) { - return false; + return false; } public List getPreviousRanks() { - return null; + return null; } public List getValidPreviousRanks(CMIUser user) { - return null; + return null; } public String getValidPreviousRanksAsString() { - - return null; + return null; } public rankupFailType canRankup(CMIUser user) { - return null; + if (user.getRank() == this) + return rankupFailType.SameRank; + return CMI.getInstance().getRankManager().canRankUp(user, this); } public double getMoneyCost() { - return moneyCost; + return moneyCost; } public void setMoneyCost(double moneyCost) { - this.moneyCost = moneyCost; + this.moneyCost = moneyCost; } public double getExpCost() { - return expCost; + return expCost; } public void setExpCost(double expCost) { - this.expCost = expCost; + this.expCost = expCost; } public List getCommands() { - return Commands; + return Commands; } public void setCommands(List commands) { - Commands = commands; + Commands = commands; } public LinkedHashMap> getStatRequirements() { - return statRequirements; + return statRequirements; } public LinkedHashMap getStatRequirement(CMIStatistic stat) { - return statRequirements.get(stat); + return statRequirements.get(stat); } public CMIRank addStatRequirement(CMIStatistic stat, String name, Long amount) { - return null; + return null; } public void setStatRequirements(LinkedHashMap> statRequirements) { - this.statRequirements = statRequirements; + this.statRequirements = statRequirements; } public boolean isAutoRankup() { - return AutoRankup; + return AutoRankup; } public void setAutoRankup(boolean autoRankup) { - AutoRankup = autoRankup; + AutoRankup = autoRankup; } public void setNextRanksT(List nextRanksT) { - this.nextRanksT = nextRanksT; + this.nextRanksT = nextRanksT; } public void calculateNextRanks() { - nextRanks.clear(); - for (String one : nextRanksT) { - CMIRank rank = CMI.getInstance().getRankManager().getRank(one); - if (rank != null) - nextRanks.add(rank); - } + nextRanks.clear(); + for (String one : nextRanksT) { + CMIRank rank = CMI.getInstance().getRankManager().getRank(one); + if (rank != null) + nextRanks.add(rank); + } } public void finalizeRankup(CMIUser user) { - finalizeRankup(user, true, true); + finalizeRankup(user, true, true); } public void finalizeRankup(CMIUser user, Boolean commands, Boolean cost) { @@ -199,89 +208,94 @@ public void takeExp(CMIUser user) { @Deprecated public void takeMoney(CMIUser user) { - if (this.getMoneyCost() <= 0) - return; - user.withdraw(this.getMoneyCost()); + if (this.getMoneyCost() <= 0) + return; + user.withdraw(this.getMoneyCost()); } public void takeItems(CMIUser user) { - CMI.getInstance().getRankManager().removeContents(user.getPlayer(), this.getItemRequirements()); + CMI.getInstance().getRankManager().removeContents(user.getPlayer(), this.getItemRequirements()); } public void performCommands(CMIUser user) { - Snd snd = new Snd().setSender(user).setTarget(user); - List cp = new ArrayList(this.Commands); - cp = CMI.getInstance().getLM().updateSnd(snd, cp); - CMI.getInstance().getSpecializedCommandManager().processCmds(cp, user.isOnline() ? user.getPlayer() : null); } public void performCommandsOnRankDown(CMIUser user) { + } public String getDisplayName() { - if (displayName == null) - return this.getName(); - return CMIChatColor.translate(displayName); + if (displayName == null) + return this.getName(); + return CMIChatColor.translate(displayName); } public void setDisplayName(String displayName) { - this.displayName = displayName; + this.displayName = displayName; } public LinkedHashMap getPermRequirements() { - return permRequirements; + return permRequirements; } public void setPermRequirements(LinkedHashMap permRequirements) { - this.permRequirements = permRequirements; + this.permRequirements = permRequirements; } public LinkedHashMap getMcmmoRequirements() { - return mcmmoRequirements; + return mcmmoRequirements; } public void setMcmmoRequirements(LinkedHashMap mcmmoRequirements) { - this.mcmmoRequirements = mcmmoRequirements; + this.mcmmoRequirements = mcmmoRequirements; } public LinkedHashMap getJobsRequirements() { - return JobsRequirements; + return JobsRequirements; } public void setJobsRequirements(LinkedHashMap jobsRequirements) { - JobsRequirements = jobsRequirements; + JobsRequirements = jobsRequirements; } public LinkedHashMap getItemRequirements() { - return ItemRequirements; + return ItemRequirements; } public void setItemRequirements(LinkedHashMap itemRequirements) { - ItemRequirements = itemRequirements; + ItemRequirements = itemRequirements; } public int getVotes() { - return votes; + return votes; } public void setVotes(int votes) { - this.votes = votes; + this.votes = votes; } public List getCommandsOnRankDown() { - return CommandsOnRankDown; + return CommandsOnRankDown; } public void setCommandsOnRankDown(List commandsOnRankDown) { - CommandsOnRankDown = commandsOnRankDown; + CommandsOnRankDown = commandsOnRankDown; } public int getWeight() { - return weight; + return weight; } public void setWeight(int weight) { - this.weight = weight; + this.weight = weight; + } + + public LinkedHashMap getAureliumRequirements() { + return aureliumRequirements; + } + + public void setAureliumRequirements(LinkedHashMap aureliumRequirements) { + this.aureliumRequirements = aureliumRequirements; } } diff --git a/src/com/Zrips/CMI/Modules/Ranks/JobsManager.java b/src/com/Zrips/CMI/Modules/Ranks/JobsManager.java index 0201c2b..9481511 100644 --- a/src/com/Zrips/CMI/Modules/Ranks/JobsManager.java +++ b/src/com/Zrips/CMI/Modules/Ranks/JobsManager.java @@ -8,14 +8,14 @@ public JobsManager() { } public static boolean isJobCorrect(String name) { - return false; + return false; } public static String getRealJobName(String name) { - return null; + return null; } public static int getJobsLevel(Player player, String jobName) { - return 0; + return 0; } } diff --git a/src/com/Zrips/CMI/Modules/Ranks/McMMOManager.java b/src/com/Zrips/CMI/Modules/Ranks/McMMOManager.java index 08c4147..748b2b2 100644 --- a/src/com/Zrips/CMI/Modules/Ranks/McMMOManager.java +++ b/src/com/Zrips/CMI/Modules/Ranks/McMMOManager.java @@ -8,14 +8,14 @@ public McMMOManager() { } public static boolean isSkillCorrect(String name) { - return false; + return false; } public static String getRealSkillName(String name) { - return null; + return null; } public static int getSkillLevel(Player player, String skill) { - return 0; + return 0; } } diff --git a/src/com/Zrips/CMI/Modules/Ranks/RankManager.java b/src/com/Zrips/CMI/Modules/Ranks/RankManager.java index 7373456..78e8717 100644 --- a/src/com/Zrips/CMI/Modules/Ranks/RankManager.java +++ b/src/com/Zrips/CMI/Modules/Ranks/RankManager.java @@ -6,6 +6,7 @@ import java.util.LinkedHashMap; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitScheduler; @@ -21,28 +22,50 @@ public class RankManager { private LinkedHashMap ranks = new LinkedHashMap(); private HashMap nextCheck = new HashMap(); + private HashMap nextAutoRecalculate = new HashMap(); private HashMap nextInform = new HashMap(); private CMI plugin; BukkitScheduler scheduler; public RankManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } private boolean isNextCheck(UUID uuid) { - return false; + return false; + } + + private boolean isNextAutoRecalculate(UUID uuid) { + return false; } private boolean isNextInform(UUID uuid) { - return false; + return false; } public void removeFromCheck(UUID uuid) { + nextCheck.remove(uuid); + nextAutoRecalculate.remove(uuid); + nextInform.remove(uuid); } int sched = -1; + int recSched = -1; public void stop() { + if (sched != -1) { + Bukkit.getScheduler().cancelTask(sched); + sched = -1; + } + if (recSched != -1) { + Bukkit.getScheduler().cancelTask(recSched); + recSched = -1; + } + percentCache.clear(); + } + + public void autoRecheck() { + } public void run() { @@ -54,46 +77,46 @@ public void addRank(CMIRank rank) { } public HashMap getRanks() { - return ranks; + return ranks; } public CMIRank getRank(String name) { - if (name == null) - return null; - return ranks.get(name.toLowerCase()); + if (name == null) + return null; + return ranks.get(name.toLowerCase()); } public CMIRank getDefaultRank(Player player) { - return null; + return null; } public enum rankupFailType { - Money, Exp, Stats, McMMO, Jobs, Perm, None, NoRank, Items, Votes, SameRank + Money, Exp, Stats, McMMO, Aurelium, Jobs, Perm, None, NoRank, Items, Votes, SameRank } public enum rankupType { - Money, Exp, Stats, McMMO, Jobs, Perm, Items, Votes; + Money, Exp, Stats, McMMO, Aurelium, Jobs, Perm, Items, Votes; } public boolean canRankUpAuto(CMIUser user) { - return false; + return true; + } public rankupFailType canRankUp(CMIUser user, CMIRank rank) { - return null; + return rankupFailType.None; } private static HashMap getInvContentsAmounts(Player player) { - - return null; + HashMap map = new HashMap(); + return map; } public boolean removeContents(Player player, LinkedHashMap map) { - - return true; + return true; } public void listStatsRequirements(CommandSender sender, CMIUser user, CMIRank rank) { @@ -101,114 +124,121 @@ public void listStatsRequirements(CommandSender sender, CMIUser user, CMIRank ra } public class rankCurrentRequirement { - private Long need; - private Long have; + private Long need; + private Long have; - public rankCurrentRequirement(Long need, Long have) { - this.have = have; - this.need = need; - } + public rankCurrentRequirement(Long need, Long have) { + this.have = have; + this.need = need; + } - public Long getNeed() { - return need; - } + public Long getNeed() { + return need; + } - public void setNeed(Long need) { - this.need = need; - } + public void setNeed(Long need) { + this.need = need; + } - public Long getHave() { - return have; - } + public Long getHave() { + return have; + } - public void setHave(Long have) { - this.have = have; - } + public void setHave(Long have) { + this.have = have; + } } public HashMap> getStatsRequirements(CMIUser user, CMIRank rank) { + HashMap> haveMap = new HashMap>(); - return null; + return haveMap; } public Double getStatsDonePercentage(CMIUser user, CMIRank rank) { - - return null; + return null; } private static String firstCap(String msg) { - return msg.substring(0, 1).toUpperCase() + msg.substring(1); + return msg.substring(0, 1).toUpperCase() + msg.substring(1); } public Double getOverallDonePercentage(CMIUser user, CMIRank rank) { - return null; + return null; } public Double getMoneyDonePercentage(CMIUser user, CMIRank rank) { - - return null; + return null; } public void listMoneyRequirements(CommandSender sender, CMIUser user, CMIRank rank) { - } public Double getExpDonePercentage(CMIUser user, CMIRank rank) { - - return null; + return null; } public void listExpRequirements(CommandSender sender, CMIUser user, CMIRank rank) { - } public Double getVoteDonePercentage(CMIUser user, CMIRank rank) { - - return null; + if (rank.getVotes() <= 0 || !plugin.isVotifierEnabled()) + return null; + int have = user.getVotifierVotes(); + if (have > rank.getVotes()) + return 100D; + return (have * 100D) / ((double) rank.getVotes()); } public void listVoteRequirements(CommandSender sender, CMIUser user, CMIRank rank) { - } public void listPermRequirements(CommandSender sender, CMIUser user, CMIRank rank) { - } public class rankCache { - HashMap percentage = new HashMap(); - HashMap nextPercentageCheck = new HashMap(); + HashMap percentage = new HashMap(); + HashMap nextPercentageCheck = new HashMap(); - public rankCache() { + public rankCache() { - } + } - public boolean timeToCheck(rankupType type) { - return !nextPercentageCheck.containsKey(type) || nextPercentageCheck.get(type) < System.currentTimeMillis(); - } + public boolean timeToCheck(rankupType type) { + return !nextPercentageCheck.containsKey(type) || nextPercentageCheck.get(type) < System.currentTimeMillis(); + } - public Double getCache(rankupType type) { - return percentage.get(type); - } + public Double getCache(rankupType type) { + return percentage.get(type); + } - public void setCache(rankupType type, Double percent) { - percentage.put(type, percent); - nextPercentageCheck.put(type, System.currentTimeMillis() + 5000L); - } + public void setCache(rankupType type, Double percent) { + percentage.put(type, percent); + nextPercentageCheck.put(type, System.currentTimeMillis() + 5000L); + } } HashMap percentCache = new HashMap(); public Double getPermDonePercentage(CMIUser user, CMIRank rank) { - return null; + return null; + } + + public Double getAureliumDonePercentage(CMIUser user, CMIRank rank) { + + return null; + } + + public void listAureliumRequirements(CommandSender sender, CMIUser user, CMIRank rank) { + } public Double getMcMMODonePercentage(CMIUser user, CMIRank rank) { - return null; + return null; } public void listMcmmoRequirements(CommandSender sender, CMIUser user, CMIRank rank) { @@ -217,7 +247,7 @@ public void listMcmmoRequirements(CommandSender sender, CMIUser user, CMIRank ra public Double getJobsDonePercentage(CMIUser user, CMIRank rank) { - return null; + return null; } public void listJobsRequirements(CommandSender sender, CMIUser user, CMIRank rank) { @@ -226,7 +256,7 @@ public void listJobsRequirements(CommandSender sender, CMIUser user, CMIRank ran public Double getItemDonePercentage(CMIUser user, CMIRank rank) { - return null; + return null; } public void listItemRequirements(CommandSender sender, CMIUser user, CMIRank rank) { @@ -235,14 +265,14 @@ public void listItemRequirements(CommandSender sender, CMIUser user, CMIRank ran public String translateValue(CMIStatistic stat, Long value) { - return null; + return null; } NumberFormat formatter = new DecimalFormat("#0.00"); private String convertDistance(long distance) { - return null; + return null; } @SuppressWarnings("unchecked") @@ -251,16 +281,11 @@ public void load() { } private void calculateWeight(CMIRank rank, int weight) { - weight++; - if (weight > 1000) - return; - rank.setWeight(weight); - for (CMIRank one : rank.getNextRanks()) { - calculateWeight(one, weight); - } + } private int Delay = 30; + private int Recalculation = 0; private boolean OnlyHours = false; private boolean includeMinutes = false; private boolean async = false; @@ -276,22 +301,22 @@ public void loadConfig() { } public boolean isProgressBar() { - return progressBar; + return progressBar; } public boolean isListSamePathOnly() { - return ListSamePathOnly; + return ListSamePathOnly; } public CMIPresetAnimations getRankEffect() { - return RanksEffect; + return RanksEffect; } public boolean isPermissionCheck() { - return permissionCheck; + return permissionCheck; } public boolean isStrictPermissionCheck() { - return strictPermissionCheck; + return strictPermissionCheck; } } diff --git a/src/com/Zrips/CMI/Modules/Recipes/CMIRecipe.java b/src/com/Zrips/CMI/Modules/Recipes/CMIRecipe.java deleted file mode 100644 index 0e23778..0000000 --- a/src/com/Zrips/CMI/Modules/Recipes/CMIRecipe.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.Zrips.CMI.Modules.Recipes; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - -import org.bukkit.inventory.FurnaceRecipe; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.Recipe; -import org.bukkit.inventory.ShapedRecipe; -import org.bukkit.inventory.ShapelessRecipe; - -import com.Zrips.CMI.Modules.Recipes.RecipeManager.CMIRecipeType; - -public class CMIRecipe { - - private Recipe recipe = null; - private Integer identificator = null; - private CMIRecipeType type = null; - - public CMIRecipe(Integer identificator, CMIRecipeType type) { - this.identificator = identificator; - this.type = type; - } - - public Integer getIdentificator() { - return identificator; - } - - public CMIRecipe setIdentificator(Integer identificator) { - this.identificator = identificator; - return this; - } - - public Recipe getRecipe() { - return recipe; - } - - public CMIRecipe setRecipe(Recipe recipe) { - this.recipe = recipe; - return this; - } - - public CMIRecipeType getType() { - return type; - } - - public CMIRecipe setType(CMIRecipeType type) { - this.type = type; - return this; - } - - public ItemStack getResult() { - return this.recipe.getResult(); - } - - public HashMap getIngridients() { - - return null; - } - -} diff --git a/src/com/Zrips/CMI/Modules/Recipes/FurnaceTempData.java b/src/com/Zrips/CMI/Modules/Recipes/FurnaceTempData.java deleted file mode 100644 index 6a9d8b9..0000000 --- a/src/com/Zrips/CMI/Modules/Recipes/FurnaceTempData.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.Zrips.CMI.Modules.Recipes; - -import net.Zrips.CMILib.Version.Version; - -public class FurnaceTempData { - - private float exp = 0; - private int cookingTime = 20; - - public FurnaceTempData(float exp, int cookingTime) { - this.exp = exp; - this.cookingTime = cookingTime; - } - - public float getExp() { - return exp; - } - - public void setExp(float exp) { - if (Version.isCurrentEqualOrHigher(Version.v1_17_R1) && exp > 2) - exp = 2; - else if (!Version.isCurrentEqualOrHigher(Version.v1_17_R1) && exp > 1) - exp = 1; - if (exp < 0) - exp = 0; - this.exp = exp; - } - - public int getCookingTime() { - return cookingTime; - } - - public void setCookingTime(int cookingTime) { - this.cookingTime = cookingTime; - } - -} diff --git a/src/com/Zrips/CMI/Modules/Recipes/RecipeListener.java b/src/com/Zrips/CMI/Modules/Recipes/RecipeListener.java deleted file mode 100644 index 575be32..0000000 --- a/src/com/Zrips/CMI/Modules/Recipes/RecipeListener.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.Zrips.CMI.Modules.Recipes; - -import org.bukkit.event.Listener; - -import com.Zrips.CMI.CMI; - -public class RecipeListener implements Listener { - CMI plugin; - - public RecipeListener(CMI plugin) { - this.plugin = plugin; - } - -} diff --git a/src/com/Zrips/CMI/Modules/Recipes/RecipeManager.java b/src/com/Zrips/CMI/Modules/Recipes/RecipeManager.java index 13478b9..68504b2 100644 --- a/src/com/Zrips/CMI/Modules/Recipes/RecipeManager.java +++ b/src/com/Zrips/CMI/Modules/Recipes/RecipeManager.java @@ -1,11 +1,9 @@ package com.Zrips.CMI.Modules.Recipes; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map.Entry; +import java.util.Set; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -14,115 +12,73 @@ import com.Zrips.CMI.CMI; import net.Zrips.CMILib.Items.CMIItemStack; +import net.Zrips.CMILib.Recipes.CMIRecipe; +import net.Zrips.CMILib.Recipes.CMIRecipeCraftData; +import net.Zrips.CMILib.Recipes.CMIRecipeIngredient; +import net.Zrips.CMILib.Recipes.CMIRecipeType; public class RecipeManager { private CMI plugin; public RecipeManager(CMI plugin) { - this.plugin = plugin; - try { - loadRecipes(); - } catch (Exception e) { - e.printStackTrace(); - } + this.plugin = plugin; + try { + loadRecipes(); + } catch (Exception e) { + e.printStackTrace(); + } } - private List GUIRecipeIngridientsSlots = new ArrayList(Arrays.asList(11, 12, 13, 20, 21, 22, 29, 30, 31)); - private Integer GUIRecipeFurnacetSlot = 20; - private Integer GUIRecipeSmithingSlot = 21; + private HashMap disabledRecipes = new HashMap(); + private Integer GUIRecipeResultSlot = 24; private List recipes = new ArrayList(); - private Integer lastId = 0; - - public enum CMIRecipeType { - Shaped, Shapeless, Furnace, Blasting, Campfire, Cooking, Merchant, Smoking, Stonecutting, Smithing, Complex, Unknown; - - public static CMIRecipeType getByName(String name) { - - return null; - } - } - public CMIRecipe getById(Integer id) { - if (id == null) - return null; - for (CMIRecipe one : recipes) { - if (one.getIdentificator() == id) - return one; - } - return null; + public CMIRecipe getById(String id) { + return null; } public boolean removeRecipe(CMIRecipe recipe) { - recipes.remove(recipe); - this.saveRecipes(); - return true; - } - - public static int getIndex(LinkedHashMap itemsused, Object value) { - int result = 0; - for (Entry entry : itemsused.entrySet()) { - if (entry.getKey().equals(value)) - return result; - result++; - } - return -1; - } - - @SuppressWarnings("deprecation") - public Recipe MakeShapedRecipe(ItemStack result, HashMap Recipe) { - - return null; - } - - @SuppressWarnings("deprecation") - public Recipe MakeShaplessRecipe(ItemStack result, HashMap Recipe) { - - return null; + recipes.remove(recipe); + this.saveRecipes(); + return true; } - public Recipe MakeFurnaceRecipe(ItemStack result, ItemStack Recipe) { - return MakeFurnaceRecipe(result, Recipe, null); + public Recipe addRecipe(CMIRecipeType type, ItemStack result, HashMap Recipe) { + return addRecipe(type, result, Recipe, null); } - public Recipe MakeFurnaceRecipe(ItemStack result, ItemStack Recipe, FurnaceTempData temp) { - - return null; + public Recipe addRecipe(CMIRecipeType type, ItemStack result, HashMap Recipe, CMIRecipeCraftData temp) { + return addRecipe(type, result, Recipe, temp, null); } - public Recipe createRecipe(CMIRecipeType type, ItemStack result, HashMap Recipe) { - return createRecipe(type, result, Recipe, null); + public Recipe addRecipe(CMIRecipeType type, ItemStack result, HashMap Recipe, CMIRecipeCraftData temp, String customKey) { + return null; } - public Recipe createRecipe(CMIRecipeType type, ItemStack result, HashMap Recipe, FurnaceTempData temp) { - - return null; - } - - public Recipe addRecipe(CMIRecipeType type, ItemStack result, HashMap Recipe) { - return addRecipe(type, result, Recipe, null); + @Deprecated + public Recipe addRecipe(CMIRecipeType type, Recipe recipe) { + return addRecipe(type, recipe, null); } - public Recipe addRecipe(CMIRecipeType type, ItemStack result, HashMap Recipe, FurnaceTempData temp) { - - return null; + public Recipe addRecipe(CMIRecipeType type, Recipe recipe, CMIRecipeCraftData data) { + return addRecipe(type, recipe, data, null); } - public Recipe addRecipe(CMIRecipeType type, Recipe recipe) { - - return null; + public Recipe addRecipe(CMIRecipeType type, Recipe recipe, CMIRecipeCraftData data, String customKey) { + return null; } public Recipe exist(Recipe recipe) { - return null; + return null; } - public Recipe getRecipe(HashMap ingridients) { + public Recipe getRecipe(HashMap ingredients) { - return null; + return null; } private void saveRecipes() { @@ -130,63 +86,38 @@ private void saveRecipes() { } private void loadRecipes() { - - } - public List getGUIRecipeIngridientsSlots(CMIRecipeType type) { - if (type.equals(CMIRecipeType.Furnace)) - return new ArrayList(this.GUIRecipeFurnacetSlot); - return GUIRecipeIngridientsSlots; } -// public void setGUIRecipeIngridientsSlots(List gUIRecipeIngridientsSlots) { -// GUIRecipeIngridientsSlots = gUIRecipeIngridientsSlots; -// } - public Integer getGUIRecipeResultSlot() { - return GUIRecipeResultSlot; - } - - public void setGUIRecipeResultSlot(Integer gUIRecipeResultSlot) { - GUIRecipeResultSlot = gUIRecipeResultSlot; + return GUIRecipeResultSlot; } public List getRecipes() { - return recipes; + return recipes; } @Deprecated public void setRecipes(List recipes) { - this.recipes = recipes; + this.recipes = recipes; } - public Integer getLastId() { - return lastId; - } - - public void setLastId(Integer lastId) { - this.lastId = lastId; - } - - public Integer getGUIRecipeFurnacetSlot() { - return GUIRecipeFurnacetSlot; + public Boolean openRecipeUI(Player player, CMIItemStack cm, int page) { + return openRecipeUI(player, cm, page, false); } - public void setGUIRecipeFurnacetSlot(Integer gUIRecipeFurnacetSlot) { - GUIRecipeFurnacetSlot = gUIRecipeFurnacetSlot; + public Boolean openRecipeUI(Player player, CMIItemStack cm, int page, boolean onlyCustom) { + return null; } - public List getIngredientsList(Recipe recipe) { + public Boolean openRecipeUI(Player player, CMIItemStack cm, int page, List recipes) { - return null; + return null; } - public Boolean openRecipeUI(Player player, CMIItemStack cm, int page) { + private Set getDisabled(ItemStack item) { - return null; + return null; } - public Integer getGUIRecipeSmithingSlot() { - return GUIRecipeSmithingSlot; - } } diff --git a/src/com/Zrips/CMI/Modules/Recipes/recipeInformation.java b/src/com/Zrips/CMI/Modules/Recipes/recipeInformation.java new file mode 100644 index 0000000..5b894b5 --- /dev/null +++ b/src/com/Zrips/CMI/Modules/Recipes/recipeInformation.java @@ -0,0 +1,35 @@ +package com.Zrips.CMI.Modules.Recipes; + +import net.Zrips.CMILib.Recipes.CMIRecipeCraftData; + +public class recipeInformation { + + private boolean exact = true; + private String customId = null; + private CMIRecipeCraftData craftData = null; + + public boolean isExact() { + return exact; + } + + public void setExact(boolean exact) { + this.exact = exact; + } + + public String getCustomId() { + return customId; + } + + public void setCustomId(String customId) { + this.customId = customId; + } + + public CMIRecipeCraftData getCraftData() { + return craftData; + } + + public void setCraftData(CMIRecipeCraftData craftData) { + this.craftData = craftData; + } + +} diff --git a/src/com/Zrips/CMI/Modules/Region/RegionListener.java b/src/com/Zrips/CMI/Modules/Region/RegionListener.java index e020957..a07dfdb 100644 --- a/src/com/Zrips/CMI/Modules/Region/RegionListener.java +++ b/src/com/Zrips/CMI/Modules/Region/RegionListener.java @@ -8,7 +8,7 @@ public class RegionListener implements Listener { private CMI plugin; public RegionListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } } diff --git a/src/com/Zrips/CMI/Modules/Region/WorldInfo.java b/src/com/Zrips/CMI/Modules/Region/WorldInfo.java index d4925db..0a848ef 100644 --- a/src/com/Zrips/CMI/Modules/Region/WorldInfo.java +++ b/src/com/Zrips/CMI/Modules/Region/WorldInfo.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + import org.bukkit.Chunk; import org.bukkit.World; @@ -19,132 +20,119 @@ public class WorldInfo { private Integer range = null; @Override - public WorldInfo clone(){ - WorldInfo wi = new WorldInfo(world, center); - wi.setRegion(new HashMap>(regionChunks)); - wi.setTotalChunks(totalChunks); - return wi; + public WorldInfo clone() { + WorldInfo wi = new WorldInfo(world, center); + wi.setRegion(new HashMap>(regionChunks)); + wi.setTotalChunks(totalChunks); + return wi; } - + public WorldInfo(World world, CMIRegion center) { - this.world = world; - this.center = center; + this.world = world; + this.center = center; } - + public void setRegion(Map> regionChunks) { - this.regionChunks = regionChunks; + this.regionChunks = regionChunks; } - + public Map> getRegion() { - return regionChunks; + return regionChunks; } private static String toString(CMIRegion cord) { - return cord.getX() + ":" + cord.getZ(); + return cord.getX() + ":" + cord.getZ(); } public Boolean getRegionsChunk(CMIRegion region, int place) { - List chunks = regionChunks.get(toString(region)); -// for (Entry> one : regionChunks.entrySet()) { -// if (one.getKey().getX() == region.getX() && one.getKey().getZ() == region.getZ()) -// chunks = one.getValue(); -// } - - if (chunks == null) - return null; - return chunks.get(place); + return null; } public List getRegionPlaces(CMIRegion region) { -// List chunks = ; -// for (Entry> one : regionChunks.entrySet()) { -// if (one.getKey().getX() == region.getX() && one.getKey().getZ() == region.getZ()) -// chunks = one.getValue(); -// } - return regionChunks.get(toString(region)); + return null; } public WorldInfo setRegionPlaces(CMIRegion region, List places) { - regionChunks.put(toString(region), places); - return this; + regionChunks.put(toString(region), places); + return this; } public CMIRegion getNextChunkLoc(boolean exist) { - return CMI.getInstance().getRegionManager().getNextChunkLocation(this, exist); + return CMI.getInstance().getRegionManager().getNextChunkLocation(this, exist); } public Chunk getNextChunk(boolean exist) { - return CMI.getInstance().getRegionManager().getNextChunk(this, exist); + return CMI.getInstance().getRegionManager().getNextChunk(this, exist); } public void setRegionChunks(CMIRegion scord, List list) { - this.regionChunks.put(toString(scord), list); + this.regionChunks.put(toString(scord), list); } public CMIRegion getCenter() { - if (center == null) - center = new CMIRegion(0, 0); - return center; + if (center == null) + center = new CMIRegion(0, 0); + return center; } public void setCenter(CMIRegion center) { - this.center = center; + this.center = center; } public long getTotalChunks() { - return totalChunks; + return totalChunks; } public void setTotalChunks(long totalChunks) { - this.totalChunks = totalChunks; + this.totalChunks = totalChunks; } public void addTotalChunks(int chunks) { - this.totalChunks += chunks; + this.totalChunks += chunks; } public void addTotalChunks() { - this.totalChunks++; + this.totalChunks++; } public long getLastChecked() { - return lastChecked; + return lastChecked; } public boolean allChecked() { - return lastChecked >= totalChunks; + return lastChecked >= totalChunks; } public long getLeftToScan() { - return totalChunks - lastChecked < 0L ? 0L : totalChunks - lastChecked; + return totalChunks - lastChecked < 0L ? 0L : totalChunks - lastChecked; } public long getNextPlace() { - return lastChecked + 1; + return lastChecked + 1; } public void setLastChecked(long lastChecked) { - this.lastChecked = lastChecked; + this.lastChecked = lastChecked; } public void addLastChecked() { - this.lastChecked++; + this.lastChecked++; } public World getWorld() { - return world; + return world; } public void setWorld(World world) { - this.world = world; + this.world = world; } public Integer getRange() { - return range; + return range; } public void setRange(Integer range) { - this.range = range; + this.range = range; } } diff --git a/src/com/Zrips/CMI/Modules/Region/WorldManager.java b/src/com/Zrips/CMI/Modules/Region/WorldManager.java index 1cb0938..a73b9e8 100644 --- a/src/com/Zrips/CMI/Modules/Region/WorldManager.java +++ b/src/com/Zrips/CMI/Modules/Region/WorldManager.java @@ -1,14 +1,8 @@ package com.Zrips.CMI.Modules.Region; -import java.io.File; -import java.io.RandomAccessFile; -import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.Map.Entry; -import java.util.regex.Matcher; import java.util.regex.Pattern; import org.bukkit.Chunk; @@ -25,109 +19,110 @@ public class WorldManager { BukkitTask task = null; public void cancelLoading() { - if (task != null) - task.cancel(); + if (task != null) + task.cancel(); } public boolean stillLoading(World world) { - return false; + if (world == null) + return stillLoading(); + if (!worldMap.containsKey(world.getName()) && stillLoading()) + return true; + return false; } public boolean stillLoading() { - return task != null; + return task != null; } public WorldManager(final CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void removeWorldInfo(World world) { - worldMap.remove(world.getName()); + worldMap.remove(world.getName()); } public void loadWorldChunksInfo(final World world) { } - public void addChunk(Chunk chunk) { - + } public WorldInfo getWorldInfoInRange(World world, CMIRegion center, Integer range) { - return null; + return null; } public WorldInfo getWorldInfoFromWorld(World world) { - return worldMap.get(world.getName()); + return worldMap.get(world.getName()); } public CMIRegion getNextInSpiral(long place) { - - return null; + return null; } public CMIRegion getNextChunkLocation(WorldInfo info, boolean existing) { - - return null; + + return null; } public Chunk getNextChunk(WorldInfo info, boolean existing) { - - return null; + return null; + } public WorldInfo getWorldInfo(World world, CMIRegion center, Integer range) { - return null; + return null; } public WorldInfo fillEmpty(World world, CMIRegion center, Integer range) { - return null; + return null; } public WorldInfo getWorldInfo(World world, CMIRegion center) { - return null; + return null; } private static boolean inRange(CMIRegion center, CMIRegion scord, Integer range) { - return false; + return false; } public HashMap getRegionFiles(World world) { - - return null; + + return null; } public HashMap getRegionFiles(CMIRegion center, Integer range) { - - return null; - } + return null; + } private static CMIRegion getRegionCord(CMIRegion scord) { - return getRegionCord(scord.getX(), scord.getZ()); + return getRegionCord(scord.getX(), scord.getZ()); } private static CMIRegion getRegionCord(int x, int z) { - return new CMIRegion(x >> 5, z >> 5); + return new CMIRegion(x >> 5, z >> 5); } private static CMIRegion getRealChunkFromPlace(CMIRegion region, int place) { - CMIRegion t = getCordFromPlace(place); - return new CMIRegion(region.getX() * 32 + t.getX(), region.getZ() * 32 + t.getZ()); + CMIRegion t = getCordFromPlace(place); + return new CMIRegion(region.getX() * 32 + t.getX(), region.getZ() * 32 + t.getZ()); } private static CMIRegion getCordFromPlace(int place) { - return new CMIRegion(place % 32, place / 32); + return new CMIRegion(place % 32, place / 32); } private static int CoordToChunkPlace(int x, int z) { - return x + (z * 32); + return x + (z * 32); } } diff --git a/src/com/Zrips/CMI/Modules/Repair/RepairListener.java b/src/com/Zrips/CMI/Modules/Repair/RepairListener.java index 5464438..ef75586 100644 --- a/src/com/Zrips/CMI/Modules/Repair/RepairListener.java +++ b/src/com/Zrips/CMI/Modules/Repair/RepairListener.java @@ -1,19 +1,12 @@ package com.Zrips.CMI.Modules.Repair; -import java.util.UUID; - -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.inventory.ItemStack; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.NBT.CMINBT; -import com.Zrips.CMI.Modules.AttachedCommands.CustomNBTManager.CustomNBTType; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; import com.Zrips.CMI.events.CMIAnvilItemRepairEvent; import com.Zrips.CMI.events.CMIArmorChangeEvent; @@ -21,7 +14,26 @@ public class RepairListener implements Listener { private CMI plugin; public RepairListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void CMIAnvilItemRepairEvent(CMIAnvilItemRepairEvent event) { + } + + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerItemHeldEvent(PlayerPickupItemEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerItemHeldEvent(PlayerItemHeldEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void CMIArmorChangeEvent(CMIArmorChangeEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/ReplaceBlock/BRInfo.java b/src/com/Zrips/CMI/Modules/ReplaceBlock/BRInfo.java index 3c50215..fe706ca 100644 --- a/src/com/Zrips/CMI/Modules/ReplaceBlock/BRInfo.java +++ b/src/com/Zrips/CMI/Modules/ReplaceBlock/BRInfo.java @@ -28,8 +28,6 @@ public class BRInfo { private boolean running = false; -// private int wId = 0; -// private short wData = -1; private int y = -1; private long replaced = 0L; @@ -44,133 +42,133 @@ public BRInfo() { } public void setY(int y) { - this.y = y; + this.y = y; } public int getY() { - if (this.y == -1) - this.y = this.RI.getWorld().getMaxHeight(); - return this.y; + if (this.y == -1) + this.y = this.RI.getWorld().getMaxHeight(); + return this.y; } public void addReplaced() { - this.replaced++; + this.replaced++; } public long getReplaced() { - return this.replaced; + return this.replaced; } public void setscheduleId(int id) { - this.scheduleId = id; + this.scheduleId = id; } public int getScheduleId() { - return this.scheduleId; + return this.scheduleId; } public void setShowInfo(long time) { - this.showedInfo = time; + this.showedInfo = time; } public long getShowInfo() { - return this.showedInfo; + return this.showedInfo; } public void setAutoSpeed(boolean autoSpeed) { - this.autoSpeed = autoSpeed; + this.autoSpeed = autoSpeed; } public boolean isAutoSpeed() { - return this.autoSpeed; + return this.autoSpeed; } public void setMessages(boolean messages) { - this.messages = messages; + this.messages = messages; } public boolean isMessages() { - return this.messages; + return this.messages; } public void setShowInfo(boolean state) { - this.showInfo = state; + this.showInfo = state; } public boolean isShowInfo() { - return this.showInfo; + return this.showInfo; } public void setSpeed(int speed) { - this.speed = speed; + this.speed = speed; } public int getSpeed() { - return this.speed; + return this.speed; } public void setRunning(boolean state) { - this.running = state; + this.running = state; } public boolean isRunning() { - return this.running; + return this.running; } public void setStartTime() { - this.startTime = System.currentTimeMillis(); + this.startTime = System.currentTimeMillis(); } public long getStartTime() { - return this.startTime; + return this.startTime; } public String getPlayerName() { - return this.Playername; + return this.Playername; } public Player getPlayer() { - Player p = Bukkit.getPlayer(this.player.getUniqueId()); - if (p != null) - this.player = p; - return this.player; + Player p = Bukkit.getPlayer(this.player.getUniqueId()); + if (p != null) + this.player = p; + return this.player; } public void setPlayer(Player Player) { - this.Playername = Player.getName(); - this.player = Player; + this.Playername = Player.getName(); + this.player = Player; } public void addItemInfo(itemInfo info) { - this.itemIds.add(info); + this.itemIds.add(info); } public List getItemInfo() { - return itemIds; + return itemIds; } - + public void addReplaceInfo(itemInfo info) { - this.replaceIds.add(info); + this.replaceIds.add(info); } - + public List getReplaceInfo() { - return replaceIds; + return replaceIds; } public void setTotal(double d) { - this.d = d; + this.d = d; } public double getTotal() { - return d; + return d; } public WorldInfo getRI() { - return RI; + return RI; } public void setRI(WorldInfo rI) { - RI = rI; + RI = rI; } } diff --git a/src/com/Zrips/CMI/Modules/ReplaceBlock/ReplaceBlock.java b/src/com/Zrips/CMI/Modules/ReplaceBlock/ReplaceBlock.java index fc9613e..f696c2c 100644 --- a/src/com/Zrips/CMI/Modules/ReplaceBlock/ReplaceBlock.java +++ b/src/com/Zrips/CMI/Modules/ReplaceBlock/ReplaceBlock.java @@ -13,13 +13,13 @@ public class ReplaceBlock { private CMI plugin; public ReplaceBlock(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void start(final BRInfo scan) { - if (scan.getStartTime() == 0L) - scan.setShowInfo(System.currentTimeMillis()); - loadChunk(scan); + if (scan.getStartTime() == 0L) + scan.setShowInfo(System.currentTimeMillis()); + loadChunk(scan); } private void loadChunk(final BRInfo scan) { diff --git a/src/com/Zrips/CMI/Modules/SavedInv/SaveInvListener.java b/src/com/Zrips/CMI/Modules/SavedInv/SaveInvListener.java index 00b0c69..8419cc8 100644 --- a/src/com/Zrips/CMI/Modules/SavedInv/SaveInvListener.java +++ b/src/com/Zrips/CMI/Modules/SavedInv/SaveInvListener.java @@ -1,6 +1,12 @@ package com.Zrips.CMI.Modules.SavedInv; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.InventoryDragEvent; import com.Zrips.CMI.CMI; @@ -9,7 +15,26 @@ public class SaveInvListener implements Listener { private CMI plugin; public SaveInvListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onPlayerDeath(PlayerDeathEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onInventoryClick(InventoryClickEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onInventoryDrag(InventoryDragEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onNormalInventoryClose(InventoryCloseEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/SavedInv/SavedInventoryManager.java b/src/com/Zrips/CMI/Modules/SavedInv/SavedInventoryManager.java index 2b497e7..5eed3ce 100644 --- a/src/com/Zrips/CMI/Modules/SavedInv/SavedInventoryManager.java +++ b/src/com/Zrips/CMI/Modules/SavedInv/SavedInventoryManager.java @@ -21,114 +21,117 @@ public class SavedInventoryManager { private CMI plugin; public SavedInventoryManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } private SavedInventories getInventories(UUID uuid) { - return map.get(uuid); + return map.get(uuid); } public void addInventory(CMIUser user, CMIInventory inventory) { - addInventory(user, inventory, null); + addInventory(user, inventory, null); } public void addInventory(CMIUser user, CMIInventory inventory, Integer id) { } private void checkInvLimit(SavedInventories inventories) { - } public CMIInventory getInvById(CMIUser user, int id) { - return null; + + return null; } public CMIInventory getFirstInv(CMIUser user) { - return getFirstInv(getInventories(user)); + return getFirstInv(getInventories(user)); } public CMIInventory getFirstInv(SavedInventories inventories) { - return null; + return null; } public CMIInventory getLastInv(CMIUser user) { - return null; + return null; } public CMIInventory getNextInv(CMIUser user, int id) { - - return null; + + return null; } public CMIInventory getPrevInv(CMIUser user, int id) { - - return null; + + return null; } public SavedInventories getInventories(CMIUser user) { - - return null; + + return null; } public void loadInventories(CMIUser user) { - } public void loadInventories(CMIUser user, String invString) { - + } public boolean saveAllInventories(UUID uuid) { - - return true; + + return true; } public CMIInventory saveInv(Player player, Entity killer, DamageCause cause) { - return saveInv(player, killer, cause, null); + return saveInv(player, killer, cause, null); } public CMIInventory saveInv(Player player, Entity killer, DamageCause cause, Integer id) { - return null; + CMIUser user = plugin.getPlayerManager().getUser(player); + if (user == null) + return null; + + return saveInv(generateCMIInventory(player, killer, cause), id); } public CMIInventory saveInv(CMIInventory inv, Integer id) { - - return null; + + return null; } public CMIInventory generateCMIInventory(Player player, Entity killer, DamageCause cause) { - return generateCMIInventory(new CMIInventory(player.getName(), player.getUniqueId()), killer, cause); + return generateCMIInventory(new CMIInventory(player.getName(), player.getUniqueId()), killer, cause); } @SuppressWarnings("deprecation") public CMIInventory generateCMIInventory(CMIInventory cmiI, Entity killer, DamageCause cause) { - return null; + return null; } @SuppressWarnings("unchecked") public CMIInventory generateInvFromMap(HashMap map) { - return null; + return null; } public HashMap generateMapFromPlayerInv(CMIInventory inv) { - - return null; + + return null; } private static String serialize(HashMap map) { - - return null; + + return null; } @SuppressWarnings("unchecked") private static HashMap deserialize(String string) { - - return null; + + return null; } private void fillFields(CMIGui gui, CMIInventory inv) { @@ -140,31 +143,30 @@ public void updateCMIInventoryItems(Inventory top, CMIInventory inv) { } public void openSavedInv(Player player, CMIInventory inv, boolean preview) { - + } public void InvList(CommandSender sender, Player player) { + CMIUser user = plugin.getPlayerManager().getUser(player); + InvList(sender, user); } public void InvList(CommandSender sender, CMIUser user) { - } @SuppressWarnings("deprecation") public boolean loadInv(CommandSender sender, CMIUser user, CMIInventory inv) { - - return true; + return true; } public boolean removeInventory(CMIUser user, int id) { - - return true; + + return true; } public int showTimer(Player player, int current, int found, int total, int skipped, int currentplace) { - - return 1; + return 1; } private Boolean restoreHP = true; @@ -179,26 +181,26 @@ public int showTimer(Player player, int current, int found, int total, int skipp private int SavedInventorys = 10; public void loadConfig() { - + } public Boolean isSaveOnDeath() { - return SaveOnDeath; + return SaveOnDeath; } public Boolean isSaveOnDeathRequiresPermission() { - return SaveOnDeathRequiresPermission; + return SaveOnDeathRequiresPermission; } public int getMaxSavedInventorys() { - return SavedInventorys; + return SavedInventorys; } public ConcurrentHashMap getMap() { - return map; + return map; } public void clearAll() { - map.clear(); + map.clear(); } } diff --git a/src/com/Zrips/CMI/Modules/SavedItems/SavedItemManager.java b/src/com/Zrips/CMI/Modules/SavedItems/SavedItemManager.java index 0412568..98d3fa9 100644 --- a/src/com/Zrips/CMI/Modules/SavedItems/SavedItemManager.java +++ b/src/com/Zrips/CMI/Modules/SavedItems/SavedItemManager.java @@ -1,29 +1,13 @@ package com.Zrips.CMI.Modules.SavedItems; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Random; import java.util.Set; -import org.bukkit.Bukkit; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.CMILib; -import net.Zrips.CMILib.Colors.CMIChatColor; -import com.Zrips.CMI.Containers.Snd; -import net.Zrips.CMILib.Items.CMIItemStack; - public class SavedItemManager { private LinkedHashMap> map = new LinkedHashMap>(); @@ -31,47 +15,60 @@ public class SavedItemManager { private CMI plugin; public SavedItemManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void addSavedItem(SavedItem savedItem) { + + } + + public boolean removeSavedItem(SavedItem savedItem) { + return removeSavedItem(savedItem.getCategory(), savedItem.getName()); } public boolean removeSavedItem(String category, String name) { - return false; + + return false; + } public SavedItem getSavedItem(String category, String name) { - return null; + + return null; } public LinkedHashMap> getSavedItemMap() { - return map; + return map; } public Set getSavedItems(String category) { - return null; + + return null; + } + + public void load() { + } public int savedItemCount() { - int count = 0; - for (LinkedHashMap one : this.map.values()) { - count += one.size(); - } - return count; + int count = 0; + for (LinkedHashMap one : this.map.values()) { + count += one.size(); + } + return count; } public void save() { - + } public ItemStack getUpatedItemClone(Player player, SavedItem savedItem) { - return null; + return null; } public String processText(String text, Player player, SavedItem savedItem) { - - return null; + + return null; } } diff --git a/src/com/Zrips/CMI/Modules/Scan/Scan.java b/src/com/Zrips/CMI/Modules/Scan/Scan.java index cb7c31e..bd851c7 100644 --- a/src/com/Zrips/CMI/Modules/Scan/Scan.java +++ b/src/com/Zrips/CMI/Modules/Scan/Scan.java @@ -1,8 +1,6 @@ package com.Zrips.CMI.Modules.Scan; -import java.util.ArrayList; import java.util.List; -import java.util.Map.Entry; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Pattern; @@ -25,64 +23,35 @@ public class Scan { private CMI plugin; public Scan(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void start(final ScanInfo scan) { - if (scan.getStartTime() == 0L) - scan.setShowInfo(System.currentTimeMillis()); - loadChunk(scan); + if (scan.getStartTime() == 0L) + scan.setShowInfo(System.currentTimeMillis()); + loadChunk(scan); } private void loadChunk(final ScanInfo scan) { } - private static void RemoveItemsFromBlock(List toRemove, Block block) { - - } - - private void RemoveItemsFromEntity(List toRemove, Entity ent) { - - } - public boolean isValidContainer(Block block) { - return block.getState() instanceof InventoryHolder; - } - - private static ScanResultLocations checkArmorStand(ScanResultLocations ScanResult, Entity oneEnt) { - - return null; - } - - private static void removeFromArmorStand(List toRemove, Entity oneEnt) { - + return block.getState() instanceof InventoryHolder; } - public List CheckContent(ScanInfo scan, ScanResultLocations ScanResult, Block block, Entity ent) { + public List CheckContent(ScanInfo scan, ScanResultLocations scanResult, Block block, Entity ent) { - return null; + return null; } @SuppressWarnings("incomplete-switch") public Location findLocation(Location loc, BlockFace oldDir, boolean checkDouble, int rotate) { - return null; + return null; } public void setCheckedPlace(Player player, int id) { - ScanInfo scan = ScanInfo.get(player.getUniqueId()); - if (scan == null) - return; - - base: for (Entry> one : scan.getLocations().entrySet()) { - for (ScanResultLocations oneLoc : one.getValue()) { - if (oneLoc.getId() == id) { - oneLoc.setChecked(true); - break base; - } - } - } } } diff --git a/src/com/Zrips/CMI/Modules/Scan/ScanInfo.java b/src/com/Zrips/CMI/Modules/Scan/ScanInfo.java index 7faf32a..194a1e2 100644 --- a/src/com/Zrips/CMI/Modules/Scan/ScanInfo.java +++ b/src/com/Zrips/CMI/Modules/Scan/ScanInfo.java @@ -54,183 +54,175 @@ public ScanInfo() { } public HashMap> getLocations() { - return this.multimap; + return this.multimap; } public void addLocation(int amount, ScanResultLocations location) { - if (multimap.containsKey(amount)) { - ArrayList list = multimap.get(amount); - list.add(location); - multimap.put(amount, list); - } else { - ArrayList list = new ArrayList(); - list.add(location); - multimap.put(amount, list); - } + } public int getCurrentId() { - return this.currentId; + return this.currentId; } public void setCurrentId(int id) { - this.currentId = id; + this.currentId = id; } public void setPurge(boolean state) { - this.purge = state; + this.purge = state; } public boolean isPurge() { - return this.purge; + return this.purge; } public void setOversize(boolean state) { - this.oversize = state; + this.oversize = state; } public boolean isOversize() { - return this.oversize; + return this.oversize; } public void setscheduleId(int id) { - this.scheduleId = id; + this.scheduleId = id; } public int getScheduleId() { - return this.scheduleId; + return this.scheduleId; } public void setShowInfo(long time) { - this.showedInfo = time; + this.showedInfo = time; } public long getShowInfo() { - return this.showedInfo; + return this.showedInfo; } public void setAutoSpeed(boolean autoSpeed) { - this.autoSpeed = autoSpeed; + this.autoSpeed = autoSpeed; } public boolean isAutoSpeed() { - return this.autoSpeed; + return this.autoSpeed; } public void setMessages(boolean messages) { - this.messages = messages; + this.messages = messages; } public boolean isMessages() { - return this.messages; + return this.messages; } public void setShowRegionInfo(boolean state) { - this.showInfo = state; + this.showInfo = state; } public boolean isShowRegionInfo() { - return this.showInfo; + return this.showInfo; } public void addFound() { - this.found++; + this.found++; } public int getFound() { - return this.found; + return this.found; } public void setAmount(int q) { - this.amount = q; + this.amount = q; } public int getAmount() { - return this.amount; + return this.amount; } public void setName(String name) { - this.name = name; + this.name = name; } public String getName() { - return this.name; + return this.name; } public void setEnchant(Enchantment enchant) { - this.enchant = enchant; + this.enchant = enchant; } public Enchantment getEnchant() { - return this.enchant; + return this.enchant; } public void setEnchantLvl(int enchantlvl) { - this.enchantLvl = enchantlvl; + this.enchantLvl = enchantlvl; } public int getEnchantLvl() { - return this.enchantLvl; + return this.enchantLvl; } public void setLore(String lore) { - this.lore = lore.toLowerCase(); + this.lore = lore.toLowerCase(); } public String getLore() { - return this.lore; + return this.lore; } public void addItemInfo(itemInfo info) { - this.itemIds.add(info); + this.itemIds.add(info); } public List getItemInfo() { - return itemIds; + return itemIds; } public void setSpeed(int speed) { - this.speed = speed; + this.speed = speed; } public int getSpeed() { - return this.speed; + return this.speed; } public void setRunning(boolean state) { - this.running = state; + this.running = state; } public boolean isRunning() { - return this.running; + return this.running; } public void setStartTime() { - this.startTime = System.currentTimeMillis(); + this.startTime = System.currentTimeMillis(); } public long getStartTime() { - return this.startTime; + return this.startTime; } public String getPlayerName() { - return this.Playername; + return this.Playername; } public Player getPlayer() { - return this.player; + return this.player; } public void setPlayer(Player Player) { - this.Playername = Player.getName(); - this.player = Player; + this.Playername = Player.getName(); + this.player = Player; } public WorldInfo getRI() { - return RI; + return RI; } public void setRI(WorldInfo RI) { - this.RI = RI; + this.RI = RI; } } diff --git a/src/com/Zrips/CMI/Modules/Scavenger/CMIScavengeItem.java b/src/com/Zrips/CMI/Modules/Scavenger/CMIScavengeItem.java index f9f3894..ac80ff5 100644 --- a/src/com/Zrips/CMI/Modules/Scavenger/CMIScavengeItem.java +++ b/src/com/Zrips/CMI/Modules/Scavenger/CMIScavengeItem.java @@ -1,25 +1,13 @@ package com.Zrips.CMI.Modules.Scavenger; -import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; -import org.bukkit.inventory.meta.EnchantmentStorageMeta; -import org.bukkit.inventory.meta.ItemMeta; - -import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Items.CMIItemStack; -import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; -import com.Zrips.CMI.Modules.Worth.WorthEnchantment; -import com.Zrips.CMI.Modules.Worth.WorthItem; public class CMIScavengeItem { @@ -32,124 +20,101 @@ public class CMIScavengeItem { Recipe recipe = null; CMIScavengeItem(ItemStack item) { - this(item, null); + this(item, null); } CMIScavengeItem(ItemStack item, Player player) { + } public boolean canScavenge() { - - return true; + + return true; } public boolean isBlackListedItem() { - return false; + return false; } public ItemStack getItem() { - return item; + return item; } public Player getPlayer() { - return player; + return player; } public void setPlayer(Player player) { - this.player = player; + this.player = player; } public Map getEnchants() { - return enchants; + return enchants; } public double getEnchantExtractionFailChance(Enchantment enchant) { - Integer level = this.enchants.get(enchant); - if (level == null) - level = 1; - Double chance = ScavengeManager.baseEnchantFailPercentage; - int max = enchant.getMaxLevel(); - chance += (level * ScavengeManager.levelEnchantFailPercentage) / max; - chance = chance > ScavengeManager.levelEnchantFailMaxChance ? ScavengeManager.levelEnchantFailMaxChance : chance; - return format(chance); + return format(0); } private double format(double number) { - return (int) (number * 100) / 100D; + return (int) (number * 100) / 100D; } public double getExtractionCost() { - return 0D; + + return format(0); } public double getIngredientReturnChance() { - - double chance = ScavengeManager.IngredientReturnBase; - -// chance = (chance * keepPercent) / 100D; - - return format(chance); + return format(0); } public double getEnchantLevelLowerChance(Enchantment enchant) { - Integer level = this.enchants.get(enchant); - if (level == null) - level = 1; - Double chance = ScavengeManager.LowerLevelChanceBase; - int max = enchant.getMaxLevel(); - chance += (level * ScavengeManager.LowerLevelForEachLevel) / max; - chance = chance > ScavengeManager.LowerLevelMaxChance ? ScavengeManager.LowerLevelMaxChance : chance; - return format(chance); + + return format(0); } public double getItemBreakChance() { - - return 100D; - + + return format(0); } public double getBreakChanceByItemDurability() { - if (ScavengeManager.ItemBreakDurabilityChange > 0 && this.maxDurability != this.durability) { - return format(ScavengeManager.ItemBreakDurabilityChange - (Math.ceil((getLeftDurabilityPercentage() * ScavengeManager.ItemBreakDurabilityChange) / 100D))); - } - return 0D; + return 0D; } public List getIngredients() { - return getIngredients(ScavengeManager.ItemMaterialDurabilityCheck, false); + return getIngredients(ScavengeManager.ItemMaterialDurabilityCheck, false); } public List getIngredients(boolean checkDurability) { - return getIngredients(checkDurability, false); + return getIngredients(checkDurability, false); } public List getIngredients(boolean checkDurability, boolean considerEndResultAmount) { - return null; + return null; } public double getLeftDurabilityPercentage() { - return format(durability * 100 / maxDurability); + return format(durability * 100 / maxDurability); } public List enchantsToBooks() { - - return null; + return null; } public ItemStack createBook(Enchantment enchant) { - - return null; + return null; } public ItemStack createBook(Enchantment enchant, int level) { - - return null; + return null; } public int getRecipeResultAmount() { - return recipeResultAmount; + return recipeResultAmount; } } diff --git a/src/com/Zrips/CMI/Modules/Scavenger/ScavengeManager.java b/src/com/Zrips/CMI/Modules/Scavenger/ScavengeManager.java index 1148309..2275647 100644 --- a/src/com/Zrips/CMI/Modules/Scavenger/ScavengeManager.java +++ b/src/com/Zrips/CMI/Modules/Scavenger/ScavengeManager.java @@ -10,6 +10,7 @@ import net.Zrips.CMILib.GUI.CMIGui; import net.Zrips.CMILib.GUI.CMIGuiButton; +import net.Zrips.CMILib.GUI.GUIManager.GUIClickType; import net.Zrips.CMILib.Items.CMIMaterial; public class ScavengeManager { @@ -17,7 +18,7 @@ public class ScavengeManager { private CMI plugin; public ScavengeManager(CMI cmi) { - this.plugin = cmi; + this.plugin = cmi; } public static Double baseBreakPercentage = 0D; @@ -42,7 +43,7 @@ public ScavengeManager(CMI cmi) { public static Set blackList = new HashSet(); public void loadConfig() { - + } //item black list @@ -53,23 +54,32 @@ public void openExtractor(Player player) { } private void processClick(CMIGuiButton button) { - updateExtractor(button.getGui()); + updateExtractor(button.getGui(), null); + } + + private void processClick(CMIGuiButton button, GUIClickType type) { + updateExtractor(button.getGui(), type); } private void updateExtractor(CMIGui gui) { + updateExtractor(gui, null); + } + + private void updateExtractor(CMIGui gui, GUIClickType type) { } private double format(double number) { - return (int) (number * 100) / 100D; + return (int) (number * 100) / 100D; } private boolean isFailed(double failChance) { - if (failChance >= 100) - return true; - Random random = new Random(); - double c = random.nextDouble() * 100; + if (failChance >= 100) + return true; + + Random random = new Random(); + double c = random.nextDouble() * 100; - return c < failChance; + return c < failChance; } } diff --git a/src/com/Zrips/CMI/Modules/Search/Search.java b/src/com/Zrips/CMI/Modules/Search/Search.java index d007b5f..4dcaeeb 100644 --- a/src/com/Zrips/CMI/Modules/Search/Search.java +++ b/src/com/Zrips/CMI/Modules/Search/Search.java @@ -1,43 +1,15 @@ package com.Zrips.CMI.Modules.Search; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Damageable; import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BookMeta; -import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.potion.PotionEffect; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.CMIUser; -import net.Zrips.CMILib.Items.CMIItemStack; -import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Locale.LC; - import com.Zrips.CMI.Modules.Scan.ScanResultLocations; -import com.Zrips.CMI.utils.PlayerVaultManager; - -import net.Zrips.CMILib.ActionBar.CMIActionBar; - -import net.Zrips.CMILib.Colors.CMIChatColor; public class Search { @@ -46,53 +18,51 @@ public class Search { private CMI plugin; public Search(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public enum SearchPlaceType { - Inventory("inv", "inv%", "cmi inv [player]"), - InventoryShulker("invS", "invS%", "cmi inv [player]"), - EnderChest("ender", "end%", "cmi ender [player]"), - PlayerVaults("PlayerVault", "Pv%", "pv [player] [nr]"), - Custom("", "Cs%", ""); - - private String Place; - private String pref; - private String cmd; - - private SearchPlaceType(String Place, String pref, String cmd) { - this.Place = Place; - this.pref = pref; - this.cmd = cmd; - } - - public String getPlace() { - return Place; - } - - public String getPref() { - return pref; - } - - public String getCmd() { - return cmd; - } + Inventory("inv", "inv%", "cmi inv [player]"), + InventoryShulker("invS", "invS%", "cmi inv [player]"), + EnderChest("ender", "end%", "cmi ender [player]"), + PlayerVaults("PlayerVault", "Pv%", "pv [player] [nr]"), + Custom("", "Cs%", ""); + + private String Place; + private String pref; + private String cmd; + + private SearchPlaceType(String Place, String pref, String cmd) { + this.Place = Place; + this.pref = pref; + this.cmd = cmd; + } + + public String getPlace() { + return Place; + } + + public String getPref() { + return pref; + } + + public String getCmd() { + return cmd; + } } public HashMap sortByComparator(Map unsortMap) { - - return null; + return null; } public HashMap> sortByKey(HashMap> list2) { - - return null; + return null; } @SuppressWarnings("deprecation") private boolean isThisItemOk(SearchInfo SI, ItemStack OneItem, Player player) { - return false; + return false; } private void checkPlayer(SearchInfo SI, Player one) { @@ -103,10 +73,6 @@ public void search(final SearchInfo SI) { } - private void perform(final SearchInfo SI) { - - } - public void showTimer(SearchInfo SI) { } diff --git a/src/com/Zrips/CMI/Modules/Search/SearchInfo.java b/src/com/Zrips/CMI/Modules/Search/SearchInfo.java index 327c8fa..9bea658 100644 --- a/src/com/Zrips/CMI/Modules/Search/SearchInfo.java +++ b/src/com/Zrips/CMI/Modules/Search/SearchInfo.java @@ -6,19 +6,21 @@ import java.util.concurrent.ConcurrentHashMap; import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; -import net.Zrips.CMILib.Items.CMIItemStack; import com.Zrips.CMI.Modules.Search.Search.SearchPlaceType; +import net.Zrips.CMILib.Items.CMIItemStack; + public class SearchInfo { private List itemIds = new ArrayList(); private List players = new ArrayList(); private int id = -1; private ConcurrentHashMap> places = new ConcurrentHashMap>(); - private Player player; + private CommandSender sender; private SearchType SearchType = null; String ItemName = null; @@ -38,191 +40,196 @@ public class SearchInfo { boolean purge = false; public void addChecked() { - this.totalcChecked++; + this.totalcChecked++; } public int getTotalChecked() { - return this.totalcChecked; + return this.totalcChecked; } public boolean isPurge() { - return purge; + return purge; } public void setPurge() { - this.purge = true; + this.purge = true; } public void setCurrent(int current) { - this.current = current; + this.current = current; } public void setTime() { - this.time = System.currentTimeMillis(); + this.time = System.currentTimeMillis(); } public int getCurrent() { - return this.current; + return this.current; } public long getTime() { - return this.time; + return this.time; } public void setAmount(int amount) { - this.amount = amount; + this.amount = amount; } public void addItemInfo(CMIItemStack info) { - this.itemIds.add(info); + this.itemIds.add(info); } public List getItemInfo() { - return itemIds; + return itemIds; } public void setNumberState(int id) { - this.NumberState = id; + this.NumberState = id; } public void setItemName(String name) { - this.ItemName = name; + this.ItemName = name; } public void setItemLore(String name) { - this.ItemLore = name; + this.ItemLore = name; } public void setBooleanState(boolean state) { - this.BooleanState = state; + this.BooleanState = state; } public int getAmount() { - return this.amount; + return this.amount; } public boolean getBooleanState() { - return this.BooleanState; + return this.BooleanState; } public int getNumberState() { - return this.NumberState; + return this.NumberState; } public String getItemName() { - return this.ItemName; + return this.ItemName; } public String getItemLore() { - return this.ItemLore; + return this.ItemLore; } public SearchInfo() { } public void setSearchType(SearchType SearchType) { - this.SearchType = SearchType; + this.SearchType = SearchType; } public com.Zrips.CMI.Modules.Search.SearchType getSearchType() { - return this.SearchType; + return this.SearchType; } public void setid(int i) { - this.id = i; + this.id = i; } public void clear() { - this.places.clear(); - this.SearchType = null; - } - - public Player getPlayer() { - return this.player; - } - - public void setPlayer(Player Player) { - this.player = Player; + this.places.clear(); + this.SearchType = null; } public int getid() { - return this.id; + return this.id; } public Integer found() { - int i = 0; - for (Entry> one : this.places.entrySet()) { - i += this.places.get(one.getKey()).size(); - } - return i; + int i = 0; + for (Entry> one : this.places.entrySet()) { + i += this.places.get(one.getKey()).size(); + } + return i; } public boolean exist(SearchPlaceType type, String name) { - ConcurrentHashMap one = this.places.get(type); - if (one == null) - return false; - return one.containsKey(name); + ConcurrentHashMap one = this.places.get(type); + if (one == null) + return false; + return one.containsKey(name); } public Integer get(SearchPlaceType type, String name) { - ConcurrentHashMap one = this.places.get(type); - if (one == null) - return null; - if (one.containsKey(name)) - return one.get(name); - return 0; + return 0; } public void remove(SearchPlaceType type, String name) { - ConcurrentHashMap one = this.places.get(type); - if (one == null) - return; - one.remove(name); + ConcurrentHashMap one = this.places.get(type); + if (one == null) + return; + one.remove(name); } public ConcurrentHashMap get(SearchPlaceType type) { - if (this.places.containsKey(type)) - return this.places.get(type); - return new ConcurrentHashMap(); + if (this.places.containsKey(type)) + return this.places.get(type); + return new ConcurrentHashMap(); } public void add(SearchPlaceType type, String name) { - add(type, name, 1); + add(type, name, 1); } public void add(SearchPlaceType type, String name, int amount) { - ConcurrentHashMap one = this.places.get(type); - if (one == null) - one = new ConcurrentHashMap(); - Integer sec = one.get(name); - if (sec == null) - sec = 0; - one.put(name, sec + amount); - this.places.put(type, one); + ConcurrentHashMap one = this.places.get(type); + if (one == null) + one = new ConcurrentHashMap(); + Integer sec = one.get(name); + if (sec == null) + sec = 0; + one.put(name, sec + amount); + this.places.put(type, one); } public int getTotalPlayersToCheck() { - return totalPlayersToCheck; + return totalPlayersToCheck; } public void setTotalPlayersToCheck(int totalPlayersToCheck) { - this.totalPlayersToCheck = totalPlayersToCheck; + this.totalPlayersToCheck = totalPlayersToCheck; } public List getPlayers() { - return players; + return players; } public void setPlayers(List players) { - this.players = players; - setTotalPlayersToCheck(players.size()); + this.players = players; + setTotalPlayersToCheck(players.size()); } public Enchantment getEnchant() { - return enchant; + return enchant; } public void setEnchant(Enchantment enchant) { - this.enchant = enchant; + this.enchant = enchant; + } + + @Deprecated + public Player getPlayer() { + return this.sender instanceof Player ? (Player) this.sender : null; + } + + @Deprecated + public void setPlayer(Player Player) { + this.sender = Player; + } + + public CommandSender getSender() { + return sender; + } + + public void setSender(CommandSender sender) { + this.sender = sender; } } diff --git a/src/com/Zrips/CMI/Modules/Selection/SelectionListener.java b/src/com/Zrips/CMI/Modules/Selection/SelectionListener.java index 65d2c41..ed4d9e1 100644 --- a/src/com/Zrips/CMI/Modules/Selection/SelectionListener.java +++ b/src/com/Zrips/CMI/Modules/Selection/SelectionListener.java @@ -1,28 +1,21 @@ package com.Zrips.CMI.Modules.Selection; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.EquipmentSlot; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.Items.CMIMaterial; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; -import com.Zrips.CMI.events.CMISelectionEvent; public class SelectionListener implements Listener { private CMI plugin; public SelectionListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onSelection(PlayerInteractEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Selection/SelectionManager.java b/src/com/Zrips/CMI/Modules/Selection/SelectionManager.java index 5739f04..361bb90 100644 --- a/src/com/Zrips/CMI/Modules/Selection/SelectionManager.java +++ b/src/com/Zrips/CMI/Modules/Selection/SelectionManager.java @@ -21,31 +21,33 @@ public class SelectionManager { protected Map selections; protected CMI plugin; - public static final int MIN_HEIGHT = 0; - private HashMap vMap = new HashMap(); public SelectionManager(CMI plugin) { - this.plugin = plugin; - selections = Collections.synchronizedMap(new HashMap()); + this.plugin = plugin; + selections = Collections.synchronizedMap(new HashMap()); } public void hideSelection(Player player) { - Visualizer vis = vMap.get(player.getUniqueId()); - if (vis == null) - return; - vis.cancelAll(); + Visualizer vis = vMap.get(player.getUniqueId()); + if (vis == null) + return; + vis.cancelAll(); } public void updateLocations(Player player, Location loc1, Location loc2) { - updateLocations(player, loc1, loc2, false); + updateLocations(player, loc1, loc2, false); } public void updateLocations(Player player, Location loc1, Location loc2, boolean force) { + if (loc1 != null && loc2 != null) { + selections.put(player.getUniqueId(), new CuboidArea(loc1, loc2)); + this.afterSelectionUpdate(player, force); + } } public void placeLoc1(Player player, Location loc) { - placeLoc1(player, loc, false); + placeLoc1(player, loc, false); } public void placeLoc1(Player player, Location loc, boolean show) { @@ -53,7 +55,7 @@ public void placeLoc1(Player player, Location loc, boolean show) { } public void placeLoc2(Player player, Location loc) { - placeLoc2(player, loc, false); + placeLoc2(player, loc, false); } public void placeLoc2(Player player, Location loc, boolean show) { @@ -61,7 +63,7 @@ public void placeLoc2(Player player, Location loc, boolean show) { } public void afterSelectionUpdate(Player player) { - afterSelectionUpdate(player, false); + afterSelectionUpdate(player, false); } public void afterSelectionUpdate(Player player, boolean force) { @@ -70,87 +72,96 @@ public void afterSelectionUpdate(Player player, boolean force) { @Deprecated public Location getPlayerLoc1(Player player) { - return getPlayerLoc1(player.getUniqueId()); + return getPlayerLoc1(player.getUniqueId()); } @Deprecated public Location getPlayerLoc1(String player) { - - return null; + CMIUser user = plugin.getPlayerManager().getUser(player); + if (user == null) + return null; + return getPlayerLoc1(user.getUniqueId()); } @Deprecated public Location getPlayerLoc1(UUID uuid) { - CuboidArea selection = selections.get(uuid); - if (selection == null) - return null; - return selection.getLowLoc(); + CuboidArea selection = selections.get(uuid); + if (selection == null) + return null; + return selection.getLowLoc(); } @Deprecated public Location getPlayerLoc2(Player player) { - return getPlayerLoc2(player.getUniqueId()); + return getPlayerLoc2(player.getUniqueId()); } @Deprecated public Location getPlayerLoc2(String player) { - return null; + CMIUser user = plugin.getPlayerManager().getUser(player); + if (user == null) + return null; + return getPlayerLoc2(user.getUniqueId()); } @Deprecated public Location getPlayerLoc2(UUID uuid) { - return null; + CuboidArea selection = selections.get(uuid); + if (selection == null) + return null; + return selection.getHighLoc(); } public CuboidArea getSelectionCuboid(Player player) { - if (player == null) - return null; - return getSelectionCuboid(player.getUniqueId()); + if (player == null) + return null; + return getSelectionCuboid(player.getUniqueId()); } public void setSelectionCuboid(Player player, CuboidArea area) { - this.selections.put(player.getUniqueId(), area); + } @Deprecated public CuboidArea getSelectionCuboid(String player) { - CMIUser user = plugin.getPlayerManager().getUser(player); - if (user == null) - return null; - return getSelectionCuboid(user.getUniqueId()); + CMIUser user = plugin.getPlayerManager().getUser(player); + if (user == null) + return null; + return getSelectionCuboid(user.getUniqueId()); } public CuboidArea getSelectionCuboid(UUID uuid) { - if (uuid == null) - return null; - return selections.get(uuid); + if (uuid == null) + return null; + return selections.get(uuid); } public boolean hasPlacedBoth(Player player) { - return hasPlacedBoth(player.getUniqueId()); + return hasPlacedBoth(player.getUniqueId()); } @Deprecated public boolean hasPlacedBoth(String player) { - CMIUser user = plugin.getPlayerManager().getUser(player); - if (user == null) - return false; - return hasPlacedBoth(user.getUniqueId()); + CMIUser user = plugin.getPlayerManager().getUser(player); + if (user == null) + return false; + return hasPlacedBoth(user.getUniqueId()); } public boolean hasPlacedBoth(UUID uuid) { - CuboidArea selection = selections.get(uuid); - if (selection == null) - return false; - return selection.valid(); + CuboidArea selection = selections.get(uuid); + if (selection == null) + return false; + return selection.valid(); } @Deprecated public void showSelectionInfo(Player player) { - showSelection(player); + showSelection(player); } public void showSelection(Player player) { + } public void showBounds(final Player player, final Visualizer v) { @@ -159,28 +170,38 @@ public void showBounds(final Player player, final Visualizer v) { public List getLocations(Location lowLoc, Location loc, Vector vector, boolean StartFromZero) { - return null; + return null; + } + + private List getLocationsWallsByData(Location loc, Vector vector, Location lowLoc, SelectionSides Sides) { + + return null; + } + + private List getLocationsCornersByData(Location loc, Vector vector, Location lowLoc, SelectionSides Sides) { + + return null; } private static int Range = 16; public boolean makeBorders(final Player player) { - return true; + return true; } public void clearSelection(Player player) { - selections.remove(player.getUniqueId()); + selections.remove(player.getUniqueId()); } public boolean worldEdit(Player player) { - plugin.sendMessage(player, LC.info_NoInformation); - return false; + plugin.sendMessage(player, LC.info_NoInformation); + return false; } public boolean worldEditUpdate(Player player) { - plugin.sendMessage(player, LC.info_NoInformation); - return false; + plugin.sendMessage(player, LC.info_NoInformation); + return false; } } diff --git a/src/com/Zrips/CMI/Modules/Selection/Visualizer.java b/src/com/Zrips/CMI/Modules/Selection/Visualizer.java index c2be18f..0d30e0e 100644 --- a/src/com/Zrips/CMI/Modules/Selection/Visualizer.java +++ b/src/com/Zrips/CMI/Modules/Selection/Visualizer.java @@ -11,7 +11,6 @@ import com.Zrips.CMI.Modules.Portals.CMIPortal; import com.Zrips.CMI.Modules.Portals.CuboidArea; - public class Visualizer { private Player player; private long start; @@ -29,161 +28,153 @@ public class Visualizer { private Location loc = null; public Visualizer(Player player) { - this.player = player; - this.start = System.currentTimeMillis(); + this.player = player; + this.start = System.currentTimeMillis(); } public void cancelAll() { - if (id != -1) { - Bukkit.getScheduler().cancelTask(id); - } - if (errorId != -1) { - Bukkit.getScheduler().cancelTask(errorId); - } - loc = null; + if (id != -1) { + Bukkit.getScheduler().cancelTask(id); + } + if (errorId != -1) { + Bukkit.getScheduler().cancelTask(errorId); + } + loc = null; } public boolean isSameLoc() { - if (loc == null) - return false; - if (loc.getWorld() != player.getWorld()) - return false; - if (!errorAreas.isEmpty() && errorLocations.isEmpty()) - return false; - if (loc.distance(player.getLocation()) > 1) - return false; - return true; + return true; } public long getStart() { - return start; + return start; } public void setStart(long start) { - this.start = start; + this.start = start; } public Player getPlayer() { - return player; + return player; } public void setPlayer(Player player) { - this.player = player; + this.player = player; } public List getAreas() { - return areas; + return areas; } public void setAreas(CMIPortal res) { - if (res != null) - this.areas = Arrays.asList(res.getArea()); + if (res != null) + this.areas = Arrays.asList(res.getArea()); } public void setAreas(CuboidArea[] areas) { - this.areas = Arrays.asList(areas); + this.areas = Arrays.asList(areas); } public void setAreas(ArrayList areas) { - this.areas = areas; + this.areas = areas; } public void setAreas(CuboidArea area) { - areas = new ArrayList(); - this.areas.add(area); + areas = new ArrayList(); + this.areas.add(area); } public List getErrorAreas() { - return errorAreas; + return errorAreas; } public void setErrorAreas(CMIPortal res) { - if (res != null) - this.errorAreas = Arrays.asList(res.getArea()); + if (res != null) + this.errorAreas = Arrays.asList(res.getArea()); } public void setErrorAreas(CuboidArea[] errorAreas) { - this.errorAreas = Arrays.asList(errorAreas); + this.errorAreas = Arrays.asList(errorAreas); } public void setErrorAreas(ArrayList errorAreas) { - this.errorAreas = errorAreas; + this.errorAreas = errorAreas; } public void setErrorAreas(CuboidArea errorArea) { - this.errorAreas.add(errorArea); + this.errorAreas.add(errorArea); } public int getId() { - return id; + return id; } public void setId(int id) { - this.id = id; + this.id = id; } public int getErrorId() { - return errorId; + return errorId; } public void setErrorId(int errorId) { - this.errorId = errorId; + this.errorId = errorId; } public boolean isOnce() { - return once; + return once; } public void setOnce(boolean once) { - this.once = once; + this.once = once; } public List getLocations() { - return locations; + return locations; } public void setLocations(List locations) { - this.locations = locations; + this.locations = locations; } public List getLocations2() { - return locations2; + return locations2; } public void setLocations2(List locations) { - this.locations2 = locations; + this.locations2 = locations; } public List getErrorLocations() { - return errorLocations; + return errorLocations; } public void setErrorLocations(List errorLocations) { - this.errorLocations = errorLocations; + this.errorLocations = errorLocations; } public List getErrorLocations2() { - return errorLocations2; + return errorLocations2; } public void setErrorLocations2(List errorLocations) { - this.errorLocations2 = errorLocations; + this.errorLocations2 = errorLocations; } public Location getLoc() { - return loc; + return loc; } public void setLoc(Location loc) { - this.loc = loc; + this.loc = loc; } public int getStarting() { - return starting; + return starting; } public void setStarting(int starting) { - this.starting = starting; + this.starting = starting; } } diff --git a/src/com/Zrips/CMI/Modules/Sheduler/SchedTime.java b/src/com/Zrips/CMI/Modules/Sheduler/SchedTime.java index 57b4d61..c28fa0c 100644 --- a/src/com/Zrips/CMI/Modules/Sheduler/SchedTime.java +++ b/src/com/Zrips/CMI/Modules/Sheduler/SchedTime.java @@ -1,13 +1,5 @@ package com.Zrips.CMI.Modules.Sheduler; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; - -import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Logs.CMIDebug; -import com.Zrips.CMI.utils.DateFormat; - public class SchedTime { private Integer year = null; @@ -23,80 +15,81 @@ public SchedTime() { } public Integer getYear() { - return year; + return year; } public void setYear(Integer year) { - if (year < 100) - year += 2000; - this.year = year; + if (year < 100) + year += 2000; + this.year = year; } public Integer getMonth() { - return month; + return month; } public void setMonth(Integer month) { - this.month = month; + this.month = month; } public Integer getDay() { - return day; + return day; } public void setDay(Integer day) { - this.day = day; + this.day = day; } public Integer getHour() { - return hour; + return hour; } public void setHour(Integer hour) { - this.hour = hour; + this.hour = hour; } public Integer getMinute() { - return minute; + return minute; } public void setMinute(Integer minute) { - this.minute = minute; + this.minute = minute; } public Integer getSecond() { - return second; + return second; } public void setSecond(Integer second) { - this.second = second; + this.second = second; } public boolean isNow() { - return true; + return true; } Long next = 0L; public long getNextMili() { - return 0L; + return next < System.currentTimeMillis() + 1000L ? System.currentTimeMillis() + 1000L : next; + } public boolean isDone() { - return done; + return done; } public void setDone(boolean done) { - this.done = done; + this.done = done; } public Integer getDayOfWeek() { - return dayOfWeek; + return dayOfWeek; } public void setDayOfWeek(Integer dayOfWeek) { - this.dayOfWeek = dayOfWeek; + this.dayOfWeek = dayOfWeek; } } diff --git a/src/com/Zrips/CMI/Modules/Sheduler/Schedule.java b/src/com/Zrips/CMI/Modules/Sheduler/Schedule.java index b8e8606..771f49f 100644 --- a/src/com/Zrips/CMI/Modules/Sheduler/Schedule.java +++ b/src/com/Zrips/CMI/Modules/Sheduler/Schedule.java @@ -1,21 +1,12 @@ package com.Zrips.CMI.Modules.Sheduler; import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map.Entry; -import java.util.Random; import java.util.regex.Pattern; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; - -import net.Zrips.CMILib.Colors.CMIChatColor; - public class Schedule { private boolean enabled = false; @@ -40,31 +31,37 @@ public class Schedule { private boolean randomPlayer = false; public Schedule(String name) { - this.name = name; + this.name = name; } public void reset() { - + performOn = 0L; + performed = false; + commands = new ArrayList(); + repeatable = false; + delay = 0L; + randomize = false; + duplicateRandomize = false; + singleLinear = false; + MinPlayer = null; + MaxPlayer = null; } public String getDuplicatedRandomCommand() { - - return null; + return null; } public String getRandomCommand() { - - return null; + return null; } public String getSingleLinearCommand() { - - return null; + return null; } public List getCommands() { - return commands; + return commands; } public void setCommands(List commands) { @@ -72,28 +69,28 @@ public void setCommands(List commands) { } public boolean isPerformed() { - return performed; + return performed; } public void setPerformed(boolean performed) { - this.performed = performed; + this.performed = performed; } public boolean isPlayerAmountOk() { - return isPlayerMinOk() && isPlayerMaxOk(); + return isPlayerMinOk() && isPlayerMaxOk(); } public boolean isPlayerMinOk() { - return this.getMinPlayer() == null || Bukkit.getOnlinePlayers().size() >= this.getMinPlayer(); + return this.getMinPlayer() == null || Bukkit.getOnlinePlayers().size() >= this.getMinPlayer(); } public boolean isPlayerMaxOk() { - return this.getMaxPlayer() == null || Bukkit.getOnlinePlayers().size() <= this.getMaxPlayer(); + return this.getMaxPlayer() == null || Bukkit.getOnlinePlayers().size() <= this.getMaxPlayer(); } public boolean itsTimeToPerform() { - return false; + return false; } public void recalculateNext() { @@ -102,153 +99,148 @@ public void recalculateNext() { public Long getPerformOn() { - this.recalculateNext(); + this.recalculateNext(); - return performOn; + return performOn; } -// public void setPerformOn(Long performOn) { -// this.performOn = performOn; -// } - public String getName() { - return name; + return name; } public void setName(String name) { - this.name = name; + this.name = name; } public boolean isRepeatable() { - return repeatable; + return repeatable; } public void setRepeatable(boolean repeatable) { - this.repeatable = repeatable; + this.repeatable = repeatable; } public long getDelay() { - return delay; + return delay; } public void setDelay(long delay) { - this.delay = delay; + this.delay = delay; } public Long getLastPerformedOn() { - return lastPerformedOn; + return lastPerformedOn; } public void setLastPerformedOn() { - if (this.time.isEmpty()) - setLastPerformedOn(System.currentTimeMillis()); - else { - recalculateNext(); - } + if (this.time.isEmpty()) + setLastPerformedOn(System.currentTimeMillis()); + else { + recalculateNext(); + } } public void setLastPerformedOn(Long lastPerformedOn) { - this.lastPerformedOn = lastPerformedOn; - updateNextPerform(); + this.lastPerformedOn = lastPerformedOn; + updateNextPerform(); } private void updateNextPerform() { - performOn = (lastPerformedOn == 0L ? System.currentTimeMillis() : lastPerformedOn) + (delay * 1000); + performOn = (lastPerformedOn == 0L ? System.currentTimeMillis() : lastPerformedOn) + (delay * 1000); } public List getTime() { - return time; + return time; } public void setTime(List time) { - this.time = time; + this.time = time; } public Integer getMinPlayer() { - return MinPlayer; + return MinPlayer; } public void setMinPlayer(Integer minPlayer) { - MinPlayer = minPlayer; + MinPlayer = minPlayer; } public Integer getMaxPlayer() { - return MaxPlayer; + return MaxPlayer; } public void setMaxPlayer(Integer maxPlayer) { - MaxPlayer = maxPlayer; + MaxPlayer = maxPlayer; } public boolean isRandomize() { - return randomize; + return randomize; } public void setRandomize(boolean randomize) { - this.randomize = randomize; + this.randomize = randomize; } public void safePerform() { - } Pattern placeholderKeepPatern = Pattern.compile("(\\{\\%)([^\\\"^\\%^ ]+)(\\%\\})(\\B)"); public void perform() { + return; } public List updateSchedCmds(List cmds, Player player) { - return null; + return null; } public Player getRandomPlayer() { - - return null; + return null; } public boolean isEnabled() { - return enabled; + return enabled; } public void setEnabled(boolean enabled) { - this.enabled = enabled; + this.enabled = enabled; } public Boolean isPlayerAmountFeedback() { - return playerAmountFeedback; + return playerAmountFeedback; } public void setPlayerAmountFeedback(Boolean playerAmountFeedback) { - this.playerAmountFeedback = playerAmountFeedback; + this.playerAmountFeedback = playerAmountFeedback; } public Double getTotalCommandDelay() { - return commandDelay; + return commandDelay; } public boolean isSingleLinear() { - return singleLinear; + return singleLinear; } public void setSingleLinear(boolean singleLinear) { - this.singleLinear = singleLinear; + this.singleLinear = singleLinear; } public boolean isDuplicateRandomize() { - return duplicateRandomize; + return duplicateRandomize; } public void setDuplicateRandomize(boolean duplicateRandomize) { - this.duplicateRandomize = duplicateRandomize; + this.duplicateRandomize = duplicateRandomize; } public List getMinPlayerCommands() { - return minPlayerCommands; + return minPlayerCommands; } public void setMinPlayerCommands(List minPlayerCommands) { - this.minPlayerCommands = minPlayerCommands; + this.minPlayerCommands = minPlayerCommands; } } diff --git a/src/com/Zrips/CMI/Modules/Sheduler/SchedulerManager.java b/src/com/Zrips/CMI/Modules/Sheduler/SchedulerManager.java index d643862..c1f13c6 100644 --- a/src/com/Zrips/CMI/Modules/Sheduler/SchedulerManager.java +++ b/src/com/Zrips/CMI/Modules/Sheduler/SchedulerManager.java @@ -1,22 +1,12 @@ package com.Zrips.CMI.Modules.Sheduler; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Calendar; -import java.util.Date; import java.util.HashMap; -import java.util.List; -import java.util.Map; import java.util.Map.Entry; import org.bukkit.Bukkit; -import org.bukkit.configuration.file.YamlConfiguration; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.FileHandler.ConfigReader; -import com.Zrips.CMI.Modules.ModuleHandling.CMIModule; public class SchedulerManager { @@ -29,27 +19,27 @@ public class SchedulerManager { public static final String randomPlayerLabel = "[randomPlayer]"; public SchedulerManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public Schedule getSchedule(String name) { - return getSchedule(name, false); + return getSchedule(name, false); } public Schedule getSchedule(String name, boolean includeDisabled) { - Schedule sched = map.get(name.toLowerCase()); - if (sched == null) - return null; - if (!sched.isEnabled() && !includeDisabled) - return null; - return sched; + Schedule sched = map.get(name.toLowerCase()); + if (sched == null) + return null; + if (!sched.isEnabled() && !includeDisabled) + return null; + return sched; } public void stop() { - if (autoTimerBukkitId != 0) { - Bukkit.getScheduler().cancelTask(autoTimerBukkitId); - autoTimerBukkitId = 0; - } + if (autoTimerBukkitId != 0) { + Bukkit.getScheduler().cancelTask(autoTimerBukkitId); + autoTimerBukkitId = 0; + } } @SuppressWarnings("unchecked") @@ -58,51 +48,60 @@ public void load() { } private void runTimer() { + } private Runnable autoTimer = new Runnable() { - @Override - public void run() { - try { - checkSchedulers(); - } catch (Throwable e) { - e.printStackTrace(); - } - runTimer(); - } + @Override + public void run() { + try { + checkSchedulers(); + } catch (Throwable e) { + e.printStackTrace(); + } + runTimer(); + } }; private static Long nextIn() { - return null; + return null; } public int getActualWeekDay(int day) { - switch (day) { - case Calendar.SUNDAY: - return 7; - case Calendar.MONDAY: - return 1; - case Calendar.TUESDAY: - return 2; - case Calendar.WEDNESDAY: - return 3; - case Calendar.THURSDAY: - return 4; - case Calendar.FRIDAY: - return 5; - case Calendar.SATURDAY: - return 6; - default: - return 1; - } + switch (day) { + case Calendar.SUNDAY: + return 7; + case Calendar.MONDAY: + return 1; + case Calendar.TUESDAY: + return 2; + case Calendar.WEDNESDAY: + return 3; + case Calendar.THURSDAY: + return 4; + case Calendar.FRIDAY: + return 5; + case Calendar.SATURDAY: + return 6; + default: + return 1; + } } private void checkSchedulers() { + for (Entry one : map.entrySet()) { + Schedule sched = one.getValue(); + if (!sched.isEnabled()) + continue; + if (!sched.itsTimeToPerform()) + continue; + sched.safePerform(); + } } public HashMap getMap() { - return map; + return map; } } diff --git a/src/com/Zrips/CMI/Modules/ShulkerBoxInventory/ShulkerBoxListener.java b/src/com/Zrips/CMI/Modules/ShulkerBoxInventory/ShulkerBoxListener.java index c413b4f..28884a5 100644 --- a/src/com/Zrips/CMI/Modules/ShulkerBoxInventory/ShulkerBoxListener.java +++ b/src/com/Zrips/CMI/Modules/ShulkerBoxInventory/ShulkerBoxListener.java @@ -1,36 +1,49 @@ package com.Zrips.CMI.Modules.ShulkerBoxInventory; -import java.util.Random; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryDragEvent; -import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.EquipmentSlot; -import org.bukkit.inventory.ItemStack; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; - -import net.Zrips.CMILib.CMILib; -import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; -import net.Zrips.CMILib.NBT.CMINBT; -import net.Zrips.CMILib.Version.Version; public class ShulkerBoxListener implements Listener { private CMI plugin; public ShulkerBoxListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void CheckForChulker(InventoryClickEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void ShulkerItemOpen(InventoryClickEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void PlayerInteractEvent(PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW) + public void ShulkerEdit(InventoryClickEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void ShulkerEdit(InventoryDragEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void InventoryCloseEvent(InventoryCloseEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/ShulkerBoxInventory/ShulkerBoxManager.java b/src/com/Zrips/CMI/Modules/ShulkerBoxInventory/ShulkerBoxManager.java index b0064be..adb8602 100644 --- a/src/com/Zrips/CMI/Modules/ShulkerBoxInventory/ShulkerBoxManager.java +++ b/src/com/Zrips/CMI/Modules/ShulkerBoxInventory/ShulkerBoxManager.java @@ -17,65 +17,65 @@ public class ShulkerBoxManager { private CMI plugin; public ShulkerBoxManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public final static String identifier = "CMIBackPack"; public boolean stillHaveItem(Player player) { - - return false; + + return false; } public void closeAll() { - + } public boolean isEditing(Player player) { - if (map.isEmpty()) - return false; - return map.containsKey(player.getUniqueId()); + if (map.isEmpty()) + return false; + return map.containsKey(player.getUniqueId()); } private Inventory getExisting(Player player) { - - return null; + + return null; } private boolean PreventInCombat = true; public void loadConfig() { + } public void openShulkerBox(Player player, ItemStack item) { - - } + } public void updateShulkerItem(Player player) { - + } public void remove(Player player) { - map.remove(player.getUniqueId()); + map.remove(player.getUniqueId()); } public boolean isShulkerBox(ItemStack OneItem) { - - return true; + + return true; } public List getShulkerBoxContents(ItemStack OneItem) { - - return null; + + return null; } public void updateEntireShulkerInv(Player player, ItemStack[] cont) { - + } public void setShulkerInv(ItemStack shulkerBox, ItemStack[] cont) { - + } } diff --git a/src/com/Zrips/CMI/Modules/SilentChest/silentChestListener.java b/src/com/Zrips/CMI/Modules/SilentChest/silentChestListener.java index d7f8a9d..1e202ca 100644 --- a/src/com/Zrips/CMI/Modules/SilentChest/silentChestListener.java +++ b/src/com/Zrips/CMI/Modules/SilentChest/silentChestListener.java @@ -3,7 +3,15 @@ import java.util.HashMap; import java.util.UUID; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.event.player.PlayerAnimationEvent; +import org.bukkit.event.player.PlayerInteractEvent; import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.SilentChest; @@ -17,7 +25,47 @@ public class silentChestListener implements Listener { private HashMap sleep = new HashMap(); public silentChestListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.NORMAL) + public void animation(PlayerAnimationEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onBlockBreakEvent(BlockBreakEvent event) { + + } + + @SuppressWarnings("unchecked") + @EventHandler(priority = EventPriority.HIGHEST) + public void onPlayerInteract(PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onSilentInventoryClose(InventoryCloseEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onSilentInventoryClickWatcher(final InventoryClickEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onSilentInventoryClickWatcher(final InventoryDragEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onSilentInventoryClick(final InventoryClickEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onSilentInventoryClick(final InventoryDragEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Skin/SkinListener.java b/src/com/Zrips/CMI/Modules/Skin/SkinListener.java index c91221e..676c84c 100644 --- a/src/com/Zrips/CMI/Modules/Skin/SkinListener.java +++ b/src/com/Zrips/CMI/Modules/Skin/SkinListener.java @@ -1,6 +1,9 @@ package com.Zrips.CMI.Modules.Skin; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerLoginEvent; import com.Zrips.CMI.CMI; @@ -8,7 +11,11 @@ public class SkinListener implements Listener { private CMI plugin; public SkinListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerLogin(final PlayerLoginEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Skin/SkinManager.java b/src/com/Zrips/CMI/Modules/Skin/SkinManager.java index a45d790..93e231c 100644 --- a/src/com/Zrips/CMI/Modules/Skin/SkinManager.java +++ b/src/com/Zrips/CMI/Modules/Skin/SkinManager.java @@ -21,7 +21,7 @@ public class SkinManager { private long SkinRequestFrequency = 60; public SkinManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void loadConfig() { @@ -29,66 +29,65 @@ public void loadConfig() { } public void removeSkinFromCache(String playerName) { + CMISkin skin = skinCacheByName.remove(playerName); + if (skin != null) + skinCacheByUUID.remove(skin.getUuid()); } public boolean applySkin(Player player, String playerName) { - - return false; + return false; } public boolean applySkin(final Player player, UUID uuid) { - return false; + return false; } Long lastUpdateRequest = 0L; public boolean setSkin(GameProfile profile, UUID uuid) { - return false; - + return false; } private boolean checkCache(GameProfile profile, UUID uuid) { - - return false; + return false; } public CMISkin getSkin(String name) { - - return null; + + return null; } boolean saving = false; public void save(CMISkin skin) { - - } + } public void load() { - + } public boolean isSteveOnOff() { - return SteveOnOff; + return SteveOnOff; } public void setSteveOnOff(boolean steveOnOff) { - SteveOnOff = steveOnOff; + SteveOnOff = steveOnOff; } public boolean isRequireSpecificPerm() { - return RequireSpecificPerm; + return RequireSpecificPerm; } public void setRequireSpecificPerm(boolean requireSpecificPerm) { - RequireSpecificPerm = requireSpecificPerm; + RequireSpecificPerm = requireSpecificPerm; } public boolean isAutoApply() { - return AutoApply; + return AutoApply; } } diff --git a/src/com/Zrips/CMI/Modules/SpawnerCharge/PlayerCharge.java b/src/com/Zrips/CMI/Modules/SpawnerCharge/PlayerCharge.java index 5ef5765..1b7265a 100644 --- a/src/com/Zrips/CMI/Modules/SpawnerCharge/PlayerCharge.java +++ b/src/com/Zrips/CMI/Modules/SpawnerCharge/PlayerCharge.java @@ -12,116 +12,109 @@ public class PlayerCharge { private long lastChecked = 0L; public PlayerCharge(CMIUser user, boolean update) { - this.user = user; - if (update) - updateSpawnerCharge(); -// if (this.lastGive == 0L) -// this.lastGive = System.currentTimeMillis(); + } private void updateSpawnerCharge() { } public void reset() { - reset(true); + reset(true); } public void reset(boolean update) { - charges = 0; - lastGive = 0L; - SCharge = null; - if (update) - updateSpawnerCharge(); + } public int getCharges() { - updateSpawnerCharge(); - updateChargeTimer(); - return charges; + updateSpawnerCharge(); + updateChargeTimer(); + return charges; } public int getChargesClean() { - return charges; + return charges; } public boolean haveLeftCharge() { - if (!CMI.getInstance().getConfigManager().ChargesUse) - return true; - updateSpawnerCharge(); - return charges > 0; + if (!CMI.getInstance().getConfigManager().ChargesUse) + return true; + updateSpawnerCharge(); + return charges > 0; } public boolean have() { - updateSpawnerCharge(); - return SCharge != null; + updateSpawnerCharge(); + return SCharge != null; } public int getBonus() { - if (this.SCharge == null) - return 0; - if (this.SCharge.getBonus() <= 0) - return 0; - return this.SCharge.getBonus(); + if (this.SCharge == null) + return 0; + if (this.SCharge.getBonus() <= 0) + return 0; + return this.SCharge.getBonus(); } public boolean lowerCd() { - return true; + return true; } public void setCharges(int charges) { - this.charges = charges; + this.charges = charges; } private void updateChargeTimer() { } public String getLeftTime() { - return null; + return null; } public boolean addCharge() { - return addCharge(1); + return addCharge(1); } public boolean addCharge(int amount) { - return addCharge(amount, false); + return addCharge(amount, false); } public boolean addCharge(int amount, boolean force) { - return true; + return true; } public boolean takeCharge() { - return takeCharge(1); + return takeCharge(1); } public boolean takeCharge(int amount) { - return takeCharge(amount, false); + return takeCharge(amount, false); } public boolean takeCharge(int amount, boolean force) { - return true; + + return true; } public int getMaxCharges() { - updateSpawnerCharge(); - if (SCharge == null) - return 0; - return SCharge.getMaxCharges(); + updateSpawnerCharge(); + if (SCharge == null) + return 0; + return SCharge.getMaxCharges(); } public long getLastGive() { - return lastGive; + return lastGive; } public void setLastGive(long lastGive) { - this.lastGive = lastGive; + this.lastGive = lastGive; } public int getCooldown() { - updateSpawnerCharge(); - if (SCharge == null) - return -1; - return SCharge.getCooldown(); + updateSpawnerCharge(); + if (SCharge == null) + return -1; + return SCharge.getCooldown(); } } diff --git a/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerActionsListener.java b/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerActionsListener.java index 54d15f3..010050c 100644 --- a/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerActionsListener.java +++ b/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerActionsListener.java @@ -1,39 +1,44 @@ package com.Zrips.CMI.Modules.SpawnerCharge; -import java.util.List; -import java.util.Random; - -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockState; -import org.bukkit.block.CreatureSpawner; -import org.bukkit.entity.Creeper; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.EquipmentSlot; -import org.bukkit.inventory.ItemStack; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Config; -import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.Items.CMIItemStack; -import net.Zrips.CMILib.Items.CMIMaterial; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; -import net.Zrips.CMILib.Version.Version; public class SpawnerActionsListener implements Listener { private CMI plugin; public SpawnerActionsListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onBlockBreakExplodeTnT(EntityExplodeEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerInteractEvent(PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onBlockBreakExplodeCreeper(EntityExplodeEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onBlockPlace(BlockPlaceEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onSpawnerInteract(PlayerInteractEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerChargeListener.java b/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerChargeListener.java index 9b2086a..7bf989c 100644 --- a/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerChargeListener.java +++ b/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerChargeListener.java @@ -1,31 +1,50 @@ package com.Zrips.CMI.Modules.SpawnerCharge; +import java.util.HashMap; import java.util.Random; +import java.util.UUID; import org.bukkit.block.Block; -import org.bukkit.block.BlockState; -import org.bukkit.block.CreatureSpawner; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.inventory.ItemStack; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.CMIUser; -import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.Items.CMIMaterial; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; - -import net.Zrips.CMILib.ActionBar.CMIActionBar; public class SpawnerChargeListener implements Listener { private CMI plugin; public SpawnerChargeListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void BlockBreakEventExpDrop(BlockBreakEvent event) { + + } + + Random rand = new Random(); + + @EventHandler(priority = EventPriority.HIGHEST) + public void BlockBreakEventFull(BlockBreakEvent event) { + } + public static void clearCache(UUID uuid) { + breaking.remove(uuid); + } + + static HashMap breaking = new HashMap(); + + @EventHandler(priority = EventPriority.MONITOR) + public void blockBreakEventFull(BlockBreakEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void BlockPlaceEvent(BlockPlaceEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerChargeManager.java b/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerChargeManager.java index 2460790..838619c 100644 --- a/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerChargeManager.java +++ b/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerChargeManager.java @@ -1,33 +1,14 @@ package com.Zrips.CMI.Modules.SpawnerCharge; -import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map.Entry; -import java.util.stream.Stream; -import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.BlockState; -import org.bukkit.block.CreatureSpawner; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Config; -import com.Zrips.CMI.Modules.Permissions.PermissionInfo; import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; -import net.Zrips.CMILib.Container.PageInfo; -import net.Zrips.CMILib.Entities.CMIEntityType; -import net.Zrips.CMILib.GUI.CMIGui; -import net.Zrips.CMILib.GUI.CMIGuiButton; -import net.Zrips.CMILib.GUI.GUIManager.InvType; -import net.Zrips.CMILib.Items.CMIItemStack; -import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; -import net.Zrips.CMILib.NBT.CMINBT; - public class SpawnerChargeManager { private LinkedHashMap map = new LinkedHashMap(); @@ -35,39 +16,38 @@ public class SpawnerChargeManager { private Integer total = 0; private void recalculateTotalSpawnerEntities() { - - + } public void addCharge(SCharges charge) { - map.put(charge.getName().toLowerCase(), charge); + map.put(charge.getName().toLowerCase(), charge); } public SCharges getCharge(String name) { - return map.get(name.toLowerCase()); + return map.get(name.toLowerCase()); } public SCharges getCharge(Player player) { - return null; + return null; } public boolean changeSpawnerType(Block block, EntityType type) { - return true; + + return true; } @Deprecated public void openSpawnerPickerUI(Player player) { - openSpawnerPickerUI(player, 1); + openSpawnerPickerUI(player, 1); } public void openSpawnerPickerUI(Player player, int page) { - + } public int getSpawnerDropChance(Player player, Block block) { - return 0; - + return 0; } } diff --git a/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerProximityListener.java b/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerProximityListener.java index 774e650..66d45d1 100644 --- a/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerProximityListener.java +++ b/src/com/Zrips/CMI/Modules/SpawnerCharge/SpawnerProximityListener.java @@ -1,24 +1,21 @@ package com.Zrips.CMI.Modules.SpawnerCharge; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPlaceEvent; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.Effects.CMIEffectManager.CMIParticle; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; public class SpawnerProximityListener implements Listener { private CMI plugin; public SpawnerProximityListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.NORMAL) + public void BlockPlaceEventRange(BlockPlaceEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/SpecializedCommands/SpecializedCommandManager.java b/src/com/Zrips/CMI/Modules/SpecializedCommands/SpecializedCommandManager.java index 40edcc4..84b2b58 100644 --- a/src/com/Zrips/CMI/Modules/SpecializedCommands/SpecializedCommandManager.java +++ b/src/com/Zrips/CMI/Modules/SpecializedCommands/SpecializedCommandManager.java @@ -1,59 +1,63 @@ package com.Zrips.CMI.Modules.SpecializedCommands; -import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import java.util.Map.Entry; import java.util.UUID; -import java.util.regex.Matcher; import java.util.regex.Pattern; import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.command.Command; import org.bukkit.command.CommandException; import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.command.RemoteConsoleCommandSender; -import org.bukkit.entity.Damageable; import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.inventory.ItemStack; import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIInteractType; -import com.Zrips.CMI.Containers.CMIPlayerInventory.CMIInventorySlot; -import com.Zrips.CMI.Containers.CMIUser; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; -import com.Zrips.CMI.Modules.Portals.CMIPortal; -import com.Zrips.CMI.commands.CMICommand; -import com.Zrips.CMI.commands.CommandsHandler; -import com.Zrips.CMI.events.CMIPlayerKickEvent; - -import net.Zrips.CMILib.CMILib; -import net.Zrips.CMILib.ActionBar.CMIActionBar; -import net.Zrips.CMILib.Colors.CMIChatColor; -import net.Zrips.CMILib.Items.CMIItemStack; -import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.RawMessages.RawMessage; -import net.Zrips.CMILib.Time.CMITimeManager; -import net.Zrips.CMILib.TitleMessages.CMITitleMessage; -import net.Zrips.CMILib.Version.Version; public class SpecializedCommandManager { private CMI plugin; public SpecializedCommandManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } - HashMap> runaway = new HashMap>(); + HashMap> runaway = new HashMap>(); + HashMap globalRunaway = new HashMap(); + + class runAway { + + private Long time = null; + private int schedId = 0; + + public runAway(Long time) { + this.time = time; + } + + public Long getTime() { + return time; + } + + public void setTime(Long time) { + this.time = time; + } + + public int getSchedId() { + return schedId; + } + + public void stopSched() { + if (schedId > 0) { + Bukkit.getScheduler().cancelTask(schedId); + } + } + + public void setSchedId(int schedId) { + this.schedId = schedId; + } + } public void clearCache(UUID uuid) { + } public void processAliasCmdsAsPlayer(String initializer, List cmds, final Player player) { @@ -61,31 +65,35 @@ public void processAliasCmdsAsPlayer(String initializer, List cmds, fina } private void process(String initializer, List cmds, final Player player) { + process(initializer, cmds, player, null); + } + + private void process(String initializer, List cmds, final Player player, CheckStatements conditions) { } public void processCmds(List cmds) { - processCmds(null, cmds, null, null, null); + processCmds(null, cmds, null, null, null); } public void processCmds(List cmds, CommandSender sender) { - processCmds(null, cmds, null, null, sender); + processCmds(null, cmds, null, null, sender); } public void processCmds(List cmds, final Player player) { - processCmds(null, cmds, player, null, null); + processCmds(null, cmds, player, null, null); } public void processCmds(List cmds, final Player player, CMIInteractType clickType) { - processCmds(null, cmds, player, clickType, null); + processCmds(null, cmds, player, clickType, null); } public void processCmds(String initializer, List cmds, final Player player) { - processCmds(initializer, cmds, player, null, null); + processCmds(initializer, cmds, player, null, null); } public void processCmds(String initializer, List cmds, final Player player, CMIInteractType clickType) { - processCmds(initializer, cmds, player, clickType, null); + processCmds(initializer, cmds, player, clickType, null); } public void processCmds(String initializer, List cmds, final Player player, CMIInteractType clickType, CommandSender sender) { @@ -93,29 +101,29 @@ public void processCmds(String initializer, List cmds, final Player play } private class CheckStatements { - HashMap statements = new HashMap(); + HashMap statements = new HashMap(); - private String temp = null; + private String temp = null; - private CheckStatements() { + private CheckStatements() { - } + } - public void setStatement(String statement, boolean value) { - statements.put(statement.toLowerCase(), value); - } + public void setStatement(String statement, boolean value) { + statements.put(statement.toLowerCase(), value); + } - public Boolean getStatementValue(String statement) { - return statements.get(statement.toLowerCase()); - } + public Boolean getStatementValue(String statement) { + return statements.get(statement.toLowerCase()); + } - public String getTemp() { - return temp; - } + public String getTemp() { + return temp; + } - public void setTemp(String temp) { - this.temp = temp; - } + public void setTemp(String temp) { + this.temp = temp; + } } @@ -124,301 +132,233 @@ private void process(String initializer, List cmds, final Player player, } private enum failType { - proceed, cancel, none; + proceed, cancel, none; } public enum specialisedCommandType { - action, subaction, condition, statement; + action, subaction, condition, statement; } private enum invEmptyType { - hand, offhand, quickbar, armor, inv, subinv, maininv; - - public static invEmptyType getByName(String name) { - for (invEmptyType one : invEmptyType.values()) { - if (one.toString().equalsIgnoreCase(name)) - return one; - } - return null; - } + hand, offhand, quickbar, armor, inv, subinv, maininv; + + public static invEmptyType getByName(String name) { + for (invEmptyType one : invEmptyType.values()) { + if (one.toString().equalsIgnoreCase(name)) + return one; + } + return null; + } } public enum specialisedCommand { - permission("perm:[value][@][?][#]!", specialisedCommandType.condition), - group("group:[value][@][?][#]!", specialisedCommandType.condition), - bpermission("bperm:[value][@][?][#]!", specialisedCommandType.condition), - money("moneycost:[value][?][#]!", specialisedCommandType.condition), - exp("expcost:[value][?][#]!", specialisedCommandType.condition), - hasMoney("hasmoney:[value][@][?][#]!", specialisedCommandType.condition), - hasItem("hasitem:[value][@][?][#]!", specialisedCommandType.condition), - item("item:[value][?][#]!", specialisedCommandType.condition), - hasExp("hasexp:[value][@][?][#]!", specialisedCommandType.condition), - votes("votes:[value][@][?][#]!", specialisedCommandType.condition), - cooldown("cooldown:[value][?][#]!", specialisedCommandType.condition), - ucooldown("ucooldown:[value][?][#]!", specialisedCommandType.condition), - gcooldown("gcooldown:[value][?][#]!", specialisedCommandType.condition), - ifonline("ifonline:[value][?][#]!", specialisedCommandType.condition), - ifoffline("ifoffline:[value][?][#]!", specialisedCommandType.condition), - ifempty("ifempty:[value][?][#]!", specialisedCommandType.condition), - - check("check:[value1][==|>|>=|<|<=|!=][value2][?][#]!", specialisedCommandType.condition), - - statement("statement:[value]!", specialisedCommandType.statement), - if_("if:[value][@][#]!", specialisedCommandType.statement), - - ifhasair("ifhasair:[value][@][#]!", specialisedCommandType.condition), - ifhashunger("ifhashunger:[value][@][#]!", specialisedCommandType.condition), - ifhashealth("ifhashealth:[value][@][#]!", specialisedCommandType.condition), - ifingamemode("ifingamemode:[value][@][#]!", specialisedCommandType.condition), - - ifinworld("ifinworld:[value][@][?][#]!", specialisedCommandType.condition), - ifinportal("ifinportal:[value][@][?][#]!", specialisedCommandType.condition), - - click("click:[value][#]!", specialisedCommandType.condition), - - ptarget("ptarget:[value]!", specialisedCommandType.condition), - - msg("msg!", specialisedCommandType.action), - broadcast("broadcast!", specialisedCommandType.action), - actionbar("actionbar!", specialisedCommandType.action), - title("title!", specialisedCommandType.action), - subtitle("subtitle!", specialisedCommandType.action), - kickall("kickall!", specialisedCommandType.action), - - fromConsole("fromConsole!", specialisedCommandType.action), - asConsole("asConsole!", specialisedCommandType.action), - asFakeOp("asFakeOp!", specialisedCommandType.action), - likePlayer("likePlayer!", specialisedCommandType.action), - asPlayer("asPlayer!", specialisedCommandType.action), - allPlayers("allPlayers!", specialisedCommandType.action); - - private String format; - private specialisedCommandType type; - - specialisedCommand(String format, specialisedCommandType type) { - this.format = format; - this.type = type; - } - - public String getFormat() { - return format; - } - - public String getFormatForCheck() { - if (getType().equals(specialisedCommandType.action)) - return this.getFormat().toLowerCase(); - return format.split(":")[0].toLowerCase() + ":"; - } - - public void setFormat(String format) { - this.format = format; - } - - public specialisedCommandType getType() { - return type; - } - - public void setType(specialisedCommandType type) { - this.type = type; - } - - public static specCommandAction get(String arg) { - return null; - } - } - - private class specCommand { - private String cmd; - private specialisedCommand action = null; - private List subactions = new ArrayList(); - private List list = new ArrayList(); - private List statements = new ArrayList(); - - public String getCmd() { - return cmd; - } - - public void setCmd(String cmd) { - this.cmd = cmd; - } - - public List getConditionList() { - return list; - } - -// public void setList(List list) { -// this.list = list; -// } - - public void add(specCommandAction l) { - if (l.getCmd().getType().equals(specialisedCommandType.action)) { - action = l.getCmd(); - return; - } - if (l.getCmd().getType().equals(specialisedCommandType.subaction)) { - subactions.add(l); - return; - } - if (l.getCmd().getType().equals(specialisedCommandType.statement)) { - statements.add(l); - return; - } - this.list.add(l); - } - - public specialisedCommand getAction() { - return action; - } - - public List getSubactions() { - return subactions; - } - - public List getStatements() { - return statements; - } - -// public void setAction(specialisedCommand action) { -// this.action = action; -// } + permission("perm:[value][@][?][#]!", specialisedCommandType.condition), + group("group:[value][@][?][#]!", specialisedCommandType.condition), + bpermission("bperm:[value][@][?][#]!", specialisedCommandType.condition), + money("moneycost:[value][?][#]!", specialisedCommandType.condition), + exp("expcost:[value][?][#]!", specialisedCommandType.condition), + hasMoney("hasmoney:[value][@][?][#]!", specialisedCommandType.condition), + hasItem("hasitem:[value][@][?][#]!", specialisedCommandType.condition), + item("item:[value][?][#]!", specialisedCommandType.condition), + hasExp("hasexp:[value][@][?][#]!", specialisedCommandType.condition), + votes("votes:[value][@][?][#]!", specialisedCommandType.condition), + cooldown("cooldown:[value][?][#]!", specialisedCommandType.condition), + ucooldown("ucooldown:[value][?][#]!", specialisedCommandType.condition), + gcooldown("gcooldown:[value][?][#]!", specialisedCommandType.condition), + ifonline("ifonline:[value][?][#]!", specialisedCommandType.condition), + ifoffline("ifoffline:[value][?][#]!", specialisedCommandType.condition), + ifempty("ifempty:[value][?][#]!", specialisedCommandType.condition), + stopdelay("stopdelay:[value]!", specialisedCommandType.condition), + + check("check:[value1][==|>|>=|<|<=|!=][value2][?][#]!", specialisedCommandType.condition), + + statement("statement:[value]!", specialisedCommandType.statement), + if_("if:[value][@][#]!", specialisedCommandType.statement), + + ifhasair("ifhasair:[value][@][#]!", specialisedCommandType.condition), + ifhashunger("ifhashunger:[value][@][#]!", specialisedCommandType.condition), + ifhashealth("ifhashealth:[value][@][#]!", specialisedCommandType.condition), + ifingamemode("ifingamemode:[value][@][#]!", specialisedCommandType.condition), + + ifinworld("ifinworld:[value][@][?][#]!", specialisedCommandType.condition), + ifinportal("ifinportal:[value][@][?][#]!", specialisedCommandType.condition), + + click("click:[value][#]!", specialisedCommandType.condition), + + ptarget("ptarget:[value]!", specialisedCommandType.condition), + + closeinv("closeinv!", specialisedCommandType.subaction), + + msg("msg!", specialisedCommandType.action), + broadcast("broadcast!", specialisedCommandType.action), + actionbar("actionbar!", specialisedCommandType.action), + title("title!", specialisedCommandType.action), + subtitle("subtitle!", specialisedCommandType.action), + kickall("kickall!", specialisedCommandType.action), + + fromConsole("fromConsole!", specialisedCommandType.action), + asConsole("asConsole!", specialisedCommandType.action), + asFakeOp("asFakeOp!", specialisedCommandType.action), + likePlayer("likePlayer!", specialisedCommandType.action), + asPlayer("asPlayer!", specialisedCommandType.action), + allPlayers("allPlayers!", specialisedCommandType.action); + + private String format; + private specialisedCommandType type; + + specialisedCommand(String format, specialisedCommandType type) { + this.format = format; + this.type = type; + } + + public String getFormat() { + return format; + } + + public String getFormatForCheck() { + if (getType().equals(specialisedCommandType.action) || getType().equals(specialisedCommandType.subaction)) + return this.getFormat().toLowerCase(); + return format.split(":")[0].toLowerCase() + ":"; + } + + public void setFormat(String format) { + this.format = format; + } + + public specialisedCommandType getType() { + return type; + } + + public void setType(specialisedCommandType type) { + this.type = type; + } + + public static specCommandAction get(String arg) { + + return null; + } } public class specCommandAction { - private specialisedCommand cmd; - private boolean needToBreak = false; - private boolean needToInform = false; - private boolean opposite = false; - private Object value = null; - private Object value2 = null; - - private String initializer = null; - - public specCommandAction(specialisedCommand cmd) { - this.cmd = cmd; - } - - public specialisedCommand getCmd() { - return cmd; - } - - public void setCmd(specialisedCommand cmd) { - this.cmd = cmd; - } - - public boolean isNeedToBreak() { - return needToBreak; - } - - public void setNeedToBreak(boolean needToBreak) { - this.needToBreak = needToBreak; - } - - public boolean isNeedToInform() { - return needToInform; - } - - public void setNeedToInform(boolean needToInform) { - this.needToInform = needToInform; - } - - public Object getValue() { - return value; - } - - public void setValue(Object value) { - this.value = value; - } - - public Object getValue2() { - return value2; - } - - public void setValue2(Object value2) { - this.value2 = value2; - } - - public boolean isOpposite() { - return opposite; - } - - public void setOpposite(boolean opposite) { - this.opposite = opposite; - } - - public String getInitializer() { - return initializer; - } - - public void setInitializer(String initializer) { - this.initializer = initializer; - } + private specialisedCommand cmd; + private boolean needToBreak = false; + private boolean needToInform = false; + private boolean stopAfter = false; + private boolean opposite = false; + private Object value = null; + private Object value2 = null; + + private String initializer = null; + + public specCommandAction(specialisedCommand cmd) { + this.cmd = cmd; + } + + public specialisedCommand getCmd() { + return cmd; + } + + public void setCmd(specialisedCommand cmd) { + this.cmd = cmd; + } + + public boolean isNeedToBreak() { + return needToBreak; + } + + public void setNeedToBreak(boolean needToBreak) { + this.needToBreak = needToBreak; + } + + public boolean isNeedToInform() { + return needToInform; + } + + public void setNeedToInform(boolean needToInform) { + this.needToInform = needToInform; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public Object getValue2() { + return value2; + } + + public void setValue2(Object value2) { + this.value2 = value2; + } + + public boolean isOpposite() { + return opposite; + } + + public void setOpposite(boolean opposite) { + this.opposite = opposite; + } + + public String getInitializer() { + return initializer; + } + + public void setInitializer(String initializer) { + this.initializer = initializer; + } + + public boolean isStopAfter() { + return stopAfter; + } + + public void setStopAfter(boolean stopAfter) { + this.stopAfter = stopAfter; + } } public specCommand processSpecializedCommand(String cmd) { - - return null; + + return null; } public boolean isSpecializedCommand(String cmd) { - specCommand processed = processSpecializedCommand(cmd); - if (processed.getConditionList().isEmpty() && processed.getAction() == null) { - return false; - } - return true; + + return true; } -// Pattern patern = Pattern.compile("^ptarget:(\\S+)!"); Pattern patern = Pattern.compile("^ptarget:(\\S+)!|^asPlayer! ptarget:(\\S+)!"); public boolean executeCmd(String cmd, Player senderPlayer) { - return executeCmd(cmd, senderPlayer, null); + return executeCmd(cmd, senderPlayer, null); } public boolean executeCmd(String cmd, Player senderPlayer, CMIInteractType clickType) { - return executeCmd(cmd, senderPlayer, clickType, null); + return executeCmd(cmd, senderPlayer, clickType, null); } public boolean executeCmd(String cmd, Player senderPlayer, CMIInteractType clickType, CommandSender sender) { - return executeCmd(null, cmd, senderPlayer, clickType, sender); + return executeCmd(null, cmd, senderPlayer, clickType, sender); } public boolean executeCmd(String initializer, String cmd, Player senderPlayer, CMIInteractType clickType, CommandSender sender) { - return executeCmd(initializer, cmd, senderPlayer, clickType, sender, null); + return executeCmd(initializer, cmd, senderPlayer, clickType, sender, null); } public boolean executeCmd(String initializer, String cmd, Player senderPlayer, CMIInteractType clickType, CommandSender sender, CheckStatements groupedStatements) { - - return true; - } - - private static void processCondition(failType feedback, CheckStatements groupedConditions) { - if (groupedConditions == null || groupedConditions.getTemp() == null) - return; - groupedConditions.setStatement(groupedConditions.getTemp(), feedback == failType.none); - groupedConditions.setTemp(null); + return true; } private static final Pattern PATTERN_ON_SPACE = Pattern.compile(" ", Pattern.LITERAL); public synchronized boolean dispatch(CommandSender sender, String commandLine) throws CommandException { - return false; - } - - private static boolean isOpCmd(String cmd) { - return cmd.toLowerCase().startsWith("op") || cmd.toLowerCase().startsWith("minecraft:op") || cmd.toLowerCase().startsWith("deop") || cmd.toLowerCase().startsWith("minecraft:deop"); - } - private failType deductForCommand(Player player, List conditions) { - - return null; + return false; } Pattern checkPattern = Pattern.compile("(.+)?(==|>=|>|<=|<|!=)(.+)"); - private failType canPerformCommand(Player player, List conditions, boolean deduct, CMIInteractType clickType, CheckStatements groupedStatements) { - - return null; - } - } diff --git a/src/com/Zrips/CMI/Modules/SpecializedCommands/specCommand.java b/src/com/Zrips/CMI/Modules/SpecializedCommands/specCommand.java new file mode 100644 index 0000000..f184b4c --- /dev/null +++ b/src/com/Zrips/CMI/Modules/SpecializedCommands/specCommand.java @@ -0,0 +1,43 @@ +package com.Zrips.CMI.Modules.SpecializedCommands; + +import java.util.ArrayList; +import java.util.List; + +import com.Zrips.CMI.Modules.SpecializedCommands.SpecializedCommandManager.specCommandAction; +import com.Zrips.CMI.Modules.SpecializedCommands.SpecializedCommandManager.specialisedCommand; + +public class specCommand { + private String cmd; + private specialisedCommand action = null; + private List subactions = new ArrayList(); + private List list = new ArrayList(); + private List statements = new ArrayList(); + + public String getCmd() { + return cmd; + } + + public void setCmd(String cmd) { + this.cmd = cmd; + } + + public List getConditionList() { + return list; + } + + public void add(specCommandAction l) { + } + + public specialisedCommand getAction() { + return action; + } + + public List getSubactions() { + return subactions; + } + + public List getStatements() { + return statements; + } + +} diff --git a/src/com/Zrips/CMI/Modules/Statistics/CMIStats.java b/src/com/Zrips/CMI/Modules/Statistics/CMIStats.java index 40d4eff..70b79e2 100644 --- a/src/com/Zrips/CMI/Modules/Statistics/CMIStats.java +++ b/src/com/Zrips/CMI/Modules/Statistics/CMIStats.java @@ -1,72 +1,45 @@ package com.Zrips.CMI.Modules.Statistics; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; - import com.Zrips.CMI.Containers.CMIUser; import com.Zrips.CMI.Modules.Statistics.StatsManager.CMIStatistic; -import com.Zrips.CMI.Modules.Statistics.StatsManager.svt; -import net.Zrips.CMILib.Version.Version; - -import net.Zrips.CMILib.Entities.CMIEntityType; -import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; public class CMIStats { private CMIUser user; public CMIStats(CMIUser user) { - this.user = user; + this.user = user; } public CMIUser getUser() { - return user; + return user; } public void setUser(CMIUser user) { - this.user = user; + this.user = user; } public Long getStat(CMIStatistic stat) { - return getStat(stat, null); + return getStat(stat, null); } public Long getStat(CMIStatistic stat, Object thing) { - return null; + return null; } private Long getStats(CMIStatistic stat) { - if (stat == CMIStatistic.PLAY_ONE_TICK && user != null) { - return user.getTotalPlayTime(false); - } - if (stat == CMIStatistic.TRAVEL) { - return getTotalTravelDistance(); - } - if (stat == CMIStatistic.ACOUNT_AGE && user != null) { - Player player = user.getPlayer(); - if (player != null) - return System.currentTimeMillis() - player.getFirstPlayed(); - } - return getTotal(stat); + + return null; } public Long getTotalTravelDistance() { - Long i = 0L; - for (CMIStatistic oneS : CMIStatistic.values()) { - if (oneS.getType() != svt.Distance) - continue; - if (oneS.getBukkitStat() == null) - continue; - i += getStat(oneS); - } - return i; + + return null; } private long getTotal(CMIStatistic stat) { - return 0L; + return 0; } } diff --git a/src/com/Zrips/CMI/Modules/Statistics/StatsManager.java b/src/com/Zrips/CMI/Modules/Statistics/StatsManager.java index 1fa26d2..3c3ab24 100644 --- a/src/com/Zrips/CMI/Modules/Statistics/StatsManager.java +++ b/src/com/Zrips/CMI/Modules/Statistics/StatsManager.java @@ -21,17 +21,18 @@ import net.Zrips.CMILib.CMILib; import net.Zrips.CMILib.Entities.CMIEntityType; import net.Zrips.CMILib.Items.CMIItemStack; +import net.Zrips.CMILib.Logs.CMIDebug; public class StatsManager { private CMI plugin; public enum svt { - Time, Distance, Damage, Number + Time, Distance, Damage, Number } public enum CMIType { - None, Material, Block, Entity + None, Material, Block, Entity } private static HashMap cache = new HashMap(); @@ -41,210 +42,209 @@ public enum CMIType { public enum CMIStatistic { - LEAVE_GAME("Game quit", svt.Number, false, false, CMIType.None), - PLAY_ONE_TICK("Play time", svt.Time, false, false, CMIType.None, "PLAY_ONE_MINUTE"), - TIME_SINCE_DEATH("From last death", svt.Time, false, false, CMIType.None), - TIME_SINCE_REST("From last rest", svt.Time, false, false, CMIType.None), - SNEAK_TIME("Sneak time", svt.Time, false, false, CMIType.None), - ACOUNT_AGE("Account age", svt.Time, false, false, CMIType.None), - - TRAVEL("Travel", svt.Distance, false, false, CMIType.None), - WALK_ONE_CM("Walk", svt.Distance, false, false, CMIType.None), - CROUCH_ONE_CM("Sneak", svt.Distance, false, false, CMIType.None), - SPRINT_ONE_CM("Sprint", svt.Distance, false, false, CMIType.None), - SWIM_ONE_CM("Swim", svt.Distance, false, false, CMIType.None), - FALL_ONE_CM("Fall", svt.Distance, false, false, CMIType.None), - CLIMB_ONE_CM("Climb", svt.Distance, false, false, CMIType.None), - FLY_ONE_CM("Fly", svt.Distance, false, false, CMIType.None), - DIVE_ONE_CM("Dive", svt.Distance, false, false, CMIType.None), - WALK_UNDER_WATER_ONE_CM("Walk under water", svt.Distance, false, false, CMIType.None), - WALK_ON_WATER_ONE_CM("Walk on water", svt.Distance, false, false, CMIType.None), - MINECART_ONE_CM("Minecart travel", svt.Distance, false, false, CMIType.None), - BOAT_ONE_CM("Boat travel", svt.Distance, false, false, CMIType.None), - PIG_ONE_CM("Pig travel", svt.Distance, false, false, CMIType.None), - HORSE_ONE_CM("Horse travel", svt.Distance, false, false, CMIType.None), - AVIATE_ONE_CM("Elytra travel", svt.Distance, false, false, CMIType.None), - - JUMP("Jump", svt.Number, false, false, CMIType.None), - DAMAGE_DEALT("Damage dealt", svt.Damage, false, false, CMIType.None), - DAMAGE_TAKEN("Damage taken", svt.Damage, false, false, CMIType.None), - DAMAGE_DEALT_ABSORBED("Damage dealt absorbed", svt.Damage, false, false, CMIType.None), - DAMAGE_DEALT_RESISTED("Damage dealt resisted", svt.Damage, false, false, CMIType.None), - DAMAGE_BLOCKED_BY_SHIELD("Damage blocked by shield", svt.Damage, false, false, CMIType.None), - DAMAGE_ABSORBED("Damage absorbed", svt.Damage, false, false, CMIType.None), - DAMAGE_RESISTED("Damage resisted", svt.Damage, false, false, CMIType.None), - DEATHS("Deaths", svt.Number, false, false, CMIType.None), - ENTITY_KILLED_BY("Killed by", svt.Number, false, true, CMIType.Entity), - MOB_KILLS("Mob kills", svt.Number, false, false, CMIType.None), - PLAYER_KILLS("Player kills", svt.Number, false, false, CMIType.None), - ITEM_ENCHANTED("Item enchanted", svt.Number, false, false, CMIType.None), - ANIMALS_BRED("Animals bred", svt.Number, false, false, CMIType.None), - FISH_CAUGHT("Fish caught", svt.Number, false, false, CMIType.None), - TALKED_TO_VILLAGER("Talked to villager", svt.Number, false, false, CMIType.None), - TRADED_WITH_VILLAGER("Traded with villager", svt.Number, false, false, CMIType.None), - CAKE_SLICES_EATEN("Cake slices eaten", svt.Number, false, false, CMIType.None), - CAULDRON_FILLED("Cauldron filled", svt.Number, false, false, CMIType.None), - CAULDRON_USED("Couldron used", svt.Number, false, false, CMIType.None), - ARMOR_CLEANED("Armor cleaned", svt.Number, false, false, CMIType.None), - BANNER_CLEANED("Banner cleaned", svt.Number, false, false, CMIType.None), - BREWINGSTAND_INTERACTION("Brewing stand interactions", svt.Number, false, false, CMIType.None), - BEACON_INTERACTION("Beacon interactions", svt.Number, false, false, CMIType.None), - CRAFTING_TABLE_INTERACTION("Crafting table interactions", svt.Number, false, false, CMIType.None), - FURNACE_INTERACTION("Furnace interactions", svt.Number, false, false, CMIType.None), - DISPENSER_INSPECTED("Dispenser inspected", svt.Number, false, false, CMIType.None), - DROPPER_INSPECTED("Dropper inspected", svt.Number, false, false, CMIType.None), - HOPPER_INSPECTED("Hopper inspected", svt.Number, false, false, CMIType.None), - CHEST_OPENED("Chest open", svt.Number, false, false, CMIType.None), - TRAPPED_CHEST_TRIGGERED("Trapped chest triggered", svt.Number, false, false, CMIType.None), - ENDERCHEST_OPENED("Ender chest opened", svt.Number, false, false, CMIType.None), - NOTEBLOCK_PLAYED("Noteblock played", svt.Number, false, false, CMIType.None), - NOTEBLOCK_TUNED("Noteblock tuned", svt.Number, false, false, CMIType.None), - FLOWER_POTTED("Flower potted", svt.Number, false, false, CMIType.None), - RECORD_PLAYED("Record played", svt.Number, false, false, CMIType.None), - SLEEP_IN_BED("Slept in bed", svt.Number, false, false, CMIType.None), - SHULKER_BOX_OPENED("Shulker box opened", svt.Number, false, false, CMIType.None), - CLEAN_SHULKER_BOX("Shulker box cleaned", svt.Number, false, false, CMIType.None), - - DROP("Item dropped", svt.Number, false, true, CMIType.Material), - MINE_BLOCK("Blocks mined", svt.Number, true, true, CMIType.Block), - PLACE_BLOCK("Blocks placed", svt.Number, true, true, CMIType.Block, Statistic.USE_ITEM), - BREAK_ITEM("Item breaks", svt.Number, false, true, CMIType.Material), - CRAFT_ITEM("Item crafts", svt.Number, false, true, CMIType.Material), - USE_ITEM("Items used", svt.Number, false, true, CMIType.Material), - PICKUP("Item pickups", svt.Number, false, true, CMIType.Material), - KILL_ENTITY("Monster kills", svt.Number, false, true, CMIType.Entity), - - STRIDER_ONE_CM("Strider travel", svt.Distance, false, false, CMIType.None), - - INTERACT_WITH_BLAST_FURNACE("Interaction with blast furnace", svt.Number, false, false, CMIType.None), - INTERACT_WITH_SMOKER("Interaction with smoker", svt.Number, false, false, CMIType.None), - INTERACT_WITH_LECTERN("Interaction with lectern", svt.Number, false, false, CMIType.None), - INTERACT_WITH_CAMPFIRE("Interaction with campfire", svt.Number, false, false, CMIType.None), - INTERACT_WITH_CARTOGRAPHY_TABLE("Interaction with cartography table", svt.Number, false, false, CMIType.None), - INTERACT_WITH_LOOM("Interaction with loom", svt.Number, false, false, CMIType.None), - INTERACT_WITH_STONECUTTER("Interaction with stonecutter", svt.Number, false, false, CMIType.None), - INTERACT_WITH_ANVIL("Interaction with anvil", svt.Number, false, false, CMIType.None), - INTERACT_WITH_GRINDSTONE("Interaction with grindstone", svt.Number, false, false, CMIType.None), - INTERACT_WITH_SMITHING_TABLE("Interaction with smithing table", svt.Number, false, false, CMIType.None), - - BELL_RING("Bell rings", svt.Number, false, false, CMIType.None), - RAID_TRIGGER("Raid triggers", svt.Number, false, false, CMIType.None), - RAID_WIN("Raid wins", svt.Number, false, false, CMIType.None), - TARGET_HIT("Target hits", svt.Number, false, false, CMIType.None), - OPEN_BARREL("Opened barrels", svt.Number, false, false, CMIType.None), - DROP_COUNT("Drop count", svt.Number, false, false, CMIType.None), - - TOTAL_WORLD_TIME("Time in world", svt.Time, false, false, CMIType.None), - - ; - - private svt type; - private boolean isBlock; - private boolean isSubSatistic; - private CMIType subType; - private String name; - private String newName; - private Statistic bukkit; - private boolean checked = false; - - CMIStatistic(String name, svt type, boolean isBlock, boolean isSubSatistic, CMIType subType, Statistic stat) { - this(name, type, isBlock, isSubSatistic, subType, ""); - bukkit = stat; - } - - CMIStatistic(String name, svt type, boolean isBlock, boolean isSubSatistic, CMIType subType, String newName) { - this.name = name; - this.type = type; - this.isBlock = isBlock; - this.isSubSatistic = isSubSatistic; - this.subType = subType; - this.newName = newName.isEmpty() ? null : newName; - } - - CMIStatistic(String name, svt type, boolean isBlock, boolean isSubSatistic, CMIType subType) { - this(name, type, isBlock, isSubSatistic, subType, ""); - } - - public svt getType() { - return type; - } - - public boolean isBlock() { - return isBlock; - } - - public void setBlock(boolean isBlock) { - this.isBlock = isBlock; - } - - public boolean isSubSatistic() { - return isSubSatistic; - } - - public void setSubSatistic(boolean isSubSatistic) { - this.isSubSatistic = isSubSatistic; - } - - public CMIType getSubType() { - return subType; - } - - public Statistic getBukkitStat() { - if (bukkit == null && !checked) { - checked = true; - for (Statistic one : Statistic.values()) { - if (one.name().equalsIgnoreCase(this.name())) - bukkit = one; - if (getNewName() != null && one.name().equalsIgnoreCase(getNewName())) - bukkit = one; - } - } - return bukkit; - } - - public String getName() { - return name; - } - - public String getNewName() { - return newName; - } - - public static CMIStatistic getByName(String name) { - return cache.get(name.toLowerCase().replace("_", "")); - } + LEAVE_GAME("Game quit", svt.Number, false, false, CMIType.None), + PLAY_ONE_TICK("Play time", svt.Time, false, false, CMIType.None, "PLAY_ONE_MINUTE"), + TIME_SINCE_DEATH("From last death", svt.Time, false, false, CMIType.None), + TIME_SINCE_REST("From last rest", svt.Time, false, false, CMIType.None), + SNEAK_TIME("Sneak time", svt.Time, false, false, CMIType.None), + ACOUNT_AGE("Account age", svt.Time, false, false, CMIType.None), + + TRAVEL("Travel", svt.Distance, false, false, CMIType.None), + WALK_ONE_CM("Walk", svt.Distance, false, false, CMIType.None), + CROUCH_ONE_CM("Sneak", svt.Distance, false, false, CMIType.None), + SPRINT_ONE_CM("Sprint", svt.Distance, false, false, CMIType.None), + SWIM_ONE_CM("Swim", svt.Distance, false, false, CMIType.None), + FALL_ONE_CM("Fall", svt.Distance, false, false, CMIType.None), + CLIMB_ONE_CM("Climb", svt.Distance, false, false, CMIType.None), + FLY_ONE_CM("Fly", svt.Distance, false, false, CMIType.None), + DIVE_ONE_CM("Dive", svt.Distance, false, false, CMIType.None), + WALK_UNDER_WATER_ONE_CM("Walk under water", svt.Distance, false, false, CMIType.None), + WALK_ON_WATER_ONE_CM("Walk on water", svt.Distance, false, false, CMIType.None), + MINECART_ONE_CM("Minecart travel", svt.Distance, false, false, CMIType.None), + BOAT_ONE_CM("Boat travel", svt.Distance, false, false, CMIType.None), + PIG_ONE_CM("Pig travel", svt.Distance, false, false, CMIType.None), + HORSE_ONE_CM("Horse travel", svt.Distance, false, false, CMIType.None), + AVIATE_ONE_CM("Elytra travel", svt.Distance, false, false, CMIType.None), + + JUMP("Jump", svt.Number, false, false, CMIType.None), + DAMAGE_DEALT("Damage dealt", svt.Damage, false, false, CMIType.None), + DAMAGE_TAKEN("Damage taken", svt.Damage, false, false, CMIType.None), + DAMAGE_DEALT_ABSORBED("Damage dealt absorbed", svt.Damage, false, false, CMIType.None), + DAMAGE_DEALT_RESISTED("Damage dealt resisted", svt.Damage, false, false, CMIType.None), + DAMAGE_BLOCKED_BY_SHIELD("Damage blocked by shield", svt.Damage, false, false, CMIType.None), + DAMAGE_ABSORBED("Damage absorbed", svt.Damage, false, false, CMIType.None), + DAMAGE_RESISTED("Damage resisted", svt.Damage, false, false, CMIType.None), + DEATHS("Deaths", svt.Number, false, false, CMIType.None), + ENTITY_KILLED_BY("Killed by", svt.Number, false, true, CMIType.Entity), + MOB_KILLS("Mob kills", svt.Number, false, false, CMIType.None), + PLAYER_KILLS("Player kills", svt.Number, false, false, CMIType.None), + ITEM_ENCHANTED("Item enchanted", svt.Number, false, false, CMIType.None), + ANIMALS_BRED("Animals bred", svt.Number, false, false, CMIType.None), + FISH_CAUGHT("Fish caught", svt.Number, false, false, CMIType.None), + TALKED_TO_VILLAGER("Talked to villager", svt.Number, false, false, CMIType.None), + TRADED_WITH_VILLAGER("Traded with villager", svt.Number, false, false, CMIType.None), + CAKE_SLICES_EATEN("Cake slices eaten", svt.Number, false, false, CMIType.None), + CAULDRON_FILLED("Cauldron filled", svt.Number, false, false, CMIType.None), + CAULDRON_USED("Couldron used", svt.Number, false, false, CMIType.None), + ARMOR_CLEANED("Armor cleaned", svt.Number, false, false, CMIType.None), + BANNER_CLEANED("Banner cleaned", svt.Number, false, false, CMIType.None), + BREWINGSTAND_INTERACTION("Brewing stand interactions", svt.Number, false, false, CMIType.None), + BEACON_INTERACTION("Beacon interactions", svt.Number, false, false, CMIType.None), + CRAFTING_TABLE_INTERACTION("Crafting table interactions", svt.Number, false, false, CMIType.None), + FURNACE_INTERACTION("Furnace interactions", svt.Number, false, false, CMIType.None), + DISPENSER_INSPECTED("Dispenser inspected", svt.Number, false, false, CMIType.None), + DROPPER_INSPECTED("Dropper inspected", svt.Number, false, false, CMIType.None), + HOPPER_INSPECTED("Hopper inspected", svt.Number, false, false, CMIType.None), + CHEST_OPENED("Chest open", svt.Number, false, false, CMIType.None), + TRAPPED_CHEST_TRIGGERED("Trapped chest triggered", svt.Number, false, false, CMIType.None), + ENDERCHEST_OPENED("Ender chest opened", svt.Number, false, false, CMIType.None), + NOTEBLOCK_PLAYED("Noteblock played", svt.Number, false, false, CMIType.None), + NOTEBLOCK_TUNED("Noteblock tuned", svt.Number, false, false, CMIType.None), + FLOWER_POTTED("Flower potted", svt.Number, false, false, CMIType.None), + RECORD_PLAYED("Record played", svt.Number, false, false, CMIType.None), + SLEEP_IN_BED("Slept in bed", svt.Number, false, false, CMIType.None), + SHULKER_BOX_OPENED("Shulker box opened", svt.Number, false, false, CMIType.None), + CLEAN_SHULKER_BOX("Shulker box cleaned", svt.Number, false, false, CMIType.None), + + DROP("Item dropped", svt.Number, false, true, CMIType.Material), + MINE_BLOCK("Blocks mined", svt.Number, true, true, CMIType.Block), + PLACE_BLOCK("Blocks placed", svt.Number, true, true, CMIType.Block, Statistic.USE_ITEM), + BREAK_ITEM("Item breaks", svt.Number, false, true, CMIType.Material), + CRAFT_ITEM("Item crafts", svt.Number, false, true, CMIType.Material), + USE_ITEM("Items used", svt.Number, false, true, CMIType.Material), + PICKUP("Item pickups", svt.Number, false, true, CMIType.Material), + KILL_ENTITY("Monster kills", svt.Number, false, true, CMIType.Entity), + + STRIDER_ONE_CM("Strider travel", svt.Distance, false, false, CMIType.None), + + INTERACT_WITH_BLAST_FURNACE("Interaction with blast furnace", svt.Number, false, false, CMIType.None), + INTERACT_WITH_SMOKER("Interaction with smoker", svt.Number, false, false, CMIType.None), + INTERACT_WITH_LECTERN("Interaction with lectern", svt.Number, false, false, CMIType.None), + INTERACT_WITH_CAMPFIRE("Interaction with campfire", svt.Number, false, false, CMIType.None), + INTERACT_WITH_CARTOGRAPHY_TABLE("Interaction with cartography table", svt.Number, false, false, CMIType.None), + INTERACT_WITH_LOOM("Interaction with loom", svt.Number, false, false, CMIType.None), + INTERACT_WITH_STONECUTTER("Interaction with stonecutter", svt.Number, false, false, CMIType.None), + INTERACT_WITH_ANVIL("Interaction with anvil", svt.Number, false, false, CMIType.None), + INTERACT_WITH_GRINDSTONE("Interaction with grindstone", svt.Number, false, false, CMIType.None), + INTERACT_WITH_SMITHING_TABLE("Interaction with smithing table", svt.Number, false, false, CMIType.None), + + BELL_RING("Bell rings", svt.Number, false, false, CMIType.None), + RAID_TRIGGER("Raid triggers", svt.Number, false, false, CMIType.None), + RAID_WIN("Raid wins", svt.Number, false, false, CMIType.None), + TARGET_HIT("Target hits", svt.Number, false, false, CMIType.None), + OPEN_BARREL("Opened barrels", svt.Number, false, false, CMIType.None), + DROP_COUNT("Drop count", svt.Number, false, false, CMIType.None), + + TOTAL_WORLD_TIME("Time in world", svt.Time, false, false, CMIType.None), + + ; + + private svt type; + private boolean isBlock; + private boolean isSubSatistic; + private CMIType subType; + private String name; + private String newName; + private Statistic bukkit; + private boolean checked = false; + + CMIStatistic(String name, svt type, boolean isBlock, boolean isSubSatistic, CMIType subType, Statistic stat) { + this(name, type, isBlock, isSubSatistic, subType, ""); + bukkit = stat; + } + + CMIStatistic(String name, svt type, boolean isBlock, boolean isSubSatistic, CMIType subType, String newName) { + this.name = name; + this.type = type; + this.isBlock = isBlock; + this.isSubSatistic = isSubSatistic; + this.subType = subType; + this.newName = newName.isEmpty() ? null : newName; + } + + CMIStatistic(String name, svt type, boolean isBlock, boolean isSubSatistic, CMIType subType) { + this(name, type, isBlock, isSubSatistic, subType, ""); + } + + public svt getType() { + return type; + } + + public boolean isBlock() { + return isBlock; + } + + public void setBlock(boolean isBlock) { + this.isBlock = isBlock; + } + + public boolean isSubSatistic() { + return isSubSatistic; + } + + public void setSubSatistic(boolean isSubSatistic) { + this.isSubSatistic = isSubSatistic; + } + + public CMIType getSubType() { + return subType; + } + + public Statistic getBukkitStat() { + if (bukkit == null && !checked) { + checked = true; + for (Statistic one : Statistic.values()) { + if (one.name().equalsIgnoreCase(this.name())) + bukkit = one; + if (getNewName() != null && one.name().equalsIgnoreCase(getNewName())) + bukkit = one; + } + } + return bukkit; + } + + public String getName() { + return name; + } + + public String getNewName() { + return newName; + } + + public static CMIStatistic getByName(String name) { + return cache.get(name.toLowerCase().replace("_", "")); + } } private int autoTimerBukkitId = 0; public StatsManager(CMI plugin) { - this.plugin = plugin; - autoTimerBukkitId = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, autoTimer, 60 * 20L, 60 * 20L); + this.plugin = plugin; + autoTimerBukkitId = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, autoTimer, 60 * 20L, 60 * 20L); } public void stop() { - if (autoTimerBukkitId > 0) - Bukkit.getScheduler().cancelTask(autoTimerBukkitId); + if (autoTimerBukkitId > 0) + Bukkit.getScheduler().cancelTask(autoTimerBukkitId); } public CMIStatistic getStatisticByName(String name) { - return cache.get(name.toLowerCase().replace("_", "").replace(" ", "")); + return cache.get(name.toLowerCase().replace("_", "").replace(" ", "")); } public Statistic getStatistic(CMIStatistic type) { - if (type.getBukkitStat() != null) - return type.getBukkitStat(); - for (Statistic one : Statistic.values()) { - if (one.name().equalsIgnoreCase(type.name())) - return one; - } - return null; + if (type.getBukkitStat() != null) + return type.getBukkitStat(); + for (Statistic one : Statistic.values()) { + if (one.name().equalsIgnoreCase(type.name())) + return one; + } + return null; } public synchronized boolean changeTo(Player player, CMIStatistic st, String extra, Long amount) { - - return true; + return true; } private BukkitTask task; @@ -253,69 +253,82 @@ public synchronized boolean changeTo(Player player, CMIStatistic st, String extr private boolean loaded = false; public boolean isScanning() { - return task != null; + return task != null; } public boolean isDataLoaded() { - return loaded; + return loaded; } public int getTotalCount() { - return sm.size(); + return sm.size(); } public int getPages() { - return sm.size() / 10; + return sm.size() / 10; } public void addUserData(CMIUser user) { - if (isScanning()) - return; - if (Config.PlaytimeTopExclude.contains(user.getName(false).toLowerCase())) - return; - Long time = user.getTotalPlayTime(false); - Long od = smt.get(user.getUniqueId()); - if (od != null) { - sm.remove(od); - } - smt.put(user.getUniqueId(), time); - sm.put(time, user); + if (isScanning()) + return; + if (Config.PlaytimeTopExclude.contains(user.getName(false).toLowerCase())) + return; + if (plugin.getPlayerManager().getFakeUserName().equals(user.getName(false))) + return; + Long time = user.getTotalPlayTime(false); + Long od = smt.get(user.getUniqueId()); + if (od != null) { + sm.remove(od); + } + smt.put(user.getUniqueId(), time); + sm.put(time, user); } public Long getPlaytimeFromCache(CMIUser user) { - return smt.get(user.getUniqueId()); + return smt.get(user.getUniqueId()); } long lastUpdate = 0L; // SortedMap tmp = Collections.synchronizedSortedMap(new TreeMap(Collections.reverseOrder())); public SortedMap getTop() { - return null; + + return null; } public synchronized SortedMap getTop(int count) { - return null; + + return null; + } + + public synchronized Long getTimeByPlace(int place) { + + return null; + } + + public synchronized CMIUser getUserByPlace(int place) { + + return null; } public int getPlace(CMIUser user) { - int i = 0; - UUID uuid = user.getUniqueId(); - for (Entry one : sm.entrySet()) { - i++; - if (one.getValue().getUniqueId().equals(uuid)) - return i; - } - return 0; + + return 0; } private Runnable autoTimer = new Runnable() { - @Override - public void run() { - - } + @Override + public void run() { + for (Player one : Bukkit.getOnlinePlayers()) { + CMIUser user = plugin.getPlayerManager().getUser(one); + if (user.isVanished()) + continue; + addUserData(user); + } + } }; public void loadStats(final CommandSender sender, final String targetName) { - + } } diff --git a/src/com/Zrips/CMI/Modules/TabList/CMITabSortingType.java b/src/com/Zrips/CMI/Modules/TabList/CMITabSortingType.java index 349179f..374ecdc 100644 --- a/src/com/Zrips/CMI/Modules/TabList/CMITabSortingType.java +++ b/src/com/Zrips/CMI/Modules/TabList/CMITabSortingType.java @@ -8,22 +8,11 @@ public enum CMITabSortingType { Group, CustomGroup, Name, NickName, Balance, World; public static CMITabSortingType getByName(String name) { - for (CMITabSortingType one : CMITabSortingType.values()) { - if (one.toString().equalsIgnoreCase(name)) - return one; - } - return null; + return null; } public static String toStringList() { - String n = ""; - for (CMITabSortingType one : CMITabSortingType.values()) { - if (!n.isEmpty()) - n += CMI.getInstance().getMsg(LC.info_ListSpliter); - n += one.toString(); - } - - return n; + return null; } } diff --git a/src/com/Zrips/CMI/Modules/TabList/TabList.java b/src/com/Zrips/CMI/Modules/TabList/TabList.java index d7df137..bc6d250 100644 --- a/src/com/Zrips/CMI/Modules/TabList/TabList.java +++ b/src/com/Zrips/CMI/Modules/TabList/TabList.java @@ -1,7 +1,6 @@ package com.Zrips.CMI.Modules.TabList; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; @@ -18,59 +17,67 @@ public TabList() { } public String getPlayerNameFormat() { - return playerNameFormat; + return playerNameFormat; } public void setPlayerNameFormat(String format) { - this.playerNameFormat = format; + this.playerNameFormat = format; } public void prepareNextAnimationForHeader() { + } public void prepareNextAnimationForFooter() { + } public List getHeader() { - return null; + return null; } @Deprecated public void setHeader(List header) { - headerMap.put(1, header); + headerMap.put(1, header); } public void addHeaderAnimation(List header) { - headerMap.put(headerMap.size() + 1, header); + headerMap.put(headerMap.size() + 1, header); } public void addFooterAnimation(List footer) { - footerMap.put(footerMap.size() + 1, footer); + footerMap.put(footerMap.size() + 1, footer); } public List getFooter() { - return null; + if (footerMap.size() == 1) { + for (Entry> one : footerMap.entrySet()) { + return one.getValue(); + } + return new ArrayList(); + } + return footerMap.get(lastFooter); } @Deprecated public void setFooter(List footer) { - footerMap.put(1, footer); + footerMap.put(1, footer); } public HashMap> getHeaderMap() { - return headerMap; + return headerMap; } public void setHeaderMap(HashMap> headerMap) { - this.headerMap = headerMap; + this.headerMap = headerMap; } public HashMap> getFooterMap() { - return footerMap; + return footerMap; } public void setFooterMap(HashMap> footerMap) { - this.footerMap = footerMap; + this.footerMap = footerMap; } } diff --git a/src/com/Zrips/CMI/Modules/TabList/TabListHeaderFooterHandler.java b/src/com/Zrips/CMI/Modules/TabList/TabListHeaderFooterHandler.java index 1ffec7f..d162949 100644 --- a/src/com/Zrips/CMI/Modules/TabList/TabListHeaderFooterHandler.java +++ b/src/com/Zrips/CMI/Modules/TabList/TabListHeaderFooterHandler.java @@ -22,6 +22,7 @@ public class TabListHeaderFooterHandler { private CMI plugin; public TabListHeaderFooterHandler(CMI plugin) { + } public void send(Player receivingPacket, List h, List f) { @@ -33,34 +34,32 @@ public void send(Player receivingPacket, String header, String footer) { } private void sendPacket(Player player, Object packet) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { - Object handle = getHandle.invoke(player); - Object connection = playerConnection.get(handle); - sendPacket.invoke(connection, packet); + } private String getCraftPlayerClasspath() { - return "org.bukkit.craftbukkit." + version + ".entity.CraftPlayer"; + return "org.bukkit.craftbukkit." + version + ".entity.CraftPlayer"; } private String getPlayerConnectionClasspath() { - return "net.minecraft.server." + version + ".PlayerConnection"; + return "net.minecraft.server." + version + ".PlayerConnection"; } private String getNMSPlayerClasspath() { - return "net.minecraft.server." + version + ".EntityPlayer"; + return "net.minecraft.server." + version + ".EntityPlayer"; } private String getPacketClasspath() { - return "net.minecraft.server." + version + ".Packet"; + return "net.minecraft.server." + version + ".Packet"; } private String getChatSerializerClasspath() { - if (!Version.isCurrentHigher(Version.v1_8_R2)) - return "net.minecraft.server." + version + ".ChatSerializer"; - return "net.minecraft.server." + version + ".IChatBaseComponent$ChatSerializer";// 1_8_R2 moved to IChatBaseComponent + if (!Version.isCurrentHigher(Version.v1_8_R2)) + return "net.minecraft.server." + version + ".ChatSerializer"; + return "net.minecraft.server." + version + ".IChatBaseComponent$ChatSerializer";// 1_8_R2 moved to IChatBaseComponent } private String getPacketPlayOutPlayerListHeaderFooter() { - return "net.minecraft.server." + version + ".PacketPlayOutPlayerListHeaderFooter"; + return "net.minecraft.server." + version + ".PacketPlayOutPlayerListHeaderFooter"; } } diff --git a/src/com/Zrips/CMI/Modules/TabList/TabListListener.java b/src/com/Zrips/CMI/Modules/TabList/TabListListener.java index 4fce1a5..e2bdf0c 100644 --- a/src/com/Zrips/CMI/Modules/TabList/TabListListener.java +++ b/src/com/Zrips/CMI/Modules/TabList/TabListListener.java @@ -1,6 +1,5 @@ package com.Zrips.CMI.Modules.TabList; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -18,7 +17,41 @@ public class TabListListener implements Listener { private CMI plugin; public TabListListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerJoinEvent(PlayerJoinEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerQuitEvent(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerChangedWorldEvent(PlayerChangedWorldEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerDeathEvent(PlayerDeathEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onCMIAfkLeaveEvent(CMIAfkLeaveEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onCMIAfkEnterEvent(CMIAfkEnterEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerTeleportEvent(PlayerTeleportEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/TabList/TabListManager.java b/src/com/Zrips/CMI/Modules/TabList/TabListManager.java index a481de0..99d6f63 100644 --- a/src/com/Zrips/CMI/Modules/TabList/TabListManager.java +++ b/src/com/Zrips/CMI/Modules/TabList/TabListManager.java @@ -4,7 +4,6 @@ import java.util.HashMap; import java.util.List; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; @@ -17,7 +16,7 @@ public class TabListManager { private CMI plugin; public TabListManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } private int sched = -1; @@ -47,101 +46,88 @@ public TabListManager(CMI plugin) { private int SortingAutoUpdate = 1; public void stop() { - if (sched != -1) { - Bukkit.getScheduler().cancelTask(sched); - sched = -1; - } - if (sortSched != -1) { - Bukkit.getScheduler().cancelTask(sortSched); - sortSched = -1; - } + } public void loadConfig() { - + } private void tasker() { - - } + } public TabList getTL(Player player) { - - return null; + return null; } public void updateTabList(int delay) { } public void updateTabList() { - } public void updateTablistName(Player player) { - } public void updateTabList(Player player) { - - } + } public void updateTabListSync(Player player) { - } public void updateTabListAsync(final Player player) { - + } public boolean isUpdatesOnJoin() { - return UpdatesOnJoin; + return UpdatesOnJoin; } public boolean isUpdatesOnLeave() { - return UpdatesOnLeave; + return UpdatesOnLeave; } public boolean isUpdatesOnWorldChange() { - return UpdatesOnWorldChange; + return UpdatesOnWorldChange; } public boolean isUpdatesOnPlayerDeath() { - return UpdatesOnPlayerDeath; + return UpdatesOnPlayerDeath; } public boolean isUpdatesOnPlayerTeleport() { - return UpdatesOnPlayerTeleport; + return UpdatesOnPlayerTeleport; } public boolean isUpdatesOnNickChange() { - return UpdatesOnNickChange; + return UpdatesOnNickChange; } public boolean isUpdatesOnAfkStateChange() { - return UpdatesOnAfkStateChange; + return UpdatesOnAfkStateChange; } public boolean isEnabled() { - return CMIModule.tablist.isEnabled(); + return CMIModule.tablist.isEnabled(); } public boolean isUpdateTabListNames() { - return UpdateTabListNames; + return UpdateTabListNames; } public boolean isSortingEnabled() { - return sortingEnabled; + return sortingEnabled; } public CMITabSortingType getSortingType() { - return sortingType; + return sortingType; } public CMITabSortingOrder getSortingOrder() { - return sortingOrder; + return sortingOrder; } } diff --git a/src/com/Zrips/CMI/Modules/TimedCommands/TimedCommandListener.java b/src/com/Zrips/CMI/Modules/TimedCommands/TimedCommandListener.java index 12a845b..3089164 100644 --- a/src/com/Zrips/CMI/Modules/TimedCommands/TimedCommandListener.java +++ b/src/com/Zrips/CMI/Modules/TimedCommands/TimedCommandListener.java @@ -1,24 +1,39 @@ package com.Zrips.CMI.Modules.TimedCommands; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerChangedWorldEvent; -import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.CMIUser; -import com.Zrips.CMI.Modules.tp.Teleportations.TeleportType; - -import net.Zrips.CMILib.Logs.CMIDebug; public class TimedCommandListener implements Listener { private CMI plugin; public TimedCommandListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerLogOff(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void PlayerLoginEvent(PlayerLoginEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void PlayerLoginEvent(PlayerChangedWorldEvent event) { + } + @EventHandler(priority = EventPriority.MONITOR) + public void onRespawn(PlayerRespawnEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/TimedCommands/TimedCommandManager.java b/src/com/Zrips/CMI/Modules/TimedCommands/TimedCommandManager.java index 0056112..3751e2c 100644 --- a/src/com/Zrips/CMI/Modules/TimedCommands/TimedCommandManager.java +++ b/src/com/Zrips/CMI/Modules/TimedCommands/TimedCommandManager.java @@ -1,23 +1,12 @@ package com.Zrips.CMI.Modules.TimedCommands; -import java.util.ArrayList; import java.util.HashSet; -import java.util.List; import java.util.Set; -import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIUser; -import com.Zrips.CMI.Modules.ModuleHandling.CMIModule; -import com.Zrips.CMI.Modules.tp.Teleportations.TeleportType; - -import net.Zrips.CMILib.ActionBar.CMIActionBar; -import net.Zrips.CMILib.Logs.CMIDebug; -import net.Zrips.CMILib.Time.CMITimeManager; public class TimedCommandManager { @@ -27,49 +16,47 @@ public class TimedCommandManager { private boolean delay = false; public TimedCommandManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public Set timed = new HashSet(); public void addTimed(CMIUser user) { + } public void stop() { - if (autoTimerBukkitId == -1) - return; - Bukkit.getScheduler().cancelTask(autoTimerBukkitId); - autoTimerBukkitId = -1; + } private Runnable autoTimer = new Runnable() { - @Override - public void run() { - } + @Override + public void run() { + + } }; private void checkUsers() { - + } private void updateNextIn(Long time) { - if (nextIn == -1L || nextIn > time) - nextIn = time; + } public boolean checkTFly(final CMIUser user, boolean logout) { - - return true; + + return true; } public boolean checkTGod(final CMIUser user, boolean logout) { - return true; + return true; } private static Location getSafeLocation(Location loc) { - return null; + return null; } } diff --git a/src/com/Zrips/CMI/Modules/Totems/ResurectionListener.java b/src/com/Zrips/CMI/Modules/Totems/ResurectionListener.java index 21b5c6b..477661b 100644 --- a/src/com/Zrips/CMI/Modules/Totems/ResurectionListener.java +++ b/src/com/Zrips/CMI/Modules/Totems/ResurectionListener.java @@ -1,32 +1,70 @@ package com.Zrips.CMI.Modules.Totems; -import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityResurrectEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.CMILib; import net.Zrips.CMILib.Items.CMIMaterial; -import com.Zrips.CMI.Modules.Totems.TotemManager.BossBarType; -import com.Zrips.CMI.Modules.tp.Teleportations.TeleportType; public class ResurectionListener implements Listener { private CMI plugin; public ResurectionListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.HIGH) + public void EntityResurrectEvent(EntityResurrectEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void PlayerInteractEvent(PlayerInteractEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void EntityResurrectEventTotemUse(EntityResurrectEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void EntityDamageByEntityEvent(EntityDamageByEntityEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void EntityDamageByEntityEventWarmup(EntityDamageByEntityEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void EntityDamageEvent(EntityDamageEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void EntityDamageEventWarmup(EntityDamageEvent event) { + + } + + public static boolean haveTotem(Player player) { + for (ItemStack one : player.getInventory().getContents()) { + if (one == null) + continue; + if (!CMIMaterial.TOTEM_OF_UNDYING.equals(one.getType())) + continue; + return true; + } + return false; } } diff --git a/src/com/Zrips/CMI/Modules/Totems/TotemManager.java b/src/com/Zrips/CMI/Modules/Totems/TotemManager.java index 0964ed2..459692c 100644 --- a/src/com/Zrips/CMI/Modules/Totems/TotemManager.java +++ b/src/com/Zrips/CMI/Modules/Totems/TotemManager.java @@ -1,23 +1,12 @@ package com.Zrips.CMI.Modules.Totems; import java.util.HashMap; -import java.util.Map.Entry; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.boss.BarStyle; -import org.bukkit.boss.BossBar; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIUser; -import net.Zrips.CMILib.FileHandler.ConfigReader; -import net.Zrips.CMILib.Time.CMITimeManager; - -import net.Zrips.CMILib.Locale.LC; -import com.Zrips.CMI.Modules.Particl.CMIPEAnimationInterface; -import com.Zrips.CMI.Modules.Particl.CMIVisualEffect; -import com.Zrips.CMI.Modules.Particl.ParticleManager.CMIPresetAnimations; public class TotemManager { @@ -36,128 +25,121 @@ public class TotemManager { private int TotemEffectAbsorbtion = -1; public enum BossBarType { - Cooldown, Warmup + Cooldown, Warmup } public TotemManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void loadConfig() { - + } public boolean isTotemRemoveFromInventory() { - return TotemRemoveFromInventory; + return TotemRemoveFromInventory; } public boolean isTotemCooldownUse() { - return TotemCooldownUse; + return TotemCooldownUse; } public boolean isTotemWarmupUse() { - return TotemWarmupUse; + return TotemWarmupUse; } public int getTotemCooldownTime() { - return TotemCooldownTime; + return TotemCooldownTime; } public int getTotemWarmupTime() { - return TotemWarmupTime; + return TotemWarmupTime; } public boolean isTotemProtectFromVoid() { - return TotemProtectFromVoid; + return TotemProtectFromVoid; } public void hideAllBars() { - + } public boolean isOnCd(Player player) { - TotemBossBar tbar = totem.get(player.getUniqueId()); - if (tbar == null) - return false; - return tbar.getType() == BossBarType.Cooldown; + TotemBossBar tbar = totem.get(player.getUniqueId()); + + if (tbar == null) + return false; + + return tbar.getType() == BossBarType.Cooldown; } public boolean isOnWarmup(Player player) { - TotemBossBar tbar = totem.get(player.getUniqueId()); - if (tbar == null) - return false; - return tbar.getType() == BossBarType.Warmup; + TotemBossBar tbar = totem.get(player.getUniqueId()); + if (tbar == null) + return false; + return tbar.getType() == BossBarType.Warmup; } -// public TotemBossBar getBossBar(Player player, BossBarType type) { -// return this.totem.get(player.getUniqueId()); -// } - public TotemBossBar getBossBar(Player player) { - TotemBossBar tb = this.totem.get(player.getUniqueId()); - if (tb != null) - return tb; - return null; + TotemBossBar tb = this.totem.get(player.getUniqueId()); + if (tb != null) + return tb; + return null; } @Deprecated public TotemBossBar getBossBar(Player player, BossBarType type) { - return getBossBar(player.getUniqueId(), type); + return getBossBar(player.getUniqueId(), type); } public TotemBossBar getBossBar(UUID uuid, BossBarType type) { - TotemBossBar tb = this.totem.get(uuid); - if (tb != null && tb.getType() == type) - return tb; - return null; + TotemBossBar tb = this.totem.get(uuid); + if (tb != null && tb.getType() == type) + return tb; + return null; } public void addCooldownPlayer(Player player) { - + } public void addWarmupPlayer(Player player) { - + } public void showWarmupEffect(Player player) { - + } public void stopWarmupEffect(Player player) { - + } @Deprecated public boolean toggleBar(Player player) { - CMIUser user = plugin.getPlayerManager().getUser(player); - if (user == null) - return false; - return toggleBar(user, null); + + return false; } public boolean toggleBar(CMIUser user, Boolean state) { - return true; + + return true; } public void removePlayer(Player player, BossBarType type) { - TotemBossBar totemBar = getBossBar(player, type); - if (totemBar == null) - return; - totemBar.getBar().setVisible(false); - totem.remove(player.getUniqueId()); + } public synchronized void ShowTotemWarmup(Player player) { - + } @Deprecated public synchronized void ShowTotemCooldown(Player player) { - CMIUser user = plugin.getPlayerManager().getUser(player); - if (user == null) - return; - ShowTotemCooldown(user); + CMIUser user = plugin.getPlayerManager().getUser(player); + if (user == null) + return; + ShowTotemCooldown(user); } public synchronized void ShowTotemCooldown(CMIUser user) { @@ -165,38 +147,39 @@ public synchronized void ShowTotemCooldown(CMIUser user) { } public Long getLeftCd(Player player, int cd) { - - return null; + + return null; } private Long getLeftCd(Long usedOn, int cd) { - long t = (((cd * 1000) + usedOn) - System.currentTimeMillis()); - if (t < 0) - t = 0L; - return t; + long t = (((cd * 1000) + usedOn) - System.currentTimeMillis()); + if (t < 0) + t = 0L; + return t; } private static double getLeftCdPercentage(Long usedOn, int cd) { - double t = (((cd * 1000D) + usedOn) - System.currentTimeMillis()) / (cd * 1000D); - if (t < 0D) - t = 0D; - if (t > 1D) - t = 1D; - return t; + double t = (((cd * 1000D) + usedOn) - System.currentTimeMillis()) / (cd * 1000D); + if (t < 0D) + t = 0D; + if (t > 1D) + t = 1D; + return t; } public void checkAllForTotemCd() { + } public int getRegenerationDuration() { - return TotemEffectRegeneration; + return TotemEffectRegeneration; } public int getFireResistanceDuration() { - return TotemEffectFireResistance; + return TotemEffectFireResistance; } public int getAbsorbtionDuration() { - return TotemEffectAbsorbtion; + return TotemEffectAbsorbtion; } } diff --git a/src/com/Zrips/CMI/Modules/Vanish/VanishListener.java b/src/com/Zrips/CMI/Modules/Vanish/VanishListener.java index 5a9719c..fca7534 100644 --- a/src/com/Zrips/CMI/Modules/Vanish/VanishListener.java +++ b/src/com/Zrips/CMI/Modules/Vanish/VanishListener.java @@ -1,42 +1,90 @@ package com.Zrips.CMI.Modules.Vanish; -import java.util.Iterator; - -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.ExperienceOrb; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.server.ServerListPingEvent; -import org.bukkit.util.Vector; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.CMISpawner; -import com.Zrips.CMI.Containers.CMIUser; -import net.Zrips.CMILib.Logs.CMIDebug; -import com.Zrips.CMI.commands.list.vanishedit.VanishAction; -import net.Zrips.CMILib.Version.Version; public class VanishListener implements Listener { private CMI plugin; public VanishListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @SuppressWarnings("deprecation") + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void PlayerPickupItemEvent(PlayerPickupItemEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void CreatureSpawnEvent(org.bukkit.event.entity.CreatureSpawnEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void CreatureSpawnEvent(org.bukkit.event.entity.SpawnerSpawnEvent event) { + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void EntityDamageByEntityEvent(ProjectileHitEvent event) { + + } + + @EventHandler + public void onPlayerLeave(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.NORMAL) + public void onPlayerJoinHideOthers(PlayerJoinEvent event) { + + } + + @EventHandler + public void onPlayerJoinHideYou(PlayerJoinEvent event) { + + } + + @EventHandler + public void onEntityTarget(EntityTargetEvent event) { + + } + + @EventHandler(ignoreCancelled = true) + public void onEntityDamage(EntityDamageEvent event) { + + } + + @EventHandler + public void onPlayerInteractEvent(PlayerInteractEvent event) { + + } + + @EventHandler + public void ping(ServerListPingEvent event) { + + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onQuit(PlayerQuitEvent event) { + + } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onPlayerDeathEvent(PlayerDeathEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Vanish/VanishManager.java b/src/com/Zrips/CMI/Modules/Vanish/VanishManager.java index 9a652a5..5d8ad46 100644 --- a/src/com/Zrips/CMI/Modules/Vanish/VanishManager.java +++ b/src/com/Zrips/CMI/Modules/Vanish/VanishManager.java @@ -2,104 +2,121 @@ import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.boss.BarStyle; import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIUser; -import com.Zrips.CMI.Containers.Snd; -import net.Zrips.CMILib.Locale.LC; -import com.Zrips.CMI.Modules.Afk.AfkManager; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; -import com.Zrips.CMI.Modules.SilentChest.silentChestListener; -import com.Zrips.CMI.commands.list.vanishedit.VanishAction; -import com.Zrips.CMI.events.CMIPlayerUnVanishEvent; -import com.Zrips.CMI.events.CMIPlayerVanishEvent; - -import net.Zrips.CMILib.BossBar.BossBarInfo; -import net.Zrips.CMILib.FileHandler.ConfigReader; -import net.Zrips.CMILib.Version.Version; public class VanishManager { private CMI plugin; - Set vanishedOnlineList = new HashSet(); + private Set vanishedOnlineList = new HashSet(); Set vanishedList = new HashSet(); public VanishManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public Set getAllVanished() { - return vanishedList; + return vanishedList; } public void addPlayer(CMIUser user) { - if (user == null) - return; - addPlayer(user.getUniqueId()); + if (user == null) + return; + addPlayer(user.getUniqueId()); } public void addPlayer(Player player) { - if (player == null) - return; - addPlayer(player.getUniqueId()); + if (player == null) + return; + addPlayer(player.getUniqueId()); } public void addPlayer(UUID uuid) { + } private static final String vanishBossBar = "CMIVanishBossBar"; - public boolean nearActivePlayer(Location loc) { - - return false; + return false; } public void applyVanish(CMIUser user) { - applyVanish(user, true, true); + applyVanish(user, true, true); } public void applyVanish(CMIUser user, boolean fireUnvanishEvent) { - applyVanish(user, fireUnvanishEvent, true); + applyVanish(user, fireUnvanishEvent, true); } public void applyVanish(CMIUser user, boolean fireUnvanishEvent, boolean showMessages) { - + applyVanish(user, fireUnvanishEvent, showMessages, false); + } + + public void applyVanish(CMIUser user, boolean fireUnvanishEvent, boolean showMessages, boolean login) { + } public static String defaultString = ""; public void loadConfig() { + } public void hideVanishedPlayersFor(Player player) { - + } public void hidePlayerForEveryone(Player player) { + } public void removePlayer(CMIUser user) { + } public void removePlayer(Player player) { + } public void removePlayer(UUID uuid) { - removePlayer(uuid, true); + removePlayer(uuid, true); } public void removePlayer(UUID uuid, boolean showForOthers) { + } + + public Set getVanishedOnlineList() { + return vanishedOnlineList; + } + + private int playtimeSched = -1; + + List playtimeList = new ArrayList(); + + public void removeFromPlayTimePreventer(CMIUser user) { + playtimeList.remove(user); + } + + public void addToPlayTimePreventer(CMIUser user) { + playtimeList.add(user); + user.getVanish().setPlaytimeAtVanishStart((long) (user.getTotalPlayTime() / 1000) * 1000); + playTimePreventer(); + } + + @SuppressWarnings("deprecation") + private void playTimePreventer() { + + } + } diff --git a/src/com/Zrips/CMI/Modules/ViewRange/ChunkChange.java b/src/com/Zrips/CMI/Modules/ViewRange/ChunkChange.java index c156f30..6f86d33 100644 --- a/src/com/Zrips/CMI/Modules/ViewRange/ChunkChange.java +++ b/src/com/Zrips/CMI/Modules/ViewRange/ChunkChange.java @@ -1,18 +1,19 @@ package com.Zrips.CMI.Modules.ViewRange; -import org.bukkit.Chunk; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.Direction; import com.Zrips.CMI.events.CMIChunkChangeEvent; public class ChunkChange implements Listener { private CMI plugin; public ChunkChange(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler + public void onChunkChangeMove(CMIChunkChangeEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/ViewRange/ViewRangeInfo.java b/src/com/Zrips/CMI/Modules/ViewRange/ViewRangeInfo.java index 07d6893..a2079dc 100644 --- a/src/com/Zrips/CMI/Modules/ViewRange/ViewRangeInfo.java +++ b/src/com/Zrips/CMI/Modules/ViewRange/ViewRangeInfo.java @@ -184,6 +184,18 @@ public void addLoadedChunks(List chunks) { } public synchronized void removeLoadedChunks(List chunks) { + List remove = new ArrayList(); + for (ChunkInfo oneNew : chunks) { + for (ChunkInfo oneOld : LoadedChunks) { + if (oneOld.getX() != oneNew.getX()) + continue; + if (oneOld.getZ() != oneNew.getZ()) + continue; + remove.add(oneOld); + break; + } + } + this.LoadedChunks.removeAll(remove); } public void addLoadedChunk(ChunkInfo chunk) { diff --git a/src/com/Zrips/CMI/Modules/ViewRange/ViewRangeListener.java b/src/com/Zrips/CMI/Modules/ViewRange/ViewRangeListener.java index 9104e77..3f9dc49 100644 --- a/src/com/Zrips/CMI/Modules/ViewRange/ViewRangeListener.java +++ b/src/com/Zrips/CMI/Modules/ViewRange/ViewRangeListener.java @@ -1,18 +1,20 @@ package com.Zrips.CMI.Modules.ViewRange; -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerTeleportEvent; -import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.ChunkInfo; -import net.Zrips.CMILib.Version.Version; - public class ViewRangeListener implements Listener { + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onLogIn(PlayerJoinEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onJoin(PlayerTeleportEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/ViewRange/ViewRangeManager.java b/src/com/Zrips/CMI/Modules/ViewRange/ViewRangeManager.java index 21c10a3..90d03fc 100644 --- a/src/com/Zrips/CMI/Modules/ViewRange/ViewRangeManager.java +++ b/src/com/Zrips/CMI/Modules/ViewRange/ViewRangeManager.java @@ -3,12 +3,11 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.ConcurrentHashMap; + import org.bukkit.Bukkit; -import org.bukkit.Chunk; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.ChunkInfo; import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; public class ViewRangeManager { @@ -21,18 +20,18 @@ public class ViewRangeManager { private CMI plugin; public ViewRangeManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public int getRangeFromPerm(Player player) { - int range = Bukkit.getViewDistance(); - if (!CMIPerm.viewrange.hasPermission(player)) - return range; - for (int i = 15; i > range; i--) { - if (CMIPerm.viewrange_$1.hasPermission(player, i)) - return i; - } - return range; + int range = Bukkit.getViewDistance(); + if (!CMIPerm.viewrange.hasPermission(player)) + return range; + for (int i = 15; i > range; i--) { + if (CMIPerm.viewrange_$1.hasPermission(player, i)) + return i; + } + return range; } public void FillOnMove(final ViewRangeInfo scan) { diff --git a/src/com/Zrips/CMI/Modules/Votifier/VotifierListener.java b/src/com/Zrips/CMI/Modules/Votifier/VotifierListener.java deleted file mode 100644 index fd8636c..0000000 --- a/src/com/Zrips/CMI/Modules/Votifier/VotifierListener.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.Zrips.CMI.Modules.Votifier; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.CMIUser; - -public class VotifierListener implements Listener { - private CMI plugin; - - public VotifierListener(CMI plugin) { - this.plugin = plugin; - } - -} diff --git a/src/com/Zrips/CMI/Modules/Votifier/VotifierManager.java b/src/com/Zrips/CMI/Modules/Votifier/VotifierManager.java index ca2cd3d..438b7cc 100644 --- a/src/com/Zrips/CMI/Modules/Votifier/VotifierManager.java +++ b/src/com/Zrips/CMI/Modules/Votifier/VotifierManager.java @@ -1,25 +1,16 @@ package com.Zrips.CMI.Modules.Votifier; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Random; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentSkipListMap; -import org.bukkit.Bukkit; - import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIUser; -import com.Zrips.CMI.Containers.Snd; -import net.Zrips.CMILib.FileHandler.ConfigReader; -import net.Zrips.CMILib.Time.CMITimeManager; - -import com.Zrips.CMI.Modules.ModuleHandling.CMIModule; public class VotifierManager { @@ -36,38 +27,38 @@ public class VotifierManager { private HashMap voteReminder = new HashMap(); private class voteReminder { - private int times = 0; - private long last = 0L; + private int times = 0; + private long last = 0L; - public voteReminder() { - last = System.currentTimeMillis(); - } + public voteReminder() { + last = System.currentTimeMillis(); + } - public void recordNotified() { - times++; - last = System.currentTimeMillis(); - } + public void recordNotified() { + times++; + last = System.currentTimeMillis(); + } - public int getTimes() { - return times; - } + public int getTimes() { + return times; + } - public long getLast() { - return last; - } + public long getLast() { + return last; + } } public void removeVoteReminder(UUID uuid) { - voteReminder.remove(uuid); + voteReminder.remove(uuid); } public void addToVoteReminder(UUID uuid) { - voteReminder.put(uuid, new voteReminder()); + voteReminder.put(uuid, new voteReminder()); } public VotifierManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void loadConfig() { @@ -76,7 +67,7 @@ public void loadConfig() { @Deprecated public void processVote(CMIUser user, String service) { - processVote(user, service, null); + processVote(user, service, null); } public void processVote(CMIUser user, String service, String ip) { @@ -87,10 +78,10 @@ public void processVote(CMIUser user, String service, String ip) { private Set withVotes = new HashSet(); public void updateVoteCountList(CMIUser user) { - if (user.getVotifierVotes() <= 0) - withVotes.remove(user); - else - withVotes.add(user); + if (user.getVotifierVotes() <= 0) + withVotes.remove(user); + else + withVotes.add(user); } Long lastUpdate = 0L; @@ -98,9 +89,11 @@ public void updateVoteCountList(CMIUser user) { int updateDelay = 5; private void delayUpdate() { + } public void updateTopList() { + } boolean calculating = false; @@ -110,12 +103,12 @@ private void recalculate() { } public ConcurrentSkipListMap getTop() { - if (lastUpdate == 0) - recalculate(); - return Top; + if (lastUpdate == 0) + recalculate(); + return Top; } public int getMaxVotesInADay() { - return MaxVotesInADay; + return MaxVotesInADay; } } diff --git a/src/com/Zrips/CMI/Modules/Warnings/WarningManager.java b/src/com/Zrips/CMI/Modules/Warnings/WarningManager.java index e295ad4..3b245a9 100644 --- a/src/com/Zrips/CMI/Modules/Warnings/WarningManager.java +++ b/src/com/Zrips/CMI/Modules/Warnings/WarningManager.java @@ -1,18 +1,13 @@ package com.Zrips.CMI.Modules.Warnings; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map.Entry; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.Snd; -import net.Zrips.CMILib.FileHandler.ConfigReader; -import net.Zrips.CMILib.Logs.CMIDebug; public class WarningManager { @@ -23,34 +18,33 @@ public class WarningManager { private HashMap Categories = new HashMap(); public WarningManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } - public void loadConfig() { } public CMIWarningCategory getDefaultCategory() { - return Categories.get("default"); + return Categories.get("default"); } public CMIWarningCategory getCategory(String name) { - if (name == null) - return null; - return Categories.get(name.toLowerCase()); + if (name == null) + return null; + return Categories.get(name.toLowerCase()); } public List getCommandsByWarns(Player player, int from, int to) { - - return null; + + return null; } public List getCommandsByWarns(int warns) { - return commands.get(warns) != null ? new ArrayList(commands.get(warns)) : null; + return commands.get(warns) != null ? new ArrayList(commands.get(warns)) : null; } public HashMap getCategories() { - return Categories; + return Categories; } } diff --git a/src/com/Zrips/CMI/Modules/Warps/CmiWarp.java b/src/com/Zrips/CMI/Modules/Warps/CmiWarp.java index 00f8aac..c498022 100644 --- a/src/com/Zrips/CMI/Modules/Warps/CmiWarp.java +++ b/src/com/Zrips/CMI/Modules/Warps/CmiWarp.java @@ -1,22 +1,15 @@ package com.Zrips.CMI.Modules.Warps; -import java.math.BigInteger; import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import java.util.Random; import java.util.UUID; -import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Container.CMILocation; -import net.Zrips.CMILib.GUI.GUIManager.GUIRows; -import net.Zrips.CMILib.Items.CMIMaterial; +import net.Zrips.CMILib.Locale.LC; public class CmiWarp { @@ -41,197 +34,196 @@ public class CmiWarp { private List temp = null; public CmiWarp(String name) { - this.name = name; + this.name = name; } public void reset() { - loc = null; - item = null; + loc = null; + item = null; } public CmiWarp(String name, CMILocation loc) { - this.name = name; - this.loc = loc; + this.name = name; + this.loc = loc; } public CMILocation getLoc() { - loc.recheck(); - return loc; + loc.recheck(); + return loc; } public void resetQueue() { - temp = null; + temp = null; } public CMILocation getLocIncRand() { - return null; + return null; } public String getName() { - return name; + return name; } public ItemStack getItem() { - return item; + return item; } public ItemStack getIcon() { - return null; + return null; } public ItemStack getOffIcon() { - - return null; + + return null; } public void setItem(ItemStack item) { - this.item = item; + this.item = item; } public void setLoc(CMILocation loc) { - this.loc = loc; + this.loc = loc; } public boolean isReqPerm() { - return reqPerm; + return reqPerm; } public void setReqPerm(boolean reqPerm) { - this.reqPerm = reqPerm; + this.reqPerm = reqPerm; } public Integer getSlot() { - return slot; + return slot; } public void setSlot(Integer slot) { - if (slot != null) { - if (slot < 0) - slot = null; - if (slot != null && slot > GUIRows.r5.getFields()) { - slot = slot - GUIRows.r5.getFields(); - this.page++; - } - } - this.slot = slot; + if (slot != null) { + if (slot > 27) { + slot = 27; + } + if (slot < 0) + slot = null; + } + this.slot = slot; } public UUID getCreator() { - return creator; + return creator; } public String getCreatorName() { - return creator.equals(CMI.getInstance().getServerUUID()) ? CMI.getInstance().getMsg(LC.info_Console) : CMI.getInstance().getPlayerManager().getUser(creator) == null ? "N/A" : CMI.getInstance() - .getPlayerManager().getUser(creator).getName(); + return creator.equals(CMI.getInstance().getServerUUID()) ? CMI.getInstance().getMsg(LC.info_Console) : CMI.getInstance().getPlayerManager().getUser(creator) == null ? "N/A" : CMI.getInstance() + .getPlayerManager().getUser(creator).getName(); } public void setCreator(UUID creator) { - this.creator = creator; + this.creator = creator; } public Boolean isAutoLore() { - return autoLore; + return autoLore; } public void setAutoLore(Boolean autoLore) { - this.autoLore = autoLore; + this.autoLore = autoLore; } public ItemStack getOffItem() { - return offItem; + return offItem; } public void setOffItem(ItemStack offItem) { - this.offItem = offItem; + this.offItem = offItem; } public Boolean isShowUnavailable() { - return showUnavailable; + return showUnavailable; } public void setShowUnavailable(Boolean showUnavailable) { - this.showUnavailable = showUnavailable; + this.showUnavailable = showUnavailable; } public Integer getPage() { - return page; + return page; } public void setPage(int p) { - if (p < 0) - p = 1; - this.page = p; + if (p < 1) + p = 1; + this.page = p; } public void setName(String name) { - this.name = name; + this.name = name; } public boolean isRandomizeYaw() { - return randomizeYaw; + return randomizeYaw; } public void setRandomizeYaw(boolean randomizeYaw) { - this.randomizeYaw = randomizeYaw; + this.randomizeYaw = randomizeYaw; } public String getGroup() { - return group; + return group; } public void setGroup(String group) { - this.group = group; + this.group = group; } public boolean sameGroup(String group) { - return this.group == null && group == null || this.group != null && group != null && this.group.equalsIgnoreCase(group); + return this.group == null && group == null || this.group != null && group != null && this.group.equalsIgnoreCase(group); } public boolean isHidden() { - return hidden; + return hidden; } public void setHidden(boolean hidden) { - this.hidden = hidden; + this.hidden = hidden; } public String getShownName() { - return displayName == null ? this.getName() : displayName; + return displayName == null ? this.getName() : displayName; } public String getDisplayName() { - return displayName; + return displayName; } public void setDisplayName(String displayName) { - this.displayName = displayName; + this.displayName = displayName; } public boolean isRepeatingLocation() { - return repeatingLocation; + return repeatingLocation; } public void setRepeatingLocation(boolean repeatingLocation) { - this.repeatingLocation = repeatingLocation; + this.repeatingLocation = repeatingLocation; } public boolean hasSecondaryLocations() { - return locations != null && !locations.isEmpty(); + return locations != null && !locations.isEmpty(); } public List getLocations() { - if (locations == null) - locations = new ArrayList(); - return locations; + if (locations == null) + locations = new ArrayList(); + return locations; } public void setLocations(List locations) { - this.locations = locations; + this.locations = locations; } public void addLocation(CMILocation location) { - getLocations().add(location); + getLocations().add(location); } } diff --git a/src/com/Zrips/CMI/Modules/Warps/WarpManager.java b/src/com/Zrips/CMI/Modules/Warps/WarpManager.java index 4298466..9f1ce21 100644 --- a/src/com/Zrips/CMI/Modules/Warps/WarpManager.java +++ b/src/com/Zrips/CMI/Modules/Warps/WarpManager.java @@ -1,152 +1,181 @@ package com.Zrips.CMI.Modules.Warps; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; import net.Zrips.CMILib.FileHandler.ConfigReader; import net.Zrips.CMILib.GUI.CMIGui; +import net.Zrips.CMILib.Items.CMIItemStack; public class WarpManager { private CMI plugin; - HashMap warps = new HashMap(); + LinkedHashMap warps = new LinkedHashMap(); HashMap> userWarps = new HashMap>(); public WarpManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void onDisable() { - if (saveId != -1) { - Bukkit.getScheduler().cancelTask(saveId); - saveId = -1; - save(); - } + } public HashMap getWarps() { - return warps; + return warps; } public List getWarps(Player player, String group) { - return getWarps(player, null, group, true); + return getWarps(player, null, group, true); } public List getWarps(Player player) { - return getWarps(player, null, null, true); + return getWarps(player, null, null, true); } public int getWarpCount(Player player) { - return userWarps.get(player.getUniqueId()) == null ? 0 : userWarps.get(player.getUniqueId()).size(); + return userWarps.get(player.getUniqueId()) == null ? 0 : userWarps.get(player.getUniqueId()).size(); } public int getMaxWarps(CommandSender sender) { - if (sender instanceof Player) - return getMaxWarps((Player) sender); - return 9999; + if (sender instanceof Player) + return getMaxWarps((Player) sender); + return 9999; } public int getMaxWarps(Player player) { - int homes = 1; - return homes; - + return 0; } public List getWarps(Player player, Integer page, String group) { - return getWarps(player, page, group, true); + return getWarps(player, page, group, true); } public List getWarps(Player player, Integer page, String group, boolean includeHidden) { - return getWarps(player, page, group, includeHidden, false); + return getWarps(player, page, group, includeHidden, false); } public List getWarps(Player player, Integer page, String group, boolean includeHidden, boolean onlyOwn) { - - return null; + + return null; + } + + public HashMap> getPagedWarps(Player player, String group, boolean includeHidden, boolean onlyOwn) { + + return null; } private enum warpEditorSlots { - icon(10), offIcon(19), randomYaw(20), autoLore(11), permission(13), reqPermission(22), hidden(32), group(25), displayName(34), iconSlot(14), page(23), back(8), - location(37), seclocation(38), repeat(39); + icon(10), offIcon(19), randomYaw(20), autoLore(11), permission(13), reqPermission(22), hidden(32), group(25), displayName(34), iconSlot(14), page(23), back(8), + location(37), seclocation(38), repeat(39); - private int slot; + private int slot; - warpEditorSlots(int slot) { - this.slot = slot; - } + warpEditorSlots(int slot) { + this.slot = slot; + } - public int getSlot() { - return slot; - } + public int getSlot() { + return slot; + } - public void setSlot(int slot) { - this.slot = slot; - } + public void setSlot(int slot) { + this.slot = slot; + } } public void openWarpEditor(Player player, String warp) { - openWarpEditor(player, this.getWarp(warp)); + openWarpEditor(player, this.getWarp(warp)); } public void openWarpEditor(final Player player, final CmiWarp warp) { - + } public List getWarps(int page, String group) { - - return null; + + return null; } public int getPageCountFrom(int page, String group) { - int i = page; - - return i - page; + int i = page; + return i - page; + } + + public int getPageCount(Player player) { + return getPageCount(this.getWarps(player)); + } + + public int getPageCount(List w) { + int pages = 1; + return pages; } public List getWarps(int page, Integer slot, String group) { - - return null; + + return null; + } + + private static int slotToGUIrelativeSlot(int slot) { + return 9 + (((slot) / 7) * 2 + 1) + slot; + } + + public CMIGui openComplexGUI(Player player, int page, String group) { + HashMap> w = getPagedWarps(player, group, false, false); + return openComplexGUI(player, page, w); } -// public CMIGui generateGUI(Player player, Player source, int page) { -// return generateGUI(player, getWarps(source), page); -// } + public CMIGui openComplexGUI(Player player, int page, HashMap> warpMap) { + + return null; + } public CMIGui openGUI(Player player, int page, String group) { - return openGUI(player, plugin.getWarpManager().getWarps(player, page, group, false), group); + return openGUI(player, plugin.getWarpManager().getWarps(player, page, group, false), group); } public CMIGui openGUI(Player player, List warpList, String group) { - - return null; + + return null; } public void remove(CmiWarp warp) { + } public void addWarp(CmiWarp warp) { - addWarp(warp, true); + addWarp(warp, true); } public void addWarp(CmiWarp warp, boolean save) { + } public CmiWarp getWarp(Player player, String name) { - return null; + if (name == null) + return null; + CmiWarp warp = warps.get(name.toLowerCase()); + if (warp != null) { + if (warp.isReqPerm() && !CMIPerm.command_warp_$1.hasPermission(player, warp.getName().toLowerCase())) + return null; + return warp; + } + return null; } public CmiWarp getWarp(String name) { - if (name == null) - return null; - return warps.get(name.toLowerCase()); + if (name == null) + return null; + return warps.get(name.toLowerCase()); } private boolean warpGUI = true; @@ -158,12 +187,22 @@ public CmiWarp getWarp(String name) { private int MinLength = 4; private int MaxLength = 16; + private Boolean guiCloseButton; + private int guiCloseButtonSlot; + private CMIItemStack guiCloseButtonItem; + private List guiCloseButtonCommands; + + private boolean guiInfoButton; + private int guiInfoButtonSlot; + private CMIItemStack guiInfoButtonItem; + private List guiInfoButtonCommands; + public void loadConfig(ConfigReader cfg) { - + } public boolean isWarpGUI() { - return warpGUI; + return warpGUI; } public void load() { @@ -175,18 +214,11 @@ public void load() { private int saveId = -1; public void safeSave() { - if (saveId != -1) - return; - saveId = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CMI.getInstance(), new Runnable() { - @Override - public void run() { - asyncSave(); - saveId = -1; - } - }, 60 * 20); + } public void asyncSave() { + } public void save() { @@ -194,34 +226,34 @@ public void save() { } public int getWarpPerPage() { - return warpPerPage; + return warpPerPage; } public boolean isWarpShowCreator() { - return warpShowCreator; + return warpShowCreator; } public boolean isGUIOnCreation() { - return GUIOnCreation; + return GUIOnCreation; } public int getMinLength() { - return MinLength; + return MinLength; } public void setMinLenght(int minLenght) { - MinLength = minLenght; + MinLength = minLenght; } public int getMaxLength() { - return MaxLength; + return MaxLength; } public void setMaxLenght(int maxLenght) { - MaxLength = maxLenght; + MaxLength = maxLenght; } public boolean isWarpRequirePerm() { - return warpRequirePerm; + return warpRequirePerm; } } diff --git a/src/com/Zrips/CMI/Modules/Worlds/CMIChunk.java b/src/com/Zrips/CMI/Modules/Worlds/CMIChunk.java index 50c02e7..d4f3f79 100644 --- a/src/com/Zrips/CMI/Modules/Worlds/CMIChunk.java +++ b/src/com/Zrips/CMI/Modules/Worlds/CMIChunk.java @@ -2,13 +2,11 @@ import java.awt.Color; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import org.bukkit.Chunk; import org.bukkit.ChunkSnapshot; import org.bukkit.World; -import org.bukkit.block.Biome; import com.Zrips.CMI.Modules.Worlds.WorldManager.CMIBiome; @@ -25,101 +23,106 @@ public class CMIChunk { private List biomes = new ArrayList(); public CMIChunk(Chunk chunk) { - this(chunk.getWorld(), chunk.getX(), chunk.getZ()); - this.setGenerated(true); - recheckBiomes(chunk); + this(chunk.getWorld(), chunk.getX(), chunk.getZ()); + this.setGenerated(true); + recheckBiomes(chunk); } public CMIChunk(World world, int x, int z) { - this.x = x; - this.z = z; - this.world = world; + this.x = x; + this.z = z; + this.world = world; } public int getRelativeX() { - return this.x - ((this.x >> 5) * 32); + return this.x - ((this.x >> 5) * 32); } public int getRelativeZ() { - return this.z - ((this.z >> 5) * 32); + return this.z - ((this.z >> 5) * 32); } public Integer getPlace() { - return getRelativeX() + (getRelativeZ() * 32); + return getRelativeX() + (getRelativeZ() * 32); } private static Integer convertBiomePlace(int x, int z) { - return x + (z * 16); + return x + (z * 16); } public Integer getX() { - return x; + return x; } public Integer getZ() { - return z; + return z; } public CMIChunk recheckBiomes(Chunk chunk) { - return this; + + return this; } public CMIChunk recheckBiomes() { - return this; + + return this; } public World getWorld() { - return world; + return world; } public ChunkSnapshot getEmptyChunkSnapshot() { - return this.world.getEmptyChunkSnapshot(x, z, true, false); + return this.world.getEmptyChunkSnapshot(x, z, true, false); } public boolean isGenerated() { - return generated; + return generated; } public CMIChunk setGenerated(boolean generated) { - this.generated = generated; - return this; + this.generated = generated; + return this; } public Chunk getChunk() { - return this.getWorld().getChunkAt(x, z); + return this.getWorld().getChunkAt(x, z); } public CMIBiome getBiome() { - for (CMIBiome one : biomes) { - return one; - } - return CMIBiome.PLAINS; + for (CMIBiome one : biomes) { + return one; + } + return CMIBiome.PLAINS; } public List getBiomes() { - return biomes; + return biomes; } public String getBiomeColorCodes() { - return null; + String b = ""; + + return b; } public Color getUnbluredColor() { - - return null; + + return null; } public Color getColor() { - return null; + + return null; } private static Color blend(Color c0, Color c1) { - - return null; + + return null; } public void setBiomes(List biomes) { - this.biomes = new ArrayList(biomes); + this.biomes = new ArrayList(biomes); } } diff --git a/src/com/Zrips/CMI/Modules/Worlds/CMIRegion.java b/src/com/Zrips/CMI/Modules/Worlds/CMIRegion.java index 8827eb0..3303544 100644 --- a/src/com/Zrips/CMI/Modules/Worlds/CMIRegion.java +++ b/src/com/Zrips/CMI/Modules/Worlds/CMIRegion.java @@ -98,11 +98,6 @@ public CMIChunk addChunk(Chunk chunk) { return c; } -// public CMIChunk addChunk(CMIChunk chunk) { -// chunks.put(chunk.getPlace(), chunk); -// return chunk; -// } - public World getWorld() { return world; } diff --git a/src/com/Zrips/CMI/Modules/Worlds/CMIWorld.java b/src/com/Zrips/CMI/Modules/Worlds/CMIWorld.java index 9d06056..5429ecd 100644 --- a/src/com/Zrips/CMI/Modules/Worlds/CMIWorld.java +++ b/src/com/Zrips/CMI/Modules/Worlds/CMIWorld.java @@ -13,62 +13,66 @@ public class CMIWorld { private TreeMap regions = new TreeMap(); public CMIWorld(Chunk chunk) { - this.world = chunk.getWorld(); + this.world = chunk.getWorld(); } public CMIWorld(World world) { - this.world = world; + this.world = world; } public World getWorld() { - return world; + return world; } public CMIRegion addRegion(World world, int x, int z) { - CMIRegion c = new CMIRegion(world, x, z); - regions.put(coordinatesToPlace(x, z), c); - return c; + CMIRegion c = new CMIRegion(world, x, z); + regions.put(coordinatesToPlace(x, z), c); + return c; } public CMIRegion addRegion(Chunk chunk) { - return null; + CMIRegion c = new CMIRegion(chunk); + regions.put(coordinatesToPlace(chunk.getX() >> 5, chunk.getZ() >> 5), c); + return c; } public void setWorld(World world) { - this.world = world; + this.world = world; } public TreeMap getRegions() { - return regions; + return regions; } public void setRegions(TreeMap regions) { - this.regions = regions; + this.regions = regions; } public CMIRegion getRegion(Chunk chunk) { - return getRegionByChunkCoord(chunk.getX(), chunk.getZ()); + return getRegionByChunkCoord(chunk.getX(), chunk.getZ()); } public CMIRegion getRegionByChunkCoord(int x, int z) { - return getRegion(x >> 5, z >> 5); + return getRegion(x >> 5, z >> 5); } public CMIRegion getRegion(int x, int z) { - Integer place = coordinatesToPlace(x, z); - return regions.get(place); + Integer place = coordinatesToPlace(x, z); + return regions.get(place); } private static Integer coordinatesToPlace(int x, int z) { - return x + (z * 1024); + return x + (z * 1024); } public boolean insideWorldBorder(Location loc) { - return true; + return true; + } public static int getMinHeight(World world) { - return 0; + return 0; + } } diff --git a/src/com/Zrips/CMI/Modules/Worlds/CMIWorldListener.java b/src/com/Zrips/CMI/Modules/Worlds/CMIWorldListener.java index 81ba319..7faa2de 100644 --- a/src/com/Zrips/CMI/Modules/Worlds/CMIWorldListener.java +++ b/src/com/Zrips/CMI/Modules/Worlds/CMIWorldListener.java @@ -3,7 +3,9 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.world.WorldLoadEvent; import com.Zrips.CMI.CMI; @@ -11,12 +13,18 @@ public class CMIWorldListener implements Listener { private CMI plugin; public CMIWorldListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } static ConcurrentHashMap> locations = new ConcurrentHashMap>(); public static void delayRecheck(String world, UpdateOnWorldLoad upd) { + + } + + @EventHandler + public void onWorldLoad(WorldLoadEvent event) { + } } diff --git a/src/com/Zrips/CMI/Modules/Worth/WorthEnchantment.java b/src/com/Zrips/CMI/Modules/Worth/WorthEnchantment.java index e56dea9..225c987 100644 --- a/src/com/Zrips/CMI/Modules/Worth/WorthEnchantment.java +++ b/src/com/Zrips/CMI/Modules/Worth/WorthEnchantment.java @@ -10,45 +10,41 @@ public class WorthEnchantment { private Enchantment enchant; public WorthEnchantment(Enchantment enchant, int level, double sellPrice, Double buyPrice) { - this.enchant = enchant; - this.level = level; - this.sellPrice = sellPrice; - this.buyPrice = buyPrice; + this.enchant = enchant; + this.level = level; + this.sellPrice = sellPrice; + this.buyPrice = buyPrice; } -// public WorthEnchantment(Enchantment enchant) { -// this(enchant, 1, 0D); -// } - public Double getSellPrice() { - return sellPrice; + return sellPrice; } public void setSellPrice(double price) { - this.sellPrice = price; - if (this.sellPrice < 0D) - this.sellPrice = 0D; + this.sellPrice = price; + if (this.sellPrice < 0D) + this.sellPrice = 0D; } public Double getBuyPrice() { - return buyPrice == null ? sellPrice : buyPrice; + return buyPrice == null ? sellPrice : buyPrice; } public boolean isBuyPriceSet() { - return buyPrice != null; + return buyPrice != null; } public void setBuyPrice(Double buyPrice) { - this.buyPrice = buyPrice; - if (this.buyPrice != null && this.buyPrice < 0D) - this.buyPrice = null; + this.buyPrice = buyPrice; + if (this.buyPrice != null && this.buyPrice < 0D) + this.buyPrice = null; } public Enchantment getEnchant() { - return enchant; + return enchant; } public Integer getLevel() { - return level; + return level; } } diff --git a/src/com/Zrips/CMI/Modules/Worth/WorthItem.java b/src/com/Zrips/CMI/Modules/Worth/WorthItem.java index 2272516..e09075f 100644 --- a/src/com/Zrips/CMI/Modules/Worth/WorthItem.java +++ b/src/com/Zrips/CMI/Modules/Worth/WorthItem.java @@ -1,21 +1,11 @@ package com.Zrips.CMI.Modules.Worth; -import java.util.HashSet; -import java.util.List; import java.util.Set; -import java.util.Map.Entry; import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; -import com.Zrips.CMI.CMI; - -import net.Zrips.CMILib.CMILib; -import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; - public class WorthItem { private Material material; @@ -27,99 +17,101 @@ public class WorthItem { private Recipe exploitRecipe = null; private Set recipesFor; private Set recipesFrom; + private Integer modelData; @Deprecated public WorthItem(ItemStack item, Integer data, double price) { - this.item = item; - material = item.getType(); - this.data = data; - this.sellPrice = price; + this.item = item; + material = item.getType(); + this.data = data; + this.sellPrice = price; } public WorthItem(ItemStack item, double price) { - this.item = item; - material = item.getType(); - this.sellPrice = price; + this.item = item; + material = item.getType(); + this.sellPrice = price; } public WorthItem(ItemStack item) { - this(item, 0D); + this(item, 0D); } -// public Material getMaterial() { -// return material; -// } -// -// public void setMaterial(Material material) { -// this.material = material; -// } public Integer getData() { - return data; + return data; } public void setData(Integer data) { - this.data = data; + this.data = data; } public Double getSellPrice() { - return sellPrice; + return sellPrice; } public Double getPlayerSellPrice(ItemStack item, boolean includeEnchants, boolean includeDurability) { - return null; + + return null; } public static double getEnchantSellPrice(ItemStack item) { - return 0D; + + return 0D; + } public void setSellPrice(double price) { + + this.sellPrice = Math.round(price * 100) / 100D; + + if (this.sellPrice < 0D) + this.sellPrice = 0D; } public ItemStack getItem() { - return null; + return item; } public void setItem(ItemStack item) { - if (this.item == null) - this.item = item.clone(); + if (this.item == null) + this.item = item.clone(); } public Double getBuyPrice() { - return buyPrice == null ? sellPrice : buyPrice; + return buyPrice == null ? sellPrice : buyPrice; } public boolean isBuyPriceSet() { - return buyPrice != null; + return buyPrice != null; } public void setBuyPrice(Double buyPrice) { - this.buyPrice = buyPrice == null ? null : Math.round(buyPrice * 100) / 100D; + this.buyPrice = buyPrice == null ? null : Math.round(buyPrice * 100) / 100D; - if (this.buyPrice != null && this.buyPrice < 0D) - this.buyPrice = null; + if (this.buyPrice != null && this.buyPrice < 0D) + this.buyPrice = null; } public Recipe getExploitRecipe() { - return exploitRecipe; + return exploitRecipe; } public Recipe updateExploitRecipe() { - return null; + return null; } public void resetRecipes() { - this.exploitRecipe = null; - this.recipe = null; + this.exploitRecipe = null; + this.recipe = null; - this.recipesFor = null; - this.recipesFrom = null; + this.recipesFor = null; + this.recipesFrom = null; } public void setExploitRecipe(Recipe exploitRecipe) { - this.exploitRecipe = exploitRecipe; + this.exploitRecipe = exploitRecipe; } public void updateRecipes() { @@ -127,10 +119,18 @@ public void updateRecipes() { } public Recipe getRecipe() { - return recipe; + return recipe; } public void setRecipe(Recipe recipe) { - this.recipe = recipe; + this.recipe = recipe; + } + + public void setModelData(Integer modelData) { + this.modelData = modelData; + } + + public Integer getModelData() { + return modelData; } } diff --git a/src/com/Zrips/CMI/Modules/Worth/WorthItemCheck.java b/src/com/Zrips/CMI/Modules/Worth/WorthItemCheck.java index 721550e..da01592 100644 --- a/src/com/Zrips/CMI/Modules/Worth/WorthItemCheck.java +++ b/src/com/Zrips/CMI/Modules/Worth/WorthItemCheck.java @@ -1,61 +1,55 @@ package com.Zrips.CMI.Modules.Worth; -import java.util.Map.Entry; - -import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Logs.CMIDebug; - public class WorthItemCheck { private WorthItem worth = null; private ItemStack item; public WorthItemCheck(ItemStack item) { - this.item = item.clone(); - worth = CMI.getInstance().getWorthManager().getWorth(item); + this.item = item.clone(); + worth = CMI.getInstance().getWorthManager().getWorth(item); } public Double getSellPrice() { - return getSellPrice(true); + return getSellPrice(true); } public Double getSellPrice(boolean includeEnchants) { - return getSellPrice(includeEnchants, true); + return getSellPrice(includeEnchants, true); } public Double getSellPrice(boolean includeEnchants, boolean includeDurability) { - if (item == null) - return worth.getSellPrice(); - return worth.getPlayerSellPrice(item, includeEnchants, includeDurability); + return null; } public Double getEnchantSellPrice() { - return 0D; + + return null; } public ItemStack getItem() { - return item; + return item; } public Double getBuyPrice() { - return worth.getBuyPrice(); + return worth.getBuyPrice(); } public boolean isBuyPriceSet() { - return worth.getBuyPrice() != null; + return worth.getBuyPrice() != null; } public WorthItem getWorth() { - return worth; + return worth; } public void setWorth(WorthItem worth) { - this.worth = worth; + this.worth = worth; } } diff --git a/src/com/Zrips/CMI/Modules/Worth/WorthListener.java b/src/com/Zrips/CMI/Modules/Worth/WorthListener.java index 5fcdd74..af33626 100644 --- a/src/com/Zrips/CMI/Modules/Worth/WorthListener.java +++ b/src/com/Zrips/CMI/Modules/Worth/WorthListener.java @@ -1,34 +1,34 @@ package com.Zrips.CMI.Modules.Worth; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.CMIUser; +import com.Zrips.CMI.events.CMIPlayerItemsSellEvent; -import net.Zrips.CMILib.CMILib; import net.Zrips.CMILib.GUI.CMIGUICloseEvent; -import net.Zrips.CMILib.GUI.CMIGui; -import net.Zrips.CMILib.GUI.GUIManager.CmiInventoryType; -import net.Zrips.CMILib.Locale.LC; public class WorthListener implements Listener { private CMI plugin; public WorthListener(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } + @EventHandler(priority = EventPriority.MONITOR) + public void InventoryClickEvent(InventoryClickEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void CMIPlayerItemsSellEvent(CMIPlayerItemsSellEvent event) { + + } + + @EventHandler(priority = EventPriority.MONITOR) + public void InventoryCloseEvent(CMIGUICloseEvent event) { + + } } diff --git a/src/com/Zrips/CMI/Modules/Worth/WorthManager.java b/src/com/Zrips/CMI/Modules/Worth/WorthManager.java index ef92047..f2672da 100644 --- a/src/com/Zrips/CMI/Modules/Worth/WorthManager.java +++ b/src/com/Zrips/CMI/Modules/Worth/WorthManager.java @@ -4,7 +4,6 @@ import java.io.Writer; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Set; @@ -26,41 +25,41 @@ public class WorthManager { private CMI plugin; -// private HashMap soldFor = new HashMap(); -// private boolean reset = false; - public WorthManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } private LinkedHashMap> map = new LinkedHashMap>(); private HashMap> enchantMap = new HashMap>(); public Double getEnchantSellPrice(Enchantment enchant, int level) { - return null; + + return null; } public WorthEnchantment getEnchantWorth(Enchantment enchant, int level) { - return null; + + return null; } public void addEnchantWorth(WorthEnchantment worth) { + } public void load() { - + } public void loadEnchtWorth() { - + } - private void addSellPriceButton(CMIGui gui, WorthItem worth, int slot, CMIMaterial material, double change) { - + private void addSellPriceButton(CMIGui gui, CMIItemStack iih, WorthItem worth, int slot, CMIMaterial material, double change) { + } - private void addBuyPriceButton(CMIGui gui, WorthItem worth, int slot, CMIMaterial material, double change) { - + private void addBuyPriceButton(CMIGui gui, CMIItemStack iih, WorthItem worth, int slot, CMIMaterial material, double change) { + } public void openWorthGui(Player player, CMIItemStack iih) { @@ -68,7 +67,7 @@ public void openWorthGui(Player player, CMIItemStack iih) { } private void priceLore(CMIGuiButton button, WorthItem worth) { - + } File file = null; @@ -76,7 +75,7 @@ private void priceLore(CMIGuiButton button, WorthItem worth) { boolean checkedOldFile = false; public void closeStream() { - + } public void sellLog(Player player, HashMap total) { @@ -84,107 +83,100 @@ public void sellLog(Player player, HashMap total) { } public void updatePriceInFile() { - updateWorthInFile(null, null); + updateWorthInFile(null, null); } public void updatePriceInFile(WorthItem worth) { - updatePriceInFile(worth, null); + updatePriceInFile(worth, null); } public void updatePriceInFile(WorthEnchantment enchantWorth) { - updatePriceInFile(null, enchantWorth); + updatePriceInFile(null, enchantWorth); } public void updatePriceInFile(final WorthItem worth, final WorthEnchantment enchantWorth) { - HashSet worths = new HashSet(); - if (worth != null) - worths.add(worth); - HashSet enchantWorths = new HashSet(); - if (enchantWorth != null) - enchantWorths.add(enchantWorth); - updateWorthInFile(worths, enchantWorths); + } private void updateWorthInFile(final Set worths, final Set enchantWorths) { - } public WorthItem getWorth(ItemStack item) { - return getWorth(item, false); + return getWorth(item, false); } public boolean containsBlockedLore(CMIItemStack citem) { - for (String one : citem.getLore()) { - String o = CMIChatColor.stripColor(one).toLowerCase(); - for (String oneBad : badLore) { - if (o.contains(oneBad)) - return true; - } - } + for (String one : citem.getLore()) { + String o = CMIChatColor.stripColor(one).toLowerCase(); + for (String oneBad : badLore) { + if (o.contains(oneBad)) + return true; + } + } - return false; + return false; } public boolean isRepairBeforeSell(ItemStack item) { - CMIItemStack citem = CMILib.getInstance().getItemManager().getItem(item); - return requireFullDurability && citem.getMaxDurability() > 2 && citem.getDurability() > 0; + CMIItemStack citem = CMILib.getInstance().getItemManager().getItem(item); + return requireFullDurability && citem.getMaxDurability() > 2 && citem.getDurability() > 0; } public double damagePercentage(ItemStack item) { - return 0; + return 0; } public double getWorthByDurability(ItemStack item, double amount) { - if (!devalueByDurability) - return amount; + if (!devalueByDurability) + return amount; - CMIItemStack citem = CMILib.getInstance().getItemManager().getItem(item); + CMIItemStack citem = CMILib.getInstance().getItemManager().getItem(item); - if (citem.getMaxDurability() < 2) - return amount; + if (citem.getMaxDurability() < 2) + return amount; - double percent = (citem.getMaxDurability() - citem.getDurability()) / (double) citem.getMaxDurability(); + double percent = (citem.getMaxDurability() - citem.getDurability()) / (double) citem.getMaxDurability(); - return (int) ((amount * percent) * 10000) / 10000D; + return (int) ((amount * percent) * 10000) / 10000D; } public WorthItem getWorth(ItemStack item, boolean includeFree) { - - return null; + + return null; } public enum worthType { - all, hand, blocks, same, material; + all, hand, blocks, same, material, gui; - public static worthType getByname(String name) { - for (worthType one : worthType.values()) { - if (one.name().equalsIgnoreCase(name)) - return one; - } - return null; - } + public static worthType getByName(String name) { + for (worthType one : worthType.values()) { + if (one.name().equalsIgnoreCase(name)) + return one; + } + return null; + } } public List getItems(Player player, worthType type) { - return getItems(player, type, null); + return getItems(player, type, null); } public List getItems(Player player, worthType type, CMIMaterial material) { - return getItems(player, type, material, 0); + return getItems(player, type, material, 0); } public List getItems(Player player, worthType type, CMIMaterial material, int amount) { - return null; + return null; } public boolean isShulkerWithItems(ItemStack item) { - if (!CMIMaterial.isShulkerBox(item.getType())) - return false; - List items = plugin.getShulkerBoxManager().getShulkerBoxContents(item); - return !items.isEmpty(); + if (!CMIMaterial.isShulkerBox(item.getType())) + return false; + List items = plugin.getShulkerBoxManager().getShulkerBoxContents(item); + return !items.isEmpty(); } List badLore = new ArrayList(); @@ -195,28 +187,28 @@ public boolean isShulkerWithItems(ItemStack item) { private boolean customNameBlocking = false; public void loadConfig() { - + } public HashMap> getMap() { - return map; + return map; } public WorthItem addWorth(WorthItem worth) { - return null; + + return null; } @Deprecated public void openWorthListGui(Player player, int page) { - openWorthListGui(player, page, false); + openWorthListGui(player, page, false); } public void openWorthListGui(Player player, int page, boolean missing) { - - } + } public int getAutoGeneratePriceIncrease() { - return autoGeneratePriceIncrease; + return autoGeneratePriceIncrease; } } diff --git a/src/com/Zrips/CMI/Modules/tp/SafeTeleport.java b/src/com/Zrips/CMI/Modules/tp/SafeTeleport.java index 6d3c4f3..3ae8860 100644 --- a/src/com/Zrips/CMI/Modules/tp/SafeTeleport.java +++ b/src/com/Zrips/CMI/Modules/tp/SafeTeleport.java @@ -1,6 +1,7 @@ package com.Zrips.CMI.Modules.tp; import org.bukkit.Location; + import com.Zrips.CMI.Modules.tp.Teleportations.TpCondition; public class SafeTeleport { @@ -13,74 +14,62 @@ public class SafeTeleport { private boolean forceDisableFly; public SafeTeleport(Location old, Location safeLoc, Location lastCheckedLoc, TpCondition TpCondition) { - this(old, safeLoc, lastCheckedLoc, TpCondition, false); + this(old, safeLoc, lastCheckedLoc, TpCondition, false); } public SafeTeleport(Location old, Location safeLoc, TpCondition TpCondition) { - this(old, safeLoc, TpCondition, false); + this(old, safeLoc, TpCondition, false); } public SafeTeleport(Location old, Location safeLoc, TpCondition TpCondition, boolean enableFly) { - this(old, safeLoc, null, TpCondition, enableFly); + this(old, safeLoc, null, TpCondition, enableFly); } public SafeTeleport(Location old, Location safeLoc, Location lastCheckedLoc, TpCondition TpCondition, boolean enableFly) { - this.old = old; - this.safeLoc = safeLoc; - this.TpCond = TpCondition; - this.enableFly = enableFly; - this.lastCheckedLoc = lastCheckedLoc; + this.old = old; + this.safeLoc = safeLoc; + this.TpCond = TpCondition; + this.enableFly = enableFly; + this.lastCheckedLoc = lastCheckedLoc; } public Location getOld() { - return old; + return old; } -// public void setOld(Location old) { -// this.old = old; -// } - public Location getSafeLoc() { - if (safeLoc == null) - return old; - return safeLoc; + if (safeLoc == null) + return old; + return safeLoc; } -// public void setSafeLoc(Location safeLoc) { -// this.safeLoc = safeLoc; -// } - public TpCondition getTpCondition() { - return TpCond; + return TpCond; } -// public void setTpCondition(TpCondition tpCondition) { -// TpCondition = tpCondition; -// } - public boolean isEnableFly() { - return enableFly; + return enableFly; } public SafeTeleport setEnableFly(boolean enableFly) { - this.enableFly = enableFly; - return this; + this.enableFly = enableFly; + return this; } public boolean isForceDisableFly() { - return forceDisableFly; + return forceDisableFly; } public void setForceDisableFly(boolean forceDisableFly) { - this.forceDisableFly = forceDisableFly; + this.forceDisableFly = forceDisableFly; } public Location getLastCheckedLoc() { - return lastCheckedLoc; + return lastCheckedLoc; } public void setLastCheckedLoc(Location lastCheckedLoc) { - this.lastCheckedLoc = lastCheckedLoc; + this.lastCheckedLoc = lastCheckedLoc; } } diff --git a/src/com/Zrips/CMI/Modules/tp/Teleportations.java b/src/com/Zrips/CMI/Modules/tp/Teleportations.java index 0bdfd9a..65161f5 100644 --- a/src/com/Zrips/CMI/Modules/tp/Teleportations.java +++ b/src/com/Zrips/CMI/Modules/tp/Teleportations.java @@ -8,7 +8,6 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.World; @@ -21,10 +20,8 @@ import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.CMIHitBox; import com.Zrips.CMI.Containers.CMIUser; -import com.Zrips.CMI.Containers.RandomTeleport; import com.Zrips.CMI.Modules.Particl.ParticleManager.CMIPresetAnimations; import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; -import com.Zrips.CMI.Modules.Worlds.CMIWorld; import net.Zrips.CMILib.Container.CMILocation; import net.Zrips.CMILib.Items.CMIMaterial; @@ -41,72 +38,80 @@ public class Teleportations { private int btprange = 15; public enum TeleportType { - Unknown(TeleportCause.UNKNOWN), - Elevator(TeleportCause.UNKNOWN), - SafeLogin(TeleportCause.PLUGIN), - Spawn(TeleportCause.COMMAND), - NetherRoof(TeleportCause.PLUGIN), - BelowBedrock(TeleportCause.PLUGIN), - Back(TeleportCause.COMMAND), - DBack(TeleportCause.COMMAND), - Home(TeleportCause.COMMAND), - Jump(TeleportCause.COMMAND), - Patrol(TeleportCause.COMMAND), - Portal(TeleportCause.PLUGIN), - WarmUp(TeleportCause.COMMAND), - Biome(TeleportCause.COMMAND), - FlightCharge(TeleportCause.PLUGIN), - InvEdit(TeleportCause.COMMAND), - TimedCommand(TeleportCause.PLUGIN), - TpaAll(TeleportCause.COMMAND), - Tp(TeleportCause.COMMAND), - Top(TeleportCause.COMMAND), - TpAll(TeleportCause.COMMAND), - TpHere(TeleportCause.COMMAND), - TpPos(TeleportCause.COMMAND), - Warp(TeleportCause.COMMAND), - JoinSpawn(TeleportCause.PLUGIN), - Totem(TeleportCause.PLUGIN), - randomTp(TeleportCause.COMMAND), - World(TeleportCause.COMMAND), - HoloEdit(TeleportCause.PLUGIN); - - private CMIPresetAnimations from = null; - private CMIPresetAnimations to = null; - private TeleportCause cause; - - TeleportType(TeleportCause cause) { - this.cause = cause; - } - - public CMIPresetAnimations getFrom() { - return from; - } - - public void setFrom(CMIPresetAnimations from) { - this.from = from; - } - - public CMIPresetAnimations getTo() { - return to; - } - - public void setTo(CMIPresetAnimations to) { - this.to = to; - } - - public TeleportCause getCause() { - return cause; - } + Unknown(TeleportCause.UNKNOWN), + Elevator(TeleportCause.UNKNOWN), + SafeLogin(TeleportCause.PLUGIN), + Spawn(TeleportCause.COMMAND), + NetherRoof(TeleportCause.PLUGIN), + BelowBedrock(TeleportCause.PLUGIN), + Back(TeleportCause.COMMAND), + DBack(TeleportCause.COMMAND), + Home(TeleportCause.COMMAND), + Jump(TeleportCause.COMMAND), + Patrol(TeleportCause.COMMAND), + Portal(TeleportCause.PLUGIN), + WarmUp(TeleportCause.COMMAND), + Biome(TeleportCause.COMMAND), + FlightCharge(TeleportCause.PLUGIN), + InvEdit(TeleportCause.COMMAND), + TimedCommand(TeleportCause.PLUGIN), + TpaAll(TeleportCause.COMMAND), + Tp(TeleportCause.COMMAND), + Top(TeleportCause.COMMAND), + Down(TeleportCause.COMMAND), + TpAll(TeleportCause.COMMAND), + TpHere(TeleportCause.COMMAND), + TpPos(TeleportCause.COMMAND), + Warp(TeleportCause.COMMAND), + JoinSpawn(TeleportCause.PLUGIN), + Totem(TeleportCause.PLUGIN), + randomTp(TeleportCause.COMMAND), + World(TeleportCause.COMMAND), + HoloEdit(TeleportCause.PLUGIN); + + private CMIPresetAnimations from = null; + private CMIPresetAnimations to = null; + private TeleportCause cause; + + TeleportType(TeleportCause cause) { + this.cause = cause; + } + + public CMIPresetAnimations getFrom() { + return from; + } + + public void setFrom(CMIPresetAnimations from) { + this.from = from; + } + + public CMIPresetAnimations getTo() { + return to; + } + + public void setTo(CMIPresetAnimations to) { + this.to = to; + } + + public TeleportCause getCause() { + return cause; + } } public enum TpCondition { - Lava, Void, Suffocation, Good, Unknown, Plugin, unsafeTeleportation, noPerm; + Lava, Void, Suffocation, Good, Unknown, Plugin, unsafeTeleportation, noPerm; - public static String getBadLocations() { - String all = ""; - return all; - } + public static String getBadLocations() { + String all = ""; + for (TpCondition one : TpCondition.values()) { + if (one.equals(TpCondition.Good)) + continue; + if (!all.isEmpty()) + all += "/"; + all += one.name(); + } + return all; + } } private void fill() { @@ -114,235 +119,227 @@ private void fill() { } public Teleportations(CMI plugin) { + this.plugin = plugin; + fill(); } private static boolean isImortal(Player player) { - CMIUser user = CMI.getInstance().getPlayerManager().getUser(player); - if (user == null) - return false; - return user.isGod() || player.getGameMode() == GameMode.CREATIVE || player.getGameMode().name().equalsIgnoreCase("SPECTATOR"); + CMIUser user = CMI.getInstance().getPlayerManager().getUser(player); + if (user == null) + return false; + return user.isGod() || player.getGameMode() == GameMode.CREATIVE || player.getGameMode().name().equalsIgnoreCase("SPECTATOR"); } public boolean teleport(Player player, Location loc, TeleportType type) { - return teleport(null, player, loc, true, false, true, type, false, null); + return teleport(null, player, loc, true, false, true, type, false, null); } public boolean teleport(Player player, Location loc, boolean inform, boolean reqPerm, TeleportType type) { - return teleport(null, player, loc, inform, reqPerm, true, type, false, null); + return teleport(null, player, loc, inform, reqPerm, true, type, false, null); } public boolean teleport(Player player, Location loc, boolean inform, boolean reqPerm, boolean forceTeleport, TeleportType type) { - return teleport(null, player, loc, inform, reqPerm, forceTeleport, type, false, null); + return teleport(null, player, loc, inform, reqPerm, forceTeleport, type, false, null); } public boolean teleport(Player player, Location loc, boolean reqPerm, TeleportType type) { - return teleport(null, player, loc, false, reqPerm, true, type, false, null); + return teleport(null, player, loc, false, reqPerm, true, type, false, null); } public boolean teleport(CommandSender sender, Player player, Location loc, TeleportType type) { - return teleport(sender, player, loc, true, true, true, type, false, null); + return teleport(sender, player, loc, true, true, true, type, false, null); } public boolean teleport(CommandSender sender, Player player, Location loc, boolean inform, TeleportType type) { - return teleport(sender, player, loc, inform, true, true, type, false, null); + return teleport(sender, player, loc, inform, true, true, type, false, null); } public boolean teleport(CommandSender sender, Player player, Location loc, boolean inform, boolean reqPerm, TeleportType type) { - return teleport(sender, player, loc, inform, reqPerm, true, type, false, null); + return teleport(sender, player, loc, inform, reqPerm, true, type, false, null); } public boolean teleport(CommandSender sender, Player player, Location loc, boolean inform, boolean reqPerm, boolean forceTeleport, TeleportType type) { - return teleport(sender, player, loc, inform, reqPerm, forceTeleport, type, false, null); + return teleport(sender, player, loc, inform, reqPerm, forceTeleport, type, false, null); } public boolean teleport(CommandSender sender, Player player, Location loc, boolean inform, boolean reqPerm, boolean forceTeleport, TeleportType type, boolean toSpawnIfNeeded) { - return teleport(sender, player, loc, inform, reqPerm, forceTeleport, type, toSpawnIfNeeded, null); + return teleport(sender, player, loc, inform, reqPerm, forceTeleport, type, toSpawnIfNeeded, null); } public boolean teleport(CommandSender sender, Player player, Location loc, boolean inform, boolean reqPerm, boolean forceTeleport, TeleportType type, boolean toSpawnIfNeeded, - Integer maxDistanceToCheck) { - return false; + Integer maxDistanceToCheck) { + + return false; } public boolean teleportAsync(CommandSender sender, Player player, boolean inform, SafeTeleport safe, TeleportType type, boolean toSpawnIfNeeded) { - return false; + + return false; } public boolean bypassesBadLocation(Player player, TpCondition condition) { - return CMIPerm.safeteleport_bypass_$1.hasPermission(player, condition.name()); + return CMIPerm.safeteleport_bypass_$1.hasPermission(player, condition.name()); } public void addBadTeleport(UUID uuid, Location loc) { - DangerousTp dtp = new DangerousTp(uuid, loc); - badTeleports.put(uuid, dtp); + DangerousTp dtp = new DangerousTp(uuid, loc); + badTeleports.put(uuid, dtp); } public void removeBadTp(UUID uuid) { - badTeleports.remove(uuid); + badTeleports.remove(uuid); } public Location getBadTp(UUID uuid) { - return null; + + return null; } public SafeTeleport getSafeLocationAsync(Player player, Location loc, boolean reqPerm, boolean forceTeleport, Integer maxDistanceToCheck) { - return null; + return null; } public SafeTeleport getSafeLocation(Player player, Location loc, boolean reqPerm, boolean forceTeleport) { - return getSafeLocation(player, loc, reqPerm, forceTeleport, null); + return getSafeLocation(player, loc, reqPerm, forceTeleport, null); } private Location center(CMIHitBox hitBox, Location cloned) { - return null; + + return null; } public SafeTeleport getSafeLocation(Player player, Location loc, boolean reqPerm, boolean forceTeleport, Integer maxDistanceToCheck) { - return null; + return null; } +// private boolean finalizeTeleport(Player player, Location loc) { +// return finalizeTeleport(player, loc, TeleportType.Unknown, true); +// } public boolean directTeleport(Player player, Location loc, TeleportType type) { - return finalizeTeleport(player, loc, type, true); + return finalizeTeleport(player, loc, type, true); } private boolean finalizeTeleport(Player player, Location loc, TeleportType t, boolean toSpawnIfNeeded) { - return true; + return true; } private void setTeleportInvulnerability(Player player) { - + } public List shakePassengers(Entity entity) { - - return null; + + return null; } public boolean isBad(Block block) { - CMILocation loc = new CMILocation(block.getLocation()); - CMIMaterial cmat = loc.getBlockCMIType(); - return bad.contains(cmat); + CMILocation loc = new CMILocation(block.getLocation()); + CMIMaterial cmat = loc.getBlockCMIType(); + return bad.contains(cmat); } public boolean isEmpty(Block block) { - - return false; + + return false; } public boolean isWater(Block block) { - CMILocation loc = new CMILocation(block.getLocation()); - CMIMaterial cmat = loc.getBlockCMIType(); - return cmat.isWater(); + CMILocation loc = new CMILocation(block.getLocation()); + CMIMaterial cmat = loc.getBlockCMIType(); + return cmat.isWater(); } public double getDistanceToDrop(Player player, Location loc) { - Location down = getDownLocation(player, loc); - return down == null ? 0 : down.distance(loc); + Location down = getDownLocation(player, loc); + return down == null ? 0 : down.distance(loc); } public boolean isSafeToDrop(Location loc, Player player) { - - return false; + + return false; } public Location getDownLocationAsync(Player player, Location oloc, Integer maxDistanceToCheck) { - - return null; + + return null; } public Location getDownLocation(Player player, Location oloc) { - return getDownLocation(player, oloc, null); + return getDownLocation(player, oloc, null); } public Location getDownLocation(Player player, Location oloc, Integer maxDistanceToCheck) { - - return null; + + return null; } public Location getDownLocationSimple(Location oloc) { - - return null; + return getDownLocationSimple(oloc, false); + } + + public Location getDownLocationSimple(Location oloc, boolean firstHitOnly) { + + return null; } private Location cycleDown(Location loc) { - - return null; + return cycleDown(loc, false); + } + + private Location cycleDown(Location loc, boolean firstHitOnly) { + + return null; } public Location getUpLocation(Player player, Location oloc) { - return getUpLocation(player, oloc, null); + return getUpLocation(player, oloc, null); } public Location getUpLocation(Player player, Location oloc, Integer maxDistanceToCheck) { - return null; + return null; } public Location getTopLocation(Location loc) { - return null; + return null; } public boolean needToFly(Player player) { - int distance = 0; - Location loc = player.getLocation().clone(); - - int y = loc.getBlockY(); - - int lowestY = CMIWorld.getMinHeight(loc.getWorld()); - - while (isEmpty(loc.getBlock()) && y > lowestY) { - distance++; - y--; - loc.setY(y); - } - - if (isBad(loc.getBlock())) - return true; - - if (y <= lowestY) - return true; - return distance > 4; + return true; } public Location getSafeLocation(Player player) { - Location loc = player.getLocation(); - return getDownLocation(player, loc); + Location loc = player.getLocation(); + return getDownLocation(player, loc); } ConcurrentHashMap> randomLocCache = new ConcurrentHashMap>(); Set cacheFilling = new HashSet(); public void clearRLCache() { - randomLocCache.clear(); + randomLocCache.clear(); } public void fillRLCache() { - for (World one : Bukkit.getWorlds()) { - RandomTeleport rtloc = plugin.getConfigManager().getRandomTeleport(one); - if (rtloc == null) - continue; - fillRLCache(one); - } + } private void fillRLCache(World world) { - fillRLCache(world.getName()); + fillRLCache(world.getName()); } public CMILocation fillRLCache(String worldName) { - - return null; - } + return null; + } public CMILocation getRandomCachedLocation(World world) { - - return null; + return null; } Random random = new Random(System.nanoTime()); @@ -350,6 +347,6 @@ public CMILocation getRandomCachedLocation(World world) { public Location getRandomLocation(World world) { - return null; + return null; } } diff --git a/src/com/Zrips/CMI/Modules/tp/TpManager.java b/src/com/Zrips/CMI/Modules/tp/TpManager.java index 81c5115..aabc0d0 100644 --- a/src/com/Zrips/CMI/Modules/tp/TpManager.java +++ b/src/com/Zrips/CMI/Modules/tp/TpManager.java @@ -1,101 +1,107 @@ package com.Zrips.CMI.Modules.tp; -import java.util.HashSet; -import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.events.CMIPlayerTeleportRequestEvent; public class TpManager { private CMI plugin; - TreeMap> tpRequests = new TreeMap>(); - TreeMap> blockedRequests = new TreeMap>(); + private TreeMap> tpRequests = new TreeMap>(); + private TreeMap> blockedRequests = new TreeMap>(); // public int showFor = 60; // public int blockFor = 6; public enum TpAction { - tpa, tpahere, tpaall, tp, warp, home, spawn; + tpa, tpahere, tpaall, tp, warp, home, spawn; - public static TpAction get(String name) { - for (TpAction one : TpAction.values()) { - if (one.toString().equalsIgnoreCase(name)) - return one; - } - return null; - } + public static TpAction get(String name) { + for (TpAction one : TpAction.values()) { + if (one.toString().equalsIgnoreCase(name)) + return one; + } + return null; + } } public TpManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void clearRequests(Player player) { - tpRequests.remove(player.getUniqueId()); + tpRequests.remove(player.getUniqueId()); } private void clearRequests() { + } private void clearBlocks() { + } public void addTpBlock(Player whoAccepts, TpInfo ti) { + } public boolean isBlockedRequest(Player whoOffers, Player whoAccepts, TpAction action) { - - return false; + + return false; } public long getBlockTime(Player whoOffers, Player whoAccepts, TpAction action) { - - return 0L; + + return 0L; } public boolean addTpRequest(Player whoOffers, Player whoAccepts, TpAction action) { - return addTpRequest(whoOffers, whoAccepts, action, true); + return addTpRequest(whoOffers, whoAccepts, action, true); } public boolean addTpRequest(Player whoOffers, Player whoAccepts, TpAction action, boolean currentLoc) { - return true; + return true; } public boolean removeTpRequest(Player whoOffers, Player whoAccepts) { - Set list = tpRequests.get(whoOffers.getUniqueId()); - if (list == null) - return true; - for (TpInfo one : new HashSet(list)) { - if (one.getWhoAccepts().equals(whoAccepts)) { - list.remove(one); - return true; - } - } - return false; + + return false; } public boolean isAlreadyInRequest(Player whoOffers, Player whoAccepts, TpAction action) { - - return false; + + return false; } @Deprecated public TpInfo getTeleportInfo(Player whoAccepts, Player whoOffers) { - return getTeleportInfo(whoAccepts, whoOffers, null); + return getTeleportInfo(whoAccepts, whoOffers, null); } public TpInfo getTeleportInfo(Player whoAccepts, Player whoOffers, TpAction action) { - - return null; + + return null; } + public TreeMap> getTpRequests() { + return tpRequests; + } + + public Set getTpRequests(UUID uuid) { + return tpRequests.get(uuid); + } + + public TreeMap> getBlockedRequests() { + return blockedRequests; + } + + public Set getBlockedRequests(UUID uuid) { + return blockedRequests.get(uuid); + } } diff --git a/src/com/Zrips/CMI/NBT/NMS.java b/src/com/Zrips/CMI/NBT/NMS.java index 4b1aa7f..7154f99 100644 --- a/src/com/Zrips/CMI/NBT/NMS.java +++ b/src/com/Zrips/CMI/NBT/NMS.java @@ -50,7 +50,7 @@ public interface NMS { Player getPlayer(CMIUser user); - ItemStack addAttributes(List ls, ItemStack item); +// ItemStack addAttributes(List ls, ItemStack item); void updateCollisions(Player player, boolean collision, boolean onlyTarget); @@ -62,6 +62,8 @@ public interface NMS { public void showResurection(Player player); +// boolean changeGameModePlayerSide(Player player, int state); + boolean changeGodMode(Player player, boolean state); boolean getGodMode(Player player); @@ -108,7 +110,7 @@ public interface NMS { boolean forceTeleport(Player player, Location location); - HashMap getBlockStates(Block block); +// HashMap getBlockStates(Block block); CMIHitBox getBlockHitBox(CMIHitBox hb); @@ -130,5 +132,8 @@ public interface NMS { void setEntityTag(Entity entity, String path, Object value); +// TreeMap getIpBans(); + +// void printEntityTag(Entity object, Player player); } diff --git a/src/com/Zrips/CMI/PlayerManager.java b/src/com/Zrips/CMI/PlayerManager.java index 06a0c97..e7df45d 100644 --- a/src/com/Zrips/CMI/PlayerManager.java +++ b/src/com/Zrips/CMI/PlayerManager.java @@ -1,30 +1,69 @@ package com.Zrips.CMI; +import java.io.File; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.UUID; +import java.util.regex.Matcher; import java.util.regex.Pattern; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.OfflinePlayer; +import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import com.Zrips.CMI.Containers.CMIUser; +import com.Zrips.CMI.Containers.PlayerMail; +import com.Zrips.CMI.Containers.PlayerNote; +import com.Zrips.CMI.Containers.Snd; +import com.Zrips.CMI.Locale.CMILC; +import com.Zrips.CMI.Modules.CmdCooldown.CmdCooldown; +import com.Zrips.CMI.Modules.CmdCooldown.CmdCooldown.CMICooldown; +import com.Zrips.CMI.Modules.DataBase.DBDAO; import com.Zrips.CMI.Modules.DataBase.DBDAO.TablesFieldsType; import com.Zrips.CMI.Modules.DataBase.DBDAO.UserTablesFields; - +import com.Zrips.CMI.Modules.DataBase.DBDAO.mysqltypes; +import com.Zrips.CMI.Modules.Economy.CMIEconomyAcount; +import com.Zrips.CMI.Modules.Economy.EconomyManager.WorldGroup; +import com.Zrips.CMI.Modules.Homes.CmiHome; +import com.Zrips.CMI.Modules.Jail.CMIJail; +import com.Zrips.CMI.Modules.Jail.CMIJailCell; +import com.Zrips.CMI.Modules.Kits.Kit; +import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; +import com.Zrips.CMI.Modules.PlayerOptions.PlayerOption; +import com.Zrips.CMI.Modules.Vanish.VanishManager; +import com.Zrips.CMI.Modules.Warnings.CMIPlayerWarning; +import com.Zrips.CMI.Modules.Warnings.CMIWarningCategory; +import com.Zrips.CMI.Modules.Warps.CmiWarp; +import com.Zrips.CMI.utils.DateFormat; +import com.google.common.base.Charsets; + +import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Container.CMILocation; +import net.Zrips.CMILib.Container.PageInfo; +import net.Zrips.CMILib.GUI.CMIGui; +import net.Zrips.CMILib.GUI.CMIGuiButton; +import net.Zrips.CMILib.GUI.GUIManager.GUIClickType; +import net.Zrips.CMILib.Items.CMIMaterial; +import net.Zrips.CMILib.Logs.CMIDebug; +import net.Zrips.CMILib.RawMessages.RawMessage; +import net.Zrips.CMILib.Time.CMITimeManager; public class PlayerManager { @@ -52,142 +91,153 @@ public class PlayerManager { private CMI plugin; public PlayerManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void updateUserName(CMIUser user, String newName) { - } public void clearData() { + users.clear(); + usersName.clear(); + duplicateUserNames.clear(); + cuffed.clear(); } public Map getAllUsers() { - return users; + return users; } public boolean isDuplicatedUserName(String name) { - return duplicateUserNames.containsKey(name.toLowerCase()); + return duplicateUserNames.containsKey(name.toLowerCase()); } public Map> getDuplicatedUsers() { - return duplicateUserNames; + return duplicateUserNames; } public CMIUser getDuplicatedUser(String name) { + if (!duplicateUserNames.containsKey(name.toLowerCase())) + return null; - CMIUser newest = null; + CMIUser newest = null; - return newest; + return newest; } public boolean switchPlayerData(UUID source, UUID target) { - return false; + CMIUser source1 = plugin.getPlayerManager().getUser(source); + if (source == null) + return false; + CMIUser target2 = plugin.getPlayerManager().getUser(target); + if (target == null) + return false; + + return switchPlayerData(source1, target2); } public boolean switchPlayerData(CMIUser source, CMIUser target) { - - return true; + return true; } public boolean addDuplicatedUser(CMIUser user) { - - return true; + return true; } public int getTotalUserCount() { - return realUserCount; + return realUserCount; } public CMIUser softRemoveUser(UUID uuid) { - return softRemoveUser(this.getUser(uuid)); + return softRemoveUser(this.getUser(uuid)); } public CMIUser softRemoveUser(UUID uuid, boolean fromDataBse) { - return softRemoveUser(this.getUser(uuid), fromDataBse); + return softRemoveUser(this.getUser(uuid), fromDataBse); } public CMIUser softRemoveUser(CMIUser user) { - return softRemoveUser(user, true); + return softRemoveUser(user, true); } public CMIUser softRemoveUser(CMIUser user, boolean fromDataBse) { - return null; + return user; } public void removeUser(CMIUser user) { - - } + } private CMIUser getByName(String name) { - if (name == null) - return null; - return usersName.get(name.toLowerCase()); + if (name == null) + return null; + return usersName.get(name.toLowerCase()); } public void addUser(CMIUser user) { - } + + } public CMIUser getUser(Integer id) { - return usersIds.get(id); + return usersIds.get(id); } public void addUser(CMIUser user, Integer id) { - if (id > 0) - usersIds.put(id, user); + if (id > 0) + usersIds.put(id, user); } public CMIUser getUserByAproxName(String name) { - return getUser(name, true, false, false, false, true); + return getUser(name, true, false, false, false, true); } public CMIUser getUser(String name) { - return getUser(name, true, false, false, true, true); + return getUser(name, true, false, false, true, true); } public CMIUser getUser(String name, boolean includeDuplicate) { - return getUser(name, includeDuplicate, false, false, true, true); + return getUser(name, includeDuplicate, false, false, true, true); } @Deprecated public CMIUser getUser(String name, boolean includeDuplicate, boolean checkOflline) { - return getUser(name, includeDuplicate, checkOflline, false, true, true); + return getUser(name, includeDuplicate, checkOflline, false, true, true); } public CMIUser getUser(String name, boolean includeDuplicate, @Deprecated boolean checkOflline, boolean createFake, boolean exactName) { - return getUser(name, includeDuplicate, checkOflline, createFake, exactName, true); + return getUser(name, includeDuplicate, checkOflline, createFake, exactName, true); } public CMIUser getUser(String name, boolean includeDuplicate, @Deprecated boolean checkOflline, boolean createFake, boolean exactName, boolean checkNickName) { - - - return null; - + + return null; + } public boolean isUserExist(UUID uuid) { - return users.containsKey(uuid); + return users.containsKey(uuid); } public CMIUser getUser(OfflinePlayer player) { - return getUser(player, true); + return getUser(player, true); } public CMIUser getUser(OfflinePlayer player, boolean createNew) { - - return null; - + return null; + } public CMIUser getUser(Player player) { - return null; + + return null; + } public CMIUser getUser(UUID uuid) { - return null; - + + return null; + } public void loadData() { @@ -195,77 +245,69 @@ public void loadData() { } public boolean checkForExistingSimilarUser(CMIUser user, boolean inform) { - - return true; + + return true; } public Map convertLoc(Location loc) { - Map map = new HashMap(); - return map; + Map map = new HashMap(); + return map; } public String convertLocToString(Location loc) { - String map = ""; - return map.replace(",", "."); + String map = ""; + return map.replace(",", "."); } public String convertLocToString(CMILocation loc) { - String map = ""; - return map.replace(",", "."); + String map = ""; + return map.replace(",", "."); } public String convertBlockLocToString(Location loc) { - String map = ""; - - return map.replace(",", "."); + String map = ""; + return map.replace(",", "."); } public String convertLocToStringShort(CMILocation loc) { - String map = ""; - - return map.replace(",", "."); + String map = ""; + return map.replace(",", "."); } public String convertLocToStringShort(Location loc) { - String map = ""; - - return map.replace(",", "."); + String map = ""; + return map.replace(",", "."); } public CMILocation convertStringToLocation(String map, boolean includeSpawnPoints) { - CMILocation loc = convertStringToLocation(map); - - - return loc; + CMILocation loc = convertStringToLocation(map); + return loc; } public CMILocation convertStringToLocation(String map) { - CMILocation loc = null; - - return loc; + CMILocation loc = null; + + + return loc; } public CMILocation getLoc(YamlConfiguration conf, String path) { - - return null; + + return null; } public void saveUser(CMIUser user) { - save(user); + save(user); } - private void save(CMIUser user) { - } public static HashMap timer = new HashMap(); public static int timesProcessed = 0; - public PreparedStatement savePlayerToDB(CMIUser user, PreparedStatement prest, boolean addId) throws Throwable { - - - return prest; + public PreparedStatement savePlayerToDB(CMIUser user, PreparedStatement prest, boolean addId) throws Throwable { + return prest; } public static final String mapKeySeparator = "%%"; @@ -279,20 +321,20 @@ public PreparedStatement savePlayerToDB(CMIUser user, PreparedStatement prest, b private static Pattern kitPattern = Pattern.compile("(\\S+)(" + multiSeparator + ")(\\d)"); private static String filterOutForLoad(String message) { - return message.replace(mapKeySeparatorForsave, mapKeySeparator).replace(sectionSeparatorForSave, sectionSeparator).replace(lineSeparatorForSave, lineSeparator); + return message.replace(mapKeySeparatorForsave, mapKeySeparator).replace(sectionSeparatorForSave, sectionSeparator).replace(lineSeparatorForSave, lineSeparator); } private static String filterOutForSave(String message) { - return message.replace(mapKeySeparator, mapKeySeparatorForsave).replace(sectionSeparator, sectionSeparatorForSave).replace(lineSeparator, lineSeparatorForSave); + return message.replace(mapKeySeparator, mapKeySeparatorForsave).replace(sectionSeparator, sectionSeparatorForSave).replace(lineSeparator, lineSeparatorForSave); } private static PreparedStatement proccessForSaveField(PreparedStatement prest, int place, Object value, UserTablesFields field) throws Throwable { - - return prest; + + return prest; } public void loadUserFromDb(ResultSet res) { - + } // private Long lastUserChecked = 0L; @@ -300,157 +342,227 @@ public void loadUserFromDb(ResultSet res) { List duplicates = new ArrayList(); + private static CMILocation invertLoc(Object loc) { + CMILocation l = (CMILocation) loc; + CMILocation n = new CMILocation(l.getWorldName(), l.getX(), l.getY(), l.getZ()); + n.setPitch(l.getYaw()); + n.setYaw(l.getPitch()); + return n; + } public Object getValueFromDb(ResultSet res, TablesFieldsType fieldType, String collumn) { - Object value = null; - - return value; + Object value = null; + + return value; + } + + private static List getStringListFromString(String string) { + List list = new ArrayList(); + + return list; + } + + private static HashMap getStringLongMapFromString(String string) { + HashMap map = new HashMap(); + + return map; + } + + private static HashMap getStringDoubleMapFromString(String string) { + HashMap map = new HashMap(); + + return map; + } + + private static HashMap getStringStringMapFromString(String string) { + HashMap map = new HashMap(); + + return map; + } + + private static HashMap getStringIntMapFromString(String string) { + HashMap map = new HashMap(); + + return map; + } + + private static String convertLocationToString(CMILocation loc) { + return (loc.getWorld() == null ? loc.getWorldName() : loc.getWorld().getName()) + sectionSeparator + fNumber(loc.getX()) + sectionSeparator + fNumber(loc.getY()) + sectionSeparator + + fNumber(loc.getZ()) + sectionSeparator + fNumber(loc.getPitch()) + sectionSeparator + fNumber(loc.getYaw()); + } + + private static String convertLocationToString(Location loc) { + return null; + } + + private static Double fNumber(float amount) { + return (long) (amount * 100) / 100D; } static DecimalFormat decimalFormat = new DecimalFormat("0.00"); + private static Double fNumber(Double amount) { + return (long) (amount * 100) / 100D; + } + + + private static LinkedHashMap getLocationMapFromString(String string) { + LinkedHashMap map = new LinkedHashMap(); + + return map; + } + + private static CMILocation getLocationFromString(String string) { + + return null; + + } + public void addCuffed(UUID uuid) { - if (uuid == null) - return; - this.cuffed.add(uuid); + if (uuid == null) + return; + this.cuffed.add(uuid); } public void removeCuffed(Player player) { - removeCuffed(player.getUniqueId()); + removeCuffed(player.getUniqueId()); } public void removeCuffed(UUID uuid) { - if (uuid == null) - return; - this.cuffed.remove(uuid); + if (uuid == null) + return; + this.cuffed.remove(uuid); } public boolean isCuffed(Player player) { - return isCuffed(player.getUniqueId()); + return isCuffed(player.getUniqueId()); } public boolean isCuffed(UUID uuid) { - if (uuid == null) - return false; - return this.cuffed.contains(uuid); + if (uuid == null) + return false; + return this.cuffed.contains(uuid); } HashMap delaySSTrigger = new HashMap(); public void removeSocialSpyDelayed(UUID uuid) { - Integer id = delaySSTrigger.remove(uuid); - if (id != null) - Bukkit.getScheduler().cancelTask(id); } public void addSocialSpyDelayed(final UUID uuid) { + } public void addSocialSpy(UUID uuid) { - this.socialSpy.add(uuid); + this.socialSpy.add(uuid); } public void removeSocialSpy(UUID uuid) { - this.socialSpy.remove(uuid); + this.socialSpy.remove(uuid); } public boolean isSocialSpy(UUID uuid) { - return this.socialSpy.contains(uuid); + return this.socialSpy.contains(uuid); } public void sendMessageToSpies(CommandSender sender, String senderName, Player receiver, String msg) { - + } public void sendChatRoomMessageToSpies(CommandSender sender, String receiver, String msg) { - + } HashMap delayCSTrigger = new HashMap(); HashMap delaySignSTrigger = new HashMap(); public void removeCommandSpyDelayed(UUID uuid) { - } public void addCommandSpyDelayed(final UUID uuid) { - } public void addCommandSpy(UUID uuid) { - this.commandSpy.add(uuid); + this.commandSpy.add(uuid); } public void removeCommandSpy(UUID uuid) { - this.commandSpy.remove(uuid); + this.commandSpy.remove(uuid); } public boolean isCommandSpy(UUID uuid) { - return this.commandSpy.contains(uuid); + return this.commandSpy.contains(uuid); } public void sendMessageToCommandSpies(Player sender, String msg) { - + } public void addSignSpyDelayed(final UUID uuid) { - + } public void addSignSpy(UUID uuid) { - this.signSpy.add(uuid); + this.signSpy.add(uuid); } public void removeSignSpy(UUID uuid) { - this.signSpy.remove(uuid); + this.signSpy.remove(uuid); } public boolean isSignSpy(UUID uuid) { - return this.signSpy.contains(uuid); + return this.signSpy.contains(uuid); } public void sendMessageToSignSpies(Player sender, String msg, Location loc) { - + } public UUID getEmptyUserUUID() { - return emptyUserUUID; + return emptyUserUUID; } public void forceSaveAllUsersIntoDataBase() { + for (Entry one : this.users.entrySet()) { + one.getValue().addForDelayedSave(); + } } public Player getFakeOperator() { - fakeOperator = plugin.getNMS().createFakeOperator(); - return fakeOperator; + fakeOperator = plugin.getNMS().createFakeOperator(); + if (fakeOperator != null) + for (Player on : Bukkit.getOnlinePlayers()) { + on.hidePlayer(plugin, fakeOperator); + } + return fakeOperator; } public Player getFakeOperatorRaw() { - return fakeOperator; + return fakeOperator; } public String getFakeUserName() { - return fakeUserName; + return fakeUserName; } public UUID getFakeUserUUID() { - return fakeUserUUID; + return fakeUserUUID; } public boolean openMailGui(Player player, int page) { - return true; + return true; } public Set getAlerts() { - return alerts; + return alerts; } public void addAlert(UUID uuid) { - this.alerts.add(uuid); + this.alerts.add(uuid); } public void removeAlert(UUID uuid) { - this.alerts.remove(uuid); + this.alerts.remove(uuid); } } diff --git a/src/com/Zrips/CMI/Reflections.java b/src/com/Zrips/CMI/Reflections.java index 3759027..ac2e8b7 100644 --- a/src/com/Zrips/CMI/Reflections.java +++ b/src/com/Zrips/CMI/Reflections.java @@ -32,7 +32,7 @@ public class Reflections { private Class CEntity; private Class nbtTagCompound; private Class nbtTagList; - private Class NBTBase; +// private Class NBTBase; private Class EnumHand; private Class CraftBeehive; private Class TileEntityBeehive; @@ -48,21 +48,20 @@ public class Reflections { private CMI plugin; public Reflections(CMI plugin) { - this.plugin = plugin; - initialize(); + this.plugin = plugin; + initialize(); } private void initialize() { + } private static Class getBukkitClass(String nmsClassString) { - - return null; + return null; } public Class getMinecraftClass(String nmsClassString) { - - return null; + return null; } public void exitBed(Player p) { @@ -70,69 +69,92 @@ public void exitBed(Player p) { } public void setOnGround(Player p, boolean state) { - + } public void changePlayerLimit(int amount) { - + } @SuppressWarnings("deprecation") public void setGameMode(Player player, GameMode mode) { - + } @SuppressWarnings({ "unchecked", "deprecation" }) public void manageEnchantment(Enchantment enchant, boolean disable) { - + } public void setMotd(String motd) { - + } public int getPing(Player player) { - - return 999; + + return 999; } public int getHoneyLevel(Block block) { - - return 0; + + return 0; } public int getBeesInside(Block block) { - - return 0; + + return 0; + } + + public boolean openCartographyTable(Player player) { + + return false; + } + + public boolean openGrindstone(Player player) { + + return false; + } + + public boolean openLoom(Player player) { + + return false; + } + + public boolean openSmithingTable(Player player) { + + return false; + } + + public boolean openStonecutter(Player player) { + + return false; } public boolean openSignUI(Player player, Sign sign) { - - return false; + + return false; } public void respawn(Player player) { - + } public void openBook(ItemStack i, Player p) { - + } public void printItemNBT(ItemStack item, CommandSender sender) { - + } public void printEntityNBT(Entity entity, CommandSender sender) { - } public void printNBT(Object t, int level, CommandSender sender, List path) { - + } - public ItemStack tryToMakeShulkerBox(ItemStack item) { - return null; + public ItemStack tryToMakeShulkerBox(ItemStack item) { + return item; } - } diff --git a/src/com/Zrips/CMI/TabComplete.java b/src/com/Zrips/CMI/TabComplete.java index 2fd84a7..20adf90 100644 --- a/src/com/Zrips/CMI/TabComplete.java +++ b/src/com/Zrips/CMI/TabComplete.java @@ -16,14 +16,13 @@ public class TabComplete implements TabCompleter { private CMI plugin; public TabComplete(CMI plugin) { - this.plugin = plugin; } @Override public List onTabComplete(CommandSender sender, Command command, String label, String[] args) { - List completionList = get(sender, command.getName(), label, args); - Collections.sort(completionList); - return completionList; + List completionList = get(sender, command.getName(), label, args); + Collections.sort(completionList); + return completionList; } static HashMap map = new HashMap(); @@ -31,120 +30,122 @@ public List onTabComplete(CommandSender sender, Command command, String public static CMITabComplete tabs = new CMITabComplete(); public List getTabCompleteList(String[] args) { - return tabs.getTabCompleteList(args); + return tabs.getTabCompleteList(args); } public String getTabComplete(String tab) { - return tabs.getTabComplete(tab); + return tabs.getTabComplete(tab); } public void addTabComplete(String tab) { - tabs.addTabComplete(tab); + tabs.addTabComplete(tab); } public enum TabAction { - na, - allPlayername("All players including vanished ones"), - playername("All players excluding vanished ones"), - mutedplayername("All online muted players"), - damageCause("Damage cause variations"), - bannedplayername("Banned player names"), - gamemode("Game modes"), - worlds("Worlds"), - portals("List of portal names. Exclude disabled"), - allportals("List of portal names"), - itemname("Materials"), - playeritems("Materials in player inventory"), - blockname("Blocks"), - EntityType("Entity Types"), - cleanEntityType("Entity Types without _"), - kit("Kit names by access"), - kitnames("Kit config names by access"), - kitp("Kits by preview access"), - chatroom("Chat rooms"), - biome("Biomes"), - treeType("Tree types"), - maxplayers("Server max player limit"), - potioneffect("Potion effects"), - effect("Particle effects"), - merchants("Villager professions"), - enchant("Enchant names"), - halfViewRange("Half of max server view range"), - doubleViewRange("Double of max server view range"), - ViewRange("Server view range"), - maxenchantlevel("Max enchant level. Uses previous variable to determine enchantment"), - currentItemName("Item name in main hand"), - loreLine("Lists numbers of lore lines of item in main hand"), - currentItemLore("Lists lore of item in main hand"), - currentX("Current player X position"), - currentY("Current player Y position"), - currentZ("Current player Z position"), - currentWorld("World name player is in"), - currentPitch("Players pitch"), - currentYaw("Players yaw"), - itemFlag("Item flag values"), - nickName("Users display name"), - gamerule("List of world game rules"), - nickNames("All online users nick names"), - homes("Users home list"), - warps("Warps by access to them"), - allwarps("All warps"), - playerwarps("Warps by access to them"), - rankname("Rank names"), - statstype("Statistics names"), - statssubtype("Sub statistics names. Uses previous variable to determine main statistic"), - motd("Servers motd"), - bungeeserver("Bungee servers"), - scheduleName("Schedule names"), - ctext("Custom text names"), - attachedCommand("Includes attached command"), - jail("Jail names"), - cellId("Cewll id's. Uses previous variable to determine jail"), - sound("Sound names"), - customalias("Custom alias list"), - dbusercollumsshort, - placeholders("Placeholders"), - warncategory("Warn categories"), - projectiletype("Projectile types"), - holograms("Hologram names"), - mobtype("Mob types"), - signLine("Sign line text. Uses previous variable to determine line number"); - - private String desc; - - TabAction() { - } - - TabAction(String desc) { - this.desc = desc; - } - - public static TabAction getAction(String name) { - if (name.startsWith("_")) - return TabAction.na; - TabAction got = map.get(name.toLowerCase()); - return got == null ? TabAction.na : got; - } - - public String getDesc() { - return desc; - } + na, + allPlayername("All players including vanished ones"), + allIGNPlayername("All IGN players including vanished ones"), + playername("All players excluding vanished ones"), + mutedplayername("All online muted players"), + damageCause("Damage cause variations"), + bannedplayername("Banned player names"), + playerOption("Player options"), + gamemode("Game modes"), + worlds("Worlds"), + portals("List of portal names. Exclude disabled"), + allportals("List of portal names"), + itemname("Materials"), + playeritems("Materials in player inventory"), + blockname("Blocks"), + EntityType("Entity Types"), + cleanEntityType("Entity Types without _"), + kit("Kit names by access"), + kitnames("Kit config names by access"), + kitp("Kits by preview access"), + chatroom("Chat rooms"), + biome("Biomes"), + treeType("Tree types"), + maxplayers("Server max player limit"), + potioneffect("Potion effects"), + effect("Particle effects"), + merchants("Villager professions"), + enchant("Enchant names"), + halfViewRange("Half of max server view range"), + doubleViewRange("Double of max server view range"), + ViewRange("Server view range"), + maxenchantlevel("Max enchant level. Uses previous variable to determine enchantment"), + currentItemName("Item name in main hand"), + loreLine("Lists numbers of lore lines of item in main hand"), + currentItemLore("Lists lore of item in main hand"), + currentLocation("Current player location"), + currentFullLocation("Current player location with pitch and yaw"), + currentX("Current player X position"), + currentY("Current player Y position"), + currentZ("Current player Z position"), + currentWorld("World name player is in"), + currentPitch("Players pitch"), + currentYaw("Players yaw"), + itemFlag("Item flag values"), + nickName("Users display name"), + gamerule("List of world game rules"), + nickNames("All online users nick names"), + homes("Users home list"), + warps("Warps by access to them"), + allwarps("All warps"), + playerwarps("Warps by access to them"), + rankname("Rank names"), + statstype("Statistics names"), + statssubtype("Sub statistics names. Uses previous variable to determine main statistic"), + motd("Servers motd"), + bungeeserver("Bungee servers"), + scheduleName("Schedule names"), + ctext("Custom text names"), + attachedCommand("Includes attached command"), + jail("Jail names"), + cellId("Cewll id's. Uses previous variable to determine jail"), + sound("Sound names"), + customalias("Custom alias list"), + dbusercollumsshort, + placeholders("Placeholders"), + warncategory("Warn categories"), + projectiletype("Projectile types"), + holograms("Hologram names"), + mobtype("Mob types"), + signLine("Sign line text. Uses previous variable to determine line number"); + + private String desc; + + TabAction() { + } + + TabAction(String desc) { + this.desc = desc; + } + + public static TabAction getAction(String name) { + if (name.startsWith("_")) + return TabAction.na; + TabAction got = map.get(name.toLowerCase()); + return got == null ? TabAction.na : got; + } + + public String getDesc() { + return desc; + } } public List get(CommandSender sender, String command, String label, String[] args) { - List completionList = new ArrayList<>(); - return completionList; - + List completionList = new ArrayList<>(); + return completionList; } public List getByAction(CommandSender sender, TabAction action, String[] args, int i) { - List temp = new ArrayList(); - - return temp; + List temp = new ArrayList(); + return temp; } private static List getColorNames() { - List list = new ArrayList(); - return list; + List list = new ArrayList(); + return list; } } diff --git a/src/com/Zrips/CMI/commands/CAnnotation.java b/src/com/Zrips/CMI/commands/CAnnotation.java index c123aa1..0f483bb 100644 --- a/src/com/Zrips/CMI/commands/CAnnotation.java +++ b/src/com/Zrips/CMI/commands/CAnnotation.java @@ -19,19 +19,25 @@ @Deprecated String[] tab() default {}; + + // ! in front prevents repeatable suggestions + // |number| to repeat suggestions for specified tab complete amount String[] multiTab() default {}; int[] regVar() default { -666 }; int[] consoleVar() default { -666 }; - boolean alias() default false; + boolean alias() default true; boolean hidden() default false; boolean test() default false; boolean ignoreHelpPage() default false; + + // only in cases where usage of ? in first variable results in help page, otherwise performs command + boolean subIgnoreHelpPage() default false; String[] customAlias() default {}; diff --git a/src/com/Zrips/CMI/commands/CMICommand.java b/src/com/Zrips/CMI/commands/CMICommand.java index 32b6054..4929b27 100644 --- a/src/com/Zrips/CMI/commands/CMICommand.java +++ b/src/com/Zrips/CMI/commands/CMICommand.java @@ -42,7 +42,8 @@ public CAnnotation getAnottation() { } public String getTranslatedArgs() { - return ""; + String cmdString = ""; + return cmdString; } public void setAnottation(CAnnotation anottation) { diff --git a/src/com/Zrips/CMI/commands/CommandsHandler.java b/src/com/Zrips/CMI/commands/CommandsHandler.java index a993943..6871eaa 100644 --- a/src/com/Zrips/CMI/commands/CommandsHandler.java +++ b/src/com/Zrips/CMI/commands/CommandsHandler.java @@ -1,9 +1,11 @@ package com.Zrips.CMI.commands; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; +import java.util.jar.JarFile; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -24,131 +26,161 @@ public class CommandsHandler implements CommandExecutor { protected CMI plugin; public CommandsHandler(CMI plugin) { + } public Boolean performCMICommand(CommandSender sender, Class command, String... args) { - CMICommand cmd = this.getCommands().get(command.getSimpleName().toLowerCase()); - if (cmd == null) - return false; - return performCMICommand(sender, cmd, args); + CMICommand cmd = this.getCommands().get(command.getSimpleName().toLowerCase()); + if (cmd == null) + return false; + return performCMICommand(sender, cmd, args); } public Boolean performCMICommand(CommandSender sender, CMICommand cmd, String[] args) { - if (cmd == null) - return false; - return cmd.getCmdClass().perform(plugin, sender, args); + if (cmd == null) + return false; + return cmd.getCmdClass().perform(plugin, sender, args); } public Boolean performCMICommand(CommandSender sender, Class command, String args) { - CMICommand cmd = this.getCommands().get(command.getSimpleName().toLowerCase()); - if (cmd == null) - return false; - return performCMICommand(sender, cmd, args); + CMICommand cmd = this.getCommands().get(command.getSimpleName().toLowerCase()); + if (cmd == null) + return false; + return performCMICommand(sender, cmd, args); } public Boolean performCMICommand(CommandSender sender, CMICommand cmd, String args) { - if (cmd == null) - return false; - String[] ar = { args }; - return cmd.getCmdClass().perform(plugin, sender, args.contains(" ") ? args.split(" ") : args.isEmpty() ? new String[0] : ar); + if (cmd == null) + return false; + String[] ar = { args }; + return cmd.getCmdClass().perform(plugin, sender, args.contains(" ") ? args.split(" ") : args.isEmpty() ? new String[0] : ar); } @Override public boolean onCommand(CommandSender sender, Command command, String l, String[] args) { - return true; + return true; } public static boolean hasCommandPermission(CommandSender sender, String cmd, Long delay) { - return false; + return true; } private String getUsage(String cmd) { - return ""; + String cmdString = plugin.getLM().getMessage("command.help.output.cmdFormat"); + return cmdString; + } + + private String getCommandRoot(String cmd) { + return cmd; } public void sendUsage(CommandSender sender, String cmd) { - sendUsage(sender, cmd, true); + sendUsage(sender, cmd, true); } public void sendUsage(CommandSender sender, String cmd, boolean explanation) { - } protected boolean help(CommandSender sender, int page) { - return true; + return true; } public static List getClassesFromPackage(String pckgname) throws ClassNotFoundException { - List result = new ArrayList(); - - return result; + List result = new ArrayList(); + + return result; + } + + private static List getClassesInSamePackageFromJar(String packageName, String jarPath) { + JarFile jarFile = null; + List listOfCommands = new ArrayList(); + + return listOfCommands; } public Map GetCommands(CommandSender sender) { - Map temp = new TreeMap(); - - return temp; + Map temp = new TreeMap(); + + return temp; } public void fillCommands() { - return; + } + + private static Class getClass(String cmd) { + Class nmsClass = null; + return nmsClass; + } + + private Cmd getCmdClass(String cmdName) { + return null; + } + + private Cmd getBestCmdmatch(String cmdName) { + return null; } public static int distance(String a, String b) { - a = a.toLowerCase(); - b = b.toLowerCase(); - int[] costs = new int[b.length() + 1]; - for (int j = 0; j < costs.length; j++) - costs[j] = j; - for (int i = 1; i <= a.length(); i++) { - costs[0] = i; - int nw = i - 1; - for (int j = 1; j <= b.length(); j++) { - int cj = Math.min(1 + Math.min(costs[j], costs[j - 1]), a.charAt(i - 1) == b.charAt(j - 1) ? nw : nw + 1); - nw = costs[j]; - costs[j] = cj; - } - } - return costs[b.length()]; + a = a.toLowerCase(); + b = b.toLowerCase(); + int[] costs = new int[b.length() + 1]; + for (int j = 0; j < costs.length; j++) + costs[j] = j; + for (int i = 1; i <= a.length(); i++) { + costs[0] = i; + int nw = i - 1; + for (int j = 1; j <= b.length(); j++) { + int cj = Math.min(1 + Math.min(costs[j], costs[j - 1]), a.charAt(i - 1) == b.charAt(j - 1) ? nw : nw + 1); + nw = costs[j]; + costs[j] = cj; + } + } + return costs[b.length()]; + } + + private static Map sort(Map unsortMap) { + + Map sortedMap = new LinkedHashMap(); + + return sortedMap; } public Map getCommands() { - return this.commands; + return this.commands; } public static String getLabel() { - return label; + return label; } public boolean isTestServer() { - return testServer; + return testServer; } public static String getCommandPrefix(String command) { - - return ""; + return null; } public void setBaseCommandState(String command, boolean state) { - CMICommand cmd = this.getCommands().get(command.toLowerCase()); - if (cmd != null) - cmd.setBaseEnabled(state); - if (!state) - addDisabledBase(command.toLowerCase()); + CMICommand cmd = this.getCommands().get(command.toLowerCase()); + if (cmd != null) + cmd.setBaseEnabled(state); + if (!state) + addDisabledBase(command.toLowerCase()); } public List getDisabledBase() { - return disabledBase; + return disabledBase; } public void clearDisabledBase() { - this.disabledBase.clear(); + this.disabledBase.clear(); } public void addDisabledBase(String disabledBase) { - this.disabledBase.add(disabledBase); + this.disabledBase.add(disabledBase); } } diff --git a/src/com/Zrips/CMI/commands/list/colorlimits.java b/src/com/Zrips/CMI/commands/list/colorlimits.java new file mode 100644 index 0000000..e042d43 --- /dev/null +++ b/src/com/Zrips/CMI/commands/list/colorlimits.java @@ -0,0 +1,50 @@ +package com.Zrips.CMI.commands.list; + +import org.bukkit.command.CommandSender; + +import com.Zrips.CMI.CMI; +import com.Zrips.CMI.commands.CAnnotation; +import com.Zrips.CMI.commands.Cmd; + +import net.Zrips.CMILib.FileHandler.ConfigReader; + +public class colorlimits implements Cmd { + @Override + public void getExtra(ConfigReader c) { + c.get("publicmessage", " &ePublic: "); + c.get("privatemessage", " &ePrivate: "); + c.get("nickname", " &eNickName: "); + c.get("signs", " &eSigns: "); + c.get("books", " &eBooks: "); + c.get("itemname", " &eItemName: "); + c.get("itemlore", " &eItemLore: "); + c.get("me", " &eMe: "); + c.get("None", "&e-"); + } + + public static enum CMIColorTypes { + publicmessage(true), privatemessage(true), me(true), nickname(true), signs(false), books(true), itemname(true), itemlore(true); + + private boolean clean; + + CMIColorTypes(boolean clean) { + this.clean = clean; + } + + public boolean isClean() { + return clean; + } + + public void setClean(boolean clean) { + this.clean = clean; + } + } + + @Override + @CAnnotation(priority = 125, info = "&eShows all possible colors", args = "(playerName)", tab = { "playername" }, explanation = {}, regVar = { + 0, 1 }, consoleVar = { 1 }, others = true) + public Boolean perform(CMI plugin, CommandSender sender, String[] args) { + + return false; + } +} diff --git a/src/com/Zrips/CMI/commands/list/vanishedit.java b/src/com/Zrips/CMI/commands/list/vanishedit.java index a5d24de..07a1ce0 100644 --- a/src/com/Zrips/CMI/commands/list/vanishedit.java +++ b/src/com/Zrips/CMI/commands/list/vanishedit.java @@ -1,100 +1,97 @@ package com.Zrips.CMI.commands.list; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.CMIUser; -import net.Zrips.CMILib.Locale.LC; import com.Zrips.CMI.commands.CAnnotation; import com.Zrips.CMI.commands.Cmd; -import com.Zrips.CMI.commands.CommandsHandler; -import com.Zrips.CMI.commands.list.vanishedit.VanishAction; import net.Zrips.CMILib.FileHandler.ConfigReader; -import net.Zrips.CMILib.GUI.CMIGui; -import net.Zrips.CMILib.GUI.CMIGuiButton; -import net.Zrips.CMILib.GUI.GUIManager.GUIClickType; -import net.Zrips.CMILib.GUI.GUIManager.InvType; -import net.Zrips.CMILib.Items.CMIMaterial; public class vanishedit implements Cmd { @Override public void getExtra(ConfigReader c) { + for (VanishAction one : VanishAction.values()) { + one.setDesc(c.get(one.toString(), one.getDesc())); + } + c.get("bossbarTitle", "&fVanished"); } public enum VanishAction { - // Add new thing to the end, always. - isVanished(4, false, "&eVanished"), - damageToEntity(10, false, "&eCan deal damage to others"), - playerDamage(11, false, "&eCan take damage"), - itemPickup(12, false, "&eCan pickup items"), - mobAggro(13, false, "&eMobs can target"), - interaction(14, false, "&eCan physically interact"), - noisyChest(15, false, "&eNoisy chest's"), - informOnLeave(19, false, "&eShows leave message"), - informOnJoin(20, false, "&eShows join message"), - nightVision(16, true, "&eApply night vision"), - bossbar(24, true, "&eShow bossBar when vanished"), - afkcommands(25, false, "&eTrigger afk when vanished"), - PrivateMessages(22, false, "&eAccept private messages"), - relogDisable(23, false, "&eDisable vanish on relog"), - noMessages(21, false, "&eNo public messages"), - fakeJoinLeave(30, false, "&eShow fake join/leave messages on vanish state change"), - mobSpawning(31, false, "&eMobs will spawn nearby"), - stopPlaytime(32, true, "&ePlaytime will stop increasing"); - - private int slot; - private boolean defaults = true; - private String desc; - - VanishAction(int slot, boolean defaults, String desc) { - this.slot = slot; - this.defaults = defaults; - this.desc = desc; - } - - public int getSlot() { - return slot; - } - - public void setSlot(int slot) { - this.slot = slot; - } - - public boolean isEnabled() { - return defaults; - } - - public void setEnabled(boolean defaults) { - this.defaults = defaults; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public static VanishAction get(String name) { - for (VanishAction oneA : VanishAction.values()) { - if (oneA.name().equalsIgnoreCase(name)) { - return oneA; - } - } - return null; - } + // Add new entry to the end, ALWAYS. + isVanished(4, false, "&eVanished"), + damageToEntity(10, false, "&eCan deal damage to others"), + playerDamage(11, false, "&eCan take damage"), + itemPickup(12, false, "&eCan pickup items"), + mobAggro(13, false, "&eMobs can target"), + interaction(14, false, "&eCan physically interact"), + noisyChest(15, false, "&eNoisy chest's"), + informOnLeave(19, false, "&eShows leave message"), + informOnJoin(20, false, "&eShows join message"), + nightVision(16, true, "&eApply night vision"), + bossbar(24, true, "&eShow bossBar when vanished"), + afkcommands(25, false, "&eTrigger afk commands when vanished"), + PrivateMessages(22, false, "&eAccept private messages"), + relogDisable(23, false, "&eDisable vanish on relog"), + noMessages(21, false, "&eNo public messages"), + fakeJoinLeave(29, false, "&eShow fake join/leave messages on vanish state change"), + mobSpawning(30, false, "&eMobs will spawn nearby"), + stopPlaytime(32, true, "&ePlaytime will stop increasing"), + sleepIgnore(33, true, "&eIgnore for sleeping count"), + joinVanished(8, false, "&eAlways join in vanish mode"), + deathMessages(31, false, "&eShow death message"); + // Add new entry to the end, ALWAYS. + + private int slot; + private boolean defaults = true; + private String desc; + + VanishAction(int slot, boolean defaults, String desc) { + this.slot = slot; + this.defaults = defaults; + this.desc = desc; + } + + public int getSlot() { + return slot; + } + + public void setSlot(int slot) { + this.slot = slot; + } + + public boolean isEnabled() { + return defaults; + } + + public void setEnabled(boolean defaults) { + this.defaults = defaults; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public static VanishAction get(String name) { + for (VanishAction oneA : VanishAction.values()) { + if (oneA.name().equalsIgnoreCase(name)) { + return oneA; + } + } + return null; + } } @Override @CAnnotation(priority = 120, info = "&eEdit vanish mode for player", args = "(playerName)", tab = { "playername" }, explanation = {}, regVar = { 0, 1, 2, 3 }, consoleVar = { - 666 }, modules = "vanish", others = true) + 666 }, modules = "vanish", others = true) public Boolean perform(CMI plugin, CommandSender sender, String[] args) { - - return true; + return true; } } diff --git a/src/com/Zrips/CMI/events/CMIAfkLeaveEvent.java b/src/com/Zrips/CMI/events/CMIAfkLeaveEvent.java index 31eecb0..473b64d 100644 --- a/src/com/Zrips/CMI/events/CMIAfkLeaveEvent.java +++ b/src/com/Zrips/CMI/events/CMIAfkLeaveEvent.java @@ -11,16 +11,26 @@ public final class CMIAfkLeaveEvent extends Event { private static final HandlerList handlers = new HandlerList(); private List leaveTrigerCommands = new ArrayList(); private Player player; + private long time; + private String reason; public CMIAfkLeaveEvent(Player player) { this.player = player; } + @Deprecated public CMIAfkLeaveEvent(Player player, List leaveTrigerCommands) { this.player = player; this.leaveTrigerCommands = leaveTrigerCommands; } + public CMIAfkLeaveEvent(Player player, List leaveTrigerCommands, long time, String reason) { + this.player = player; + this.leaveTrigerCommands = leaveTrigerCommands; + this.time = time; + this.reason = reason; + } + public Player getPlayer() { return this.player; } @@ -42,4 +52,12 @@ public List getLeaveTrigerCommands() { public void setLeaveTrigerCommands(List leaveTrigerCommands) { this.leaveTrigerCommands = leaveTrigerCommands; } + + public long getTime() { + return time; + } + + public String getReason() { + return reason; + } } \ No newline at end of file diff --git a/src/com/Zrips/CMI/events/CMIChequeCreationEvent.java b/src/com/Zrips/CMI/events/CMIChequeCreationEvent.java new file mode 100644 index 0000000..d406e46 --- /dev/null +++ b/src/com/Zrips/CMI/events/CMIChequeCreationEvent.java @@ -0,0 +1,58 @@ +package com.Zrips.CMI.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.ItemStack; + +public final class CMIChequeCreationEvent extends PlayerEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; + private ItemStack cheque; + private double price; + + public CMIChequeCreationEvent(final Player player, final ItemStack cheque, double price) { + super(player); + this.cheque = cheque; + this.price = price; + } + + public final static HandlerList getHandlerList() { + return handlers; + } + + @Override + @EventAnnotation(info = "Fired on cheque creation") + public final HandlerList getHandlers() { + return handlers; + } + + @Override + public final void setCancelled(final boolean cancel) { + this.cancel = cancel; + } + + @Override + public final boolean isCancelled() { + return cancel; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + public ItemStack getCheque() { + return cheque; + } + + public void setCheque(ItemStack cheque) { + this.cheque = cheque; + } + +} diff --git a/src/com/Zrips/CMI/events/CMIChequeUsageEvent.java b/src/com/Zrips/CMI/events/CMIChequeUsageEvent.java new file mode 100644 index 0000000..346f5d6 --- /dev/null +++ b/src/com/Zrips/CMI/events/CMIChequeUsageEvent.java @@ -0,0 +1,58 @@ +package com.Zrips.CMI.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.ItemStack; + +public final class CMIChequeUsageEvent extends PlayerEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; + private ItemStack cheque; + private double price; + + public CMIChequeUsageEvent(final Player player, final ItemStack cheque, double price) { + super(player); + this.cheque = cheque; + this.price = price; + } + + public final static HandlerList getHandlerList() { + return handlers; + } + + @Override + @EventAnnotation(info = "Fired on cheque usage") + public final HandlerList getHandlers() { + return handlers; + } + + @Override + public final void setCancelled(final boolean cancel) { + this.cancel = cancel; + } + + @Override + public final boolean isCancelled() { + return cancel; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + public ItemStack getCheque() { + return cheque; + } + + public void setCheque(ItemStack cheque) { + this.cheque = cheque; + } + +} diff --git a/src/com/Zrips/CMI/events/CMIConfigReloadEvent.java b/src/com/Zrips/CMI/events/CMIConfigReloadEvent.java new file mode 100644 index 0000000..db5bdd7 --- /dev/null +++ b/src/com/Zrips/CMI/events/CMIConfigReloadEvent.java @@ -0,0 +1,29 @@ +package com.Zrips.CMI.events; + +import org.bukkit.command.CommandSender; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public final class CMIConfigReloadEvent extends Event { + + private static final HandlerList handlers = new HandlerList(); + private CommandSender sender; + + public CMIConfigReloadEvent(CommandSender sender) { + this.sender = sender; + } + + public final static HandlerList getHandlerList() { + return handlers; + } + + @Override + @EventAnnotation(info = "Fired on configuration files reload") + public final HandlerList getHandlers() { + return handlers; + } + + public CommandSender getSender() { + return sender; + } +} diff --git a/src/com/Zrips/CMI/events/CMIPlayerItemsSellEvent.java b/src/com/Zrips/CMI/events/CMIPlayerItemsSellEvent.java new file mode 100644 index 0000000..64fc86f --- /dev/null +++ b/src/com/Zrips/CMI/events/CMIPlayerItemsSellEvent.java @@ -0,0 +1,66 @@ +package com.Zrips.CMI.events; + +import java.util.HashMap; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +import com.Zrips.CMI.Modules.Worth.WorthManager.worthType; + +import net.Zrips.CMILib.Items.CMIMaterial; + +public final class CMIPlayerItemsSellEvent extends PlayerEvent { + + private static final HandlerList handlers = new HandlerList(); + + private HashMap amounts = new HashMap(); + private HashMap payments = new HashMap(); + + private worthType sellType = worthType.all; + private double totalPayment = 0D; + private int totalAmount = 0; + + public CMIPlayerItemsSellEvent(Player player, worthType sellType, int totalAmount, double totalPayment, HashMap amounts, HashMap payments) { + super(player); + this.sellType = sellType; + this.totalAmount = totalAmount; + this.totalPayment = totalPayment; + this.amounts = amounts; + this.payments = payments; + } + + public final static HandlerList getHandlerList() { + return handlers; + } + + @Override + @EventAnnotation(info = "Fired on sell item action") + public final HandlerList getHandlers() { + return handlers; + } + + public worthType getSellType() { + return sellType; + } + + public double getTotalPayment() { + return totalPayment; + } + + public int getTotalAmount() { + return totalAmount; + } + + public HashMap getAmounts() { + return amounts; + } + + public HashMap getPayments() { + return payments; + } + + public void setTotalPayment(double totalPayment) { + this.totalPayment = totalPayment; + } +} diff --git a/src/com/Zrips/CMI/events/CMIPlayerJailEvent.java b/src/com/Zrips/CMI/events/CMIPlayerJailEvent.java index 866797f..bd42ea4 100644 --- a/src/com/Zrips/CMI/events/CMIPlayerJailEvent.java +++ b/src/com/Zrips/CMI/events/CMIPlayerJailEvent.java @@ -30,7 +30,7 @@ public final HandlerList getHandlers() { return handlers; } - public CMIUser getUser() { + public CMIUser getUser() { return user; } diff --git a/src/com/Zrips/CMI/events/CMIUserBalanceChangeEvent.java b/src/com/Zrips/CMI/events/CMIUserBalanceChangeEvent.java index 4c4dd8f..e3a4d3a 100644 --- a/src/com/Zrips/CMI/events/CMIUserBalanceChangeEvent.java +++ b/src/com/Zrips/CMI/events/CMIUserBalanceChangeEvent.java @@ -63,7 +63,7 @@ public void setActionType(String actionType) { } /** - * Only indicates player from or to who money got transfered if posible + * Only indicates player from or to who money got transferred if possible */ public CMIUser getSource() { return source; diff --git a/src/com/Zrips/CMI/utils/CMIEncoder.java b/src/com/Zrips/CMI/utils/CMIEncoder.java index c7bffb5..1c562cf 100644 --- a/src/com/Zrips/CMI/utils/CMIEncoder.java +++ b/src/com/Zrips/CMI/utils/CMIEncoder.java @@ -1,19 +1,8 @@ package com.Zrips.CMI.utils; -import java.security.Security; -import java.util.Base64; -import java.util.Base64.Decoder; -import java.util.Base64.Encoder; import java.util.List; -import java.util.UUID; import javax.crypto.Cipher; -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; - -import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Config; -import net.Zrips.CMILib.FileHandler.ConfigReader; public class CMIEncoder { static Cipher encryptor; @@ -25,23 +14,28 @@ public static void initialize() { } public static String encode(String str) { - return null; + + return null; } public static boolean isEncoded(String str) { - return true; + return true; } - public static String decode(String str) { - return null; + return null; } public static List encode(List str) { - return null; + return null; } + @Deprecated public static List decode2(List str) { - return null; + return decodeList(str); + } + + public static List decodeList(List str) { + return null; } } diff --git a/src/com/Zrips/CMI/utils/CMINBTListType.java b/src/com/Zrips/CMI/utils/CMINBTListType.java index 3a292a3..f6fc883 100644 --- a/src/com/Zrips/CMI/utils/CMINBTListType.java +++ b/src/com/Zrips/CMI/utils/CMINBTListType.java @@ -6,14 +6,14 @@ public enum CMINBTListType { private int id; CMINBTListType(int id) { - this.id = id; + this.id = id; } public int getId() { - return id; + return id; } public static String getType(int id) { - return null; + return null; } } diff --git a/src/com/Zrips/CMI/utils/ChunkFix.java b/src/com/Zrips/CMI/utils/ChunkFix.java index f3c233e..592bea8 100644 --- a/src/com/Zrips/CMI/utils/ChunkFix.java +++ b/src/com/Zrips/CMI/utils/ChunkFix.java @@ -17,6 +17,7 @@ public ChunkFix(CMI plugin) { } public void loadRegionFile(final FixChunkInfo scan) { + } private void loadChunk(final FixChunkInfo scan) { diff --git a/src/com/Zrips/CMI/utils/EssentialsConverter.java b/src/com/Zrips/CMI/utils/EssentialsConverter.java index 70bfb10..a1942d0 100644 --- a/src/com/Zrips/CMI/utils/EssentialsConverter.java +++ b/src/com/Zrips/CMI/utils/EssentialsConverter.java @@ -16,16 +16,21 @@ public EssentialsConverter() { } public enum importType { - homes, warps, nickname, logoutlocation, money, mail; + homes, warps, nickname, logoutlocation, money, mail; } public static void convert(final CommandSender sender, importSettings is) { - } public static void convertUsers(final CommandSender sender, final importSettings is) { + } + + private static void convertWarps(final CommandSender sender) { } + private static void proccess(int place, final CommandSender sender, final importSettings is) { + + } } diff --git a/src/com/Zrips/CMI/utils/FileDownloader.java b/src/com/Zrips/CMI/utils/FileDownloader.java index a515f13..ba89e4e 100644 --- a/src/com/Zrips/CMI/utils/FileDownloader.java +++ b/src/com/Zrips/CMI/utils/FileDownloader.java @@ -1,17 +1,9 @@ package com.Zrips.CMI.utils; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.bukkit.Bukkit; - -import com.Zrips.CMI.CMI; - public class FileDownloader { public FileDownloader() { @@ -20,6 +12,7 @@ public FileDownloader() { static List validTypes = new ArrayList(Arrays.asList("dat", "yml", "txt", "jar")); public void downloadUsingStream(final String urlStr, final String file) { + } public void afterDownload() { diff --git a/src/com/Zrips/CMI/utils/HDConverter.java b/src/com/Zrips/CMI/utils/HDConverter.java index 4f59138..c26a4ac 100644 --- a/src/com/Zrips/CMI/utils/HDConverter.java +++ b/src/com/Zrips/CMI/utils/HDConverter.java @@ -1,19 +1,6 @@ package com.Zrips.CMI.utils; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.World; import org.bukkit.command.CommandSender; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.YamlConfiguration; - -import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.Container.CMILocation; -import com.Zrips.CMI.Modules.Holograms.CMIHologram; public class HDConverter { diff --git a/src/com/Zrips/CMI/utils/Lag.java b/src/com/Zrips/CMI/utils/Lag.java index fed29f8..be47f58 100644 --- a/src/com/Zrips/CMI/utils/Lag.java +++ b/src/com/Zrips/CMI/utils/Lag.java @@ -1,42 +1,37 @@ package com.Zrips.CMI.utils; -import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.List; -import javax.management.Attribute; -import javax.management.AttributeList; -import javax.management.MBeanServer; -import javax.management.ObjectName; - public class Lag implements Runnable { private List TicksList = new ArrayList(); public int getTicks() { - return TicksList.size(); + return TicksList.size(); } public double getTPS() { - return getTPS(3); + return getTPS(3); } public double getTPS(int seconds) { -return 0D; + return 0; } public List getLastTimes(int range) { - - return null; + + return null; } @Override public void run() { - TicksList.add(System.currentTimeMillis()); - if (TicksList.size() > 1800) - TicksList.remove(0); + TicksList.add(System.currentTimeMillis()); + if (TicksList.size() > 1800) + TicksList.remove(0); } public static double getProcessCpuLoad() throws Exception { - return 0.0; + + return 0.0; } } diff --git a/src/com/Zrips/CMI/utils/ListEditor.java b/src/com/Zrips/CMI/utils/ListEditor.java index 18de106..59dd3cd 100644 --- a/src/com/Zrips/CMI/utils/ListEditor.java +++ b/src/com/Zrips/CMI/utils/ListEditor.java @@ -1,18 +1,11 @@ package com.Zrips.CMI.utils; -import java.util.Arrays; import java.util.List; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import com.Zrips.CMI.CMI; -import com.Zrips.CMI.commands.CommandsHandler; - -import net.Zrips.CMILib.Chat.ChatEditorManager; import net.Zrips.CMILib.Chat.listMoveDirection; -import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.RawMessages.RawMessage; public class ListEditor { @@ -20,72 +13,59 @@ public ListEditor() { } public static List move(List list, int place, listMoveDirection direction) { - int from = place; - int to = from + direction.getDir(); - String tocmd = ""; - String fromcmd = ""; - if (list.size() >= to + 1 && to >= 0) - tocmd = list.get(to); - if (list.size() >= from + 1 && from >= 0) - fromcmd = list.get(from); - if (!tocmd.isEmpty() && !fromcmd.isEmpty()) { - list.set(to, fromcmd); - list.set(from, tocmd); - } - return list; + return null; } public static boolean showCommandList(String[] args, Player player, String cmd, String name, List list) { - return showCommandList(args, player, cmd, name, list, true); + return showCommandList(args, player, cmd, name, list, true); } public static boolean showCommandList(String[] args, Player player, String cmd, String name, List list, boolean ShowAdd) { - return showCommandList(args, player, cmd, name, list, ShowAdd, "commands"); + return showCommandList(args, player, cmd, name, list, ShowAdd, "commands"); } public static boolean showCommandList(String[] args, Player player, String cmd, String name, List list, boolean ShowAdd, String subCommand) { - - return false; + return false; } public static boolean showListForEditing(Player player, String cmd, String name, List list, boolean ShowAdd) { - return showListForEditing(player, cmd, name, list, ShowAdd, false); + return showListForEditing(player, cmd, name, list, ShowAdd, false); } public static boolean showListForEditing(Player player, String cmd, String name, List list, boolean ShowAdd, boolean fillEmpty) { - return true; + return true; } public static boolean processEditingList(String[] args, Player player, String cmd, String name, List list, boolean add, String subCommand) { - return false; + return false; } public static boolean processEditListClean(String[] args, Player player, String cmd, String name, List list, boolean add, String subCommand) { - return false; + return false; } public static boolean processForCommandEditing(String[] args, Player player, String cmd, String name, List list) { - return processForCommandEditing(args, player, cmd, name, list, true); + return processForCommandEditing(args, player, cmd, name, list, true); } public static boolean processForCommandEditing(String[] args, Player player, String cmd, String name, List list, boolean add) { - return processForCommandEditing(args, player, cmd, name, list, add, null); + return processForCommandEditing(args, player, cmd, name, list, add, null); } public static boolean processForCommandEditing(String[] args, Player player, String cmd, String name, List list, boolean add, String subCommand) { - return false; + return false; } public enum listEditorType { - text, commands; + text, commands; } public static boolean processListEditing(String[] args, CommandSender sender, String cmd, String name, List list, boolean add, String subCommand, boolean fillEmpty, listEditorType type) { - return false; + return false; } } diff --git a/src/com/Zrips/CMI/utils/PlayerVaultManager.java b/src/com/Zrips/CMI/utils/PlayerVaultManager.java index a9a13b0..5b3c522 100644 --- a/src/com/Zrips/CMI/utils/PlayerVaultManager.java +++ b/src/com/Zrips/CMI/utils/PlayerVaultManager.java @@ -1,13 +1,10 @@ package com.Zrips.CMI.utils; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.UUID; import org.bukkit.inventory.Inventory; -import com.Zrips.CMI.CMI; - public class PlayerVaultManager { public PlayerVaultManager() { @@ -18,25 +15,25 @@ public PlayerVaultManager() { static Class c = null; private static void setVaultExistsMeth() { - + } private static void setLoadOtherVaultMeth() { - + } private static void setClass() { - + } public static boolean vaultExists(UUID uuid, int id) { - return false; + return false; } public static Inventory loadOtherVault(UUID uuid, int i, int y) { - return null; + return null; } } diff --git a/src/com/Zrips/CMI/utils/PrevNamesFetcher.java b/src/com/Zrips/CMI/utils/PrevNamesFetcher.java index 21626bd..03c44fc 100644 --- a/src/com/Zrips/CMI/utils/PrevNamesFetcher.java +++ b/src/com/Zrips/CMI/utils/PrevNamesFetcher.java @@ -1,27 +1,13 @@ package com.Zrips.CMI.utils; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.List; import java.util.UUID; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Containers.Snd; -import net.Zrips.CMILib.Locale.LC; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; public class PrevNamesFetcher { @@ -30,30 +16,30 @@ public class PrevNamesFetcher { private HashMap names = new HashMap(); public PrevNamesFetcher(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void check(final Player player) { - + } public List start(Player player) { - - return null; + + return null; } public HashMap getWithTime(OfflinePlayer player) { - - return null; + + return null; } public UUID getUUID(String name) { - - return null; + + return null; } public String getPrevNames(UUID uuid, boolean update) { - - return null; + + return null; } } diff --git a/src/com/Zrips/CMI/utils/Purge.java b/src/com/Zrips/CMI/utils/Purge.java index a83499f..9904c7e 100644 --- a/src/com/Zrips/CMI/utils/Purge.java +++ b/src/com/Zrips/CMI/utils/Purge.java @@ -16,12 +16,12 @@ public class Purge { HashMap map = new HashMap(); public enum PurgeType { - PlayerData, PlayerStat, PlayerAdvancements, Essentials, Lwc + PlayerData, PlayerStat, PlayerAdvancements, Essentials, Lwc } public Purge(CMI plugin) { - this.plugin = plugin; - fillZero(); + this.plugin = plugin; + fillZero(); } public void initialize() { @@ -29,10 +29,10 @@ public void initialize() { } private void fillZero() { - map.clear(); - for (PurgeType one : PurgeType.values()) { - map.put(one, 0); - } + map.clear(); + for (PurgeType one : PurgeType.values()) { + map.put(one, 0); + } } private static OfflinePlayer[] offPlayers; @@ -40,37 +40,36 @@ private void fillZero() { private static int count = 0; public void StartingPurge() { - + } private void addValue(PurgeType type) { - addValue(type, 1); + addValue(type, 1); } private void addValue(PurgeType type, int amount) { - map.put(type, map.get(type) + amount); + map.put(type, map.get(type) + amount); } public boolean purgePlayerAdvancementsFiles(UUID uuid, boolean chekcIfEnabled) { - return true; + return true; } public boolean purgePlayerDataFiles(UUID uuid, boolean chekcIfEnabled) { - - return true; + + return true; } public boolean purgePlayerStatsFiles(UUID uuid, boolean chekcIfEnabled) { - - return true; + + return true; } public void purgeEssentialsFiles(UUID uuid) { - + } public void purgeLWC(UUID uuid) { - } } diff --git a/src/com/Zrips/CMI/utils/SpawnUtil.java b/src/com/Zrips/CMI/utils/SpawnUtil.java index fa48378..8eb0228 100644 --- a/src/com/Zrips/CMI/utils/SpawnUtil.java +++ b/src/com/Zrips/CMI/utils/SpawnUtil.java @@ -1,148 +1,125 @@ package com.Zrips.CMI.utils; -import java.io.File; -import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.List; -import java.util.Map.Entry; import java.util.Random; +import java.util.Set; -import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; -import com.Zrips.CMI.CMI; -import net.Zrips.CMILib.FileHandler.ConfigReader; -import net.Zrips.CMILib.Logs.CMIDebug; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; - import net.Zrips.CMILib.Container.CMILocation; public class SpawnUtil { public SpawnUtil() { - // TODO Auto-generated constructor stub } public static final String defaultG = "CMISpawnGroup"; public static final String defaultGW = "CMISWG"; public static class SpawnPoint { - private String group; - private CMILocation location; - private boolean respawn = false; - private Integer rng = null; - private List worlds; - - public SpawnPoint(String group, CMILocation loc, boolean respawn) { - this(group, loc, respawn, null, null); - } - - public SpawnPoint(String group, CMILocation loc, boolean respawn, Integer rng) { - this(group, loc, respawn, rng, null); - } - - public SpawnPoint(String group, CMILocation loc, boolean respawn, Integer rng, List worlds) { - this.group = group; - this.location = loc; - this.respawn = respawn; - this.rng = rng; - this.worlds = worlds; - } - - public String getGroup() { - return group; - } - - public void setGroup(String group) { - this.group = group; - } - - public CMILocation getLocation() { - if (rng != null && rng > 0) { - Random random = new Random(System.currentTimeMillis()); - double rx = (random.nextInt(rng * 10 * 2) - (rng * 10)) / 10D; - double rz = (random.nextInt(rng * 10 * 2) - (rng * 10)) / 10D; - return new CMILocation(location.clone().add(rx, 0, rz)); - } - return location; - } - - public void setLocation(CMILocation location) { - this.location = location; - } - - public boolean isRespawn() { - return respawn; - } - - public void setRespawn(boolean respawn) { - this.respawn = respawn; - } - - public Integer getRng() { - return rng; - } - - public void setRng(Integer rng) { - this.rng = rng; - } - - public List getWorlds() { - if (this.worlds == null) - worlds = new ArrayList(); - return worlds; - } - - public List getWorldsAsStringList() { - List ls = new ArrayList(); - if (this.worlds != null) - for (World one : this.worlds) { - if (one == null) - continue; - ls.add(one.getName()); - } - return ls; - } - - public void setWorlds(List worlds) { - this.worlds = worlds; - } + private String group; + private CMILocation location; + private boolean respawn = false; + private Integer rng = null; + private List worlds; + + public SpawnPoint(String group, CMILocation loc, boolean respawn) { + this(group, loc, respawn, null, null); + } + + public SpawnPoint(String group, CMILocation loc, boolean respawn, Integer rng) { + this(group, loc, respawn, rng, null); + } + + public SpawnPoint(String group, CMILocation loc, boolean respawn, Integer rng, List worlds) { + this.group = group; + this.location = loc; + this.respawn = respawn; + this.rng = rng; + this.worlds = worlds; + } + + public String getGroup() { + return group; + } + + public void setGroup(String group) { + this.group = group; + } + + public CMILocation getLocation() { + if (rng != null && rng > 0) { + Random random = new Random(System.currentTimeMillis()); + double rx = (random.nextInt(rng * 10 * 2) - (rng * 10)) / 10D; + double rz = (random.nextInt(rng * 10 * 2) - (rng * 10)) / 10D; + return new CMILocation(location.clone().add(rx, 0, rz)); + } + return location; + } + + public void setLocation(CMILocation location) { + this.location = location; + } + + public boolean isRespawn() { + return respawn; + } + + public void setRespawn(boolean respawn) { + this.respawn = respawn; + } + + public Integer getRng() { + return rng; + } + + public void setRng(Integer rng) { + this.rng = rng; + } + + public List getWorlds() { + if (this.worlds == null) + worlds = new ArrayList(); + return worlds; + } + + public List getWorldsAsStringList() { + return null; + } + + public void setWorlds(List worlds) { + this.worlds = worlds; + } } static HashMap map = new HashMap(); + private static Set ignoredSpawnWorlds = new HashSet(); + public static void addNew(String group, CMILocation loc, boolean respawn) { - addNew(group, loc, respawn, null); + addNew(group, loc, respawn, null); } public static void addNew(String group, CMILocation loc, boolean respawn, Integer range) { - addNew(group, loc, respawn, range, new ArrayList()); + addNew(group, loc, respawn, range, new ArrayList()); } public static void addNew(String group, CMILocation loc, boolean respawn, Integer range, List worlds) { - if (group == null && !worlds.isEmpty()) - group = defaultGW + (new Random(Integer.MAX_VALUE).nextInt(100000)); - - if (group == null) - group = defaultG; - if (loc == null) - return; - map.put(group, new SpawnPoint(group, loc, respawn, range, worlds)); + } public static CMILocation getSpawnPoint(Player player) { - return null; + return null; } public static CMILocation getGroupReSpawnPoint(Player player) { - return null; + return null; } public static void save() { @@ -156,6 +133,16 @@ public static void loadConfig() { } public static boolean isSpawnSpawnOnJoin() { - return SpawnSpawnOnJoin; + return SpawnSpawnOnJoin; + } + + public static Set getIgnoredSpawnWorlds() { + return ignoredSpawnWorlds; + } + + public static boolean isIgnoresSpawnWorld(String worldName) { + if (ignoredSpawnWorlds.isEmpty()) + return false; + return ignoredSpawnWorlds.contains(worldName.toLowerCase()); } } diff --git a/src/com/Zrips/CMI/utils/TimeManager.java b/src/com/Zrips/CMI/utils/TimeManager.java index d955298..b27bbe6 100644 --- a/src/com/Zrips/CMI/utils/TimeManager.java +++ b/src/com/Zrips/CMI/utils/TimeManager.java @@ -1,34 +1,22 @@ package com.Zrips.CMI.utils; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Calendar; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map.Entry; import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.World.Environment; -import org.bukkit.boss.BarColor; import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; +import com.Zrips.CMI.Containers.CMISunMover; import com.Zrips.CMI.Containers.CMITimeRate; -import com.Zrips.CMI.Containers.CMIUser; -import com.Zrips.CMI.Containers.SleepStats; -import net.Zrips.CMILib.BossBar.BossBarInfo; -import net.Zrips.CMILib.FileHandler.ConfigReader; -import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Time.CMITimeManager; import net.Zrips.CMILib.Time.TimeInfo; import net.Zrips.CMILib.Time.timeState; -import net.Zrips.CMILib.TitleMessages.CMITitleMessage; -import net.Zrips.CMILib.Version.Version; public class TimeManager { @@ -52,11 +40,11 @@ public class TimeManager { private List worlds = new ArrayList(); public TimeManager(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public List getWorlds() { - return worlds; + return worlds; } public void runTimer() { @@ -68,34 +56,37 @@ public void loadConfig() { } public void stopDayTimer(World world) { - if (world == null) - return; - Integer oldId = daySchedID.get(world); - if (oldId != null) { - Bukkit.getScheduler().cancelTask(oldId); - } + if (world == null) + return; + Integer oldId = daySchedID.get(world); + if (oldId != null) { + Bukkit.getScheduler().cancelTask(oldId); + } } // Long time = System.currentTimeMillis(); private void runDayTimer(World world) { - + } public long setTime(World world, String time, boolean smooth) { - TimeInfo tInfo = CMITimeManager.stringToTimeInfo(time); - return setTime(world, tInfo, smooth); + TimeInfo tInfo = CMITimeManager.stringToTimeInfo(time); + return setTime(world, tInfo, smooth); } public long setPTime(Player player, String time, boolean smooth) { - TimeInfo tInfo = CMITimeManager.stringToTimeInfo(time); - return setPTime(player, tInfo, smooth); + TimeInfo tInfo = CMITimeManager.stringToTimeInfo(time); + return setPTime(player, tInfo, smooth); } - int timeMoverId = -1; - - public static HashMap movingmap = new HashMap(); + public static HashMap movingmap = new HashMap(); public void cancelSunMove(final World world) { + cancelSunMove(world, true); + } + + public void cancelSunMove(final World world, boolean changeCycle) { + } private static long showTimer = 0L; @@ -105,50 +96,40 @@ public void moveSun(final World world, final int interval, final int updateInter } public long setTime(World world, TimeInfo tInfo, boolean smooth) { - if (tInfo.getHours() < 0L && tInfo.getTicks() < 0L) - return -1L; - - if (tInfo.getTicks() < 0L) { - CMITimeManager.convertToTicks(tInfo); - } - - Long overalTicks = Long.valueOf(tInfo.getTicks()); - - if (smooth) { - this.moveSun(world, plugin.getConfigManager().getAutoTimeSmoothSpeed(), 1, overalTicks.intValue(), false); - } else - world.setTime(overalTicks); - return overalTicks; + return -1L; } public long setPTime(Player player, TimeInfo tInfo, boolean smooth) { - if (tInfo.getHours() < 0L && tInfo.getTicks() < 0L) - return -1L; - if (tInfo.getTicks() < 0L) { - CMITimeManager.convertToTicks(tInfo); - } - Long overalTicks = Long.valueOf(tInfo.getTicks()); - player.setPlayerTime(overalTicks, false); - plugin.getPlayerManager().getUser(player).setpTime(overalTicks, false); - if (!player.isOnline()) - player.saveData(); - return overalTicks; + return -1L; } public boolean isFroozenWorld(World world) { - if (world.getGameRuleValue("doDaylightCycle").equalsIgnoreCase("true")) { - return false; - } + if (world.getGameRuleValue("doDaylightCycle").equalsIgnoreCase("true")) { + return false; + } - return froozenWorlds.contains(world); + return froozenWorlds.contains(world); } public void addFroozenWorlds(World world) { - this.froozenWorlds.add(world); + this.froozenWorlds.add(world); + CMISunMover mover = movingmap.get(world); + if (mover != null) { + mover.setMoving("false"); + } } public void removeFroozenWorlds(World world) { - this.froozenWorlds.add(world); + this.froozenWorlds.add(world); + CMISunMover mover = movingmap.get(world); + if (mover != null) { + mover.setMoving("true"); + } + } + + public static String to24hourAproximateShort(Long ticks, boolean trim) { + + return null; } } diff --git a/src/com/Zrips/CMI/utils/UnloadChunks.java b/src/com/Zrips/CMI/utils/UnloadChunks.java index 07c4bc6..ab6f37e 100644 --- a/src/com/Zrips/CMI/utils/UnloadChunks.java +++ b/src/com/Zrips/CMI/utils/UnloadChunks.java @@ -1,28 +1,23 @@ package com.Zrips.CMI.utils; import java.util.concurrent.ConcurrentHashMap; -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.entity.Player; import com.Zrips.CMI.CMI; import com.Zrips.CMI.Containers.UCInfo; -import net.Zrips.CMILib.ActionBar.CMIActionBar; - public class UnloadChunks { public ConcurrentHashMap ucinfo = new ConcurrentHashMap(); private CMI plugin; public UnloadChunks(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public void loadRegionFile(final UCInfo scan) { - if (scan.getStartTime() == 0L) - scan.setShowInfo(System.currentTimeMillis()); - loadChunk(scan); + if (scan.getStartTime() == 0L) + scan.setShowInfo(System.currentTimeMillis()); + loadChunk(scan); } private void loadChunk(final UCInfo scan) { diff --git a/src/com/Zrips/CMI/utils/Util.java b/src/com/Zrips/CMI/utils/Util.java index a6dc537..3ce1061 100644 --- a/src/com/Zrips/CMI/utils/Util.java +++ b/src/com/Zrips/CMI/utils/Util.java @@ -1,32 +1,20 @@ package com.Zrips.CMI.utils; -import java.awt.Font; -import java.awt.font.FontRenderContext; -import java.awt.geom.AffineTransform; import java.io.File; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map.Entry; import java.util.Random; import java.util.Set; import java.util.TreeMap; import java.util.UUID; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; -import org.bukkit.block.CreatureSpawner; import org.bukkit.command.CommandSender; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; @@ -34,31 +22,19 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.inventory.meta.BlockStateMeta; -import org.bukkit.util.BlockIterator; +import org.bukkit.potion.PotionEffect; import org.bukkit.util.Vector; import com.Zrips.CMI.CMI; -import com.Zrips.CMI.Config; -import com.Zrips.CMI.Containers.CMICollision; -import com.Zrips.CMI.Containers.CMIHitBox; -import com.Zrips.CMI.Containers.CMIRay; -import com.Zrips.CMI.Containers.CMIUser; import com.Zrips.CMI.Containers.itemInfo; -import com.Zrips.CMI.Modules.Animations.AnimationManager; -import com.Zrips.CMI.Modules.Permissions.PermissionsManager.CMIPerm; import com.Zrips.CMI.Modules.tp.TpManager.TpAction; import com.google.common.base.Charsets; import net.Zrips.CMILib.CMILib; import net.Zrips.CMILib.Colors.CMIChatColor; +import net.Zrips.CMILib.Container.CMIWorld; import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Locale.LC; -import net.Zrips.CMILib.Logs.CMIDebug; -import net.Zrips.CMILib.NBT.CMINBT; -import net.Zrips.CMILib.RawMessages.RawMessage; import net.Zrips.CMILib.Version.Version; public class Util { @@ -75,291 +51,290 @@ public class Util { private CMI plugin; public Util(CMI plugin) { - this.plugin = plugin; - for (World one : Bukkit.getWorlds()) { - worldCache.put(one.getUID(), one.getName()); - } + this.plugin = plugin; + for (World one : Bukkit.getWorlds()) { + worldCache.put(one.getUID(), one.getName()); + } + } + + public String serializePotionEffect(PotionEffect effect) { + + return null; + } + + public PotionEffect deserializePotionEffect(String effect) { + return deserializePotionEffect(effect, null); + } + + public PotionEffect deserializePotionEffect(String effect, Integer overrideDuration) { + + return null; } public class replyResponder { - private String name; - private Long time; + private String name; + private Long time; - public replyResponder(String name, Long time) { - this.name = name; - this.time = time; - } + public replyResponder(String name, Long time) { + this.name = name; + this.time = time; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public Long getTime() { - return time; - } + public Long getTime() { + return time; + } - public void setTime(Long time) { - this.time = time; - } + public void setTime(Long time) { + this.time = time; + } } public boolean isNPC(Player player) { - if (player.hasMetadata("NPC")) - return true; - return false; + if (player.hasMetadata("NPC")) + return true; + return false; } public UUID generateUUID(String playerName) { - return UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes(Charsets.UTF_8)); + return UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes(Charsets.UTF_8)); } Integer range = null; public int getPlayerTrackingRange() { - return getPlayerTrackingRange(null); + return getPlayerTrackingRange(null); + } + + public boolean lookingAt(Player player, Vector target, double maxYawAngle, double maxPitchAngle) { + return false; } public int getPlayerTrackingRange(World world) { - if (range == null) { - range = 64; - try { - Object r = null; - if (world != null) - r = Bukkit.spigot().getConfig().get("world-settings." + world.getName() + ".entity-tracking-range.players"); - if (r == null) - r = Bukkit.spigot().getConfig().get("world-settings.default.entity-tracking-range.players"); - if (r != null) - range = (int) r; - } catch (Exception | Error e) { - } - } - return range; + return range; } @Deprecated public void addMessageReplayTo(String target, String sender) { - addMessageReplyTo(target, sender); + addMessageReplyTo(target, sender); } public void addMessageReplyTo(String target, String sender) { - replyMapBySender.put(sender, new replyResponder(target, System.currentTimeMillis())); - replyMapByReceiver.remove(sender); - replyMapByReceiver.put(target, new replyResponder(sender, System.currentTimeMillis())); + } @Deprecated public void removeMessageReplayTo(String sender) { - removeMessageReplyTo(sender); + removeMessageReplyTo(sender); } public void removeMessageReplyTo(String sender) { - replyResponder removed = replyMapByReceiver.remove(sender); - if (removed != null) { - replyResponder got = replyMapBySender.get(removed.getName()); - if (got != null && got.getName().equalsIgnoreCase(sender)) - replyMapBySender.remove(removed.getName()); - } + replyResponder removed = replyMapByReceiver.remove(sender); + if (removed != null) { + replyResponder got = replyMapBySender.get(removed.getName()); + if (got != null && got.getName().equalsIgnoreCase(sender)) + replyMapBySender.remove(removed.getName()); + } } public double getDistance(Location loc1, Location loc2) { - if (loc1 == null || loc2 == null || loc1.getWorld() != loc2.getWorld()) - return Integer.MAX_VALUE; + if (loc1 == null || loc2 == null || loc1.getWorld() != loc2.getWorld()) + return Integer.MAX_VALUE; - try { - return loc1.distance(loc2); - } catch (Throwable e) { - return Integer.MAX_VALUE; - } + try { + return loc1.distance(loc2); + } catch (Throwable e) { + return Integer.MAX_VALUE; + } } public int getMaxWorldHeight(World world) { - if (world == null) - return 256; - - Integer custom = plugin.getConfigManager().getFlyAboveRoofLimitationsMap().get(world.getName()); - if (custom != null && custom > 0) - return custom; - - switch (world.getEnvironment()) { - case NETHER: - return 128; - case NORMAL: - case THE_END: - if (Version.isCurrentEqualOrHigher(Version.v1_17_R1)) - return world.getMaxHeight(); - return 256; - default: - break; - } - return 256; + + return 256; } public Vector getVector(Location loc1, Location loc2) { - return null; + return null; } public double getYaw(Location loc1, Location loc2) { - double dX = loc1.getX() - loc2.getX(); - double dZ = loc1.getZ() - loc2.getZ(); - return Math.toDegrees(Math.atan2(dZ, dX)); + double dX = loc1.getX() - loc2.getX(); + double dZ = loc1.getZ() - loc2.getZ(); + return Math.toDegrees(Math.atan2(dZ, dX)); } public double getPitch(Location loc1, Location loc2) { - double dX = loc1.getX() - loc2.getX(); - double dY = loc1.getY() - loc2.getY(); - double dZ = loc1.getZ() - loc2.getZ(); - return Math.toDegrees(Math.atan2(Math.sqrt(dZ * dZ + dX * dX), dY) + Math.PI); + double dX = loc1.getX() - loc2.getX(); + double dY = loc1.getY() - loc2.getY(); + double dZ = loc1.getZ() - loc2.getZ(); + return Math.toDegrees(Math.atan2(Math.sqrt(dZ * dZ + dX * dX), dY) + Math.PI); } @Deprecated public String getMessageReplayTo(String sender) { - return null; + return getMessageReplyTo(sender); } public String getMessageReplyTo(String sender) { - return null; + + return null; } public String createTextProbgressBar(int bars, int total, int current) { - return null; + return null; } public Block getHighestBlockAt(Location loc, boolean includeSolids) { - return null; + for (int y = loc.getWorld().getMaxHeight(); y > CMIWorld.getMinHeight(loc.getWorld()); y--) { + Block b = loc.getWorld().getBlockAt(loc.getBlockX(), y, loc.getBlockZ()); + + if (b == null || b.getType().equals(Material.AIR)) + continue; + + if (includeSolids && !b.getType().isSolid()) + continue; + + return b; + } + + return null; } public TreeMap getClosestEntities(Location center, int range, double treshold, EntityType type) { - return null; + return null; } public Entity getClosestEntity(Location center, int range, EntityType type) { - return null; + return null; } public Entity getTargetEntity(Player player) { - return getTargetEntity(player, 0.95, false, true); + return getTargetEntity(player, 0.95, false, true); } public Entity getTargetEntity(Player player, double pov) { - return getTargetEntity(player, pov, false, true); + return getTargetEntity(player, pov, false, true); } public Entity getTargetEntity(Player player, boolean includeSpectator, boolean includeInvisible) { - return getTargetEntity(player, 0.95, includeSpectator, includeInvisible); + return getTargetEntity(player, 0.95, includeSpectator, includeInvisible); } public Entity getTargetEntity(Player player, double pov, boolean includeSpectator, boolean includeInvisible) { - return null; + return null; } public Block getTargetBlock(Player player, int distance, boolean ignoreNoneSolids) { - return getTargetBlock(player, null, distance, ignoreNoneSolids); + return getTargetBlock(player, null, distance, ignoreNoneSolids); } public Block getTargetBlock(Player player, int distance) { - return getTargetBlock(player, null, distance, false); + return getTargetBlock(player, null, distance, false); } public Block getTargetBlock(Player player, Material lookingFor, int distance) { - return getTargetBlock(player, lookingFor, distance, false); + return getTargetBlock(player, lookingFor, distance, false); } public Block getTargetBlock(Player player, Material lookingFor, int distance, boolean ignoreNoneSolids) { - ArrayList blocks = getLastTwoTargetBlock(player, lookingFor, distance, ignoreNoneSolids); - return blocks.isEmpty() ? null : blocks.get(blocks.size() - 1); + ArrayList blocks = getLastTwoTargetBlock(player, lookingFor, distance, ignoreNoneSolids); + return blocks.isEmpty() ? null : blocks.get(blocks.size() - 1); } public ArrayList getLastTwoTargetBlock(Player player, int distance) { - return getLastTwoTargetBlock(player, null, distance, false); + return getLastTwoTargetBlock(player, null, distance, false); } public ArrayList getLastTwoTargetBlock(Player player, Material lookingFor, int distance, boolean fluids) { - return null; + return null; } public itemInfo getItemInfo(String text) { - - return null; + CMIItemStack ci = CMILib.getInstance().getItemManager().getItem(text); + if (ci != null) + return new itemInfo(ci.getCMIType()); + return new itemInfo(CMIMaterial.get(text)); } public int getItemData(ItemStack item) { - if (item.getType().toString().contains("_EGG")) - return CMILib.getInstance().getReflectionManager().getEggId(item); - else if (item.getType().equals(CMIMaterial.SPAWNER.getMaterial())) - return new CMIItemStack(item).getEntityType().getTypeId(); - if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) - return 0; - return item.getData().getData(); + if (item.getType().toString().contains("_EGG")) + return CMILib.getInstance().getReflectionManager().getEggId(item); + else if (item.getType().equals(CMIMaterial.SPAWNER.getMaterial())) + return new CMIItemStack(item).getEntityType().getTypeId(); + if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) + return 0; + return item.getData().getData(); } public String translateDamageCause(String cause) { - if (CMILib.getInstance().getLM().containsKey("info.DamageCause." + cause.toLowerCase())) - cause = CMILib.getInstance().getLM().getMessage("info.DamageCause." + cause.toLowerCase()); - return cause; + if (CMILib.getInstance().getLM().containsKey("info.DamageCause." + cause.toLowerCase())) + cause = CMILib.getInstance().getLM().getMessage("info.DamageCause." + cause.toLowerCase()); + return cause; } public int getOnlinePlayerCount() { - int i = 0; - for (Player one : Bukkit.getOnlinePlayers()) { - i++; - } - return i; + return getOnlinePlayerCount(null); + } + + public int getOnlinePlayerCount(World world) { + int i = 0; + for (Player one : Bukkit.getOnlinePlayers()) { + if (world != null && !one.getWorld().equals(world)) + continue; + i++; + } + return i; } public String getOnlinePlayersAsString() { - return getOnlinePlayersAsString(null); + return getOnlinePlayersAsString(null); } public String getOnlinePlayersAsString(String ignore) { - String players = ""; - for (Player one : Bukkit.getOnlinePlayers()) { - if (ignore != null && one.getName().equalsIgnoreCase(ignore)) - continue; - if (!players.isEmpty()) - players += ","; - players += one.getName(); - } - return players; + return null; } @Deprecated public List getPlayersFromRange(Location loc, int range, @SuppressWarnings("unused") boolean forced) { - return getPlayersFromRange(loc, range); + return getPlayersFromRange(loc, range); } public List getPlayersFromRange(Location loc, int range) { - return getPlayersFromRange(null, loc, range); + return getPlayersFromRange(null, loc, range); } public List getPlayersFromRange(Player player, Location loc, int range) { - return null; + return null; } public List getPlayersFromRangeForCounter(Location loc, int range, boolean forced) { - return null; + return null; } public World getWorld(String name) { - return null; + return null; } public List getWorldList() { - return null; + return null; } public void resendBlockInfo(final Player player, final Block block) { @@ -367,59 +342,51 @@ public void resendBlockInfo(final Player player, final Block block) { } public boolean isFullInv(ItemStack[] cn, List list) { - int total = 36; - for (ItemStack one : cn) { - if (one != null) - total--; - } - if (total < list.size()) - return true; - return false; + return false; } public List ConvertInvToList(Inventory inv) { - ItemStack[] contents = inv.getContents(); - List items = new ArrayList(); - for (ItemStack one : contents) { - if (one != null) - items.add(one); - } - return items; + return null; } public boolean isOnline(String name) { - return Bukkit.getPlayer(name) != null; + return Bukkit.getPlayer(name) != null; } public boolean canRepair(ItemStack item) { - return true; + return true; } public boolean needRepair(ItemStack item) { - return true; + return true; } public ItemStack repairItem(ItemStack item) { - return item; + return null; } public boolean hasSilkTouch(ItemStack is, int lvl) { - - return false; + if (is == null) + return false; + for (Entry one : is.getEnchantments().entrySet()) { + if (one.getKey().getName().equalsIgnoreCase("SILK_TOUCH") && one.getValue() >= lvl) + return true; + } + return false; } @SuppressWarnings("deprecation") public ItemStack setEntityType(ItemStack is, EntityType type) { - return null; + return null; } public boolean haveBlackListedItems(Player player, TpAction action) { - return false; + return false; } private void showBlackListedItemList(Player player, HashMap items) { @@ -428,65 +395,63 @@ private void showBlackListedItemList(Player player, HashMap i public HashMap getBlackListedItems(Player player) { - return null; + return null; } private HashMap getAllItemsFromInv(Inventory inv, HashMap t) { - return null; + return null; } public String convertLocToStringShort(Location loc) { - return null; + return null; } public boolean validName(String name) { - return validName("[^a-zA-Z0-9\\-\\_]", name); + return validName("[^a-zA-Z0-9\\-\\_]", name); } public boolean validName(String regex, String name) { - return false; + return false; } public String getWorldName(UUID uuid) { - World w = Bukkit.getWorld(uuid); - if (w != null) - return w.getName(); - return this.worldCache.get(uuid); + + return null; } public CMIChatColor getTpsColor(Double tps) { - return null; + return null; } public static File getFile(Player player) { - return getFile(player.getUniqueId()); + return getFile(player.getUniqueId()); } public static File getFile(UUID uuid) { - return new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata" + File.separator + uuid + ".dat"); + return new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata" + File.separator + uuid + ".dat"); } public Player getRandomOnlinePlayer() { - return getRandomOnlinePlayer(null); + return getRandomOnlinePlayer(null); } public Player getRandomOnlinePlayer(Set exclude) { - return null; + return null; } public boolean blockedItemFromRenaming(CommandSender sender, ItemStack item, String newName) { - return false; + return false; } public String getLineSplitter(String text) { - return null; + return null; } } diff --git a/src/com/Zrips/CMI/utils/VersionChecker.java b/src/com/Zrips/CMI/utils/VersionChecker.java index db1433f..f0f2ab9 100644 --- a/src/com/Zrips/CMI/utils/VersionChecker.java +++ b/src/com/Zrips/CMI/utils/VersionChecker.java @@ -10,27 +10,34 @@ public class VersionChecker { private CMI plugin; public VersionChecker(CMI plugin) { - this.plugin = plugin; + this.plugin = plugin; } public Integer convertVersion(String v) { - return null; + + return null; } public String deconvertVersion(Integer v) { - return null; + return null; } public void VersionCheck(final Player player) { + } public String getOfficialVersion() { - return getOfficialVersion(resource); + return getOfficialVersion(resource); } public String getOfficialVersion(int resource) { - return null; + + return null; } + public static String s1 = "%%__USER__%%"; + public static String s2 = "%%__RESOURCE__%%"; + public static String s3 = "%%__NONCE__%%"; + }