Add warning and stop startup when plugin is used with a minecraft version that has not been tested yet (I hope this reduce confusion on the next major minecraft update)

This commit is contained in:
GeorgH93 2016-03-12 15:11:45 +01:00
parent 900d106a7c
commit 4228867c1c
6 changed files with 47 additions and 14 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>at.pcgamingfreaks</groupId> <groupId>at.pcgamingfreaks</groupId>
<artifactId>MinePacks</artifactId> <artifactId>MinePacks</artifactId>
<version>1.15</version> <version>1.16-SNAPSHOT</version>
<scm> <scm>
<connection>scm:git:git@github.com:GeorgH93/Bukkit_Minepacks.git</connection> <connection>scm:git:git@github.com:GeorgH93/Bukkit_Minepacks.git</connection>

View File

@ -6,6 +6,7 @@ Language:
LangUpdated: Die Sprachdatei wurde aktualisiert. LangUpdated: Die Sprachdatei wurde aktualisiert.
UpdateUUIDs: Beginne die Spielernamen in UUIDs umzuwandeln... UpdateUUIDs: Beginne die Spielernamen in UUIDs umzuwandeln...
UpdatedUUIDs: 'Es wurden %d Spielernamen in UUIDs umgewandelt.' UpdatedUUIDs: 'Es wurden %d Spielernamen in UUIDs umgewandelt.'
MinecraftVersionNotCompatible: "Deine Minecraft Version (MC %1$s) ist mit der Version des Plugins (%2$s) nicht kompatibel! Bitte prüfe ob ein update verfügbar ist!"
Ingame: Ingame:
NoPermission: 'Dir fehlen die Rechte dafür.' NoPermission: 'Dir fehlen die Rechte dafür.'
OwnBackPackClose: 'Rucksack geschlossen.' OwnBackPackClose: 'Rucksack geschlossen.'
@ -20,4 +21,4 @@ Language:
View: Öffnet den Rucksack eines anderen Spielers. View: Öffnet den Rucksack eines anderen Spielers.
# Language file version. Don't touch it! # Language file version. Don't touch it!
Version: 3 Version: 4

View File

@ -6,6 +6,7 @@ Language:
LangUpdated: Language File has been updated. LangUpdated: Language File has been updated.
UpdateUUIDs: Start updating database to UUIDs ... UpdateUUIDs: Start updating database to UUIDs ...
UpdatedUUIDs: 'Updated %s accounts to UUIDs.' UpdatedUUIDs: 'Updated %s accounts to UUIDs.'
MinecraftVersionNotCompatible: "Your minecraft version (MC %1$s) is currently not compatible with this plugins version (%2$s). Please check for updates!"
Ingame: Ingame:
NoPermission: You don't have the Permission to do that. NoPermission: You don't have the Permission to do that.
OwnBackPackClose: 'Backpack closed!' OwnBackPackClose: 'Backpack closed!'
@ -20,4 +21,4 @@ Language:
View: Shows the backpack of other player. View: Shows the backpack of other player.
# Language file version. Don't touch it! # Language file version. Don't touch it!
Version: 3 Version: 4

View File

@ -20,6 +20,7 @@
import at.pcgamingfreaks.Bukkit.ItemStackSerializer.BukkitItemStackSerializer; import at.pcgamingfreaks.Bukkit.ItemStackSerializer.BukkitItemStackSerializer;
import at.pcgamingfreaks.Bukkit.ItemStackSerializer.ItemStackSerializer; import at.pcgamingfreaks.Bukkit.ItemStackSerializer.ItemStackSerializer;
import at.pcgamingfreaks.Bukkit.ItemStackSerializer.NBTItemStackSerializer; import at.pcgamingfreaks.Bukkit.ItemStackSerializer.NBTItemStackSerializer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

View File

@ -21,7 +21,7 @@
public class Language extends at.pcgamingfreaks.Bukkit.Language public class Language extends at.pcgamingfreaks.Bukkit.Language
{ {
private static final int LANG_VERSION = 3; private static final int LANG_VERSION = 4;
public Language(JavaPlugin plugin) public Language(JavaPlugin plugin)
{ {
@ -35,6 +35,7 @@ protected void doUpdate()
{ {
case 1: lang.set("Language.Ingame.Cooldown", "Please wait till you reopen your backpack."); case 1: lang.set("Language.Ingame.Cooldown", "Please wait till you reopen your backpack.");
case 2: lang.set("Language.Ingame.InvalidBackpack", lang.getString("Language.Ingame.IvalidBackpack", "Invalid backpack.")); case 2: lang.set("Language.Ingame.InvalidBackpack", lang.getString("Language.Ingame.IvalidBackpack", "Invalid backpack."));
case 3: lang.set("Language.Console.MinecraftVersionNotCompatible", "Your minecraft version (MC %1$s) is currently not compatible with this plugins version (%2$s). Please check for updates!");
break; break;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2014-2015 GeorgH93 * Copyright (C) 2014-2016 GeorgH93
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,18 +17,22 @@
package at.pcgamingfreaks.MinePacks; package at.pcgamingfreaks.MinePacks;
import java.util.HashMap; import at.pcgamingfreaks.MinePacks.Database.Config;
import java.util.logging.Logger; import at.pcgamingfreaks.MinePacks.Database.Database;
import at.pcgamingfreaks.MinePacks.Database.Language;
import net.gravitydevelopment.Updater.Bukkit_Updater; import net.gravitydevelopment.Updater.Bukkit_Updater;
import net.gravitydevelopment.Updater.UpdateType; import net.gravitydevelopment.Updater.UpdateType;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.ServicePriority; import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import at.pcgamingfreaks.MinePacks.Database.*; import java.util.HashMap;
import java.util.logging.Logger;
public class MinePacks extends JavaPlugin public class MinePacks extends JavaPlugin
{ {
@ -38,9 +42,9 @@ public class MinePacks extends JavaPlugin
public Config config; public Config config;
public Language lang; public Language lang;
public Database DB; public Database DB;
public HashMap<Player, Long> cooldowns = new HashMap<>(); public HashMap<Player, Long> cooldowns = new HashMap<>();
public static String BackpackTitle; public static String BackpackTitle;
public String Message_InvalidBackpack; public String Message_InvalidBackpack;
@ -53,6 +57,16 @@ public static MinePacks getInstance()
public void onEnable() public void onEnable()
{ {
log = getLogger(); log = getLogger();
String name = Bukkit.getServer().getClass().getPackage().getName();
String[] version = name.substring(name.lastIndexOf('.') + 2).split("_");
if((version[0].equals("1") && Integer.valueOf(version[1]) > 9) || Integer.valueOf(version[0]) > 1)
{
MinePacks.getInstance().warnOnVersionIncompatibility(version[0] + "." + version[1]);
this.setEnabled(false);
return;
}
config = new Config(this); config = new Config(this);
lang = new Language(this); lang = new Language(this);
@ -67,7 +81,7 @@ public void onEnable()
{ {
(new ItemsCollector(this)).runTaskTimer(this, config.getFullInvCheckInterval(), config.getFullInvCheckInterval()); (new ItemsCollector(this)).runTaskTimer(this, config.getFullInvCheckInterval(), config.getFullInvCheckInterval());
} }
BackpackTitle = config.getBPTitle(); BackpackTitle = config.getBPTitle();
Message_InvalidBackpack = lang.getTranslated("Ingame.InvalidBackpack"); Message_InvalidBackpack = lang.getTranslated("Ingame.InvalidBackpack");
getServer().getServicesManager().register(MinePacks.class, this, this, ServicePriority.Normal); getServer().getServicesManager().register(MinePacks.class, this, this, ServicePriority.Normal);
@ -85,7 +99,22 @@ public void onDisable()
} }
log.info(lang.get("Console.Disabled")); log.info(lang.get("Console.Disabled"));
} }
public void warnOnVersionIncompatibility(String version)
{
log.warning(ChatColor.RED + "################################");
log.warning(ChatColor.RED + String.format(MinePacks.getInstance().lang.getTranslated("Console.MinecraftVersionNotCompatible"), version));
log.warning(ChatColor.RED + "################################");
try
{
Thread.sleep(5000L);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
public void openBackpack(final Player opener, OfflinePlayer owner, final boolean editable) public void openBackpack(final Player opener, OfflinePlayer owner, final boolean editable)
{ {
if(owner == null) if(owner == null)
@ -104,7 +133,7 @@ public void onResult(Backpack backpack)
public void onFail() {} public void onFail() {}
}); });
} }
public void openBackpack(Player opener, Backpack backpack, boolean editable) public void openBackpack(Player opener, Backpack backpack, boolean editable)
{ {
if(backpack == null) if(backpack == null)
@ -114,7 +143,7 @@ public void openBackpack(Player opener, Backpack backpack, boolean editable)
} }
backpack.open(opener, editable); backpack.open(opener, editable);
} }
public int getBackpackPermSize(Player player) public int getBackpackPermSize(Player player)
{ {
for(int i = 9; i > 1; i--) for(int i = 9; i > 1; i--)