mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2026-01-04 15:41:35 +00:00
2.2.9
This commit is contained in:
@@ -45,7 +45,7 @@ public interface FishingStatistics {
|
|||||||
* Retrieves the amount of fish caught with the specified ID.
|
* Retrieves the amount of fish caught with the specified ID.
|
||||||
*
|
*
|
||||||
* @param id the ID of the fish.
|
* @param id the ID of the fish.
|
||||||
* @return the amount of fish caught with the specified ID. -1 if not exist.
|
* @return the amount of fish caught with the specified ID. 0 if not exist.
|
||||||
*/
|
*/
|
||||||
int getAmount(String id);
|
int getAmount(String id);
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class FishingStatisticsImpl implements FishingStatistics {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAmount(String id) {
|
public int getAmount(String id) {
|
||||||
return amountMap.getOrDefault(id, -1);
|
return amountMap.getOrDefault(id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -70,12 +70,12 @@ public class FishingStatisticsImpl implements FishingStatistics {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMaxSize(String id) {
|
public float getMaxSize(String id) {
|
||||||
return sizeMap.getOrDefault(id, -1f);
|
return sizeMap.getOrDefault(id, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMaxSize(String id, float maxSize) {
|
public void setMaxSize(String id, float maxSize) {
|
||||||
if (maxSize < 0) maxSize = 0;
|
if (maxSize < 0) return;
|
||||||
sizeMap.put(id, maxSize);
|
sizeMap.put(id, maxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,14 +22,13 @@ import com.saicone.rtag.tag.TagBase;
|
|||||||
import com.saicone.rtag.tag.TagCompound;
|
import com.saicone.rtag.tag.TagCompound;
|
||||||
import com.saicone.rtag.tag.TagList;
|
import com.saicone.rtag.tag.TagList;
|
||||||
import net.momirealms.customfishing.bukkit.item.BukkitItemFactory;
|
import net.momirealms.customfishing.bukkit.item.BukkitItemFactory;
|
||||||
|
import net.momirealms.customfishing.bukkit.util.SkullUtils;
|
||||||
import net.momirealms.customfishing.common.plugin.CustomFishingPlugin;
|
import net.momirealms.customfishing.common.plugin.CustomFishingPlugin;
|
||||||
import net.momirealms.customfishing.common.util.Key;
|
import net.momirealms.customfishing.common.util.Key;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class UniversalItemFactory extends BukkitItemFactory {
|
public class UniversalItemFactory extends BukkitItemFactory {
|
||||||
|
|
||||||
@@ -72,7 +71,11 @@ public class UniversalItemFactory extends BukkitItemFactory {
|
|||||||
if (skullData == null) {
|
if (skullData == null) {
|
||||||
item.remove("SkullOwner");
|
item.remove("SkullOwner");
|
||||||
} else {
|
} else {
|
||||||
item.set(List.of(Map.of("Value", skullData)), "SkullOwner", "Properties", "textures");
|
item.set(UUID.nameUUIDFromBytes(SkullUtils.identifierFromBase64(skullData).getBytes(StandardCharsets.UTF_8)), "SkullOwner", "Id");
|
||||||
|
item.set(
|
||||||
|
List.of(Map.of("Value", skullData)),
|
||||||
|
"SkullOwner", "Properties", "textures"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) <2024> <XiaoMoMi>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.momirealms.customfishing.bukkit.util;
|
||||||
|
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
|
public class SkullUtils {
|
||||||
|
|
||||||
|
public static String identifierFromBase64(String base64) {
|
||||||
|
byte[] decodedBytes = Base64.getDecoder().decode(base64);
|
||||||
|
String decodedString = new String(decodedBytes);
|
||||||
|
int urlStartIndex = decodedString.indexOf("\"url\":\"") + 7;
|
||||||
|
int urlEndIndex = decodedString.indexOf("\"", urlStartIndex);
|
||||||
|
String textureUrl = decodedString.substring(urlStartIndex, urlEndIndex);
|
||||||
|
return textureUrl.substring(textureUrl.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Project settings
|
# Project settings
|
||||||
# Rule: [major update].[feature update].[bug fix]
|
# Rule: [major update].[feature update].[bug fix]
|
||||||
project_version=2.2.8
|
project_version=2.2.9
|
||||||
config_version=34
|
config_version=34
|
||||||
project_group=net.momirealms
|
project_group=net.momirealms
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user