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 super E> 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 super E> 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 super E> 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 super E> 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