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 #16

Closed
github-actions bot opened this issue Jun 6, 2020 · 1 comment
Closed

Add backwards compatibility #16

github-actions bot opened this issue Jun 6, 2020 · 1 comment
Labels

Comments

@github-actions
Copy link

github-actions bot commented Jun 6, 2020

Add backwards compatibility

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

 *
 */
package me.magnum;

import co.aikar.commands.BukkitCommandManager;
import de.leonhard.storage.Yaml;
import de.leonhard.storage.sections.FlatFileSection;
import lombok.Getter;
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;
	}

	public void spawnMob (World world, Location location, EntityType mobType) {
		world.spawnEntity(location, mobType);
	}
ndex 437bd41..c5e3c8d 100644
++ b/src/main/java/me/magnum/breedablepets/Command.java

82ee36010b830dfd97cf220ba2532cc64db96808

@github-actions github-actions bot added the todo label Jun 6, 2020
@Magnum97
Copy link
Owner

Duplicate of #15

@Magnum97 Magnum97 marked this as a duplicate of #15 Jun 17, 2020
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

1 participant