1
0
mirror of https://e.coding.net/circlecloud/ResExtras.git synced 2024-12-27 16:18:48 +00:00

添加默认配置文件 添加版本检查...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-12-14 23:29:24 +08:00
parent dac9c78e34
commit 27b7b9ff36
2 changed files with 87 additions and 312 deletions

View File

@ -1,16 +1,8 @@
package cn.citycraft.ResExtras;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@ -18,6 +10,8 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.bekvon.bukkit.residence.protection.FlagPermissions;
import cn.citycraft.PluginHelper.config.FileConfig;
import cn.citycraft.PluginHelper.utils.VersionChecker;
import cn.citycraft.ResExtras.flags.animalkilling;
import cn.citycraft.ResExtras.flags.bat;
import cn.citycraft.ResExtras.flags.blaze;
@ -74,326 +68,45 @@ import cn.citycraft.ResExtras.flags.zombie;
import cn.citycraft.ResExtras.flags.zombiepigmen;
public class ResExtras extends JavaPlugin implements CommandExecutor {
public static final String PLUGIN_NAME = "ResExtras";
public static final String LOG_HEADER = "[" + PLUGIN_NAME + "] ";
private Logger log;
public Configuration config;
// very long config
// Going to make this shorter but I'm too lazy
// To be honest I just made it like that way since it was in my other plugin so I just copy and pasta'd I'm really lazy :3
// and I like making little stories in my code...I'm insane o.o
/*
* I love ramen since its like the only thing I actually know how to make. I used to make
* pancakes but I forgot how to make them which kinda pisses me off. Oh by the way I'm
* only 17 :P. Its nice to know that someone has to read this (I think) since one of my friends
* is on the DevBukkit team so its nice to meet you :D. You can even message me on Bukkit(Tonkovich)
* just so I know you read this. Well thats all I really know what to type since I kinda just typed
* random stuff. I have a pokeball :3
*
* Dafuq did you just read o.O
*/
public void loadDefaults() {
final FileConfiguration configG = getConfig();
final File configFile = new File("plugins/ResExtras/config.yml");
config = YamlConfiguration.loadConfiguration(configFile);
configG.options().header("This completely disables parts of ResExtras increasing efficiency.");
if (config.contains("Zombie")) {
} else {
getConfig().addDefault("Zombie", true);
}
if (config.contains("Skeleton")) {
} else {
getConfig().addDefault("Skeleton", true);
}
if (config.contains("Spider")) {
} else {
getConfig().addDefault("Spider", true);
}
if (config.contains("Creeperspawn")) {
} else {
getConfig().addDefault("Creeperspawn", true);
}
if (config.contains("Blaze")) {
} else {
getConfig().addDefault("Blaze", true);
}
if (config.contains("Cavespider")) {
} else {
getConfig().addDefault("Cavespider", true);
}
if (config.contains("Ghast")) {
} else {
getConfig().addDefault("Ghast", true);
}
if (config.contains("Slime")) {
} else {
getConfig().addDefault("Slime", true);
}
if (config.contains("Magmacube")) {
} else {
getConfig().addDefault("Magmacube", true);
}
if (config.contains("Silverfish")) {
} else {
getConfig().addDefault("Silverfish", true);
}
if (config.contains("Snowgolem")) {
} else {
getConfig().addDefault("Snowgolem", true);
}
if (config.contains("Irongolem")) {
} else {
getConfig().addDefault("Irongolem", true);
}
if (config.contains("Enderman")) {
} else {
getConfig().addDefault("Enderman", true);
}
if (config.contains("Zombiepigmen")) {
} else {
getConfig().addDefault("Zombiepigmen", true);
}
if (config.contains("Chicken")) {
} else {
getConfig().addDefault("Chicken", true);
}
if (config.contains("Cow")) {
} else {
getConfig().addDefault("Cow", true);
}
if (config.contains("Mooshroom")) {
} else {
getConfig().addDefault("Mooshroom", true);
}
if (config.contains("Ocelot")) {
} else {
getConfig().addDefault("Ocelot", true);
}
if (config.contains("Pig")) {
} else {
getConfig().addDefault("Pig", true);
}
if (config.contains("Sheep")) {
} else {
getConfig().addDefault("Sheep", true);
}
if (config.contains("Squid")) {
} else {
getConfig().addDefault("Squid", true);
}
if (config.contains("Villager")) {
} else {
getConfig().addDefault("Villager", true);
}
if (config.contains("Wolf")) {
} else {
getConfig().addDefault("Wolf", true);
}
if (config.contains("Bat")) {
} else {
getConfig().addDefault("Bat", true);
}
if (config.contains("Witherspawn")) {
} else {
getConfig().addDefault("Witherspawn", true);
}
if (config.contains("Witch")) {
} else {
getConfig().addDefault("Witch", true);
}
if (config.contains("Form")) {
} else {
getConfig().addDefault("Form", true);
}
if (config.contains("Melt")) {
} else {
getConfig().addDefault("Melt", true);
}
if (config.contains("Commands")) {
} else {
getConfig().addDefault("Commands", true);
}
if (config.contains("Falldamage")) {
} else {
getConfig().addDefault("Falldamage", true);
}
if (config.contains("Portal")) {
} else {
getConfig().addDefault("Portal", true);
}
if (config.contains("Enderpearl")) {
} else {
getConfig().addDefault("Enderpearl", true);
}
if (config.contains("Mobkilling")) {
} else {
getConfig().addDefault("Mobkilling", true);
}
if (config.contains("Animalkilling")) {
} else {
getConfig().addDefault("Animalkilling", true);
}
if (config.contains("Villagerkilling")) {
} else {
getConfig().addDefault("Villagerkilling", true);
}
if (config.contains("Drops")) {
} else {
getConfig().addDefault("Drops", true);
}
if (config.contains("Pickup")) {
} else {
getConfig().addDefault("Pickup", true);
}
if (config.contains("Vehicleprotect")) {
} else {
getConfig().addDefault("Vehicleprotect", true);
}
if (config.contains("Lightning")) {
} else {
getConfig().addDefault("Lightning", true);
}
if (config.contains("Grow")) {
} else {
getConfig().addDefault("Grow", true);
}
if (config.contains("Hunger")) {
} else {
getConfig().addDefault("Hunger", true);
}
if (config.contains("Sprint")) {
} else {
getConfig().addDefault("Sprint", true);
}
if (config.contains("Fishing")) {
} else {
getConfig().addDefault("Fishing", true);
}
if (config.contains("Eggs")) {
} else {
getConfig().addDefault("Eggs", true);
}
if (config.contains("Sneak")) {
} else {
getConfig().addDefault("Sneak", true);
}
if (config.contains("Pigzap")) {
} else {
getConfig().addDefault("Pigzap", true);
}
if (config.contains("Slimesplit")) {
} else {
getConfig().addDefault("Slimesplit", true);
}
if (config.contains("Shear")) {
} else {
getConfig().addDefault("Shear", true);
}
if (config.contains("Pigsaddle")) {
} else {
getConfig().addDefault("Pigsaddle", true);
}
if (config.contains("Trade")) {
} else {
getConfig().addDefault("Trade", true);
}
if (config.contains("God")) {
} else {
getConfig().addDefault("God", true);
}
if (config.contains("Time")) {
} else {
getConfig().addDefault("Time", true);
}
if (config.contains("Weather")) {
} else {
getConfig().addDefault("Weather", true);
}
if (config.contains("BlockDamage")) {
} else {
getConfig().addDefault("BlockDamage", true);
}
/*
* if(config.contains("CrystalProtect")){
* }
* else {
* getConfig().addDefault("CrystalProtect", true);
* }
*/
configG.options().copyDefaults(true);
saveConfig();
}
public void logError(final String _message) {
log.log(Level.SEVERE, String.format("%s %s", LOG_HEADER, _message));
}
public void logInfo(final String _message) {
log.log(Level.INFO, String.format("%s %s", LOG_HEADER, _message));
}
public FileConfig config;
@Override
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if (sender instanceof Player) {
if (args.length == 0) {
if (cmd.getName().equalsIgnoreCase("resextras")) {
if (sender.hasPermission("ResExtras.help")) {
sender.sendMessage(ChatColor.GOLD + "----------------" + ChatColor.BLUE + "[ResExtras] Help Menu" + ChatColor.GOLD + "----------------");
sender.sendMessage(ChatColor.RED + "/ResExtras" + ChatColor.GREEN + " Displays help menu ");
sender.sendMessage(ChatColor.RED + "/ResExtras help" + ChatColor.GREEN + " Displays help menu ");
sender.sendMessage(ChatColor.RED + "/ResExtras version" + ChatColor.GREEN + " Displays version Number ");
sender.sendMessage(ChatColor.RED + "/ResExtras list" + ChatColor.GREEN + " Displays flag list ");
sender.sendMessage(ChatColor.GOLD + "---------------------------------------------------");
}
}
sendHelp(sender);
}
if (args.length == 1) {
if (args[0].equalsIgnoreCase("version")) {
switch (args[0].toLowerCase()) {
case "version":
if (sender.hasPermission("ResExtras.version")) {
sender.sendMessage(ChatColor.BLUE + "[ResExtras]" + ChatColor.GREEN + " v2.0.5 ");
sender.sendMessage("§6[§bResExtras§6] §av2.0.5 §6重制 §dBy §a喵♂呜");
}
}
if (args[0].equalsIgnoreCase("list")) {
return true;
case "list":
if (sender.hasPermission("ResExtras.list")) {
sender.sendMessage(ChatColor.BLUE + "[ResExtras]" + ChatColor.GREEN + " Flags");
sender.sendMessage(ChatColor.WHITE
+ " Zombie, Skeleton, Spider, Creeperspawn, Blaze, Cavespider, Ghast, Slime, Magmacube, Silverfish, Snowgolem, Irongolem, Enderman, Zombiepigmen, Chicken, Cow, Mooshroom, Ocelot, Pig, Sheep, Squid, Villager, Wolf, Bat, Witherspawn, Witch, Form, Melt, Commands, FallDamage, Portal, Enderperal, Mobkilling, AnimalKilling, VillagerKilling, Drops, Pickup, VehicleProtect, Lightning, Grow, Hunger, Sprint, Fishing, Eggs, Sneak, PigZap, SlimeSplit, Shear, PigSaddle, Trade, God, Weather, Time, BlockDamage ");
}
}
if (args[0].equalsIgnoreCase("help")) {
if (sender.hasPermission("ResExtras.help")) {
sender.sendMessage(ChatColor.GOLD + "----------------" + ChatColor.BLUE + "[ResExtras] Help Menu" + ChatColor.GOLD + "----------------");
sender.sendMessage(ChatColor.RED + "/ResExtras" + ChatColor.GREEN + " Displays help menu ");
sender.sendMessage(ChatColor.RED + "/ResExtras help" + ChatColor.GREEN + " Displays help menu ");
sender.sendMessage(ChatColor.RED + "/ResExtras version" + ChatColor.GREEN + " Displays version Number ");
sender.sendMessage(ChatColor.RED + "/ResExtras list" + ChatColor.GREEN + " Displays flag list ");
sender.sendMessage(ChatColor.GOLD + "---------------------------------------------------");
sender.sendMessage("§6[§bResExtras§6] §a 扩展Flags");
sender.sendMessage("Zombie, Skeleton, Spider, Creeperspawn, Blaze, Cavespider, Ghast, Slime, Magmacube, Silverfish, Snowgolem, Irongolem, Enderman, Zombiepigmen, "
+ "Chicken, Cow, Mooshroom, Ocelot, Pig, Sheep, Squid, Villager, Wolf, Bat, Witherspawn, Witch, Form, Melt, Commands, FallDamage, Portal, Enderperal, "
+ "Mobkilling, AnimalKilling, VillagerKilling, Drops, Pickup, VehicleProtect, Lightning, Grow, Hunger, Sprint, Fishing, Eggs, Sneak, PigZap, SlimeSplit, "
+ "Shear, PigSaddle, Trade, God, Weather, Time, BlockDamage ");
}
return true;
case "help":
sendHelp(sender);
return true;
}
}
return true;
}
return true;
}
@Override
public void onDisable() {
saveConfig();
}
// very long start up lolz
@Override
public void onEnable() {
log = Logger.getLogger("Minecraft");
loadDefaults();
final PluginManager pm = getServer().getPluginManager();
final Plugin p = pm.getPlugin("Residence");
if (p != null) {
if (p.isEnabled()) {
logInfo("Enabled");
pm.enablePlugin(p);
FlagPermissions.addResidenceOnlyFlag("zombie");
FlagPermissions.addResidenceOnlyFlag("skeleton");
@ -450,7 +163,6 @@ public class ResExtras extends JavaPlugin implements CommandExecutor {
FlagPermissions.addResidenceOnlyFlag("day");
FlagPermissions.addResidenceOnlyFlag("night");
FlagPermissions.addResidenceOnlyFlag("blockdamage");
// FlagPermissions.addFlag("crystalprotect");
if (getConfig().getBoolean("Zombie", true)) {
pm.registerEvents(new zombie(), this);
}
@ -613,15 +325,24 @@ public class ResExtras extends JavaPlugin implements CommandExecutor {
if (getConfig().getBoolean("BlockDamage", true)) {
pm.registerEvents(new blockdamage(), this);
}
/*
* if(getConfig().getBoolean("CrystalProtect", true)){
* pm.registerEvents(new crystalprotect(), this);
* }
*/
this.getLogger().info("领地扩展 版本 " + this.getDescription().getVersion() + " 已正确载入 重置 By 喵♂呜");
new VersionChecker(this);
}
} else {
logInfo("Can't find plugin Residence!");
this.getLogger().warning("未找到 Residence 插件!");
this.setEnabled(false);
}
}
@Override
public void onLoad() {
config = new FileConfig(this);
}
public void sendHelp(final CommandSender sender) {
sender.sendMessage("§6========= §6[§b领地扩展§6] §6插件帮助列表=========");
sender.sendMessage("§6/ResExtras help §6- §a显示帮助页面");
sender.sendMessage("§6/ResExtras version §6- §a显示插件版本");
sender.sendMessage("§6/ResExtras list §6- §a显示Flags列表");
}
}

View File

@ -0,0 +1,54 @@
Zombie: true
Skeleton: true
Spider: true
Creeperspawn: true
Blaze: true
Cavespider: true
Ghast: true
Slime: true
Magmacube: true
Silverfish: true
Snowgolem: true
Irongolem: true
Enderman: true
Zombiepigmen: true
Chicken: true
Cow: true
Mooshroom: true
Ocelot: true
Pig: true
Sheep: true
Squid: true
Villager: true
Wolf: true
Bat: true
Witherspawn: true
Witch: true
Form: true
Melt: true
Commands: true
Falldamage: true
Portal: true
Enderpearl: true
Mobkilling: true
Animalkilling: true
Villagerkilling: true
Drops: true
Pickup: true
Vehicleprotect: true
Lightning: true
Grow: true
Hunger: true
Sprint: true
Fishing: true
Eggs: true
Sneak: true
Pigzap: true
Slimesplit: true
Shear: true
Pigsaddle: true
Trade: true
God: true
Time: true
Weather: true
BlockDamage: true