From d79b93d6c5b3aa36217215b40d3a09bd90fa594e Mon Sep 17 00:00:00 2001 From: Driftay Date: Sat, 4 Apr 2020 05:09:05 -0400 Subject: [PATCH] New Shop Config Format With Help, Removed Useless Code FactionsBlockListener Block Break Revamp, F Wild Revamp (DroppingAnvil) & Alot I can't remember xD --- javadoc/allclasses-frame.html | 8 +- javadoc/allclasses-index.html | 6 +- javadoc/allclasses-noframe.html | 8 +- javadoc/allpackages-index.html | 2 +- .../com/massivecraft/factions/Faction.html | 12 +- .../factions/util/FactionWarpsFrame.html | 2 +- .../factions/util/InventoryTypeAdapter.html | 2 +- .../factions/util/LocationTypeAdapter.html | 2 +- .../util/MapFLocToStringSetTypeAdapter.html | 2 +- .../factions/util/MyLocationTypeAdapter.html | 2 +- .../util/PermissionsMapTypeAdapter.html | 2 +- .../zcore/fupgrades/CropUpgrades.html | 8 +- .../factions/zcore/fupgrades/EXPUpgrade.html | 12 +- .../zcore/fupgrades/FUpgradesGUI.html | 4 +- .../zcore/fupgrades/SpawnerUpgrades.html | 8 +- .../factions/zcore/fupgrades/UpgradeType.html | 44 +++--- .../zcore/fupgrades/UpgradesListener.html | 4 +- .../zcore/fupgrades/package-frame.html | 12 +- .../zcore/fupgrades/package-summary.html | 10 +- .../zcore/fupgrades/package-tree.html | 18 +-- .../factions/zcore/persist/MemoryFaction.html | 16 +- .../zcore/persist/json/JSONFaction.html | 2 +- javadoc/element-list | 2 +- javadoc/index-files/index-13.html | 2 +- javadoc/index-files/index-15.html | 18 +-- javadoc/index-files/index-16.html | 2 +- javadoc/index-files/index-18.html | 4 +- javadoc/index-files/index-19.html | 6 +- javadoc/index-files/index-20.html | 4 +- javadoc/index-files/index-21.html | 6 +- javadoc/index-files/index-22.html | 4 +- javadoc/index-files/index-23.html | 2 +- javadoc/index-files/index-3.html | 6 +- javadoc/index-files/index-4.html | 4 +- javadoc/index-files/index-5.html | 2 +- javadoc/index-files/index-6.html | 4 +- javadoc/index-files/index-7.html | 4 +- javadoc/index.html | 2 +- javadoc/overview-frame.html | 2 +- javadoc/overview-tree.html | 8 +- javadoc/package-list | 2 +- .../com/massivecraft/factions/Faction.java | 2 +- .../massivecraft/factions/FactionsPlugin.java | 20 ++- .../massivecraft/factions/cmd/CmdDisband.java | 2 +- .../massivecraft/factions/cmd/CmdFWarp.java | 2 +- .../massivecraft/factions/cmd/CmdJoin.java | 2 +- .../massivecraft/factions/cmd/CmdReload.java | 3 +- .../massivecraft/factions/cmd/CmdSaveAll.java | 3 +- .../factions/cmd/CmdSeeChunk.java | 2 +- .../factions/cmd/CmdUpgrades.java | 2 +- .../factions/cmd/check/CheckHistoryFrame.java | 2 +- .../cmd/check/CheckSettingsFrame.java | 2 +- .../factions/cmd/tnt/CmdTntFill.java | 8 - .../factions/cmd/wild/CmdWild.java | 40 ++--- .../factions/cmd/wild/WildGUI.java | 6 +- .../listeners/FactionsBlockListener.java | 65 ++++---- .../listeners/FactionsPlayerListener.java | 14 +- .../factions/missions/MissionGUI.java | 2 +- .../factions/shop/ShopConfig.java | 60 -------- .../factions/shop/ShopGUIFrame.java | 16 +- .../factions/util/InventoryUtil.java | 2 +- .../util/{Particles => }/ParticleEffect.java | 9 +- .../factions/util/Particles/Particles.java | 59 -------- .../util/{Particles => }/ReflectionUtils.java | 9 +- .../massivecraft/factions/util/TimeUtil.java | 108 -------------- .../massivecraft/factions/util/Updater.java | 49 ------ .../util/{ => adapters}/EnumTypeAdapter.java | 2 +- .../{ => adapters}/InventoryTypeAdapter.java | 3 +- .../{ => adapters}/LocationTypeAdapter.java | 2 +- .../MapFLocToStringSetTypeAdapter.java | 2 +- .../{ => adapters}/MyLocationTypeAdapter.java | 3 +- .../PermissionsMapTypeAdapter.java | 2 +- .../util/exceptions/SaberException.java | 11 -- .../exceptions/impl/DiscordException.java | 12 -- .../factions/util/wait/WaitExecutor.java | 46 ++++++ .../factions/util/wait/WaitTask.java | 47 ++++++ .../factions/util/wait/WaitedTask.java | 14 ++ .../factions/zcore/file/CustomFile.java | 141 ++++++++++++++++++ .../factions/zcore/file/impl/FileManager.java | 25 ++++ .../{util => zcore/frame}/FactionGUI.java | 2 +- .../{ => frame}/fdisband/FDisbandFrame.java | 2 +- .../{ => frame}/fupgrades/FUpgradeFrame.java | 2 +- .../{ => frame}/fupgrades/UpgradeType.java | 2 +- .../fupgrades/UpgradesListener.java | 2 +- .../frame/fwarps}/FactionWarpsFrame.java | 6 +- .../factions/zcore/persist/MemoryFPlayer.java | 6 +- .../factions/zcore/persist/MemoryFaction.java | 2 +- src/main/resources/config.yml | 6 +- src/main/resources/plugin.yml | 1 + src/main/resources/shop.yml | 36 +++++ 90 files changed, 576 insertions(+), 560 deletions(-) delete mode 100644 src/main/java/com/massivecraft/factions/shop/ShopConfig.java rename src/main/java/com/massivecraft/factions/util/{Particles => }/ParticleEffect.java (99%) delete mode 100644 src/main/java/com/massivecraft/factions/util/Particles/Particles.java rename src/main/java/com/massivecraft/factions/util/{Particles => }/ReflectionUtils.java (99%) delete mode 100644 src/main/java/com/massivecraft/factions/util/TimeUtil.java delete mode 100644 src/main/java/com/massivecraft/factions/util/Updater.java rename src/main/java/com/massivecraft/factions/util/{ => adapters}/EnumTypeAdapter.java (97%) rename src/main/java/com/massivecraft/factions/util/{ => adapters}/InventoryTypeAdapter.java (90%) rename src/main/java/com/massivecraft/factions/util/{ => adapters}/LocationTypeAdapter.java (97%) rename src/main/java/com/massivecraft/factions/util/{ => adapters}/MapFLocToStringSetTypeAdapter.java (98%) rename src/main/java/com/massivecraft/factions/util/{ => adapters}/MyLocationTypeAdapter.java (95%) rename src/main/java/com/massivecraft/factions/util/{ => adapters}/PermissionsMapTypeAdapter.java (98%) delete mode 100644 src/main/java/com/massivecraft/factions/util/exceptions/SaberException.java delete mode 100644 src/main/java/com/massivecraft/factions/util/exceptions/impl/DiscordException.java create mode 100644 src/main/java/com/massivecraft/factions/util/wait/WaitExecutor.java create mode 100644 src/main/java/com/massivecraft/factions/util/wait/WaitTask.java create mode 100644 src/main/java/com/massivecraft/factions/util/wait/WaitedTask.java create mode 100644 src/main/java/com/massivecraft/factions/zcore/file/CustomFile.java create mode 100644 src/main/java/com/massivecraft/factions/zcore/file/impl/FileManager.java rename src/main/java/com/massivecraft/factions/{util => zcore/frame}/FactionGUI.java (82%) rename src/main/java/com/massivecraft/factions/zcore/{ => frame}/fdisband/FDisbandFrame.java (98%) rename src/main/java/com/massivecraft/factions/zcore/{ => frame}/fupgrades/FUpgradeFrame.java (98%) rename src/main/java/com/massivecraft/factions/zcore/{ => frame}/fupgrades/UpgradeType.java (98%) rename src/main/java/com/massivecraft/factions/zcore/{ => frame}/fupgrades/UpgradesListener.java (99%) rename src/main/java/com/massivecraft/factions/{util => zcore/frame/fwarps}/FactionWarpsFrame.java (95%) create mode 100644 src/main/resources/shop.yml diff --git a/javadoc/allclasses-frame.html b/javadoc/allclasses-frame.html index 345f4acb..40ba8159 100644 --- a/javadoc/allclasses-frame.html +++ b/javadoc/allclasses-frame.html @@ -128,7 +128,7 @@
  • CommandVisibility
  • Conf
  • Conf.Backend
  • -
  • CropUpgrades
  • +
  • CropUpgrades
  • DiscUtil
  • DynmapStyle
  • Econ
  • @@ -136,7 +136,7 @@
  • EngineDynmap
  • EnumTypeAdapter
  • Essentials
  • -
  • EXPUpgrade
  • +
  • EXPUpgrade
  • Faction
  • FactionCreateEvent
  • FactionDisbandEvent
  • @@ -171,7 +171,7 @@
  • FScoreboard
  • FSidebarProvider
  • FTeamWrapper
  • -
  • FUpgradesGUI
  • +
  • FUpgradesGUI
  • GsonWrapper
  • InventoryTypeAdapter
  • InventoryUtil
  • @@ -242,7 +242,7 @@ title="class in com.massivecraft.factions">SaberFactions
  • SaveTask
  • SmokeUtil
  • -
  • SpawnerUpgrades
  • +
  • SpawnerUpgrades
  • SpiralTask
  • TagReplacer
  • TagReplacer.TagType
  • diff --git a/javadoc/allclasses-index.html b/javadoc/allclasses-index.html index 3c28c37f..3ee4bba2 100644 --- a/javadoc/allclasses-index.html +++ b/javadoc/allclasses-index.html @@ -942,7 +942,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));   -FUpgradesGUI +FUpgradesGUI   @@ -1364,11 +1364,11 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height")); -UpgradesListener +UpgradesListener   -UpgradeType +UpgradeType   diff --git a/javadoc/allclasses-noframe.html b/javadoc/allclasses-noframe.html index c91018bd..775703f2 100644 --- a/javadoc/allclasses-noframe.html +++ b/javadoc/allclasses-noframe.html @@ -128,7 +128,7 @@
  • CommandVisibility
  • Conf
  • Conf.Backend
  • -
  • CropUpgrades
  • +
  • CropUpgrades
  • DiscUtil
  • DynmapStyle
  • Econ
  • @@ -136,7 +136,7 @@
  • EngineDynmap
  • EnumTypeAdapter
  • Essentials
  • -
  • EXPUpgrade
  • +
  • EXPUpgrade
  • Faction
  • FactionCreateEvent
  • FactionDisbandEvent
  • @@ -171,7 +171,7 @@
  • FScoreboard
  • FSidebarProvider
  • FTeamWrapper
  • -
  • FUpgradesGUI
  • +
  • FUpgradesGUI
  • GsonWrapper
  • InventoryTypeAdapter
  • InventoryUtil
  • @@ -242,7 +242,7 @@
  • SaveTask
  • SmokeUtil
  • -
  • SpawnerUpgrades
  • +
  • SpawnerUpgrades
  • SpiralTask
  • TagReplacer
  • TagReplacer.TagType
  • diff --git a/javadoc/allpackages-index.html b/javadoc/allpackages-index.html index 34382ffd..18364687 100644 --- a/javadoc/allpackages-index.html +++ b/javadoc/allpackages-index.html @@ -223,7 +223,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));   -com.massivecraft.factions.zcore.fupgrades +com.massivecraft.factions.zcore.frame.fupgrades   diff --git a/javadoc/com/massivecraft/factions/Faction.html b/javadoc/com/massivecraft/factions/Faction.html index b32b5f9e..bd46baba 100644 --- a/javadoc/com/massivecraft/factions/Faction.html +++ b/javadoc/com/massivecraft/factions/Faction.html @@ -630,7 +630,7 @@ extends int -getUpgrade​(UpgradeType upgrade) +getUpgrade​(UpgradeType upgrade)   @@ -1066,7 +1066,7 @@ extends void -setUpgrade​(UpgradeType upgrade, +setUpgrade​(UpgradeType upgrade, int level)   @@ -1743,23 +1743,23 @@ extends void deinvite​(FPlayer fplayer) - + - + diff --git a/javadoc/com/massivecraft/factions/util/FactionWarpsFrame.html b/javadoc/com/massivecraft/factions/util/FactionWarpsFrame.html index a5e57a72..7145a4b4 100644 --- a/javadoc/com/massivecraft/factions/util/FactionWarpsFrame.html +++ b/javadoc/com/massivecraft/factions/util/FactionWarpsFrame.html @@ -107,7 +107,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
  • java.lang.Object
    • -
    • com.massivecraft.factions.util.FactionWarpsFrame
    • +
    • com.massivecraft.factions.zcore.frame.fdisband.FactionWarpsFrame
  • diff --git a/javadoc/com/massivecraft/factions/util/InventoryTypeAdapter.html b/javadoc/com/massivecraft/factions/util/InventoryTypeAdapter.html index ec092f51..fc1e877c 100644 --- a/javadoc/com/massivecraft/factions/util/InventoryTypeAdapter.html +++ b/javadoc/com/massivecraft/factions/util/InventoryTypeAdapter.html @@ -107,7 +107,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
  • java.lang.Object
    • -
    • com.massivecraft.factions.util.InventoryTypeAdapter
    • +
    • com.massivecraft.factions.util.adapters.InventoryTypeAdapter
  • diff --git a/javadoc/com/massivecraft/factions/util/LocationTypeAdapter.html b/javadoc/com/massivecraft/factions/util/LocationTypeAdapter.html index 463a63e8..a7fee8e2 100644 --- a/javadoc/com/massivecraft/factions/util/LocationTypeAdapter.html +++ b/javadoc/com/massivecraft/factions/util/LocationTypeAdapter.html @@ -107,7 +107,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
  • java.lang.Object
    • -
    • com.massivecraft.factions.util.LocationTypeAdapter
    • +
    • com.massivecraft.factions.util.adapters.LocationTypeAdapter
  • diff --git a/javadoc/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.html b/javadoc/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.html index 368421f8..b8ec68f3 100644 --- a/javadoc/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.html +++ b/javadoc/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.html @@ -107,7 +107,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
  • java.lang.Object
    • -
    • com.massivecraft.factions.util.MapFLocToStringSetTypeAdapter
    • +
    • com.massivecraft.factions.util.adapters.MapFLocToStringSetTypeAdapter
  • diff --git a/javadoc/com/massivecraft/factions/util/MyLocationTypeAdapter.html b/javadoc/com/massivecraft/factions/util/MyLocationTypeAdapter.html index b35193f9..5fbc1729 100644 --- a/javadoc/com/massivecraft/factions/util/MyLocationTypeAdapter.html +++ b/javadoc/com/massivecraft/factions/util/MyLocationTypeAdapter.html @@ -107,7 +107,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
  • java.lang.Object
    • -
    • com.massivecraft.factions.util.MyLocationTypeAdapter
    • +
    • com.massivecraft.factions.util.adapters.MyLocationTypeAdapter
  • diff --git a/javadoc/com/massivecraft/factions/util/PermissionsMapTypeAdapter.html b/javadoc/com/massivecraft/factions/util/PermissionsMapTypeAdapter.html index c449a789..db1d32c4 100644 --- a/javadoc/com/massivecraft/factions/util/PermissionsMapTypeAdapter.html +++ b/javadoc/com/massivecraft/factions/util/PermissionsMapTypeAdapter.html @@ -107,7 +107,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
  • java.lang.Object
    • -
    • com.massivecraft.factions.util.PermissionsMapTypeAdapter
    • +
    • com.massivecraft.factions.util.adapters.PermissionsMapTypeAdapter
  • diff --git a/javadoc/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.html b/javadoc/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.html index 3e3e7767..41301d93 100644 --- a/javadoc/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.html +++ b/javadoc/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.html @@ -49,7 +49,7 @@ var activeTableTab = "activeTableTab";
    @@ -313,7 +313,7 @@ the order they are declared. @@ -322,7 +322,7 @@ the order they are declared. @@ -331,7 +331,7 @@ the order they are declared. @@ -340,7 +340,7 @@ the order they are declared. @@ -349,7 +349,7 @@ the order they are declared. @@ -358,7 +358,7 @@ the order they are declared. @@ -367,7 +367,7 @@ the order they are declared. @@ -376,7 +376,7 @@ the order they are declared. @@ -385,7 +385,7 @@ the order they are declared. @@ -394,7 +394,7 @@ the order they are declared. @@ -413,7 +413,7 @@ the order they are declared. diff --git a/javadoc/com/massivecraft/factions/zcore/fupgrades/package-frame.html b/javadoc/com/massivecraft/factions/zcore/fupgrades/package-frame.html index 4dfdbcd3..4f1a7c3c 100644 --- a/javadoc/com/massivecraft/factions/zcore/fupgrades/package-frame.html +++ b/javadoc/com/massivecraft/factions/zcore/fupgrades/package-frame.html @@ -3,20 +3,20 @@ -com.massivecraft.factions.zcore.fupgrades +com.massivecraft.factions.zcore.frame.fupgrades -

    com.massivecraft.factions.zcore.fupgrades

    +

    com.massivecraft.factions.zcore.frame.fupgrades

    diff --git a/javadoc/com/massivecraft/factions/zcore/fupgrades/package-summary.html b/javadoc/com/massivecraft/factions/zcore/fupgrades/package-summary.html index 532ffcff..04a1fa3f 100644 --- a/javadoc/com/massivecraft/factions/zcore/fupgrades/package-summary.html +++ b/javadoc/com/massivecraft/factions/zcore/fupgrades/package-summary.html @@ -3,7 +3,7 @@ -com.massivecraft.factions.zcore.fupgrades +com.massivecraft.factions.zcore.frame.fupgrades @@ -77,7 +77,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
    -

    Package com.massivecraft.factions.zcore.fupgrades

    +

    Package com.massivecraft.factions.zcore.frame.fupgrades

    -
    CROP - com.massivecraft.factions.zcore.fupgrades.UpgradeType
    +
    CROP - com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType
     
    CROSSBOW - com.massivecraft.factions.util.XMaterial
     
    diff --git a/javadoc/index-files/index-4.html b/javadoc/index-files/index-4.html index aecd5c79..8918fb03 100644 --- a/javadoc/index-files/index-4.html +++ b/javadoc/index-files/index-4.html @@ -87,9 +87,9 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
    DAMAGED_ANVIL - com.massivecraft.factions.util.XMaterial
     
    -
    DAMAGEDECREASE - com.massivecraft.factions.zcore.fupgrades.UpgradeType
    +
    DAMAGEDECREASE - com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType
     
    -
    DAMAGEINCREASE - com.massivecraft.factions.zcore.fupgrades.UpgradeType
    +
    DAMAGEINCREASE - com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType
     
    DANDELION - com.massivecraft.factions.util.XMaterial
     
    diff --git a/javadoc/index-files/index-5.html b/javadoc/index-files/index-5.html index d8f97fc6..5bf333b5 100644 --- a/javadoc/index-files/index-5.html +++ b/javadoc/index-files/index-5.html @@ -279,7 +279,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
     
    execute(CommandSender, List<String>, List<MCommand<?>>) - Method in class com.massivecraft.factions.zcore.MCommand
     
    -
    EXP - com.massivecraft.factions.zcore.fupgrades.UpgradeType
    +
    EXP - com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType
     
    EXPERIENCE_BOTTLE - com.massivecraft.factions.util.XMaterial
     
    diff --git a/javadoc/index-files/index-6.html b/javadoc/index-files/index-6.html index 775f1929..dfdc672d 100644 --- a/javadoc/index-files/index-6.html +++ b/javadoc/index-files/index-6.html @@ -533,9 +533,9 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
     
    FTeamWrapper - Class in com.massivecraft.factions.scoreboards
     
    -
    FUpgradesGUI - Class in com.massivecraft.factions.zcore.fupgrades
    +
    FUpgradesGUI - Class in com.massivecraft.factions.zcore.frame.fupgrades
     
    -
    FUpgradesGUI() - Constructor for class com.massivecraft.factions.zcore.fupgrades.FUpgradesGUI
    +
    FUpgradesGUI() - Constructor for class com.massivecraft.factions.zcore.frame.fupgrades.FUpgradesGUI
     
    FURNACE - com.massivecraft.factions.util.XMaterial
     
    diff --git a/javadoc/index-files/index-7.html b/javadoc/index-files/index-7.html index e06469b9..f76e0625 100644 --- a/javadoc/index-files/index-7.html +++ b/javadoc/index-files/index-7.html @@ -1528,9 +1528,9 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
     
    getTypeMethodName() - Static method in class com.massivecraft.factions.zcore.nbtapi.utils.MethodNames
     
    -
    getUpgrade(UpgradeType) - Method in interface com.massivecraft.factions.Faction
    +
    getUpgrade(UpgradeType) - Method in interface com.massivecraft.factions.Faction
     
    -
    getUpgrade(UpgradeType) - Method in class com.massivecraft.factions.zcore.persist.MemoryFaction
    +
    getUpgrade(UpgradeType) - Method in class com.massivecraft.factions.zcore.persist.MemoryFaction
     
    getUsageTemplate(CommandContext) - Method in class com.massivecraft.factions.cmd.FCommand
     
    diff --git a/javadoc/index.html b/javadoc/index.html index 2903f48e..3ddc02d9 100644 --- a/javadoc/index.html +++ b/javadoc/index.html @@ -218,7 +218,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));   -com.massivecraft.factions.zcore.fupgrades +com.massivecraft.factions.zcore.frame.fupgrades   diff --git a/javadoc/overview-frame.html b/javadoc/overview-frame.html index 7d096dfb..988479db 100644 --- a/javadoc/overview-frame.html +++ b/javadoc/overview-frame.html @@ -28,7 +28,7 @@
  • com.massivecraft.factions.zcore
  • com.massivecraft.factions.zcore.fperms
  • com.massivecraft.factions.zcore.fperms.gui
  • -
  • com.massivecraft.factions.zcore.fupgrades
  • +
  • com.massivecraft.factions.zcore.frame.fupgrades
  • com.massivecraft.factions.zcore.nbtapi
  • com.massivecraft.factions.zcore.nbtapi.utils
  • com.massivecraft.factions.zcore.persist
  • diff --git a/javadoc/overview-tree.html b/javadoc/overview-tree.html index 572f6519..e3691469 100644 --- a/javadoc/overview-tree.html +++ b/javadoc/overview-tree.html @@ -113,7 +113,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
  • com.massivecraft.factions.zcore,
  • com.massivecraft.factions.zcore.fperms,
  • com.massivecraft.factions.zcore.fperms.gui,
  • -
  • com.massivecraft.factions.zcore.fupgrades,
  • +
  • com.massivecraft.factions.zcore.frame.fupgrades,
  • com.massivecraft.factions.zcore.nbtapi,
  • com.massivecraft.factions.zcore.nbtapi.utils,
  • com.massivecraft.factions.zcore.persist,
  • @@ -379,7 +379,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
  • com.massivecraft.factions.scoreboards.FTeamWrapper
  • -
  • com.massivecraft.factions.zcore.fupgrades.FUpgradesGUI (implements org.bukkit.event.Listener)
  • +
  • com.massivecraft.factions.zcore.frame.fupgrades.FUpgradesGUI (implements org.bukkit.event.Listener)
  • com.massivecraft.factions.zcore.nbtapi.utils.GsonWrapper
  • com.massivecraft.factions.util.InventoryTypeAdapter (implements com.google.gson.JsonDeserializer<T>, com.google.gson.JsonSerializer<T>)
  • com.massivecraft.factions.util.InventoryUtil
  • @@ -493,7 +493,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
  • com.massivecraft.factions.util.EnumTypeAdapter<T>
  • -
  • com.massivecraft.factions.zcore.fupgrades.UpgradesListener (implements org.bukkit.event.Listener)
  • +
  • com.massivecraft.factions.zcore.frame.fupgrades.UpgradesListener (implements org.bukkit.event.Listener)
  • com.massivecraft.factions.util.UtilFly
  • com.massivecraft.factions.zcore.util.UUIDFetcher (implements java.util.concurrent.Callable<V>)
  • com.massivecraft.factions.util.VisualizeUtil
  • @@ -562,7 +562,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
  • com.massivecraft.factions.zcore.util.TagReplacer
  • com.massivecraft.factions.zcore.util.TagReplacer.TagType
  • com.massivecraft.factions.zcore.util.TL
  • -
  • com.massivecraft.factions.zcore.fupgrades.UpgradeType
  • +
  • com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType
  • com.massivecraft.factions.util.WarmUpUtil.Warmup
  • com.massivecraft.factions.util.XMaterial
  • com.massivecraft.factions.util.XMaterial.MinecraftVersion
  • diff --git a/javadoc/package-list b/javadoc/package-list index ca91acea..1f415e97 100644 --- a/javadoc/package-list +++ b/javadoc/package-list @@ -13,7 +13,7 @@ com.massivecraft.factions.util.Particles com.massivecraft.factions.zcore com.massivecraft.factions.zcore.fperms com.massivecraft.factions.zcore.fperms.gui -com.massivecraft.factions.zcore.fupgrades +com.massivecraft.factions.zcore.frame.fupgrades com.massivecraft.factions.zcore.nbtapi com.massivecraft.factions.zcore.nbtapi.utils com.massivecraft.factions.zcore.persist diff --git a/src/main/java/com/massivecraft/factions/Faction.java b/src/main/java/com/massivecraft/factions/Faction.java index d2b8e509..5603e58b 100644 --- a/src/main/java/com/massivecraft/factions/Faction.java +++ b/src/main/java/com/massivecraft/factions/Faction.java @@ -11,7 +11,7 @@ import com.massivecraft.factions.util.LazyLocation; import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.fperms.PermissableAction; -import com.massivecraft.factions.zcore.fupgrades.UpgradeType; +import com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.Player; diff --git a/src/main/java/com/massivecraft/factions/FactionsPlugin.java b/src/main/java/com/massivecraft/factions/FactionsPlugin.java index 54b7bcc4..4d2436f4 100755 --- a/src/main/java/com/massivecraft/factions/FactionsPlugin.java +++ b/src/main/java/com/massivecraft/factions/FactionsPlugin.java @@ -21,18 +21,19 @@ import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.integration.dynmap.EngineDynmap; import com.massivecraft.factions.listeners.*; import com.massivecraft.factions.missions.MissionHandler; -import com.massivecraft.factions.shop.ShopConfig; import com.massivecraft.factions.struct.ChatMode; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.util.*; -import com.massivecraft.factions.util.Particles.ReflectionUtils; +import com.massivecraft.factions.util.adapters.*; +import com.massivecraft.factions.util.wait.WaitExecutor; import com.massivecraft.factions.zcore.CommandVisibility; import com.massivecraft.factions.zcore.MPlugin; +import com.massivecraft.factions.zcore.file.impl.FileManager; import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.fperms.PermissableAction; -import com.massivecraft.factions.zcore.fupgrades.UpgradesListener; +import com.massivecraft.factions.zcore.frame.fupgrades.UpgradesListener; import com.massivecraft.factions.zcore.util.TextUtil; import me.lucko.commodore.CommodoreProvider; import net.milkbowl.vault.economy.Economy; @@ -55,7 +56,6 @@ import java.lang.reflect.Type; import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; -import java.util.concurrent.atomic.AtomicReference; import java.util.logging.Level; import java.util.stream.Collectors; @@ -95,7 +95,11 @@ public class FactionsPlugin extends MPlugin { private Worldguard wg; private FLogManager fLogManager; private List reserveObjects; + private FileManager fileManager; + public FileManager getFileManager() { + return fileManager; + } public FactionsPlugin() { instance = this; @@ -181,16 +185,21 @@ public class FactionsPlugin extends MPlugin { this.saveResource("config.yml", false); this.reloadConfig(); } + + //Start wait task executor + WaitExecutor.startTask(); //Attempt to generate a permission list PermissionList.generateFile(); // Load Conf from disk + fileManager = new FileManager(); + getFileManager().setupFiles(); Conf.load(); fLogManager = new FLogManager(); //Dependency checks if (Conf.dependencyCheck && (!Bukkit.getPluginManager().isPluginEnabled("Vault"))) { divider(); System.out.println("You are missing dependencies!"); - System.out.println("Please verify and Vault are installed!"); + System.out.println("Please verify [Vault] is installed!"); Conf.save(); Bukkit.getPluginManager().disablePlugin(instance); divider(); @@ -264,7 +273,6 @@ public class FactionsPlugin extends MPlugin { //Setup Discord Bot new Discord(this); - ShopConfig.setup(); fLogManager.loadLogs(this); getServer().getPluginManager().registerEvents(factionsPlayerListener = new FactionsPlayerListener(), this); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java index 065d4945..3a9a7d41 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java @@ -4,7 +4,7 @@ import com.massivecraft.factions.*; import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; -import com.massivecraft.factions.zcore.fdisband.FDisbandFrame; +import com.massivecraft.factions.zcore.frame.fdisband.FDisbandFrame; import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.util.TL; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java index 70a7b74e..116b9b3e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java @@ -3,9 +3,9 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.util.FactionWarpsFrame; import com.massivecraft.factions.util.WarmUpUtil; import com.massivecraft.factions.zcore.fperms.PermissableAction; +import com.massivecraft.factions.zcore.frame.fwarps.FactionWarpsFrame; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java index 1a2380d0..e07e4476 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java @@ -6,7 +6,7 @@ import com.massivecraft.factions.discord.Discord; import com.massivecraft.factions.event.FPlayerJoinEvent; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.util.CC; -import com.massivecraft.factions.zcore.fupgrades.UpgradeType; +import com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType; import com.massivecraft.factions.zcore.util.TL; import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.core.exceptions.HierarchyException; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdReload.java b/src/main/java/com/massivecraft/factions/cmd/CmdReload.java index c74611b5..6655d6a0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdReload.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdReload.java @@ -4,7 +4,6 @@ import com.massivecraft.factions.Conf; import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.discord.Discord; import com.massivecraft.factions.listeners.FactionsPlayerListener; -import com.massivecraft.factions.shop.ShopConfig; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; @@ -26,7 +25,7 @@ public class CmdReload extends FCommand { long timeInitStart = System.currentTimeMillis(); Conf.load(); Conf.save(); - ShopConfig.loadShop(); + FactionsPlugin.getInstance().getFileManager().getShop().loadFile(); FactionsPlugin.getInstance().reloadConfig(); FactionsPlugin.getInstance().loadLang(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSaveAll.java b/src/main/java/com/massivecraft/factions/cmd/CmdSaveAll.java index bd69fcc7..99c8ae49 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSaveAll.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSaveAll.java @@ -1,7 +1,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.*; -import com.massivecraft.factions.shop.ShopConfig; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; @@ -30,7 +29,7 @@ public class CmdSaveAll extends FCommand { } catch (Exception e) { e.printStackTrace(); } - ShopConfig.saveShop(); + FactionsPlugin.getInstance().getFileManager().getShop().saveFile(); context.msg(TL.COMMAND_SAVEALL_SUCCESS); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java index fc1ce6a3..393af64b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java @@ -4,7 +4,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.util.Particles.ParticleEffect; +import com.massivecraft.factions.util.ParticleEffect; import com.massivecraft.factions.util.VisualizeUtil; import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.util.TL; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java b/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java index c911546c..9b5263db 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java @@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.zcore.fupgrades.FUpgradeFrame; +import com.massivecraft.factions.zcore.frame.fupgrades.FUpgradeFrame; import com.massivecraft.factions.zcore.util.TL; public class CmdUpgrades extends FCommand { diff --git a/src/main/java/com/massivecraft/factions/cmd/check/CheckHistoryFrame.java b/src/main/java/com/massivecraft/factions/cmd/check/CheckHistoryFrame.java index 340a37b6..545a6ab7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/check/CheckHistoryFrame.java +++ b/src/main/java/com/massivecraft/factions/cmd/check/CheckHistoryFrame.java @@ -4,7 +4,7 @@ import com.google.common.collect.Lists; import com.massivecraft.factions.Conf; import com.massivecraft.factions.Faction; import com.massivecraft.factions.FactionsPlugin; -import com.massivecraft.factions.util.FactionGUI; +import com.massivecraft.factions.zcore.frame.FactionGUI; import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.DyeColor; diff --git a/src/main/java/com/massivecraft/factions/cmd/check/CheckSettingsFrame.java b/src/main/java/com/massivecraft/factions/cmd/check/CheckSettingsFrame.java index f8d2235b..5831b48f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/check/CheckSettingsFrame.java +++ b/src/main/java/com/massivecraft/factions/cmd/check/CheckSettingsFrame.java @@ -3,7 +3,7 @@ package com.massivecraft.factions.cmd.check; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; import com.massivecraft.factions.FactionsPlugin; -import com.massivecraft.factions.util.FactionGUI; +import com.massivecraft.factions.zcore.frame.FactionGUI; import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.ChatColor; diff --git a/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTntFill.java b/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTntFill.java index 1a9c3194..b9034d18 100644 --- a/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTntFill.java +++ b/src/main/java/com/massivecraft/factions/cmd/tnt/CmdTntFill.java @@ -165,14 +165,6 @@ public class CmdTntFill extends FCommand { } } - // Counts the item type available in the inventory. - private int inventoryItemCount(Inventory inventory, Material mat) { - int count = 0; - HashMap items = inventory.all(mat); - for (int item : items.keySet()) - count += inventory.getItem(item).getAmount(); - return count; - } public int getAddable(Inventory inv, Material material) { int output = 0; diff --git a/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java b/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java index b3d7bf1f..5d982b87 100644 --- a/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java +++ b/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java @@ -10,6 +10,7 @@ import com.massivecraft.factions.cmd.CommandContext; import com.massivecraft.factions.cmd.CommandRequirements; import com.massivecraft.factions.cmd.FCommand; import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.util.wait.WaitedTask; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -23,51 +24,31 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Random; -public class CmdWild extends FCommand { - public static HashMap waitingTeleport; +public class CmdWild extends FCommand implements WaitedTask { public static HashMap teleportRange; public static HashSet teleporting; + public static CmdWild instance; public CmdWild() { super(); + if (instance == null) instance = this; this.aliases.addAll(Aliases.wild); this.requirements = new CommandRequirements.Builder(Permission.WILD) .playerOnly() .build(); - waitingTeleport = new HashMap<>(); teleporting = new HashSet<>(); teleportRange = new HashMap<>(); - startWild(); } @Override public void perform(CommandContext context) { - if (!waitingTeleport.containsKey(context.player)) { + if (!teleportRange.containsKey(context.player)) { context.player.openInventory(new WildGUI(context.player, context.fPlayer).getInventory()); } else { context.fPlayer.msg(TL.COMMAND_WILD_WAIT); } } - public void startWild() { - Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.instance, () -> { - for (Player p : waitingTeleport.keySet()) { - int i = waitingTeleport.get(p) - 1; - if (i > 0) { - if (i != 1) { - p.sendMessage(TL.COMMAND_WILD_WAIT.format((i + " Seconds"))); - } else { - p.sendMessage(TL.COMMAND_WILD_WAIT.format((i + " Second"))); - } - waitingTeleport.replace(p, i); - } else { - p.sendMessage(TL.COMMAND_WILD_SUCCESS.toString()); - waitingTeleport.remove(p); - attemptTeleport(p); - } - } - }, 0L, 20L); - } public void attemptTeleport(Player p) { boolean success = false; @@ -121,4 +102,15 @@ public class CmdWild extends FCommand { public TL getUsageTranslation() { return TL.COMMAND_WILD_DESCRIPTION; } + + @Override + public void handleSuccess(Player player) { + attemptTeleport(player); + } + + @Override + public void handleFailure(Player player) { + player.sendMessage(TL.COMMAND_WILD_INTERUPTED.toString()); + } + } diff --git a/src/main/java/com/massivecraft/factions/cmd/wild/WildGUI.java b/src/main/java/com/massivecraft/factions/cmd/wild/WildGUI.java index ca36ddef..3d084d9c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/wild/WildGUI.java +++ b/src/main/java/com/massivecraft/factions/cmd/wild/WildGUI.java @@ -2,7 +2,9 @@ package com.massivecraft.factions.cmd.wild; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FactionsPlugin; -import com.massivecraft.factions.util.FactionGUI; +import com.massivecraft.factions.util.wait.WaitExecutor; +import com.massivecraft.factions.util.wait.WaitTask; +import com.massivecraft.factions.zcore.frame.FactionGUI; import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.Bukkit; @@ -35,7 +37,7 @@ public class WildGUI implements FactionGUI { if (map.containsKey(slot)) { String zone = map.get(slot); if (fplayer.hasMoney(FactionsPlugin.getInstance().getConfig().getInt("Wild.Zones." + zone + ".Cost"))) { - CmdWild.waitingTeleport.put(player, FactionsPlugin.getInstance().getConfig().getInt("Wild.Wait")); + WaitExecutor.taskMap.put(player, new WaitTask(FactionsPlugin.getInstance().getConfig().getInt("Wild.Wait"), TL.COMMAND_WILD_INPROGRESS, player, CmdWild.instance)); CmdWild.teleportRange.put(player, zone); fplayer.msg(TL.COMMAND_WILD_WAIT, FactionsPlugin.getInstance().getConfig().getInt("Wild.Wait") + " Seconds"); player.closeInventory(); diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java index 97d0a549..7ee6316a 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -8,7 +8,6 @@ import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.util.ItemBuilder; -import com.massivecraft.factions.util.Particles.ParticleEffect; import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.PermissableAction; @@ -28,7 +27,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.*; import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.inventory.ItemStack; @@ -394,8 +392,6 @@ public class FactionsBlockListener implements Listener { String[] components = effect.split(":"); player.addPotionEffect(new PotionEffect(Objects.requireNonNull(PotionEffectType.getByName(components[0])), 100, Integer.parseInt(components[1]))); } - ParticleEffect.LAVA.display(1.0f, 1.0f, 1.0f, 1.0f, 10, banner.getLocation(), 16.0); - ParticleEffect.FLAME.display(1.0f, 1.0f, 1.0f, 1.0f, 10, banner.getLocation(), 16.0); if (banner.getType() == bannerType) { continue; } @@ -491,42 +487,49 @@ public class FactionsBlockListener implements Listener { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { - Block block = event.getBlock(); + //If there is an error its much safer to not allow the block to be broken + try { + Block block = event.getBlock(); - Faction at = Board.getInstance().getFactionAt(new FLocation(block)); - boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial()); + Faction at = Board.getInstance().getFactionAt(new FLocation(block)); + boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial()); - if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) { - event.setCancelled(true); - return; - } - - FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer()); - if (fme == null || !fme.hasFaction()) return; - - if (isSpawner) { - Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER); - if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners"); + if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) { + event.setCancelled(true); + return; } - } - if (isSpawner && !fme.isAdminBypassing()) { - ItemStack item = new ItemStack(block.getType(), 1, block.getData()); - if (at != null && at.isNormal()) { - FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer()); - if (fplayer != null) { - BlockState state = block.getState(); - if (state instanceof CreatureSpawner) { - CreatureSpawner spawner = (CreatureSpawner) state; - item.setDurability(spawner.getSpawnedType().getTypeId()); - } - handleSpawnerUpdate(at, event.getPlayer(), item, LogTimer.TimerSubType.SPAWNER_BREAK); + FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer()); + if (fme == null || !fme.hasFaction()) return; + + if (isSpawner) { + Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER); + if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners"); } } + + if (isSpawner && !fme.isAdminBypassing()) { + ItemStack item = new ItemStack(block.getType(), 1, block.getData()); + if (at != null && at.isNormal()) { + FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer()); + if (fplayer != null) { + BlockState state = block.getState(); + if (state instanceof CreatureSpawner) { + CreatureSpawner spawner = (CreatureSpawner) state; + item.setDurability(spawner.getSpawnedType().getTypeId()); + } + handleSpawnerUpdate(at, event.getPlayer(), item, LogTimer.TimerSubType.SPAWNER_BREAK); + } + } + } + } catch (Exception e) { + event.setCancelled(true); + e.printStackTrace(); } } + @EventHandler(priority = EventPriority.HIGHEST) public void FrameRemove(HangingBreakByEntityEvent event) { if (event.getRemover() == null) return; diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 63436d94..12af8b4c 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -19,7 +19,8 @@ import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.util.CC; -import com.massivecraft.factions.util.FactionGUI; +import com.massivecraft.factions.util.wait.WaitExecutor; +import com.massivecraft.factions.zcore.frame.FactionGUI; import com.massivecraft.factions.util.VisualizeUtil; import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.fperms.Access; @@ -937,11 +938,7 @@ public class FactionsPlayerListener implements Listener { handler.cancelLogout(e.getPlayer()); e.getPlayer().sendMessage(String.valueOf(TL.COMMAND_LOGOUT_MOVED)); } - - if (CmdWild.waitingTeleport.containsKey(e.getPlayer())) { - CmdWild.waitingTeleport.remove(e.getPlayer()); - FPlayers.getInstance().getByPlayer(e.getPlayer()).msg(TL.COMMAND_WILD_INTERUPTED); - } + WaitExecutor.handleAction(e.getPlayer()); } @EventHandler @@ -953,10 +950,7 @@ public class FactionsPlayerListener implements Listener { handler.cancelLogout(player); player.sendMessage(String.valueOf(TL.COMMAND_LOGOUT_DAMAGE_TAKEN)); } - if (CmdWild.waitingTeleport.containsKey(player)) { - CmdWild.waitingTeleport.remove(player); - FPlayers.getInstance().getByPlayer(player).msg(TL.COMMAND_WILD_INTERUPTED); - } + WaitExecutor.handleAction(player); if (CmdWild.teleporting.contains(player)) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("Wild.FallDamage") && e.getCause() == EntityDamageEvent.DamageCause.FALL) { e.setCancelled(true); diff --git a/src/main/java/com/massivecraft/factions/missions/MissionGUI.java b/src/main/java/com/massivecraft/factions/missions/MissionGUI.java index 65ae8fdf..bf381107 100644 --- a/src/main/java/com/massivecraft/factions/missions/MissionGUI.java +++ b/src/main/java/com/massivecraft/factions/missions/MissionGUI.java @@ -2,7 +2,7 @@ package com.massivecraft.factions.missions; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FactionsPlugin; -import com.massivecraft.factions.util.FactionGUI; +import com.massivecraft.factions.zcore.frame.FactionGUI; import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.ChatColor; diff --git a/src/main/java/com/massivecraft/factions/shop/ShopConfig.java b/src/main/java/com/massivecraft/factions/shop/ShopConfig.java deleted file mode 100644 index a3aed52e..00000000 --- a/src/main/java/com/massivecraft/factions/shop/ShopConfig.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.massivecraft.factions.shop; - -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; - -public class ShopConfig { - - /** - * @author Driftay - */ - - //TODO: Shop YAML Converter mySQL - - public static File shop = new File("plugins/Factions/shop.yml"); - public static FileConfiguration s = YamlConfiguration.loadConfiguration(shop); - - public static FileConfiguration getShop() { - return s; - } - - public static void loadShop() { - s = YamlConfiguration.loadConfiguration(shop); - } - - public static void saveShop() { - try { - getShop().save(shop); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public static void setup() { - if (!shop.exists()) { - try { - shop.createNewFile(); - getShop().set("prefix", "&4&lFactionShop&8» &7Purchased &f%item% &7for &b%points% Points&7!"); - getShop().set("items.1.slot", 1); - getShop().set("items.1.block", "STONE"); - getShop().set("items.1.name", "&aTest Shop"); - ArrayList lore = new ArrayList<>(); - lore.add("&cFully Customizable Lore!"); - lore.add("&b&l{cost} &7Points"); - getShop().set("items.1.lore", lore); - ArrayList t = new ArrayList<>(); - t.add("broadcast %player% bought Test Shop!"); - getShop().set("items.1.cmds", t); - getShop().set("items.1.cost", 5); - getShop().set("items.1.glowing", true); - saveShop(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } -} diff --git a/src/main/java/com/massivecraft/factions/shop/ShopGUIFrame.java b/src/main/java/com/massivecraft/factions/shop/ShopGUIFrame.java index 42cd6a05..a777603b 100644 --- a/src/main/java/com/massivecraft/factions/shop/ShopGUIFrame.java +++ b/src/main/java/com/massivecraft/factions/shop/ShopGUIFrame.java @@ -45,15 +45,15 @@ public class ShopGUIFrame { ItemStack dummy = buildDummyItem(fplayer.getFaction()); for (int x = 0; x <= (gui.getRows() * 9) - 1; x++) GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true))); - int items = ShopConfig.getShop().getConfigurationSection("items").getKeys(false).size(); + int items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false).size(); for (int a = 1; a <= items; a++) { String s = a + ""; - int slot = ShopConfig.getShop().getInt("items." + s + ".slot"); - ItemStack material = XMaterial.matchXMaterial(Objects.requireNonNull(ShopConfig.getShop().getString("items." + s + ".block"))).get().parseItem(); - int cost = ShopConfig.getShop().getInt("items." + s + ".cost"); - String name = ShopConfig.getShop().getString("items." + s + ".name"); - boolean glowing = ShopConfig.getShop().getBoolean("items." + s + ".glowing"); - List lore = ShopConfig.getShop().getStringList("items." + s + ".lore"); + int slot = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".slot"); + ItemStack material = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".block")).get().parseItem(); + int cost = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".cost"); + String name = FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".name"); + boolean glowing = FactionsPlugin.getInstance().getFileManager().getShop().fetchBoolean("items." + s + ".glowing"); + List lore = FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".lore"); ItemStack item = new ItemStack(material); @@ -73,7 +73,7 @@ public class ShopGUIFrame { FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked()); if (fplayer.getFaction().getPoints() >= cost) { fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost); - runCommands(ShopConfig.getShop().getStringList("items." + s + ".cmds"), fplayer.getPlayer()); + runCommands(FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".cmds"), fplayer.getPlayer()); for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers()) { fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString() .replace("{player}", fplayer.getPlayer().getName()) diff --git a/src/main/java/com/massivecraft/factions/util/InventoryUtil.java b/src/main/java/com/massivecraft/factions/util/InventoryUtil.java index a6b0908e..ef9ad2b3 100644 --- a/src/main/java/com/massivecraft/factions/util/InventoryUtil.java +++ b/src/main/java/com/massivecraft/factions/util/InventoryUtil.java @@ -62,7 +62,7 @@ public class InventoryUtil { dataOutput.close(); return Base64Coder.encodeLines(outputStream.toByteArray()); } catch (Exception e) { - throw new IllegalStateException("Cannot into itemstacksz!", e); + throw new IllegalStateException("Cannot convert into itemstacks!", e); } } diff --git a/src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java b/src/main/java/com/massivecraft/factions/util/ParticleEffect.java similarity index 99% rename from src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java rename to src/main/java/com/massivecraft/factions/util/ParticleEffect.java index 4b58026a..ae840a9f 100644 --- a/src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java +++ b/src/main/java/com/massivecraft/factions/util/ParticleEffect.java @@ -1,5 +1,10 @@ -package com.massivecraft.factions.util.Particles; +package com.massivecraft.factions.util; +/** + * Factions - Developed by Driftay. + * All rights reserved 2020. + * Creation Date: 4/4/2020 + */ import com.massivecraft.factions.util.XMaterial; import org.bukkit.Bukkit; import org.bukkit.Color; @@ -1595,4 +1600,4 @@ public enum ParticleEffect { } } } -} \ No newline at end of file +} diff --git a/src/main/java/com/massivecraft/factions/util/Particles/Particles.java b/src/main/java/com/massivecraft/factions/util/Particles/Particles.java deleted file mode 100644 index 2d7177a1..00000000 --- a/src/main/java/com/massivecraft/factions/util/Particles/Particles.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.massivecraft.factions.util.Particles; - -import com.massivecraft.factions.FactionsPlugin; -import org.bukkit.Color; -import org.bukkit.Location; -import org.bukkit.Particle; - -public enum Particles { - - - // Gotta use Strings or runtime errors on 1.8, the Particle class does not exist - CLOUD(ParticleEffect.CLOUD, "CLOUD"), - REDSTONE(ParticleEffect.REDSTONE, "REDSTONE"), - NOTE(ParticleEffect.NOTE, "NOTE"); - - - private ParticleEffect sub18; - private String over19; - - Particles(ParticleEffect sub18, String over19) { - this.sub18 = sub18; - this.over19 = over19; - } - - - public void displayAtLocation(Location location, int amt) { - if (FactionsPlugin.getInstance().useNonPacketParticles) { - // 1.9+ based servers will use the built in particleAPI instead of packet based. - // any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working. - // So setting the amount to 0 spawns 1 in the precise location - location.getWorld().spawnParticle(Particle.valueOf(over19), location, 0); - } else { - sub18.display((float) 0, (float) 0, (float) 0, (float) 0, amt, location, 16); - } - } - - public void displayAtLocation(Location location, int amt, ParticleEffect.OrdinaryColor color) { - if (FactionsPlugin.getInstance().useNonPacketParticles) { - // 1.9-1.11 & 1.13+ based servers will use the built in particleAPI instead of packet based. - // any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working. - // So setting the amount to 0 spawns 1 in the precise location - - - // Gotta do this so colorable ones have their data :FactionsPlugin - if (this == Particles.REDSTONE || this == Particles.CLOUD || this == Particles.NOTE) { - if (FactionsPlugin.getInstance().mc112) { - location.getWorld().spawnParticle(Particle.valueOf(over19), location, 0); - } else { - location.getWorld().spawnParticle(Particle.valueOf(over19), location, 0, new Particle.DustOptions(Color.fromRGB(color.getRed(), color.getGreen(), color.getBlue()), 1)); - } - } else { - location.getWorld().spawnParticle(Particle.valueOf(over19), location, 0); - } - } else { - sub18.display(color, location, 16); - - } - } -} diff --git a/src/main/java/com/massivecraft/factions/util/Particles/ReflectionUtils.java b/src/main/java/com/massivecraft/factions/util/ReflectionUtils.java similarity index 99% rename from src/main/java/com/massivecraft/factions/util/Particles/ReflectionUtils.java rename to src/main/java/com/massivecraft/factions/util/ReflectionUtils.java index 7ddf979c..bb199159 100644 --- a/src/main/java/com/massivecraft/factions/util/Particles/ReflectionUtils.java +++ b/src/main/java/com/massivecraft/factions/util/ReflectionUtils.java @@ -1,5 +1,10 @@ -package com.massivecraft.factions.util.Particles; +package com.massivecraft.factions.util; +/** + * Factions - Developed by Driftay. + * All rights reserved 2020. + * Creation Date: 4/4/2020 + */ import org.bukkit.Bukkit; import java.lang.reflect.Constructor; @@ -605,4 +610,4 @@ public final class ReflectionUtils { return reference; } } -} \ No newline at end of file +} diff --git a/src/main/java/com/massivecraft/factions/util/TimeUtil.java b/src/main/java/com/massivecraft/factions/util/TimeUtil.java deleted file mode 100644 index 8c5bcd43..00000000 --- a/src/main/java/com/massivecraft/factions/util/TimeUtil.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.massivecraft.factions.util; - -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.concurrent.TimeUnit; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Factions - Developed by Driftay. - * All rights reserved 2020. - * Creation Date: 1/30/2020 - */ -public class TimeUtil { - - public static long parseDateDiff(String time, boolean future) throws Exception { - Pattern timePattern = Pattern.compile("(?:([0-9]+)\\s*y[a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:s[a-z]*)?)?", 2); - Matcher m = timePattern.matcher(time); - int years = 0; - int months = 0; - int weeks = 0; - int days = 0; - int hours = 0; - int minutes = 0; - int seconds = 0; - boolean found = false; - while (m.find()) { - if (m.group() != null) { - if (m.group().isEmpty()) continue; - for (int i = 0; i < m.groupCount(); ++i) { - if (m.group(i) != null && !m.group(i).isEmpty()) { - found = true; - break; - } - } - if (!found) continue; - - if (m.group(1) != null && !m.group(1).isEmpty()) years = Integer.parseInt(m.group(1)); - - if (m.group(2) != null && !m.group(2).isEmpty()) months = Integer.parseInt(m.group(2)); - - if (m.group(3) != null && !m.group(3).isEmpty()) weeks = Integer.parseInt(m.group(3)); - - if (m.group(4) != null && !m.group(4).isEmpty()) days = Integer.parseInt(m.group(4)); - - if (m.group(5) != null && !m.group(5).isEmpty()) hours = Integer.parseInt(m.group(5)); - - if (m.group(6) != null && !m.group(6).isEmpty()) minutes = Integer.parseInt(m.group(6)); - - if (m.group(7) != null && !m.group(7).isEmpty()) { - seconds = Integer.parseInt(m.group(7)); - break; - } - break; - } - } - if (!found) throw new Exception("Illegal Date"); - - if (years > 20) throw new Exception("Illegal Date"); - - Calendar c = new GregorianCalendar(); - if (years > 0) c.add(Calendar.YEAR, years * (future ? 1 : -1)); - - if (months > 0) c.add(Calendar.MONTH, months * (future ? 1 : -1)); - - if (weeks > 0) c.add(Calendar.WEEK_OF_YEAR, weeks * (future ? 1 : -1)); - - if (days > 0) c.add(Calendar.DATE, days * (future ? 1 : -1)); - - if (hours > 0) c.add(Calendar.HOUR_OF_DAY, hours * (future ? 1 : -1)); - - if (minutes > 0) c.add(Calendar.MINUTE, minutes * (future ? 1 : -1)); - - if (seconds > 0) c.add(Calendar.SECOND, seconds * (future ? 1 : -1)); - - System.out.println("current: " + c.getTimeInMillis() + " Time: " + System.currentTimeMillis() + " Form: " + formatTime(c.getTimeInMillis() / 1000L)); - return c.getTimeInMillis() / 1000L; - } - - public static String formatDifference(long time) { - if (time == 0L) return "Never"; - - long day = TimeUnit.SECONDS.toDays(time); - long hours = TimeUnit.SECONDS.toHours(time) - day * 24L; - long minutes = TimeUnit.SECONDS.toMinutes(time) - TimeUnit.SECONDS.toHours(time) * 60L; - long seconds = TimeUnit.SECONDS.toSeconds(time) - TimeUnit.SECONDS.toMinutes(time) * 60L; - StringBuilder sb = new StringBuilder(); - if (day > 0L) sb.append(day).append((day == 1L) ? "day" : "days").append(" "); - - if (hours > 0L) sb.append(hours).append((hours == 1L) ? "h" : "h").append(" "); - - if (minutes > 0L) sb.append(minutes).append((minutes == 1L) ? "m" : "m").append(" "); - - if (seconds > 0L) sb.append(seconds).append((seconds == 1L) ? "s" : "s"); - - String diff = sb.toString().trim(); - return diff.isEmpty() ? "Now" : diff; - } - - public static String formatTime(long time) { - if (time == System.currentTimeMillis()) return "Now"; - - if (time == -1L) return "Never"; - - return formatDifference(time - System.currentTimeMillis() / 1000L); - } -} - diff --git a/src/main/java/com/massivecraft/factions/util/Updater.java b/src/main/java/com/massivecraft/factions/util/Updater.java deleted file mode 100644 index 60a69a59..00000000 --- a/src/main/java/com/massivecraft/factions/util/Updater.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.massivecraft.factions.util; - -import com.massivecraft.factions.FactionsPlugin; -import org.bukkit.configuration.file.FileConfiguration; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -public class Updater { - public static double currentVersion = 1.1; - - public static void updateIfNeeded(FileConfiguration conf) { - double version = conf.getDouble("Config-Version", 0); - //Previous version - if (version == 0) { - //Instructions for this configuration to be updated to current - FactionsPlugin.getInstance().log("Your config.yml is pre-versioning so we are going to assign it version 1.0 \n Please regenerate your config.yml if you run into any errors relating to config."); - conf.set("Config-Version", 1.0); - version = 1.0; - } - if (version == 1.0) { - FactionsPlugin.getInstance().log("Updating config from version 1.0 to 1.1"); - FactionsPlugin.getInstance().log("Adding randomization support for f missions..."); - conf.set("Randomization.Enabled", false); - conf.set("Randomization.Start-Item.Allowed.Name", "&aStart!"); - conf.set("Randomization.Start-Item.Allowed.Material", "GREEN_STAINED_GLASS_PANE"); - List lore = new ArrayList<>(); - lore.add("&aStart a new mission!"); - conf.set("Randomization.Start-Item.Allowed.Lore", lore); - conf.set("Randomization.Start-Item.Disallowed.Name", "&4Cannot start new mission"); - conf.set("Randomization.Start-Item.Disallowed.Material", "GRAY_STAINED_GLASS_PANE"); - lore.clear(); - lore.add("&4%reason%"); - conf.set("Randomization.Start-Item.Disallowed.Lore", lore); - conf.set("Randomization.Start-Item.Slot", 28); - conf.set("Config-Version", 1.1); - currentVersion = 1.1; - } - //End with save + reload - try { - conf.save(new File("plugins/Factions/config.yml")); - FactionsPlugin.getInstance().reloadConfig(); - } catch (IOException e) { - e.printStackTrace(); - } - } -} diff --git a/src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/adapters/EnumTypeAdapter.java similarity index 97% rename from src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java rename to src/main/java/com/massivecraft/factions/util/adapters/EnumTypeAdapter.java index f5b2b975..d126930f 100644 --- a/src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/adapters/EnumTypeAdapter.java @@ -1,4 +1,4 @@ -package com.massivecraft.factions.util; +package com.massivecraft.factions.util.adapters; import com.google.gson.Gson; import com.google.gson.TypeAdapter; diff --git a/src/main/java/com/massivecraft/factions/util/InventoryTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/adapters/InventoryTypeAdapter.java similarity index 90% rename from src/main/java/com/massivecraft/factions/util/InventoryTypeAdapter.java rename to src/main/java/com/massivecraft/factions/util/adapters/InventoryTypeAdapter.java index e883a4d5..abdc1985 100644 --- a/src/main/java/com/massivecraft/factions/util/InventoryTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/adapters/InventoryTypeAdapter.java @@ -1,7 +1,8 @@ -package com.massivecraft.factions.util; +package com.massivecraft.factions.util.adapters; import com.google.gson.*; import com.massivecraft.factions.FactionsPlugin; +import com.massivecraft.factions.util.InventoryUtil; import org.bukkit.inventory.Inventory; import java.lang.reflect.Type; diff --git a/src/main/java/com/massivecraft/factions/util/LocationTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/adapters/LocationTypeAdapter.java similarity index 97% rename from src/main/java/com/massivecraft/factions/util/LocationTypeAdapter.java rename to src/main/java/com/massivecraft/factions/util/adapters/LocationTypeAdapter.java index d04383a0..61010948 100644 --- a/src/main/java/com/massivecraft/factions/util/LocationTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/adapters/LocationTypeAdapter.java @@ -1,4 +1,4 @@ -package com.massivecraft.factions.util; +package com.massivecraft.factions.util.adapters; import com.google.gson.*; import com.massivecraft.factions.FactionsPlugin; diff --git a/src/main/java/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/adapters/MapFLocToStringSetTypeAdapter.java similarity index 98% rename from src/main/java/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java rename to src/main/java/com/massivecraft/factions/util/adapters/MapFLocToStringSetTypeAdapter.java index 2006a898..e7d56183 100644 --- a/src/main/java/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/adapters/MapFLocToStringSetTypeAdapter.java @@ -1,4 +1,4 @@ -package com.massivecraft.factions.util; +package com.massivecraft.factions.util.adapters; import com.google.gson.*; import com.massivecraft.factions.FLocation; diff --git a/src/main/java/com/massivecraft/factions/util/MyLocationTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/adapters/MyLocationTypeAdapter.java similarity index 95% rename from src/main/java/com/massivecraft/factions/util/MyLocationTypeAdapter.java rename to src/main/java/com/massivecraft/factions/util/adapters/MyLocationTypeAdapter.java index 8ce59598..1adfe8f4 100644 --- a/src/main/java/com/massivecraft/factions/util/MyLocationTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/adapters/MyLocationTypeAdapter.java @@ -1,7 +1,8 @@ -package com.massivecraft.factions.util; +package com.massivecraft.factions.util.adapters; import com.google.gson.*; import com.massivecraft.factions.FactionsPlugin; +import com.massivecraft.factions.util.LazyLocation; import java.lang.reflect.Type; import java.util.logging.Level; diff --git a/src/main/java/com/massivecraft/factions/util/PermissionsMapTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/adapters/PermissionsMapTypeAdapter.java similarity index 98% rename from src/main/java/com/massivecraft/factions/util/PermissionsMapTypeAdapter.java rename to src/main/java/com/massivecraft/factions/util/adapters/PermissionsMapTypeAdapter.java index d5a7f661..cc6773fe 100644 --- a/src/main/java/com/massivecraft/factions/util/PermissionsMapTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/adapters/PermissionsMapTypeAdapter.java @@ -1,4 +1,4 @@ -package com.massivecraft.factions.util; +package com.massivecraft.factions.util.adapters; import com.google.gson.*; import com.massivecraft.factions.FactionsPlugin; diff --git a/src/main/java/com/massivecraft/factions/util/exceptions/SaberException.java b/src/main/java/com/massivecraft/factions/util/exceptions/SaberException.java deleted file mode 100644 index c71ee835..00000000 --- a/src/main/java/com/massivecraft/factions/util/exceptions/SaberException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.massivecraft.factions.util.exceptions; - -/** - * @author Saser - */ - -public abstract class SaberException extends Exception { - public SaberException(String message) { - super(message); - } -} diff --git a/src/main/java/com/massivecraft/factions/util/exceptions/impl/DiscordException.java b/src/main/java/com/massivecraft/factions/util/exceptions/impl/DiscordException.java deleted file mode 100644 index 9956fb0e..00000000 --- a/src/main/java/com/massivecraft/factions/util/exceptions/impl/DiscordException.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.massivecraft.factions.util.exceptions.impl; - -import com.massivecraft.factions.util.exceptions.SaberException; - -/** - * @author Saser - */ -public class DiscordException extends SaberException { - public DiscordException(String message) { - super(message); - } -} diff --git a/src/main/java/com/massivecraft/factions/util/wait/WaitExecutor.java b/src/main/java/com/massivecraft/factions/util/wait/WaitExecutor.java new file mode 100644 index 00000000..d9bdd616 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/util/wait/WaitExecutor.java @@ -0,0 +1,46 @@ +package com.massivecraft.factions.util.wait; + + +import com.massivecraft.factions.FactionsPlugin; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import java.util.concurrent.ConcurrentHashMap; + +/** + * Factions - Developed by Driftay. + * All rights reserved 2020. + * Creation Date: 4/4/2020 + */ +public class WaitExecutor { + private static boolean enabled = false; + public static ConcurrentHashMap taskMap = new ConcurrentHashMap<>(); + + public static void startTask() { + if (enabled) return; + Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.instance, () -> + { + for (WaitTask task : taskMap.values()) { + int i = task.getWait() - 1; + if (i > 0) { + if (i != 1) { + task.getPlayer().sendMessage(task.getMessage().format((i + " Seconds"))); + } else { + task.getPlayer().sendMessage(task.getMessage().format((i + " Second"))); + } + task.setWait(i); + } else { + task.success(); + taskMap.remove(task.getPlayer()); + } + } + }, 0L, 20L); + enabled = true; + } + + public static void handleAction(Player player) { + if (!taskMap.containsKey(player)) return; + taskMap.get(player).fail(); + taskMap.remove(player); + } +} \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/util/wait/WaitTask.java b/src/main/java/com/massivecraft/factions/util/wait/WaitTask.java new file mode 100644 index 00000000..eb84647f --- /dev/null +++ b/src/main/java/com/massivecraft/factions/util/wait/WaitTask.java @@ -0,0 +1,47 @@ +package com.massivecraft.factions.util.wait; + +import com.massivecraft.factions.zcore.util.TL; +import org.bukkit.entity.Player; + +/** + * @author droppinganvil + */ + +public class WaitTask { + private Integer wait; + private TL msg; + //Using player as to not have to convert every event + private Player player; + private WaitedTask origin; + + public WaitTask(Integer wait, TL message, Player player, WaitedTask waitedTask) { + this.wait = wait; + this.msg = message; + this.player = player; + this.origin = waitedTask; + } + + public Integer getWait() { + return wait; + } + + public TL getMessage() { + return msg; + } + + public Player getPlayer() { + return player; + } + + public void setWait(Integer i) { + wait = i; + } + + public void success() { + origin.handleSuccess(player); + } + + public void fail() { + origin.handleFailure(player); + } +} diff --git a/src/main/java/com/massivecraft/factions/util/wait/WaitedTask.java b/src/main/java/com/massivecraft/factions/util/wait/WaitedTask.java new file mode 100644 index 00000000..0f331cf2 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/util/wait/WaitedTask.java @@ -0,0 +1,14 @@ +package com.massivecraft.factions.util.wait; + +import org.bukkit.entity.Player; + +/** + * Factions - Developed by Driftay. + * All rights reserved 2020. + * Creation Date: 4/4/2020 + */ +public interface WaitedTask { + void handleSuccess(Player player); + + void handleFailure(Player player); +} diff --git a/src/main/java/com/massivecraft/factions/zcore/file/CustomFile.java b/src/main/java/com/massivecraft/factions/zcore/file/CustomFile.java new file mode 100644 index 00000000..c5c87c17 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/zcore/file/CustomFile.java @@ -0,0 +1,141 @@ +package com.massivecraft.factions.zcore.file; + +import com.massivecraft.factions.FactionsPlugin; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; + +/** + * Factions - Developed by Driftay. + * All rights reserved 2020. + * Creation Date: 4/4/2020 + */ +public class CustomFile { + + private File file; + private YamlConfiguration fileConfig; + private HashMap cachedObjects = new HashMap<>(); + + public CustomFile(File file) { + this.file = file; + this.fileConfig = YamlConfiguration.loadConfiguration(file); + } + + public void setup(boolean loadFromProject, String inFolder) { + if (!getFile().exists()) { + if (loadFromProject) { + if (!inFolder.equalsIgnoreCase("")) { + FactionsPlugin.getInstance().saveResource(inFolder + "/" + file.getName(), false); + } else { + FactionsPlugin.getInstance().saveResource(file.getName(), false); + } + } else { + try { + getFile().createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + loadFile(); + } + + public void loadFile() { + this.fileConfig = YamlConfiguration.loadConfiguration(file); + this.cachedObjects.clear(); // remove cached objects + } + + public void saveFile() { + try { + getConfig().save(file); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public String fetchString(String key) { + return (String) getObj(key, dataTypes.STRING); + } + + public int fetchInt(String key) { + return (int) getObj(key, dataTypes.INT); + } + + public double fetchDouble(String key) { + return (double) getObj(key, dataTypes.DOUBLE); + } + + public List fetchStringList(String key) { + return (List) getObj(key, dataTypes.STRINGLIST); + } + + public boolean fetchBoolean(String key) { + return (boolean) getObj(key, dataTypes.BOOLEAN); + } + + public Object getObj(String key, Enum data) { + //check for cache first + + if (getCachedObjects().containsKey(key)) { + return getCachedObjects().get(key); + } + + if (data.equals(dataTypes.STRING)) { + String d = getConfig().getString(key); + this.cachedObjects.put(key, d); + return d; + } + + if (data.equals(dataTypes.DOUBLE)) { + double d = getConfig().getDouble(key); + this.cachedObjects.put(key, d); + return d; + } + + if (data.equals(dataTypes.INT)) { + int d = getConfig().getInt(key); + this.cachedObjects.put(key, d); + return d; + } + + if (data.equals(dataTypes.BOOLEAN)) { + boolean d = getConfig().getBoolean(key); + this.cachedObjects.put(key, d); + return d; + } + + if (data.equals(dataTypes.STRINGLIST)) { + List d = getConfig().getStringList(key); + this.cachedObjects.put(key, d); + return d; + } + return null; + } + + public HashMap getCachedObjects() { + return cachedObjects; + } + + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } + + public void setFileConfig(YamlConfiguration fileConfig) { + this.fileConfig = fileConfig; + } + + public YamlConfiguration getConfig() { + return fileConfig; + } + + public enum dataTypes { + STRING, INT, DOUBLE, STRINGLIST, BOOLEAN, MAP + } +} diff --git a/src/main/java/com/massivecraft/factions/zcore/file/impl/FileManager.java b/src/main/java/com/massivecraft/factions/zcore/file/impl/FileManager.java new file mode 100644 index 00000000..a16b840d --- /dev/null +++ b/src/main/java/com/massivecraft/factions/zcore/file/impl/FileManager.java @@ -0,0 +1,25 @@ +package com.massivecraft.factions.zcore.file.impl; + +import com.massivecraft.factions.FactionsPlugin; +import com.massivecraft.factions.zcore.file.CustomFile; + +import java.io.File; + +/** + * Factions - Developed by Driftay. + * All rights reserved 2020. + * Creation Date: 4/4/2020 + */ +public class FileManager { + + private CustomFile shop = new CustomFile(new File(FactionsPlugin.getInstance().getDataFolder() + "/shop.yml")); + + public void setupFiles() { + shop.setup(true, ""); + } + + + public CustomFile getShop() { + return shop; + } +} diff --git a/src/main/java/com/massivecraft/factions/util/FactionGUI.java b/src/main/java/com/massivecraft/factions/zcore/frame/FactionGUI.java similarity index 82% rename from src/main/java/com/massivecraft/factions/util/FactionGUI.java rename to src/main/java/com/massivecraft/factions/zcore/frame/FactionGUI.java index c9d964ee..618c22e9 100644 --- a/src/main/java/com/massivecraft/factions/util/FactionGUI.java +++ b/src/main/java/com/massivecraft/factions/zcore/frame/FactionGUI.java @@ -1,4 +1,4 @@ -package com.massivecraft.factions.util; +package com.massivecraft.factions.zcore.frame; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.InventoryHolder; diff --git a/src/main/java/com/massivecraft/factions/zcore/fdisband/FDisbandFrame.java b/src/main/java/com/massivecraft/factions/zcore/frame/fdisband/FDisbandFrame.java similarity index 98% rename from src/main/java/com/massivecraft/factions/zcore/fdisband/FDisbandFrame.java rename to src/main/java/com/massivecraft/factions/zcore/frame/fdisband/FDisbandFrame.java index f2831366..b53f47b5 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fdisband/FDisbandFrame.java +++ b/src/main/java/com/massivecraft/factions/zcore/frame/fdisband/FDisbandFrame.java @@ -1,4 +1,4 @@ -package com.massivecraft.factions.zcore.fdisband; +package com.massivecraft.factions.zcore.frame.fdisband; import com.github.stefvanschie.inventoryframework.Gui; import com.github.stefvanschie.inventoryframework.GuiItem; diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradeFrame.java b/src/main/java/com/massivecraft/factions/zcore/frame/fupgrades/FUpgradeFrame.java similarity index 98% rename from src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradeFrame.java rename to src/main/java/com/massivecraft/factions/zcore/frame/fupgrades/FUpgradeFrame.java index cd0a327f..89ed6f2d 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradeFrame.java +++ b/src/main/java/com/massivecraft/factions/zcore/frame/fupgrades/FUpgradeFrame.java @@ -1,4 +1,4 @@ -package com.massivecraft.factions.zcore.fupgrades; +package com.massivecraft.factions.zcore.frame.fupgrades; import com.github.stefvanschie.inventoryframework.Gui; import com.github.stefvanschie.inventoryframework.GuiItem; diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/UpgradeType.java b/src/main/java/com/massivecraft/factions/zcore/frame/fupgrades/UpgradeType.java similarity index 98% rename from src/main/java/com/massivecraft/factions/zcore/fupgrades/UpgradeType.java rename to src/main/java/com/massivecraft/factions/zcore/frame/fupgrades/UpgradeType.java index 9c84f6db..70f70ef6 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/UpgradeType.java +++ b/src/main/java/com/massivecraft/factions/zcore/frame/fupgrades/UpgradeType.java @@ -1,4 +1,4 @@ -package com.massivecraft.factions.zcore.fupgrades; +package com.massivecraft.factions.zcore.frame.fupgrades; import com.massivecraft.factions.Faction; import com.massivecraft.factions.FactionsPlugin; diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/UpgradesListener.java b/src/main/java/com/massivecraft/factions/zcore/frame/fupgrades/UpgradesListener.java similarity index 99% rename from src/main/java/com/massivecraft/factions/zcore/fupgrades/UpgradesListener.java rename to src/main/java/com/massivecraft/factions/zcore/frame/fupgrades/UpgradesListener.java index 21c90b7b..b6a0d472 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/UpgradesListener.java +++ b/src/main/java/com/massivecraft/factions/zcore/frame/fupgrades/UpgradesListener.java @@ -1,4 +1,4 @@ -package com.massivecraft.factions.zcore.fupgrades; +package com.massivecraft.factions.zcore.frame.fupgrades; import com.massivecraft.factions.*; import com.massivecraft.factions.util.XMaterial; diff --git a/src/main/java/com/massivecraft/factions/util/FactionWarpsFrame.java b/src/main/java/com/massivecraft/factions/zcore/frame/fwarps/FactionWarpsFrame.java similarity index 95% rename from src/main/java/com/massivecraft/factions/util/FactionWarpsFrame.java rename to src/main/java/com/massivecraft/factions/zcore/frame/fwarps/FactionWarpsFrame.java index 8ce7bc95..31be3e85 100644 --- a/src/main/java/com/massivecraft/factions/util/FactionWarpsFrame.java +++ b/src/main/java/com/massivecraft/factions/zcore/frame/fwarps/FactionWarpsFrame.java @@ -1,4 +1,4 @@ -package com.massivecraft.factions.util; +package com.massivecraft.factions.zcore.frame.fwarps; import com.github.stefvanschie.inventoryframework.Gui; import com.github.stefvanschie.inventoryframework.GuiItem; @@ -8,6 +8,10 @@ import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.factions.util.LazyLocation; +import com.massivecraft.factions.util.Placeholder; +import com.massivecraft.factions.util.WarmUpUtil; +import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java index 42329f40..5ca53382 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -863,12 +863,14 @@ public abstract class MemoryFPlayer implements FPlayer { return true; } else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW) { return true; + } else if (currentFaction.isWilderness() && forFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW) { + return true; } else if (myFaction != forFaction) { error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this)); } else if (forFaction == currentFaction) { error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_ALREADYOWN.toString(), forFaction.describeTo(this, true)); - } else if (this.getRole().value < Role.MODERATOR.value) { - error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_MUSTBE.toString(), Role.MODERATOR.getTranslation()); + } else if (forFaction.getAccess(this, PermissableAction.TERRITORY) != Access.ALLOW) { + error = TL.COMMAND_CLAIM_DENIED.toString(); } else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) { error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_MEMBERS.toString(), Conf.claimsRequireMinFactionMembers); } else if (currentFaction.isSafeZone()) { diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java index 573425b8..37bc7be6 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -20,7 +20,7 @@ import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.fperms.PermissableAction; -import com.massivecraft.factions.zcore.fupgrades.UpgradeType; +import com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType; import com.massivecraft.factions.zcore.util.TL; import net.dv8tion.jda.core.entities.Member; import org.bukkit.Bukkit; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 081e2efc..f967120c 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -405,6 +405,7 @@ help: - '&c/f points &8- &7Check your factions points.' - '&c/f invsee &8- &7Check a faction members inventory.' - '&c/f stealth &8- &7Go into stealth mode to not disable enemies flight.' + - '&c/f notifications &8- &7Disable or enable faction claim notifications.' - '&7&m--------------------&r &e/f help &7&m-----------------------' ############################################################ # +------------------------------------------------------+ # @@ -625,7 +626,6 @@ f-check: #This option is to see if another faction member can see their faction members that have the invisible potion effect See-Invisible-Faction-Members: false #ONLY WHEN SCOREBOARD IS ENABLED - ############################################################ # +------------------------------------------------------+ # # | Faction Inventory See | # @@ -634,6 +634,7 @@ See-Invisible-Faction-Members: false #ONLY WHEN SCOREBOARD IS ENABLED #This option is the ability to see other faction members inventories f-inventory-see: Enabled: true + ############################################################ # +------------------------------------------------------+ # # | Faction Alt Accounts | # @@ -745,7 +746,6 @@ fcooldowns: Falling-Block-Fix: enabled: true - ############################################################ # +------------------------------------------------------+ # # | Faction Disband | # @@ -769,8 +769,6 @@ f-disband-gui: Name: ' ' Lore: - - ############################################################ # +------------------------------------------------------+ # # | Faction GracePeriod | # diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index ec1d7b1f..246a551f 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -66,6 +66,7 @@ permissions: factions.kit.halfplayer: description: Can do all but create factions. children: + factions.check: true factions.audit: true factions.drain: true factions.wild: true diff --git a/src/main/resources/shop.yml b/src/main/resources/shop.yml new file mode 100644 index 00000000..f75a4151 --- /dev/null +++ b/src/main/resources/shop.yml @@ -0,0 +1,36 @@ +prefix: '&4&lFactionShop&8» &7Purchased &f%item% &7for &b%points% Points&7!' + +items: + '1': + slot: 1 + block: STONE #Validated Through XMaterial Class Located At: https://github.com/SaberLLC/Saber-Factions/blob/1.6.x/src/main/java/com/massivecraft/factions/util/XMaterial.java + name: '&aShop Item 1' #Display name of the item wanted in shop. + lore: + - '&cFully Customizable Lore!' + - '&b&l{cost} &7Points' + cmds: #You can have more then 1 command in this as it is a list of commands! + - broadcast %player% bought Test Shop! + cost: 5 #The number of faction points it will cost to buy this item. + glowing: true #Do we want it to glow or not? + '2': + slot: 2 + block: STONE #Validated Through XMaterial Class Located At: https://github.com/SaberLLC/Saber-Factions/blob/1.6.x/src/main/java/com/massivecraft/factions/util/XMaterial.java + name: '&aShop Item 2' #Display name of the item wanted in shop. + lore: + - '&cFully Customizable Lore!' + - '&b&l{cost} &7Points' + cmds: #You can have more then 1 command in this as it is a list of commands! + - broadcast %player% bought Test Shop! + cost: 5 #The number of faction points it will cost to buy this item. + glowing: true #Do we want it to glow or not? + '3': + slot: 3 + block: STONE #Validated Through XMaterial Class Located At: https://github.com/SaberLLC/Saber-Factions/blob/1.6.x/src/main/java/com/massivecraft/factions/util/XMaterial.java + name: '&aShop Item 3' #Display name of the item wanted in shop. + lore: + - '&cFully Customizable Lore!' + - '&b&l{cost} &7Points' + cmds: #You can have more then 1 command in this as it is a list of commands! + - broadcast %player% bought Test Shop! + cost: 5 #The number of faction points it will cost to buy this item. + glowing: true #Do we want it to glow or not? \ No newline at end of file