Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void onEnable() {
- String msg = "Golden Games";
- Runnable runnable = new Runnable() {
- /*
- * Start (WARMUP)
- * ONCE
- */
- long defWaitTime1 = 20,
- waitTime1 = defWaitTime1;
- /*
- * Refresh
- * ONLY ON END
- */
- long defWaitTime2 = 20*3,
- waitTime2 = defWaitTime2,
- showTime = 0,
- shutdownTime = 15;
- /*
- * Between
- * ONLY BETWEEN CHANGES
- */
- long defWaitTime3 = 20 * (3/4),
- waitTime3 = defWaitTime3;
- int index = 0;
- String latest = msg,
- refresh;
- @Override
- public void run() {
- if (waitTime1 == 0) {
- if (waitTime2 == 0) {
- refresh = null;
- if (waitTime3 == 0) {
- latest = next(msg, index);
- index++;
- if (index > msg.length()) {
- waitTime2 = defWaitTime2;
- index = 0;
- }
- else {
- waitTime3 = defWaitTime3;
- }
- }
- else {
- waitTime3--;
- }
- }
- else {
- long mod = waitTime2 % 20;
- if (mod == showTime) {
- refresh = latest;
- }
- else if (mod == shutdownTime) {
- refresh = msg;
- }
- waitTime2--;
- }
- }
- else {
- waitTime1--;
- }
- String title = refresh == null ? latest : refresh;
- }
- };
- Bukkit.getScheduler().scheduleSyncRepeatingTask(this, runnable, 0, 1);
- }
- public String next(String str, int index) {
- return next(str, index, ChatColor.YELLOW, ChatColor.GOLD, String.valueOf(ChatColor.BOLD));
- }
- public String next(String str, int index, ChatColor firstColor, ChatColor secondColor, String constant) {
- String newString = "";
- boolean first = true;
- for (int i = 0; i < str.length(); i++) {
- char ch = str.charAt(i);
- if (i == index) {
- newString +=
- firstColor;
- newString += constant;
- }
- else if (i == 0) {
- newString += secondColor;
- newString += constant;
- }
- else if (i > index){
- if (first) {
- newString += ChatColor.RESET;
- newString += constant;
- first = false;
- }
- }
- newString += ch;
- }
- return newString;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement