Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
<version>3.0.0</version>
<scope>compile</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public boolean onCommand(CommandSender sender, Command command, String s, String
//Time
sender.sendMessage(" " + ChatColor.GREEN + Lang.TIME + ": " + ChatColor.YELLOW + point.getTime() + " " + Lang.SECONDS);
//Actionbar
if(point.getMessage_actionBar() != null && !point.getMessage_actionBar().equalsIgnoreCase("")) sender.sendMessage(" " + ChatColor.GREEN + "Actionbar: " + ChatColor.YELLOW + point.getMessage_actionBar());
if(point.getMessageActionbar() != null && !point.getMessageActionbar().equalsIgnoreCase("")) sender.sendMessage(" " + ChatColor.GREEN + "Actionbar: " + ChatColor.YELLOW + point.getMessageActionbar());
//Title
if(point.getTitleInfo() != null){
if(!point.getTitleInfo().title.equalsIgnoreCase("")) sender.sendMessage(" " + ChatColor.GREEN + "Title: " + ChatColor.YELLOW + ChatColor.translateAlternateColorCodes('&', point.getTitleInfo().title));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ public abstract class ServerTutorialPoint{
protected ServerTutorialPlus plugin;
protected PointType type;

protected BukkitTask actionbarRunnable = null;

protected Location loc;
protected List<String> message_chat;
protected List<String> commands;
protected List<FireWorkInfo> fireworks;
protected String message_actionBar;
protected String messageActionbar;
protected double actionbarShowAfter;
protected double actionbarHideAfter;
protected PlayerTitle titleInfo;
protected PlayerSound soundInfo;
protected List<PotionEffect> pointionEffects;
Expand Down Expand Up @@ -89,6 +93,7 @@ public void run() {
@Override
public void stop() {
if(timerTask != null) timerTask.cancel();
if (actionbarRunnable != null) actionbarRunnable.cancel();
}
};
}
Expand Down Expand Up @@ -151,9 +156,23 @@ protected void playDefault(Player player, OldValuesPlayer oldValuesPlayer, boole
//endregion

//region actionbar
if (message_actionBar != null) {
//NeedsReflection.sendActionBar(player, PluginUtils.replaceVariables(plugin.placeholderAPI, player, message_actionBar));
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(PluginUtils.replaceVariables(plugin.placeholderAPI, player, message_actionBar)));
if (messageActionbar != null && actionbarHideAfter > actionbarShowAfter) {
actionbarRunnable = new BukkitRunnable() {
final double showAfterTicks = actionbarShowAfter * 20;
final double hideAfterTicks = actionbarHideAfter * 20;
int ticksPassed = 0;
@Override
public void run() {
if (ticksPassed >= showAfterTicks && ticksPassed < hideAfterTicks) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR,
new TextComponent(PluginUtils.replaceVariables(plugin.placeholderAPI, player, messageActionbar)));
} else if (ticksPassed > hideAfterTicks || ticksPassed > time * 20) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(""));
this.cancel();
}
ticksPassed += 2;
}
}.runTaskTimer(plugin, 0, 2);
}
//endregion

Expand Down Expand Up @@ -197,7 +216,9 @@ public void readSaveData(Config tutorialSaves, String ID, String i) {
message_chat = tutorialSaves.getStringList("tutorials." + ID + ".points." + i + ".messages");
commands = tutorialSaves.getStringList("tutorials." + ID + ".points." + i + ".commands");

message_actionBar = tutorialSaves.getString("tutorials." + ID + ".points." + i + ".actionbar");
messageActionbar = tutorialSaves.getString("tutorials." + ID + ".points." + i + ".actionbar.message");
actionbarShowAfter = tutorialSaves.getDouble("tutorials." + ID + ".points." + i + ".actionbar.show-after", 0);
actionbarHideAfter = tutorialSaves.getDouble("tutorials." + ID + ".points." + i + ".actionbar.hide-after", time);
lockPlayer = tutorialSaves.getBoolean("tutorials." + ID + ".points." + i + ".locplayer");
lockView = tutorialSaves.getBoolean("tutorials." + ID + ".points." + i + ".locview");
flying = tutorialSaves.getBoolean("tutorials." + ID + ".points." + i + ".setFly");
Expand Down Expand Up @@ -263,7 +284,9 @@ public void saveData(Config tutorialSaves, String key, String i){
tutorialSaves.set("tutorials." + key + ".points." + i + ".locplayer", lockPlayer);
tutorialSaves.set("tutorials." + key + ".points." + i + ".locview", lockView);
tutorialSaves.set("tutorials." + key + ".points." + i + ".messages", message_chat);
tutorialSaves.set("tutorials." + key + ".points." + i + ".actionbar", message_actionBar);
tutorialSaves.set("tutorials." + key + ".points." + i + ".actionbar.message", messageActionbar);
tutorialSaves.set("tutorials." + key + ".points." + i + ".actionbar.show-after", actionbarShowAfter);
tutorialSaves.set("tutorials." + key + ".points." + i + ".actionbar.hide-after", actionbarHideAfter);
tutorialSaves.set("tutorials." + key + ".points." + i + ".commands", commands);
if(flying) tutorialSaves.set("tutorials." + key + ".points." + i + ".setFly", flying);

Expand Down Expand Up @@ -352,12 +375,20 @@ public void setLoc(Location loc) {
this.loc = loc;
}

public String getMessage_actionBar() {
return message_actionBar;
public String getMessageActionbar() {
return messageActionbar;
}

public void setMessageActionbar(String message_actionBar) {
this.messageActionbar = message_actionBar;
}

public void setActionbarShowAfter(double actionbarShowAfter) {
this.actionbarShowAfter = actionbarShowAfter;
}

public void setMessage_actionBar(String message_actionBar) {
this.message_actionBar = message_actionBar;
public void setActionbarHideAfter(double actionbarHideAfter) {
this.actionbarHideAfter = actionbarHideAfter;
}

public PlayerTitle getTitleInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ public void run() {
}

if (repeatActionbar) {
if (message_actionBar != null) {
if (messageActionbar != null) {
//NeedsReflection.sendActionBar(player, PluginUtils.replaceVariables(plugin.placeholderAPI, player, message_actionBar));
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(PluginUtils.replaceVariables(plugin.placeholderAPI, player, message_actionBar)));
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(PluginUtils.replaceVariables(plugin.placeholderAPI, player, messageActionbar)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,45 @@ public ActionbarArg() {
@Override
public boolean run(ServerTutorial serverTutorial, ServerTutorialPoint point, CommandSender sender, String[] args) {
if(args.length < 1){
sender.sendMessage(Lang.WRONG_COMMAND_FORMAT + "/st editpoint <t> <p> actionbar <clear/set>");
sender.sendMessage(Lang.WRONG_COMMAND_FORMAT + "/st editpoint <t> <p> actionbar <clear/message/show-after/hide-after> <args>");
return false;
}

switch (args[0]) {
case "clear":
point.setMessage_actionBar(null);
point.setMessageActionbar(null);
break;
case "set":
case "message":
if (args.length < 2) {
sender.sendMessage(Lang.ERROR_ATLEAST_ONE_WORD.toString());
return false;
}

String message = StringUtils.join(args, ' ', 1, args.length);
point.setMessage_actionBar(message);
point.setMessageActionbar(message);
break;
case "show-after":
double showAfter;
try {
showAfter = Double.parseDouble(args[1]);
} catch (NumberFormatException e) {
sender.sendMessage(Lang.ERROR_INVALID_NUMBNER.toString());
return false;
}
point.setActionbarShowAfter(showAfter);
break;
case "hide-after":
double hideAfter;
try {
hideAfter = Double.parseDouble(args[1]);
} catch (NumberFormatException e) {
sender.sendMessage(Lang.ERROR_INVALID_NUMBNER.toString());
return false;
}
point.setActionbarHideAfter(hideAfter);
break;

default:
sender.sendMessage(Lang.WRONG_COMMAND_FORMAT + "/st editpoint <t> <p> actionbar <clear/set>");
sender.sendMessage(Lang.WRONG_COMMAND_FORMAT + "/st editpoint <t> <p> actionbar <clear/set/show-after/hide-after>");
return false;
}
return true;
Expand Down