├── gradle.properties ├── addons ├── skins │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── config.yml │ │ │ └── java │ │ │ └── xyz │ │ │ └── jpenilla │ │ │ └── squaremap │ │ │ └── addon │ │ │ └── skins │ │ │ └── SquaremapSkins.java │ ├── build.gradle.kts │ └── README.md ├── deathspot │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── icon.png │ │ │ └── java │ │ │ └── xyz │ │ │ └── jpenilla │ │ │ └── squaremap │ │ │ └── addon │ │ │ └── deathspot │ │ │ ├── config │ │ │ ├── DeathSpotConfig.java │ │ │ └── DeathSpotWorldConfig.java │ │ │ ├── listener │ │ │ └── PlayerListener.java │ │ │ ├── DeathSpots.java │ │ │ ├── task │ │ │ └── SquaremapTask.java │ │ │ └── hook │ │ │ └── SquaremapHook.java │ └── build.gradle.kts ├── essentialsx │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── warp.png │ │ │ └── java │ │ │ └── xyz │ │ │ └── jpenilla │ │ │ └── squaremap │ │ │ └── addon │ │ │ └── essentialsx │ │ │ ├── hook │ │ │ ├── EssentialsHook.java │ │ │ └── SquaremapHook.java │ │ │ ├── config │ │ │ ├── EssXConfig.java │ │ │ └── EssXWorldConfig.java │ │ │ ├── SquaremapEssentials.java │ │ │ ├── listener │ │ │ └── EssentialsListener.java │ │ │ └── task │ │ │ └── SquaremapTask.java │ └── build.gradle.kts ├── mobs │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── icons │ │ │ │ ├── bat.png │ │ │ │ ├── bee.png │ │ │ │ ├── blaze.png │ │ │ │ ├── cat.png │ │ │ │ ├── cod.png │ │ │ │ ├── cow.png │ │ │ │ ├── fox.png │ │ │ │ ├── ghast.png │ │ │ │ ├── giant.png │ │ │ │ ├── horse.png │ │ │ │ ├── husk.png │ │ │ │ ├── llama.png │ │ │ │ ├── mule.png │ │ │ │ ├── panda.png │ │ │ │ ├── pig.png │ │ │ │ ├── sheep.png │ │ │ │ ├── slime.png │ │ │ │ ├── squid.png │ │ │ │ ├── stray.png │ │ │ │ ├── vex.png │ │ │ │ ├── witch.png │ │ │ │ ├── wolf.png │ │ │ │ ├── chicken.png │ │ │ │ ├── creeper.png │ │ │ │ ├── dolphin.png │ │ │ │ ├── donkey.png │ │ │ │ ├── drowned.png │ │ │ │ ├── evoker.png │ │ │ │ ├── hoglin.png │ │ │ │ ├── ocelot.png │ │ │ │ ├── parrot.png │ │ │ │ ├── phantom.png │ │ │ │ ├── piglin.png │ │ │ │ ├── rabbit.png │ │ │ │ ├── ravager.png │ │ │ │ ├── salmon.png │ │ │ │ ├── shulker.png │ │ │ │ ├── spider.png │ │ │ │ ├── strider.png │ │ │ │ ├── turtle.png │ │ │ │ ├── wither.png │ │ │ │ ├── zoglin.png │ │ │ │ ├── zombie.png │ │ │ │ ├── enderman.png │ │ │ │ ├── endermite.png │ │ │ │ ├── guardian.png │ │ │ │ ├── illusioner.png │ │ │ │ ├── iron_golem.png │ │ │ │ ├── magma_cube.png │ │ │ │ ├── mooshroom.png │ │ │ │ ├── pillager.png │ │ │ │ ├── polar_bear.png │ │ │ │ ├── pufferfish.png │ │ │ │ ├── silverfish.png │ │ │ │ ├── skeleton.png │ │ │ │ ├── snow_golem.png │ │ │ │ ├── villager.png │ │ │ │ ├── vindicator.png │ │ │ │ ├── cave_spider.png │ │ │ │ ├── ender_dragon.png │ │ │ │ ├── killer_bunny.png │ │ │ │ ├── piglin_brute.png │ │ │ │ ├── trader_llama.png │ │ │ │ ├── zombie_horse.png │ │ │ │ ├── elder_guardian.png │ │ │ │ ├── skeleton_horse.png │ │ │ │ ├── tropical_fish.png │ │ │ │ ├── wither_skeleton.png │ │ │ │ ├── zombie_villager.png │ │ │ │ ├── wandering_trader.png │ │ │ │ ├── zombified_piglin.png │ │ │ │ └── trader_llama.png:Zone.Identifier │ │ │ └── java │ │ │ └── xyz │ │ │ └── jpenilla │ │ │ └── squaremap │ │ │ └── addon │ │ │ └── mobs │ │ │ ├── config │ │ │ ├── MobsConfig.java │ │ │ └── MobsWorldConfig.java │ │ │ ├── SquaremapMobs.java │ │ │ ├── hook │ │ │ └── SquaremapHook.java │ │ │ ├── task │ │ │ └── SquaremapTask.java │ │ │ └── data │ │ │ └── Icons.java │ └── build.gradle.kts ├── banners │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── icons │ │ │ │ ├── BLUE.png │ │ │ │ ├── CYAN.png │ │ │ │ ├── GRAY.png │ │ │ │ ├── LIME.png │ │ │ │ ├── PINK.png │ │ │ │ ├── RED.png │ │ │ │ ├── BLACK.png │ │ │ │ ├── BROWN.png │ │ │ │ ├── GREEN.png │ │ │ │ ├── MAGENTA.png │ │ │ │ ├── ORANGE.png │ │ │ │ ├── PURPLE.png │ │ │ │ ├── WHITE.png │ │ │ │ ├── YELLOW.png │ │ │ │ ├── LIGHT_BLUE.png │ │ │ │ └── LIGHT_GRAY.png │ │ │ └── java │ │ │ └── xyz │ │ │ └── jpenilla │ │ │ └── squaremap │ │ │ └── addon │ │ │ └── banners │ │ │ ├── data │ │ │ ├── Data.java │ │ │ ├── Position.java │ │ │ ├── BannerLayerProvider.java │ │ │ ├── Icons.java │ │ │ └── BannersManager.java │ │ │ ├── configuration │ │ │ ├── BannersConfig.java │ │ │ └── BannersWorldConfig.java │ │ │ ├── listener │ │ │ ├── WorldListener.java │ │ │ └── BannersListener.java │ │ │ ├── hook │ │ │ └── SquaremapHook.java │ │ │ └── SquaremapBanners.java │ ├── README.md │ └── build.gradle.kts ├── signs │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── icons │ │ │ │ ├── sign_oak.png │ │ │ │ ├── sign_acacia.png │ │ │ │ ├── sign_birch.png │ │ │ │ ├── sign_jungle.png │ │ │ │ ├── sign_spruce.png │ │ │ │ ├── sign_warped.png │ │ │ │ ├── sign_crimson.png │ │ │ │ └── sign_dark_oak.png │ │ │ └── java │ │ │ └── xyz │ │ │ └── jpenilla │ │ │ └── squaremap │ │ │ └── addon │ │ │ └── signs │ │ │ ├── data │ │ │ ├── Data.java │ │ │ ├── SignType.java │ │ │ ├── Position.java │ │ │ ├── Icons.java │ │ │ ├── CustomIcons.java │ │ │ └── SignLayerProvider.java │ │ │ ├── config │ │ │ ├── SignsConfig.java │ │ │ └── SignsWorldConfig.java │ │ │ ├── listener │ │ │ ├── WorldListener.java │ │ │ └── SignListener.java │ │ │ ├── SignsPlugin.java │ │ │ └── hook │ │ │ └── LayerProviderManager.java │ ├── build.gradle.kts │ └── README.md ├── vanish │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── xyz │ │ │ └── jpenilla │ │ │ └── squaremap │ │ │ └── addon │ │ │ └── vanish │ │ │ ├── VanishAdapter.java │ │ │ ├── SuperVanish.java │ │ │ ├── VanishFallback.java │ │ │ └── SquaremapVanish.java │ ├── README.md │ └── build.gradle.kts ├── claimchunk │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── xyz │ │ └── jpenilla │ │ └── squaremap │ │ └── addon │ │ └── claimchunk │ │ ├── SquaremapClaimChunk.java │ │ ├── hook │ │ ├── ClaimChunkHook.java │ │ └── SquaremapHook.java │ │ ├── data │ │ ├── Claim.java │ │ └── Group.java │ │ ├── config │ │ └── ClaimChunkConfig.java │ │ └── util │ │ └── RectangleMerge.java ├── griefprevention │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── xyz │ │ └── jpenilla │ │ └── squaremap │ │ └── addon │ │ └── griefprevention │ │ ├── hook │ │ ├── GPHook.java │ │ └── SquaremapHook.java │ │ ├── SquaremapGriefPrevention.java │ │ ├── config │ │ └── GPConfig.java │ │ └── task │ │ └── SquaremapTask.java └── worldguard │ ├── build.gradle.kts │ └── src │ └── main │ └── java │ └── xyz │ └── jpenilla │ └── squaremap │ └── addon │ └── worldguard │ ├── EventListener.java │ ├── hook │ ├── WGHook.java │ └── SquaremapHook.java │ ├── config │ ├── WGWorldConfig.java │ ├── WGConfig.java │ └── StyleSettings.java │ ├── SquaremapWorldGuard.java │ └── task │ └── SquaremapTask.java ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .editorconfig ├── .gitignore ├── renovate.json ├── .gitattributes ├── .github └── workflows │ └── build.yml ├── common ├── build.gradle.kts └── src │ └── main │ └── java │ └── xyz │ └── jpenilla │ └── squaremap │ └── addon │ └── common │ ├── config │ ├── ListMode.java │ ├── ColorSerializer.java │ ├── ConfigUpgrader.java │ └── WorldConfig.java │ └── Util.java ├── settings.gradle.kts ├── gradlew.bat └── README.md /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.caching=true 2 | org.gradle.parallel=true 3 | -------------------------------------------------------------------------------- /addons/skins/src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | # How often to update skins (in seconds) 2 | update-interval: 60 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | charset = utf-8 3 | indent_size = 4 4 | indent_style = space 5 | insert_final_newline = true 6 | max_line_length = off 7 | -------------------------------------------------------------------------------- /addons/deathspot/src/main/resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/deathspot/src/main/resources/icon.png -------------------------------------------------------------------------------- /addons/essentialsx/src/main/resources/warp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/essentialsx/src/main/resources/warp.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/bat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/bat.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/bee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/bee.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/blaze.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/blaze.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/cat.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/cod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/cod.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/cow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/cow.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/fox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/fox.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/ghast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/ghast.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/giant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/giant.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/horse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/horse.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/husk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/husk.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/llama.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/llama.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/mule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/mule.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/panda.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/panda.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/pig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/pig.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/sheep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/sheep.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/slime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/slime.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/squid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/squid.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/stray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/stray.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/vex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/vex.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/witch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/witch.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/wolf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/wolf.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | .idea/ 7 | /run/ 8 | -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/BLUE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/BLUE.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/CYAN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/CYAN.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/GRAY.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/GRAY.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/LIME.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/LIME.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/PINK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/PINK.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/RED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/RED.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/chicken.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/chicken.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/creeper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/creeper.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/dolphin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/dolphin.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/donkey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/donkey.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/drowned.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/drowned.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/evoker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/evoker.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/hoglin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/hoglin.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/ocelot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/ocelot.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/parrot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/parrot.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/phantom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/phantom.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/piglin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/piglin.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/rabbit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/rabbit.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/ravager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/ravager.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/salmon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/salmon.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/shulker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/shulker.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/spider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/spider.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/strider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/strider.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/turtle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/turtle.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/wither.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/wither.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/zoglin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/zoglin.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/zombie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/zombie.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/BLACK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/BLACK.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/BROWN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/BROWN.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/GREEN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/GREEN.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/MAGENTA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/MAGENTA.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/ORANGE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/ORANGE.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/PURPLE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/PURPLE.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/WHITE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/WHITE.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/YELLOW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/YELLOW.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/enderman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/enderman.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/endermite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/endermite.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/guardian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/guardian.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/illusioner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/illusioner.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/iron_golem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/iron_golem.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/magma_cube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/magma_cube.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/mooshroom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/mooshroom.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/pillager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/pillager.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/polar_bear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/polar_bear.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/pufferfish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/pufferfish.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/silverfish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/silverfish.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/skeleton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/skeleton.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/snow_golem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/snow_golem.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/villager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/villager.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/vindicator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/vindicator.png -------------------------------------------------------------------------------- /addons/signs/src/main/resources/icons/sign_oak.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/signs/src/main/resources/icons/sign_oak.png -------------------------------------------------------------------------------- /addons/skins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | bukkitPluginYaml { 2 | main = "xyz.jpenilla.squaremap.addon.skins.SquaremapSkins" 3 | authors.add("BillyGalbreath") 4 | } 5 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:recommended" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/cave_spider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/cave_spider.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/ender_dragon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/ender_dragon.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/killer_bunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/killer_bunny.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/piglin_brute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/piglin_brute.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/trader_llama.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/trader_llama.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/zombie_horse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/zombie_horse.png -------------------------------------------------------------------------------- /addons/signs/src/main/resources/icons/sign_acacia.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/signs/src/main/resources/icons/sign_acacia.png -------------------------------------------------------------------------------- /addons/signs/src/main/resources/icons/sign_birch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/signs/src/main/resources/icons/sign_birch.png -------------------------------------------------------------------------------- /addons/signs/src/main/resources/icons/sign_jungle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/signs/src/main/resources/icons/sign_jungle.png -------------------------------------------------------------------------------- /addons/signs/src/main/resources/icons/sign_spruce.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/signs/src/main/resources/icons/sign_spruce.png -------------------------------------------------------------------------------- /addons/signs/src/main/resources/icons/sign_warped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/signs/src/main/resources/icons/sign_warped.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/LIGHT_BLUE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/LIGHT_BLUE.png -------------------------------------------------------------------------------- /addons/banners/src/main/resources/icons/LIGHT_GRAY.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/banners/src/main/resources/icons/LIGHT_GRAY.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/elder_guardian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/elder_guardian.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/skeleton_horse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/skeleton_horse.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/tropical_fish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/tropical_fish.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/wither_skeleton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/wither_skeleton.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/zombie_villager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/zombie_villager.png -------------------------------------------------------------------------------- /addons/signs/src/main/resources/icons/sign_crimson.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/signs/src/main/resources/icons/sign_crimson.png -------------------------------------------------------------------------------- /addons/signs/src/main/resources/icons/sign_dark_oak.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/signs/src/main/resources/icons/sign_dark_oak.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/wandering_trader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/wandering_trader.png -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/zombified_piglin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpenilla/squaremap-addons/HEAD/addons/mobs/src/main/resources/icons/zombified_piglin.png -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /addons/mobs/build.gradle.kts: -------------------------------------------------------------------------------- 1 | description = "Mobs addon for squaremap" 2 | 3 | bukkitPluginYaml { 4 | main = "xyz.jpenilla.squaremap.addon.mobs.SquaremapMobs" 5 | authors.add("BillyGalbreath") 6 | } 7 | -------------------------------------------------------------------------------- /addons/deathspot/build.gradle.kts: -------------------------------------------------------------------------------- 1 | description = "DeathSpots addon for squaremap" 2 | 3 | bukkitPluginYaml { 4 | main = "xyz.jpenilla.squaremap.addon.deathspot.DeathSpots" 5 | authors.add("BillyGalbreath") 6 | } 7 | -------------------------------------------------------------------------------- /addons/mobs/src/main/resources/icons/trader_llama.png:Zone.Identifier: -------------------------------------------------------------------------------- 1 | [ZoneTransfer] 2 | ZoneId=3 3 | ReferrerUrl=https://minecraft.gamepedia.com/ 4 | HostUrl=https://static.wikia.nocookie.net/minecraft_gamepedia/images/d/d3/LlamaFace.png/revision/latest/scale-to-width-down/64?cb=20190823005427 5 | -------------------------------------------------------------------------------- /addons/banners/src/main/java/xyz/jpenilla/squaremap/addon/banners/data/Data.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.banners.data; 2 | 3 | import xyz.jpenilla.squaremap.api.Key; 4 | import xyz.jpenilla.squaremap.api.marker.Marker; 5 | 6 | public record Data(Marker marker, Key key, String name) { 7 | } 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /addons/vanish/src/main/java/xyz/jpenilla/squaremap/addon/vanish/VanishAdapter.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.vanish; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.Listener; 5 | 6 | public interface VanishAdapter extends Listener { 7 | 8 | boolean isVanished(final Player player); 9 | } 10 | -------------------------------------------------------------------------------- /addons/skins/README.md: -------------------------------------------------------------------------------- 1 | ### How to use 2 | 3 | First, Install this plugin like any other plugin. 4 | 5 | Then in the squaremap config, change `heads-url` to the skins path. 6 | 7 | i.e: 8 | ``` 9 | heads-url: http://localhost:8080/skins/{name}.png 10 | ``` 11 | 12 | Be sure to replace `localhost:8080` with your public map url. 13 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: "build" 2 | 3 | on: 4 | push: 5 | branches: [ "**" ] 6 | tags-ignore: [ "**" ] 7 | pull_request: 8 | 9 | jobs: 10 | call-build: 11 | uses: "jpenilla/actions/.github/workflows/shared-ci.yml@master" 12 | with: 13 | artifacts-path: 'build/libs/*.jar' 14 | -------------------------------------------------------------------------------- /addons/claimchunk/build.gradle.kts: -------------------------------------------------------------------------------- 1 | description = "ClaimChunk addon for squaremap" 2 | 3 | dependencies { 4 | compileOnly("maven.modrinth.workaround:claimchunk:unused") 5 | } 6 | 7 | bukkitPluginYaml { 8 | main = "xyz.jpenilla.squaremap.addon.claimchunk.SquaremapClaimChunk" 9 | authors.add("BillyGalbreath") 10 | depend.add("ClaimChunk") 11 | } 12 | -------------------------------------------------------------------------------- /addons/vanish/README.md: -------------------------------------------------------------------------------- 1 | # squaremap-vanish 2 | 3 | squaremap integration for various vanish plugins. 4 | 5 | Directly supported vanish plugins: 6 | - SuperVanish 7 | - PremiumVanish 8 | 9 | Any other plugin that sets the "vanished" metadata will also work. 10 | 11 | Note that `squaremap-essentialsx` will handle EssentialsX vanish without `squaremap-vanish`. 12 | -------------------------------------------------------------------------------- /addons/griefprevention/build.gradle.kts: -------------------------------------------------------------------------------- 1 | description = "GriefPrevention integration for squaremap" 2 | 3 | dependencies { 4 | compileOnly("com.github.TechFortress:GriefPrevention:17.0.0") 5 | } 6 | 7 | bukkitPluginYaml { 8 | main = "xyz.jpenilla.squaremap.addon.griefprevention.SquaremapGriefPrevention" 9 | authors.add("BillyGalbreath") 10 | depend.add("GriefPrevention") 11 | } 12 | -------------------------------------------------------------------------------- /addons/essentialsx/build.gradle.kts: -------------------------------------------------------------------------------- 1 | description = "EssentialsX addon for squaremap" 2 | 3 | dependencies { 4 | compileOnly("net.essentialsx:EssentialsX:2.20.1") { 5 | isTransitive = false 6 | } 7 | } 8 | 9 | bukkitPluginYaml { 10 | main = "xyz.jpenilla.squaremap.addon.essentialsx.SquaremapEssentials" 11 | authors.add("BillyGalbreath") 12 | depend.add("Essentials") 13 | } 14 | -------------------------------------------------------------------------------- /addons/banners/README.md: -------------------------------------------------------------------------------- 1 | # squaremap-banners 2 | 3 | squaremap-banners is an addon to squaremap that allows players to display their banners the same way you can see banners on the vanilla map. Players with the `squaremap.banners.admin` permission need to shift right-click with an open map in their main hand on a placed banner to make it visible. Shift left-clicking will make the banner disappear from the map. 4 | -------------------------------------------------------------------------------- /addons/vanish/build.gradle.kts: -------------------------------------------------------------------------------- 1 | description = "Integration with various vanish plugins for squaremap" 2 | 3 | dependencies { 4 | compileOnly("com.github.LeonMangler:SuperVanish:6.2.19") { 5 | isTransitive = false 6 | } 7 | } 8 | 9 | bukkitPluginYaml { 10 | main = "xyz.jpenilla.squaremap.addon.vanish.SquaremapVanish" 11 | softDepend = listOf("SuperVanish", "PremiumVanish") 12 | } 13 | -------------------------------------------------------------------------------- /addons/worldguard/build.gradle.kts: -------------------------------------------------------------------------------- 1 | description = "WorldGuard addon for squaremap" 2 | 3 | dependencies { 4 | compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.9") { 5 | exclude("org.bstats") 6 | exclude("org.spigotmc") 7 | } 8 | } 9 | 10 | bukkitPluginYaml { 11 | main = "xyz.jpenilla.squaremap.addon.worldguard.SquaremapWorldGuard" 12 | authors.add("BillyGalbreath") 13 | depend.add("WorldGuard") 14 | } 15 | -------------------------------------------------------------------------------- /addons/signs/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import xyz.jpenilla.resourcefactory.bukkit.Permission 2 | 3 | description = "Signs addon for squaremap" 4 | 5 | bukkitPluginYaml { 6 | main = "xyz.jpenilla.squaremap.addon.signs.SignsPlugin" 7 | authors.add("BillyGalbreath") 8 | 9 | permissions { 10 | register("squaremap.signs.admin") { 11 | description = "Allow controlling the plugin" 12 | default = Permission.Default.OP 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /addons/signs/src/main/java/xyz/jpenilla/squaremap/addon/signs/data/Data.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.signs.data; 2 | 3 | import java.util.List; 4 | import net.kyori.adventure.text.Component; 5 | import org.checkerframework.checker.nullness.qual.Nullable; 6 | import xyz.jpenilla.squaremap.api.marker.Marker; 7 | 8 | public record Data( 9 | Marker marker, 10 | SignType type, 11 | @Nullable List front, 12 | @Nullable List back 13 | ) { 14 | } 15 | -------------------------------------------------------------------------------- /common/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `base-conventions` 3 | } 4 | 5 | description = "Common code shared between all addon plugins in this repository" 6 | 7 | dependencies { 8 | api(platform("org.spongepowered:configurate-bom:4.2.0")) 9 | api("org.spongepowered:configurate-yaml") 10 | 11 | compileOnlyApi("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") { 12 | exclude("org.yaml", "snakeyaml") 13 | } 14 | compileOnlyApi("xyz.jpenilla:squaremap-api:1.3.9") 15 | } 16 | -------------------------------------------------------------------------------- /addons/banners/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import xyz.jpenilla.resourcefactory.bukkit.Permission 2 | 3 | description = "Banners addon for squaremap" 4 | 5 | bukkitPluginYaml { 6 | main = "xyz.jpenilla.squaremap.addon.banners.SquaremapBanners" 7 | authors.add("BillyGalbreath") 8 | authors.add("granny") 9 | 10 | permissions { 11 | register("squaremap.banners.admin") { 12 | description = "Allow controlling the plugin" 13 | default = Permission.Default.OP 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /addons/essentialsx/src/main/java/xyz/jpenilla/squaremap/addon/essentialsx/hook/EssentialsHook.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.essentialsx.hook; 2 | 3 | import com.earth2me.essentials.Essentials; 4 | import com.earth2me.essentials.Warps; 5 | import org.bukkit.entity.Player; 6 | 7 | public final class EssentialsHook { 8 | public static Warps getWarps() { 9 | return ess().getWarps(); 10 | } 11 | 12 | public static boolean isVanished(Player player) { 13 | return ess().getUser(player).isVanished(); 14 | } 15 | 16 | public static Essentials ess() { 17 | return Essentials.getPlugin(Essentials.class); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /addons/signs/src/main/java/xyz/jpenilla/squaremap/addon/signs/config/SignsConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.signs.config; 2 | 3 | import org.bukkit.plugin.Plugin; 4 | import xyz.jpenilla.squaremap.addon.common.config.Config; 5 | 6 | public final class SignsConfig extends Config { 7 | public boolean debugMode = false; 8 | 9 | @SuppressWarnings("unused") 10 | private void baseSettings() { 11 | this.debugMode = this.getBoolean("settings.debug-mode", this.debugMode); 12 | } 13 | 14 | public SignsConfig(Plugin plugin) { 15 | super(SignsConfig.class, SignsWorldConfig.class, plugin); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common/src/main/java/xyz/jpenilla/squaremap/addon/common/config/ListMode.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.common.config; 2 | 3 | import java.util.Collection; 4 | 5 | public enum ListMode { 6 | WHITELIST { 7 | @Override 8 | public boolean allowed(final Collection collection, final E e) { 9 | return collection.contains(e); 10 | } 11 | }, 12 | BLACKLIST { 13 | @Override 14 | public boolean allowed(final Collection collection, final E e) { 15 | return !collection.contains(e); 16 | } 17 | }; 18 | 19 | public abstract boolean allowed(Collection collection, E e); 20 | } 21 | -------------------------------------------------------------------------------- /addons/deathspot/src/main/java/xyz/jpenilla/squaremap/addon/deathspot/config/DeathSpotConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.deathspot.config; 2 | 3 | import org.bukkit.plugin.Plugin; 4 | import xyz.jpenilla.squaremap.addon.common.config.Config; 5 | 6 | public final class DeathSpotConfig extends Config { 7 | public DeathSpotConfig(final Plugin plugin) { 8 | super(DeathSpotConfig.class, DeathSpotWorldConfig.class, plugin); 9 | } 10 | 11 | public boolean debugMode = false; 12 | 13 | @SuppressWarnings("unused") 14 | private void baseSettings() { 15 | this.debugMode = this.getBoolean("settings.debug-mode", this.debugMode); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /addons/griefprevention/src/main/java/xyz/jpenilla/squaremap/addon/griefprevention/hook/GPHook.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.griefprevention.hook; 2 | 3 | import java.util.Collection; 4 | import java.util.UUID; 5 | import me.ryanhamshire.GriefPrevention.Claim; 6 | import me.ryanhamshire.GriefPrevention.GriefPrevention; 7 | import org.bukkit.Bukkit; 8 | import org.bukkit.World; 9 | 10 | public final class GPHook { 11 | public static boolean isWorldEnabled(UUID uuid) { 12 | World world = Bukkit.getWorld(uuid); 13 | return GriefPrevention.instance.claimsEnabledForWorld(world); 14 | } 15 | 16 | public static Collection getClaims() { 17 | return GriefPrevention.instance.dataStore.getClaims(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /addons/mobs/src/main/java/xyz/jpenilla/squaremap/addon/mobs/config/MobsConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.mobs.config; 2 | 3 | import org.bukkit.plugin.Plugin; 4 | import xyz.jpenilla.squaremap.addon.common.config.Config; 5 | 6 | public final class MobsConfig extends Config { 7 | public boolean debugMode = false; 8 | public int updateInterval = 5; 9 | 10 | @SuppressWarnings("unused") 11 | private void baseSettings() { 12 | this.debugMode = this.getBoolean("settings.debug-mode", this.debugMode); 13 | this.updateInterval = this.getInt("update-interval", this.updateInterval); 14 | } 15 | 16 | public MobsConfig(Plugin plugin) { 17 | super(MobsConfig.class, MobsWorldConfig.class, plugin); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /addons/banners/src/main/java/xyz/jpenilla/squaremap/addon/banners/configuration/BannersConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.banners.configuration; 2 | 3 | import org.bukkit.plugin.Plugin; 4 | import org.checkerframework.checker.nullness.qual.NonNull; 5 | import org.checkerframework.framework.qual.DefaultQualifier; 6 | import xyz.jpenilla.squaremap.addon.common.config.Config; 7 | 8 | @DefaultQualifier(NonNull.class) 9 | public class BannersConfig extends Config { 10 | public BannersConfig(final Plugin plugin) { 11 | super(BannersConfig.class, BannersWorldConfig.class, plugin); 12 | } 13 | 14 | public boolean debugMode = false; 15 | 16 | private void baseSettings() { 17 | this.debugMode = this.getBoolean("settings.debug-mode", this.debugMode); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /addons/banners/src/main/java/xyz/jpenilla/squaremap/addon/banners/data/Position.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.banners.data; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.World; 5 | import org.bukkit.block.Banner; 6 | import xyz.jpenilla.squaremap.api.Point; 7 | 8 | public record Position(int x, int y, int z) { 9 | public static Position of(Location loc) { 10 | return new Position(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); 11 | } 12 | 13 | public static Position of(int x, int y, int z) { 14 | return new Position(x, y, z); 15 | } 16 | 17 | public Point point() { 18 | return Point.of(this.x, this.z); 19 | } 20 | 21 | public boolean isBanner(World world) { 22 | return world.getBlockAt(this.x, this.y, this.z).getState() instanceof Banner; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /addons/worldguard/src/main/java/xyz/jpenilla/squaremap/addon/worldguard/EventListener.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.worldguard; 2 | 3 | import org.bukkit.event.EventHandler; 4 | import org.bukkit.event.EventPriority; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.world.WorldLoadEvent; 7 | import org.bukkit.event.world.WorldUnloadEvent; 8 | 9 | public record EventListener(SquaremapWorldGuard plugin) implements Listener { 10 | @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) 11 | public void worldLoad(final WorldLoadEvent event) { 12 | this.plugin.squaremapHook().addWorld(event.getWorld()); 13 | } 14 | 15 | @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) 16 | public void worldUnload(final WorldUnloadEvent event) { 17 | this.plugin.squaremapHook().removeWorld(event.getWorld()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /addons/essentialsx/src/main/java/xyz/jpenilla/squaremap/addon/essentialsx/config/EssXConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.essentialsx.config; 2 | 3 | import org.bukkit.plugin.Plugin; 4 | import xyz.jpenilla.squaremap.addon.common.config.Config; 5 | 6 | public final class EssXConfig extends Config { 7 | public boolean debugMode = false; 8 | public int updateInterval = 5; 9 | public boolean hideVanished = true; 10 | 11 | @SuppressWarnings("unused") 12 | private void baseSettings() { 13 | this.debugMode = this.getBoolean("settings.debug-mode", this.debugMode); 14 | this.updateInterval = this.getInt("settings.update-interval", this.updateInterval); 15 | this.hideVanished = this.getBoolean("settings.hide-vanished", this.hideVanished); 16 | } 17 | 18 | public EssXConfig(final Plugin plugin) { 19 | super(EssXConfig.class, EssXWorldConfig.class, plugin); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /addons/claimchunk/src/main/java/xyz/jpenilla/squaremap/addon/claimchunk/SquaremapClaimChunk.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.claimchunk; 2 | 3 | import org.bukkit.plugin.java.JavaPlugin; 4 | import xyz.jpenilla.squaremap.addon.claimchunk.config.ClaimChunkConfig; 5 | import xyz.jpenilla.squaremap.addon.claimchunk.hook.SquaremapHook; 6 | 7 | public final class SquaremapClaimChunk extends JavaPlugin { 8 | private SquaremapHook squaremapHook; 9 | private ClaimChunkConfig config; 10 | 11 | @Override 12 | public void onEnable() { 13 | this.config = new ClaimChunkConfig(this); 14 | this.config.reload(); 15 | 16 | this.squaremapHook = new SquaremapHook(this); 17 | } 18 | 19 | @Override 20 | public void onDisable() { 21 | if (this.squaremapHook != null) { 22 | this.squaremapHook.disable(); 23 | } 24 | } 25 | 26 | public ClaimChunkConfig config() { 27 | return this.config; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /addons/griefprevention/src/main/java/xyz/jpenilla/squaremap/addon/griefprevention/SquaremapGriefPrevention.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.griefprevention; 2 | 3 | import org.bukkit.plugin.java.JavaPlugin; 4 | import xyz.jpenilla.squaremap.addon.griefprevention.config.GPConfig; 5 | import xyz.jpenilla.squaremap.addon.griefprevention.hook.SquaremapHook; 6 | 7 | public final class SquaremapGriefPrevention extends JavaPlugin { 8 | private SquaremapHook squaremapHook; 9 | private GPConfig config; 10 | 11 | public GPConfig config() { 12 | return this.config; 13 | } 14 | 15 | @Override 16 | public void onEnable() { 17 | this.config = new GPConfig(this); 18 | this.config.reload(); 19 | 20 | this.squaremapHook = new SquaremapHook(this); 21 | } 22 | 23 | @Override 24 | public void onDisable() { 25 | if (this.squaremapHook != null) { 26 | this.squaremapHook.disable(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /addons/claimchunk/src/main/java/xyz/jpenilla/squaremap/addon/claimchunk/hook/ClaimChunkHook.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.claimchunk.hook; 2 | 3 | import com.cjburkey.claimchunk.ClaimChunk; 4 | import com.cjburkey.claimchunk.chunk.DataChunk; 5 | import com.cjburkey.claimchunk.data.newdata.IClaimChunkDataHandler; 6 | import java.lang.reflect.Field; 7 | import org.bukkit.Bukkit; 8 | 9 | public final class ClaimChunkHook { 10 | public static DataChunk[] getClaims() { 11 | final ClaimChunk cc = 12 | (ClaimChunk) Bukkit.getServer().getPluginManager().getPlugin("ClaimChunk"); 13 | 14 | IClaimChunkDataHandler dataHandler; 15 | try { 16 | Field field = ClaimChunk.class.getDeclaredField("dataHandler"); 17 | field.setAccessible(true); 18 | dataHandler = (IClaimChunkDataHandler) field.get(cc); 19 | } catch (NoSuchFieldException | IllegalAccessException e) { 20 | e.printStackTrace(); 21 | return null; 22 | } 23 | 24 | return dataHandler.getClaimedChunks(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /addons/vanish/src/main/java/xyz/jpenilla/squaremap/addon/vanish/SuperVanish.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.vanish; 2 | 3 | import de.myzelyam.api.vanish.PlayerHideEvent; 4 | import de.myzelyam.api.vanish.PlayerShowEvent; 5 | import de.myzelyam.api.vanish.VanishAPI; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.EventPriority; 9 | import org.bukkit.event.Listener; 10 | import xyz.jpenilla.squaremap.api.Squaremap; 11 | 12 | public record SuperVanish(Squaremap squaremap) implements VanishAdapter { 13 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 14 | public void hide(final PlayerHideEvent event) { 15 | this.squaremap.playerManager().hide(event.getPlayer().getUniqueId()); 16 | } 17 | 18 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 19 | public void show(final PlayerShowEvent event) { 20 | this.squaremap.playerManager().show(event.getPlayer().getUniqueId()); 21 | } 22 | 23 | @Override 24 | public boolean isVanished(final Player player) { 25 | return VanishAPI.isInvisible(player); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /addons/worldguard/src/main/java/xyz/jpenilla/squaremap/addon/worldguard/hook/WGHook.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.worldguard.hook; 2 | 3 | import com.sk89q.worldedit.bukkit.BukkitAdapter; 4 | import com.sk89q.worldguard.WorldGuard; 5 | import com.sk89q.worldguard.protection.managers.RegionManager; 6 | import com.sk89q.worldguard.protection.regions.ProtectedRegion; 7 | import com.sk89q.worldguard.protection.regions.RegionContainer; 8 | import java.util.Map; 9 | import org.bukkit.Bukkit; 10 | import org.bukkit.World; 11 | import xyz.jpenilla.squaremap.api.WorldIdentifier; 12 | 13 | public final class WGHook { 14 | public static Map getRegions(WorldIdentifier identifier) { 15 | World bukkitWorld = Bukkit.getWorld(xyz.jpenilla.squaremap.api.BukkitAdapter.namespacedKey(identifier)); 16 | if (bukkitWorld == null) { 17 | return null; 18 | } 19 | RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); 20 | RegionManager manager = container.get(BukkitAdapter.adapt(bukkitWorld)); 21 | if (manager == null) { 22 | return null; 23 | } 24 | return manager.getRegions(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /addons/signs/README.md: -------------------------------------------------------------------------------- 1 | # signs 2 | 3 | Add map markers using in-game signs. 4 | 5 | ## permissions required 6 | 7 | * `squaremap.signs.admin` 8 | 9 | ## add a marker 10 | 11 | 1. In your game client, place a sign block in your world. 12 | 13 | 2. Set its text to your liking. 14 | 15 | 3. Hold a filled map in your primary hand. You may use any map item; it does not need to correspond to your current location. 16 | 17 | 4. Right-click the sign. 18 | 19 | A new map marker is added immediately. Refresh the squaremap website to see it. 20 | 21 | ## update a marker 22 | 23 | If the marker sign's text changes, the map marker is updated immediately. 24 | 25 | ## remove a marker 26 | 27 | Either 28 | 29 | * Destroy the marker sign, removing it from the world; OR 30 | 31 | * Hold a filled map in your primary hand, and left-click the sign. 32 | 33 | The map marker is removed immediately. 34 | 35 | ## tips and tricks 36 | 37 | * Simple/safe HTML is permitted in signs 38 | 39 | * Add your own icon images to the `customicons/` directory. If the first line of text on the front side of the sign matches the `icon.custom.regexp`, the matched portion will be interpreted as an icon filename. 40 | 41 | The default regexp matches text like: 42 | 43 | ``` 44 | ![cool_icon] 45 | ``` 46 | 47 | and uses the image file `customicons/cool_icon.png` as the icon. 48 | -------------------------------------------------------------------------------- /addons/vanish/src/main/java/xyz/jpenilla/squaremap/addon/vanish/VanishFallback.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.vanish; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.metadata.MetadataValue; 5 | import xyz.jpenilla.squaremap.api.Squaremap; 6 | 7 | import java.util.List; 8 | import java.util.UUID; 9 | 10 | public class VanishFallback implements VanishAdapter { 11 | 12 | public VanishFallback(final SquaremapVanish plugin, final Squaremap squaremap) { 13 | plugin.getServer().getScheduler().runTaskTimer(plugin, () -> { 14 | for (final Player player : plugin.getServer().getOnlinePlayers()) { 15 | final boolean isVanished = isVanished(player); 16 | final UUID playerId = player.getUniqueId(); 17 | if (isVanished != squaremap.playerManager().hidden(playerId)) { 18 | squaremap.playerManager().hidden(playerId, isVanished); 19 | } 20 | } 21 | }, 0, 20); 22 | } 23 | 24 | @Override 25 | public boolean isVanished(final Player player) { 26 | final List list = player.getMetadata("vanished"); 27 | for (MetadataValue value : list) { 28 | if (value.asBoolean()) { 29 | return true; 30 | } 31 | } 32 | return false; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /addons/mobs/src/main/java/xyz/jpenilla/squaremap/addon/mobs/SquaremapMobs.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.mobs; 2 | 3 | import org.bukkit.plugin.java.JavaPlugin; 4 | import xyz.jpenilla.squaremap.addon.mobs.config.MobsConfig; 5 | import xyz.jpenilla.squaremap.addon.mobs.data.Icons; 6 | import xyz.jpenilla.squaremap.addon.mobs.hook.SquaremapHook; 7 | 8 | public final class SquaremapMobs extends JavaPlugin { 9 | private static SquaremapMobs instance; 10 | private SquaremapHook squaremapHook; 11 | private MobsConfig config; 12 | 13 | public SquaremapMobs() { 14 | instance = this; 15 | } 16 | 17 | @Override 18 | public void onEnable() { 19 | this.config = new MobsConfig(this); 20 | this.config.reload(); 21 | 22 | @SuppressWarnings("unused") final String staticInit = Icons.class.getTypeName(); 23 | 24 | this.squaremapHook = new SquaremapHook(this); 25 | this.squaremapHook.load(); 26 | } 27 | 28 | @Override 29 | public void onDisable() { 30 | if (this.squaremapHook != null) { 31 | this.squaremapHook.disable(); 32 | } 33 | this.squaremapHook = null; 34 | } 35 | 36 | public static SquaremapMobs getInstance() { 37 | return instance; 38 | } 39 | 40 | public MobsConfig config() { 41 | return this.config; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /addons/essentialsx/src/main/java/xyz/jpenilla/squaremap/addon/essentialsx/SquaremapEssentials.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.essentialsx; 2 | 3 | import java.io.File; 4 | import org.bukkit.plugin.java.JavaPlugin; 5 | import xyz.jpenilla.squaremap.addon.essentialsx.config.EssXConfig; 6 | import xyz.jpenilla.squaremap.addon.essentialsx.hook.SquaremapHook; 7 | import xyz.jpenilla.squaremap.addon.essentialsx.listener.EssentialsListener; 8 | 9 | public final class SquaremapEssentials extends JavaPlugin { 10 | private SquaremapHook squaremapHook; 11 | private EssXConfig config; 12 | 13 | public EssXConfig config() { 14 | return this.config; 15 | } 16 | 17 | @Override 18 | public void onEnable() { 19 | this.config = new EssXConfig(this); 20 | this.config.reload(); 21 | 22 | if (!new File(this.getDataFolder(), "warp.png").exists()) { 23 | this.saveResource("warp.png", false); 24 | } 25 | 26 | this.squaremapHook = new SquaremapHook(this); 27 | this.squaremapHook.load(); 28 | 29 | this.getServer().getPluginManager().registerEvents(new EssentialsListener(this), this); 30 | } 31 | 32 | @Override 33 | public void onDisable() { 34 | if (this.squaremapHook != null) { 35 | this.squaremapHook.disable(); 36 | } 37 | this.squaremapHook = null; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /addons/deathspot/src/main/java/xyz/jpenilla/squaremap/addon/deathspot/config/DeathSpotWorldConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.deathspot.config; 2 | 3 | import xyz.jpenilla.squaremap.addon.common.config.Config; 4 | import xyz.jpenilla.squaremap.addon.common.config.WorldConfig; 5 | 6 | public final class DeathSpotWorldConfig extends WorldConfig { 7 | public boolean enabled = true; 8 | public int updateInterval = 5; 9 | public boolean enableControls = true; 10 | public boolean controlsHiddenByDefault = false; 11 | public String tooltip = "{name}'s
Death Spot"; 12 | public int removeMarkerAfter = 60 * 5; 13 | 14 | @SuppressWarnings("unused") 15 | private void worldSettings() { 16 | this.enabled = this.getBoolean("enabled", this.enabled); 17 | this.updateInterval = this.getInt("update-interval", this.updateInterval); 18 | this.enableControls = this.getBoolean("controls.enabled", this.enableControls); 19 | this.controlsHiddenByDefault = this.getBoolean("controls.hidden-by-default", this.controlsHiddenByDefault); 20 | this.tooltip = this.getString("marker.tooltip", this.tooltip); 21 | this.removeMarkerAfter = this.getInt("marker.remove-after", this.removeMarkerAfter); 22 | } 23 | 24 | private DeathSpotWorldConfig(final Config parent, final String world) { 25 | super(parent, world); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /addons/claimchunk/src/main/java/xyz/jpenilla/squaremap/addon/claimchunk/data/Claim.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.claimchunk.data; 2 | 3 | import java.util.UUID; 4 | 5 | public record Claim(int x, int z, UUID owner) { 6 | public boolean isTouching(Claim claim) { 7 | if (!owner.equals(claim.owner)) { 8 | return false; // not same owner 9 | } 10 | if (claim.x == x && claim.z == z - 1) { 11 | return true; // touches north 12 | } 13 | if (claim.x == x && claim.z == z + 1) { 14 | return true; // touches south 15 | } 16 | if (claim.x == x - 1 && claim.z == z) { 17 | return true; // touches west 18 | } 19 | if (claim.x == x + 1 && claim.z == z) { 20 | return true; // touches east 21 | } 22 | return false; 23 | } 24 | 25 | @Override 26 | public boolean equals(Object o) { 27 | if (this == o) { 28 | return true; 29 | } 30 | if (!(o instanceof Claim other)) { 31 | return false; 32 | } 33 | return this.x == other.x && this.z == other.z; 34 | } 35 | 36 | @Override 37 | public int hashCode() { 38 | final int prime = 31; 39 | int result = 1; 40 | result = prime * result + x; 41 | result = prime * result + z; 42 | return result; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /addons/signs/src/main/java/xyz/jpenilla/squaremap/addon/signs/listener/WorldListener.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.signs.listener; 2 | 3 | import org.bukkit.event.EventHandler; 4 | import org.bukkit.event.EventPriority; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.world.ChunkLoadEvent; 7 | import org.bukkit.event.world.ChunkUnloadEvent; 8 | import org.bukkit.event.world.WorldLoadEvent; 9 | import org.bukkit.event.world.WorldUnloadEvent; 10 | import xyz.jpenilla.squaremap.addon.signs.SignsPlugin; 11 | 12 | public record WorldListener(SignsPlugin plugin) implements Listener { 13 | 14 | @EventHandler(priority = EventPriority.MONITOR) 15 | public void onWorldLoad(WorldLoadEvent event) { 16 | this.plugin.layerProviders().provider(event.getWorld()); 17 | } 18 | 19 | @EventHandler(priority = EventPriority.MONITOR) 20 | public void onWorldUnload(WorldUnloadEvent event) { 21 | this.plugin.layerProviders().unloadProvider(event.getWorld()); 22 | } 23 | 24 | @EventHandler(priority = EventPriority.MONITOR) 25 | public void onChunkLoad(ChunkLoadEvent event) { 26 | if (!event.isNewChunk()) { 27 | this.plugin.signManager().checkChunk(event.getChunk()); 28 | } 29 | } 30 | 31 | @EventHandler(priority = EventPriority.MONITOR) 32 | public void onChunkUnload(ChunkUnloadEvent event) { 33 | this.plugin.signManager().checkChunk(event.getChunk()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/xyz/jpenilla/squaremap/addon/common/config/ColorSerializer.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.common.config; 2 | 3 | import java.awt.Color; 4 | import java.lang.reflect.Type; 5 | import java.util.function.Predicate; 6 | import org.spongepowered.configurate.serialize.ScalarSerializer; 7 | import org.spongepowered.configurate.serialize.SerializationException; 8 | 9 | public final class ColorSerializer extends ScalarSerializer { 10 | public static final ColorSerializer INSTANCE = new ColorSerializer(); 11 | 12 | private ColorSerializer() { 13 | super(Color.class); 14 | } 15 | 16 | @Override 17 | public Color deserialize(Type type, Object obj) throws SerializationException { 18 | if (obj instanceof String string) { 19 | try { 20 | return parseHex(string); 21 | } catch (final NumberFormatException ex) { 22 | throw new SerializationException(ex); 23 | } 24 | } 25 | return null; 26 | } 27 | 28 | @Override 29 | public Object serialize(Color obj, Predicate> typeSupported) { 30 | if (obj == null) { 31 | return null; 32 | } 33 | return String.format("#%06x", obj.getRGB() & 0x00FFFFFF); 34 | } 35 | 36 | private static Color parseHex(final String hex) { 37 | final int rgb = Integer.parseInt(hex.charAt(0) == '#' ? hex.substring(1) : hex, 16); 38 | return new Color(rgb); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /addons/signs/src/main/java/xyz/jpenilla/squaremap/addon/signs/data/SignType.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.signs.data; 2 | 3 | import java.util.Locale; 4 | import org.bukkit.Material; 5 | import xyz.jpenilla.squaremap.addon.signs.SignsPlugin; 6 | import xyz.jpenilla.squaremap.api.Key; 7 | 8 | public enum SignType { 9 | OAK(Icons.OAK), 10 | SPRUCE(Icons.SPRUCE), 11 | BIRCH(Icons.BIRCH), 12 | JUNGLE(Icons.JUNGLE), 13 | ACACIA(Icons.ACACIA), 14 | DARK_OAK(Icons.DARK_OAK), 15 | CRIMSON(Icons.CRIMSON), 16 | WARPED(Icons.WARPED), 17 | BAMBOO(Icons.OAK), // todo 18 | MANGROVE(Icons.OAK), // todo 19 | CHERRY(Icons.OAK); // todo 20 | 21 | public final Key iconKey; 22 | 23 | SignType(final Key iconKey) { 24 | this.iconKey = iconKey; 25 | } 26 | 27 | public static SignType typeOrDefault(final Material type) { 28 | return SignType.typeOrDefault( 29 | type.name() 30 | .replace("_WALL_HANGING_SIGN", "") 31 | .replace("_HANGING_SIGN", "") 32 | .replace("_WALL_SIGN", "") 33 | .replace("_SIGN", "") 34 | ); 35 | } 36 | 37 | public static SignType typeOrDefault(final String name) { 38 | try { 39 | return SignType.valueOf(name.toUpperCase(Locale.ROOT)); 40 | } catch (final IllegalArgumentException e) { 41 | SignsPlugin.instance().getLogger().warning("Missing SignType for " + name); 42 | return OAK; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /addons/claimchunk/src/main/java/xyz/jpenilla/squaremap/addon/claimchunk/data/Group.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.claimchunk.data; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.UUID; 6 | 7 | public final class Group { 8 | private final List claims = new ArrayList<>(); 9 | private final UUID owner; 10 | 11 | public Group(Claim claim, UUID owner) { 12 | add(claim); 13 | this.owner = owner; 14 | } 15 | 16 | public boolean isTouching(Claim claim) { 17 | for (Claim toChk : claims) { 18 | if (toChk.isTouching(claim)) { 19 | return true; 20 | } 21 | } 22 | return false; 23 | } 24 | 25 | public boolean isTouching(Group group) { 26 | for (Claim claim : group.claims()) { 27 | if (isTouching(claim)) { 28 | return true; 29 | } 30 | } 31 | return false; 32 | } 33 | 34 | public void add(Claim claim) { 35 | claims.add(claim); 36 | } 37 | 38 | public void add(Group group) { 39 | claims.addAll(group.claims()); 40 | } 41 | 42 | public List claims() { 43 | return claims; 44 | } 45 | 46 | public UUID owner() { 47 | return owner; 48 | } 49 | 50 | public String id() { 51 | if (claims.size() > 0) { 52 | Claim claim = claims.get(0); 53 | return claim.x() + "_" + claim.z(); 54 | } else { 55 | return "NaN_NaN"; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /addons/banners/src/main/java/xyz/jpenilla/squaremap/addon/banners/listener/WorldListener.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.banners.listener; 2 | 3 | import org.bukkit.event.EventHandler; 4 | import org.bukkit.event.EventPriority; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.world.ChunkLoadEvent; 7 | import org.bukkit.event.world.ChunkUnloadEvent; 8 | import org.bukkit.event.world.WorldLoadEvent; 9 | import org.bukkit.event.world.WorldUnloadEvent; 10 | import xyz.jpenilla.squaremap.addon.banners.SquaremapBanners; 11 | 12 | public class WorldListener implements Listener { 13 | private final SquaremapBanners plugin; 14 | 15 | public WorldListener(SquaremapBanners plugin) { 16 | this.plugin = plugin; 17 | } 18 | 19 | @EventHandler(priority = EventPriority.MONITOR) 20 | public void onWorldLoad(WorldLoadEvent event) { 21 | plugin.squaremapHook().getProvider(event.getWorld()); 22 | } 23 | 24 | @EventHandler(priority = EventPriority.MONITOR) 25 | public void onWorldUnload(WorldUnloadEvent event) { 26 | plugin.squaremapHook().unloadProvider(event.getWorld()); 27 | } 28 | 29 | @EventHandler(priority = EventPriority.MONITOR) 30 | public void onChunkLoad(ChunkLoadEvent event) { 31 | if (!event.isNewChunk()) { 32 | plugin.bannerManager().checkChunk(event.getChunk()); 33 | } 34 | } 35 | 36 | @EventHandler(priority = EventPriority.MONITOR) 37 | public void onChunkUnload(ChunkUnloadEvent event) { 38 | plugin.bannerManager().checkChunk(event.getChunk()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /addons/essentialsx/src/main/java/xyz/jpenilla/squaremap/addon/essentialsx/listener/EssentialsListener.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.essentialsx.listener; 2 | 3 | import net.ess3.api.events.VanishStatusChangeEvent; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.EventPriority; 7 | import org.bukkit.event.Listener; 8 | import org.bukkit.event.player.PlayerJoinEvent; 9 | import xyz.jpenilla.squaremap.addon.essentialsx.SquaremapEssentials; 10 | import xyz.jpenilla.squaremap.addon.essentialsx.hook.EssentialsHook; 11 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 12 | 13 | public record EssentialsListener(SquaremapEssentials plugin) implements Listener { 14 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 15 | public void onVanishStatusChange(VanishStatusChangeEvent event) { 16 | if (!this.plugin.config().hideVanished) { 17 | return; 18 | } 19 | final Player player = event.getAffected().getBase(); 20 | final boolean vanished = event.getValue(); 21 | SquaremapProvider.get().playerManager().hidden(player.getUniqueId(), vanished); 22 | } 23 | 24 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 25 | public void onPlayerJoin(PlayerJoinEvent event) { 26 | if (!this.plugin.config().hideVanished) { 27 | return; 28 | } 29 | final Player player = event.getPlayer(); 30 | if (EssentialsHook.isVanished(player)) { 31 | SquaremapProvider.get().playerManager().hide(player.getUniqueId()); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /addons/deathspot/src/main/java/xyz/jpenilla/squaremap/addon/deathspot/listener/PlayerListener.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.deathspot.listener; 2 | 3 | import java.util.UUID; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.EventPriority; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.entity.PlayerDeathEvent; 10 | import org.bukkit.scheduler.BukkitRunnable; 11 | import xyz.jpenilla.squaremap.addon.deathspot.DeathSpots; 12 | import xyz.jpenilla.squaremap.addon.deathspot.config.DeathSpotWorldConfig; 13 | import xyz.jpenilla.squaremap.api.BukkitAdapter; 14 | import xyz.jpenilla.squaremap.api.Pair; 15 | 16 | public record PlayerListener(DeathSpots plugin) implements Listener { 17 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 18 | public void onPlayerDeath(PlayerDeathEvent event) { 19 | final Player player = event.getEntity(); 20 | final UUID uuid = player.getUniqueId(); 21 | final Location location = player.getLocation(); 22 | 23 | final DeathSpotWorldConfig worldConfig = this.plugin.config().worldConfig(BukkitAdapter.worldIdentifier(location.getWorld())); 24 | if (!worldConfig.enabled) { 25 | return; 26 | } 27 | 28 | this.plugin.getDeathSpots().put(uuid, Pair.of(player.getName(), location)); 29 | 30 | new BukkitRunnable() { 31 | @Override 32 | public void run() { 33 | PlayerListener.this.plugin.getDeathSpots().remove(uuid); 34 | } 35 | }.runTaskLater(this.plugin, 20L * worldConfig.removeMarkerAfter); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /addons/signs/src/main/java/xyz/jpenilla/squaremap/addon/signs/data/Position.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.signs.data; 2 | 3 | import com.google.gson.stream.JsonReader; 4 | import com.google.gson.stream.JsonWriter; 5 | import java.io.IOException; 6 | import java.util.Arrays; 7 | import java.util.List; 8 | import org.bukkit.Location; 9 | import org.bukkit.World; 10 | import org.bukkit.block.Sign; 11 | import xyz.jpenilla.squaremap.api.Point; 12 | 13 | public record Position(int x, int y, int z) { 14 | public static Position of(Location loc) { 15 | return new Position(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); 16 | } 17 | 18 | public static Position of(final int x, final int y, final int z) { 19 | return new Position(x, y, z); 20 | } 21 | 22 | public Point point() { 23 | return Point.of(this.x, this.z); 24 | } 25 | 26 | public boolean isSign(final World world) { 27 | return world.getBlockAt(this.x, this.y, this.z).getState() instanceof Sign; 28 | } 29 | 30 | public static final class TypeAdapter extends com.google.gson.TypeAdapter { 31 | @Override 32 | public void write(final JsonWriter out, final Position value) throws IOException { 33 | out.value(value.x() + ";" + value.y() + ";" + value.z()); 34 | } 35 | 36 | @Override 37 | public Position read(final JsonReader in) throws IOException { 38 | final List coords = Arrays.stream(in.nextString().split(";")) 39 | .map(Integer::parseInt) 40 | .toList(); 41 | return of(coords.get(0), coords.get(1), coords.get(2)); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /addons/claimchunk/src/main/java/xyz/jpenilla/squaremap/addon/claimchunk/hook/SquaremapHook.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.claimchunk.hook; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import xyz.jpenilla.squaremap.addon.claimchunk.SquaremapClaimChunk; 6 | import xyz.jpenilla.squaremap.addon.claimchunk.task.SquaremapTask; 7 | import xyz.jpenilla.squaremap.api.Key; 8 | import xyz.jpenilla.squaremap.api.MapWorld; 9 | import xyz.jpenilla.squaremap.api.SimpleLayerProvider; 10 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 11 | import xyz.jpenilla.squaremap.api.WorldIdentifier; 12 | 13 | import static xyz.jpenilla.squaremap.api.Key.key; 14 | 15 | public final class SquaremapHook { 16 | private static final Key CLAIM_CHUNK_LAYER_KEY = key("claimchunk"); 17 | 18 | private final Map tasks = new HashMap<>(); 19 | 20 | public SquaremapHook(final SquaremapClaimChunk plugin) { 21 | for (final MapWorld world : SquaremapProvider.get().mapWorlds()) { 22 | final SimpleLayerProvider provider = SimpleLayerProvider.builder(plugin.config().controlLabel) 23 | .showControls(plugin.config().controlShow) 24 | .defaultHidden(plugin.config().controlHide) 25 | .build(); 26 | 27 | world.layerRegistry().register(CLAIM_CHUNK_LAYER_KEY, provider); 28 | 29 | final SquaremapTask task = new SquaremapTask(plugin, world, provider); 30 | task.runTaskTimerAsynchronously(plugin, 20L, 20L * plugin.config().updateInterval); 31 | 32 | this.tasks.put(world.identifier(), task); 33 | } 34 | } 35 | 36 | public void disable() { 37 | this.tasks.values().forEach(SquaremapTask::disable); 38 | this.tasks.clear(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /common/src/main/java/xyz/jpenilla/squaremap/addon/common/config/ConfigUpgrader.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.common.config; 2 | 3 | import java.util.function.Consumer; 4 | import org.checkerframework.checker.nullness.qual.NonNull; 5 | import org.checkerframework.framework.qual.DefaultQualifier; 6 | import org.spongepowered.configurate.ConfigurateException; 7 | import org.spongepowered.configurate.ConfigurationNode; 8 | import org.spongepowered.configurate.transformation.ConfigurationTransformation; 9 | import xyz.jpenilla.squaremap.addon.common.Util; 10 | 11 | @DefaultQualifier(NonNull.class) 12 | public final class ConfigUpgrader { 13 | private final ConfigurationTransformation.Versioned upgrader; 14 | 15 | public ConfigUpgrader(final Consumer op) { 16 | final ConfigurationTransformation.VersionedBuilder builder = ConfigurationTransformation.versionedBuilder(); 17 | op.accept(builder); 18 | this.upgrader = builder.build(); 19 | } 20 | 21 | public UpgradeResult upgrade(final N node) { 22 | final int original = this.upgrader.version(node); 23 | try { 24 | this.upgrader.apply(node); 25 | } catch (final ConfigurateException e) { 26 | Util.rethrow(e); 27 | } 28 | final int newVer = this.upgrader.version(node); 29 | return new UpgradeResult<>(original, newVer, node, original != newVer); 30 | } 31 | 32 | public ConfigurationTransformation.Versioned transform() { 33 | return this.upgrader; 34 | } 35 | 36 | public record UpgradeResult( 37 | int originalVersion, 38 | int newVersion, 39 | N node, 40 | boolean didUpgrade 41 | ) { 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /addons/deathspot/src/main/java/xyz/jpenilla/squaremap/addon/deathspot/DeathSpots.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.deathspot; 2 | 3 | import java.io.File; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | import java.util.UUID; 7 | import org.bukkit.Location; 8 | import org.bukkit.plugin.java.JavaPlugin; 9 | import xyz.jpenilla.squaremap.addon.deathspot.config.DeathSpotConfig; 10 | import xyz.jpenilla.squaremap.addon.deathspot.hook.SquaremapHook; 11 | import xyz.jpenilla.squaremap.addon.deathspot.listener.PlayerListener; 12 | import xyz.jpenilla.squaremap.api.Pair; 13 | 14 | public final class DeathSpots extends JavaPlugin { 15 | private static DeathSpots instance; 16 | private DeathSpotConfig config; 17 | private final Map> deathSpots = new HashMap<>(); 18 | private SquaremapHook squaremapHook; 19 | 20 | public DeathSpots() { 21 | instance = this; 22 | } 23 | 24 | @Override 25 | public void onEnable() { 26 | this.config = new DeathSpotConfig(this); 27 | this.config.reload(); 28 | 29 | if (!new File(this.getDataFolder(), "icon.png").exists()) { 30 | this.saveResource("icon.png", false); 31 | } 32 | 33 | this.getServer().getPluginManager().registerEvents(new PlayerListener(this), this); 34 | 35 | this.squaremapHook = new SquaremapHook(this); 36 | } 37 | 38 | @Override 39 | public void onDisable() { 40 | if (this.squaremapHook != null) { 41 | this.squaremapHook.disable(); 42 | } 43 | this.deathSpots.clear(); 44 | } 45 | 46 | public static DeathSpots getInstance() { 47 | return instance; 48 | } 49 | 50 | public Map> getDeathSpots() { 51 | return this.deathSpots; 52 | } 53 | 54 | public DeathSpotConfig config() { 55 | return this.config; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /addons/essentialsx/src/main/java/xyz/jpenilla/squaremap/addon/essentialsx/config/EssXWorldConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.essentialsx.config; 2 | 3 | import xyz.jpenilla.squaremap.addon.common.config.Config; 4 | import xyz.jpenilla.squaremap.addon.common.config.WorldConfig; 5 | 6 | @SuppressWarnings("unused") 7 | public final class EssXWorldConfig extends WorldConfig { 8 | public boolean enabled = true; 9 | 10 | private void worldSettings() { 11 | this.enabled = this.getBoolean("enabled", enabled); 12 | } 13 | 14 | public String warpsLabel = "Warps"; 15 | public boolean warpsShowControls = true; 16 | public boolean warpsControlsHidden = false; 17 | public int warpsPriority = 999; 18 | public int warpsZindex = 999; 19 | public String warpsTooltip = "{warp}"; 20 | 21 | private void layerSettings() { 22 | this.warpsLabel = this.getString("warps.label", this.warpsLabel); 23 | this.warpsShowControls = this.getBoolean("warps.show-controls", this.warpsShowControls); 24 | this.warpsControlsHidden = this.getBoolean("warps.hide-by-default", this.warpsControlsHidden); 25 | this.warpsPriority = this.getInt("warps.priority", this.warpsPriority); 26 | this.warpsZindex = this.getInt("warps.z-index", this.warpsZindex); 27 | this.warpsTooltip = this.getString("warps.tooltip", this.warpsTooltip); 28 | } 29 | 30 | public int iconSize = 16; 31 | public int iconAnchorX = 8; 32 | public int iconAnchorZ = 16; 33 | 34 | private void iconSettings() { 35 | this.iconSize = this.getInt("icon.size", this.iconSize); 36 | this.iconAnchorX = this.getInt("icon.anchor.x", this.iconAnchorX); 37 | this.iconAnchorZ = this.getInt("icon.anchor.z", this.iconAnchorZ); 38 | } 39 | 40 | private EssXWorldConfig(final Config parent, final String world) { 41 | super(parent, world); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /common/src/main/java/xyz/jpenilla/squaremap/addon/common/Util.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.common; 2 | 3 | import io.papermc.paper.text.PaperComponents; 4 | import java.lang.reflect.Method; 5 | import net.kyori.adventure.text.Component; 6 | import net.kyori.adventure.text.ComponentLike; 7 | import net.kyori.adventure.text.flattener.ComponentFlattener; 8 | import org.checkerframework.checker.nullness.qual.NonNull; 9 | import org.checkerframework.framework.qual.DefaultQualifier; 10 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 11 | 12 | @DefaultQualifier(NonNull.class) 13 | public final class Util { 14 | private Util() { 15 | } 16 | 17 | @SuppressWarnings("unchecked") 18 | public static RuntimeException rethrow(final Throwable t) throws X { 19 | throw (X) t; 20 | } 21 | 22 | public static String asHtml(final Component component) { 23 | try { 24 | return SquaremapProvider.get().htmlComponentSerializer().serialize(component); 25 | } catch (final Throwable thr) { 26 | // fallback for pre-1.2 27 | try { 28 | final Class s = Class.forName("xyz.jpenilla.squaremap.common.util.HtmlComponentSerializer"); 29 | final Method make = s.getDeclaredMethod("withFlattener", ComponentFlattener.class); 30 | final Object serializer = make.invoke(null, PaperComponents.flattener()); 31 | final Method serialize = s.getDeclaredMethod("serialize", ComponentLike.class); 32 | return (String) serialize.invoke(serializer, component); 33 | } catch (final ReflectiveOperationException ex) { 34 | final RuntimeException err = new RuntimeException("Failed to serialize component to HTML"); 35 | err.addSuppressed(thr); 36 | err.addSuppressed(ex); 37 | throw err; 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /addons/banners/src/main/java/xyz/jpenilla/squaremap/addon/banners/configuration/BannersWorldConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.banners.configuration; 2 | 3 | import xyz.jpenilla.squaremap.addon.common.config.Config; 4 | import xyz.jpenilla.squaremap.addon.common.config.WorldConfig; 5 | 6 | @SuppressWarnings("unused") 7 | public class BannersWorldConfig extends WorldConfig { 8 | public boolean enabled = true; 9 | public int updateInterval = 5; 10 | public boolean enableControls = true; 11 | public boolean controlsHiddenByDefault = false; 12 | public String tooltip = "
{name}
"; 13 | 14 | private BannersWorldConfig(Config parent, String world) { 15 | super(parent, world); 16 | } 17 | 18 | private void worldSettings() { 19 | enabled = getBoolean("enabled", enabled); 20 | updateInterval = getInt("update-interval", updateInterval); 21 | enableControls = getBoolean("controls.enabled", enableControls); 22 | controlsHiddenByDefault = getBoolean("controls.hidden-by-default", controlsHiddenByDefault); 23 | tooltip = getString("marker.tooltip", tooltip); 24 | } 25 | 26 | public String layerLabel = "Banners"; 27 | public boolean layerControls = true; 28 | public boolean layerControlsHidden = false; 29 | public int layerPriority = 999; 30 | public int layerZindex = 999; 31 | 32 | private void layerSettings() { 33 | layerLabel = getString("layer.label", layerLabel); 34 | layerControls = getBoolean("layer.controls.enabled", layerControls); 35 | layerControlsHidden = getBoolean("layer.controls.hide-by-default", layerControlsHidden); 36 | layerPriority = getInt("layer.priority", layerPriority); 37 | layerZindex = getInt("layer.z-index", layerZindex); 38 | } 39 | 40 | public int ICON_SIZE = 16; 41 | 42 | private void iconSettings() { 43 | ICON_SIZE = getInt("icon.size", ICON_SIZE); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /addons/vanish/src/main/java/xyz/jpenilla/squaremap/addon/vanish/SquaremapVanish.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.vanish; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.EventPriority; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.event.player.PlayerJoinEvent; 8 | import org.bukkit.plugin.java.JavaPlugin; 9 | import xyz.jpenilla.squaremap.api.Squaremap; 10 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 11 | 12 | public final class SquaremapVanish extends JavaPlugin implements Listener { 13 | private Squaremap squaremap; 14 | 15 | private VanishAdapter vanishAdapter = null; 16 | 17 | @Override 18 | public void onEnable() { 19 | this.squaremap = SquaremapProvider.get(); 20 | 21 | final boolean superVanish = this.getServer().getPluginManager().isPluginEnabled("SuperVanish") || 22 | this.getServer().getPluginManager().isPluginEnabled("PremiumVanish"); 23 | if (superVanish) { 24 | this.vanishAdapter = new SuperVanish(this.squaremap); 25 | } 26 | 27 | if (this.vanishAdapter == null) { 28 | this.getLogger().info("You have installed squaremap-vanish without any explicitly supported vanish plugins (SuperVanish, PremiumVanish). Trying to get vanish status from 'vanished' player metadata value used by some vanish plugins."); 29 | this.vanishAdapter = new VanishFallback(this, squaremap); 30 | } 31 | 32 | this.getServer().getPluginManager().registerEvents(this, this); 33 | this.getServer().getPluginManager().registerEvents(vanishAdapter, this); 34 | } 35 | 36 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 37 | public void join(final PlayerJoinEvent event) { 38 | final Player player = event.getPlayer(); 39 | if (this.vanishAdapter.isVanished(player)) { 40 | this.squaremap.playerManager().hide(player.getUniqueId()); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /addons/mobs/src/main/java/xyz/jpenilla/squaremap/addon/mobs/hook/SquaremapHook.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.mobs.hook; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import xyz.jpenilla.squaremap.addon.mobs.SquaremapMobs; 6 | import xyz.jpenilla.squaremap.addon.mobs.config.MobsWorldConfig; 7 | import xyz.jpenilla.squaremap.addon.mobs.task.SquaremapTask; 8 | import xyz.jpenilla.squaremap.api.Key; 9 | import xyz.jpenilla.squaremap.api.MapWorld; 10 | import xyz.jpenilla.squaremap.api.SimpleLayerProvider; 11 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 12 | import xyz.jpenilla.squaremap.api.WorldIdentifier; 13 | 14 | public final class SquaremapHook { 15 | private static final Key MOBS_LAYER_KEY = Key.of("mobs"); 16 | 17 | private final Map tasks = new HashMap<>(); 18 | private final SquaremapMobs plugin; 19 | 20 | public SquaremapHook(SquaremapMobs plugin) { 21 | this.plugin = plugin; 22 | } 23 | 24 | public void load() { 25 | for (final MapWorld mapWorld : SquaremapProvider.get().mapWorlds()) { 26 | final MobsWorldConfig worldConfig = this.plugin.config().worldConfig(mapWorld.identifier()); 27 | if (!worldConfig.enabled) { 28 | continue; 29 | } 30 | 31 | final SimpleLayerProvider provider = SimpleLayerProvider.builder(worldConfig.layerLabel) 32 | .showControls(worldConfig.layerShowControls) 33 | .defaultHidden(worldConfig.layerControlsHidden) 34 | .build(); 35 | mapWorld.layerRegistry().register(MOBS_LAYER_KEY, provider); 36 | final SquaremapTask task = new SquaremapTask(mapWorld, worldConfig, provider); 37 | task.runTaskTimer(this.plugin, 0, 20L * this.plugin.config().updateInterval); 38 | this.tasks.put(mapWorld.identifier(), task); 39 | } 40 | } 41 | 42 | public void disable() { 43 | this.tasks.values().forEach(SquaremapTask::disable); 44 | this.tasks.clear(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /addons/griefprevention/src/main/java/xyz/jpenilla/squaremap/addon/griefprevention/hook/SquaremapHook.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.griefprevention.hook; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import org.bukkit.World; 6 | import xyz.jpenilla.squaremap.addon.griefprevention.SquaremapGriefPrevention; 7 | import xyz.jpenilla.squaremap.addon.griefprevention.task.SquaremapTask; 8 | import xyz.jpenilla.squaremap.api.BukkitAdapter; 9 | import xyz.jpenilla.squaremap.api.Key; 10 | import xyz.jpenilla.squaremap.api.MapWorld; 11 | import xyz.jpenilla.squaremap.api.SimpleLayerProvider; 12 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 13 | import xyz.jpenilla.squaremap.api.WorldIdentifier; 14 | 15 | public final class SquaremapHook { 16 | private static final Key GP_LAYER_KEY = Key.of("griefprevention"); 17 | 18 | private final Map tasks = new HashMap<>(); 19 | 20 | public SquaremapHook(SquaremapGriefPrevention plugin) { 21 | for (final MapWorld world : SquaremapProvider.get().mapWorlds()) { 22 | final World bukkitWorld = BukkitAdapter.bukkitWorld(world); 23 | if (!GPHook.isWorldEnabled(bukkitWorld.getUID())) { 24 | continue; 25 | } 26 | 27 | SimpleLayerProvider provider = SimpleLayerProvider 28 | .builder(plugin.config().controlLabel) 29 | .showControls(plugin.config().controlShow) 30 | .defaultHidden(plugin.config().controlHide) 31 | .zIndex(plugin.config().zIndex) 32 | .layerPriority(plugin.config().layerPriority) 33 | .build(); 34 | world.layerRegistry().register(GP_LAYER_KEY, provider); 35 | SquaremapTask task = new SquaremapTask(plugin, world, provider); 36 | task.runTaskTimerAsynchronously(plugin, 0, 20L * plugin.config().updateInterval); 37 | this.tasks.put(world.identifier(), task); 38 | } 39 | } 40 | 41 | public void disable() { 42 | this.tasks.values().forEach(SquaremapTask::disable); 43 | this.tasks.clear(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /addons/signs/src/main/java/xyz/jpenilla/squaremap/addon/signs/data/Icons.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.signs.data; 2 | 3 | import java.awt.image.BufferedImage; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import javax.imageio.ImageIO; 9 | import org.bukkit.plugin.java.JavaPlugin; 10 | import xyz.jpenilla.squaremap.api.Key; 11 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 12 | 13 | public final class Icons { 14 | private static final List KEYS = new ArrayList<>(); 15 | 16 | public static final Key OAK = icon("sign_oak"); 17 | public static final Key SPRUCE = icon("sign_spruce"); 18 | public static final Key BIRCH = icon("sign_birch"); 19 | public static final Key JUNGLE = icon("sign_jungle"); 20 | public static final Key ACACIA = icon("sign_acacia"); 21 | public static final Key DARK_OAK = icon("sign_dark_oak"); 22 | public static final Key CRIMSON = icon("sign_crimson"); 23 | public static final Key WARPED = icon("sign_warped"); 24 | 25 | private static Key icon(final String name) { 26 | final Key key = Key.of(name); 27 | KEYS.add(key); 28 | return key; 29 | } 30 | 31 | public static void register(final JavaPlugin plugin) { 32 | try { 33 | for (final Key key : KEYS) { 34 | final String filename = "icons" + File.separator + key.getKey() + ".png"; 35 | final File file = new File(plugin.getDataFolder(), filename); 36 | if (!file.exists()) { 37 | plugin.saveResource(filename, false); 38 | } 39 | final BufferedImage image = ImageIO.read(file); 40 | SquaremapProvider.get().iconRegistry().register(key, image); 41 | } 42 | } catch (final IOException e) { 43 | throw new RuntimeException("Failed to register signs icons", e); 44 | } 45 | } 46 | 47 | public static void unregister() { 48 | for (final Key key : KEYS) { 49 | SquaremapProvider.get().iconRegistry().unregister(key); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /addons/claimchunk/src/main/java/xyz/jpenilla/squaremap/addon/claimchunk/config/ClaimChunkConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.claimchunk.config; 2 | 3 | import java.awt.Color; 4 | import org.bukkit.plugin.Plugin; 5 | import xyz.jpenilla.squaremap.addon.common.config.Config; 6 | import xyz.jpenilla.squaremap.addon.common.config.WorldConfig; 7 | 8 | public final class ClaimChunkConfig extends Config { 9 | public String controlLabel = "ClaimChunk"; 10 | public boolean controlShow = true; 11 | public boolean controlHide = false; 12 | public int updateInterval = 300; 13 | public Color strokeColor = Color.RED; 14 | public int strokeWeight = 2; 15 | public double strokeOpacity = 0.75D; 16 | public Color fillColor = Color.RED; 17 | public double fillOpacity = 0.2D; 18 | public String claimTooltip = "{name}"; 19 | public boolean showChunks = false; 20 | 21 | @SuppressWarnings("unused") 22 | private void init() { 23 | this.controlLabel = this.getString("settings.control.label", this.controlLabel); 24 | this.controlShow = this.getBoolean("settings.control.show", this.controlShow); 25 | this.controlHide = this.getBoolean("settings.control.hide-by-default", this.controlHide); 26 | this.updateInterval = this.getInt("settings.update-interval", this.updateInterval); 27 | this.strokeColor = this.getColor("settings.style.stroke.color", this.strokeColor); 28 | this.strokeWeight = this.getInt("settings.style.stroke.weight", this.strokeWeight); 29 | this.strokeOpacity = this.getDouble("settings.style.stroke.opacity", this.strokeOpacity); 30 | this.fillColor = this.getColor("settings.style.fill.color", this.fillColor); 31 | this.fillOpacity = this.getDouble("settings.style.fill.opacity", this.fillOpacity); 32 | this.claimTooltip = this.getString("settings.claim.tooltip", this.claimTooltip); 33 | this.showChunks = this.getBoolean("settings.claim.show-chunks", this.showChunks); 34 | } 35 | 36 | public ClaimChunkConfig(final Plugin plugin) { 37 | super(ClaimChunkConfig.class, plugin); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /addons/signs/src/main/java/xyz/jpenilla/squaremap/addon/signs/SignsPlugin.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.signs; 2 | 3 | import org.bukkit.plugin.java.JavaPlugin; 4 | import xyz.jpenilla.squaremap.addon.signs.config.SignsConfig; 5 | import xyz.jpenilla.squaremap.addon.signs.data.CustomIcons; 6 | import xyz.jpenilla.squaremap.addon.signs.data.Icons; 7 | import xyz.jpenilla.squaremap.addon.signs.data.SignManager; 8 | import xyz.jpenilla.squaremap.addon.signs.hook.LayerProviderManager; 9 | import xyz.jpenilla.squaremap.addon.signs.listener.SignListener; 10 | import xyz.jpenilla.squaremap.addon.signs.listener.WorldListener; 11 | 12 | public final class SignsPlugin extends JavaPlugin { 13 | private static SignsPlugin instance; 14 | private LayerProviderManager layerProviderManager; 15 | private SignManager signManager; 16 | private SignsConfig config; 17 | private CustomIcons customIcons; 18 | 19 | public SignsPlugin() { 20 | instance = this; 21 | } 22 | 23 | @Override 24 | public void onEnable() { 25 | this.config = new SignsConfig(this); 26 | this.config.reload(); 27 | 28 | Icons.register(this); 29 | this.customIcons = CustomIcons.register(this); 30 | 31 | this.layerProviderManager = new LayerProviderManager(this); 32 | this.signManager = new SignManager(this); 33 | this.layerProviderManager.load(); 34 | 35 | this.getServer().getPluginManager().registerEvents(new SignListener(this), this); 36 | this.getServer().getPluginManager().registerEvents(new WorldListener(this), this); 37 | } 38 | 39 | @Override 40 | public void onDisable() { 41 | if (this.layerProviderManager != null) { 42 | this.layerProviderManager.disable(); 43 | this.layerProviderManager = null; 44 | } 45 | this.signManager = null; 46 | 47 | this.customIcons.unregister(); 48 | Icons.unregister(); 49 | } 50 | 51 | public static SignsPlugin instance() { 52 | return instance; 53 | } 54 | 55 | public LayerProviderManager layerProviders() { 56 | return this.layerProviderManager; 57 | } 58 | 59 | public SignManager signManager() { 60 | return this.signManager; 61 | } 62 | 63 | public SignsConfig config() { 64 | return this.config; 65 | } 66 | 67 | public CustomIcons customIcons() { 68 | return this.customIcons; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories { 3 | mavenCentral() 4 | maven("https://repo.papermc.io/repository/maven-public/") 5 | maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") { 6 | mavenContent { 7 | snapshotsOnly() 8 | includeGroup("xyz.jpenilla") 9 | } 10 | } 11 | maven("https://maven.enginehub.org/repo/") { 12 | mavenContent { 13 | includeGroup("com.sk89q") 14 | includeGroupByRegex("com\\.sk89q\\..*") 15 | } 16 | } 17 | maven("https://repo.essentialsx.net/releases/") { 18 | mavenContent { 19 | includeGroup("net.essentialsx") 20 | } 21 | } 22 | maven("https://jitpack.io/") { 23 | mavenContent { 24 | includeGroupByRegex("com\\.github\\..*") 25 | } 26 | } 27 | modrinthMavenWorkaround( 28 | "claimchunk", 29 | "0.0.25-FIX3", 30 | "claimchunk-0.0.25-FIX3-plugin.jar" 31 | ) 32 | } 33 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 34 | } 35 | 36 | plugins { 37 | id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" 38 | } 39 | 40 | rootProject.name = "squaremap-addons" 41 | 42 | include(":common") 43 | 44 | includeAddon("signs") 45 | includeAddon("mobs") 46 | includeAddon("worldguard") 47 | includeAddon("essentialsx") 48 | includeAddon("deathspot") 49 | includeAddon("skins") 50 | includeAddon("griefprevention") 51 | includeAddon("claimchunk") 52 | includeAddon("banners") 53 | includeAddon("vanish") 54 | 55 | fun includeAddon(addonName: String) { 56 | val name = "squaremap-$addonName" 57 | include(name) 58 | project(":$name").apply { 59 | projectDir = file("addons/$addonName") 60 | } 61 | } 62 | 63 | // https://github.com/modrinth/code/issues/2428 64 | fun RepositoryHandler.modrinthMavenWorkaround(nameOrId: String, version: String, fileName: String) { 65 | val url = "https://api.modrinth.com/maven/maven/modrinth/$nameOrId/$version/$fileName" 66 | val group = "maven.modrinth.workaround" 67 | ivy(url.substringBeforeLast('/')) { 68 | name = "Modrinth Maven Workaround for $nameOrId" 69 | patternLayout { artifact(url.substringAfterLast('/')) } 70 | metadataSources { artifact() } 71 | content { includeModule(group, nameOrId) } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /addons/banners/src/main/java/xyz/jpenilla/squaremap/addon/banners/hook/SquaremapHook.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.banners.hook; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.World; 7 | import xyz.jpenilla.squaremap.addon.banners.SquaremapBanners; 8 | import xyz.jpenilla.squaremap.addon.banners.configuration.BannersWorldConfig; 9 | import xyz.jpenilla.squaremap.addon.banners.data.BannerLayerProvider; 10 | import xyz.jpenilla.squaremap.api.BukkitAdapter; 11 | import xyz.jpenilla.squaremap.api.Key; 12 | import xyz.jpenilla.squaremap.api.MapWorld; 13 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 14 | import xyz.jpenilla.squaremap.api.WorldIdentifier; 15 | 16 | public class SquaremapHook { 17 | private static final Key BANNERS_LAYER = Key.key("banners"); 18 | 19 | private final Map providers = new HashMap<>(); 20 | 21 | public Map getProviders() { 22 | return this.providers; 23 | } 24 | 25 | public void load() { 26 | Bukkit.getWorlds().forEach(this::getProvider); 27 | } 28 | 29 | public BannerLayerProvider getProvider(World world) { 30 | BannerLayerProvider provider = this.providers.get(BukkitAdapter.worldIdentifier(world)); 31 | if (provider != null) { 32 | return provider; 33 | } 34 | MapWorld mapWorld = SquaremapProvider.get().getWorldIfEnabled(BukkitAdapter.worldIdentifier(world)).orElse(null); 35 | if (mapWorld == null) { 36 | return null; 37 | } 38 | BannersWorldConfig worldConfig = SquaremapBanners.instance().config().worldConfig(mapWorld.identifier()); 39 | if (!worldConfig.enabled) { 40 | return null; 41 | } 42 | provider = new BannerLayerProvider(worldConfig); 43 | Key key = Key.of("banners"); 44 | mapWorld.layerRegistry().register(key, provider); 45 | this.providers.put(mapWorld.identifier(), provider); 46 | return provider; 47 | } 48 | 49 | public void unloadProvider(World world) { 50 | unloadProvider(BukkitAdapter.worldIdentifier(world)); 51 | } 52 | 53 | public void unloadProvider(WorldIdentifier id) { 54 | SquaremapProvider.get().getWorldIfEnabled(id).ifPresent(world -> world.layerRegistry().unregister(BANNERS_LAYER)); 55 | } 56 | 57 | public void disable() { 58 | this.providers.forEach((uuid, provider) -> unloadProvider(uuid)); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /addons/banners/src/main/java/xyz/jpenilla/squaremap/addon/banners/SquaremapBanners.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.banners; 2 | 3 | import org.bukkit.plugin.java.JavaPlugin; 4 | import xyz.jpenilla.squaremap.addon.banners.configuration.BannersConfig; 5 | import xyz.jpenilla.squaremap.addon.banners.data.BannersManager; 6 | import xyz.jpenilla.squaremap.addon.banners.data.Icons; 7 | import xyz.jpenilla.squaremap.addon.banners.hook.SquaremapHook; 8 | import xyz.jpenilla.squaremap.addon.banners.listener.BannersListener; 9 | import xyz.jpenilla.squaremap.addon.banners.listener.WorldListener; 10 | import xyz.jpenilla.squaremap.api.Key; 11 | 12 | public final class SquaremapBanners extends JavaPlugin { 13 | private static SquaremapBanners instance; 14 | private SquaremapHook squaremapHook; 15 | private BannersManager bannerManager; 16 | private BannersConfig config; 17 | 18 | public SquaremapBanners() { 19 | instance = this; 20 | } 21 | 22 | @Override 23 | public void onEnable() { 24 | this.config = new BannersConfig(this); 25 | this.config.reload(); 26 | 27 | //noinspection unused 28 | Key loadme = Icons.WHITE; 29 | 30 | squaremapHook = new SquaremapHook(); 31 | squaremapHook.load(); 32 | 33 | bannerManager = new BannersManager(this); 34 | bannerManager.load(); 35 | 36 | getServer().getPluginManager().registerEvents(new BannersListener(this), this); 37 | getServer().getPluginManager().registerEvents(new WorldListener(this), this); 38 | } 39 | 40 | @Override 41 | public void onDisable() { 42 | if (bannerManager != null) { 43 | bannerManager.save(); 44 | bannerManager = null; 45 | } 46 | 47 | if (squaremapHook != null) { 48 | squaremapHook.disable(); 49 | bannerManager = null; 50 | } 51 | } 52 | 53 | public BannersConfig config() { 54 | return this.config; 55 | } 56 | 57 | public static SquaremapBanners instance() { 58 | return instance; 59 | } 60 | 61 | public SquaremapHook squaremapHook() { 62 | return squaremapHook; 63 | } 64 | 65 | public BannersManager bannerManager() { 66 | return bannerManager; 67 | } 68 | 69 | public void debug(String msg) { 70 | if (!this.config().debugMode) { 71 | return; 72 | } 73 | for (String part : msg.split("\n")) { 74 | this.getLogger().info("[debug] " + part); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /addons/worldguard/src/main/java/xyz/jpenilla/squaremap/addon/worldguard/config/WGWorldConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.worldguard.config; 2 | 3 | import io.leangen.geantyref.TypeToken; 4 | import java.util.ArrayList; 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | import xyz.jpenilla.squaremap.addon.common.config.Config; 9 | import xyz.jpenilla.squaremap.addon.common.config.ListMode; 10 | import xyz.jpenilla.squaremap.addon.common.config.WorldConfig; 11 | 12 | public class WGWorldConfig extends WorldConfig { 13 | public String controlLabel = "WorldGuard"; 14 | public boolean controlShow = true; 15 | public boolean controlHide = false; 16 | public int updateInterval = 300; 17 | public StyleSettings defaultStyle = StyleSettings.defaultSettings(); 18 | public ListMode listMode = ListMode.BLACKLIST; 19 | public List regionList = new ArrayList<>(); 20 | public ListMode flagListMode = ListMode.BLACKLIST; 21 | public List flagList = List.of( 22 | "squaremap-visible", 23 | "squaremap-stroke-color", 24 | "squaremap-stroke-weight", 25 | "squaremap-stroke-opacity", 26 | "squaremap-fill-color", 27 | "squaremap-fill-opacity", 28 | "squaremap-click-tooltip" 29 | ); 30 | public Map styleOverrides = new HashMap<>(); 31 | 32 | @SuppressWarnings("unused") 33 | private void init() { 34 | this.controlLabel = this.getString("control.label", this.controlLabel); 35 | this.controlShow = this.getBoolean("control.show", this.controlShow); 36 | this.controlHide = this.getBoolean("control.hide-by-default", this.controlHide); 37 | this.updateInterval = this.getInt("update-interval", this.updateInterval); 38 | this.defaultStyle = this.get("default-style", StyleSettings.class, this.defaultStyle); 39 | this.defaultStyle.validate(); 40 | this.listMode = this.getEnum("regions.list-mode", ListMode.class, this.listMode); 41 | this.regionList = this.getList(String.class, "regions.list", this.regionList); 42 | this.flagListMode = this.getEnum("flags.list-mode", ListMode.class, this.flagListMode); 43 | this.flagList = this.getList(String.class, "flags.list", this.flagList); 44 | this.styleOverrides = this.get("style-overrides", new TypeToken>() {}.getType(), this.styleOverrides); 45 | } 46 | 47 | protected WGWorldConfig(final Config parent, final String world) { 48 | super(parent, world); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /addons/deathspot/src/main/java/xyz/jpenilla/squaremap/addon/deathspot/task/SquaremapTask.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.deathspot.task; 2 | 3 | import java.util.UUID; 4 | import org.bukkit.Location; 5 | import org.bukkit.World; 6 | import org.bukkit.scheduler.BukkitRunnable; 7 | import xyz.jpenilla.squaremap.addon.deathspot.DeathSpots; 8 | import xyz.jpenilla.squaremap.addon.deathspot.config.DeathSpotWorldConfig; 9 | import xyz.jpenilla.squaremap.addon.deathspot.hook.SquaremapHook; 10 | import xyz.jpenilla.squaremap.api.BukkitAdapter; 11 | import xyz.jpenilla.squaremap.api.Key; 12 | import xyz.jpenilla.squaremap.api.MapWorld; 13 | import xyz.jpenilla.squaremap.api.SimpleLayerProvider; 14 | import xyz.jpenilla.squaremap.api.marker.Icon; 15 | import xyz.jpenilla.squaremap.api.marker.Marker; 16 | import xyz.jpenilla.squaremap.api.marker.MarkerOptions; 17 | 18 | public final class SquaremapTask extends BukkitRunnable { 19 | private final DeathSpots plugin; 20 | private final SimpleLayerProvider provider; 21 | private final DeathSpotWorldConfig worldConfig; 22 | private final MapWorld world; 23 | 24 | private boolean stop; 25 | 26 | public SquaremapTask(DeathSpots plugin, MapWorld world, SimpleLayerProvider provider) { 27 | this.plugin = plugin; 28 | this.world = world; 29 | this.provider = provider; 30 | this.worldConfig = plugin.config().worldConfig(world.identifier()); 31 | } 32 | 33 | @Override 34 | public void run() { 35 | if (this.stop) { 36 | this.cancel(); 37 | } 38 | 39 | this.provider.clearMarkers(); 40 | 41 | final World bukkitWorld = BukkitAdapter.bukkitWorld(this.world); 42 | 43 | this.plugin.getDeathSpots().forEach((uuid, pair) -> { 44 | if (pair.right().getWorld().getUID().equals(bukkitWorld.getUID())) { 45 | this.handle(uuid, pair.left(), pair.right()); 46 | } 47 | }); 48 | } 49 | 50 | private void handle(UUID uuid, String name, Location location) { 51 | Icon icon = Marker.icon(BukkitAdapter.point(location), SquaremapHook.DEATH_SPOT_ICON_KEY, 16); 52 | 53 | icon.markerOptions( 54 | MarkerOptions.builder() 55 | .hoverTooltip(worldConfig.tooltip.replace("{name}", name)) 56 | ); 57 | 58 | final String markerid = "deathspots_player_" + uuid; 59 | this.provider.addMarker(Key.of(markerid), icon); 60 | } 61 | 62 | public void disable() { 63 | this.cancel(); 64 | this.stop = true; 65 | this.provider.clearMarkers(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /addons/deathspot/src/main/java/xyz/jpenilla/squaremap/addon/deathspot/hook/SquaremapHook.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.deathspot.hook; 2 | 3 | import java.awt.image.BufferedImage; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | import java.util.logging.Level; 9 | import javax.imageio.ImageIO; 10 | import xyz.jpenilla.squaremap.addon.deathspot.DeathSpots; 11 | import xyz.jpenilla.squaremap.addon.deathspot.config.DeathSpotWorldConfig; 12 | import xyz.jpenilla.squaremap.addon.deathspot.task.SquaremapTask; 13 | import xyz.jpenilla.squaremap.api.Key; 14 | import xyz.jpenilla.squaremap.api.MapWorld; 15 | import xyz.jpenilla.squaremap.api.SimpleLayerProvider; 16 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 17 | import xyz.jpenilla.squaremap.api.WorldIdentifier; 18 | 19 | import static xyz.jpenilla.squaremap.api.Key.key; 20 | 21 | public final class SquaremapHook { 22 | public static final Key DEATH_SPOT_ICON_KEY = key("deathspot_icon"); 23 | private static final Key DEATH_SPOTS_LAYER_KEY = key("deathspots"); 24 | 25 | private final Map tasks = new HashMap<>(); 26 | 27 | public SquaremapHook(final DeathSpots plugin) { 28 | try { 29 | final BufferedImage image = ImageIO.read(new File(plugin.getDataFolder(), "icon.png")); 30 | SquaremapProvider.get().iconRegistry().register(DEATH_SPOT_ICON_KEY, image); 31 | } catch (final IOException e) { 32 | plugin.getLogger().log(Level.WARNING, "Failed to register deathspot icon", e); 33 | } 34 | 35 | for (final MapWorld world : SquaremapProvider.get().mapWorlds()) { 36 | final DeathSpotWorldConfig worldConfig = plugin.config().worldConfig(world.identifier()); 37 | if (!worldConfig.enabled) { 38 | continue; 39 | } 40 | 41 | final SimpleLayerProvider provider = SimpleLayerProvider.builder("DeathSpots") 42 | .showControls(worldConfig.enableControls) 43 | .defaultHidden(worldConfig.controlsHiddenByDefault) 44 | .build(); 45 | world.layerRegistry().register(DEATH_SPOTS_LAYER_KEY, provider); 46 | 47 | final SquaremapTask task = new SquaremapTask(plugin, world, provider); 48 | task.runTaskTimerAsynchronously(plugin, 0, 20L * worldConfig.updateInterval); 49 | 50 | this.tasks.put(world.identifier(), task); 51 | } 52 | } 53 | 54 | public void disable() { 55 | this.tasks.values().forEach(SquaremapTask::disable); 56 | this.tasks.clear(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /addons/essentialsx/src/main/java/xyz/jpenilla/squaremap/addon/essentialsx/hook/SquaremapHook.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.essentialsx.hook; 2 | 3 | import java.awt.image.BufferedImage; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | import javax.imageio.ImageIO; 9 | import xyz.jpenilla.squaremap.addon.essentialsx.SquaremapEssentials; 10 | import xyz.jpenilla.squaremap.addon.essentialsx.config.EssXWorldConfig; 11 | import xyz.jpenilla.squaremap.addon.essentialsx.task.SquaremapTask; 12 | import xyz.jpenilla.squaremap.api.Key; 13 | import xyz.jpenilla.squaremap.api.MapWorld; 14 | import xyz.jpenilla.squaremap.api.SimpleLayerProvider; 15 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 16 | import xyz.jpenilla.squaremap.api.WorldIdentifier; 17 | 18 | import static xyz.jpenilla.squaremap.api.Key.key; 19 | 20 | public final class SquaremapHook { 21 | public static final Key WARP_ICON_KEY = key("essentials_warp_icon"); 22 | 23 | private final Map tasks = new HashMap<>(); 24 | private final SquaremapEssentials plugin; 25 | 26 | public SquaremapHook(SquaremapEssentials squaremapEssentials) { 27 | this.plugin = squaremapEssentials; 28 | } 29 | 30 | public void load() { 31 | try { 32 | BufferedImage icon = ImageIO.read(new File(this.plugin.getDataFolder(), "warp.png")); 33 | SquaremapProvider.get().iconRegistry().register(WARP_ICON_KEY, icon); 34 | } catch (IOException e) { 35 | throw new RuntimeException("Failed to register warp icon", e); 36 | } 37 | 38 | for (final MapWorld mapWorld : SquaremapProvider.get().mapWorlds()) { 39 | EssXWorldConfig worldConfig = this.plugin.config().worldConfig(mapWorld.identifier()); 40 | if (!worldConfig.enabled) { 41 | continue; 42 | } 43 | 44 | SimpleLayerProvider provider = SimpleLayerProvider.builder(worldConfig.warpsLabel) 45 | .showControls(worldConfig.warpsShowControls) 46 | .defaultHidden(worldConfig.warpsControlsHidden) 47 | .build(); 48 | mapWorld.layerRegistry().register(Key.of("essentials_warps"), provider); 49 | SquaremapTask task = new SquaremapTask(mapWorld, worldConfig, provider); 50 | task.runTaskTimerAsynchronously(this.plugin, 0, 20L * this.plugin.config().updateInterval); 51 | this.tasks.put(mapWorld.identifier(), task); 52 | } 53 | } 54 | 55 | public void disable() { 56 | this.tasks.values().forEach(SquaremapTask::disable); 57 | this.tasks.clear(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /addons/banners/src/main/java/xyz/jpenilla/squaremap/addon/banners/data/BannerLayerProvider.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.banners.data; 2 | 3 | import java.util.Collection; 4 | import java.util.Map; 5 | import java.util.Set; 6 | import java.util.concurrent.ConcurrentHashMap; 7 | import java.util.stream.Collectors; 8 | import org.checkerframework.checker.nullness.qual.NonNull; 9 | import xyz.jpenilla.squaremap.addon.banners.SquaremapBanners; 10 | import xyz.jpenilla.squaremap.addon.banners.configuration.BannersWorldConfig; 11 | import xyz.jpenilla.squaremap.api.Key; 12 | import xyz.jpenilla.squaremap.api.LayerProvider; 13 | import xyz.jpenilla.squaremap.api.marker.Icon; 14 | import xyz.jpenilla.squaremap.api.marker.Marker; 15 | import xyz.jpenilla.squaremap.api.marker.MarkerOptions; 16 | 17 | public class BannerLayerProvider implements LayerProvider { 18 | private final Map data = new ConcurrentHashMap<>(); 19 | private final BannersWorldConfig worldConfig; 20 | 21 | public BannerLayerProvider(BannersWorldConfig worldConfig) { 22 | this.worldConfig = worldConfig; 23 | } 24 | 25 | @Override 26 | public @NonNull String getLabel() { 27 | return this.worldConfig.layerLabel; 28 | } 29 | 30 | @Override 31 | public boolean showControls() { 32 | return this.worldConfig.layerControls; 33 | } 34 | 35 | @Override 36 | public boolean defaultHidden() { 37 | return this.worldConfig.layerControlsHidden; 38 | } 39 | 40 | @Override 41 | public int layerPriority() { 42 | return this.worldConfig.layerPriority; 43 | } 44 | 45 | @Override 46 | public int zIndex() { 47 | return this.worldConfig.layerZindex; 48 | } 49 | 50 | @Override 51 | public @NonNull Collection getMarkers() { 52 | return this.data.values().stream() 53 | .map(Data::marker) 54 | .collect(Collectors.toSet()); 55 | } 56 | 57 | public Set getPositions() { 58 | return this.data.keySet(); 59 | } 60 | 61 | public Map getData() { 62 | return this.data; 63 | } 64 | 65 | public void add(Position position, Key key, String name) { 66 | name = name == null ? "null" : name; 67 | SquaremapBanners.instance().debug(position + " icon: " + key + " name: " + name); 68 | Icon icon = Marker.icon(position.point(), key, worldConfig.ICON_SIZE); 69 | icon.markerOptions(MarkerOptions.builder() 70 | .hoverTooltip(worldConfig.tooltip 71 | .replace("{name}", name))); 72 | this.data.put(position, new Data(icon, key, name)); 73 | } 74 | 75 | public void remove(Position position) { 76 | SquaremapBanners.instance().debug("Removing banner from " + position); 77 | this.data.remove(position); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /addons/worldguard/src/main/java/xyz/jpenilla/squaremap/addon/worldguard/SquaremapWorldGuard.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.worldguard; 2 | 3 | import com.sk89q.worldguard.WorldGuard; 4 | import com.sk89q.worldguard.protection.flags.DoubleFlag; 5 | import com.sk89q.worldguard.protection.flags.IntegerFlag; 6 | import com.sk89q.worldguard.protection.flags.StateFlag; 7 | import com.sk89q.worldguard.protection.flags.StringFlag; 8 | import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; 9 | import java.util.List; 10 | import org.bukkit.plugin.java.JavaPlugin; 11 | import xyz.jpenilla.squaremap.addon.worldguard.config.WGConfig; 12 | import xyz.jpenilla.squaremap.addon.worldguard.hook.SquaremapHook; 13 | 14 | public final class SquaremapWorldGuard extends JavaPlugin { 15 | private SquaremapHook squaremapHook; 16 | private WGConfig config; 17 | public StateFlag visibleFlag; 18 | public StringFlag strokeColorFlag; 19 | public IntegerFlag strokeWeightFlag; 20 | public DoubleFlag strokeOpacityFlag; 21 | public StringFlag fillColorFlag; 22 | public DoubleFlag fillOpacityFlag; 23 | public StringFlag clickTooltipFlag; 24 | 25 | @Override 26 | public void onEnable() { 27 | this.config = new WGConfig(this); 28 | this.config.reload(); 29 | 30 | this.squaremapHook = new SquaremapHook(this); 31 | this.getServer().getPluginManager().registerEvents(new EventListener(this), this); 32 | } 33 | 34 | @Override 35 | public void onLoad() { 36 | this.setupFlags(); 37 | } 38 | 39 | private void setupFlags() { 40 | this.visibleFlag = new StateFlag("squaremap-visible", true); 41 | this.strokeColorFlag = new StringFlag("squaremap-stroke-color", (String) null); 42 | this.strokeWeightFlag = new IntegerFlag("squaremap-stroke-weight"); 43 | this.strokeOpacityFlag = new DoubleFlag("squaremap-stroke-opacity"); 44 | this.fillColorFlag = new StringFlag("squaremap-fill-color", (String) null); 45 | this.fillOpacityFlag = new DoubleFlag("squaremap-fill-opacity"); 46 | this.clickTooltipFlag = new StringFlag("squaremap-click-tooltip", (String) null); 47 | 48 | final FlagRegistry flagRegistry = WorldGuard.getInstance().getFlagRegistry(); 49 | flagRegistry.registerAll(List.of( 50 | this.visibleFlag, this.strokeColorFlag, this.strokeWeightFlag, this.strokeOpacityFlag, this.fillColorFlag, this.fillOpacityFlag, this.clickTooltipFlag 51 | )); 52 | } 53 | 54 | @Override 55 | public void onDisable() { 56 | if (this.squaremapHook != null) { 57 | this.squaremapHook.disable(); 58 | } 59 | } 60 | 61 | public WGConfig config() { 62 | return this.config; 63 | } 64 | 65 | public SquaremapHook squaremapHook() { 66 | return this.squaremapHook; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /addons/worldguard/src/main/java/xyz/jpenilla/squaremap/addon/worldguard/config/WGConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.worldguard.config; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import org.bukkit.plugin.Plugin; 6 | import org.spongepowered.configurate.ConfigurationNode; 7 | import org.spongepowered.configurate.NodePath; 8 | import org.spongepowered.configurate.transformation.ConfigurationTransformation; 9 | import org.spongepowered.configurate.transformation.TransformAction; 10 | import xyz.jpenilla.squaremap.addon.common.config.Config; 11 | import xyz.jpenilla.squaremap.addon.common.config.ListMode; 12 | 13 | public final class WGConfig extends Config { 14 | public WGConfig(Plugin plugin) { 15 | super(WGConfig.class, WGWorldConfig.class, plugin); 16 | } 17 | 18 | @Override 19 | protected void addVersions(final ConfigurationTransformation.VersionedBuilder versionedBuilder) { 20 | final ConfigurationTransformation zeroToOne = ConfigurationTransformation.builder() 21 | .addAction(NodePath.path("settings", "style"), (path, node) -> new Object[]{"settings", "default-style"}) 22 | .addAction(NodePath.path("settings", "region", "tooltip"), (path, node) -> new Object[]{"settings", "default-style", "click-tooltip"}) 23 | .addAction(NodePath.path("settings", "region"), TransformAction.remove()) 24 | .build(); 25 | 26 | final ConfigurationTransformation oneToTwo = ConfigurationTransformation.builder() 27 | .addAction(NodePath.path("settings"), (path, node) -> new Object[]{"world-settings", "default"}) 28 | .build(); 29 | 30 | final ConfigurationTransformation twoToThree = ConfigurationTransformation.builder() 31 | .addAction(NodePath.path("world-settings", "default", "flags"), (path, node) -> { 32 | if (node.node("list-mode").get(ListMode.class, ListMode.BLACKLIST) == ListMode.BLACKLIST) { 33 | final ConfigurationNode listNode = node.node("list"); 34 | final List list = new ArrayList<>(listNode.getList(String.class, List.of())); 35 | list.addAll(List.of( 36 | "squaremap-stroke-color", 37 | "squaremap-stroke-weight", 38 | "squaremap-stroke-opacity", 39 | "squaremap-fill-color", 40 | "squaremap-fill-opacity", 41 | "squaremap-click-tooltip" 42 | )); 43 | listNode.setList(String.class, list); 44 | } 45 | return null; 46 | }) 47 | .build(); 48 | 49 | versionedBuilder.addVersion(1, zeroToOne) 50 | .addVersion(2, oneToTwo) 51 | .addVersion(3, twoToThree); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /addons/essentialsx/src/main/java/xyz/jpenilla/squaremap/addon/essentialsx/task/SquaremapTask.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.essentialsx.task; 2 | 3 | import com.earth2me.essentials.Warps; 4 | import com.earth2me.essentials.commands.WarpNotFoundException; 5 | import net.ess3.api.InvalidWorldException; 6 | import org.bukkit.Location; 7 | import org.bukkit.World; 8 | import org.bukkit.scheduler.BukkitRunnable; 9 | import xyz.jpenilla.squaremap.addon.essentialsx.config.EssXWorldConfig; 10 | import xyz.jpenilla.squaremap.addon.essentialsx.hook.EssentialsHook; 11 | import xyz.jpenilla.squaremap.addon.essentialsx.hook.SquaremapHook; 12 | import xyz.jpenilla.squaremap.api.BukkitAdapter; 13 | import xyz.jpenilla.squaremap.api.Key; 14 | import xyz.jpenilla.squaremap.api.MapWorld; 15 | import xyz.jpenilla.squaremap.api.Point; 16 | import xyz.jpenilla.squaremap.api.SimpleLayerProvider; 17 | import xyz.jpenilla.squaremap.api.marker.Icon; 18 | import xyz.jpenilla.squaremap.api.marker.Marker; 19 | import xyz.jpenilla.squaremap.api.marker.MarkerOptions; 20 | 21 | public final class SquaremapTask extends BukkitRunnable { 22 | private final MapWorld world; 23 | private final SimpleLayerProvider provider; 24 | private final EssXWorldConfig worldConfig; 25 | 26 | private boolean stop; 27 | 28 | public SquaremapTask(MapWorld world, EssXWorldConfig worldConfig, SimpleLayerProvider provider) { 29 | this.world = world; 30 | this.provider = provider; 31 | this.worldConfig = worldConfig; 32 | } 33 | 34 | @Override 35 | public void run() { 36 | if (this.stop) { 37 | this.cancel(); 38 | } 39 | 40 | this.provider.clearMarkers(); 41 | 42 | Warps warps = EssentialsHook.getWarps(); 43 | 44 | final World bukkitWorld = BukkitAdapter.bukkitWorld(this.world); 45 | 46 | warps.getList().forEach(warpName -> { 47 | try { 48 | Location loc = warps.getWarp(warpName); 49 | if (loc.getWorld().getUID().equals(bukkitWorld.getUID())) { 50 | this.handle(warpName, loc); 51 | } 52 | } catch (WarpNotFoundException | InvalidWorldException ignore) { 53 | } 54 | }); 55 | } 56 | 57 | private void handle(String warpName, Location loc) { 58 | Icon icon = Marker.icon(BukkitAdapter.point(loc), SquaremapHook.WARP_ICON_KEY, this.worldConfig.iconSize); 59 | 60 | icon.anchor(Point.of(this.worldConfig.iconAnchorX, this.worldConfig.iconAnchorZ)); 61 | 62 | icon.markerOptions( 63 | MarkerOptions.builder() 64 | .hoverTooltip(this.worldConfig.warpsTooltip.replace("{warp}", warpName)) 65 | ); 66 | 67 | String markerid = "essentials_warp_" + warpName.hashCode(); 68 | this.provider.addMarker(Key.of(markerid), icon); 69 | } 70 | 71 | public void disable() { 72 | this.cancel(); 73 | this.stop = true; 74 | this.provider.clearMarkers(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /addons/claimchunk/src/main/java/xyz/jpenilla/squaremap/addon/claimchunk/util/RectangleMerge.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.claimchunk.util; 2 | 3 | import java.awt.Shape; 4 | import java.awt.geom.Area; 5 | import java.awt.geom.Path2D; 6 | import java.awt.geom.PathIterator; 7 | import java.util.ArrayList; 8 | import java.util.Arrays; 9 | import java.util.List; 10 | import xyz.jpenilla.squaremap.addon.claimchunk.data.Claim; 11 | import xyz.jpenilla.squaremap.api.Point; 12 | import xyz.jpenilla.squaremap.api.marker.Marker; 13 | import xyz.jpenilla.squaremap.api.marker.Polygon; 14 | 15 | // https://stackoverflow.com/a/56326866 16 | 17 | public final class RectangleMerge { 18 | 19 | public static Polygon getPoly(List claims) { 20 | List shapes = new ArrayList<>(); 21 | for (Claim claim : claims) { 22 | int x = claim.x() << 4; 23 | int z = claim.z() << 4; 24 | List points = Arrays.asList( 25 | Point.of(x, z), 26 | Point.of(x, z + 16), 27 | Point.of(x + 16, z + 16), 28 | Point.of(x + 16, z) 29 | ); 30 | shapes.add(toShape(points)); 31 | } 32 | 33 | Area area = null; 34 | for (Shape shape : shapes) { 35 | if (area == null) { 36 | area = new Area(shape); 37 | } else { 38 | area.add(new Area(shape)); 39 | } 40 | } 41 | 42 | if (area == null) { 43 | throw new IllegalStateException(); 44 | } 45 | 46 | return toMarker(area); 47 | } 48 | 49 | private static Shape toShape(List points) { 50 | Path2D path = new Path2D.Double(); 51 | for (int i = 0; i < points.size(); i++) { 52 | Point p = points.get(i); 53 | if (i == 0) { 54 | path.moveTo(p.x(), p.z()); 55 | } else { 56 | path.lineTo(p.x(), p.z()); 57 | } 58 | } 59 | path.closePath(); 60 | return path; 61 | } 62 | 63 | private static Polygon toMarker(Shape shape) { 64 | List main = new ArrayList<>(); 65 | List> subtract = new ArrayList<>(); 66 | PathIterator iter = shape.getPathIterator(null, 0.0); 67 | double[] coords = new double[6]; 68 | List current = main; 69 | while (!iter.isDone()) { 70 | int segment = iter.currentSegment(coords); 71 | switch (segment) { 72 | case PathIterator.SEG_MOVETO, PathIterator.SEG_LINETO -> current.add(Point.of(coords[0], coords[1])); 73 | case PathIterator.SEG_CLOSE -> { 74 | List newList = new ArrayList<>(); 75 | subtract.add(newList); 76 | current = newList; 77 | } 78 | } 79 | iter.next(); 80 | } 81 | subtract.removeIf(List::isEmpty); 82 | return Marker.polygon(main, subtract); 83 | } 84 | 85 | } 86 | 87 | -------------------------------------------------------------------------------- /addons/signs/src/main/java/xyz/jpenilla/squaremap/addon/signs/config/SignsWorldConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.signs.config; 2 | 3 | import xyz.jpenilla.squaremap.addon.common.config.Config; 4 | import xyz.jpenilla.squaremap.addon.common.config.WorldConfig; 5 | 6 | @SuppressWarnings("unused") 7 | public final class SignsWorldConfig extends WorldConfig { 8 | public boolean enabled = true; 9 | public int updateInterval = 5; 10 | public boolean enableControls = true; 11 | public boolean controlsHiddenByDefault = false; 12 | public String frontAndBackTooltip = "
{line1}
{line2}
{line3}
{line4}

" + 13 | "Back:
{line1b}
{line2b}
{line3b}
{line4b}
"; 14 | public String frontOnlyTooltip = "
{line1}
{line2}
{line3}
{line4}"; 15 | public String backOnlyTooltip = "
Back:
{line1}
{line2}
{line3}
{line4}"; 16 | public String blankTooltip = "This sign has no text."; 17 | 18 | private void worldSettings() { 19 | this.enabled = this.getBoolean("enabled", this.enabled); 20 | this.updateInterval = this.getInt("update-interval", this.updateInterval); 21 | this.enableControls = this.getBoolean("controls.enabled", this.enableControls); 22 | this.controlsHiddenByDefault = this.getBoolean("controls.hidden-by-default", this.controlsHiddenByDefault); 23 | this.frontAndBackTooltip = this.getString("marker.tooltip_both", this.frontAndBackTooltip); 24 | this.frontOnlyTooltip = this.getString("marker.tooltip_front_only", this.frontOnlyTooltip); 25 | this.backOnlyTooltip = this.getString("marker.tooltip_back_only", this.backOnlyTooltip); 26 | this.blankTooltip = this.getString("marker.tooltip_blank", this.blankTooltip); 27 | } 28 | 29 | public String layerLabel = "Signs"; 30 | public boolean layerControls = true; 31 | public boolean layerControlsHidden = false; 32 | public int layerPriority = 999; 33 | public int layerZindex = 999; 34 | 35 | private void layerSettings() { 36 | this.layerLabel = this.getString("layer.label", this.layerLabel); 37 | this.layerControls = this.getBoolean("layer.controls.enabled", this.layerControls); 38 | this.layerControlsHidden = this.getBoolean("layer.controls.hide-by-default", this.layerControlsHidden); 39 | this.layerPriority = this.getInt("layer.priority", this.layerPriority); 40 | this.layerZindex = this.getInt("layer.z-index", this.layerZindex); 41 | } 42 | 43 | public int iconSize = 16; 44 | public boolean iconCustom = false; 45 | public String iconCustomRegexp = "^!\\[([^\\]]+)\\]$"; 46 | 47 | private void iconSettings() { 48 | this.iconSize = getInt("icon.size", this.iconSize); 49 | this.iconCustom = this.getBoolean("icon.custom.enabled", this.iconCustom); 50 | this.iconCustomRegexp = this.getString("icon.custom.regexp", this.iconCustomRegexp); 51 | } 52 | 53 | private SignsWorldConfig(Config parent, String world) { 54 | super(parent, world); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /addons/worldguard/src/main/java/xyz/jpenilla/squaremap/addon/worldguard/hook/SquaremapHook.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.worldguard.hook; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import org.bukkit.World; 6 | import org.checkerframework.checker.nullness.qual.Nullable; 7 | import xyz.jpenilla.squaremap.addon.worldguard.SquaremapWorldGuard; 8 | import xyz.jpenilla.squaremap.addon.worldguard.config.WGWorldConfig; 9 | import xyz.jpenilla.squaremap.addon.worldguard.task.SquaremapTask; 10 | import xyz.jpenilla.squaremap.api.BukkitAdapter; 11 | import xyz.jpenilla.squaremap.api.Key; 12 | import xyz.jpenilla.squaremap.api.MapWorld; 13 | import xyz.jpenilla.squaremap.api.SimpleLayerProvider; 14 | import xyz.jpenilla.squaremap.api.Squaremap; 15 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 16 | import xyz.jpenilla.squaremap.api.WorldIdentifier; 17 | 18 | import static xyz.jpenilla.squaremap.api.Key.key; 19 | 20 | public final class SquaremapHook { 21 | private static final Key WORLDGUARD_LAYER_KEY = key("worldguard"); 22 | 23 | private final Map providers = new HashMap<>(); 24 | private final SquaremapWorldGuard plugin; 25 | private final Squaremap squaremap; 26 | 27 | public SquaremapHook(final SquaremapWorldGuard plugin) { 28 | this.plugin = plugin; 29 | this.squaremap = SquaremapProvider.get(); 30 | this.squaremap.mapWorlds().forEach(this::addWorld); 31 | } 32 | 33 | public void addWorld(final World world) { 34 | this.squaremap.getWorldIfEnabled(BukkitAdapter.worldIdentifier(world)).ifPresent(this::addWorld); 35 | } 36 | 37 | private void addWorld(final MapWorld world) { 38 | this.providers.computeIfAbsent(world.identifier(), id -> { 39 | final WGWorldConfig cfg = this.plugin.config().worldConfig(id); 40 | SimpleLayerProvider provider = SimpleLayerProvider.builder(cfg.controlLabel) 41 | .showControls(cfg.controlShow) 42 | .defaultHidden(cfg.controlHide) 43 | .build(); 44 | world.layerRegistry().register(WORLDGUARD_LAYER_KEY, provider); 45 | SquaremapTask task = new SquaremapTask(this.plugin, id, provider); 46 | task.runTaskTimerAsynchronously(this.plugin, 0, 20L * cfg.updateInterval); 47 | return task; 48 | }); 49 | } 50 | 51 | public void removeWorld(final World world) { 52 | this.removeWorld(BukkitAdapter.worldIdentifier(world)); 53 | } 54 | 55 | public void removeWorld(final WorldIdentifier world) { 56 | final @Nullable SquaremapTask remove = this.providers.remove(world); 57 | if (remove != null) { 58 | remove.disable(); 59 | } 60 | this.squaremap.getWorldIfEnabled(world).ifPresent(mapWorld -> { 61 | if (mapWorld.layerRegistry().hasEntry(WORLDGUARD_LAYER_KEY)) { 62 | mapWorld.layerRegistry().unregister(WORLDGUARD_LAYER_KEY); 63 | } 64 | }); 65 | } 66 | 67 | public void disable() { 68 | Map.copyOf(this.providers).keySet().forEach(this::removeWorld); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /addons/signs/src/main/java/xyz/jpenilla/squaremap/addon/signs/data/CustomIcons.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.signs.data; 2 | 3 | import java.awt.image.BufferedImage; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Optional; 9 | 10 | import javax.imageio.ImageIO; 11 | 12 | import org.bukkit.plugin.java.JavaPlugin; 13 | import org.checkerframework.checker.nullness.qual.NonNull; 14 | import org.checkerframework.checker.nullness.qual.Nullable; 15 | 16 | import xyz.jpenilla.squaremap.api.Key; 17 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 18 | 19 | public final class CustomIcons { 20 | private static final String KEY_PREFIX = "signs_custom_"; 21 | private static final String CUSTOM_ICONS_DIR = "customicons"; 22 | 23 | private List keys = new ArrayList<>(); 24 | 25 | public static CustomIcons register(final @NonNull JavaPlugin plugin) { 26 | CustomIcons out = new CustomIcons(); 27 | 28 | final File iconDir = new File(plugin.getDataFolder(), CUSTOM_ICONS_DIR); 29 | iconDir.mkdir(); 30 | 31 | final File[] iconFiles = iconDir.listFiles(); 32 | if (iconFiles == null) { 33 | plugin.getSLF4JLogger().warn("unable to read customicons directory at \"{}\"", iconDir.getAbsolutePath()); 34 | return out; 35 | } 36 | 37 | for (final File file : iconFiles) { 38 | if (!file.isFile()) { 39 | continue; 40 | } 41 | try { 42 | final String stem = file.getName().replaceAll("\\..*$", ""); 43 | final BufferedImage image = ImageIO.read(file); 44 | if (image == null) { 45 | throw new IOException("no image data"); 46 | } 47 | final Key key = CustomIcons.asKey(stem); 48 | out.keys.add(key); 49 | SquaremapProvider.get().iconRegistry().register(key, image); 50 | plugin.getSLF4JLogger().trace("loaded custom icon {} → \"{}\"", key, file); 51 | } catch (final IOException e) { 52 | plugin.getSLF4JLogger().warn("unable to read custom icon \"{}\" as an image", file); 53 | } 54 | } 55 | 56 | return out; 57 | } 58 | 59 | public final Optional lookup(final @Nullable String iconName) { 60 | if (iconName == null || iconName.isEmpty()) { 61 | return Optional.empty(); 62 | } 63 | Key k = CustomIcons.asKey(iconName); 64 | if (keys.contains(k)) { 65 | return Optional.of(k); 66 | } 67 | return Optional.empty(); 68 | } 69 | 70 | public void unregister() { 71 | for (final Key key : this.keys) { 72 | SquaremapProvider.get().iconRegistry().unregister(key); 73 | } 74 | this.keys.clear(); 75 | } 76 | 77 | public boolean isEmpty() { 78 | return this.keys.isEmpty(); 79 | } 80 | 81 | private static final Key asKey(final @NonNull String iconName) { 82 | return Key.of(KEY_PREFIX + iconName); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH= 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /addons/signs/src/main/java/xyz/jpenilla/squaremap/addon/signs/hook/LayerProviderManager.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.signs.hook; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.World; 7 | import org.checkerframework.checker.nullness.qual.NonNull; 8 | import org.checkerframework.checker.nullness.qual.Nullable; 9 | import org.checkerframework.framework.qual.DefaultQualifier; 10 | import xyz.jpenilla.squaremap.addon.signs.SignsPlugin; 11 | import xyz.jpenilla.squaremap.addon.signs.config.SignsWorldConfig; 12 | import xyz.jpenilla.squaremap.addon.signs.data.SignLayerProvider; 13 | import xyz.jpenilla.squaremap.api.BukkitAdapter; 14 | import xyz.jpenilla.squaremap.api.Key; 15 | import xyz.jpenilla.squaremap.api.MapWorld; 16 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 17 | import xyz.jpenilla.squaremap.api.WorldIdentifier; 18 | 19 | import static xyz.jpenilla.squaremap.api.Key.key; 20 | 21 | @DefaultQualifier(NonNull.class) 22 | public final class LayerProviderManager { 23 | private static final Key SIGNS_LAYER_KEY = key("signs"); 24 | 25 | private final SignsPlugin plugin; 26 | private final Map providers = new HashMap<>(); 27 | 28 | public LayerProviderManager(final SignsPlugin plugin) { 29 | this.plugin = plugin; 30 | } 31 | 32 | public void load() { 33 | Bukkit.getWorlds().forEach(this::provider); 34 | } 35 | 36 | public @Nullable SignLayerProvider provider(final World world) { 37 | return this.providers.computeIfAbsent(BukkitAdapter.worldIdentifier(world), id -> { 38 | final @Nullable MapWorld mapWorld = SquaremapProvider.get().getWorldIfEnabled(id).orElse(null); 39 | if (mapWorld == null) { 40 | return null; 41 | } 42 | final SignsWorldConfig worldConfig = this.plugin.config().worldConfig(id); 43 | if (!worldConfig.enabled) { 44 | return null; 45 | } 46 | final SignLayerProvider provider = new SignLayerProvider(worldConfig, this.plugin); 47 | try { 48 | this.plugin.signManager().load(id, provider); 49 | } catch (final Exception e) { 50 | this.plugin.getSLF4JLogger().warn("Failed to load data for world {}", id, e); 51 | } 52 | mapWorld.layerRegistry().register(SIGNS_LAYER_KEY, provider); 53 | return provider; 54 | }); 55 | } 56 | 57 | public void unloadProvider(final World world) { 58 | this.unloadProvider(BukkitAdapter.worldIdentifier(world)); 59 | } 60 | 61 | public void unloadProvider(final WorldIdentifier id) { 62 | SquaremapProvider.get().getWorldIfEnabled(id).ifPresent(mapWorld -> { 63 | if (mapWorld.layerRegistry().hasEntry(SIGNS_LAYER_KEY)) { 64 | mapWorld.layerRegistry().unregister(SIGNS_LAYER_KEY); 65 | } 66 | }); 67 | final @Nullable SignLayerProvider removed = this.providers.remove(id); 68 | if (removed != null) { 69 | this.plugin.signManager().save(id, removed); 70 | } 71 | } 72 | 73 | public void disable() { 74 | Map.copyOf(this.providers).forEach((id, provider) -> this.unloadProvider(id)); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /addons/griefprevention/src/main/java/xyz/jpenilla/squaremap/addon/griefprevention/config/GPConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.griefprevention.config; 2 | 3 | import java.awt.Color; 4 | import org.bukkit.plugin.Plugin; 5 | import xyz.jpenilla.squaremap.addon.common.config.Config; 6 | import xyz.jpenilla.squaremap.addon.common.config.WorldConfig; 7 | 8 | public final class GPConfig extends Config { 9 | public String controlLabel = "GriefPrevention"; 10 | public boolean controlShow = true; 11 | public boolean controlHide = false; 12 | public int updateInterval = 300; 13 | public Color strokeColor = Color.GREEN; 14 | public int strokeWeight = 1; 15 | public double strokeOpacity = 1.0D; 16 | public Color fillColor = Color.GREEN; 17 | public double fillOpacity = 0.2D; 18 | public String stringsPublic = "Public"; 19 | public int zIndex = 99; 20 | public int layerPriority = 99; 21 | public String claimTooltip = "Claim Owner: {owner}
" + 22 | "Permission Trust: {managers}
" + 23 | "Trust: {builders}
" + 24 | "Container Trust: {containers}
" + 25 | "Access Trust: {accessors}"; 26 | public String adminClaimTooltip = "Administrator Claim
" + 27 | "Permission Trust: {managers}
" + 28 | "Trust: {builders}
" + 29 | "Container Trust: {containers}
" + 30 | "Access Trust: {accessors}"; 31 | 32 | private void init() { 33 | this.controlLabel = this.getString("settings.control.label", this.controlLabel); 34 | this.controlShow = this.getBoolean("settings.control.show", this.controlShow); 35 | this.controlHide = this.getBoolean("settings.control.hide-by-default", this.controlHide); 36 | this.updateInterval = this.getInt("settings.update-interval", this.updateInterval); 37 | this.strokeColor = this.getColor("settings.style.stroke.color", this.strokeColor); 38 | this.strokeWeight = this.getInt("settings.style.stroke.weight", this.strokeWeight); 39 | this.strokeOpacity = this.getDouble("settings.style.stroke.opacity", this.strokeOpacity); 40 | this.fillColor = this.getColor("settings.style.fill.color", this.fillColor); 41 | this.fillOpacity = this.getDouble("settings.style.fill.opacity", this.fillOpacity); 42 | this.stringsPublic = this.getString("settings.strings.public", this.stringsPublic); 43 | this.claimTooltip = this.getString("settings.region.tooltip.regular-claim", this.claimTooltip); 44 | this.adminClaimTooltip = this.getString("settings.region.tooltip.admin-claim", this.adminClaimTooltip); 45 | this.zIndex = this.getInt("settings.control.z-index", this.zIndex); 46 | this.layerPriority = this.getInt("settings.control.layer-priority", this.layerPriority); 47 | } 48 | 49 | public GPConfig(Plugin plugin) { 50 | super(GPConfig.class, plugin); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # squaremap-addons 2 | 3 | [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/jpenilla/squaremap-addons/build.yml?branch=master)](https://github.com/jpenilla/squaremap-addons/actions) 4 | [![Discord](https://img.shields.io/discord/390942438061113344?color=8C9CFE&label=discord&logo=discord&logoColor=white)](https://discord.gg/PHpuzZS) 5 | 6 | Various addons for [squaremap](https://github.com/jpenilla/squaremap) 7 | 8 | ## Addon list 9 | - [squaremap-banners](https://github.com/jpenilla/squaremap-addons/tree/master/addons/banners) 10 | - Shows banners on the map in a similar way to vanilla maps 11 | - [squaremap-claimchunk](https://github.com/jpenilla/squaremap-addons/tree/master/addons/claimchunk) 12 | - [ClaimChunk](https://www.spigotmc.org/resources/claimchunk.44458/) integration for squaremap 13 | - [squaremap-deathspot](https://github.com/jpenilla/squaremap-addons/tree/master/addons/deathspot) 14 | - DeathSpot addon for squaremap 15 | - [squaremap-essentialsx](https://github.com/jpenilla/squaremap-addons/tree/master/addons/essentialsx) 16 | - [EssentialsX](https://essentialsx.net/) integration for squaremap 17 | - [squaremap-griefprevention](https://github.com/jpenilla/squaremap-addons/tree/master/addons/griefprevention) 18 | - [GriefPrevention](https://www.spigotmc.org/resources/griefprevention.1884/) integration for squaremap 19 | - [squaremap-mobs](https://github.com/jpenilla/squaremap-addons/tree/master/addons/mobs) 20 | - Shows mobs on squaremap 21 | - [squaremap-signs](https://github.com/jpenilla/squaremap-addons/tree/master/addons/signs) 22 | - Shows placed signs on squaremap 23 | - [squaremap-skins](https://github.com/jpenilla/squaremap-addons/tree/master/addons/skins) 24 | - Custom skin support for squaremap 25 | - [squaremap-vanish](https://github.com/jpenilla/squaremap-addons/tree/master/addons/vanish) 26 | - Integration with various vanish plugins for squaremap 27 | - [squaremap-worldguard](https://github.com/jpenilla/squaremap-addons/tree/master/addons/worldguard) 28 | - [WorldGuard](https://enginehub.org/worldguard/) integration for squaremap 29 | 30 | ## Download 31 | Download the latest builds from [this link](https://nightly.link/jpenilla/squaremap-addons/workflows/build/master/artifacts.zip) 32 | 33 | ## Building from source 34 | 35 | Build squaremap-addons by invoking the `build` task with Gradle. 36 | 37 | ``` 38 | ./gradlew build 39 | ``` 40 | 41 | Built artifacts will be saved in `./build/libs/`. 42 | 43 | ## Note 44 | 45 |
46 | The source code for some modules is derivative of works in the following repositories: 47 | 48 | - squaremap-banners: [Pl3xMap-Banners](https://github.com/granny/Pl3xMap-Banners) 49 | - squaremap-claimchunk: [Pl3xMap-ClaimChunk](https://github.com/pl3xgaming/Pl3xMap-ClaimChunk) 50 | - squaremap-deathspot: [Pl3xMap-DeathSpot](https://github.com/pl3xgaming/Pl3xMap-DeathSpot) 51 | - squaremap-essentialsx: [Pl3xMap-Essentials](https://github.com/pl3xgaming/Pl3xMap-Essentials) 52 | - squaremap-griefprevention: [Pl3xMap-GriefPrevention](https://github.com/pl3xgaming/Pl3xMap-GriefPrevention) 53 | - squaremap-mobs: [Pl3xMap-Mobs](https://github.com/pl3xgaming/Pl3xMap-Mobs) 54 | - squaremap-signs: [Pl3xMap-Signs](https://github.com/pl3xgaming/Pl3xMap-Signs) 55 | - squaremap-skins: [Pl3xMap-Skins](https://github.com/pl3xgaming/Pl3xMap-Skins) 56 | - squaremap-worldguard: [Pl3xMap-WorldGuard](https://github.com/pl3xgaming/Pl3xMap-WorldGuard) 57 | 58 |
59 | -------------------------------------------------------------------------------- /addons/mobs/src/main/java/xyz/jpenilla/squaremap/addon/mobs/task/SquaremapTask.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.mobs.task; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; 5 | import org.bukkit.HeightMap; 6 | import org.bukkit.Location; 7 | import org.bukkit.entity.EntityType; 8 | import org.bukkit.entity.Mob; 9 | import org.bukkit.scheduler.BukkitRunnable; 10 | import xyz.jpenilla.squaremap.addon.mobs.config.MobsWorldConfig; 11 | import xyz.jpenilla.squaremap.addon.mobs.data.Icons; 12 | import xyz.jpenilla.squaremap.api.BukkitAdapter; 13 | import xyz.jpenilla.squaremap.api.Key; 14 | import xyz.jpenilla.squaremap.api.MapWorld; 15 | import xyz.jpenilla.squaremap.api.SimpleLayerProvider; 16 | import xyz.jpenilla.squaremap.api.marker.Icon; 17 | import xyz.jpenilla.squaremap.api.marker.Marker; 18 | import xyz.jpenilla.squaremap.api.marker.MarkerOptions; 19 | 20 | public final class SquaremapTask extends BukkitRunnable { 21 | private final MapWorld world; 22 | private final SimpleLayerProvider provider; 23 | private final MobsWorldConfig worldConfig; 24 | 25 | private boolean stop; 26 | 27 | public SquaremapTask(MapWorld world, MobsWorldConfig worldConfig, SimpleLayerProvider provider) { 28 | this.world = world; 29 | this.provider = provider; 30 | this.worldConfig = worldConfig; 31 | } 32 | 33 | @Override 34 | public void run() { 35 | if (this.stop) { 36 | this.cancel(); 37 | } 38 | 39 | this.provider.clearMarkers(); 40 | 41 | for (final Mob mob : BukkitAdapter.bukkitWorld(this.world).getEntitiesByClass(Mob.class)) { 42 | final EntityType type = mob.getType(); 43 | if (!this.worldConfig.allowedTypes.contains(type)) { 44 | continue; 45 | } 46 | final Location loc = mob.getLocation(); 47 | if (loc.getY() < this.worldConfig.minimumY) { 48 | continue; 49 | } 50 | if (this.worldConfig.surfaceOnly && aboveSurface(loc)) { 51 | continue; 52 | } 53 | this.handleMob(type, mob.getEntityId(), loc); 54 | } 55 | } 56 | 57 | private static boolean aboveSurface(final Location loc) { 58 | return loc.getY() < loc.getWorld().getHighestBlockYAt(loc.getBlockX(), loc.getBlockZ(), HeightMap.WORLD_SURFACE); 59 | } 60 | 61 | private void handleMob(EntityType type, int id, Location loc) { 62 | final Icon icon = Marker.icon( 63 | BukkitAdapter.point(loc), 64 | Icons.getIcon(type), 65 | this.worldConfig.iconSize 66 | ); 67 | 68 | final String name = PlainTextComponentSerializer.plainText().serialize(Component.translatable(type.translationKey())); 69 | 70 | icon.markerOptions( 71 | MarkerOptions.builder() 72 | .hoverTooltip( 73 | this.worldConfig.iconTooltip 74 | .replace("{id}", Integer.toString(id)) 75 | .replace("{key}", type.getKey().asString()) 76 | .replace("{name}", name) 77 | ) 78 | ); 79 | 80 | final String markerid = "mob_" + type + "_id_" + id; 81 | this.provider.addMarker(Key.of(markerid), icon); 82 | } 83 | 84 | public void disable() { 85 | this.cancel(); 86 | this.stop = true; 87 | this.provider.clearMarkers(); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /common/src/main/java/xyz/jpenilla/squaremap/addon/common/config/WorldConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.common.config; 2 | 3 | import java.awt.Color; 4 | import java.lang.reflect.Type; 5 | import java.util.List; 6 | 7 | @SuppressWarnings("unused") 8 | public abstract class WorldConfig { 9 | public static final String DOT = "____dot____"; 10 | 11 | private final String worldIdentifier; 12 | private final Config parent; 13 | 14 | protected WorldConfig(final Config parent, final String world) { 15 | this.parent = parent; 16 | this.worldIdentifier = world.replace(".", DOT); 17 | } 18 | 19 | protected final boolean getBoolean(String path, boolean def) { 20 | if (this.virtual(this.wrapPath(path))) { 21 | return this.parent.getBoolean(wrapDefaultPath(path), def); 22 | } 23 | return this.parent.getBoolean(this.wrapPath(path), this.parent.getBoolean(wrapDefaultPath(path), def)); 24 | } 25 | 26 | protected final int getInt(String path, int def) { 27 | if (this.virtual(this.wrapPath(path))) { 28 | return this.parent.getInt(wrapDefaultPath(path), def); 29 | } 30 | return this.parent.getInt(this.wrapPath(path), this.parent.getInt(wrapDefaultPath(path), def)); 31 | } 32 | 33 | protected final double getDouble(String path, double def) { 34 | if (this.virtual(this.wrapPath(path))) { 35 | return this.parent.getDouble(wrapDefaultPath(path), def); 36 | } 37 | return this.parent.getDouble(this.wrapPath(path), this.parent.getDouble(wrapDefaultPath(path), def)); 38 | } 39 | 40 | protected final String getString(String path, String def) { 41 | if (this.virtual(this.wrapPath(path))) { 42 | return this.parent.getString(wrapDefaultPath(path), def); 43 | } 44 | return this.parent.getString(this.wrapPath(path), this.parent.getString(wrapDefaultPath(path), def)); 45 | } 46 | 47 | protected final List getList(Class elementType, String path, List def) { 48 | if (this.virtual(this.wrapPath(path))) { 49 | return this.parent.getList(elementType, wrapDefaultPath(path), def); 50 | } 51 | return this.parent.getList(elementType, this.wrapPath(path), this.parent.getList(elementType, wrapDefaultPath(path), def)); 52 | } 53 | 54 | protected final Color getColor(String path, Color def) { 55 | if (this.virtual(this.wrapPath(path))) { 56 | return this.parent.getColor(wrapDefaultPath(path), def); 57 | } 58 | return this.parent.getColor(this.wrapPath(path), this.parent.getColor(wrapDefaultPath(path), def)); 59 | } 60 | 61 | protected final > E getEnum(String path, Class enumClass, E def) { 62 | if (this.virtual(this.wrapPath(path))) { 63 | return this.parent.getEnum(wrapDefaultPath(path), enumClass, def); 64 | } 65 | return this.parent.getEnum(this.wrapPath(path), enumClass, this.parent.getEnum(wrapDefaultPath(path), enumClass, def)); 66 | } 67 | 68 | protected final T get(String path, Class type, T def) { 69 | if (this.virtual(this.wrapPath(path))) { 70 | return this.parent.get(wrapDefaultPath(path), type, def); 71 | } 72 | return this.parent.get(this.wrapPath(path), type, this.parent.get(wrapDefaultPath(path), type, def)); 73 | } 74 | 75 | protected final T get(String path, Type type, T def) { 76 | if (this.virtual(this.wrapPath(path))) { 77 | return this.parent.get(wrapDefaultPath(path), type, def); 78 | } 79 | return this.parent.get(this.wrapPath(path), type, this.parent.get(wrapDefaultPath(path), type, def)); 80 | } 81 | 82 | private boolean virtual(String path) { 83 | return this.parent.config.node(Config.splitPath(path)).virtual(); 84 | } 85 | 86 | private String wrapPath(final String path) { 87 | return "world-settings." + this.worldIdentifier + "." + path; 88 | } 89 | 90 | private static String wrapDefaultPath(final String path) { 91 | return "world-settings.default." + path; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /addons/mobs/src/main/java/xyz/jpenilla/squaremap/addon/mobs/config/MobsWorldConfig.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.mobs.config; 2 | 3 | import java.util.HashSet; 4 | import java.util.List; 5 | import java.util.Set; 6 | import org.bukkit.NamespacedKey; 7 | import org.bukkit.Registry; 8 | import org.bukkit.entity.EntityType; 9 | import org.checkerframework.checker.nullness.qual.Nullable; 10 | import xyz.jpenilla.squaremap.addon.common.config.Config; 11 | import xyz.jpenilla.squaremap.addon.common.config.WorldConfig; 12 | import xyz.jpenilla.squaremap.addon.mobs.SquaremapMobs; 13 | import xyz.jpenilla.squaremap.addon.mobs.data.Icons; 14 | 15 | @SuppressWarnings("unused") 16 | public final class MobsWorldConfig extends WorldConfig { 17 | public boolean enabled = true; 18 | 19 | private void worldSettings() { 20 | this.enabled = this.getBoolean("enabled", this.enabled); 21 | } 22 | 23 | public String layerLabel = "Mobs"; 24 | public boolean layerShowControls = true; 25 | public boolean layerControlsHidden = false; 26 | public int layerPriority = 999; 27 | public int layerZindex = 999; 28 | 29 | private void layerSettings() { 30 | this.layerLabel = this.getString("layer.label", this.layerLabel); 31 | this.layerShowControls = this.getBoolean("layer.controls.enabled", this.layerShowControls); 32 | this.layerControlsHidden = this.getBoolean("layer.controls.hide-by-default", this.layerControlsHidden); 33 | this.layerPriority = this.getInt("layer.priority", this.layerPriority); 34 | this.layerZindex = this.getInt("layer.z-index", this.layerZindex); 35 | } 36 | 37 | public int minimumY = 64; 38 | public boolean surfaceOnly = true; 39 | 40 | public int iconSize = 16; 41 | public String iconTooltip = "{name}"; 42 | 43 | private void iconSettings() { 44 | this.iconSize = getInt("icon.size", this.iconSize); 45 | this.iconTooltip = getString("icon.tooltip", this.iconTooltip); 46 | } 47 | 48 | public final Set allowedTypes = new HashSet<>(); 49 | 50 | private void allowedTypes() { 51 | this.allowedTypes.clear(); 52 | this.getList( 53 | String.class, 54 | "allowed-mobs", 55 | List.of( 56 | "cat", 57 | "chicken", 58 | "cod", 59 | "cow", 60 | "dolphin", 61 | "fox", 62 | "horse", 63 | "iron_golem", 64 | "llama", 65 | "mooshroom", 66 | "mule", 67 | "ocelot", 68 | "panda", 69 | "parrot", 70 | "pig", 71 | "polar_bear", 72 | "pufferfish", 73 | "rabbit", 74 | "salmon", 75 | "sheep", 76 | "snow_golem", 77 | "squid", 78 | "strider", 79 | "trader_llama", 80 | "tropical_fish", 81 | "turtle", 82 | "villager", 83 | "wandering_trader", 84 | "wolf" 85 | ) 86 | ).forEach(key -> { 87 | if (key.equals("*")) { 88 | this.allowedTypes.addAll(Icons.BY_TYPE.keySet()); 89 | return; 90 | } 91 | EntityType type = parseEntityType(key); 92 | if (type != null) { 93 | this.allowedTypes.add(type); 94 | } else { 95 | SquaremapMobs.getInstance().getLogger().warning("Unknown entity type: " + key); 96 | } 97 | }); 98 | } 99 | 100 | public static @Nullable EntityType parseEntityType(String name) { 101 | final NamespacedKey entityTypeKey = NamespacedKey.fromString(name); 102 | if (entityTypeKey == null) { 103 | return null; 104 | } 105 | return Registry.ENTITY_TYPE.get(entityTypeKey); 106 | } 107 | 108 | private MobsWorldConfig(Config parent, String world) { 109 | super(parent, world); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /addons/banners/src/main/java/xyz/jpenilla/squaremap/addon/banners/data/Icons.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.banners.data; 2 | 3 | import java.awt.image.BufferedImage; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.util.logging.Level; 7 | import javax.imageio.ImageIO; 8 | import org.bukkit.Material; 9 | import xyz.jpenilla.squaremap.addon.banners.SquaremapBanners; 10 | import xyz.jpenilla.squaremap.api.Key; 11 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 12 | 13 | public class Icons { 14 | public static final Key BLACK = register("BLACK"); 15 | public static final Key BLUE = register("BLUE"); 16 | public static final Key BROWN = register("BROWN"); 17 | public static final Key CYAN = register("CYAN"); 18 | public static final Key GRAY = register("GRAY"); 19 | public static final Key GREEN = register("GREEN"); 20 | public static final Key LIGHT_BLUE = register("LIGHT_BLUE"); 21 | public static final Key LIGHT_GRAY = register("LIGHT_GRAY"); 22 | public static final Key LIME = register("LIME"); 23 | public static final Key MAGENTA = register("MAGENTA"); 24 | public static final Key ORANGE = register("ORANGE"); 25 | public static final Key PINK = register("PINK"); 26 | public static final Key PURPLE = register("PURPLE"); 27 | public static final Key RED = register("RED"); 28 | public static final Key WHITE = register("WHITE"); 29 | public static final Key YELLOW = register("YELLOW"); 30 | 31 | private static Key register(String name) { 32 | SquaremapBanners plugin = SquaremapBanners.instance(); 33 | String filename = "icons" + File.separator + name + ".png"; 34 | File file = new File(plugin.getDataFolder(), filename); 35 | if (!file.exists()) { 36 | plugin.saveResource(filename, false); 37 | } 38 | Key key = Key.of(name); 39 | try { 40 | BufferedImage image = ImageIO.read(file); 41 | SquaremapProvider.get().iconRegistry().register(key, image); 42 | } catch (IOException e) { 43 | SquaremapBanners.instance().getLogger().log(Level.WARNING, "Failed to register banners icon", e); 44 | } 45 | return key; 46 | } 47 | 48 | public static Key getIcon(Material type) { 49 | switch (type) { 50 | case BLACK_BANNER: 51 | case BLACK_WALL_BANNER: 52 | return BLACK; 53 | case BLUE_BANNER: 54 | case BLUE_WALL_BANNER: 55 | return BLUE; 56 | case BROWN_BANNER: 57 | case BROWN_WALL_BANNER: 58 | return BROWN; 59 | case CYAN_BANNER: 60 | case CYAN_WALL_BANNER: 61 | return CYAN; 62 | case GRAY_BANNER: 63 | case GRAY_WALL_BANNER: 64 | return GRAY; 65 | case GREEN_BANNER: 66 | case GREEN_WALL_BANNER: 67 | return GREEN; 68 | case LIGHT_BLUE_BANNER: 69 | case LIGHT_BLUE_WALL_BANNER: 70 | return LIGHT_BLUE; 71 | case LIGHT_GRAY_BANNER: 72 | case LIGHT_GRAY_WALL_BANNER: 73 | return LIGHT_GRAY; 74 | case LIME_BANNER: 75 | case LIME_WALL_BANNER: 76 | return LIME; 77 | case MAGENTA_BANNER: 78 | case MAGENTA_WALL_BANNER: 79 | return MAGENTA; 80 | case ORANGE_BANNER: 81 | case ORANGE_WALL_BANNER: 82 | return ORANGE; 83 | case PINK_BANNER: 84 | case PINK_WALL_BANNER: 85 | return PINK; 86 | case PURPLE_BANNER: 87 | case PURPLE_WALL_BANNER: 88 | return PURPLE; 89 | case RED_BANNER: 90 | case RED_WALL_BANNER: 91 | return RED; 92 | case YELLOW_BANNER: 93 | case YELLOW_WALL_BANNER: 94 | return YELLOW; 95 | case WHITE_BANNER: 96 | case WHITE_WALL_BANNER: 97 | default: 98 | return WHITE; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /addons/signs/src/main/java/xyz/jpenilla/squaremap/addon/signs/listener/SignListener.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.signs.listener; 2 | 3 | import com.destroystokyo.paper.event.block.BlockDestroyEvent; 4 | import java.util.List; 5 | import net.kyori.adventure.text.Component; 6 | import org.bukkit.Material; 7 | import org.bukkit.block.Block; 8 | import org.bukkit.block.BlockState; 9 | import org.bukkit.block.Sign; 10 | import org.bukkit.block.sign.Side; 11 | import org.bukkit.event.EventHandler; 12 | import org.bukkit.event.EventPriority; 13 | import org.bukkit.event.Listener; 14 | import org.bukkit.event.block.Action; 15 | import org.bukkit.event.block.BlockBurnEvent; 16 | import org.bukkit.event.block.BlockDropItemEvent; 17 | import org.bukkit.event.block.BlockExplodeEvent; 18 | import org.bukkit.event.block.BlockFromToEvent; 19 | import org.bukkit.event.block.BlockPistonExtendEvent; 20 | import org.bukkit.event.block.BlockPistonRetractEvent; 21 | import org.bukkit.event.block.SignChangeEvent; 22 | import org.bukkit.event.entity.EntityExplodeEvent; 23 | import org.bukkit.event.player.PlayerInteractEvent; 24 | import xyz.jpenilla.squaremap.addon.signs.SignsPlugin; 25 | 26 | public record SignListener(SignsPlugin plugin) implements Listener { 27 | 28 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 29 | public void onSignEdit(SignChangeEvent event) { 30 | if (!event.getPlayer().hasPermission("squaremap.signs.admin")) { 31 | return; 32 | } 33 | Sign state = (Sign) event.getBlock().getState(); 34 | if (!plugin.signManager().isTracked(state)) { 35 | return; 36 | } 37 | final List edited = event.lines(); 38 | final List front = event.getSide() == Side.FRONT ? edited : state.getSide(Side.FRONT).lines(); 39 | final List back = event.getSide() == Side.BACK ? edited : state.getSide(Side.BACK).lines(); 40 | plugin.signManager().putSign(state, front, back); 41 | } 42 | 43 | @EventHandler 44 | public void onClickSign(PlayerInteractEvent event) { 45 | Block block = event.getClickedBlock(); 46 | if (block == null) { 47 | return; 48 | } 49 | BlockState state = block.getState(); 50 | if (!(state instanceof Sign sign)) { 51 | return; 52 | } 53 | if (event.getPlayer().getInventory().getItemInMainHand().getType() != Material.FILLED_MAP) { 54 | return; 55 | } 56 | if (!event.getPlayer().hasPermission("squaremap.signs.admin")) { 57 | return; 58 | } 59 | event.setCancelled(true); 60 | if (event.getAction() == Action.LEFT_CLICK_BLOCK) { 61 | plugin.signManager().removeSign(state); 62 | } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { 63 | plugin.signManager().putSign(state, sign.getSide(Side.FRONT).lines(), sign.getSide(Side.BACK).lines()); 64 | } 65 | } 66 | 67 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 68 | public void onSignBreak(BlockDropItemEvent event) { 69 | remove(event.getBlockState()); 70 | } 71 | 72 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 73 | public void onSignBreak(BlockDestroyEvent event) { 74 | remove(event.getBlock().getState()); 75 | } 76 | 77 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 78 | public void onSignBreak(BlockBurnEvent event) { 79 | remove(event.getBlock().getState()); 80 | } 81 | 82 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 83 | public void onSignBreak(BlockExplodeEvent event) { 84 | event.blockList().forEach(block -> remove(block.getState())); 85 | } 86 | 87 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 88 | public void onSignBreak(EntityExplodeEvent event) { 89 | event.blockList().forEach(block -> remove(block.getState())); 90 | } 91 | 92 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 93 | public void onSignBreak(BlockPistonExtendEvent event) { 94 | event.getBlocks().forEach(block -> remove(block.getState())); 95 | } 96 | 97 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 98 | public void onSignBreak(BlockPistonRetractEvent event) { 99 | event.getBlocks().forEach(block -> remove(block.getState())); 100 | } 101 | 102 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 103 | public void onSignBreak(BlockFromToEvent event) { 104 | remove(event.getToBlock().getState()); 105 | } 106 | 107 | private void remove(BlockState state) { 108 | if (state instanceof Sign) { 109 | plugin.signManager().removeSign(state); 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /addons/skins/src/main/java/xyz/jpenilla/squaremap/addon/skins/SquaremapSkins.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.skins; 2 | 3 | import com.destroystokyo.paper.profile.PlayerProfile; 4 | import com.destroystokyo.paper.profile.ProfileProperty; 5 | import java.awt.image.BufferedImage; 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.net.URL; 9 | import java.util.Base64; 10 | import javax.imageio.ImageIO; 11 | import org.bukkit.Bukkit; 12 | import org.bukkit.entity.Player; 13 | import org.bukkit.event.EventHandler; 14 | import org.bukkit.event.EventPriority; 15 | import org.bukkit.event.Listener; 16 | import org.bukkit.event.player.PlayerJoinEvent; 17 | import org.bukkit.plugin.java.JavaPlugin; 18 | import org.bukkit.scheduler.BukkitRunnable; 19 | import org.json.simple.JSONObject; 20 | import org.json.simple.parser.JSONParser; 21 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 22 | 23 | public final class SquaremapSkins extends JavaPlugin { 24 | private static SquaremapSkins instance; 25 | private static File skinsDir; 26 | 27 | public SquaremapSkins() { 28 | instance = this; 29 | } 30 | 31 | @Override 32 | public void onEnable() { 33 | saveDefaultConfig(); 34 | 35 | skinsDir = new File(SquaremapProvider.get().webDir().toFile(), "skins"); 36 | if (!skinsDir.exists() && !skinsDir.mkdirs()) { 37 | getLogger().severe("Could not create skins directory!"); 38 | getLogger().severe("Check your file permissions and try again"); 39 | getServer().getPluginManager().disablePlugin(this); 40 | return; 41 | } 42 | 43 | getServer().getPluginManager().registerEvents(new Listener() { 44 | @EventHandler(priority = EventPriority.MONITOR) 45 | public void onPlayerJoin(PlayerJoinEvent event) { 46 | new FetchSkinURL(event.getPlayer()).runTaskLater(instance, 5); 47 | } 48 | }, this); 49 | 50 | int interval = getConfig().getInt("update-interval", 60); 51 | new UpdateTask().runTaskTimer(instance, interval, interval); 52 | } 53 | 54 | private static class UpdateTask extends BukkitRunnable { 55 | @Override 56 | public void run() { 57 | Bukkit.getOnlinePlayers().forEach(player -> 58 | new FetchSkinURL(player).runTask(instance)); 59 | } 60 | } 61 | 62 | private static final class FetchSkinURL extends BukkitRunnable { 63 | private final Player player; 64 | 65 | private FetchSkinURL(Player player) { 66 | this.player = player; 67 | } 68 | 69 | @Override 70 | public void run() { 71 | if (!player.isOnline()) { 72 | return; 73 | } 74 | String url = getTexture(player); 75 | if (url == null || url.isEmpty()) { 76 | return; 77 | } 78 | String name = player.getName(); 79 | new SaveSkin(name, url).runTaskAsynchronously(instance); 80 | } 81 | } 82 | 83 | private static final class SaveSkin extends BukkitRunnable { 84 | private final String name; 85 | private final String url; 86 | 87 | private SaveSkin(String name, String url) { 88 | this.name = name; 89 | this.url = url; 90 | } 91 | 92 | @Override 93 | public void run() { 94 | instance.saveTexture(name, url); 95 | } 96 | } 97 | 98 | private static String getTexture(Player player) { 99 | PlayerProfile profile = player.getPlayerProfile(); 100 | for (ProfileProperty property : profile.getProperties()) { 101 | if (property.getName().equals("textures")) { 102 | try { 103 | String data = property.getValue(); 104 | byte[] base64 = Base64.getDecoder().decode(data); 105 | String json = new String(base64); 106 | JSONObject obj = (JSONObject) new JSONParser().parse(json); 107 | JSONObject obj2 = (JSONObject) obj.get("textures"); 108 | JSONObject obj3 = (JSONObject) obj2.get("SKIN"); 109 | return (String) obj3.get("url"); 110 | } catch (Exception e) { 111 | e.printStackTrace(); 112 | } 113 | } 114 | } 115 | return null; 116 | } 117 | 118 | private void saveTexture(String name, String url) { 119 | try { 120 | BufferedImage img = ImageIO.read(new URL(url)).getSubimage(8, 8, 8, 8); 121 | File file = new File(skinsDir, name + ".png"); 122 | ImageIO.write(img, "png", file); 123 | } catch (Exception e) { 124 | this.getSLF4JLogger().info("Could not save texture {} to {}", url, new File(skinsDir, name + ".png"), e); 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /addons/worldguard/src/main/java/xyz/jpenilla/squaremap/addon/worldguard/config/StyleSettings.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.worldguard.config; 2 | 3 | import com.sk89q.worldguard.protection.flags.StringFlag; 4 | import com.sk89q.worldguard.protection.regions.ProtectedRegion; 5 | import java.awt.Color; 6 | import java.lang.reflect.Type; 7 | import java.util.Objects; 8 | import org.checkerframework.checker.nullness.qual.Nullable; 9 | import org.spongepowered.configurate.objectmapping.ConfigSerializable; 10 | import org.spongepowered.configurate.serialize.SerializationException; 11 | import xyz.jpenilla.squaremap.addon.common.Util; 12 | import xyz.jpenilla.squaremap.addon.common.config.ColorSerializer; 13 | import xyz.jpenilla.squaremap.addon.worldguard.SquaremapWorldGuard; 14 | 15 | @ConfigSerializable 16 | public class StyleSettings { 17 | @ConfigSerializable 18 | public static class Stroke { 19 | public Color color = null; 20 | public Integer weight = null; 21 | public Double opacity = null; 22 | } 23 | 24 | @ConfigSerializable 25 | public static class Fill { 26 | public Color color = null; 27 | public Double opacity = null; 28 | } 29 | 30 | public Stroke stroke = null; 31 | public Fill fill = null; 32 | public String clickTooltip = null; 33 | 34 | public void validate() { 35 | Objects.requireNonNull(this.stroke, "stroke is required for the default style"); 36 | Objects.requireNonNull(this.fill, "fill is required for the default style"); 37 | Objects.requireNonNull(this.stroke.color, "stroke.color is required for the default style"); 38 | Objects.requireNonNull(this.stroke.opacity, "stroke.opacity is required for the default style"); 39 | Objects.requireNonNull(this.stroke.weight, "stroke.weight is required for the default style"); 40 | Objects.requireNonNull(this.fill.color, "fill.color is required for the default style"); 41 | Objects.requireNonNull(this.fill.opacity, "fill.opacity is required for the default style"); 42 | } 43 | 44 | public StyleSettings defaulted(final StyleSettings fallback) { 45 | final StyleSettings settings = new StyleSettings(); 46 | if (this.stroke != null) { 47 | final Stroke s = new Stroke(); 48 | s.opacity = this.stroke.opacity != null ? this.stroke.opacity : fallback.stroke.opacity; 49 | s.color = this.stroke.color != null ? this.stroke.color : fallback.stroke.color; 50 | s.weight = this.stroke.weight != null ? this.stroke.weight : fallback.stroke.weight; 51 | settings.stroke = s; 52 | } else { 53 | settings.stroke = fallback.stroke; 54 | } 55 | if (this.fill != null) { 56 | final Fill f = new Fill(); 57 | f.opacity = this.fill.opacity != null ? this.fill.opacity : fallback.fill.opacity; 58 | f.color = this.fill.color != null ? this.fill.color : fallback.fill.color; 59 | settings.fill = f; 60 | } else { 61 | settings.fill = fallback.fill; 62 | } 63 | settings.clickTooltip = this.clickTooltip != null ? this.clickTooltip : fallback.clickTooltip; 64 | return settings; 65 | } 66 | 67 | public static StyleSettings defaultSettings() { 68 | final StyleSettings settings = new StyleSettings(); 69 | final Stroke s = new Stroke(); 70 | s.color = Color.GREEN; 71 | s.weight = 1; 72 | s.opacity = 1.0D; 73 | final Fill f = new Fill(); 74 | f.color = Color.GREEN; 75 | f.opacity = 0.2D; 76 | settings.stroke = s; 77 | settings.fill = f; 78 | settings.clickTooltip = "{regionname}
" + 79 | "Owner {playerowners}
" + 80 | "Flags
{flags}"; 81 | return settings; 82 | } 83 | 84 | public static StyleSettings fromFlags(final SquaremapWorldGuard plugin, final ProtectedRegion region) { 85 | try { 86 | final StyleSettings settings = new StyleSettings(); 87 | final Stroke s = new Stroke(); 88 | s.color = color(region, plugin.strokeColorFlag); 89 | s.weight = region.getFlag(plugin.strokeWeightFlag); 90 | s.opacity = region.getFlag(plugin.strokeOpacityFlag); 91 | final Fill f = new Fill(); 92 | f.color = color(region, plugin.fillColorFlag); 93 | f.opacity = region.getFlag(plugin.fillOpacityFlag); 94 | settings.stroke = s; 95 | settings.fill = f; 96 | settings.clickTooltip = region.getFlag(plugin.clickTooltipFlag); 97 | return settings; 98 | } catch (final Exception ex) { 99 | throw Util.rethrow(ex); 100 | } 101 | } 102 | 103 | private static @Nullable Color color(final ProtectedRegion region, final StringFlag flag) throws SerializationException { 104 | final @Nullable String data = region.getFlag(flag); 105 | if (data == null) { 106 | return null; 107 | } 108 | //noinspection DataFlowIssue 109 | return ColorSerializer.INSTANCE.deserialize((Type) null, data); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /addons/griefprevention/src/main/java/xyz/jpenilla/squaremap/addon/griefprevention/task/SquaremapTask.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.griefprevention.task; 2 | 3 | import java.awt.Color; 4 | import java.util.ArrayList; 5 | import java.util.Collection; 6 | import java.util.List; 7 | import java.util.UUID; 8 | import me.ryanhamshire.GriefPrevention.Claim; 9 | import org.bukkit.Bukkit; 10 | import org.bukkit.Location; 11 | import org.bukkit.OfflinePlayer; 12 | import org.bukkit.World; 13 | import org.bukkit.scheduler.BukkitRunnable; 14 | import xyz.jpenilla.squaremap.addon.griefprevention.SquaremapGriefPrevention; 15 | import xyz.jpenilla.squaremap.addon.griefprevention.hook.GPHook; 16 | import xyz.jpenilla.squaremap.api.BukkitAdapter; 17 | import xyz.jpenilla.squaremap.api.Key; 18 | import xyz.jpenilla.squaremap.api.MapWorld; 19 | import xyz.jpenilla.squaremap.api.Point; 20 | import xyz.jpenilla.squaremap.api.SimpleLayerProvider; 21 | import xyz.jpenilla.squaremap.api.marker.Marker; 22 | import xyz.jpenilla.squaremap.api.marker.MarkerOptions; 23 | import xyz.jpenilla.squaremap.api.marker.Rectangle; 24 | 25 | public final class SquaremapTask extends BukkitRunnable { 26 | private final World bukkitWorld; 27 | private final SimpleLayerProvider provider; 28 | private final SquaremapGriefPrevention plugin; 29 | 30 | private boolean stop; 31 | 32 | public SquaremapTask(SquaremapGriefPrevention plugin, MapWorld world, SimpleLayerProvider provider) { 33 | this.plugin = plugin; 34 | this.bukkitWorld = BukkitAdapter.bukkitWorld(world); 35 | this.provider = provider; 36 | } 37 | 38 | @Override 39 | public void run() { 40 | if (this.stop) { 41 | this.cancel(); 42 | } 43 | this.updateClaims(); 44 | } 45 | 46 | void updateClaims() { 47 | this.provider.clearMarkers(); // TODO track markers instead of clearing them 48 | Collection topLevelClaims = GPHook.getClaims(); 49 | if (topLevelClaims != null) { 50 | topLevelClaims.stream() 51 | .filter(claim -> claim.getGreaterBoundaryCorner().getWorld().getUID().equals(this.bukkitWorld.getUID())) 52 | .filter(claim -> claim.parent == null) 53 | .forEach(this::handleClaim); 54 | } 55 | } 56 | 57 | private void handleClaim(Claim claim) { 58 | Location min = claim.getLesserBoundaryCorner(); 59 | Location max = claim.getGreaterBoundaryCorner(); 60 | if (min == null) { 61 | return; 62 | } 63 | 64 | Rectangle rect = Marker.rectangle(Point.of(min.getBlockX(), min.getBlockZ()), Point.of(max.getBlockX() + 1, max.getBlockZ() + 1)); 65 | 66 | ArrayList builders = new ArrayList<>(); 67 | ArrayList containers = new ArrayList<>(); 68 | ArrayList accessors = new ArrayList<>(); 69 | ArrayList managers = new ArrayList<>(); 70 | claim.getPermissions(builders, containers, accessors, managers); 71 | 72 | String worldName = min.getWorld().getName(); 73 | 74 | MarkerOptions.Builder options = MarkerOptions.builder() 75 | .strokeColor(this.plugin.config().strokeColor) 76 | .strokeWeight(this.plugin.config().strokeWeight) 77 | .strokeOpacity(this.plugin.config().strokeOpacity) 78 | .fillColor(this.plugin.config().fillColor) 79 | .fillOpacity(this.plugin.config().fillOpacity) 80 | .clickTooltip( 81 | (claim.isAdminClaim() ? this.plugin.config().adminClaimTooltip : this.plugin.config().claimTooltip) 82 | .replace("{world}", worldName) 83 | .replace("{id}", Long.toString(claim.getID())) 84 | .replace("{owner}", claim.getOwnerName()) 85 | .replace("{managers}", getNames(managers)) 86 | .replace("{builders}", getNames(builders)) 87 | .replace("{containers}", getNames(containers)) 88 | .replace("{accessors}", getNames(accessors)) 89 | .replace("{area}", Integer.toString(claim.getArea())) 90 | .replace("{width}", Integer.toString(claim.getWidth())) 91 | .replace("{height}", Integer.toString(claim.getHeight())) 92 | ); 93 | 94 | if (claim.isAdminClaim()) { 95 | options.strokeColor(Color.BLUE).fillColor(Color.BLUE); 96 | } 97 | 98 | rect.markerOptions(options); 99 | 100 | String markerid = "griefprevention_region_" + Long.toHexString(claim.getID()); 101 | this.provider.addMarker(Key.of(markerid), rect); 102 | } 103 | 104 | private static String getNames(List list) { 105 | List names = new ArrayList<>(); 106 | for (String str : list) { 107 | try { 108 | UUID uuid = UUID.fromString(str); 109 | OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid); 110 | names.add(offlinePlayer.getName()); 111 | } catch (Exception e) { 112 | names.add(str); 113 | } 114 | } 115 | return String.join(", ", names); 116 | } 117 | 118 | public void disable() { 119 | this.cancel(); 120 | this.stop = true; 121 | this.provider.clearMarkers(); 122 | } 123 | } 124 | 125 | -------------------------------------------------------------------------------- /addons/banners/src/main/java/xyz/jpenilla/squaremap/addon/banners/data/BannersManager.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.banners.data; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.nio.file.Files; 6 | import java.nio.file.Path; 7 | import java.util.Objects; 8 | import java.util.logging.Level; 9 | import org.bukkit.Chunk; 10 | import org.bukkit.Location; 11 | import org.bukkit.block.BlockState; 12 | import org.bukkit.configuration.InvalidConfigurationException; 13 | import org.bukkit.configuration.file.YamlConfiguration; 14 | import xyz.jpenilla.squaremap.addon.banners.SquaremapBanners; 15 | import xyz.jpenilla.squaremap.addon.common.Util; 16 | import xyz.jpenilla.squaremap.api.Key; 17 | import xyz.jpenilla.squaremap.api.WorldIdentifier; 18 | 19 | public final class BannersManager { 20 | private final SquaremapBanners plugin; 21 | private final Path dataDir; 22 | 23 | public BannersManager(SquaremapBanners plugin) { 24 | this.plugin = plugin; 25 | this.dataDir = new File(plugin.getDataFolder(), "data").toPath(); 26 | 27 | if (!Files.exists(this.dataDir)) { 28 | try { 29 | Files.createDirectories(this.dataDir); 30 | } catch (final IOException e) { 31 | Util.rethrow(e); 32 | } 33 | } 34 | } 35 | 36 | private Path dataFile(final WorldIdentifier identifier) { 37 | final Path resolve = this.dataDir.resolve(identifier.asString().replace(":", "_") + ".yml"); 38 | try { 39 | final Path old = this.dataDir.resolve(identifier + ".yml"); 40 | if (Files.exists(old)) { 41 | Files.move(old, resolve); 42 | } 43 | } catch (final Exception ignore) { 44 | } 45 | return resolve; 46 | } 47 | 48 | public void load() { 49 | this.plugin.squaremapHook().getProviders().forEach((worldIdentifier, provider) -> { 50 | YamlConfiguration config = new YamlConfiguration(); 51 | try { 52 | File file = this.dataFile(worldIdentifier).toFile(); 53 | if (file.exists()) { 54 | this.plugin.debug("Loading " + file); 55 | config.load(file); 56 | } 57 | } catch (IOException | InvalidConfigurationException e) { 58 | e.printStackTrace(); 59 | } 60 | config.getKeys(false).forEach(entry -> { 61 | try { 62 | this.plugin.debug("Entry: " + entry); 63 | String[] split = entry.split(","); 64 | int x = Integer.parseInt(split[0]); 65 | int y = Integer.parseInt(split[1]); 66 | int z = Integer.parseInt(split[2]); 67 | Position pos = Position.of(x, y, z); 68 | Key key = Key.of(Objects.requireNonNull(config.getString(entry + ".key"))); 69 | String name = config.getString(entry + ".name", "Unknown"); 70 | provider.add(pos, key, name); 71 | } catch (Exception e) { 72 | this.plugin.getLogger().log(Level.SEVERE, "Could not load " + entry + " from " + worldIdentifier, e); 73 | } 74 | }); 75 | }); 76 | } 77 | 78 | public void save() { 79 | this.plugin.squaremapHook().getProviders().forEach((worldIdentifier, provider) -> { 80 | YamlConfiguration config = new YamlConfiguration(); 81 | provider.getData().forEach((pos, data) -> { 82 | String entry = pos.x() + "," + pos.y() + "," + pos.z(); 83 | this.plugin.debug("Entry: " + entry + " key: " + data.key().getKey() + " name: " + data.name()); 84 | config.set(entry + ".key", data.key().getKey()); 85 | config.set(entry + ".name", data.name()); 86 | }); 87 | try { 88 | final Path path = this.dataFile(worldIdentifier); 89 | this.plugin.debug("Saving data at " + path + " ..."); 90 | config.save(path.toFile()); 91 | } catch (IOException e) { 92 | e.printStackTrace(); 93 | } 94 | }); 95 | } 96 | 97 | public void removeBanner(BlockState state) { 98 | BannerLayerProvider provider = this.plugin.squaremapHook().getProvider(state.getWorld()); 99 | if (provider == null) { 100 | return; 101 | } 102 | Location loc = state.getLocation(); 103 | provider.remove(Position.of(loc)); 104 | } 105 | 106 | public void putBanner(BlockState state, String name) { 107 | BannerLayerProvider provider = this.plugin.squaremapHook().getProvider(state.getWorld()); 108 | if (provider == null) { 109 | return; 110 | } 111 | provider.add(Position.of(state.getLocation()), Icons.getIcon(state.getType()), name); 112 | } 113 | 114 | public void checkChunk(Chunk chunk) { 115 | int minX = chunk.getX(); 116 | int minZ = chunk.getZ(); 117 | int maxX = minX + 16; 118 | int maxZ = minZ + 16; 119 | BannerLayerProvider provider = this.plugin.squaremapHook().getProvider(chunk.getWorld()); 120 | if (provider != null) { 121 | provider.getPositions().forEach(pos -> { 122 | if (pos.x() >= minX && pos.z() >= minZ && 123 | pos.x() <= maxX && pos.z() <= maxZ && 124 | !pos.isBanner(chunk.getWorld())) { 125 | provider.remove(pos); 126 | } 127 | }); 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /addons/banners/src/main/java/xyz/jpenilla/squaremap/addon/banners/listener/BannersListener.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.banners.listener; 2 | 3 | import com.destroystokyo.paper.event.block.BlockDestroyEvent; 4 | import org.bukkit.Material; 5 | import org.bukkit.NamespacedKey; 6 | import org.bukkit.block.Banner; 7 | import org.bukkit.block.Block; 8 | import org.bukkit.block.BlockState; 9 | import org.bukkit.event.EventHandler; 10 | import org.bukkit.event.EventPriority; 11 | import org.bukkit.event.Listener; 12 | import org.bukkit.event.block.Action; 13 | import org.bukkit.event.block.BlockBurnEvent; 14 | import org.bukkit.event.block.BlockDropItemEvent; 15 | import org.bukkit.event.block.BlockExplodeEvent; 16 | import org.bukkit.event.block.BlockFromToEvent; 17 | import org.bukkit.event.block.BlockPistonExtendEvent; 18 | import org.bukkit.event.block.BlockPistonRetractEvent; 19 | import org.bukkit.event.block.BlockPlaceEvent; 20 | import org.bukkit.event.entity.EntityExplodeEvent; 21 | import org.bukkit.event.player.PlayerInteractEvent; 22 | import org.bukkit.inventory.ItemStack; 23 | import org.bukkit.persistence.PersistentDataType; 24 | import xyz.jpenilla.squaremap.addon.banners.SquaremapBanners; 25 | 26 | public class BannersListener implements Listener { 27 | private final SquaremapBanners plugin; 28 | private final NamespacedKey key; 29 | 30 | public BannersListener(SquaremapBanners plugin) { 31 | this.plugin = plugin; 32 | this.key = new NamespacedKey(plugin, "display_name"); 33 | } 34 | 35 | @EventHandler 36 | public void onClickBanner(PlayerInteractEvent event) { 37 | Block block = event.getClickedBlock(); 38 | if (block == null) { 39 | return; 40 | } 41 | BlockState state = block.getState(); 42 | if (!(state instanceof Banner banner)) { 43 | return; 44 | } 45 | if (event.getPlayer().getInventory().getItemInMainHand().getType() != Material.FILLED_MAP) { 46 | return; 47 | } 48 | if (!event.getPlayer().isSneaking()) { 49 | return; 50 | } 51 | if (!event.getPlayer().hasPermission("squaremap.banners.admin")) { 52 | return; 53 | } 54 | event.setCancelled(true); 55 | if (event.getAction() == Action.LEFT_CLICK_BLOCK) { 56 | plugin.bannerManager().removeBanner(state); 57 | } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { 58 | this.plugin.debug("Putting banner: " + banner); 59 | String displayName = banner.getPersistentDataContainer().get(key, PersistentDataType.STRING); 60 | this.plugin.debug("key: " + key + " PersistentDataContainer: " + displayName); 61 | plugin.bannerManager().putBanner(state, displayName); 62 | } 63 | } 64 | 65 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 66 | public void onBlockPlace(BlockPlaceEvent event) { 67 | BlockState state = event.getBlockPlaced().getState(); 68 | if (state instanceof Banner banner) { 69 | ItemStack item = event.getItemInHand(); 70 | String itemName = item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : ""; 71 | this.plugin.debug("Setting '" + itemName + "' into banner."); 72 | banner.getPersistentDataContainer().set(key, PersistentDataType.STRING, itemName); 73 | boolean updateState = banner.update(); 74 | this.plugin.debug("Update State: " + (updateState ? "Success" : "Failure")); 75 | this.plugin.debug("Banner: " + banner); 76 | this.plugin.debug("PersistentDataContainer: " + banner.getPersistentDataContainer().get(key, PersistentDataType.STRING)); 77 | } 78 | } 79 | 80 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 81 | public void onBannerBreak(BlockDropItemEvent event) { 82 | remove(event.getBlockState()); 83 | } 84 | 85 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 86 | public void onBannerBreak(BlockDestroyEvent event) { 87 | remove(event.getBlock().getState()); 88 | } 89 | 90 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 91 | public void onBannerBreak(BlockBurnEvent event) { 92 | remove(event.getBlock().getState()); 93 | } 94 | 95 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 96 | public void onBannerBreak(BlockExplodeEvent event) { 97 | event.blockList().forEach(block -> remove(block.getState())); 98 | } 99 | 100 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 101 | public void onBannerBreak(EntityExplodeEvent event) { 102 | event.blockList().forEach(block -> remove(block.getState())); 103 | } 104 | 105 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 106 | public void onBannerBreak(BlockPistonExtendEvent event) { 107 | event.getBlocks().forEach(block -> remove(block.getState())); 108 | } 109 | 110 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 111 | public void onBannerBreak(BlockPistonRetractEvent event) { 112 | event.getBlocks().forEach(block -> remove(block.getState())); 113 | } 114 | 115 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 116 | public void onBannerBreak(BlockFromToEvent event) { 117 | remove(event.getToBlock().getState()); 118 | } 119 | 120 | private void remove(BlockState state) { 121 | if (state instanceof Banner) { 122 | plugin.bannerManager().removeBanner(state); 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /addons/mobs/src/main/java/xyz/jpenilla/squaremap/addon/mobs/data/Icons.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.mobs.data; 2 | 3 | import java.awt.image.BufferedImage; 4 | import java.io.File; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import java.util.logging.Level; 8 | import javax.imageio.ImageIO; 9 | import org.bukkit.entity.EntityType; 10 | import xyz.jpenilla.squaremap.addon.mobs.SquaremapMobs; 11 | import xyz.jpenilla.squaremap.addon.mobs.config.MobsWorldConfig; 12 | import xyz.jpenilla.squaremap.api.Key; 13 | import xyz.jpenilla.squaremap.api.SquaremapProvider; 14 | 15 | public final class Icons { 16 | public static final Map BY_TYPE = new HashMap<>(); 17 | 18 | public static final Key BAT = register("bat"); 19 | public static final Key BEE = register("bee"); 20 | public static final Key BLAZE = register("blaze"); 21 | public static final Key CAT = register("cat"); 22 | public static final Key CAVE_SPIDER = register("cave_spider"); 23 | public static final Key CHICKEN = register("chicken"); 24 | public static final Key COD = register("cod"); 25 | public static final Key COW = register("cow"); 26 | public static final Key CREEPER = register("creeper"); 27 | public static final Key DOLPHIN = register("dolphin"); 28 | public static final Key DONKEY = register("donkey"); 29 | public static final Key DROWNED = register("drowned"); 30 | public static final Key ELDER_GUARDIAN = register("elder_guardian"); 31 | public static final Key ENDER_DRAGON = register("ender_dragon"); 32 | public static final Key ENDERMAN = register("enderman"); 33 | public static final Key ENDERMITE = register("endermite"); 34 | public static final Key EVOKER = register("evoker"); 35 | public static final Key FOX = register("fox"); 36 | public static final Key GHAST = register("ghast"); 37 | public static final Key GIANT = register("giant"); 38 | public static final Key GUARDIAN = register("guardian"); 39 | public static final Key HOGLIN = register("hoglin"); 40 | public static final Key HORSE = register("horse"); 41 | public static final Key HUSK = register("husk"); 42 | public static final Key ILLUSIONER = register("illusioner"); 43 | public static final Key IRON_GOLEM = register("iron_golem"); 44 | // public static final Key KILLER_BUNNY = register("killer_bunny"); 45 | public static final Key LLAMA = register("llama"); 46 | public static final Key MAGMA_CUBE = register("magma_cube"); 47 | public static final Key MOOSHROOM = register("mooshroom"); 48 | public static final Key MULE = register("mule"); 49 | public static final Key OCELOT = register("ocelot"); 50 | public static final Key PANDA = register("panda"); 51 | public static final Key PARROT = register("parrot"); 52 | public static final Key PHANTOM = register("phantom"); 53 | public static final Key PIG = register("pig"); 54 | public static final Key PIGLIN = register("piglin"); 55 | public static final Key PIGLIN_BRUTE = register("piglin_brute"); 56 | public static final Key PILLAGER = register("pillager"); 57 | public static final Key POLAR_BEAR = register("polar_bear"); 58 | public static final Key PUFFERFISH = register("pufferfish"); 59 | public static final Key RABBIT = register("rabbit"); 60 | public static final Key RAVAGER = register("ravager"); 61 | public static final Key SALMON = register("salmon"); 62 | public static final Key SHEEP = register("sheep"); 63 | public static final Key SHULKER = register("shulker"); 64 | public static final Key SILVERFISH = register("silverfish"); 65 | public static final Key SKELETON = register("skeleton"); 66 | public static final Key SKELETON_HORSE = register("skeleton_horse"); 67 | public static final Key SLIME = register("slime"); 68 | public static final Key SNOW_GOLEM = register("snow_golem"); 69 | public static final Key SPIDER = register("spider"); 70 | public static final Key SQUID = register("squid"); 71 | public static final Key STRAY = register("stray"); 72 | public static final Key STRIDER = register("strider"); 73 | public static final Key TRADER_LLAMA = register("trader_llama"); 74 | public static final Key TROPICAL_FISH = register("tropical_fish"); 75 | public static final Key TURTLE = register("turtle"); 76 | public static final Key VEX = register("vex"); 77 | public static final Key VILLAGER = register("villager"); 78 | public static final Key VINDICATOR = register("vindicator"); 79 | public static final Key WANDERING_TRADER = register("wandering_trader"); 80 | public static final Key WITCH = register("witch"); 81 | public static final Key WITHER = register("wither"); 82 | public static final Key WITHER_SKELETON = register("wither_skeleton"); 83 | public static final Key WOLF = register("wolf"); 84 | public static final Key ZOGLIN = register("zoglin"); 85 | public static final Key ZOMBIE = register("zombie"); 86 | public static final Key ZOMBIE_HORSE = register("zombie_horse"); 87 | public static final Key ZOMBIE_VILLAGER = register("zombie_villager"); 88 | public static final Key ZOMBIFIED_PIGLIN = register("zombified_piglin"); 89 | 90 | private static Key register(String name) { 91 | SquaremapMobs plugin = SquaremapMobs.getInstance(); 92 | String filename = "icons" + File.separator + name + ".png"; 93 | File file = new File(plugin.getDataFolder(), filename); 94 | if (!file.exists()) { 95 | plugin.saveResource(filename, false); 96 | } 97 | 98 | final Key key = Key.of(name); 99 | try { 100 | final BufferedImage image = ImageIO.read(file); 101 | SquaremapProvider.get().iconRegistry().register(key, image); 102 | 103 | final EntityType type = MobsWorldConfig.parseEntityType(name); 104 | if (type == null) { 105 | throw new RuntimeException("unknown entity type: " + name); 106 | } 107 | 108 | BY_TYPE.put(type, key); 109 | } catch (final Exception e) { 110 | SquaremapMobs.getInstance().getLogger().log(Level.WARNING, "Failed to register signs icon", e); 111 | } 112 | return key; 113 | } 114 | 115 | public static Key getIcon(EntityType type) { 116 | return BY_TYPE.get(type); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /addons/worldguard/src/main/java/xyz/jpenilla/squaremap/addon/worldguard/task/SquaremapTask.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.worldguard.task; 2 | 3 | import com.sk89q.worldedit.math.BlockVector3; 4 | import com.sk89q.worldguard.WorldGuard; 5 | import com.sk89q.worldguard.protection.flags.Flag; 6 | import com.sk89q.worldguard.protection.flags.StateFlag; 7 | import com.sk89q.worldguard.protection.regions.ProtectedRegion; 8 | import com.sk89q.worldguard.protection.regions.RegionType; 9 | import com.sk89q.worldguard.util.profile.cache.ProfileCache; 10 | import java.util.List; 11 | import java.util.Map; 12 | import java.util.stream.Collectors; 13 | import org.bukkit.Bukkit; 14 | import org.bukkit.scheduler.BukkitRunnable; 15 | import org.checkerframework.checker.nullness.qual.Nullable; 16 | import xyz.jpenilla.squaremap.addon.common.config.ListMode; 17 | import xyz.jpenilla.squaremap.addon.worldguard.SquaremapWorldGuard; 18 | import xyz.jpenilla.squaremap.addon.worldguard.config.StyleSettings; 19 | import xyz.jpenilla.squaremap.addon.worldguard.config.WGWorldConfig; 20 | import xyz.jpenilla.squaremap.addon.worldguard.hook.WGHook; 21 | import xyz.jpenilla.squaremap.api.BukkitAdapter; 22 | import xyz.jpenilla.squaremap.api.Key; 23 | import xyz.jpenilla.squaremap.api.Point; 24 | import xyz.jpenilla.squaremap.api.SimpleLayerProvider; 25 | import xyz.jpenilla.squaremap.api.WorldIdentifier; 26 | import xyz.jpenilla.squaremap.api.marker.Marker; 27 | import xyz.jpenilla.squaremap.api.marker.MarkerOptions; 28 | 29 | public final class SquaremapTask extends BukkitRunnable { 30 | private final WorldIdentifier world; 31 | private final SimpleLayerProvider provider; 32 | private final SquaremapWorldGuard plugin; 33 | 34 | private boolean stop; 35 | 36 | public SquaremapTask(SquaremapWorldGuard plugin, WorldIdentifier world, SimpleLayerProvider provider) { 37 | this.plugin = plugin; 38 | this.world = world; 39 | this.provider = provider; 40 | } 41 | 42 | @Override 43 | public void run() { 44 | if (this.stop) { 45 | this.cancel(); 46 | } 47 | this.updateClaims(); 48 | } 49 | 50 | void updateClaims() { 51 | this.provider.clearMarkers(); // TODO track markers instead of clearing them 52 | Map regions = WGHook.getRegions(this.world); 53 | if (regions == null) { 54 | return; 55 | } 56 | final WGWorldConfig cfg = this.plugin.config().worldConfig(this.world); 57 | final ListMode listMode = cfg.listMode; 58 | final List list = cfg.regionList; 59 | regions.forEach((id, region) -> { 60 | if (!listMode.allowed(list, id)) { 61 | return; 62 | } 63 | this.handleClaim(region); 64 | }); 65 | } 66 | 67 | private void handleClaim(ProtectedRegion region) { 68 | final StateFlag.State state = region.getFlag(this.plugin.visibleFlag); 69 | if (state == StateFlag.State.DENY) { 70 | return; 71 | } 72 | 73 | Marker marker; 74 | 75 | if (region.getType() == RegionType.CUBOID) { 76 | BlockVector3 min = region.getMinimumPoint(); 77 | BlockVector3 max = region.getMaximumPoint(); 78 | marker = Marker.rectangle( 79 | Point.of(min.getX(), min.getZ()), 80 | Point.of(max.getX() + 1, max.getZ() + 1) 81 | ); 82 | } else if (region.getType() == RegionType.POLYGON) { 83 | List points = region.getPoints().stream() 84 | .map(point -> Point.of(point.getX(), point.getZ())) 85 | .collect(Collectors.toList()); 86 | marker = Marker.polygon(points); 87 | } else { 88 | // do not draw global region 89 | return; 90 | } 91 | 92 | ProfileCache pc = WorldGuard.getInstance().getProfileCache(); 93 | Map, Object> flags = region.getFlags(); 94 | 95 | final WGWorldConfig cfg = this.plugin.config().worldConfig(this.world); 96 | final StyleSettings defaults = StyleSettings.fromFlags(this.plugin, region).defaulted(cfg.defaultStyle); 97 | final @Nullable StyleSettings override = cfg.styleOverrides.get(region.getId()); 98 | final StyleSettings style = override == null ? defaults : override.defaulted(defaults); 99 | MarkerOptions.Builder options = MarkerOptions.builder() 100 | .strokeColor(style.stroke.color) 101 | .strokeWeight(style.stroke.weight) 102 | .strokeOpacity(style.stroke.opacity) 103 | .fillColor(style.fill.color) 104 | .fillOpacity(style.fill.opacity); 105 | if (style.clickTooltip != null && !style.clickTooltip.isBlank()) { 106 | options.clickTooltip( 107 | style.clickTooltip 108 | .replace("{world}", Bukkit.getWorld(BukkitAdapter.namespacedKey(this.world)).getName()) // use names for now 109 | .replace("{id}", region.getId()) 110 | .replace("{owner}", region.getOwners().toPlayersString()) 111 | .replace("{regionname}", region.getId()) 112 | .replace("{playerowners}", region.getOwners().toPlayersString(pc)) 113 | .replace("{groupowners}", region.getOwners().toGroupsString()) 114 | .replace("{playermembers}", region.getMembers().toPlayersString(pc)) 115 | .replace("{groupmembers}", region.getMembers().toGroupsString()) 116 | .replace("{parent}", region.getParent() == null ? "" : region.getParent().getId()) 117 | .replace("{priority}", String.valueOf(region.getPriority())) 118 | .replace( 119 | "{flags}", 120 | flags.keySet().stream() 121 | .filter(flag -> cfg.flagListMode.allowed(cfg.flagList, flag.getName())) 122 | .map(flag -> flag.getName() + ": " + flags.get(flag) + "
") 123 | .collect(Collectors.joining()) 124 | ) 125 | ); 126 | } 127 | 128 | marker.markerOptions(options); 129 | 130 | String markerid = "worldguard_region_" + region.getId().hashCode(); 131 | this.provider.addMarker(Key.of(markerid), marker); 132 | } 133 | 134 | public void disable() { 135 | this.cancel(); 136 | this.stop = true; 137 | this.provider.clearMarkers(); 138 | } 139 | } 140 | 141 | -------------------------------------------------------------------------------- /addons/signs/src/main/java/xyz/jpenilla/squaremap/addon/signs/data/SignLayerProvider.java: -------------------------------------------------------------------------------- 1 | package xyz.jpenilla.squaremap.addon.signs.data; 2 | 3 | import java.util.Collection; 4 | import java.util.List; 5 | import java.util.Map; 6 | import java.util.Optional; 7 | import java.util.Set; 8 | import java.util.concurrent.ConcurrentHashMap; 9 | import java.util.regex.Matcher; 10 | import java.util.regex.Pattern; 11 | import java.util.stream.Collectors; 12 | import net.kyori.adventure.text.Component; 13 | import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; 14 | import org.checkerframework.checker.nullness.qual.NonNull; 15 | import org.checkerframework.checker.nullness.qual.Nullable; 16 | import org.checkerframework.framework.qual.DefaultQualifier; 17 | import xyz.jpenilla.squaremap.addon.common.Util; 18 | import xyz.jpenilla.squaremap.addon.signs.SignsPlugin; 19 | import xyz.jpenilla.squaremap.addon.signs.config.SignsWorldConfig; 20 | import xyz.jpenilla.squaremap.api.Key; 21 | import xyz.jpenilla.squaremap.api.LayerProvider; 22 | import xyz.jpenilla.squaremap.api.marker.Icon; 23 | import xyz.jpenilla.squaremap.api.marker.Marker; 24 | import xyz.jpenilla.squaremap.api.marker.MarkerOptions; 25 | 26 | @DefaultQualifier(NonNull.class) 27 | public final class SignLayerProvider implements LayerProvider { 28 | private final Map data = new ConcurrentHashMap<>(); 29 | private final SignsWorldConfig worldConfig; 30 | private final SignsPlugin plugin; 31 | private final @Nullable Pattern customIconPattern; 32 | 33 | public SignLayerProvider(final SignsWorldConfig worldConfig, final SignsPlugin plugin) { 34 | this.worldConfig = worldConfig; 35 | this.plugin = plugin; 36 | if (this.worldConfig.iconCustom) { 37 | this.customIconPattern = this.compileCustomIconPattern(); 38 | if (this.plugin.customIcons().isEmpty()) { 39 | this.plugin.getSLF4JLogger().warn("custom icons were requested but no image files were found in customicons/"); 40 | } 41 | } else { 42 | this.customIconPattern = null; 43 | } 44 | } 45 | 46 | @Override 47 | public String getLabel() { 48 | return this.worldConfig.layerLabel; 49 | } 50 | 51 | @Override 52 | public boolean showControls() { 53 | return this.worldConfig.layerControls; 54 | } 55 | 56 | @Override 57 | public boolean defaultHidden() { 58 | return this.worldConfig.layerControlsHidden; 59 | } 60 | 61 | @Override 62 | public int layerPriority() { 63 | return this.worldConfig.layerPriority; 64 | } 65 | 66 | @Override 67 | public int zIndex() { 68 | return this.worldConfig.layerZindex; 69 | } 70 | 71 | @Override 72 | public Collection getMarkers() { 73 | return this.data.values().stream() 74 | .map(Data::marker) 75 | .collect(Collectors.toSet()); 76 | } 77 | 78 | public void clear() { 79 | this.data.clear(); 80 | } 81 | 82 | public Set getPositions() { 83 | return this.data.keySet(); 84 | } 85 | 86 | public Map getData() { 87 | return this.data; 88 | } 89 | 90 | public @Nullable Data getData(Position position) { 91 | return this.data.get(position); 92 | } 93 | 94 | public void add( 95 | final Position position, 96 | final SignType signType, 97 | @Nullable List front, 98 | @Nullable List back 99 | ) { 100 | final Key iconKey = this.tryExtractCustomIcon(front).orElse(signType.iconKey); 101 | Icon icon = Marker.icon(position.point(), iconKey, worldConfig.iconSize); 102 | front = front == null || isBlank(front) ? null : front; 103 | back = back == null || isBlank(back) ? null : back; 104 | icon.markerOptions(MarkerOptions.builder().hoverTooltip(this.renderHoverTooltip(front, back))); 105 | this.data.put(position, new Data(icon, signType, front, back)); 106 | } 107 | 108 | private @Nullable String renderHoverTooltip( 109 | final @Nullable List front, 110 | final @Nullable List back 111 | ) { 112 | final boolean frontBlank = front == null; 113 | final boolean backBlank = back == null; 114 | if (frontBlank && backBlank) { 115 | if (this.worldConfig.blankTooltip.isBlank()) { 116 | return null; 117 | } 118 | return this.worldConfig.blankTooltip; 119 | } else if (backBlank) { 120 | return this.worldConfig.frontOnlyTooltip 121 | .replace("{line1}", Util.asHtml(front.get(0))) 122 | .replace("{line2}", Util.asHtml(front.get(1))) 123 | .replace("{line3}", Util.asHtml(front.get(2))) 124 | .replace("{line4}", Util.asHtml(front.get(3))); 125 | } else if (frontBlank) { 126 | return this.worldConfig.backOnlyTooltip 127 | .replace("{line1}", Util.asHtml(back.get(0))) 128 | .replace("{line2}", Util.asHtml(back.get(1))) 129 | .replace("{line3}", Util.asHtml(back.get(2))) 130 | .replace("{line4}", Util.asHtml(back.get(3))); 131 | } 132 | return this.worldConfig.frontAndBackTooltip 133 | .replace("{line1}", Util.asHtml(front.get(0))) 134 | .replace("{line2}", Util.asHtml(front.get(1))) 135 | .replace("{line3}", Util.asHtml(front.get(2))) 136 | .replace("{line4}", Util.asHtml(front.get(3))) 137 | .replace("{line1b}", Util.asHtml(back.get(0))) 138 | .replace("{line2b}", Util.asHtml(back.get(1))) 139 | .replace("{line3b}", Util.asHtml(back.get(2))) 140 | .replace("{line4b}", Util.asHtml(back.get(3))); 141 | } 142 | 143 | private static boolean isBlank(final List components) { 144 | for (final Component component : components) { 145 | if (!PlainTextComponentSerializer.plainText().serialize(component).isEmpty()) { 146 | return false; 147 | } 148 | } 149 | return true; 150 | } 151 | 152 | public void remove(Position position) { 153 | this.data.remove(position); 154 | } 155 | 156 | private final Optional tryExtractCustomIcon(final @Nullable List front) { 157 | if (this.customIconPattern == null || front == null || front.get(0) == null) { 158 | return Optional.empty(); 159 | } 160 | 161 | try { 162 | final String firstLine = PlainTextComponentSerializer.plainText().serialize(front.get(0)); 163 | final Matcher match = this.customIconPattern.matcher(firstLine); 164 | if (match != null && match.matches()) { 165 | // get last regexp capture group 166 | final String matchText = match.group(match.groupCount()); 167 | return this.plugin.customIcons().lookup(matchText); 168 | } 169 | } catch (final Exception e) { 170 | } 171 | 172 | return Optional.empty(); 173 | } 174 | 175 | private final @Nullable Pattern compileCustomIconPattern() { 176 | try { 177 | return Pattern.compile(worldConfig.iconCustomRegexp); 178 | } catch (final Exception e) { 179 | this.plugin.getSLF4JLogger().warn("invalid regexp in \"icon.custom.regexp\", custom icons disabled: {}", 180 | e.getLocalizedMessage()); 181 | } 182 | return null; 183 | } 184 | } 185 | --------------------------------------------------------------------------------