Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Commit

Permalink
Added placeholders
Browse files Browse the repository at this point in the history
- Added %p (Gets the skull's owner)
- Added %m (Gets the player who's interacting with the skull's IGN)
  • Loading branch information
Thatsmusic99 committed Mar 9, 2017
1 parent fc19712 commit b2bfd07
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ private static void loadMessages() {
getMessages().options().header("HeadsPlus by Thatsmusic99");
getMessages().addDefault("prefix", "&1[&6HeadsPlus&1]");
getMessages().addDefault("reloadMessage", "&3Config has reloaded!");
getMessages().addDefault("head-interact-message", "&3That is &b%p&3''s head!");
getMessages().options().copyDefaults(true);
saveMessages();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.bukkit.event.player.PlayerInteractEvent;

import io.github.thatsmusic99.headsplus.HeadsPlus;
import io.github.thatsmusic99.headsplus.HeadsPlusConfig;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -31,25 +32,35 @@ public void interact(PlayerInteractEvent event) {
Skull skull = (Skull) block;
@SuppressWarnings("deprecation")
String owner = skull.getOwner();
String playerName = player.toString();
if (TimesSent < 1) {
Pattern mhf = Pattern.compile("MHF_");
Matcher match = mhf.matcher(owner);
if (match.find() && !(match.matches())) {
String newMatch = owner.replace("MHF_", "");
String iMessage1 = ChatColor.translateAlternateColorCodes('&', HeadsPlus.getInstance().getConfig().getString("head-mhf-interact-message"));
String iMessage1 = ChatColor.translateAlternateColorCodes('&', HeadsPlusConfig.getMessages().getString("head-mhf-interact-message"));
String iMessage2 = iMessage1.replaceAll("%p", newMatch);
player.sendMessage(iMessage2);
String iMessage3 = iMessage2.replaceAll("''", "'");
String iMessage4 = iMessage3.replaceAll("^'", "");
String iMessage5 = iMessage4.replaceAll("'$", "");
String iMessage6 = iMessage5.replaceAll("%m", playerName);
player.sendMessage(iMessage6);
TimesSent++;
} else {
String iMessage1 = ChatColor.translateAlternateColorCodes('&', HeadsPlus.getInstance().getConfig().getString("head-interact-message"));
String iMessage2 = iMessage1.replaceAll("%p", owner);
player.sendMessage(iMessage2);
String iMessage3 = iMessage2.replaceAll("''", "'");
String iMessage4 = iMessage3.replaceAll("^'", "");
String iMessage5 = iMessage4.replaceAll("'$", "");
String iMessage6 = iMessage5.replaceAll("%m", playerName);
player.sendMessage(iMessage6);
TimesSent++;
}
} else {
TimesSent --;
}
}
}
}
}

}

0 comments on commit b2bfd07

Please sign in to comment.