Skip to content

Commit

Permalink
2.7.0 - bstats
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranhart committed Dec 26, 2021
1 parent b18e0e6 commit 579e0b0
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 17 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -7,7 +7,7 @@
<artifactId>skulls</artifactId>

<name>Skulls</name>
<version>2.6.0</version>
<version>2.7.0</version>
<packaging>jar</packaging>

<properties>
Expand Down Expand Up @@ -75,7 +75,7 @@
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<include>${tweety.path}:tweety*</include>
<include>${tweety.path}:Tweety*</include>
</includes>
</artifactSet>
<filters>
Expand Down
53 changes: 40 additions & 13 deletions src/main/java/ca/tweetzy/skulls/Skulls.java
Expand Up @@ -3,7 +3,6 @@
import ca.tweetzy.skulls.api.DataFile;
import ca.tweetzy.skulls.api.SkullsAPI;
import ca.tweetzy.skulls.api.enums.SkullsDefaultCategory;
import ca.tweetzy.skulls.commands.SkullsCommandGroup;
import ca.tweetzy.skulls.impl.SkullCategory;
import ca.tweetzy.skulls.impl.SkullPlayer;
import ca.tweetzy.skulls.listeners.PlayerJoinLeaveListener;
Expand All @@ -15,12 +14,15 @@
import ca.tweetzy.tweety.Messenger;
import ca.tweetzy.tweety.MinecraftVersion;
import ca.tweetzy.tweety.collection.StrictList;
import ca.tweetzy.tweety.command.SimpleCommandGroup;
import ca.tweetzy.tweety.model.SpigotUpdater;
import ca.tweetzy.tweety.plugin.SimplePlugin;
import ca.tweetzy.tweety.remain.Remain;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;

import java.io.File;
import java.io.IOException;

/**
* The current file has been created by Kiran Hart
Expand All @@ -37,26 +39,38 @@ public final class Skulls extends SimplePlugin {
private final SkullCategoryManager skullCategoryManager = new SkullCategoryManager();
private final SkullPlayerManager skullPlayerManager = new SkullPlayerManager();

@Getter
private boolean bStats = false;

@Override
protected void onPluginStart() {
Common.ADD_TELL_PREFIX = true;
Common.ADD_LOG_PREFIX = true;
Common.setLogPrefix(Settings.PREFIX + " ");
Common.setTellPrefix(Settings.PREFIX);
Messenger.setInfoPrefix(Settings.PREFIX + " ");
Messenger.setAnnouncePrefix(Settings.PREFIX + " ");
Messenger.setErrorPrefix(Settings.PREFIX + " ");
Messenger.setQuestionPrefix(Settings.PREFIX + " ");
Messenger.setSuccessPrefix(Settings.PREFIX + " ");
Messenger.setWarnPrefix(Settings.PREFIX + " ");
normalizePrefix();

if (Settings.AUTO_STATS) {
final File file = new File("plugins" + File.separator + "bStats" + File.separator + "config.yml");
if (!file.exists()) bStats = true;
else {
final YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file);
configuration.set("enabled", true);
try {
configuration.save(file);
bStats = true;
} catch (IOException e) {
e.printStackTrace();
}
}
}

if (!bStats) {
Common.logFramed("&cPlease enable bStats within your plugins folder", "&cit helps me collect data on Skulls.");
}

Common.runAsync(() -> {
for (SkullsDefaultCategory value : SkullsDefaultCategory.values()) {
SkullsAPI.addCategory(new SkullCategory(value.getId(), value.getName(), false, null));
}

this.skullCategoryManager.loadCustomCategories();

skullManager.downloadHeads(false);
});

Expand Down Expand Up @@ -84,6 +98,19 @@ protected void onPluginStop() {
}


private void normalizePrefix() {
Common.ADD_TELL_PREFIX = true;
Common.ADD_LOG_PREFIX = true;
Common.setLogPrefix(Settings.PREFIX + " ");
Common.setTellPrefix(Settings.PREFIX);
Messenger.setInfoPrefix(Settings.PREFIX + " ");
Messenger.setAnnouncePrefix(Settings.PREFIX + " ");
Messenger.setErrorPrefix(Settings.PREFIX + " ");
Messenger.setQuestionPrefix(Settings.PREFIX + " ");
Messenger.setSuccessPrefix(Settings.PREFIX + " ");
Messenger.setWarnPrefix(Settings.PREFIX + " ");
}

@Override
public int getMetricsPluginId() {
return 10616;
Expand Down
Expand Up @@ -3,6 +3,7 @@
import ca.tweetzy.skulls.Skulls;
import ca.tweetzy.skulls.api.SkullsAPI;
import ca.tweetzy.skulls.impl.SkullPlayer;
import ca.tweetzy.skulls.settings.Settings;
import ca.tweetzy.tweety.Common;
import ca.tweetzy.tweety.collection.StrictList;
import org.bukkit.entity.Player;
Expand All @@ -22,8 +23,12 @@ public final class PlayerJoinLeaveListener implements Listener {
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent event) {
final Player player = event.getPlayer();
if (player.isOp()) {
Common.tell(player, "&aIf you need support visit https://discord.gg/WTg4PhBHEg");
if (player.isOp() && Settings.TELL_DISCORD_SERVER) {
Common.tell(player, "&aIf you need support visit https://discord.tweetzy.ca");
}

if (player.isOp() && !Skulls.getInstance().isBStats()) {
Common.tell(player, "&cPlease enable &4bStats&c as it allows be to collect stats on Skulls <3");
}

Common.runAsync(() -> {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/ca/tweetzy/skulls/settings/Settings.java
Expand Up @@ -20,6 +20,8 @@ public final class Settings extends SimpleSettings {
public static Boolean ALLOW_NON_PERM_USE;
public static Boolean SHOW_CUSTOM_CATEGORIES;
public static Boolean SHOW_FAVOURITES;
public static Boolean AUTO_STATS;
public static Boolean TELL_DISCORD_SERVER;

private static void init() {
PREFIX = getString("Prefix");
Expand All @@ -29,6 +31,8 @@ private static void init() {
ALLOW_NON_PERM_USE = getBoolean("Allow Non Permission Access");
SHOW_CUSTOM_CATEGORIES = getBoolean("Show Custom Categories");
SHOW_FAVOURITES = getBoolean("Show Favourites");
AUTO_STATS = getBoolean("Auto bStats");
TELL_DISCORD_SERVER = getBoolean("Tell Discord Server");
}

public static final class ListingMenu {
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/settings.yml
Expand Up @@ -7,6 +7,12 @@ Allow Non Permission Access: true
Show Custom Categories: true
Show Favourites: true

# if true, you'll get a link to join the Tweetzy discord on join
# this will only be shown to ops
Tell Discord Server: true

Auto bStats: true

Gui:
Category List:
Title: "&eSkulls &f- &7Custom Categories"
Expand Down

0 comments on commit 579e0b0

Please sign in to comment.