Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

Commit

Permalink
Code tweak
Browse files Browse the repository at this point in the history
Former-commit-id: 7279fde
  • Loading branch information
Ghost-chu committed Jan 5, 2020
1 parent 3bb3654 commit 25e8f8f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/main/java/org/maxgamer/quickshop/Util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public static void debugLog(@NotNull String... logs) {
long startTime = System.currentTimeMillis();
String className = Thread.currentThread().getStackTrace()[2].getClassName();
try {
Class c = Class.forName(className);
Class<?> c = Class.forName(className);
className = c.getSimpleName();
if (!c.getSimpleName().isEmpty()) {
className = c.getSimpleName();
Expand Down Expand Up @@ -260,15 +260,18 @@ public static ItemStack deserialize(@NotNull String config) throws InvalidConfig
int itemDataVersion = Integer.parseInt(String.valueOf(item.get("v")));
try{
//Try load the itemDataVersion to do some checks.
//noinspection deprecation
if(itemDataVersion > Bukkit.getUnsafe().getDataVersion()){
Util.debugLog("WARNING: DataVersion not matched with ItemStack: "+config);
//okay we need some things to do
if(plugin.getConfig().getBoolean("shop.force-load-downgrade-items.enable")){
//okay it enabled
Util.debugLog("QuickShop is trying force loading it...");
if (plugin.getConfig().getInt("shop.force-load-downgrade-items.method") == 0) {//Mode 0
//noinspection deprecation
item.put("v", Bukkit.getUnsafe().getDataVersion() - 1);
} else {//Mode other
//noinspection deprecation
item.put("v", Bukkit.getUnsafe().getDataVersion());
}
//Okay we have hacked the dataVersion, now put it back
Expand Down Expand Up @@ -363,7 +366,7 @@ public static Block getAttached(@NotNull Block b) {
* @param c The class to get name
* @return The class prefix
*/
public static String getClassPrefix(@NotNull Class c) {
public static String getClassPrefix(@NotNull Class<?> c) {
String callClassName = Thread.currentThread().getStackTrace()[2].getClassName();
String customClassName = c.getSimpleName();
return "[" + callClassName + "-" + customClassName + "] ";
Expand Down Expand Up @@ -961,7 +964,7 @@ public static Location lookAt(Location loc, Location lookat) {
* @return Map1 match Map2 and Map2 match Map1
*/
@Deprecated
public static boolean mapDuoMatches(@NotNull Map map1, @NotNull Map map2) {
public static boolean mapDuoMatches(@NotNull Map<?,?> map1, @NotNull Map<?,?> map2) {
boolean result = mapMatches(map1, map2);
if (!result) {
return false;
Expand All @@ -976,7 +979,7 @@ public static boolean mapDuoMatches(@NotNull Map map1, @NotNull Map map2) {
* @param map2 Map2
* @return Map1 match Map2
*/
public static boolean mapMatches(@NotNull Map map1, @NotNull Map map2) {
public static boolean mapMatches(@NotNull Map<?,?> map1, @NotNull Map<?,?> map2) {
for (Object obj : map1.keySet()) {
if (!map2.containsKey(obj)) {
return false;
Expand Down Expand Up @@ -1143,7 +1146,7 @@ public static String getClassPrefix() {

String className = Thread.currentThread().getStackTrace()[2].getClassName();
try {
Class c = Class.forName(className);
Class<?> c = Class.forName(className);
className = c.getSimpleName();
if (!c.getSimpleName().isEmpty()) {
className = c.getSimpleName();
Expand Down Expand Up @@ -1266,8 +1269,8 @@ public static String md5(final String s) {
instance.update(s.getBytes(StandardCharsets.UTF_8));
final byte[] digest = instance.digest();
final StringBuilder sb = new StringBuilder("");
for (int i = 0; i < digest.length; ++i) {
int n = digest[i];
for (int b : digest) {
int n = b;
if (n < 0) {
n += 256;
}
Expand Down

0 comments on commit 25e8f8f

Please sign in to comment.