From c8df7783fa821243a3c42af749482882a0f7f9e1 Mon Sep 17 00:00:00 2001 From: miozune Date: Tue, 25 Jul 2023 13:17:59 +0900 Subject: [PATCH] Remove AbstractedStack (#346) * Remove AbstractedStack * Remove outdated script Former-commit-id: 6729a9cbf4811cb39b229653cc04259ad7b47687 --- .github/scripts/test_no_error_reports | 51 ----------- .../system/object/AbstractedStack.java | 84 ------------------- 2 files changed, 135 deletions(-) delete mode 100755 .github/scripts/test_no_error_reports delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/object/AbstractedStack.java diff --git a/.github/scripts/test_no_error_reports b/.github/scripts/test_no_error_reports deleted file mode 100755 index 1fcc7396c..000000000 --- a/.github/scripts/test_no_error_reports +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash - -# bashsupport disable=BP5006 # Global environment variables -RUNDIR="run" \ - CRASH="crash-reports" \ - SERVERLOG="server.log" - -# enable nullglob to get 0 results when no match rather than the pattern -shopt -s nullglob - -# store matches in array -crash_reports=("$RUNDIR/$CRASH/crash"*.txt) - -# if array not empty there are crash_reports -if [ "${#crash_reports[@]}" -gt 0 ]; then - # get the latest crash_report from array - latest_crash_report="${crash_reports[-1]}" - { - printf 'Latest crash report detected %s:\n' "${latest_crash_report##*/}" - cat "$latest_crash_report" - } >&2 - exit 1 -fi - -if grep --quiet --fixed-strings 'Fatal errors were detected' "$SERVERLOG"; then - { - printf 'Fatal errors detected:\n' - cat server.log - } >&2 - exit 1 -fi - -if grep --quiet --fixed-strings 'The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED' \ - "$SERVERLOG"; then - { - printf 'Server force stopped:' - cat server.log - } >&2 - exit 1 -fi - -if ! grep --quiet --perl-regexp --only-matching '.+Done \(.+\)\! For help, type "help" or "\?"' "$SERVERLOG"; then - { - printf 'Server did not finish startup:' - cat server.log - } >&2 - exit 1 -fi - -printf 'No crash reports detected' -exit 0 diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/object/AbstractedStack.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/object/AbstractedStack.java deleted file mode 100644 index 86e5673eb..000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/object/AbstractedStack.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following - * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial - * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -package com.github.bartimaeusnek.bartworks.system.object; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import com.github.bartimaeusnek.bartworks.util.Pair; - -public class AbstractedStack implements Serializable { - - final Pair idDamage; - final NBTTagCompound mTag; - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof AbstractedStack)) return false; - - AbstractedStack that = (AbstractedStack) o; - - if (this.getIdDamage() != null ? !this.getIdDamage().equals(that.getIdDamage()) : that.getIdDamage() != null) - return false; - return this.getmTag() != null ? this.getmTag().equals(that.getmTag()) : that.getmTag() == null; - } - - @Override - public int hashCode() { - int result = this.getIdDamage() != null ? this.getIdDamage().hashCode() : 0; - result = 31 * result + (this.getmTag() != null ? this.getmTag().hashCode() : 0); - return result; - } - - public Pair getIdDamage() { - return this.idDamage; - } - - public NBTTagCompound getmTag() { - return this.mTag; - } - - public AbstractedStack(Pair idDamage, NBTTagCompound mTag) { - this.idDamage = idDamage; - this.mTag = mTag; - } - - public AbstractedStack(ItemStack itemStack) { - if (itemStack == null) throw new UnsupportedOperationException(); - this.idDamage = new Pair<>(Item.getIdFromItem(itemStack.getItem()), (short) itemStack.getItemDamage()); - this.mTag = itemStack.getTagCompound(); - } - - public byte[] serialize() throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - ObjectOutputStream os = new ObjectOutputStream(out); - os.writeObject(this); - return out.toByteArray(); - } - - public AbstractedStack deserialize(byte[] data) throws IOException, ClassNotFoundException, ClassCastException { - ByteArrayInputStream in = new ByteArrayInputStream(data); - ObjectInputStream is = new ObjectInputStream(in); - return (AbstractedStack) is.readObject(); - } -}