-
-
Save lyokofirelyte/df66df7a2e249fc32c43 to your computer and use it in GitHub Desktop.
Cleanup Example for Core
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.goldblockstudios.MasterDoctor.MDCore; | |
import java.io.File; | |
import org.bukkit.Bukkit; | |
import org.bukkit.ChatColor; | |
import org.bukkit.command.Command; | |
import org.bukkit.command.CommandSender; | |
import org.bukkit.entity.Player; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.player.PlayerJoinEvent; | |
import org.bukkit.plugin.Plugin; | |
import org.bukkit.plugin.PluginDescriptionFile; | |
import org.bukkit.plugin.java.JavaPlugin; | |
public class Core extends JavaPlugin implements Listener { | |
private String AS(String msg){ | |
return ChatColor.translateAlternateColorCodes('&', msg); | |
} | |
@EventHandler | |
public void onJoin(PlayerJoinEvent e){ | |
PlayerJoinEvents.playerJoin(e.getPlayer()); // such static | |
} | |
@Override | |
public void onEnable() { | |
getLogger().log(Level.INFO, "The plugin has been enabled! Setting up..."); | |
getServer().getPluginManager().registerEvents(this, this); | |
try { | |
File userfiles = new File("./plugins/MDCore/players/"); | |
File MDStore = new File("./MDStore/Configs"); | |
boolean success = !userFiles.exists() ? userFiles.mkdirs() : true; | |
success = !MDStore.exists() ? MDStore.mkdirs() && success : success; | |
} catch(SecurityException exception) { // honestly e.printStackTrace() should do it, but... | |
for (String e : new String[] { | |
"------------------------[ERROR REPORT START]---------------------", | |
"ERROR: MDCore was unable to create the necessary data structure!", | |
"MORE INFO: The player configs data structure is required for this", | |
"plugin to run correctly - to avoid problems this plugin will be (disabled?)", | |
"Please contact the author with code: ERR01 - For more", | |
"information, please search for: &6SecurityException Bukkit", | |
"More information may be avaliable in the log file.", | |
"--------------------------[ERROR REPORT END]---------------------" | |
}){ | |
getLogger().log(Level.SEVERE, AS("&c" + e)); | |
} | |
Bukkit.getPluginManager().disablePlugin(this); | |
} | |
} | |
} | |
@Override | |
public void onDisable() {} // the plugin already prints that it is disabling automatically. | |
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | |
if(cmd.getName().equalsIgnoreCase("mdcore")){ | |
sender.sendMessage(AS("&c[MDCore] &6MasterDoctor's Core - Version " + getDescription().getVersion() + " Copyright © MMXIV - By MasterDoctor")); | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks so much dude! 👍