From ef8b5c973fffc98762c43edeb4d01c61c43c2340 Mon Sep 17 00:00:00 2001 From: TONY_All Date: Thu, 8 Aug 2024 20:12:34 +0800 Subject: [PATCH] format code --- .../misc/EnhancedLinkedList.java | 631 +++++++++--------- .../blastingcrisis/command/DebugCommand.kt | 8 +- .../blastingcrisis/game/GamePlaceBreakRule.kt | 13 +- .../blastingcrisis/listener/GameListener.kt | 2 +- .../cc/maxmc/blastingcrisis/packet/BEntity.kt | 1 - .../blastingcrisis/packet/BEntityVillager.kt | 1 - src/main/resources/settings.yml | 1 - 7 files changed, 328 insertions(+), 329 deletions(-) diff --git a/src/main/java/cc/maxmc/blastingcrisis/misc/EnhancedLinkedList.java b/src/main/java/cc/maxmc/blastingcrisis/misc/EnhancedLinkedList.java index d6e0ebb..d0ddfa7 100644 --- a/src/main/java/cc/maxmc/blastingcrisis/misc/EnhancedLinkedList.java +++ b/src/main/java/cc/maxmc/blastingcrisis/misc/EnhancedLinkedList.java @@ -25,8 +25,8 @@ package cc.maxmc.blastingcrisis.misc; -import java.util.function.Consumer; import java.util.*; +import java.util.function.Consumer; /** * Doubly-linked list implementation of the {@code List} and {@code Deque} @@ -73,30 +73,28 @@ import java.util.*; * * Java Collections Framework. * - * @author Josh Bloch - * @see List - * @see ArrayList - * @since 1.2 * @param the type of elements held in this collection + * @author Josh Bloch + * @see List + * @see ArrayList + * @since 1.2 */ public class EnhancedLinkedList - extends AbstractSequentialList - implements List, Deque, Cloneable, java.io.Serializable -{ + extends AbstractSequentialList + implements List, Deque, Cloneable, java.io.Serializable { + private static final long serialVersionUID = 876323262645176354L; transient int size = 0; - /** * Pointer to first node. * Invariant: (first == null && last == null) || - * (first.prev == null && first.item != null) + * (first.prev == null && first.item != null) */ transient Node first; - /** * Pointer to last node. * Invariant: (first == null && last == null) || - * (last.next == null && last.item != null) + * (last.next == null && last.item != null) */ transient Node last; @@ -111,7 +109,7 @@ public class EnhancedLinkedList * collection, in the order they are returned by the collection's * iterator. * - * @param c the collection whose elements are to be placed into this list + * @param c the collection whose elements are to be placed into this list * @throws NullPointerException if the specified collection is null */ public EnhancedLinkedList(Collection c) { @@ -397,10 +395,10 @@ public class EnhancedLinkedList * * @param index index at which to insert the first element * from the specified collection - * @param c collection containing elements to be added to this list + * @param c collection containing elements to be added to this list * @return {@code true} if this list changed as a result of the call * @throws IndexOutOfBoundsException {@inheritDoc} - * @throws NullPointerException if the specified collection is null + * @throws NullPointerException if the specified collection is null */ public boolean addAll(int index, Collection c) { checkPositionIndex(index); @@ -441,6 +439,9 @@ public class EnhancedLinkedList return true; } + + // Positional Access Operations + /** * Removes all of the elements from this list. * The list will be empty after this call returns. @@ -462,9 +463,6 @@ public class EnhancedLinkedList modCount++; } - - // Positional Access Operations - /** * Returns the element at the specified position in this list. * @@ -481,7 +479,7 @@ public class EnhancedLinkedList * Replaces the element at the specified position in this list with the * specified element. * - * @param index index of the element to replace + * @param index index of the element to replace * @param element element to be stored at the specified position * @return the element previously at the specified position * @throws IndexOutOfBoundsException {@inheritDoc} @@ -499,7 +497,7 @@ public class EnhancedLinkedList * Shifts the element currently at that position (if any) and any * subsequent elements to the right (adds one to their indices). * - * @param index index at which the specified element is to be inserted + * @param index index at which the specified element is to be inserted * @param element element to be inserted * @throws IndexOutOfBoundsException {@inheritDoc} */ @@ -565,7 +563,7 @@ public class EnhancedLinkedList * this "outlining" performs best with both server and client VMs. */ private String outOfBoundsMsg(int index) { - return "Index: "+index+", Size: "+size; + return "Index: " + index + ", Size: " + size; } private void checkElementIndex(int index) { @@ -578,6 +576,8 @@ public class EnhancedLinkedList throw new IndexOutOfBoundsException(outOfBoundsMsg(index)); } + // Search Operations + /** * Returns the (non-null) Node at the specified element index. */ @@ -597,8 +597,6 @@ public class EnhancedLinkedList } } - // Search Operations - /** * Returns the index of the first occurrence of the specified element * in this list, or -1 if this list does not contain the element. @@ -608,7 +606,7 @@ public class EnhancedLinkedList * * @param o element to search for * @return the index of the first occurrence of the specified element in - * this list, or -1 if this list does not contain the element + * this list, or -1 if this list does not contain the element */ public int indexOf(Object o) { int index = 0; @@ -643,6 +641,8 @@ public class EnhancedLinkedList return null; } + // Queue operations. + /** * Returns the index of the last occurrence of the specified element * in this list, or -1 if this list does not contain the element. @@ -652,7 +652,7 @@ public class EnhancedLinkedList * * @param o element to search for * @return the index of the last occurrence of the specified element in - * this list, or -1 if this list does not contain the element + * this list, or -1 if this list does not contain the element */ public int lastIndexOf(Object o) { int index = size; @@ -672,8 +672,6 @@ public class EnhancedLinkedList return -1; } - // Queue operations. - /** * Retrieves, but does not remove, the head (first element) of this list. * @@ -718,6 +716,8 @@ public class EnhancedLinkedList return removeFirst(); } + // Deque operations + /** * Adds the specified element as the tail (last element) of this list. * @@ -729,7 +729,6 @@ public class EnhancedLinkedList return add(e); } - // Deque operations /** * Inserts the specified element at the front of this list. * @@ -759,20 +758,20 @@ public class EnhancedLinkedList * or returns {@code null} if this list is empty. * * @return the first element of this list, or {@code null} - * if this list is empty + * if this list is empty * @since 1.6 */ public E peekFirst() { final Node f = first; return (f == null) ? null : f.item; - } + } /** * Retrieves, but does not remove, the last element of this list, * or returns {@code null} if this list is empty. * * @return the last element of this list, or {@code null} - * if this list is empty + * if this list is empty * @since 1.6 */ public E peekLast() { @@ -785,7 +784,7 @@ public class EnhancedLinkedList * or returns {@code null} if this list is empty. * * @return the first element of this list, or {@code null} if - * this list is empty + * this list is empty * @since 1.6 */ public E pollFirst() { @@ -798,7 +797,7 @@ public class EnhancedLinkedList * or returns {@code null} if this list is empty. * * @return the last element of this list, or {@code null} if - * this list is empty + * this list is empty * @since 1.6 */ public E pollLast() { @@ -826,7 +825,7 @@ public class EnhancedLinkedList *

This method is equivalent to {@link #removeFirst()}. * * @return the element at the front of this list (which is the top - * of the stack represented by this list) + * of the stack represented by this list) * @throws NoSuchElementException if this list is empty * @since 1.6 */ @@ -879,7 +878,7 @@ public class EnhancedLinkedList * Returns a list-iterator of the elements in this list (in proper * sequence), starting at the specified position in the list. * Obeys the general contract of {@code List.listIterator(int)}.

- * + *

* The list-iterator is fail-fast: if the list is structurally * modified at any time after the Iterator is created, in any way except * through the list-iterator's own {@code remove} or {@code add} @@ -892,7 +891,7 @@ public class EnhancedLinkedList * @param index index of the first element to be returned from the * list-iterator (by a call to {@code next}) * @return a ListIterator of the elements in this list (in proper - * sequence), starting at the specified position in the list + * sequence), starting at the specified position in the list * @throws IndexOutOfBoundsException {@inheritDoc} * @see List#listIterator(int) */ @@ -901,6 +900,286 @@ public class EnhancedLinkedList return new ListItr(index); } + /** + * @since 1.6 + */ + public Iterator descendingIterator() { + return new DescendingIterator(); + } + + @SuppressWarnings("unchecked") + private EnhancedLinkedList superClone() { + try { + return (EnhancedLinkedList) super.clone(); + } catch (CloneNotSupportedException e) { + throw new InternalError(e); + } + } + + /** + * Returns a shallow copy of this {@code LinkedList}. (The elements + * themselves are not cloned.) + * + * @return a shallow copy of this {@code LinkedList} instance + */ + @Override + public Object clone() { + EnhancedLinkedList clone = superClone(); + + // Put clone into "virgin" state + clone.first = clone.last = null; + clone.size = 0; + clone.modCount = 0; + + // Initialize clone with our elements + for (Node x = first; x != null; x = x.next) + clone.add(x.item); + + return clone; + } + + /** + * Returns an array containing all of the elements in this list + * in proper sequence (from first to last element). + * + *

The returned array will be "safe" in that no references to it are + * maintained by this list. (In other words, this method must allocate + * a new array). The caller is thus free to modify the returned array. + * + *

This method acts as bridge between array-based and collection-based + * APIs. + * + * @return an array containing all of the elements in this list + * in proper sequence + */ + public Object[] toArray() { + Object[] result = new Object[size]; + int i = 0; + for (Node x = first; x != null; x = x.next) + result[i++] = x.item; + return result; + } + + /** + * Returns an array containing all of the elements in this list in + * proper sequence (from first to last element); the runtime type of + * the returned array is that of the specified array. If the list fits + * in the specified array, it is returned therein. Otherwise, a new + * array is allocated with the runtime type of the specified array and + * the size of this list. + * + *

If the list fits in the specified array with room to spare (i.e., + * the array has more elements than the list), the element in the array + * immediately following the end of the list is set to {@code null}. + * (This is useful in determining the length of the list only if + * the caller knows that the list does not contain any null elements.) + * + *

Like the {@link #toArray()} method, this method acts as bridge between + * array-based and collection-based APIs. Further, this method allows + * precise control over the runtime type of the output array, and may, + * under certain circumstances, be used to save allocation costs. + * + *

Suppose {@code x} is a list known to contain only strings. + * The following code can be used to dump the list into a newly + * allocated array of {@code String}: + * + *

+     *     String[] y = x.toArray(new String[0]);
+ *

+ * Note that {@code toArray(new Object[0])} is identical in function to + * {@code toArray()}. + * + * @param a the array into which the elements of the list are to + * be stored, if it is big enough; otherwise, a new array of the + * same runtime type is allocated for this purpose. + * @return an array containing the elements of the list + * @throws ArrayStoreException if the runtime type of the specified array + * is not a supertype of the runtime type of every element in + * this list + * @throws NullPointerException if the specified array is null + */ + @SuppressWarnings("unchecked") + public T[] toArray(T[] a) { + if (a.length < size) + a = (T[]) java.lang.reflect.Array.newInstance( + a.getClass().getComponentType(), size); + int i = 0; + Object[] result = a; + for (Node x = first; x != null; x = x.next) + result[i++] = x.item; + + if (a.length > size) + a[size] = null; + + return a; + } + + /** + * Saves the state of this {@code LinkedList} instance to a stream + * (that is, serializes it). + * + * @serialData The size of the list (the number of elements it + * contains) is emitted (int), followed by all of its + * elements (each an Object) in the proper order. + */ + private void writeObject(java.io.ObjectOutputStream s) + throws java.io.IOException { + // Write out any hidden serialization magic + s.defaultWriteObject(); + + // Write out size + s.writeInt(size); + + // Write out all elements in the proper order. + for (Node x = first; x != null; x = x.next) + s.writeObject(x.item); + } + + /** + * Reconstitutes this {@code LinkedList} instance from a stream + * (that is, deserializes it). + */ + @SuppressWarnings("unchecked") + private void readObject(java.io.ObjectInputStream s) + throws java.io.IOException, ClassNotFoundException { + // Read in any hidden serialization magic + s.defaultReadObject(); + + // Read in size + int size = s.readInt(); + + // Read in all elements in the proper order. + for (int i = 0; i < size; i++) + linkLast((E) s.readObject()); + } + + /** + * Creates a late-binding + * and fail-fast {@link Spliterator} over the elements in this + * list. + * + *

The {@code Spliterator} reports {@link Spliterator#SIZED} and + * {@link Spliterator#ORDERED}. Overriding implementations should document + * the reporting of additional characteristic values. + * + * @return a {@code Spliterator} over the elements in this list + * @implNote The {@code Spliterator} additionally reports {@link Spliterator#SUBSIZED} + * and implements {@code trySplit} to permit limited parallelism.. + * @since 1.8 + */ + @Override + public Spliterator spliterator() { + return new LLSpliterator<>(this, -1, 0); + } + + private static class Node { + E item; + Node next; + Node prev; + + Node(Node prev, E element, Node next) { + this.item = element; + this.next = next; + this.prev = prev; + } + } + + /** + * A customized variant of Spliterators.IteratorSpliterator + */ + static final class LLSpliterator implements Spliterator { + static final int BATCH_UNIT = 1 << 10; // batch array size increment + static final int MAX_BATCH = 1 << 25; // max batch array size; + final EnhancedLinkedList list; // null OK unless traversed + Node current; // current node; null until initialized + int est; // size estimate; -1 until first needed + int expectedModCount; // initialized when est set + int batch; // batch size for splits + + LLSpliterator(EnhancedLinkedList list, int est, int expectedModCount) { + this.list = list; + this.est = est; + this.expectedModCount = expectedModCount; + } + + int getEst() { + int s; // force initialization + final EnhancedLinkedList lst; + if ((s = est) < 0) { + if ((lst = list) == null) + s = est = 0; + else { + expectedModCount = lst.modCount; + current = lst.first; + s = est = lst.size; + } + } + return s; + } + + public long estimateSize() { + return getEst(); + } + + public Spliterator trySplit() { + Node p; + int s = getEst(); + if (s > 1 && (p = current) != null) { + int n = batch + BATCH_UNIT; + if (n > s) + n = s; + if (n > MAX_BATCH) + n = MAX_BATCH; + Object[] a = new Object[n]; + int j = 0; + do { + a[j++] = p.item; + } while ((p = p.next) != null && j < n); + current = p; + batch = j; + est = s - j; + return Spliterators.spliterator(a, 0, j, Spliterator.ORDERED); + } + return null; + } + + public void forEachRemaining(Consumer action) { + Node p; + int n; + if (action == null) throw new NullPointerException(); + if ((n = getEst()) > 0 && (p = current) != null) { + current = null; + est = 0; + do { + E e = p.item; + p = p.next; + action.accept(e); + } while (p != null && --n > 0); + } + if (list.modCount != expectedModCount) + throw new ConcurrentModificationException(); + } + + public boolean tryAdvance(Consumer action) { + Node p; + if (action == null) throw new NullPointerException(); + if (getEst() > 0 && (p = current) != null) { + --est; + E e = p.item; + current = p.next; + action.accept(e); + if (list.modCount != expectedModCount) + throw new ConcurrentModificationException(); + return true; + } + return false; + } + + public int characteristics() { + return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED; + } + } + private class ListItr implements ListIterator { private Node lastReturned; private Node next; @@ -1000,297 +1279,23 @@ public class EnhancedLinkedList } } - private static class Node { - E item; - Node next; - Node prev; - - Node(Node prev, E element, Node next) { - this.item = element; - this.next = next; - this.prev = prev; - } - } - - /** - * @since 1.6 - */ - public Iterator descendingIterator() { - return new DescendingIterator(); - } - /** * Adapter to provide descending iterators via ListItr.previous */ private class DescendingIterator implements Iterator { private final ListItr itr = new ListItr(size()); + public boolean hasNext() { return itr.hasPrevious(); } + public E next() { return itr.previous(); } + public void remove() { itr.remove(); } } - @SuppressWarnings("unchecked") - private EnhancedLinkedList superClone() { - try { - return (EnhancedLinkedList) super.clone(); - } catch (CloneNotSupportedException e) { - throw new InternalError(e); - } - } - - /** - * Returns a shallow copy of this {@code LinkedList}. (The elements - * themselves are not cloned.) - * - * @return a shallow copy of this {@code LinkedList} instance - */ - @Override - public Object clone() { - EnhancedLinkedList clone = superClone(); - - // Put clone into "virgin" state - clone.first = clone.last = null; - clone.size = 0; - clone.modCount = 0; - - // Initialize clone with our elements - for (Node x = first; x != null; x = x.next) - clone.add(x.item); - - return clone; - } - - /** - * Returns an array containing all of the elements in this list - * in proper sequence (from first to last element). - * - *

The returned array will be "safe" in that no references to it are - * maintained by this list. (In other words, this method must allocate - * a new array). The caller is thus free to modify the returned array. - * - *

This method acts as bridge between array-based and collection-based - * APIs. - * - * @return an array containing all of the elements in this list - * in proper sequence - */ - public Object[] toArray() { - Object[] result = new Object[size]; - int i = 0; - for (Node x = first; x != null; x = x.next) - result[i++] = x.item; - return result; - } - - /** - * Returns an array containing all of the elements in this list in - * proper sequence (from first to last element); the runtime type of - * the returned array is that of the specified array. If the list fits - * in the specified array, it is returned therein. Otherwise, a new - * array is allocated with the runtime type of the specified array and - * the size of this list. - * - *

If the list fits in the specified array with room to spare (i.e., - * the array has more elements than the list), the element in the array - * immediately following the end of the list is set to {@code null}. - * (This is useful in determining the length of the list only if - * the caller knows that the list does not contain any null elements.) - * - *

Like the {@link #toArray()} method, this method acts as bridge between - * array-based and collection-based APIs. Further, this method allows - * precise control over the runtime type of the output array, and may, - * under certain circumstances, be used to save allocation costs. - * - *

Suppose {@code x} is a list known to contain only strings. - * The following code can be used to dump the list into a newly - * allocated array of {@code String}: - * - *

-     *     String[] y = x.toArray(new String[0]);
- * - * Note that {@code toArray(new Object[0])} is identical in function to - * {@code toArray()}. - * - * @param a the array into which the elements of the list are to - * be stored, if it is big enough; otherwise, a new array of the - * same runtime type is allocated for this purpose. - * @return an array containing the elements of the list - * @throws ArrayStoreException if the runtime type of the specified array - * is not a supertype of the runtime type of every element in - * this list - * @throws NullPointerException if the specified array is null - */ - @SuppressWarnings("unchecked") - public T[] toArray(T[] a) { - if (a.length < size) - a = (T[])java.lang.reflect.Array.newInstance( - a.getClass().getComponentType(), size); - int i = 0; - Object[] result = a; - for (Node x = first; x != null; x = x.next) - result[i++] = x.item; - - if (a.length > size) - a[size] = null; - - return a; - } - - private static final long serialVersionUID = 876323262645176354L; - - /** - * Saves the state of this {@code LinkedList} instance to a stream - * (that is, serializes it). - * - * @serialData The size of the list (the number of elements it - * contains) is emitted (int), followed by all of its - * elements (each an Object) in the proper order. - */ - private void writeObject(java.io.ObjectOutputStream s) - throws java.io.IOException { - // Write out any hidden serialization magic - s.defaultWriteObject(); - - // Write out size - s.writeInt(size); - - // Write out all elements in the proper order. - for (Node x = first; x != null; x = x.next) - s.writeObject(x.item); - } - - /** - * Reconstitutes this {@code LinkedList} instance from a stream - * (that is, deserializes it). - */ - @SuppressWarnings("unchecked") - private void readObject(java.io.ObjectInputStream s) - throws java.io.IOException, ClassNotFoundException { - // Read in any hidden serialization magic - s.defaultReadObject(); - - // Read in size - int size = s.readInt(); - - // Read in all elements in the proper order. - for (int i = 0; i < size; i++) - linkLast((E)s.readObject()); - } - - /** - * Creates a late-binding - * and fail-fast {@link Spliterator} over the elements in this - * list. - * - *

The {@code Spliterator} reports {@link Spliterator#SIZED} and - * {@link Spliterator#ORDERED}. Overriding implementations should document - * the reporting of additional characteristic values. - * - * @implNote - * The {@code Spliterator} additionally reports {@link Spliterator#SUBSIZED} - * and implements {@code trySplit} to permit limited parallelism.. - * - * @return a {@code Spliterator} over the elements in this list - * @since 1.8 - */ - @Override - public Spliterator spliterator() { - return new LLSpliterator<>(this, -1, 0); - } - - /** A customized variant of Spliterators.IteratorSpliterator */ - static final class LLSpliterator implements Spliterator { - static final int BATCH_UNIT = 1 << 10; // batch array size increment - static final int MAX_BATCH = 1 << 25; // max batch array size; - final EnhancedLinkedList list; // null OK unless traversed - Node current; // current node; null until initialized - int est; // size estimate; -1 until first needed - int expectedModCount; // initialized when est set - int batch; // batch size for splits - - LLSpliterator(EnhancedLinkedList list, int est, int expectedModCount) { - this.list = list; - this.est = est; - this.expectedModCount = expectedModCount; - } - - int getEst() { - int s; // force initialization - final EnhancedLinkedList lst; - if ((s = est) < 0) { - if ((lst = list) == null) - s = est = 0; - else { - expectedModCount = lst.modCount; - current = lst.first; - s = est = lst.size; - } - } - return s; - } - - public long estimateSize() { return getEst(); } - - public Spliterator trySplit() { - Node p; - int s = getEst(); - if (s > 1 && (p = current) != null) { - int n = batch + BATCH_UNIT; - if (n > s) - n = s; - if (n > MAX_BATCH) - n = MAX_BATCH; - Object[] a = new Object[n]; - int j = 0; - do { a[j++] = p.item; } while ((p = p.next) != null && j < n); - current = p; - batch = j; - est = s - j; - return Spliterators.spliterator(a, 0, j, Spliterator.ORDERED); - } - return null; - } - - public void forEachRemaining(Consumer action) { - Node p; int n; - if (action == null) throw new NullPointerException(); - if ((n = getEst()) > 0 && (p = current) != null) { - current = null; - est = 0; - do { - E e = p.item; - p = p.next; - action.accept(e); - } while (p != null && --n > 0); - } - if (list.modCount != expectedModCount) - throw new ConcurrentModificationException(); - } - - public boolean tryAdvance(Consumer action) { - Node p; - if (action == null) throw new NullPointerException(); - if (getEst() > 0 && (p = current) != null) { - --est; - E e = p.item; - current = p.next; - action.accept(e); - if (list.modCount != expectedModCount) - throw new ConcurrentModificationException(); - return true; - } - return false; - } - - public int characteristics() { - return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED; - } - } - } diff --git a/src/main/kotlin/cc/maxmc/blastingcrisis/command/DebugCommand.kt b/src/main/kotlin/cc/maxmc/blastingcrisis/command/DebugCommand.kt index c93580d..dd4f50e 100644 --- a/src/main/kotlin/cc/maxmc/blastingcrisis/command/DebugCommand.kt +++ b/src/main/kotlin/cc/maxmc/blastingcrisis/command/DebugCommand.kt @@ -2,7 +2,6 @@ package cc.maxmc.blastingcrisis.command import cc.maxmc.blastingcrisis.game.Game import cc.maxmc.blastingcrisis.game.GameOreGenerator -import cc.maxmc.blastingcrisis.game.GamePlaceBreakRule import cc.maxmc.blastingcrisis.game.GamePlaceBreakRule.MatchResult import cc.maxmc.blastingcrisis.game.GameState import cc.maxmc.blastingcrisis.misc.Area @@ -18,10 +17,9 @@ import taboolib.common.platform.function.adaptCommandSender import taboolib.common.platform.function.getDataFolder import taboolib.module.configuration.Configuration import taboolib.platform.BukkitPlugin -import taboolib.platform.util.broadcast import taboolib.platform.util.sendActionBar import java.io.File -import java.util.UUID +import java.util.* import cc.maxmc.blastingcrisis.misc.debug as debuglog object DebugCommand { @@ -29,7 +27,7 @@ object DebugCommand { lateinit var villager: BEntityVillager var autoRespawn = false val builders = ArrayList() - private val init by lazy{ + private val init by lazy { // allow builders debuglog("init builder rule") GameManager.currentGame.placeBreakRule.addRuleFirst("builder") { (player, _, _, _) -> @@ -157,7 +155,7 @@ object DebugCommand { } literal("build_mode") { - execute { sender, _ ,_ -> + execute { sender, _, _ -> init if (builders.contains(sender.uniqueId)) { builders.remove(sender.uniqueId) diff --git a/src/main/kotlin/cc/maxmc/blastingcrisis/game/GamePlaceBreakRule.kt b/src/main/kotlin/cc/maxmc/blastingcrisis/game/GamePlaceBreakRule.kt index 2f89c30..d3be010 100644 --- a/src/main/kotlin/cc/maxmc/blastingcrisis/game/GamePlaceBreakRule.kt +++ b/src/main/kotlin/cc/maxmc/blastingcrisis/game/GamePlaceBreakRule.kt @@ -1,6 +1,5 @@ package cc.maxmc.blastingcrisis.game -import cc.maxmc.blastingcrisis.command.DebugCommand import cc.maxmc.blastingcrisis.game.GamePlaceBreakRule.ActionType.BREAK import cc.maxmc.blastingcrisis.game.GamePlaceBreakRule.ActionType.PLACE import cc.maxmc.blastingcrisis.misc.EnhancedLinkedList @@ -98,9 +97,9 @@ class GamePlaceBreakRule(val game: Game) { addRuleLast("allow_wall_conditional") { (player, actionType, loc, _) -> val team = player.team ?: return@addRuleLast MatchResult.DENY val isWall = game.teams.map { - it.teamInfo.wall.containsBlock(loc) - .also { result -> debug("area ${it.teamInfo.wall} contains $loc is $result") } - }.reduce { a, b -> a || b } + it.teamInfo.wall.containsBlock(loc) + .also { result -> debug("area ${it.teamInfo.wall} contains $loc is $result") } + }.reduce { a, b -> a || b } if (!isWall) return@addRuleLast MatchResult.DEFAULT val isHome = team.teamInfo.wall.containsBlock(loc) if ((actionType == BREAK) xor isHome) MatchResult.ALLOW else MatchResult.DENY @@ -111,9 +110,9 @@ class GamePlaceBreakRule(val game: Game) { if (type != XMaterial.TNT) return@addRuleFirst MatchResult.DEFAULT val team = player.team ?: return@addRuleFirst MatchResult.DENY val isHome = game.teams.map { - it.teamInfo.home.containsBlock(loc) - .also { result -> debug("area ${it.teamInfo.home} contains $loc is $result") } - }.reduce { a, b -> a || b } + it.teamInfo.home.containsBlock(loc) + .also { result -> debug("area ${it.teamInfo.home} contains $loc is $result") } + }.reduce { a, b -> a || b } if (!isHome) return@addRuleFirst MatchResult.DENY val isSelf = team.teamInfo.home.containsBlock(loc) if ((actionType == PLACE) xor isSelf) MatchResult.ALLOW else MatchResult.DENY diff --git a/src/main/kotlin/cc/maxmc/blastingcrisis/listener/GameListener.kt b/src/main/kotlin/cc/maxmc/blastingcrisis/listener/GameListener.kt index 5fbfcde..c146bae 100644 --- a/src/main/kotlin/cc/maxmc/blastingcrisis/listener/GameListener.kt +++ b/src/main/kotlin/cc/maxmc/blastingcrisis/listener/GameListener.kt @@ -96,7 +96,7 @@ object GameListener { GameManager.currentGame.respawnPlayer(respawnEvent.player) } -// @SubscribeEvent + // @SubscribeEvent fun protectDamageBeforeGame(damageEvent: EntityDamageEvent) { if (damageEvent.entity !is Player) return // ignore none player entity if (GameManager.currentGame.state.isStarted()) return diff --git a/src/main/kotlin/cc/maxmc/blastingcrisis/packet/BEntity.kt b/src/main/kotlin/cc/maxmc/blastingcrisis/packet/BEntity.kt index 2b9f515..2fbe639 100644 --- a/src/main/kotlin/cc/maxmc/blastingcrisis/packet/BEntity.kt +++ b/src/main/kotlin/cc/maxmc/blastingcrisis/packet/BEntity.kt @@ -7,7 +7,6 @@ import gnu.trove.map.hash.TIntObjectHashMap import net.minecraft.server.v1_8_R3.* import org.bukkit.Location import org.bukkit.entity.Player -import taboolib.common.platform.function.submit import taboolib.common.util.random import taboolib.library.reflex.Reflex.Companion.getProperty import taboolib.library.reflex.Reflex.Companion.setProperty diff --git a/src/main/kotlin/cc/maxmc/blastingcrisis/packet/BEntityVillager.kt b/src/main/kotlin/cc/maxmc/blastingcrisis/packet/BEntityVillager.kt index a3a6a73..8ac7fdd 100644 --- a/src/main/kotlin/cc/maxmc/blastingcrisis/packet/BEntityVillager.kt +++ b/src/main/kotlin/cc/maxmc/blastingcrisis/packet/BEntityVillager.kt @@ -31,7 +31,6 @@ class BEntityVillager private constructor(loc: Location) : BEntity(loc, 120) { } - override fun DataWatcher.initEntity() { a(6, 1.0f) // Health a(7, 0) // Potion Effect Color diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml index 5ee1350..be28a81 100644 --- a/src/main/resources/settings.yml +++ b/src/main/resources/settings.yml @@ -1,4 +1,3 @@ - # Time before game start # Unit: second time_to_start: 15