mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Documented and made changes to Contributor
This commit is contained in:
parent
a93a5e88d6
commit
d2b4d58e35
@ -1,11 +1,16 @@
|
||||
package me.mrCookieSlime.Slimefun.GitHub;
|
||||
|
||||
/**
|
||||
* Represents a contributor on Slimefun4's GitHub repository.
|
||||
*
|
||||
* @since 4.1.6
|
||||
*/
|
||||
public class Contributor {
|
||||
|
||||
public String name;
|
||||
public String job;
|
||||
public String profile;
|
||||
public int commits;
|
||||
private String name;
|
||||
private String job;
|
||||
private String profile;
|
||||
private int commits;
|
||||
|
||||
public Contributor(String name, String job, int commits) {
|
||||
this.name = name;
|
||||
@ -13,4 +18,47 @@ public class Contributor {
|
||||
this.commits = commits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this contributor.
|
||||
*
|
||||
* @return the name of this contributor
|
||||
* @since 4.2.0
|
||||
*/
|
||||
public String getName() { return this.name; }
|
||||
|
||||
/**
|
||||
* Returns the job of this contributor.
|
||||
* It can be {@code Author} or {@code Head Artist}.
|
||||
*
|
||||
* @return the job of this contributor
|
||||
* @since 4.2.0
|
||||
*/
|
||||
public String getJob() { return this.job; }
|
||||
|
||||
/**
|
||||
* Returns the link to the GitHub profile of this contributor.
|
||||
*
|
||||
* @return the GitHub profile of this contributor.
|
||||
* @since 4.2.0
|
||||
*/
|
||||
public String getProfile() { return this.profile; }
|
||||
|
||||
/**
|
||||
* Returns the number of commits to the Slimefun4's repository of this contributor.
|
||||
*
|
||||
* @return the number of commits of this contributor.
|
||||
* @since 4.2.0
|
||||
*/
|
||||
public int getCommits() { return this.commits; }
|
||||
|
||||
/**
|
||||
* Sets the link to the GitHub profile of this contributor.
|
||||
*
|
||||
* @param profile the link to the GitHub profile of this contributor
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
protected void setProfile(String profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class GitHubSetup {
|
||||
|
||||
if (!name.equals("invalid-email-address")) {
|
||||
Contributor contributor = new Contributor(name, job, commits);
|
||||
contributor.profile = profile;
|
||||
contributor.setProfile(profile);
|
||||
SlimefunGuide.contributors.add(contributor);
|
||||
}
|
||||
}
|
||||
|
@ -274,24 +274,24 @@ public class SlimefunGuide {
|
||||
double total = 0;
|
||||
|
||||
for (Contributor contributor: contributors) {
|
||||
total += contributor.commits;
|
||||
total += contributor.getCommits();
|
||||
}
|
||||
|
||||
for (final Contributor contributor: contributors) {
|
||||
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
|
||||
|
||||
ItemMeta meta = skull.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&a" + contributor.name));
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&a" + contributor.getName()));
|
||||
|
||||
if (contributor.commits > 0) {
|
||||
double percentage = DoubleHandler.fixDouble((contributor.commits * 100.0) / total, 2);
|
||||
if (contributor.getCommits() > 0) {
|
||||
double percentage = DoubleHandler.fixDouble((contributor.getCommits() * 100.0) / total, 2);
|
||||
|
||||
meta.setLore(Arrays.asList("", ChatColor.translateAlternateColorCodes('&', "&7Role: &r" + contributor.job), ChatColor.translateAlternateColorCodes('&', "&7Contribution: &r" + percentage + "%"), "", ChatColor.translateAlternateColorCodes('&', "&7\u21E8 Click to view my GitHub profile")));
|
||||
meta.setLore(Arrays.asList("", ChatColor.translateAlternateColorCodes('&', "&7Role: &r" + contributor.getJob()), ChatColor.translateAlternateColorCodes('&', "&7Contribution: &r" + percentage + "%"), "", ChatColor.translateAlternateColorCodes('&', "&7\u21E8 Click to view my GitHub profile")));
|
||||
}
|
||||
else {
|
||||
meta.setLore(Arrays.asList("", ChatColor.translateAlternateColorCodes('&', "&7Role: &r" + contributor.job)));
|
||||
meta.setLore(Arrays.asList("", ChatColor.translateAlternateColorCodes('&', "&7Role: &r" + contributor.getJob())));
|
||||
}
|
||||
|
||||
|
||||
skull.setItemMeta(meta);
|
||||
|
||||
menu.addItem(index, skull);
|
||||
@ -299,10 +299,10 @@ public class SlimefunGuide {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Player p, int arg1, ItemStack arg2, ClickAction arg3) {
|
||||
if (contributor.commits > 0) {
|
||||
if (contributor.getCommits() > 0) {
|
||||
p.closeInventory();
|
||||
p.sendMessage("");
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + contributor.profile));
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o" + contributor.getProfile()));
|
||||
p.sendMessage("");
|
||||
}
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user