Skip to content

Commit

Permalink
Version 1.2
Browse files Browse the repository at this point in the history
- Allows to define how inactive buttons are displayed in book interface
  (see commands.track.buttons text_inactive parameters in your lang file)
- Minor fix: Now take in consideration "scompass.track.*" in book interface
- Minor fix: Action bar compass now starts correctly when player joins,
  before he had to activate it even if option set to "ALWAYS".
  • Loading branch information
arboriginal committed Nov 28, 2019
1 parent 159d070 commit 103b110
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ To use the command **sctrack**, you need at least one tracker addon. You can fin
* [PlayerTracker](https://github.com/arboriginal/SCT-PlayerTracker): Allows to track players positions.
* [PositionTracker](https://github.com/arboriginal/SCT-PositionTracker): Allows to track static positions.

Have a look at the [Spigot plugin thread](https://www.spigotmc.org/threads/simplecompass.351093/), maybe other addon (made by other developers) will be listed.
Have a look at the [Spigot plugin thread](https://www.spigotmc.org/threads/simplecompass.351093/), maybe other addons (made by other developers) will be listed.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>me.arboriginal</groupId>
<artifactId>SimpleCompass</artifactId>
<version>1.1</version>
<version>1.2</version>

<developers>
<developer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private void buildInterfaceTracking(Player player, BookMeta meta) {
"commands." + mainCommand + ".track.buttons").getKeys(false);

for (String trackerID : sc.targets.trackersPriority)
if (player.hasPermission("scompass.track." + trackerID)) trackers.add(trackerID);
if (sc.targets.canUseTracker(player, trackerID)) trackers.add(trackerID);

for (String[] part : chunk(trackers.toArray(new String[trackers.size()]),
sc.locale.getInt("commands." + mainCommand + ".track.per_page"))) {
Expand All @@ -158,15 +158,17 @@ private void buildInterfaceTracking(Player player, BookMeta meta) {
for (String actionName : ordered) {
TrackingActions action; // @formatter:off
try { action = TrackingActions.valueOf(actionName); } catch (Exception e) { continue; }
String text = sc.prepareMessage("commands." + mainCommand + ".track.buttons." + action + ".text");
// @formatter:on
if (!actions.contains(action)) {
commands.put("{" + action + "}", ImmutableMap.of("text", inactiveCommandText(text)));
commands.put("{" + action + "}", ImmutableMap.of("text", sc.prepareMessage(
"commands." + mainCommand + ".track.buttons." + action + ".text_inactive")));
continue;
}

commands.put("{" + action + "}", ImmutableMap.of("text", text, "hover",
sc.prepareMessage("commands." + mainCommand + ".track.buttons." + action + ".hover"),
commands.put("{" + action + "}", ImmutableMap.of("text",
sc.prepareMessage("commands." + mainCommand + ".track.buttons." + action + ".text"),
"hover", sc.prepareMessage(
"commands." + mainCommand + ".track.buttons." + action + ".hover"),
"click", "/" + mainCommand
+ " " + (tracker.requireTarget(action) != TargetSelector.NONE
? SELECT_TARGET
Expand All @@ -184,16 +186,6 @@ private void buildInterfaceTracking(Player player, BookMeta meta) {
}
}

private String inactiveCommandText(String text) {
String[] inactiveText = text.replace("&", "§").split("§");

String out = "§7";
for (int i = 0; i < inactiveText.length; i++) if (inactiveText[i].length() > 1)
out += (inactiveText[i].charAt(0) == 'l') ? "§" + inactiveText[i] + "§7" : inactiveText[i].substring(1);

return out;
}

private BaseComponent[] buildPage(Player player, CompassTypes type, List<String> optionsList) {
CompassModes typeMode = sc.datas.compassModeGet(player, type);
CompassOptions selected = sc.datas.compassOptionGet(player, type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
UUID uid = player.getUniqueId();

sc.compasses.removeCompass(player);
locks.remove(uid);
sc.tasks.clear(player);
sc.targets.unloadTargets(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import org.apache.commons.lang.time.DurationFormatUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -68,7 +69,7 @@ public void onEnable() {
getServer().spigot();
}
catch (Exception e) {
getServer().getPluginManager().disablePlugin(this);
Bukkit.getPluginManager().disablePlugin(this);
getLogger().severe("This plugin only works on Spigot servers!");
// No need to go on, it will not work
return;
Expand All @@ -84,7 +85,7 @@ public void onEnable() {
getCommand("scompass").setExecutor(new InterfaceCommand(this));

listeners = new Listeners(this);
getServer().getPluginManager().registerEvents(listeners, this);
Bukkit.getPluginManager().registerEvents(listeners, this);
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# You will find an explanation of all parameters here:
# https://github.com/arboriginal/${project.artifactId}/blob/master/src/main/resources/config.yml
# .
# Optional trackers list: https://github.com/arboriginal/SimpleCompass#trackers-addons ("Trackers addons" section)
# .
# Personal message: I'd love to have videos showing and explaining the plugin in use, but I'm not good at making vids...
# If you are able to make one, send me the link (preferred on Youtube) and I will include it (with credit and link)
# on the plugin page. English language is IMHO the most important, because it will be understandable by the most,
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,27 @@ commands:
buttons: # (You can order options of this list.)
ASK:
text: "&8[&3&l♪&8]"
text_inactive: "&7[&l♪&7]"
hover: "&6Click to ask for a tracking"
START:
text: "&8[&2&l⚑&8]"
text_inactive: "&7[&l⚑&7]"
hover: "&6Click to start a tracking"
STOP:
text: "&8[&4&l⚑&8]"
text_inactive: "&7[&l⚑&7]"
hover: "&6Click to stop a tracking"
ADD:
text: "&8[&2&l+&8]"
text_inactive: "&7[&l+&7]"
hover: "&6Click to add a tracking"
DEL:
text: "&8[&4&l-&8]"
text_inactive: "&7[&l-&7]"
hover: "&6Click to remove a tracking"
HELP:
text: "&8[&6&l?&8]"
text_inactive: ""
hover: "&6Click to display help"
books:
options:
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/lang/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,27 @@ commands:
buttons: # (Tu peux ordonner les options de cette liste.)
ASK:
text: "&8[&3&l♪&8]"
text_inactive: "&7[&l♪&7]"
hover: "&6Clique pour demander un pistage"
START:
text: "&8[&2&l⚑&8]"
text_inactive: "&7[&l⚑&7]"
hover: "&6Clique pour commencer un pistage"
STOP:
text: "&8[&4&l⚑&8]"
text_inactive: "&7[&l⚑&7]"
hover: "&6Clique pour arrêter un pistage"
ADD:
text: "&8[&2&l+&8]"
text_inactive: "&7[&l+&7]"
hover: "&6Clique pour ajouter un pistage"
DEL:
text: "&8[&4&l-&8]"
text_inactive: "&7[&l-&7]"
hover: "&6Clique pour supprimer un pistage"
HELP:
text: "&8[&6&l?&8]"
text_inactive: ""
hover: "&6Clique pour afficher l'aide"
books:
options:
Expand Down

0 comments on commit 103b110

Please sign in to comment.