Refactor locationToName method for improved readability and performance and update license
This commit is contained in:
parent
a8347a5126
commit
aaa11a11ac
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -20,14 +20,21 @@ import org.apache.commons.lang3.StringUtils;
|
|||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
|
@ -63,7 +70,8 @@ public class GuiUpdateCheckerOverlay extends Gui {
|
|||
this.mc = mc;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
checkForUpdatesButton = new GuiButton(0, 0, 0, 150, 20, I18n.format("update.button") + " " + I18n.format(mc.gameSettings.enableUpdateSvc ? "gui.yes" : "gui.no"));
|
||||
checkForUpdatesButton = new GuiButton(0, 0, 0, 150, 20, I18n.format("update.button") + " "
|
||||
+ I18n.format(mc.gameSettings.enableUpdateSvc ? "gui.yes" : "gui.no"));
|
||||
startDownloadButton = new GuiButton(1, 1, 0, 115, 20, I18n.format("update.startDownload"));
|
||||
viewAllUpdatesButton = new GuiButton(2, 1, 0, 115, 20, I18n.format("update.viewAll", 0));
|
||||
dismissUpdatesButton = new GuiButton(3, 1, 0, 115, 20, I18n.format("update.dismiss"));
|
||||
|
@ -73,6 +81,7 @@ public class GuiUpdateCheckerOverlay extends Gui {
|
|||
if (!UpdateService.supported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateProgressStruct progressState = UpdateService.getUpdatingStatus();
|
||||
if (progressState.isBusy) {
|
||||
drawScreenBusy(mx, my, partialTicks, progressState);
|
||||
|
@ -90,6 +99,7 @@ public class GuiUpdateCheckerOverlay extends Gui {
|
|||
checkForUpdatesButton.visible &= shownSP;
|
||||
|
||||
if (mc.gameSettings.enableUpdateSvc) {
|
||||
|
||||
String str;
|
||||
UpdateCertificate cert = UpdateService.getLatestUpdateFound();
|
||||
if (cert != null) {
|
||||
|
@ -104,7 +114,8 @@ public class GuiUpdateCheckerOverlay extends Gui {
|
|||
int embedWidth = 115;
|
||||
int embedWidth2 = (int) (embedWidth / 0.75f);
|
||||
|
||||
List<String> lst = cert.bundleVersionComment.length() == 0 ? null : mc.fontRendererObj.listFormattedStringToWidth(cert.bundleVersionComment, embedWidth2 - 14);
|
||||
List<String> lst = cert.bundleVersionComment.length() == 0 ? null
|
||||
: mc.fontRendererObj.listFormattedStringToWidth(cert.bundleVersionComment, embedWidth2 - 14);
|
||||
|
||||
int embedHeight = 44;
|
||||
if (lst != null) {
|
||||
|
@ -133,7 +144,9 @@ public class GuiUpdateCheckerOverlay extends Gui {
|
|||
GlStateManager.popMatrix();
|
||||
|
||||
mc.fontRendererObj.drawString(EnumChatFormatting.UNDERLINE + cert.bundleDisplayName, 45, 11, 0x000000);
|
||||
mc.fontRendererObj.drawString(I18n.format("update.update") + " " + EnumChatFormatting.DARK_RED + cert.bundleDisplayVersion, 45, 25, 0x000000);
|
||||
mc.fontRendererObj.drawString(
|
||||
I18n.format("update.update") + " " + EnumChatFormatting.DARK_RED + cert.bundleDisplayVersion,
|
||||
45, 25, 0x000000);
|
||||
|
||||
if (lst != null) {
|
||||
for (int j = 0, l = lst.size(); j < l; ++j) {
|
||||
|
@ -141,7 +154,8 @@ public class GuiUpdateCheckerOverlay extends Gui {
|
|||
}
|
||||
}
|
||||
|
||||
mc.fontRendererObj.drawString(I18n.format("update.author") + " " + cert.bundleAuthorName, 5, 44 + (lst == null ? 0 : (3 + lst.size() * 8)), 0x777777);
|
||||
mc.fontRendererObj.drawString(I18n.format("update.author") + " " + cert.bundleAuthorName, 5,
|
||||
44 + (lst == null ? 0 : (3 + lst.size() * 8)), 0x777777);
|
||||
|
||||
startDownloadButton.yPosition = embedHeight + embedY + 5;
|
||||
viewAllUpdatesButton.yPosition = startDownloadButton.yPosition + 22;
|
||||
|
@ -214,7 +228,8 @@ public class GuiUpdateCheckerOverlay extends Gui {
|
|||
GlStateManager.translate(0.0f, progY2 + 2, 0.0f);
|
||||
GlStateManager.scale(0.66f, 0.66f, 0.66f);
|
||||
str = progressState.statusString3;
|
||||
List<String> wrappedURL = mc.fontRendererObj.listFormattedStringToWidth(str, (int)((progX2 - progX1) * 1.5f));
|
||||
List<String> wrappedURL = mc.fontRendererObj.listFormattedStringToWidth(str,
|
||||
(int) ((progX2 - progX1) * 1.5f));
|
||||
for (int i = 0, l = wrappedURL.size(); i < l; ++i) {
|
||||
str = wrappedURL.get(i);
|
||||
mc.fontRendererObj.drawStringWithShadow(str, 5, i * 11, cc);
|
||||
|
@ -233,7 +248,8 @@ public class GuiUpdateCheckerOverlay extends Gui {
|
|||
if (checkForUpdatesButton.mousePressed(mc, mx, my)) {
|
||||
mc.gameSettings.enableUpdateSvc = !mc.gameSettings.enableUpdateSvc;
|
||||
mc.gameSettings.saveOptions();
|
||||
checkForUpdatesButton.displayString = I18n.format("update.button") + " " + I18n.format(mc.gameSettings.enableUpdateSvc ? "gui.yes" : "gui.no");
|
||||
checkForUpdatesButton.displayString = I18n.format("update.button") + " "
|
||||
+ I18n.format(mc.gameSettings.enableUpdateSvc ? "gui.yes" : "gui.no");
|
||||
}
|
||||
if (startDownloadButton.mousePressed(mc, mx, my)) {
|
||||
if (!UpdateService.getUpdatingStatus().isBusy) {
|
||||
|
|
|
@ -109,6 +109,7 @@ public class UpdateService {
|
|||
}
|
||||
byte[] latestUpdate = PlatformApplication.getLocalStorage(EaglercraftVersion.updateLatestLocalStorageKey,
|
||||
false);
|
||||
|
||||
if (latestUpdate != null) {
|
||||
addCertificateToSet(latestUpdate, false);
|
||||
}
|
||||
|
|
|
@ -56,8 +56,13 @@ public abstract class AbstractResourcePack implements IResourcePack {
|
|||
}
|
||||
|
||||
private static String locationToName(ResourceLocation location) {
|
||||
return HString.format("%s/%s/%s",
|
||||
new Object[] { "assets", location.getResourceDomain(), location.getResourcePath() });
|
||||
String namespace = location.getResourceDomain();
|
||||
String path = location.getResourcePath();
|
||||
// uses a StringBuilder internally
|
||||
return "assets/" +
|
||||
namespace +
|
||||
'/' +
|
||||
path;
|
||||
}
|
||||
|
||||
public InputStream getInputStream(ResourceLocation location) throws IOException {
|
||||
|
|
Loading…
Reference in New Issue