Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
Arasple committed Jan 31, 2020
1 parent 75db425 commit 91beb09
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 74 deletions.
11 changes: 5 additions & 6 deletions src/main/java/me/arasple/mc/trhologram/TrHologramLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@
*/
public class TrHologramLoader {

static void unload() {
HologramManager.write();
TLocale.sendToConsole("PLUGIN.DISABLED");
}

void init() {
TLocale.sendToConsole("PLUGIN.LOADING");
updateConfig();
Updater.init(TrHologram.getPlugin());
}


void load() {
TLocale.sendToConsole("PLUGIN.ENABLED", TrHologram.getPlugin().getDescription().getVersion());
}

static void unload() {
HologramManager.write();
TLocale.sendToConsole("PLUGIN.DISABLED");
}

private void updateConfig() {
TConfig oldCfg = TrHologram.getSettings();
YamlConfiguration newCfg = YamlConfiguration.loadConfiguration(new InputStreamReader(TrHologram.getPlugin().getResource("settings.yml")));
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/me/arasple/mc/trhologram/TrHologramPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -423,14 +423,14 @@ public static TrHologramPlugin getPlugin() {
return plugin;
}

public File getPluginFile() {
return getFile();
}

public static File getLibFile() {
return libFile;
}

public File getPluginFile() {
return getFile();
}

@Override
public final void onLoad() {
if (initFailed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ public HologramInteractEvent(Player who, Hologram hologram) {
this.hologram = hologram;
}

public void call() {
Bukkit.getPluginManager().callEvent(this);
}

public static HandlerList getHandlerList() {
return HANDLERS;
}

public void call() {
Bukkit.getPluginManager().callEvent(this);
}

public Hologram getHologram() {
return hologram;
}
Expand Down
64 changes: 32 additions & 32 deletions src/main/java/me/arasple/mc/trhologram/hologram/Hologram.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ public List<UUID> getViewers() {
return viewers;
}

public void setViewers(List<UUID> viewers) {
this.viewers = viewers;
}

private List<Player> getViewersAsPlayer() {
List<Player> players = Lists.newArrayList();
viewers.forEach(viewer -> {
Expand All @@ -155,10 +159,6 @@ private List<Player> getViewersAsPlayer() {
return players;
}

public void setViewers(List<UUID> viewers) {
this.viewers = viewers;
}

public Location getLocation() {
return location;
}
Expand All @@ -177,6 +177,30 @@ public List<HologramContent> getContents() {
return contents;
}

public void setContents(List<String> contents) {
while (contents.size() < getContents().size()) {
HologramContent hologramContent = getContents().get(getContents().size() - 1);
getViewersAsPlayer().forEach(hologramContent::destroy);
getContents().remove(getContents().size() - 1);
}
int size = getContents().size();
for (int i = 0; i < contents.size(); i++) {
if (size > i) {
getContents().get(i).setText(contents.get(i));
} else {
HologramContent content = new HologramContent(contents.get(i));
getContents().add(content);
}
}
initOffsets();
getContents().forEach(content -> {
if (!content.isArmorstandInited()) {
content.initArmorstand();
getViewersAsPlayer().forEach(content::display);
}
});
}

public String getViewCondition() {
return viewCondition;
}
Expand All @@ -189,14 +213,14 @@ public String getViewDistance() {
return viewDistance;
}

public Object getExactViewDistance() {
return NumberUtils.isParsable(getViewDistance()) ? NumberUtils.toDouble(getViewDistance(), -1) : getViewDistance();
}

public void setViewDistance(String viewDistance) {
this.viewDistance = viewDistance;
}

public Object getExactViewDistance() {
return NumberUtils.isParsable(getViewDistance()) ? NumberUtils.toDouble(getViewDistance(), -1) : getViewDistance();
}

public double getFinalViewDistance() {
return finalViewDistance;
}
Expand All @@ -223,28 +247,4 @@ public List<String> getContentsAsList() {
return contents;
}

public void setContents(List<String> contents) {
while (contents.size() < getContents().size()) {
HologramContent hologramContent = getContents().get(getContents().size() - 1);
getViewersAsPlayer().forEach(hologramContent::destroy);
getContents().remove(getContents().size() - 1);
}
int size = getContents().size();
for (int i = 0; i < contents.size(); i++) {
if (size > i) {
getContents().get(i).setText(contents.get(i));
} else {
HologramContent content = new HologramContent(contents.get(i));
getContents().add(content);
}
}
initOffsets();
getContents().forEach(content -> {
if (!content.isArmorstandInited()) {
content.initArmorstand();
getViewersAsPlayer().forEach(content::display);
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ public HologramContent(String text) {
this.text = text;
}

public static List<HologramContent> createList(List<String> lines) {
List<HologramContent> holoLines = Lists.newArrayList();
lines.forEach(l -> holoLines.add(new HologramContent(l)));
return holoLines;
}

public void updateLocation(Player... players) {
HoloPackets.getInst().teleportArmorstand(getArmorstand(), location, players);
}


public void update(Player... players) {
for (Player player : players) {
HoloPackets.getInst().setArmorstandName(getArmorstand(), Vars.replace(player, text));
Expand Down Expand Up @@ -61,12 +66,6 @@ public void initArmorstand() {
setId(HoloPackets.getInst().getEntityId(getArmorstand()));
}

public static List<HologramContent> createList(List<String> lines) {
List<HologramContent> holoLines = Lists.newArrayList();
lines.forEach(l -> holoLines.add(new HologramContent(l)));
return holoLines;
}

/*
GETTERS & SETTERS
*/
Expand All @@ -75,6 +74,10 @@ public Location getLocation() {
return location;
}

public void setLocation(Location location) {
this.location = location;
}

public void setLocation(Location location, List<Player> players) {
this.location = location;

Expand All @@ -83,10 +86,6 @@ public void setLocation(Location location, List<Player> players) {
}
}

public void setLocation(Location location) {
this.location = location;
}

public String getText() {
return text;
}
Expand All @@ -102,14 +101,14 @@ public Object getArmorstand() {
return armorstand;
}

public boolean isArmorstandInited() {
return armorstand != null;
}

public void setArmorstand(Object armorstand) {
this.armorstand = armorstand;
}

public boolean isArmorstandInited() {
return armorstand != null;
}

public int getId() {
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class HologramManager {
@TInject("holograms.yml")
private static TConfig hologramsData;
private static List<Hologram> holograms = Lists.newArrayList();
private static boolean writing;

@TSchedule
static void setup() {
Expand Down Expand Up @@ -134,6 +135,4 @@ public static void write() {
writing = false;
}

private static boolean writing;

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void onMove(PlayerMoveEvent e) {
HologramManager.getHolograms().stream().forEach(hologram -> {
if (hologram.isVisible(player)) {
hologram.display(player);
}else {
} else {
hologram.destroy(player);
}
});
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/me/arasple/mc/trhologram/updater/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,6 @@ private static void grabInfo() {
}
}

@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();

if (old && !noticed.contains(p.getUniqueId()) && p.hasPermission("trmenu.admin")) {
noticed.add(p.getUniqueId());
Bukkit.getScheduler().runTaskLaterAsynchronously(TrHologram.getPlugin(), () -> TLocale.sendTo(p, "PLUGIN.UPDATER.OLD", newVersion), 1);
}
}

public static boolean isOld() {
return old;
}
Expand All @@ -109,4 +99,14 @@ public static double getVersion() {
return version;
}

@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();

if (old && !noticed.contains(p.getUniqueId()) && p.hasPermission("trmenu.admin")) {
noticed.add(p.getUniqueId());
Bukkit.getScheduler().runTaskLaterAsynchronously(TrHologram.getPlugin(), () -> TLocale.sendTo(p, "PLUGIN.UPDATER.OLD", newVersion), 1);
}
}

}

0 comments on commit 91beb09

Please sign in to comment.