-
Notifications
You must be signed in to change notification settings - Fork 11
New towny marker options for towns #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
765b5d4
dc4be7b
027d4b4
0ee5880
715ff22
6d822f2
23434cc
87df0e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| package codes.antti.bluemaptowny.TownyCommands; | ||
|
|
||
| import codes.antti.bluemaptowny.BlueMapTowny; | ||
| import com.palmergames.bukkit.towny.TownyMessaging; | ||
| import com.palmergames.bukkit.towny.TownyUniverse; | ||
| import com.palmergames.bukkit.towny.object.Resident; | ||
| import com.palmergames.bukkit.towny.object.metadata.StringDataField; | ||
| import de.bluecolored.bluemap.api.BlueMapAPI; | ||
| import org.bukkit.command.Command; | ||
| import org.bukkit.command.CommandExecutor; | ||
| import org.bukkit.command.CommandSender; | ||
| import org.bukkit.command.TabExecutor; | ||
| import org.bukkit.entity.Player; | ||
| import org.bukkit.plugin.Plugin; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| import java.io.File; | ||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| public class SetTownMarker implements CommandExecutor, TabExecutor { | ||
| @Override | ||
| public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { | ||
| if (!(sender instanceof Player)) { | ||
| TownyMessaging.sendErrorMsg(sender, "Must be run by a Player!"); | ||
| return true; | ||
| } | ||
| Resident resident = TownyUniverse.getInstance().getResident(((Player) sender).getUniqueId()); | ||
|
|
||
| if (!resident.hasTown()) { | ||
| TownyMessaging.sendErrorMsg(sender, "You don't have a town!"); | ||
| return true; | ||
| } | ||
|
|
||
| if (!resident.isMayor() && !((Player) sender).getPlayer().hasPermission("towny.command.town.set.townmarker")) { | ||
Chicken marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| TownyMessaging.sendErrorMsg(sender, "You don't have permission for this or aren't the Mayor!"); | ||
| return true; | ||
| } | ||
|
|
||
| TownyMessaging.sendPrefixedTownMessage(resident.getTownOrNull(), "Town Marker has been set to: " + String.join(" ", args)); | ||
| resident.getTownOrNull().addMetaData(new StringDataField("mapMarker", String.join(" ", args))); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The command should check that the marker is actually one of the markers in the presets if the preset mode is selected. Currently one can set anything and even do path traversal ( |
||
|
|
||
|
|
||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { | ||
| Plugin plugin = BlueMapTowny.plugin; | ||
| switch (plugin.getConfig().getInt("use-links-as-image-source")) { | ||
| case 1 -> { | ||
| File file = new File(BlueMapAPI.getInstance().get().getWebApp().getWebRoot().toFile(), "/assets/TownMarkers"); | ||
| String[] listOfFiles = file.list(); | ||
| if (args.length == 1) { | ||
| return Arrays.stream(listOfFiles).toList(); | ||
| } | ||
| return Collections.emptyList(); | ||
| } | ||
| case 2 -> { | ||
| return Collections.singletonList("<insert link here>"); | ||
Chicken marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| default -> { | ||
| return Collections.emptyList(); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,9 @@ popup-siege: '<span style="font-size: 120%"><strong>Siege: %attacker% vs %defend | |
| # If you want claims with holes in them to show up as fully claimed if only the perimeter is claimed. | ||
| # This means that the map will LIE about the actual claim status of the area!!! | ||
| lie-about-holes: false | ||
| # If you want to have towns have the option to use their own image markers (By default it's only a locked to 1 default image for every town) | ||
| # 0 for default, 1 as customizable within a preset of images inside a folder created by the plugin, 2 as letting the town/players choose their own town marker via a link (BE WARNED THAT YOU HAVE TO TRUST THE GOODWILL OF YOUR PLAYERS FOR THIS) | ||
| use-links-as-image-source: 0 | ||
|
||
| style: | ||
| # Y-level to put markers at | ||
| y-level: 62 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.