Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backwards compatibility #15

Open
github-actions bot opened this issue May 19, 2020 · 0 comments
Open

Add backwards compatibility #15

github-actions bot opened this issue May 19, 2020 · 0 comments
Labels

Comments

@github-actions
Copy link

Add backwards compatibility

// Remain.setPlugin(plugin); // TODO Add backwards compatibility

import co.aikar.commands.BukkitCommandManager;
import de.leonhard.storage.Yaml;
import de.leonhard.storage.sections.FlatFileSection;
import lombok.Getter;
import lombok.SneakyThrows;
import me.magnum.breedablepets.Command;
import me.magnum.breedablepets.listeners.BreedListener;
import me.magnum.breedablepets.listeners.EggListener;
import me.magnum.breedablepets.util.Common;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.plugin.java.JavaPlugin;

public class Breedable extends JavaPlugin {

	@Getter
	private static Breedable plugin;
	//	@Getter
//	private SimpleConfig cfg;
	@Getter
	private Yaml cfg;

	@Override
	public void onEnable () {
		plugin = this;
		setupConfig();
//		Remain.setPlugin(plugin);  // TODO Add backwards compatibility
		plugin.getServer().getPluginManager().registerEvents(new EggListener(), this);
		plugin.getServer().getPluginManager().registerEvents(new BreedListener(), this);
		registerCommands();
	}

	private void setupConfig () {
		cfg = new Yaml("settings.yml", getDataFolder().toString(), getResource("settings.yml"));
		String[] header = {"Config file for BreedablePets",
				"by Magnum1997",
				"This should be self-explanatory. I tried to comment settings.",
				"For problems, questions, or feedback please visit",
				"https://github.com/Magnum97/BreedablePetsMC/issues"};
		cfg.framedHeader(header);
		// Set defaults
		cfg.setDefault("parrots.hatch-chance", 10);
		cfg.setDefault("parrot.egg-chance", 25);
		cfg.setDefault("paired-egg-chance", 20);
		cfg.setDefault("fertile-egg-chance", 30);
		cfg.setDefault("hatch-chance", 10);
		cfg.setDefault("rare-chance", 1);
		FlatFileSection modifiers = cfg.getSection("modifiers");
		modifiers.setDefault("wheat", 10);
		modifiers.setDefault("beetroot", 20);
		modifiers.setDefault("pumpkin", 30);
		modifiers.setDefault("melon", 30);
		modifiers.setDefault("glistering-melon", 100);
	}

	@SuppressWarnings ("deprecation")
	private void registerCommands () {
		BukkitCommandManager commandManager = new BukkitCommandManager(plugin);
		commandManager.registerCommand(new Command());
		commandManager.enableUnstableAPI("help");
	}


	@Override
	public void onDisable () {
		Common.log("Disabling Breed-able pets.");
		// Remain.setPlugin(null);
		//		cfg.saveConfig();
		cfg = null;
		plugin = null;
	}
ndex 50464a9..9897f1b 100644
++ b/src/main/java/me/magnum/breedablepets/listeners/EggListener.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants