1
0

refactor: clean source code

This commit is contained in:
labalityowo
2022-07-07 10:09:42 +07:00
parent 49950087f5
commit de68079e8a
16487 changed files with 721393 additions and 227033 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,45 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mineplex</groupId>
<artifactId>mineplex-parent</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<artifactId>mineplex-core-common</artifactId>
<dependencies>
<dependency>
<groupId>com.labalityowo</groupId>
<artifactId>spigot</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mineplex-core-common-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.mineplex</groupId>
<artifactId>mineplex-serverdata</artifactId>
<version>dev-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>${project.basedir}</directory>
<includes>
<include>ascii.png</include>
</includes>
</resource>
</resources>
</build>
</project>

View File

@ -0,0 +1,57 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_Byte_Array} tag.
*/
public final class ByteArrayTag extends Tag {
private final byte[] value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public ByteArrayTag(byte[] value) {
super();
this.value = value;
}
@Override
public byte[] getValue() {
return value;
}
@Override
public String toString() {
StringBuilder hex = new StringBuilder();
for (byte b : value) {
String hexDigits = Integer.toHexString(b).toUpperCase();
if (hexDigits.length() == 1) {
hex.append("0");
}
hex.append(hexDigits).append(" ");
}
return "TAG_Byte_Array(" + hex + ")";
}
}

View File

@ -0,0 +1,49 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_Byte} tag.
*/
public final class ByteTag extends Tag {
private final byte value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public ByteTag(byte value) {
super();
this.value = value;
}
@Override
public Byte getValue() {
return value;
}
@Override
public String toString() {
return "TAG_Byte(" + value + ")";
}
}

View File

@ -0,0 +1,420 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The {@code TAG_Compound} tag.
*/
public final class CompoundTag extends Tag {
private final Map<String, Tag> value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public CompoundTag(Map<String, Tag> value) {
super();
this.value = Collections.unmodifiableMap(value);
}
/**
* Returns whether this compound tag contains the given key.
*
* @param key the given key
* @return true if the tag contains the given key
*/
public boolean containsKey(String key) {
return value.containsKey(key);
}
@Override
public Map<String, Tag> getValue() {
return value;
}
/**
* Return a new compound tag with the given values.
*
* @param value the value
* @return the new compound tag
*/
public CompoundTag setValue(Map<String, Tag> value) {
return new CompoundTag(value);
}
/**
* Create a compound tag builder.
*
* @return the builder
*/
public CompoundTagBuilder createBuilder() {
return new CompoundTagBuilder(new HashMap<String, Tag>(value));
}
/**
* Get a byte array named with the given key.
*
* <p>If the key does not exist or its value is not a byte array tag,
* then an empty byte array will be returned.</p>
*
* @param key the key
* @return a byte array
*/
public byte[] getByteArray(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteArrayTag) {
return ((ByteArrayTag) tag).getValue();
} else {
return new byte[0];
}
}
/**
* Get a byte named with the given key.
*
* <p>If the key does not exist or its value is not a byte tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a byte
*/
public byte getByte(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else {
return (byte) 0;
}
}
/**
* Get a double named with the given key.
*
* <p>If the key does not exist or its value is not a double tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a double
*/
public double getDouble(String key) {
Tag tag = value.get(key);
if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a double named with the given key, even if it's another
* type of number.
*
* <p>If the key does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a double
*/
public double asDouble(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a float named with the given key.
*
* <p>If the key does not exist or its value is not a float tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a float
*/
public float getFloat(String key) {
Tag tag = value.get(key);
if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a {@code int[]} named with the given key.
*
* <p>If the key does not exist or its value is not an int array tag,
* then an empty array will be returned.</p>
*
* @param key the key
* @return an int array
*/
public int[] getIntArray(String key) {
Tag tag = value.get(key);
if (tag instanceof IntArrayTag) {
return ((IntArrayTag) tag).getValue();
} else {
return new int[0];
}
}
/**
* Get an int named with the given key.
*
* <p>If the key does not exist or its value is not an int tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return an int
*/
public int getInt(String key) {
Tag tag = value.get(key);
if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get an int named with the given key, even if it's another
* type of number.
*
* <p>If the key does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return an int
*/
public int asInt(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue().intValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().intValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().intValue();
} else {
return 0;
}
}
/**
* Get a list of tags named with the given key.
*
* <p>If the key does not exist or its value is not a list tag,
* then an empty list will be returned.</p>
*
* @param key the key
* @return a list of tags
*/
public List<Tag> getList(String key) {
Tag tag = value.get(key);
if (tag instanceof ListTag) {
return ((ListTag) tag).getValue();
} else {
return Collections.emptyList();
}
}
/**
* Get a {@code TagList} named with the given key.
*
* <p>If the key does not exist or its value is not a list tag,
* then an empty tag list will be returned.</p>
*
* @param key the key
* @return a tag list instance
*/
public ListTag getListTag(String key) {
Tag tag = value.get(key);
if (tag instanceof ListTag) {
return (ListTag) tag;
} else {
return new ListTag(StringTag.class, Collections.<Tag>emptyList());
}
}
/**
* Get a list of tags named with the given key.
*
* <p>If the key does not exist or its value is not a list tag,
* then an empty list will be returned. If the given key references
* a list but the list of of a different type, then an empty
* list will also be returned.</p>
*
* @param key the key
* @param listType the class of the contained type
* @return a list of tags
* @param <T> the type of list
*/
@SuppressWarnings("unchecked")
public <T extends Tag> List<T> getList(String key, Class<T> listType) {
Tag tag = value.get(key);
if (tag instanceof ListTag) {
ListTag listTag = (ListTag) tag;
if (listTag.getType().equals(listType)) {
return (List<T>) listTag.getValue();
} else {
return Collections.emptyList();
}
} else {
return Collections.emptyList();
}
}
/**
* Get a long named with the given key.
*
* <p>If the key does not exist or its value is not a long tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a long
*/
public long getLong(String key) {
Tag tag = value.get(key);
if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else {
return 0L;
}
}
/**
* Get a long named with the given key, even if it's another
* type of number.
*
* <p>If the key does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a long
*/
public long asLong(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().longValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().longValue();
} else {
return 0L;
}
}
/**
* Get a short named with the given key.
*
* <p>If the key does not exist or its value is not a short tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a short
*/
public short getShort(String key) {
Tag tag = value.get(key);
if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a string named with the given key.
*
* <p>If the key does not exist or its value is not a string tag,
* then {@code ""} will be returned.</p>
*
* @param key the key
* @return a string
*/
public String getString(String key) {
Tag tag = value.get(key);
if (tag instanceof StringTag) {
return ((StringTag) tag).getValue();
} else {
return "";
}
}
@Override
public String toString() {
StringBuilder bldr = new StringBuilder();
bldr.append("TAG_Compound").append(": ").append(value.size()).append(" entries\r\n{\r\n");
for (Map.Entry<String, Tag> entry : value.entrySet()) {
bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
}
bldr.append("}");
return bldr.toString();
}
}

View File

@ -0,0 +1,204 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Helps create compound tags.
*/
public class CompoundTagBuilder {
private final Map<String, Tag> entries;
/**
* Create a new instance.
*/
CompoundTagBuilder() {
this.entries = new HashMap<String, Tag>();
}
/**
* Create a new instance and use the given map (which will be modified).
*
* @param value the value
*/
CompoundTagBuilder(Map<String, Tag> value) {
checkNotNull(value);
this.entries = value;
}
/**
* Put the given key and tag into the compound tag.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder put(String key, Tag value) {
checkNotNull(key);
checkNotNull(value);
entries.put(key, value);
return this;
}
/**
* Put the given key and value into the compound tag as a
* {@code ByteArrayTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putByteArray(String key, byte[] value) {
return put(key, new ByteArrayTag(value));
}
/**
* Put the given key and value into the compound tag as a
* {@code ByteTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putByte(String key, byte value) {
return put(key, new ByteTag(value));
}
/**
* Put the given key and value into the compound tag as a
* {@code DoubleTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putDouble(String key, double value) {
return put(key, new DoubleTag(value));
}
/**
* Put the given key and value into the compound tag as a
* {@code FloatTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putFloat(String key, float value) {
return put(key, new FloatTag(value));
}
/**
* Put the given key and value into the compound tag as a
* {@code IntArrayTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putIntArray(String key, int[] value) {
return put(key, new IntArrayTag(value));
}
/**
* Put the given key and value into the compound tag as an {@code IntTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putInt(String key, int value) {
return put(key, new IntTag(value));
}
/**
* Put the given key and value into the compound tag as a
* {@code LongTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putLong(String key, long value) {
return put(key, new LongTag(value));
}
/**
* Put the given key and value into the compound tag as a
* {@code ShortTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putShort(String key, short value) {
return put(key, new ShortTag(value));
}
/**
* Put the given key and value into the compound tag as a
* {@code StringTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putString(String key, String value) {
return put(key, new StringTag(value));
}
/**
* Put all the entries from the given map into this map.
*
* @param value the map of tags
* @return this object
*/
public CompoundTagBuilder putAll(Map<String, ? extends Tag> value) {
checkNotNull(value);
for (Map.Entry<String, ? extends Tag> entry : value.entrySet()) {
put(entry.getKey(), entry.getValue());
}
return this;
}
/**
* Build an unnamed compound tag with this builder's entries.
*
* @return the new compound tag
*/
public CompoundTag build() {
return new CompoundTag(new HashMap<String, Tag>(entries));
}
/**
* Create a new builder instance.
*
* @return a new builder
*/
public static CompoundTagBuilder create() {
return new CompoundTagBuilder();
}
}

View File

@ -0,0 +1,50 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_Double} tag.
*
*/
public final class DoubleTag extends Tag {
private final double value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public DoubleTag(double value) {
super();
this.value = value;
}
@Override
public Double getValue() {
return value;
}
@Override
public String toString() {
return "TAG_Double(" + value + ")";
}
}

View File

@ -0,0 +1,37 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_End} tag.
*/
public final class EndTag extends Tag {
@Override
public Object getValue() {
return null;
}
@Override
public String toString() {
return "TAG_End";
}
}

View File

@ -0,0 +1,49 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_Float} tag.
*/
public final class FloatTag extends Tag {
private final float value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public FloatTag(float value) {
super();
this.value = value;
}
@Override
public Float getValue() {
return value;
}
@Override
public String toString() {
return "TAG_Float(" + value + ")";
}
}

View File

@ -0,0 +1,60 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* The {@code TAG_Int_Array} tag.
*/
public final class IntArrayTag extends Tag {
private final int[] value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public IntArrayTag(int[] value) {
super();
checkNotNull(value);
this.value = value;
}
@Override
public int[] getValue() {
return value;
}
@Override
public String toString() {
StringBuilder hex = new StringBuilder();
for (int b : value) {
String hexDigits = Integer.toHexString(b).toUpperCase();
if (hexDigits.length() == 1) {
hex.append("0");
}
hex.append(hexDigits).append(" ");
}
return "TAG_Int_Array(" + hex + ")";
}
}

View File

@ -0,0 +1,49 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_Int} tag.
*/
public final class IntTag extends Tag {
private final int value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public IntTag(int value) {
super();
this.value = value;
}
@Override
public Integer getValue() {
return value;
}
@Override
public String toString() {
return "TAG_Int(" + value + ")";
}
}

View File

@ -0,0 +1,431 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* The {@code TAG_List} tag.
*/
public final class ListTag extends Tag {
private final Class<? extends Tag> type;
private final List<Tag> value;
/**
* Creates the tag with an empty name.
*
* @param type the type of tag
* @param value the value of the tag
*/
public ListTag(Class<? extends Tag> type, List<? extends Tag> value) {
super();
checkNotNull(value);
this.type = type;
this.value = Collections.unmodifiableList(value);
}
/**
* Gets the type of item in this list.
*
* @return The type of item in this list.
*/
public Class<? extends Tag> getType() {
return type;
}
@Override
public List<Tag> getValue() {
return value;
}
/**
* Create a new list tag with this tag's name and type.
*
* @param list the new list
* @return a new list tag
*/
public ListTag setValue(List<Tag> list) {
return new ListTag(getType(), list);
}
/**
* Get the tag if it exists at the given index.
*
* @param index the index
* @return the tag or null
*/
@Nullable
public Tag getIfExists(int index) {
try {
return value.get(index);
} catch (NoSuchElementException e) {
return null;
}
}
/**
* Get a byte array named with the given index.
*
* <p>If the index does not exist or its value is not a byte array tag,
* then an empty byte array will be returned.</p>
*
* @param index the index
* @return a byte array
*/
public byte[] getByteArray(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ByteArrayTag) {
return ((ByteArrayTag) tag).getValue();
} else {
return new byte[0];
}
}
/**
* Get a byte named with the given index.
*
* <p>If the index does not exist or its value is not a byte tag,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return a byte
*/
public byte getByte(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else {
return (byte) 0;
}
}
/**
* Get a double named with the given index.
*
* <p>If the index does not exist or its value is not a double tag,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return a double
*/
public double getDouble(int index) {
Tag tag = getIfExists(index);
if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a double named with the given index, even if it's another
* type of number.
*
* <p>If the index does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return a double
*/
public double asDouble(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a float named with the given index.
*
* <p>If the index does not exist or its value is not a float tag,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return a float
*/
public float getFloat(int index) {
Tag tag = getIfExists(index);
if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a {@code int[]} named with the given index.
*
* <p>If the index does not exist or its value is not an int array tag,
* then an empty array will be returned.</p>
*
* @param index the index
* @return an int array
*/
public int[] getIntArray(int index) {
Tag tag = getIfExists(index);
if (tag instanceof IntArrayTag) {
return ((IntArrayTag) tag).getValue();
} else {
return new int[0];
}
}
/**
* Get an int named with the given index.
*
* <p>If the index does not exist or its value is not an int tag,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return an int
*/
public int getInt(int index) {
Tag tag = getIfExists(index);
if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get an int named with the given index, even if it's another
* type of number.
*
* <p>If the index does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return an int
*/
public int asInt(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue().intValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().intValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().intValue();
} else {
return 0;
}
}
/**
* Get a list of tags named with the given index.
*
* <p>If the index does not exist or its value is not a list tag,
* then an empty list will be returned.</p>
*
* @param index the index
* @return a list of tags
*/
public List<Tag> getList(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ListTag) {
return ((ListTag) tag).getValue();
} else {
return Collections.emptyList();
}
}
/**
* Get a {@code TagList} named with the given index.
*
* <p>If the index does not exist or its value is not a list tag,
* then an empty tag list will be returned.</p>
*
* @param index the index
* @return a tag list instance
*/
public ListTag getListTag(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ListTag) {
return (ListTag) tag;
} else {
return new ListTag(StringTag.class, Collections.<Tag>emptyList());
}
}
/**
* Get a list of tags named with the given index.
*
* <p>If the index does not exist or its value is not a list tag,
* then an empty list will be returned. If the given index references
* a list but the list of of a different type, then an empty
* list will also be returned.</p>
*
* @param index the index
* @param listType the class of the contained type
* @return a list of tags
* @param <T> the NBT type
*/
@SuppressWarnings("unchecked")
public <T extends Tag> List<T> getList(int index, Class<T> listType) {
Tag tag = getIfExists(index);
if (tag instanceof ListTag) {
ListTag listTag = (ListTag) tag;
if (listTag.getType().equals(listType)) {
return (List<T>) listTag.getValue();
} else {
return Collections.emptyList();
}
} else {
return Collections.emptyList();
}
}
/**
* Get a long named with the given index.
*
* <p>If the index does not exist or its value is not a long tag,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return a long
*/
public long getLong(int index) {
Tag tag = getIfExists(index);
if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else {
return 0L;
}
}
/**
* Get a long named with the given index, even if it's another
* type of number.
*
* <p>If the index does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return a long
*/
public long asLong(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().longValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().longValue();
} else {
return 0;
}
}
/**
* Get a short named with the given index.
*
* <p>If the index does not exist or its value is not a short tag,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return a short
*/
public short getShort(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a string named with the given index.
*
* <p>If the index does not exist or its value is not a string tag,
* then {@code ""} will be returned.</p>
*
* @param index the index
* @return a string
*/
public String getString(int index) {
Tag tag = getIfExists(index);
if (tag instanceof StringTag) {
return ((StringTag) tag).getValue();
} else {
return "";
}
}
@Override
public String toString() {
StringBuilder bldr = new StringBuilder();
bldr.append("TAG_List").append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n");
for (Tag t : value) {
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
}
bldr.append("}");
return bldr.toString();
}
}

View File

@ -0,0 +1,119 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Helps create list tags.
*/
public class ListTagBuilder {
private final Class<? extends Tag> type;
private final List<Tag> entries;
/**
* Create a new instance.
*
* @param type of tag contained in this list
*/
ListTagBuilder(Class<? extends Tag> type) {
checkNotNull(type);
this.type = type;
this.entries = new ArrayList<Tag>();
}
/**
* Add the given tag.
*
* @param value the tag
* @return this object
*/
public ListTagBuilder add(Tag value) {
checkNotNull(value);
if (!type.isInstance(value)) {
throw new IllegalArgumentException(value.getClass().getCanonicalName() + " is not of expected type " + type.getCanonicalName());
}
entries.add(value);
return this;
}
/**
* Add all the tags in the given list.
*
* @param value a list of tags
* @return this object
*/
public ListTagBuilder addAll(Collection<? extends Tag> value) {
checkNotNull(value);
for (Tag v : value) {
add(v);
}
return this;
}
/**
* Build an unnamed list tag with this builder's entries.
*
* @return the new list tag
*/
public ListTag build() {
return new ListTag(type, new ArrayList<Tag>(entries));
}
/**
* Create a new builder instance.
*
* @return a new builder
*/
public static ListTagBuilder create(Class<? extends Tag> type) {
return new ListTagBuilder(type);
}
/**
* Create a new builder instance.
*
* @return a new builder
*/
public static <T extends Tag> ListTagBuilder createWith(T ... entries) {
checkNotNull(entries);
if (entries.length == 0) {
throw new IllegalArgumentException("This method needs an array of at least one entry");
}
Class<? extends Tag> type = entries[0].getClass();
for (int i = 1; i < entries.length; i++) {
if (!type.isInstance(entries[i])) {
throw new IllegalArgumentException("An array of different tag types was provided");
}
}
ListTagBuilder builder = new ListTagBuilder(type);
builder.addAll(Arrays.asList(entries));
return builder;
}
}

View File

@ -0,0 +1,50 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_Long} tag.
*
*/
public final class LongTag extends Tag {
private final long value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public LongTag(long value) {
super();
this.value = value;
}
@Override
public Long getValue() {
return value;
}
@Override
public String toString() {
return "TAG_Long(" + value + ")";
}
}

View File

@ -0,0 +1,81 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import java.nio.charset.Charset;
/**
* A class which holds constant values.
*/
public final class NBTConstants {
public static final Charset CHARSET = Charset.forName("UTF-8");
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2,
TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6,
TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9,
TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11;
/**
* Default private constructor.
*/
private NBTConstants() {
}
/**
* Convert a type ID to its corresponding {@link Tag} class.
*
* @param id type ID
* @return tag class
* @throws IllegalArgumentException thrown if the tag ID is not valid
*/
public static Class<? extends Tag> getClassFromType(int id) {
switch (id) {
case TYPE_END:
return EndTag.class;
case TYPE_BYTE:
return ByteTag.class;
case TYPE_SHORT:
return ShortTag.class;
case TYPE_INT:
return IntTag.class;
case TYPE_LONG:
return LongTag.class;
case TYPE_FLOAT:
return FloatTag.class;
case TYPE_DOUBLE:
return DoubleTag.class;
case TYPE_BYTE_ARRAY:
return ByteArrayTag.class;
case TYPE_STRING:
return StringTag.class;
case TYPE_LIST:
return ListTag.class;
case TYPE_COMPOUND:
return CompoundTag.class;
case TYPE_INT_ARRAY:
return IntArrayTag.class;
default:
throw new IllegalArgumentException("Unknown tag type ID of " + id);
}
}
}

View File

@ -0,0 +1,171 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* This class reads <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
* streams, and produces an object graph of subclasses of the {@code Tag}
* object.
*
* <p>The NBT format was created by Markus Persson, and the specification may be
* found at <a href="http://www.minecraft.net/docs/NBT.txt">
* http://www.minecraft.net/docs/NBT.txt</a>.</p>
*/
public final class NBTInputStream implements Closeable {
private final DataInputStream is;
/**
* Creates a new {@code NBTInputStream}, which will source its data
* from the specified input stream.
*
* @param is the input stream
* @throws IOException if an I/O error occurs
*/
public NBTInputStream(InputStream is) throws IOException {
this.is = new DataInputStream(is);
}
/**
* Reads an NBT tag from the stream.
*
* @return The tag that was read.
* @throws IOException if an I/O error occurs.
*/
public NamedTag readNamedTag() throws IOException {
return readNamedTag(0);
}
/**
* Reads an NBT from the stream.
*
* @param depth the depth of this tag
* @return The tag that was read.
* @throws IOException if an I/O error occurs.
*/
private NamedTag readNamedTag(int depth) throws IOException {
int type = is.readByte() & 0xFF;
String name;
if (type != NBTConstants.TYPE_END) {
int nameLength = is.readShort() & 0xFFFF;
byte[] nameBytes = new byte[nameLength];
is.readFully(nameBytes);
name = new String(nameBytes, NBTConstants.CHARSET);
} else {
name = "";
}
return new NamedTag(name, readTagPayload(type, depth));
}
/**
* Reads the payload of a tag given the type.
*
* @param type the type
* @param depth the depth
* @return the tag
* @throws IOException if an I/O error occurs.
*/
private Tag readTagPayload(int type, int depth) throws IOException {
switch (type) {
case NBTConstants.TYPE_END:
if (depth == 0) {
throw new IOException(
"TAG_End found without a TAG_Compound/TAG_List tag preceding it.");
} else {
return new EndTag();
}
case NBTConstants.TYPE_BYTE:
return new ByteTag(is.readByte());
case NBTConstants.TYPE_SHORT:
return new ShortTag(is.readShort());
case NBTConstants.TYPE_INT:
return new IntTag(is.readInt());
case NBTConstants.TYPE_LONG:
return new LongTag(is.readLong());
case NBTConstants.TYPE_FLOAT:
return new FloatTag(is.readFloat());
case NBTConstants.TYPE_DOUBLE:
return new DoubleTag(is.readDouble());
case NBTConstants.TYPE_BYTE_ARRAY:
int length = is.readInt();
byte[] bytes = new byte[length];
is.readFully(bytes);
return new ByteArrayTag(bytes);
case NBTConstants.TYPE_STRING:
length = is.readShort();
bytes = new byte[length];
is.readFully(bytes);
return new StringTag(new String(bytes, NBTConstants.CHARSET));
case NBTConstants.TYPE_LIST:
int childType = is.readByte();
length = is.readInt();
List<Tag> tagList = new ArrayList<Tag>();
for (int i = 0; i < length; ++i) {
Tag tag = readTagPayload(childType, depth + 1);
if (tag instanceof EndTag) {
throw new IOException("TAG_End not permitted in a list.");
}
tagList.add(tag);
}
return new ListTag(NBTUtils.getTypeClass(childType), tagList);
case NBTConstants.TYPE_COMPOUND:
Map<String, Tag> tagMap = new HashMap<String, Tag>();
while (true) {
NamedTag namedTag = readNamedTag(depth + 1);
Tag tag = namedTag.getTag();
if (tag instanceof EndTag) {
break;
} else {
tagMap.put(namedTag.getName(), tag);
}
}
return new CompoundTag(tagMap);
case NBTConstants.TYPE_INT_ARRAY:
length = is.readInt();
int[] data = new int[length];
for (int i = 0; i < length; i++) {
data[i] = is.readInt();
}
return new IntArrayTag(data);
default:
throw new IOException("Invalid tag type: " + type + ".");
}
}
@Override
public void close() throws IOException {
is.close();
}
}

View File

@ -0,0 +1,294 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import java.io.Closeable;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* This class writes <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
* {@code Tag} objects to an underlying {@code OutputStream}.
*
* <p>The NBT format was created by Markus Persson, and the specification may be
* found at <a href="http://www.minecraft.net/docs/NBT.txt">
* http://www.minecraft.net/docs/NBT.txt</a>.</p>
*/
public final class NBTOutputStream implements Closeable {
/**
* The output stream.
*/
private final DataOutputStream os;
/**
* Creates a new {@code NBTOutputStream}, which will write data to the
* specified underlying output stream.
*
* @param os
* The output stream.
* @throws IOException
* if an I/O error occurs.
*/
public NBTOutputStream(OutputStream os) throws IOException {
this.os = new DataOutputStream(os);
}
/**
* Writes a tag.
*
* @param tag
* The tag to write.
* @throws IOException
* if an I/O error occurs.
*/
public void writeNamedTag(String name, Tag tag) throws IOException {
checkNotNull(name);
checkNotNull(tag);
int type = NBTUtils.getTypeCode(tag.getClass());
byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
os.writeByte(type);
os.writeShort(nameBytes.length);
os.write(nameBytes);
if (type == NBTConstants.TYPE_END) {
throw new IOException("Named TAG_End not permitted.");
}
writeTagPayload(tag);
}
/**
* Writes tag payload.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeTagPayload(Tag tag) throws IOException {
int type = NBTUtils.getTypeCode(tag.getClass());
switch (type) {
case NBTConstants.TYPE_END:
writeEndTagPayload((EndTag) tag);
break;
case NBTConstants.TYPE_BYTE:
writeByteTagPayload((ByteTag) tag);
break;
case NBTConstants.TYPE_SHORT:
writeShortTagPayload((ShortTag) tag);
break;
case NBTConstants.TYPE_INT:
writeIntTagPayload((IntTag) tag);
break;
case NBTConstants.TYPE_LONG:
writeLongTagPayload((LongTag) tag);
break;
case NBTConstants.TYPE_FLOAT:
writeFloatTagPayload((FloatTag) tag);
break;
case NBTConstants.TYPE_DOUBLE:
writeDoubleTagPayload((DoubleTag) tag);
break;
case NBTConstants.TYPE_BYTE_ARRAY:
writeByteArrayTagPayload((ByteArrayTag) tag);
break;
case NBTConstants.TYPE_STRING:
writeStringTagPayload((StringTag) tag);
break;
case NBTConstants.TYPE_LIST:
writeListTagPayload((ListTag) tag);
break;
case NBTConstants.TYPE_COMPOUND:
writeCompoundTagPayload((CompoundTag) tag);
break;
case NBTConstants.TYPE_INT_ARRAY:
writeIntArrayTagPayload((IntArrayTag) tag);
break;
default:
throw new IOException("Invalid tag type: " + type + ".");
}
}
/**
* Writes a {@code TAG_Byte} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeByteTagPayload(ByteTag tag) throws IOException {
os.writeByte(tag.getValue());
}
/**
* Writes a {@code TAG_Byte_Array} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeByteArrayTagPayload(ByteArrayTag tag) throws IOException {
byte[] bytes = tag.getValue();
os.writeInt(bytes.length);
os.write(bytes);
}
/**
* Writes a {@code TAG_Compound} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeCompoundTagPayload(CompoundTag tag) throws IOException {
for (Map.Entry<String, Tag> entry : tag.getValue().entrySet()) {
writeNamedTag(entry.getKey(), entry.getValue());
}
os.writeByte((byte) 0); // end tag - better way?
}
/**
* Writes a {@code TAG_List} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeListTagPayload(ListTag tag) throws IOException {
Class<? extends Tag> clazz = tag.getType();
List<Tag> tags = tag.getValue();
int size = tags.size();
os.writeByte(NBTUtils.getTypeCode(clazz));
os.writeInt(size);
for (Tag tag1 : tags) {
writeTagPayload(tag1);
}
}
/**
* Writes a {@code TAG_String} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeStringTagPayload(StringTag tag) throws IOException {
byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET);
os.writeShort(bytes.length);
os.write(bytes);
}
/**
* Writes a {@code TAG_Double} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeDoubleTagPayload(DoubleTag tag) throws IOException {
os.writeDouble(tag.getValue());
}
/**
* Writes a {@code TAG_Float} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeFloatTagPayload(FloatTag tag) throws IOException {
os.writeFloat(tag.getValue());
}
/**
* Writes a {@code TAG_Long} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeLongTagPayload(LongTag tag) throws IOException {
os.writeLong(tag.getValue());
}
/**
* Writes a {@code TAG_Int} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeIntTagPayload(IntTag tag) throws IOException {
os.writeInt(tag.getValue());
}
/**
* Writes a {@code TAG_Short} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeShortTagPayload(ShortTag tag) throws IOException {
os.writeShort(tag.getValue());
}
/**
* Writes a {@code TAG_Empty} tag.
*
* @param tag the tag
*/
private void writeEndTagPayload(EndTag tag) {
/* empty */
}
private void writeIntArrayTagPayload(IntArrayTag tag) throws IOException {
int[] data = tag.getValue();
os.writeInt(data.length);
for (int aData : data) {
os.writeInt(aData);
}
}
@Override
public void close() throws IOException {
os.close();
}
}

View File

@ -0,0 +1,441 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.NBTBase;
import net.minecraft.server.v1_8_R3.NBTTagByte;
import net.minecraft.server.v1_8_R3.NBTTagByteArray;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagDouble;
import net.minecraft.server.v1_8_R3.NBTTagEnd;
import net.minecraft.server.v1_8_R3.NBTTagFloat;
import net.minecraft.server.v1_8_R3.NBTTagInt;
import net.minecraft.server.v1_8_R3.NBTTagIntArray;
import net.minecraft.server.v1_8_R3.NBTTagList;
import net.minecraft.server.v1_8_R3.NBTTagLong;
import net.minecraft.server.v1_8_R3.NBTTagShort;
import net.minecraft.server.v1_8_R3.NBTTagString;
/**
* A class which contains NBT-related utility methods.
*
*/
public final class NBTUtils {
/**
* Default private constructor.
*/
private NBTUtils() {
}
/**
* Gets the type name of a tag.
*
* @param clazz the tag class
* @return The type name.
*/
public static String getTypeName(Class<? extends Tag> clazz) {
if (clazz.equals(ByteArrayTag.class)) {
return "TAG_Byte_Array";
} else if (clazz.equals(ByteTag.class)) {
return "TAG_Byte";
} else if (clazz.equals(CompoundTag.class)) {
return "TAG_Compound";
} else if (clazz.equals(DoubleTag.class)) {
return "TAG_Double";
} else if (clazz.equals(EndTag.class)) {
return "TAG_End";
} else if (clazz.equals(FloatTag.class)) {
return "TAG_Float";
} else if (clazz.equals(IntTag.class)) {
return "TAG_Int";
} else if (clazz.equals(ListTag.class)) {
return "TAG_List";
} else if (clazz.equals(LongTag.class)) {
return "TAG_Long";
} else if (clazz.equals(ShortTag.class)) {
return "TAG_Short";
} else if (clazz.equals(StringTag.class)) {
return "TAG_String";
} else if (clazz.equals(IntArrayTag.class)) {
return "TAG_Int_Array";
} else {
throw new IllegalArgumentException("Invalid tag classs ("
+ clazz.getName() + ").");
}
}
/**
* Gets the type code of a tag class.
*
* @param clazz the tag class
* @return The type code.
* @throws IllegalArgumentException if the tag class is invalid.
*/
public static int getTypeCode(Class<? extends Tag> clazz) {
if (clazz.equals(ByteArrayTag.class)) {
return NBTConstants.TYPE_BYTE_ARRAY;
} else if (clazz.equals(ByteTag.class)) {
return NBTConstants.TYPE_BYTE;
} else if (clazz.equals(CompoundTag.class)) {
return NBTConstants.TYPE_COMPOUND;
} else if (clazz.equals(DoubleTag.class)) {
return NBTConstants.TYPE_DOUBLE;
} else if (clazz.equals(EndTag.class)) {
return NBTConstants.TYPE_END;
} else if (clazz.equals(FloatTag.class)) {
return NBTConstants.TYPE_FLOAT;
} else if (clazz.equals(IntTag.class)) {
return NBTConstants.TYPE_INT;
} else if (clazz.equals(ListTag.class)) {
return NBTConstants.TYPE_LIST;
} else if (clazz.equals(LongTag.class)) {
return NBTConstants.TYPE_LONG;
} else if (clazz.equals(ShortTag.class)) {
return NBTConstants.TYPE_SHORT;
} else if (clazz.equals(StringTag.class)) {
return NBTConstants.TYPE_STRING;
} else if (clazz.equals(IntArrayTag.class)) {
return NBTConstants.TYPE_INT_ARRAY;
} else {
throw new IllegalArgumentException("Invalid tag classs ("
+ clazz.getName() + ").");
}
}
/**
* Gets the class of a type of tag.
*
* @param type the type
* @return The class.
* @throws IllegalArgumentException if the tag type is invalid.
*/
public static Class<? extends Tag> getTypeClass(int type) {
switch (type) {
case NBTConstants.TYPE_END:
return EndTag.class;
case NBTConstants.TYPE_BYTE:
return ByteTag.class;
case NBTConstants.TYPE_SHORT:
return ShortTag.class;
case NBTConstants.TYPE_INT:
return IntTag.class;
case NBTConstants.TYPE_LONG:
return LongTag.class;
case NBTConstants.TYPE_FLOAT:
return FloatTag.class;
case NBTConstants.TYPE_DOUBLE:
return DoubleTag.class;
case NBTConstants.TYPE_BYTE_ARRAY:
return ByteArrayTag.class;
case NBTConstants.TYPE_STRING:
return StringTag.class;
case NBTConstants.TYPE_LIST:
return ListTag.class;
case NBTConstants.TYPE_COMPOUND:
return CompoundTag.class;
case NBTConstants.TYPE_INT_ARRAY:
return IntArrayTag.class;
default:
throw new IllegalArgumentException("Invalid tag type : " + type
+ ".");
}
}
/**
* Get child tag of a NBT structure.
*
* @param items the map to read from
* @param key the key to look for
* @param expected the expected NBT class type
* @return child tag
* @throws IllegalArgumentException
*/
public static <T extends Tag> T getChildTag(Map<String, Tag> items, String key, Class<T> expected) throws IllegalArgumentException {
if (!items.containsKey(key)) {
throw new IllegalArgumentException("Missing a \"" + key + "\" tag");
}
Tag tag = items.get(key);
if (!expected.isInstance(tag)) {
throw new IllegalArgumentException(key + " tag is not of tag type " + expected.getName());
}
return expected.cast(tag);
}
public static byte[] toBytesCompressed(String name, CompoundTag tag)
{
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
try (NBTOutputStream nbtStream = new NBTOutputStream(new GZIPOutputStream(byteStream)))
{
nbtStream.writeNamedTag(name, tag);
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
return byteStream.toByteArray();
}
public static NamedTag getFromBytesCompressed(byte[] bytes)
{
try (NBTInputStream stream = new NBTInputStream(new GZIPInputStream(new ByteArrayInputStream(bytes)));)
{
return stream.readNamedTag();
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}
public static NBTBase toNative(Tag tag) {
if (tag instanceof IntArrayTag) {
return toNative((IntArrayTag) tag);
} else if (tag instanceof ListTag) {
return toNative((ListTag) tag);
} else if (tag instanceof LongTag) {
return toNative((LongTag) tag);
} else if (tag instanceof StringTag) {
return toNative((StringTag) tag);
} else if (tag instanceof IntTag) {
return toNative((IntTag) tag);
} else if (tag instanceof ByteTag) {
return toNative((ByteTag) tag);
} else if (tag instanceof ByteArrayTag) {
return toNative((ByteArrayTag) tag);
} else if (tag instanceof CompoundTag) {
return toNative((CompoundTag) tag);
} else if (tag instanceof FloatTag) {
return toNative((FloatTag) tag);
} else if (tag instanceof ShortTag) {
return toNative((ShortTag) tag);
} else if (tag instanceof DoubleTag) {
return toNative((DoubleTag) tag);
} else {
throw new IllegalArgumentException("Can't convert tag of type " + tag.getClass().getCanonicalName());
}
}
public static NBTTagIntArray toNative(IntArrayTag tag) {
int[] value = tag.getValue();
return new NBTTagIntArray(Arrays.copyOf(value, value.length));
}
public static NBTTagList toNative(ListTag tag) {
NBTTagList list = new NBTTagList();
for (Tag child : tag.getValue()) {
if (child instanceof EndTag) {
continue;
}
list.add(toNative(child));
}
return list;
}
public static NBTTagLong toNative(LongTag tag) {
return new NBTTagLong(tag.getValue());
}
public static NBTTagString toNative(StringTag tag) {
return new NBTTagString(tag.getValue());
}
public static NBTTagInt toNative(IntTag tag) {
return new NBTTagInt(tag.getValue());
}
public static NBTTagByte toNative(ByteTag tag) {
return new NBTTagByte(tag.getValue());
}
public static NBTTagByteArray toNative(ByteArrayTag tag) {
byte[] value = tag.getValue();
return new NBTTagByteArray(Arrays.copyOf(value, value.length));
}
public static NBTTagCompound toNative(CompoundTag tag) {
NBTTagCompound compound = new NBTTagCompound();
for (Entry<String, Tag> child : tag.getValue().entrySet()) {
compound.set(child.getKey(), toNative(child.getValue()));
}
return compound;
}
public static NBTTagFloat toNative(FloatTag tag) {
return new NBTTagFloat(tag.getValue());
}
public static NBTTagShort toNative(ShortTag tag) {
return new NBTTagShort(tag.getValue());
}
public static NBTTagDouble toNative(DoubleTag tag) {
return new NBTTagDouble(tag.getValue());
}
public static Tag fromNative(NBTBase other) {
if (other instanceof NBTTagIntArray) {
return fromNative((NBTTagIntArray) other);
} else if (other instanceof NBTTagList) {
return fromNative((NBTTagList) other);
} else if (other instanceof NBTTagEnd) {
return fromNative((NBTTagEnd) other);
} else if (other instanceof NBTTagLong) {
return fromNative((NBTTagLong) other);
} else if (other instanceof NBTTagString) {
return fromNative((NBTTagString) other);
} else if (other instanceof NBTTagInt) {
return fromNative((NBTTagInt) other);
} else if (other instanceof NBTTagByte) {
return fromNative((NBTTagByte) other);
} else if (other instanceof NBTTagByteArray) {
return fromNative((NBTTagByteArray) other);
} else if (other instanceof NBTTagCompound) {
return fromNative((NBTTagCompound) other);
} else if (other instanceof NBTTagFloat) {
return fromNative((NBTTagFloat) other);
} else if (other instanceof NBTTagShort) {
return fromNative((NBTTagShort) other);
} else if (other instanceof NBTTagDouble) {
return fromNative((NBTTagDouble) other);
} else {
throw new IllegalArgumentException("Can't convert other of type " + other.getClass().getCanonicalName());
}
}
public static IntArrayTag fromNative(NBTTagIntArray other) {
int[] value = other.c();
return new IntArrayTag(Arrays.copyOf(value, value.length));
}
public static ListTag fromNative(NBTTagList other) {
other = (NBTTagList) other.clone();
List<Tag> list = new ArrayList<Tag>();
Class<? extends Tag> listClass = StringTag.class;
int size = other.size();
for (int i = 0; i < size; i++) {
Tag child = fromNative(other.a(0));
list.add(child);
listClass = child.getClass();
}
return new ListTag(listClass, list);
}
public static EndTag fromNative(NBTTagEnd other) {
return new EndTag();
}
public static LongTag fromNative(NBTTagLong other) {
return new LongTag(other.c());
}
public static StringTag fromNative(NBTTagString other) {
return new StringTag(other.a_());
}
public static IntTag fromNative(NBTTagInt other) {
return new IntTag(other.d());
}
public static ByteTag fromNative(NBTTagByte other) {
return new ByteTag(other.f());
}
public static ByteArrayTag fromNative(NBTTagByteArray other) {
byte[] value = other.c();
return new ByteArrayTag(Arrays.copyOf(value, value.length));
}
public static CompoundTag fromNative(NBTTagCompound other) {
@SuppressWarnings("unchecked") Collection<String> tags = other.c();
Map<String, Tag> map = new HashMap<String, Tag>();
for (String tagName : tags) {
map.put(tagName, fromNative(other.get(tagName)));
}
return new CompoundTag(map);
}
public static FloatTag fromNative(NBTTagFloat other) {
return new FloatTag(other.h());
}
public static ShortTag fromNative(NBTTagShort other) {
return new ShortTag(other.e());
}
public static DoubleTag fromNative(NBTTagDouble other) {
return new DoubleTag(other.g());
}
public static NBTTagList doubleArrayToList(double... doubles)
{
NBTTagList nbttaglist = new NBTTagList();
for(double d : doubles)
{
nbttaglist.add(new NBTTagDouble(d));
}
return nbttaglist;
}
public static Vector getVector(CompoundTag tag)
{
return new Vector(tag.asDouble("x"), tag.asDouble("y"), tag.asDouble("z"));
}
}

View File

@ -0,0 +1,63 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* A tag that has a name.
*/
public class NamedTag {
private final String name;
private final Tag tag;
/**
* Create a new named tag.
*
* @param name the name
* @param tag the tag
*/
public NamedTag(String name, Tag tag) {
checkNotNull(name);
checkNotNull(tag);
this.name = name;
this.tag = tag;
}
/**
* Get the name of the tag.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Get the tag.
*
* @return the tag
*/
public Tag getTag() {
return tag;
}
}

View File

@ -0,0 +1,49 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_Short} tag.
*/
public final class ShortTag extends Tag {
private final short value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public ShortTag(short value) {
super();
this.value = value;
}
@Override
public Short getValue() {
return value;
}
@Override
public String toString() {
return "TAG_Short(" + value + ")";
}
}

View File

@ -0,0 +1,52 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* The {@code TAG_String} tag.
*/
public final class StringTag extends Tag {
private final String value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public StringTag(String value) {
super();
checkNotNull(value);
this.value = value;
}
@Override
public String getValue() {
return value;
}
@Override
public String toString() {
return "TAG_String(" + value + ")";
}
}

View File

@ -0,0 +1,34 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* Represents a NBT tag.
*/
public abstract class Tag {
/**
* Gets the value of this tag.
*
* @return the value
*/
public abstract Object getValue();
}

View File

@ -0,0 +1,63 @@
package mineplex.core.common;
import com.google.gson.*;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.PropertyMap;
import com.mojang.util.UUIDTypeAdapter;
import java.lang.reflect.Type;
import java.util.UUID;
public class Constants
{
public static final String WEB_ADDRESS = "http://127.0.0.1:1000/";
public static final String WEB_CONFIG_KEY = "webServer";
public static Gson GSON;
static
{
GsonBuilder builder = new GsonBuilder()
.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer())
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter());
builder.registerTypeAdapter(GameProfile.class, new GameProfileSerializer());
GSON = builder.create();
}
private static class GameProfileSerializer implements JsonSerializer<GameProfile>, JsonDeserializer<GameProfile>
{
public GameProfile deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException
{
if (!(json instanceof JsonObject))
return new GameProfile(null, null);
JsonObject object = (JsonObject) json;
UUID id = object.has("id") ? (UUID) context.deserialize(object.get("id"), UUID.class) : null;
String name = object.has("name") ? object.getAsJsonPrimitive("name").getAsString() : null;
GameProfile profile = new GameProfile(id, name);
if (object.has("properties"))
profile.getProperties().putAll(context.deserialize(object.get("properties"), PropertyMap.class));
return profile;
}
public JsonElement serialize(GameProfile profile, Type type, JsonSerializationContext context)
{
JsonObject result = new JsonObject();
if (profile.getId() != null)
result.add("id", context.serialize(profile.getId()));
if (profile.getName() != null)
result.addProperty("name", profile.getName());
if (!profile.getProperties().isEmpty())
result.add("properties", context.serialize(profile.getProperties()));
return result;
}
}
}

View File

@ -0,0 +1,31 @@
package mineplex.core.common;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.World;
public class DummyEntity extends Entity
{
public DummyEntity(World world)
{
super(world);
}
@Override
protected void h()
{
}
@Override
protected void a(NBTTagCompound nbtTagCompound)
{
}
@Override
protected void b(NBTTagCompound nbtTagCompound)
{
}
}

View File

@ -0,0 +1,49 @@
package mineplex.core.common;
import mineplex.core.common.block.schematic.Schematic;
import org.bukkit.Location;
import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;
/**
* Loads schematics based on an ordered input value. A good example of usage would be to load schematics in the
* ordering of a progress bar.
*
* @author Shaun Bennett
*/
public class SortedSchematicLoader<T>
{
private final TreeMap<T, Schematic> _schematicMap;
private final Location _pasteLocation;
private T _currentValue = null;
public SortedSchematicLoader(Location pasteLocation)
{
this(pasteLocation, null);
}
public SortedSchematicLoader(Location pasteLocation, Comparator<T> comparator)
{
_schematicMap = new TreeMap<>(comparator);
_pasteLocation = pasteLocation;
}
public void addSchematic(T minValue, Schematic schematic)
{
_schematicMap.put(minValue, schematic);
}
public void update(T value)
{
Map.Entry<T, Schematic> entry = _schematicMap.floorEntry(value);
if (entry != null && !entry.getKey().equals(_currentValue))
{
_currentValue = entry.getKey();
Schematic schematic = entry.getValue();
entry.getValue().paste(_pasteLocation, false);
}
}
}

View File

@ -0,0 +1,57 @@
package mineplex.core.common.animation;
import org.bukkit.util.Vector;
import java.util.Objects;
public class AnimationPoint
{
private final int _tick;
private final Vector _move;
private final Vector _dir;
public AnimationPoint(int tick, Vector move, Vector dir)
{
_tick = tick;
_move = move.clone();
_dir = dir.clone();
}
public Vector getMove()
{
return _move.clone();
}
public Vector getDirection()
{
return _dir.clone();
}
public int getTick()
{
return _tick;
}
@Override
public String toString()
{
return "AnimationPoint[tick" + _tick + ", motion:[" + _move + "], dir:[" + _dir + "]]";
}
@Override
public boolean equals(Object obj)
{
if(obj instanceof AnimationPoint) {
AnimationPoint point = (AnimationPoint) obj;
return point._tick == _tick && point._move.equals(_move);
}
return false;
}
@Override
public int hashCode()
{
return Objects.hash(_tick, _move);
}
}

View File

@ -0,0 +1,230 @@
package mineplex.core.common.animation;
import java.util.Collection;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
/**
* Self sufficient animator to animate task with steps using local vector logic
*/
public abstract class Animator
{
private final Plugin _plugin;
// private TreeSet<AnimationPoint> _points = new TreeSet<>((a, b) -> Integer.compare(a.getTick(), b.getTick()));
private Set<AnimationPoint> _points = new HashSet<>();
private PriorityQueue<AnimationPoint> _queue = new PriorityQueue<>((a, b) -> Integer.compare(a.getTick(), b.getTick()));
private AnimationPoint _prev;
private AnimationPoint _next;
private Location _baseLoc;
private int _tick = -1;
private boolean _repeat = false;
private BukkitTask _task;
public Animator(Plugin plugin)
{
_plugin = plugin;
}
public void addPoints(Collection<AnimationPoint> points)
{
for(AnimationPoint p : points) _points.add(p);
}
public void addPoint(AnimationPoint point) {
_points.add(point);
}
public void removePoint(AnimationPoint point) {
_points.remove(point);
}
/**
* @return Returns a cloned list of the animator points for this instance.
*/
public Set<AnimationPoint> getSet() {
Set<AnimationPoint> set = new HashSet<>();
set.addAll(_points);
return set;
}
/**
* @return Returns the actual list of animator points used by this instance. As this is not a copy, editing this list will apply
* changes to the current instance.
*/
public Set<AnimationPoint> getSetRaw() {
return _points;
}
/**
* Start the animation at the given location. If the animator is already running then this call will be silently ignored.
* @param loc Location the animation will start relative too. The vector poitns will be added to relative to this location.
*/
public void start(Location loc)
{
if(isRunning()) return;
_queue.clear();
_queue.addAll(_points);
if(_queue.isEmpty()) return;
_baseLoc = loc.clone();
_next = _queue.peek();
_prev = new AnimationPoint(0, _next.getMove().clone(), _next.getDirection().clone());
_task = new BukkitRunnable()
{
public void run()
{
_tick++;
if(_next.getTick() < _tick)
{
_queue.remove();
_prev = _next;
_next = _queue.peek();
}
if(_queue.isEmpty())
{
if(_repeat)
{
Location clone = _baseLoc.clone();
stop();
start(clone);
}
else
{
finish(_baseLoc);
stop();
}
return;
}
Location prev = _baseLoc.clone().add(_prev.getMove());
Location next = _baseLoc.clone().add(_next.getMove());
prev.setDirection(_prev.getDirection());
double diff = ((double)_tick-_prev.getTick())/(_next.getTick()-_prev.getTick());
if(!Double.isFinite(diff)) diff = 0;
prev.add(next.clone().subtract(prev).toVector().multiply(diff));
Vector dirDiff = _next.getDirection().subtract(prev.getDirection());
dirDiff.multiply(diff);
prev.setDirection(prev.getDirection().add(dirDiff));
tick(prev);
}
}.runTaskTimer(_plugin, 0, 1);
}
public void start(Entity entity)
{
if(isRunning()) return;
_queue.clear();
_queue.addAll(_points);
if(_queue.isEmpty()) return;
_baseLoc = entity.getLocation().clone();
_next = _queue.peek();
_prev = new AnimationPoint(0, _next.getMove().clone(), _next.getDirection().clone());
_task = new BukkitRunnable()
{
public void run()
{
_tick++;
if(_next.getTick() < _tick)
{
_queue.remove();
_prev = _next;
_next = _queue.peek();
}
if(_queue.isEmpty())
{
if(_repeat)
{
Location clone = _baseLoc.clone();
stop();
start(clone);
}
else
{
finish(_baseLoc);
stop();
}
return;
}
Location prev = _baseLoc.clone().add(_prev.getMove());
Location next = _baseLoc.clone().add(_next.getMove());
prev.setDirection(_prev.getDirection());
double diff = ((double)_tick-_prev.getTick())/(_next.getTick()-_prev.getTick());
if(!Double.isFinite(diff)) diff = 0;
prev.add(next.clone().subtract(prev).toVector().multiply(diff));
Vector dirDiff = _next.getDirection().subtract(prev.getDirection());
dirDiff.multiply(diff);
prev.setDirection(prev.getDirection().add(dirDiff));
tick(prev);
}
}.runTaskTimer(_plugin, 0, 1);
}
public boolean isRunning()
{
return _task != null;
}
public void stop()
{
if(!isRunning()) return;
_task.cancel();
_task = null;
_tick = -1;
_baseLoc = null;
}
/**
* @return Returns true if the animation should repeat.
* @see #setRepeat(boolean)
*/
public boolean isRepeat()
{
return _repeat;
}
/**
* If the last animation point does not make the animation end up at the exact same location as the start
* then it might lead to unexpected results as it will re-start the animation from the end of the animation.
*/
public void setRepeat(boolean repeat)
{
_repeat = repeat;
}
protected abstract void tick(Location loc);
protected abstract void finish(Location loc);
}

View File

@ -0,0 +1,44 @@
package mineplex.core.common.animation;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
/**
* An implementation of the {@link Animator} which will teleport the provided entity along the animation path each tick.
*/
public class AnimatorEntity extends Animator
{
private final Entity _ent;
public AnimatorEntity(Plugin plugin, Entity ent)
{
super(plugin);
_ent = ent;
}
@Override
protected void tick(Location loc)
{
if(!_ent.isValid())
{
stop();
return;
}
_ent.setVelocity(new Vector(0,0,0));
_ent.teleport(loc);
}
@Override
protected void finish(Location loc) {}
public Entity getEntity()
{
return _ent;
}
}

View File

@ -0,0 +1,48 @@
package mineplex.core.common.animation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Location;
import org.bukkit.util.Vector;
/**
* A small factory class to build animations using location inputs with embedded directions. It then calculates the vector difference
* between the locations in an ordered fashion when building the list.
*/
public class AnimatorFactory
{
private Map<Integer, Location> _locations = new HashMap<>();
public void addLocation(Location loc, int tick)
{
_locations.put(tick, loc.clone());
}
public List<AnimationPoint> getBuildList(Location base)
{
List<AnimationPoint> list = new ArrayList<>();
Iterator<Entry<Integer, Location>> it = _locations.entrySet().stream()
.sorted((e1, e2)
-> Integer.compare(e1.getKey(), e2.getKey())
)
.iterator();
while(it.hasNext())
{
Entry<Integer, Location> e = it.next();
Vector diff = e.getValue().clone().subtract(base).toVector();
list.add(new AnimationPoint(e.getKey(), diff, e.getValue().getDirection()));
}
return list;
}
}

View File

@ -0,0 +1,41 @@
package mineplex.core.common.api;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/**
* @author Shaun Bennett
*/
public class ApiEndpoint
{
private Gson _gson;
private ApiWebCall _webCall;
public ApiEndpoint(ApiHost host, String path)
{
this(host, path, new GsonBuilder().setFieldNamingStrategy(new ApiFieldNamingStrategy())
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX").create());
}
public ApiEndpoint(ApiHost host, String path, Gson gson)
{
this(host.getHost(), host.getPort(), path, gson);
}
public ApiEndpoint(String host, int port, String path, Gson gson)
{
String url = "http://" + host + ":" + port + path;
_webCall = new ApiWebCall(url, gson);
_gson = gson;
}
protected ApiWebCall getWebCall()
{
return _webCall;
}
public Gson getGson()
{
return _gson;
}
}

View File

@ -0,0 +1,5 @@
package mineplex.core.common.api;
public class ApiException extends Exception
{
}

View File

@ -0,0 +1,17 @@
package mineplex.core.common.api;
import com.google.gson.FieldNamingStrategy;
import java.lang.reflect.Field;
/**
* @author Shaun Bennett
*/
public class ApiFieldNamingStrategy implements FieldNamingStrategy
{
@Override
public String translateName(Field field)
{
return (field.getName().startsWith("_") ? field.getName().substring(1) : field.getName());
}
}

View File

@ -0,0 +1,102 @@
package mineplex.core.common.api;
import java.util.HashMap;
import java.util.Map;
public class ApiHost
{
private static final String API_HOST_FILE = "api-config.dat";
private static final Object LOCK = new Object();
private static volatile boolean LOADED = false;
private static final Map<String, ApiHost> API_HOST_MAP = new HashMap<>();
public static ApiHost getAPIHost(String identifier)
{
if (!LOADED)
{
synchronized (LOCK)
{
if (!LOADED)
{
try
{
/*
File configFile = new File(API_HOST_FILE);
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(configFile);
for (String key : configuration.getKeys(false))
{
String ip = configuration.getConfigurationSection(key).getString("ip");
// Use parseInt to catch non-ints instead of a 0
int port = Integer.parseInt(configuration.getConfigurationSection(key).getString("port"));
if (ip == null)
{
throw new NullPointerException();
}
API_HOST_MAP.put(key, new ApiHost(ip, port));
}
Manually putting datas
*/
API_HOST_MAP.put("AMPLIFIERS", new ApiHost("127.0.0.1", 1000));
API_HOST_MAP.put("ANTISPAM", new ApiHost("127.0.0.1", 1000));
API_HOST_MAP.put("ENDERCHEST", new ApiHost("127.0.0.1", 1000));
API_HOST_MAP.put("BANNER", new ApiHost("127.0.0.1", 1000));
}
catch (Throwable t)
{
t.printStackTrace();
}
finally
{
LOADED = true;
}
}
}
}
return API_HOST_MAP.get(identifier);
}
public static ApiHost getAmplifierService()
{
return getAPIHost("AMPLIFIERS");
}
public static ApiHost getAntispamService()
{
return getAPIHost("ANTISPAM");
}
public static ApiHost getEnderchestService()
{
return getAPIHost("ENDERCHEST");
}
public static ApiHost getBanner()
{
return getAPIHost("BANNER");
}
private String _host;
private int _port;
private ApiHost(String host, int port)
{
_host = host;
_port = port;
}
public String getHost()
{
return _host;
}
public int getPort()
{
return _port;
}
}

View File

@ -0,0 +1,50 @@
package mineplex.core.common.api;
import java.util.Date;
/**
* @author Shaun Bennett
*/
public class ApiResponse implements HttpStatusCode
{
// These do not have _ prefix because of gson. Please do not add underscores!
private int statusCode;
private boolean success;
private String error;
public ApiResponse()
{
}
public boolean isSuccess()
{
return success;
}
public String getError()
{
return error;
}
@Override
public String toString()
{
return "ApiResponse{" +
"success=" + success +
", error='" + error + '\'' +
'}';
}
@Override
public int getStatusCode()
{
return statusCode;
}
@Override
public void setStatusCode(int statusCode)
{
this.statusCode = statusCode;
}
}

View File

@ -0,0 +1,164 @@
package mineplex.core.common.api;
import com.google.gson.Gson;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.IOUtils;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import mineplex.core.common.api.enderchest.HashesNotEqualException;
/**
* @author Shaun Bennett
*/
public class ApiWebCall
{
private String _url;
private Gson _gson;
private PoolingHttpClientConnectionManager _cm;
private CloseableHttpClient _httpClient;
public ApiWebCall(String url)
{
this(url, new Gson());
}
public ApiWebCall(String url, Gson gson)
{
_url = url;
_gson = gson;
_cm = new PoolingHttpClientConnectionManager();
_cm.setMaxTotal(200);
_cm.setDefaultMaxPerRoute(20);
_httpClient = HttpClients.custom().setConnectionManager(_cm).build();
}
public <T> T get(String resource, Class<T> clazz)
{
return get(resource, (Type)clazz);
}
public <T> T get(String resource, Type type)
{
T returnData = null;
HttpGet httpGet = new HttpGet(_url + resource);
try (CloseableHttpResponse response = _httpClient.execute(httpGet)) {
returnData = parseResponse(response, type);
} catch (IOException e)
{
e.printStackTrace();
}
return returnData;
}
public <T> T post(String resource, Class<T> clazz, Object data)
{
T returnData = null;
HttpPost httpPost = new HttpPost(_url + resource);
try
{
if (data != null)
{
StringEntity params = new StringEntity(_gson.toJson(data));
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpPost.setEntity(params);
}
try (CloseableHttpResponse response = _httpClient.execute(httpPost))
{
returnData = parseResponse(response, clazz);
} catch (IOException e)
{
e.printStackTrace();
}
} catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
return returnData;
}
public File getFile(String resource, String savePath) throws HashesNotEqualException, IOException
{
HttpGet httpGet = new HttpGet(_url + resource);
File file = new File(savePath);
FileOutputStream fos = null;
DigestInputStream dis = null;
try (CloseableHttpResponse response = _httpClient.execute(httpGet))
{
MessageDigest md = DigestUtils.getMd5Digest();
HttpEntity entity = response.getEntity();
dis = new DigestInputStream(entity.getContent(), md);
fos = new FileOutputStream(file);
IOUtils.copy(dis, fos);
String calculatedHash = Hex.encodeHexString(md.digest());
Header hashHeader = response.getFirstHeader("Content-MD5");
if (hashHeader != null && !calculatedHash.equals(hashHeader.getValue()))
{
file.delete();
throw new HashesNotEqualException(hashHeader.getValue(), calculatedHash);
}
} finally {
try
{
if (fos != null) fos.close();
} catch (IOException e)
{
e.printStackTrace();
}
try
{
if (dis != null) dis.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
return file;
}
private <T> T parseResponse(CloseableHttpResponse response, Type type) throws IOException
{
HttpEntity entity = response.getEntity();
T parsed = _gson.fromJson(new InputStreamReader(entity.getContent()), type);
if (parsed instanceof HttpStatusCode && response.getStatusLine() != null)
{
((HttpStatusCode) parsed).setStatusCode(response.getStatusLine().getStatusCode());
}
return parsed;
}
}

View File

@ -0,0 +1,12 @@
package mineplex.core.common.api;
/**
* Interface used to also grab status code from ApiWebCall
* @author Shaun Bennett
*/
public interface HttpStatusCode
{
public int getStatusCode();
public void setStatusCode(int statusCode);
}

View File

@ -0,0 +1,36 @@
package mineplex.core.common.api;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
/**
* @author Shaun Bennett
*/
public class ListResponseType<Data> implements ParameterizedType
{
private Class<Data> _wrapped;
public ListResponseType(Class<Data> wrapped)
{
_wrapped = wrapped;
}
@Override
public Type[] getActualTypeArguments()
{
return new Type[] { _wrapped };
}
@Override
public Type getRawType()
{
return List.class;
}
@Override
public Type getOwnerType()
{
return null;
}
}

View File

@ -0,0 +1,46 @@
package mineplex.core.common.api.enderchest;
import java.io.File;
import java.io.IOException;
import mineplex.core.common.api.ApiHost;
import mineplex.core.common.api.ApiWebCall;
import mineplex.core.common.util.ZipUtil;
import mineplex.core.common.timing.TimingManager;
/**
* Load worlds from the `enderchest` microservice
*/
public class EnderchestWorldLoader
{
private static final String TIMINGS_PREFIX = "Enderchest LoadMap::";
private ApiWebCall _webCall;
public EnderchestWorldLoader()
{
String url = "http://" + ApiHost.getEnderchestService().getHost() + ":" + ApiHost.getEnderchestService().getPort() + "/";
_webCall = new ApiWebCall(url);
}
public void loadMap(String mapType, String folder) throws HashesNotEqualException, IOException
{
TimingManager.start(TIMINGS_PREFIX + "DownloadMap");
String fileName = mapType + "_map.zip";
File f = _webCall.getFile("map/" + mapType + "/next", fileName);
TimingManager.stop(TIMINGS_PREFIX + "DownloadMap");
TimingManager.start(TIMINGS_PREFIX + "CreateFolders");
new File(folder).mkdir();
new File(folder + java.io.File.separator + "region").mkdir();
new File(folder + java.io.File.separator + "data").mkdir();
TimingManager.stop(TIMINGS_PREFIX + "CreateFolders");
TimingManager.start(TIMINGS_PREFIX + "UnzipToDirectory");
ZipUtil.UnzipToDirectory(f.getAbsolutePath(), folder);
TimingManager.stop(TIMINGS_PREFIX + "UnzipToDirectory");
TimingManager.start(TIMINGS_PREFIX + "DeleteZip");
f.delete();
TimingManager.stop(TIMINGS_PREFIX + "DeleteZip");
}
}

View File

@ -0,0 +1,25 @@
package mineplex.core.common.api.enderchest;
import mineplex.core.common.api.ApiException;
public class HashesNotEqualException extends ApiException
{
private String _hashFromServer;
private String _calculatedHash;
public HashesNotEqualException(String hashFromServer, String calculatedHash)
{
_hashFromServer = hashFromServer;
_calculatedHash = calculatedHash;
}
public String getHashFromServer()
{
return _hashFromServer;
}
public String getGeneratedHash()
{
return _calculatedHash;
}
}

View File

@ -0,0 +1,18 @@
package mineplex.core.common.api.mothership;
import mineplex.serverdata.commands.ServerCommand;
public class MothershipCommand extends ServerCommand
{
private Action action;
public Action getAction()
{
return action;
}
public enum Action
{
CLEANUP, START
}
}

View File

@ -0,0 +1,33 @@
package mineplex.core.common.block;
import org.bukkit.block.Block;
import org.bukkit.Material;
public class BlockData
{
public Block Block;
public Material Material;
public byte Data;
public long Time;
public BlockData(Block block)
{
Block = block;
Material = block.getType();
Data = block.getData();
Time = System.currentTimeMillis();
}
public void restore()
{
restore(false);
}
public void restore(boolean requireNotAir)
{
if (requireNotAir && Block.getType() == org.bukkit.Material.AIR)
return;
Block.setTypeIdAndData(Material.getId(), Data, true);
}
}

View File

@ -0,0 +1,82 @@
package mineplex.core.common.block;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.Location;
public class DataLocationMap
{
private final EnumMap<DyeColor, List<Location>> _goldDataMap, _ironDataMap, _spongeDataMap;
public DataLocationMap()
{
_goldDataMap = new EnumMap<>(DyeColor.class);
_ironDataMap = new EnumMap<>(DyeColor.class);
_spongeDataMap = new EnumMap<>(DyeColor.class);
}
public List<Location> getGoldLocations(DyeColor color)
{
List<Location> list = _goldDataMap.get(color);
return list == null ? Collections.emptyList() : list;
}
public void addGoldLocation(DyeColor color, Location location)
{
if (_goldDataMap.containsKey(color))
{
_goldDataMap.get(color).add(location);
}
else
{
List<Location> list = new ArrayList<>();
list.add(location);
_goldDataMap.put(color, list);
}
}
public List<Location> getIronLocations(DyeColor color)
{
List<Location> list = _ironDataMap.get(color);
return list == null ? Collections.emptyList() : list;
}
public void addIronLocation(DyeColor color, Location location)
{
if (_ironDataMap.containsKey(color))
{
_ironDataMap.get(color).add(location);
}
else
{
List<Location> list = new ArrayList<>();
list.add(location);
_ironDataMap.put(color, list);
}
}
public void addSpongeLocation(DyeColor color, Location location)
{
if (_spongeDataMap.containsKey(color))
{
_spongeDataMap.get(color).add(location);
}
else
{
List<Location> list = new ArrayList<>();
list.add(location);
_spongeDataMap.put(color, list);
}
}
public List<Location> getSpongeLocations(DyeColor color)
{
List<Location> list = _spongeDataMap.get(color);
return list == null ? Collections.emptyList() : list;
}
}

View File

@ -0,0 +1,150 @@
package mineplex.core.common.block;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockVector;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import net.minecraft.server.v1_8_R3.Chunk;
import net.minecraft.server.v1_8_R3.ChunkCoordIntPair;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk;
import net.minecraft.server.v1_8_R3.PacketPlayOutMultiBlockChange;
import net.minecraft.server.v1_8_R3.PacketPlayOutMultiBlockChange.MultiBlockChangeInfo;
import net.minecraft.server.v1_8_R3.TileEntity;
import net.minecraft.server.v1_8_R3.WorldServer;
/**
* An agent used to easily record and send multi-block update packets to players. The agent handles if the packet should be a
* MultiBlock packet or a chunk update. It also supports blocks across multiple chunks.
*/
public class MultiBlockUpdaterAgent
{
private Map<Chunk, List<BlockVector>> _chunks = new HashMap<>();
/**
* Add a block to the list of blocks to send to the player. The agent supports blocks across different chunks and
* will not send duplicates.
* @param block The block to send. The block is stored using a BlockVector, meaning that when the send method is called, it will use
* the material and data found for the block at the moment you call the send method.
* @see #send(Collection)
*/
public void addBlock(Block block)
{
Chunk c = ((CraftChunk)block.getChunk()).getHandle();
List<BlockVector> list = _chunks.computeIfAbsent(c,chunk -> new ArrayList<>());
if(list.size() >= 64) return;
BlockVector bv = block.getLocation().toVector().toBlockVector();
if(list.contains(bv)) return;
list.add(bv);
}
/**
* Sends all the record blocks to all online players. Players out of range will not receive packets.
* @see #send(Collection)
*/
public void send()
{
send(UtilServer.getPlayersCollection());
}
/**
* Clear all blocks for this agent.
*/
public void reset()
{
_chunks.clear();
}
/**
* Send all the recorded blocks to the provided players. This will only send packets to players in range. If the blocks span multiple
* chunks then players will only receive block updates for chunks close to them.
* @param players The players which will the packets will be sent to.
*/
public void send(Collection<? extends Player> players)
{
for(Player p : players)
{
for(Chunk c : _chunks.keySet())
{
if(!p.getWorld().equals(c.bukkitChunk.getWorld())) continue;
int x = p.getLocation().getChunk().getX();
int z = p.getLocation().getChunk().getZ();
int chunkDist = Math.max(Math.abs(c.locX-x), Math.abs(c.locZ-z));
if(chunkDist > Bukkit.getViewDistance()) continue;
sendPacket(c, p);
}
}
}
private void sendPacket(Chunk c, Player...players)
{
List<BlockVector> list = _chunks.get(c);
if(list == null) return;
if(list.size() >= 64)
{
for(Player p : players)
{
int protocol = UtilPlayer.getProtocol(p);
UtilPlayer.sendPacket(p, new PacketPlayOutMapChunk(c, true, 65535));
}
}
else
{
PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange();
packet.a = new ChunkCoordIntPair(c.locX, c.locZ);
packet.b = new MultiBlockChangeInfo[list.size()];
for(int i = 0; i < list.size(); i++)
{
BlockVector bv = list.get(i);
short xyz = (short)((bv.getBlockX() & 0xF) << 12 | (bv.getBlockZ() & 0xF) << 8 | bv.getBlockY());
packet.b[i] = packet.new MultiBlockChangeInfo(xyz, c);
}
for(Player p : players)
{
UtilPlayer.sendPacket(p, packet);
}
}
Packet<?>[] tileEntities = new Packet[c.tileEntities.size()];
int i = 0;
for(TileEntity te : c.tileEntities.values())
{
tileEntities[i++] = te.getUpdatePacket();
}
for(Player p : players)
{
UtilPlayer.sendPacket(p, tileEntities);
((WorldServer)c.world).getTracker().untrackPlayer(((CraftPlayer)p).getHandle());
}
Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () ->
{
for(Player p : players)
{
((WorldServer)c.world).getTracker().a(((CraftPlayer)p).getHandle(), c);
}
}, 5);
}
}

View File

@ -0,0 +1,408 @@
package mineplex.core.common.block.schematic;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.EntityTypes;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagInt;
import net.minecraft.server.v1_8_R3.TileEntity;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
import com.java.sk89q.jnbt.CompoundTag;
import com.java.sk89q.jnbt.DoubleTag;
import com.java.sk89q.jnbt.NBTUtils;
import com.java.sk89q.jnbt.Tag;
import mineplex.core.common.block.DataLocationMap;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
public class Schematic
{
private final short _width;
private final short _height;
private final short _length;
private final short[] _blocks;
private final byte[] _blockData;
private final Vector _weOffset;
private final Map<BlockVector, Map<String, Tag>> _tileEntities;
private final List<Tag> _entities;
public Schematic(short width, short height, short length, short[] blocks, byte[] blockData, Vector worldEditOffset, Map<BlockVector, Map<String, Tag>> tileEntities, List<Tag> entities)
{
_width = width;
_height = height;
_length = length;
_blocks = blocks;
_blockData = blockData;
_weOffset = worldEditOffset;
_tileEntities = tileEntities;
_entities = entities;
}
public Schematic(short width, short height, short length, short[] blocks, byte[] blockData, Vector worldEditOffset, Map<BlockVector, Map<String, Tag>> tileEntities)
{
this(width, height, length, blocks, blockData, worldEditOffset, tileEntities, new ArrayList<>());
}
public Schematic(short width, short height, short length, short[] blocks, byte[] blockData, Vector worldEditOffset)
{
this(width, height, length, blocks, blockData, worldEditOffset, new HashMap<>());
}
public Schematic(short width, short height, short length, short[] blocks, byte[] blockData)
{
this(width, height, length, blocks, blockData, null);
}
public Schematic(Schematic schematic)
{
this(schematic.getWidth(), schematic.getHeight(), schematic.getLength(), schematic.getBlocks(), schematic.getBlockData(), schematic.getWorldEditOffset(), schematic.getTileEntities(), schematic.getEntities());
}
public SchematicData paste(Location originLocation)
{
return paste(originLocation, false);
}
public SchematicData paste(Location originLocation, boolean ignoreAir)
{
return paste(originLocation, ignoreAir, false);
}
public SchematicData paste(Location originLocation, boolean ignoreAir, boolean worldEditOffset)
{
return paste(originLocation, ignoreAir, worldEditOffset, true);
}
public SchematicData paste(Location originLocation, boolean ignoreAir, boolean worldEditOffset, boolean quickSet)
{
if (worldEditOffset && hasWorldEditOffset())
{
originLocation = originLocation.clone().add(_weOffset);
}
DataLocationMap locationMap = new DataLocationMap();
SchematicData output = new SchematicData(locationMap, originLocation.getWorld());
int startX = originLocation.getBlockX();
int startY = originLocation.getBlockY();
int startZ = originLocation.getBlockZ();
UtilBlock.startQuickRecording();
WorldServer nmsWorld = ((CraftWorld) originLocation.getWorld()).getHandle();
for (int x = 0; x < _width; x++)
{
for (int y = 0; y < _height; y++)
{
for (int z = 0; z < _length; z++)
{
int index = getIndex(x, y, z);
// some blocks were giving me negative id's in the schematic (like stairs)
// not sure why but the math.abs is my simple fix
int materialId = Math.abs(_blocks[index]);
if (ignoreAir && materialId == 0) // Air
{
continue;
}
else if (materialId == 147) // Gold Plate
{
// Check for data wool at location below the gold plate
if (addDataWool(locationMap, true, originLocation, x, y - 1, z))
continue;
}
else if (materialId == 148) // Iron Plate
{
// Check for data wool at location below the gold plate
if (addDataWool(locationMap, false, originLocation, x, y - 1, z))
continue;
}
else if (materialId == Material.SPONGE.getId())
{
if (addSpongeLocation(locationMap, originLocation, x, y + 1, z))
continue;
}
else if (materialId == 35)
{
// Check if this is a dataloc so we can skip setting the block
int aboveIndex = getIndex(x, y + 1, z);
if (hasIndex(aboveIndex))
{
if (Math.abs(_blocks[aboveIndex]) == Material.GOLD_PLATE.getId() || Math.abs(_blocks[aboveIndex]) == Material.IRON_PLATE.getId())
continue;
}
int belowIndex = getIndex(x, y - 1, z);
if (hasIndex(belowIndex))
{
if (Math.abs(_blocks[belowIndex]) == Material.SPONGE.getId())
continue;
}
}
if (quickSet)
{
UtilBlock.setQuick(originLocation.getWorld(), startX + x, startY + y, startZ + z, materialId, _blockData[index]);
}
else
{
originLocation.getWorld().getBlockAt(startX + x, startY + y, startZ + z).setTypeIdAndData(materialId, _blockData[index], false);
}
BlockVector bv = new BlockVector(x, y, z);
output.getBlocksRaw().add(bv);
Map<String, Tag> map = _tileEntities.get(bv);
if (map != null)
{
TileEntity te = nmsWorld.getTileEntity(MapUtil.getBlockPos(bv.add(originLocation.toVector())));
if (te == null) continue;
CompoundTag weTag = new CompoundTag(map);
NBTTagCompound tag = NBTUtils.toNative(weTag);
tag.set("x", new NBTTagInt(tag.getInt("x") + startX));
tag.set("y", new NBTTagInt(tag.getInt("y") + startY));
tag.set("z", new NBTTagInt(tag.getInt("z") + startZ));
te.a(tag);
output.getTileEntitiesRaw().add(bv);
}
}
}
}
UtilBlock.stopQuickRecording();
for (Tag tag : _entities)
{
if (tag instanceof CompoundTag)
{
CompoundTag ctag = (CompoundTag) tag;
NBTTagCompound nmsTag = NBTUtils.toNative(ctag);
List<DoubleTag> list = ctag.getList("Pos", DoubleTag.class);
Vector pos = new Vector(list.get(0).getValue(), list.get(1).getValue(), list.get(2).getValue());
pos.add(originLocation.toVector());
UtilSchematic.setPosition(nmsTag, pos);
list = NBTUtils.fromNative(nmsTag).getList("Pos", DoubleTag.class);
Entity nmsEntity = EntityTypes.a(nmsTag, nmsWorld);
nmsWorld.addEntity(nmsEntity, SpawnReason.CUSTOM);
if (nmsEntity == null) continue;
output.getEntitiesRaw().add(nmsEntity.getBukkitEntity());
}
}
return output;
}
/**
* Checks the schematic location for x, y, z and adds the a Location to the DataLocationMap if it is a wool block
*
* @return true if a location was added to the DataLocationMap
*/
private boolean addDataWool(DataLocationMap map, boolean gold, Location origin, int x, int y, int z)
{
int index = getIndex(x, y, z);
if (hasIndex(index))
{
int materialId = Math.abs(_blocks[index]);
if (materialId == 35) // WOOL
{
byte data = _blockData[index];
DyeColor color = DyeColor.getByWoolData(data);
if (color != null)
{
if (gold)
{
map.addGoldLocation(color, origin.clone().add(x, y, z));
}
else
{
map.addIronLocation(color, origin.clone().add(x, y, z));
}
return true;
}
}
}
return false;
}
private boolean addSpongeLocation(DataLocationMap map, Location origin, int x, int y, int z)
{
int index = getIndex(x, y, z);
if (hasIndex(index))
{
int materialId = Math.abs(_blocks[index]);
if (materialId == 35) // WOOL
{
byte data = _blockData[index];
DyeColor color = DyeColor.getByWoolData(data);
if (color != null)
{
map.addSpongeLocation(color, origin.clone().add(x, y - 1, z));
return true;
}
}
}
return false;
}
/**
* Rotates the schematic 180 degrees.
*/
public Schematic rotate180()
{
// Swap blocks around
int area = _length * _width;
Bukkit.broadcastMessage("length=" + _length + " width=" + _width + " height=" + _height);
for (int height = 0; height < _height; height++)
{
int startIndex = height * area;
int endIndex = (int) (startIndex + area / 2D);
Bukkit.broadcastMessage("startIndex=" + startIndex + " endIndex=" + endIndex);
for (int lower = startIndex; lower <= endIndex; lower++)
{
int upper = endIndex - lower;
short temp = _blocks[lower];
byte tempData = _blockData[lower];
_blocks[lower] = _blocks[upper];
_blocks[upper] = temp;
_blockData[lower] = _blockData[upper];
_blockData[upper] = tempData;
}
}
// Inverse Tile Entities BlockVectors in the X and Z axis
_tileEntities.keySet().forEach(blockVector ->
{
blockVector.setX(-blockVector.getX());
blockVector.setZ(-blockVector.getZ());
});
return this;
}
public boolean hasWorldEditOffset()
{
return _weOffset != null;
}
public Vector getWorldEditOffset()
{
if (!hasWorldEditOffset()) return null;
return _weOffset.clone();
}
public int getSize()
{
return _blocks.length;
}
public int getIndex(int x, int y, int z)
{
return y * _width * _length + z * _width + x;
}
public boolean hasIndex(int index)
{
return index < _blocks.length && index >= 0;
}
public Short getBlock(int x, int y, int z)
{
if (getIndex(x, y, z) >= _blocks.length)
{
return null;
}
if (getIndex(x, y, z) < 0)
{
return null;
}
return _blocks[getIndex(x, y, z)];
}
public Byte getData(int x, int y, int z)
{
if (getIndex(x, y, z) >= _blocks.length)
{
return null;
}
if (getIndex(x, y, z) < 0)
{
return null;
}
return _blockData[getIndex(x, y, z)];
}
public short getWidth()
{
return _width;
}
public short getHeight()
{
return _height;
}
public short getLength()
{
return _length;
}
public short[] getBlocks()
{
return _blocks;
}
public byte[] getBlockData()
{
return _blockData;
}
public List<Tag> getEntities()
{
return _entities;
}
public Map<BlockVector, Map<String, Tag>> getTileEntities()
{
return _tileEntities;
}
@Override
public String toString()
{
return String.format("Schematic [width: %d, length: %d, height: %d, blockLength: %d, blockDataLength: %d]", _width, _length, _height, _blocks.length, _blockData.length);
}
}

View File

@ -0,0 +1,86 @@
package mineplex.core.common.block.schematic;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.util.BlockVector;
import mineplex.core.common.block.DataLocationMap;
/**
* Wrapper class for holding the output from pasting a schematic
*/
public class SchematicData
{
private final List<BlockVector> _blocks;
private final DataLocationMap _dataMap;
private final List<Entity> _entities;
private final List<BlockVector> _tileEntities;
private final World _world;
public SchematicData(DataLocationMap dataMap, World world)
{
_dataMap = dataMap;
_blocks = new ArrayList<>();
_tileEntities = new ArrayList<>();
_entities = new ArrayList<>();
_world = world;
}
/**
* @return Returns a list of blocks which has been edited by the schematic
*/
public List<BlockVector> getBlocks()
{
return new ArrayList<>(_blocks);
}
/**
* @return Returns the DataLocationMap which was utilized while pasting
*/
public DataLocationMap getDataLocationMap()
{
return _dataMap;
}
/**
* @return Returns a entities which was spawned by the schematic
*/
public List<Entity> getEntities()
{
return new ArrayList<>(_entities);
}
/**
* @return Returns a list of blocks who are tile entities which have been edited by the schematic. All the blocks in this list is also
* inside the {@link #getBlocks()} method
*/
public List<BlockVector> getTileEntities()
{
return new ArrayList<>(_tileEntities);
}
public World getWorld()
{
return _world;
}
List<BlockVector> getBlocksRaw()
{
return _blocks;
}
List<BlockVector> getTileEntitiesRaw()
{
return _tileEntities;
}
List<Entity> getEntitiesRaw()
{
return _entities;
}
}

View File

@ -0,0 +1,123 @@
package mineplex.core.common.block.schematic;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import mineplex.core.common.block.BlockData;
import mineplex.core.common.util.Callback;
public class SchematicRunnable implements Runnable
{
private JavaPlugin _plugin;
private boolean _started;
private BukkitTask _task;
private List<BlockData> _changedBlocks;
private Callback<List<BlockData>> _callback;
private Schematic _schematic;
private Block _startBlock;
private int _currentX = 0;
private int _currentY = 0;
private int _currentZ = 0;
private int _blocksPerTick = 1000;
public SchematicRunnable(JavaPlugin plugin, Schematic schematic, Block startBlock, Callback<List<BlockData>> callback)
{
_plugin = plugin;
_changedBlocks = new ArrayList<BlockData>(schematic.getSize());
_started = false;
_callback = callback;
_schematic = schematic;
_startBlock = startBlock;
}
public void start()
{
if (!_started)
{
_task = Bukkit.getScheduler().runTaskTimer(_plugin, this, 1, 1);
_started = true;
}
}
public void pause()
{
if (_started)
{
_task.cancel();
_started = false;
}
}
public void setBlocksPerTick(int blocksPerTick)
{
_blocksPerTick = blocksPerTick;
}
@Override
public void run()
{
for (int i = 0; i < _blocksPerTick; i++)
{
setBlock(_startBlock.getRelative(_currentX, _currentY, _currentZ), _currentX, _currentY, _currentZ);
_currentX++;
if (_currentX >= _schematic.getWidth())
{
_currentX = 0;
_currentZ++;
if (_currentZ >= _schematic.getLength())
{
_currentZ = 0;
_currentY++;
if (_currentY >= _schematic.getHeight())
{
// We are done
System.out.println("Finished importing schematic with setblockrunnable!");
if (_callback != null)
_callback.run(_changedBlocks);
_task.cancel();
return;
}
}
}
}
}
private void setBlock(Block block, int x, int y, int z)
{
Short materialId = _schematic.getBlock(x, y, z);
Byte data = _schematic.getData(x, y, z);
if (materialId == null || data == null)
{
return;
}
Material material = Material.getMaterial(materialId);
if (material == null)
{
System.out.println("Failed to find material with id: " + materialId);
return;
}
if (block.getTypeId() == materialId && block.getData() == data)
return;
BlockData blockData = new BlockData(block);
_changedBlocks.add(blockData);
block.setTypeIdAndData(materialId, data, false);
}
}

View File

@ -0,0 +1,387 @@
package mineplex.core.common.block.schematic;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
import com.java.sk89q.jnbt.ByteArrayTag;
import com.java.sk89q.jnbt.CompoundTag;
import com.java.sk89q.jnbt.IntTag;
import com.java.sk89q.jnbt.ListTag;
import com.java.sk89q.jnbt.NBTInputStream;
import com.java.sk89q.jnbt.NBTOutputStream;
import com.java.sk89q.jnbt.NBTUtils;
import com.java.sk89q.jnbt.NamedTag;
import com.java.sk89q.jnbt.ShortTag;
import com.java.sk89q.jnbt.StringTag;
import com.java.sk89q.jnbt.Tag;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagInt;
import net.minecraft.server.v1_8_R3.TileEntity;
import net.minecraft.server.v1_8_R3.WorldServer;
public class UtilSchematic
{
public static Schematic loadSchematic(File file) throws IOException
{
FileInputStream fis = new FileInputStream(file);
return loadSchematic(fis);
}
public static Schematic loadSchematic(byte[] bytes) throws IOException
{
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
return loadSchematic(bis);
}
public static Schematic loadSchematic(InputStream input) throws IOException
{
NBTInputStream nbtStream = new NBTInputStream(new GZIPInputStream(input));
NamedTag rootTag = nbtStream.readNamedTag();
nbtStream.close();
if (!rootTag.getName().equals("Schematic"))
return null;
CompoundTag schematicTag = (CompoundTag) rootTag.getTag();
Map<String, Tag> schematic = schematicTag.getValue();
short width = getChildTag(schematic, "Width", ShortTag.class).getValue();
short height = getChildTag(schematic, "Height", ShortTag.class).getValue();
short length = getChildTag(schematic, "Length", ShortTag.class).getValue();
byte[] blockId = getChildTag(schematic, "Blocks", ByteArrayTag.class).getValue();
byte[] addId = new byte[0];
short[] blocks = new short[blockId.length]; // Have to later combine IDs
byte[] blockData = getChildTag(schematic, "Data", ByteArrayTag.class).getValue();
Vector weOffset = null;
if (schematic.containsKey("WEOffsetX") && schematic.containsKey("WEOffsetY") && schematic.containsKey("WEOffsetZ"))
{
int x = getChildTag(schematic, "WEOffsetX", IntTag.class).getValue();
int y = getChildTag(schematic, "WEOffsetY", IntTag.class).getValue();
int z = getChildTag(schematic, "WEOffsetZ", IntTag.class).getValue();
weOffset = new Vector(x, y, z);
}
// We support 4096 block IDs using the same method as vanilla Minecraft, where
// the highest 4 bits are stored in a separate byte array.
if (schematic.containsKey("AddBlocks"))
{
addId = getChildTag(schematic, "AddBlocks", ByteArrayTag.class).getValue();
}
// Combine the AddBlocks data with the first 8-bit block ID
for (int index = 0; index < blockId.length; index++)
{
if ((index >> 1) >= addId.length)
{
blocks[index] = (short) (blockId[index] & 0xFF);
}
else
{
if ((index & 1) == 0)
{
blocks[index] = (short) (((addId[index >> 1] & 0x0F) << 8) + (blockId[index] & 0xFF));
}
else
{
blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (blockId[index] & 0xFF));
}
}
}
// Need to pull out tile entities
List<Tag> tileEntities = getChildTag(schematic, "TileEntities", ListTag.class).getValue();
Map<BlockVector, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
for (Tag tag : tileEntities)
{
if (!(tag instanceof CompoundTag))
{
continue;
}
CompoundTag t = (CompoundTag) tag;
int x = 0;
int y = 0;
int z = 0;
Map<String, Tag> values = new HashMap<>();
for (Map.Entry<String, Tag> entry : t.getValue().entrySet())
{
if (entry.getValue() instanceof IntTag)
{
if (entry.getKey().equals("x"))
{
x = ((IntTag) entry.getValue()).getValue();
}
else if (entry.getKey().equals("y"))
{
y = ((IntTag) entry.getValue()).getValue();
}
else if (entry.getKey().equals("z"))
{
z = ((IntTag) entry.getValue()).getValue();
}
}
values.put(entry.getKey(), entry.getValue());
}
BlockVector vec = new BlockVector(x, y, z);
tileEntitiesMap.put(vec, values);
}
List<Tag> entityTags = getChildTag(schematic, "Entities", ListTag.class).getValue();
return new Schematic(width, height, length, blocks, blockData, weOffset, tileEntitiesMap, entityTags);
}
/**
* @param schematic The schematic you want to turn into bytes
* @return Returns a byte array of the schematic which may be used for saving the schematic to DB or file
*/
public static byte[] getBytes(Schematic schematic)
{
ByteArrayOutputStream output = new ByteArrayOutputStream();
writeBytes(schematic, output);
return output.toByteArray();
}
/**
* @param schematic The scheamtic you want save somewhere
* @return Writes out this schematic on byte form
*/
public static void writeBytes(Schematic schematic, OutputStream output)
{
Map<String, Tag> map = new HashMap<>();
short width = schematic.getWidth();
short height = schematic.getHeight();
short length = schematic.getLength();
map.put("Width", new ShortTag(width));
map.put("Height", new ShortTag(height));
map.put("Length", new ShortTag(length));
if (schematic.hasWorldEditOffset())
{
Vector weOffset = schematic.getWorldEditOffset();
map.put("WEOffsetX", new IntTag(weOffset.getBlockX()));
map.put("WEOffsetY", new IntTag(weOffset.getBlockX()));
map.put("WEOffsetZ", new IntTag(weOffset.getBlockX()));
}
map.put("Materials", new StringTag("Alpha"));
short[] sBlocks = schematic.getBlocks();
Map<BlockVector, Map<String, Tag>> sTileEntities = schematic.getTileEntities();
byte[] blocks = new byte[sBlocks.length];
byte[] addBlocks = null;
byte[] blockData = schematic.getBlockData();
List<Tag> tileEntities = new ArrayList<>();
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
for (int z = 0; z < length; z++)
{
int index = y * width * length + z * width + x;
BlockVector bv = new BlockVector(x, y, z);
//Save 4096 IDs in an AddBlocks section
if (sBlocks[index] > 255)
{
if (addBlocks == null) // Lazily create section
{
addBlocks = new byte[(blocks.length >> 1) + 1];
}
addBlocks[index >> 1] = (byte) (((index & 1) == 0) ?
addBlocks[index >> 1] & 0xF0 | (sBlocks[index] >> 8) & 0xF
: addBlocks[index >> 1] & 0xF | ((sBlocks[index] >> 8) & 0xF) << 4);
}
blocks[index] = (byte) sBlocks[index];
if (sTileEntities.get(bv) != null)
{
Map<String, Tag> values = new HashMap<>(sTileEntities.get(bv));
values.put("x", new IntTag(x));
values.put("y", new IntTag(y));
values.put("z", new IntTag(z));
CompoundTag tileEntityTag = new CompoundTag(values);
tileEntities.add(tileEntityTag);
}
}
}
}
map.put("Blocks", new ByteArrayTag(blocks));
map.put("Data", new ByteArrayTag(blockData));
map.put("TileEntities", new ListTag(CompoundTag.class, tileEntities));
if (addBlocks != null)
{
map.put("AddBlocks", new ByteArrayTag(addBlocks));
}
// ====================================================================
// Entities
// ====================================================================
List<Tag> entities = schematic.getEntities();
map.put("Entities", new ListTag(CompoundTag.class, entities));
// ====================================================================
// Output
// ====================================================================
CompoundTag schematicTag = new CompoundTag(map);
try (NBTOutputStream outputStream = new NBTOutputStream(new GZIPOutputStream(output)))
{
outputStream.writeNamedTag("Schematic", schematicTag);
}
catch (IOException e)
{
e.printStackTrace();
}
}
public static Schematic createSchematic(Location locA, Location locB)
{
return createSchematic(locA, locB, null);
}
public static Schematic createSchematic(Location locA, Location locB, Vector worldEditOffset)
{
World world = locA.getWorld();
Vector min = Vector.getMinimum(locA.toVector(), locB.toVector());
Vector max = Vector.getMaximum(locB.toVector(), locA.toVector());
short width = (short) (max.getBlockX()-min.getBlockX());
short height = (short) (max.getBlockY()-min.getBlockY());
short length = (short) (max.getBlockZ()-min.getBlockZ());
short[] blocks = new short[width*height*length];
byte[] blocksData = new byte[blocks.length];
WorldServer nmsWorld = ((CraftWorld)world).getHandle();
Map<BlockVector, Map<String, Tag>> tileEntities = new HashMap<>();
for(int x = min.getBlockX(); x < max.getBlockX(); x++)
{
for(int y = min.getBlockY(); y < max.getBlockY(); y++)
{
for(int z = min.getBlockZ(); z < max.getBlockZ(); z++)
{
int localX = x-min.getBlockX();
int localY = y-min.getBlockY();
int localZ = z-min.getBlockZ();
Block b = world.getBlockAt(x, y, z);
int index = localY * width * length + localZ * width + localX;
blocks[index] = (short) b.getTypeId();
blocksData[index] = b.getData();
BlockPosition bp = new BlockPosition(x, y, z);
TileEntity tileEntity = nmsWorld.getTileEntity(bp);
if(tileEntity == null) continue;
NBTTagCompound nmsTag = new NBTTagCompound();
tileEntity.b(nmsTag);
nmsTag.set("x", new NBTTagInt(localX));
nmsTag.set("y", new NBTTagInt(localY));
nmsTag.set("z", new NBTTagInt(localZ));
CompoundTag tag = NBTUtils.fromNative(nmsTag);
tileEntities.put(new BlockVector(localX, localY, localZ), tag.getValue());
}
}
}
List<Tag> entities = new ArrayList<>();
for (Entity e : world.getEntities())
{
if (e instanceof Player) continue;
if (e.getLocation().toVector().isInAABB(min, max))
{
net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity)e).getHandle();
NBTTagCompound nmsTag = new NBTTagCompound();
nmsEntity.c(nmsTag);
Vector diff = e.getLocation().subtract(min).toVector();
setPosition(nmsTag, diff);
nmsTag.remove("UUID");
nmsTag.remove("UUIDMost");
nmsTag.remove("UUIDLeast");
CompoundTag tag = NBTUtils.fromNative(nmsTag);
entities.add(tag);
}
}
return new Schematic(width, height, length, blocks, blocksData, worldEditOffset, tileEntities, entities);
}
private static <T extends Tag> T getChildTag(Map<String, Tag> items, String key, Class<T> expected)
{
Tag tag = items.get(key);
return expected.cast(tag);
}
public static void setPosition(NBTTagCompound nbtTag, Vector pos)
{
nbtTag.set("Pos", NBTUtils.doubleArrayToList(pos.getX(), pos.getY(), pos.getZ()));
}
public static void main(String[] args) throws IOException
{
File file = new File("test.schematic");
System.out.println(file.getAbsoluteFile());
Schematic m = UtilSchematic.loadSchematic(file);
System.out.println(m);
}
}

View File

@ -0,0 +1,15 @@
package mineplex.core.common.generator;
import java.util.Random;
import org.bukkit.World;
import org.bukkit.generator.ChunkGenerator;
public class VoidGenerator extends ChunkGenerator
{
@Override
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
{
return createChunkData(world);
}
}

View File

@ -0,0 +1,79 @@
package mineplex.core.common.geom;
import javax.annotation.Nonnull;
import java.util.Comparator;
import org.bukkit.Location;
public class Point2D implements Comparable<Point2D>
{
private static final Comparator<Point2D> COMPARE_BY_Y_THEN_X =
Comparator.comparingDouble(Point2D::getY).thenComparingDouble(Point2D::getX);
private final double _x;
private final double _y;
private Point2D(double x, double y)
{
_x = x;
_y = y;
}
public static Point2D of(double x, double y)
{
return new Point2D(x, y);
}
public static Point2D of(Location location)
{
return new Point2D(location.getX(), location.getZ());
}
public double getX()
{
return _x;
}
public double getY()
{
return _y;
}
public Comparator<Point2D> polarOrder()
{
return (p2, p3) ->
{
double dx1 = p2._x - _x;
double dy1 = p2._y - _y;
double dx2 = p3._x - _x;
double dy2 = p3._y - _y;
if (dy1 >= 0 && dy2 < 0) return -1; // p2 above; p3 below
else if (dy2 >= 0 && dy1 < 0) return 1; // p2 below; p3 above
else if (dy1 == 0 && dy2 == 0) { // 3-collinear and horizontal
if (dx1 >= 0 && dx2 < 0) return -1; // p2 right; p3 left
else if (dx2 >= 0 && dx1 < 0) return 1; // p2 left ; p3 right
else return 0; // all the same point
}
else return -ccw(Point2D.this, p2, p3); // both above or below
};
}
public static int ccw(Point2D a, Point2D b, Point2D c) {
double area2 = (b._x-a._x)*(c._y-a._y) - (b._y-a._y)*(c._x-a._x);
if (area2 < 0) return -1;
else if (area2 > 0) return 1;
else return 0;
}
@Override
public int compareTo(@Nonnull Point2D that)
{
return COMPARE_BY_Y_THEN_X.compare(this, that);
}
@Override
public String toString()
{
return "Point2D{_x=" + _x + ",_y=" + _y + "}";
}
}

View File

@ -0,0 +1,68 @@
package mineplex.core.common.geom;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Stack;
public class Polygon2D
{
private final List<Point2D> _points;
private Polygon2D(List<Point2D> points)
{
_points = points;
// Ensure points[points.size-1] = points[0]
if (!_points.get(0).equals(points.get(_points.size()-1)))
{
_points.add(points.get(0));
}
}
public boolean contains(Point2D point)
{
boolean result = false;
for (int i = 0, j = _points.size() - 1; i < _points.size(); j = i++)
{
if ((_points.get(i).getY() > point.getY()) != (_points.get(j).getY() > point.getY()) &&
(point.getX() < (_points.get(j).getX() - _points.get(i).getX()) * (point.getY() - _points.get(i).getY()) / (_points.get(j).getY() - _points.get(i).getY()) + _points.get(i).getX()))
{
result = !result;
}
}
return result;
}
public static Polygon2D fromUnorderedPoints(List<Point2D> points)
{
Stack<Point2D> hull = new Stack<>();
Collections.sort(points);
points.subList(1, points.size()).sort(points.get(0).polarOrder());
hull.push(points.get(0));
hull.push(points.get(1));
// find first extreme point (not collinear with first and second elements)
int extreme;
for (extreme = 2; extreme < points.size(); extreme++)
if (Point2D.ccw(points.get(0), points.get(1), points.get(extreme)) != 0) break;
for (int i = extreme; i < points.size(); i++)
{
Point2D top = hull.pop();
while (Point2D.ccw(hull.peek(), top, points.get(i)) <= 0) {
top = hull.pop();
}
hull.push(top);
hull.push(points.get(i));
}
return new Polygon2D(new ArrayList<>(hull));
}
public static Polygon2D fromPoints(List<Point2D> points)
{
return new Polygon2D(new ArrayList<>(points));
}
}

View File

@ -0,0 +1,123 @@
package mineplex.core.common.jsonchat;
public class ChildJsonMessage extends JsonMessage
{
private JsonMessage _parent;
public ChildJsonMessage(String text)
{
this(new StringBuilder(), text);
}
public ChildJsonMessage(StringBuilder builder, String text)
{
this(null, builder, text);
}
public ChildJsonMessage(JsonMessage parent, StringBuilder builder, String text)
{
super(builder, text);
_parent = parent;
}
public ChildJsonMessage add(String text)
{
Builder.append("}, ");
return new ChildJsonMessage(_parent, Builder, text);
}
@Override
public ChildJsonMessage color(String color)
{
super.color(color);
return this;
}
@Override
public ChildJsonMessage bold()
{
super.bold();
return this;
}
@Override
public ChildJsonMessage italic()
{
super.italic();
return this;
}
@Override
public ChildJsonMessage underlined()
{
super.underlined();
return this;
}
@Override
public ChildJsonMessage strikethrough()
{
super.strikethrough();
return this;
}
@Override
public ChildJsonMessage obfuscated()
{
super.obfuscated();
return this;
}
@Override
public ChildJsonMessage click(String action, String value)
{
super.click(action, value);
return this;
}
@Override
public ChildJsonMessage click(ClickEvent event, String value)
{
super.click(event, value);
return this;
}
@Override
public ChildJsonMessage hover(String action, String value)
{
super.hover(action, value);
return this;
}
@Override
public ChildJsonMessage hover(HoverEvent event, String value)
{
super.hover(event, value);
return this;
}
@Override
public String toString()
{
Builder.append("}");
if (_parent != null)
{
Builder.append("]");
return _parent instanceof ChildJsonMessage ? ((ChildJsonMessage)_parent).toString() : _parent.toString();
}
else
return Builder.toString();
}
}

View File

@ -0,0 +1,22 @@
package mineplex.core.common.jsonchat;
public enum ClickEvent
{
RUN_COMMAND("run_command"),
SUGGEST_COMMAND("suggest_command"),
OPEN_URL("open_url"),
CHANGE_PAGE("change_page"); // Change Page only applies to books, which we haven't been able to use yet
private String _minecraftString;
ClickEvent(String minecraftString)
{
_minecraftString = minecraftString;
}
@Override
public String toString()
{
return _minecraftString;
}
}

View File

@ -0,0 +1,34 @@
package mineplex.core.common.jsonchat;
public enum Color
{
BLACK("black"),
DARK_BLUE("dark_blue"),
DARK_GREEN("dark_green"),
DARK_AQUA("dark_aqua"),
DARK_RED("dark_red"),
DARK_PURPLE("dark_purple"),
GOLD("gold"),
GRAY("gray"),
DARK_GRAY("dark_gray"),
BLUE("blue"),
GREEN("green"),
AQUA("aqua"),
RED("red"),
LIGHT_PURPLE("light_purple"),
YELLOW("yellow"),
WHITE("white");
private String _minecraftString;
Color(String minecraftString)
{
_minecraftString = minecraftString;
}
@Override
public String toString()
{
return _minecraftString;
}
}

View File

@ -0,0 +1,21 @@
package mineplex.core.common.jsonchat;
public enum HoverEvent
{
SHOW_TEXT("show_text"),
SHOW_ITEM("show_item"),
SHOW_ACHIEVEMENT("show_achievement");
private String _minecraftString;
HoverEvent(String minecraftString)
{
_minecraftString = minecraftString;
}
@Override
public String toString()
{
return _minecraftString;
}
}

View File

@ -0,0 +1,149 @@
package mineplex.core.common.jsonchat;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
public class JsonMessage
{
protected StringBuilder Builder;
public JsonMessage(String text)
{
this(new StringBuilder(), text);
}
public JsonMessage(StringBuilder builder, String text)
{
Builder = builder;
Builder.append("{\"text\":\"" + text + "\"");
}
public JsonMessage color(String color)
{
Builder.append(", color:" + color);
return this;
}
public JsonMessage bold()
{
Builder.append(", bold:true");
return this;
}
public JsonMessage italic()
{
Builder.append(", italic:true");
return this;
}
public JsonMessage underlined()
{
Builder.append(", underlined:true");
return this;
}
public JsonMessage strikethrough()
{
Builder.append(", strikethrough:true");
return this;
}
public JsonMessage obfuscated()
{
Builder.append(", obfuscated:true");
return this;
}
public ChildJsonMessage extra(String text)
{
Builder.append(", \"extra\":[");
return new ChildJsonMessage(this, Builder, text);
}
public JsonMessage click(String action, String value)
{
Builder.append(", \"clickEvent\":{\"action\":\"" + action + "\",\"value\":\"" + value + "\"}");
return this;
}
public JsonMessage hover(String action, String value)
{
Builder.append(", \"hoverEvent\":{\"action\":\"" + action + "\",\"value\":\"" + value + "\"}");
return this;
}
public JsonMessage click(ClickEvent event, String value)
{
return click(event.toString(), value);
}
public JsonMessage hover(HoverEvent event, String value)
{
return hover(event.toString(), value);
}
public JsonMessage color(Color color)
{
return color(color.toString());
}
public String toString()
{
Builder.append("}");
return Builder.toString();
}
public void sendToPlayer(Player player)
{
((CraftPlayer) player).getHandle().sendMessage(IChatBaseComponent.ChatSerializer.a(toString()));
}
/**
* Send a message to players using the new 1.8 message types
*
* @param messageType Message type to send
* @param players Players to send to
*/
public void send(MessageType messageType, Player... players)
{
PacketPlayOutChat chatPacket = new PacketPlayOutChat(IChatBaseComponent.ChatSerializer.a(toString()));
chatPacket.b = messageType.getId();
for (Player player : players)
{
UtilPlayer.sendPacket(player, chatPacket);
}
}
public static enum MessageType
{
CHAT_BOX((byte) 0), // Inside Chat Box
SYSTEM_MESSAGE((byte) 1), // Inside Chat Box - This is used for the client to identify difference between chat message and server messages
ABOVE_HOTBAR((byte) 2); // Shows above hotbar
private byte _id;
MessageType(byte id)
{
_id = id;
}
public byte getId()
{
return _id;
}
}
}

View File

@ -0,0 +1,233 @@
package mineplex.core.common.lang;
import java.text.Format;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class IntlString
{
public static IntlString[] toIntl(String... strings)
{
IntlString[] intl = new IntlString[strings.length];
for (int i = 0; i < strings.length; i++) {
final String string = strings[i];
intl[i] = new IntlString("")
{
public String tr(Locale locale)
{
return string;
}
};
}
return intl;
}
/**
* An empty {@link IntlString}.
*/
public static final IntlString EMPTY = toIntl("")[0];
private final Argument<String> key;
private final List<Argument<Object>> arguments = new ArrayList<>();
public IntlString(String key, ChatColor... styles)
{
this.key = new Argument<>(key, styles);
}
IntlString(String key, String style)
{
this.key = new Argument<>(key, style);
}
private IntlString arg(Argument<Object> argument)
{
IntlString result = new IntlString(getKey().getArgument(), getKey().getStyle());
result.arguments.addAll(getArguments());
result.arguments.add(argument);
return result;
}
public Argument<String> getKey()
{
return key;
}
public List<Argument<Object>> getArguments()
{
return Collections.unmodifiableList(arguments);
}
public IntlString arg(Object value, ChatColor... styles)
{
return arg(new Argument<>(value, styles));
}
public IntlString arg(Object value, String style)
{
return arg(new Argument<>(value, style));
}
public String tr()
{
return tr(Locale.getDefault());
}
public String tr(Entity entity)
{
if (entity instanceof Player)
return tr((Player) entity);
else
return tr();
}
public String tr(Player player)
{
return tr(Lang.getPlayerLocale(player));
}
public String tr(Locale locale)
{
if (locale == null)
locale = Locale.getDefault();
String formatString = Lang.get(getKey().getArgument(), locale);
if (getKey().getArgument().equals("stats.achievements.disabled.requires.0.players"))
{
int x = 8;
}
if (getArguments().isEmpty())
return getKey().getStyle() + formatString;
else
{
MessageFormat format = new MessageFormat(formatString, locale);
Format[] formats = format.getFormatsByArgumentIndex();
Object[] argArray = new Object[getArguments().size()];
for (int i = 0; i < formats.length; i++)
{
argArray[i] = getArguments().get(i);
if (argArray[i] instanceof IntlString)
argArray[i] = ((IntlString) argArray[i]).tr(locale);
if (formats[i] != null)
{
argArray[i] = formats[i].format(argArray[i]);
format.setFormatByArgumentIndex(i, null);
}
String style = getArguments().get(i).getStyle();
if (!style.isEmpty())
argArray[i] = style + argArray[i] + ChatColor.RESET;
argArray[i] = argArray[i] + getKey().getStyle();
}
return getKey().getStyle() + format.format(argArray, new StringBuffer(), null).toString();
}
}
@Override
public boolean equals(Object o)
{
if (!(o instanceof IntlString))
return false;
IntlString s = (IntlString) o;
return getKey().equals(s.getKey()) && getArguments().equals(s.getArguments());
}
@Override
public int hashCode()
{
return Objects.hash(getKey(), getArguments());
}
@Override
public String toString()
{
return toEnglishString();
}
public String toEnglishString()
{
return tr(Locale.ENGLISH);
}
private static class Argument<T>
{
private final T argument;
private final String style;
public Argument(T value, ChatColor... styles)
{
this.argument = value;
String s = "";
ChatColor color = null;
for (ChatColor style : styles)
{
if (style.isColor())
color = style;
else if (style.isFormat())
s += style;
}
this.style = ChatColor.getLastColors((color == null ? "" : color) + s);
}
public Argument(T value, String style)
{
this.argument = value;
this.style = style == null ? "" : ChatColor.getLastColors(style);
}
public T getArgument()
{
return argument;
}
public String getStyle()
{
return style;
}
@Override
public boolean equals(Object o)
{
if (!(o instanceof Argument))
return false;
Argument<?> p = (Argument<?>) o;
return getArgument().equals(p.getArgument()) && getStyle().equals(p.getStyle());
}
@Override
public int hashCode()
{
return Objects.hash(getArgument(), getStyle());
}
@Override
public String toString()
{
return getStyle() + getArgument();
}
}
}

View File

@ -0,0 +1,154 @@
package mineplex.core.common.lang;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import mineplex.core.common.util.F;
import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public final class Lang
{
public static interface PlayerLocaleFunction
{
public Locale getLocaleOfPlayer(Player player);
}
private static PlayerLocaleFunction _playerLocaleFunction = null;
private static final Map<Locale, ResourceBundle> _localeResourceBundles = Collections.synchronizedMap(new HashMap<Locale, ResourceBundle>());
public Lang()
{
init();
}
private void init()
{
System.out.println(F.main("i18n","Attempting to initialize resource bundles..."));
try
{
// Locales over which we should iterate and load.
for (Locale loc : new Locale[] {
Locale.ENGLISH,
Locale.GERMAN
})
{
ResourceBundle bundle = ResourceBundle.getBundle("mineplex.core.common.lang.MineplexBundle", loc);
_localeResourceBundles.put(loc, bundle);
System.out.println("Loaded " + loc.toString() + "...");
}
}
catch (MissingResourceException e)
{
System.err.println("AN ERROR OCCURED WHILE ATTEMPTING TO LOAD RESOURCE LOCALES");
// For now at least, crash the runtime.
throw new RuntimeException(e);
}
}
public static PlayerLocaleFunction getPlayerLocaleFunction()
{
return _playerLocaleFunction;
}
public static void setPlayerLocaleFunction(PlayerLocaleFunction playerLocaleFunction)
{
_playerLocaleFunction = playerLocaleFunction;
}
public static Locale getPlayerLocale(Player player)
{
if (getPlayerLocaleFunction() == null)
return Locale.getDefault();
else
return getPlayerLocaleFunction().getLocaleOfPlayer(player);
}
public static ResourceBundle getResourceBundle(Locale locale)
{
synchronized (_localeResourceBundles)
{
if (_localeResourceBundles.containsKey(locale))
return _localeResourceBundles.get(locale);
else
{
return _localeResourceBundles.get(Locale.ENGLISH);
}
}
}
public static ResourceBundle getBestResourceBundle(Locale locale)
{
ResourceBundle bundle = getResourceBundle(locale);
if (bundle == null && !locale.equals(Locale.getDefault()))
bundle = getResourceBundle(Locale.getDefault());
if (bundle == null && !locale.equals(Locale.ENGLISH))
bundle = getResourceBundle(Locale.ENGLISH);
return bundle;
}
/**
* Shorthand method for obtaining and translating a key.
*/
public static String tr(String key, Entity entity, Object... args)
{
IntlString string = key(key);
for (Object a : args)
string.arg(a);
return string.tr(entity);
}
public static String get(String key)
{
return get(key, (Locale) null);
}
public static String get(String key, Locale locale)
{
if (key == null)
return null;
else if (key.isEmpty())
return "";
else
{
if (locale == null)
locale = Locale.getDefault();
ResourceBundle bundle = getBestResourceBundle(locale);
if (bundle == null)
return null;
return bundle.getString(key);
}
}
public static String get(String key, Player player)
{
return get(key, getPlayerLocale(player));
}
public static IntlString key(String key, ChatColor... styles)
{
return new IntlString(key, styles);
}
public static IntlString key(String key, String style)
{
return new IntlString(key, style);
}
}

View File

@ -0,0 +1,78 @@
package mineplex.core.common.player;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
public class PlayerSnapshot
{
private Location _location;
private ItemStack[] _armor;
private ItemStack[] _items;
private double _health;
private int _hunger;
private float _saturation;
private float _exhaustion;
private int _experience;
private Vector _velocity;
private PlayerSnapshot(Location location, ItemStack[] armor, ItemStack[] items, double health, int hunger, float saturation, float exhaustion, int experience, Vector velocity)
{
_location = location;
_armor = armor;
_items = items;
_health = health;
_hunger = hunger;
_saturation = saturation;
_exhaustion = exhaustion;
_experience = experience;
_velocity = velocity;
}
public void applySnapshot(Player player)
{
player.teleport(_location);
player.getInventory().setArmorContents(_armor);
player.getInventory().setContents(_items);
player.setHealth(_health);
player.setFoodLevel(_hunger);
player.setSaturation(_saturation);
player.setExhaustion(_exhaustion);
player.setVelocity(_velocity);
player.setTotalExperience(_experience);
}
public static PlayerSnapshot getSnapshot(Player player)
{
Location location = player.getLocation();
// Inventory
ItemStack[] bArmor = player.getInventory().getArmorContents();
ItemStack[] armor = new ItemStack[bArmor.length];
for (int i = 0; i < bArmor.length; i++)
{
armor[i] = bArmor[i];
}
ItemStack[] bItems = player.getInventory().getContents();
ItemStack[] items = new ItemStack[bItems.length];
for (int i = 0; i < bItems.length; i++)
{
items[i] = bItems[i];
}
// Health
double health = player.getHealth();
int hunger = player.getFoodLevel();
float saturation = player.getSaturation();
float exhaustion = player.getExhaustion();
int experience = player.getTotalExperience();
Vector velocity = player.getVelocity();
return new PlayerSnapshot(location, armor, items, health, hunger, saturation, exhaustion, experience, velocity);
}
}

View File

@ -0,0 +1,16 @@
package mineplex.core.common.shape;
import org.bukkit.Location;
/**
* Interface used by classes which can display visuals at provided locations.
*/
public interface CosmeticShape
{
/**
* Display a visual at the given location
* @param loc The location to display the visual at
*/
void display(Location loc);
}

View File

@ -0,0 +1,182 @@
package mineplex.core.common.shape;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAlg;
/**
* A simple 3D vector stored shape
*/
public class Shape
{
protected final static double DEFAULT_DENSITY = 1;
protected HashSet<Vector> _points = new HashSet<>();
public Shape(){}
public Shape(Collection<Vector> points){
this._points.addAll(points);
}
/**
* Rotate this shape along the X-axis
* @param radians Radians to rotate the shape
*/
public void rotateOnXAxis(double radians)
{
for(Vector v : _points)
{
UtilAlg.rotateAroundXAxis(v, radians);
}
}
/**
* Rotate this shape along the Y-axis
* @param radians Radians to rotate the shape
*/
public void rotateOnYAxis(double radians)
{
for(Vector v : _points)
{
UtilAlg.rotateAroundYAxis(v, radians);
}
}
/**
* Rotate this shape along the Z-axis
* @param radians Radians to rotate the shape
*/
public void rotateOnZAxis(double radians)
{
for(Vector v : _points)
{
UtilAlg.rotateAroundZAxis(v, radians);
}
}
/**
* Offsets all the points based on the given vector
* @param v
*/
public void add(Vector v)
{
for(Vector p : _points) p.add(v);
}
public void addPoint(Vector v)
{
_points.add(v);
}
public boolean removePoint(Vector v)
{
return _points.remove(v);
}
public Set<Vector> getPoints()
{
return new HashSet<>(_points);
}
/**
* Multiply all the points by m.
* If m > 1 then the shape will become larger.
* If m < 1 then the shape will become smaller.
* If m = 1 then the shape will stay the same.
* If m < 0 then the shape will become inverted.
* @param m
*/
public void multiply(double m)
{
for(Vector v : _points) v.multiply(m);
}
public Shape clone() {
List<Vector> list = new ArrayList<>();
for(Vector p : _points)
{
list.add(p.clone());
}
return new Shape(list);
}
public Vector getMidPoint()
{
return getMaxAABBCorner().subtract(getMinAABBCorner()).multiply(0.5);
}
public Vector getMaxAABBCorner()
{
Vector max = null;
for(Vector v : _points)
{
if(max == null)
{
max = v.clone();
continue;
}
if(v.getX() > max.getX()) max.setX(v.getX());
if(v.getY() > max.getY()) max.setY(v.getY());
if(v.getZ() > max.getZ()) max.setZ(v.getZ());
}
return max;
}
public Vector getMinAABBCorner()
{
Vector min = null;
for(Vector v : _points)
{
if(min == null)
{
min = v.clone();
continue;
}
if(v.getX() < min.getX()) min.setX(v.getX());
if(v.getY() < min.getY()) min.setY(v.getY());
if(v.getZ() < min.getZ()) min.setZ(v.getZ());
}
return min;
}
/**
* Get the closest length which will be a factor of the provided length, but not longer then max
* E.g. You want to split a length of 9 into even peaces, but the peaces should not be longer than the max 5, then this will
* return 4.5, as 4.5 goes 2 times to make up precisely 9.
* @param length The length which the returned factor should fit into
* @param max The max distance of the returned length
* @return The closest to length to be a factor of the provided length which is <= max
*/
public static double getRoundFactor(double length, double max)
{
return length/Math.ceil(length/max);
}
/**
* Get the closest RoundFactor length applied to a vector, using the vector as the max length. The returned vector is a cloned
* parallel vector to the provided length
* @param length The vector used as length and direction
* @param maxLength The max length of the new returned vector
* @return Returns a parallel vector to the given length vector which is also a factor of the provided vector, but not longer
* then maxLength
*
* @see #getRoundFactor(double, double)
*/
public static Vector getVectorFactor(Vector length, double maxLength)
{
return length.clone().multiply(getRoundFactor(length.length(), maxLength));
}
}

View File

@ -0,0 +1,71 @@
package mineplex.core.common.shape;
import org.bukkit.util.Vector;
/**
* An extension of {@link Shape} creating a simple box
*/
public class ShapeBox extends Shape
{
/**
* Define a parallelepiped using three vectors using default density {@link Shape#DefaultDensity} and is not hollow
* @param localx The first vector to use as local x direction, does not have to align to global x direction
* @param localy The second vector to use as local y direction, does not have to align to global y direction
* @param localz The third vector to use as local z direction, does not have to align to global z direction
*/
public ShapeBox(Vector localx, Vector localy, Vector localz)
{
this(localx, localy, localz, false, DEFAULT_DENSITY);
}
/**
* Define a parallelepiped using three vectors using default density {@link Shape#DefaultDensity}
* @param localx The first vector to use as local x direction, does not have to align to global x direction
* @param localy The second vector to use as local y direction, does not have to align to global y direction
* @param localz The third vector to use as local z direction, does not have to align to global z direction
* @param hollow If the parallelepiped box should be hollow or not
*/
public ShapeBox(Vector localx, Vector localy, Vector localz, boolean hollow)
{
this(localx, localy, localz, hollow, DEFAULT_DENSITY);
}
/**
* Define a parallelepiped using three vectors
* @param localx The first vector to use as local x direction, does not have to align to global x direction
* @param localy The second vector to use as local y direction, does not have to align to global y direction
* @param localz The third vector to use as local z direction, does not have to align to global z direction
* @param hollow If the parallelepiped box should be hollow or not
* @param density The density of the vector points
*/
public ShapeBox(Vector localx, Vector localy, Vector localz, boolean hollow, double density)
{
Vector x = Shape.getVectorFactor(localx, density);
Vector y = Shape.getVectorFactor(localx, density);
Vector z = Shape.getVectorFactor(localx, density);
int xm = (int) Math.sqrt(localx.lengthSquared()/x.lengthSquared());
int ym = (int) Math.sqrt(localy.lengthSquared()/y.lengthSquared());
int zm = (int) Math.sqrt(localz.lengthSquared()/z.lengthSquared());
for(int ix = 0; ix < xm; ix++)
{
for(int iy = 0; iy < ym; iy++)
{
for(int iz = 0; iz < zm; iz++)
{
if(hollow)
{
if(!(ix == 0 || ix == xm-1 || iy == 0 || iy == ym-1 || iz == 0 || iz == zm-1)) continue;
}
_points.add(x.clone().multiply(ix).add(y.clone().multiply(iy)).add(z.clone().multiply(iz)));
}
}
}
}
}

View File

@ -0,0 +1,43 @@
package mineplex.core.common.shape;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
public class ShapeFidgetSpinner extends Shape implements CosmeticShape
{
public ShapeFidgetSpinner(int petalCount, int rotationDegrees)
{
double x0, y0;
double sinRotation = Math.sin(rotationDegrees);
double cosRotation = Math.cos(rotationDegrees);
for (double theta = 0; theta <= 2 * Math.PI; theta += Math.PI / 90)
{
double radius = Math.sin(petalCount * theta);
double x1 = radius * Math.cos(theta);
double y1 = radius * Math.sin(theta);
x0 = cosRotation * x1 - sinRotation * y1;
y0 = 0.2 + sinRotation * x1 + cosRotation * y1;
addPoint(new Vector(x0, y0, 0.4));
}
}
@Override
public void display(Location location)
{
Shape clone = clone();
clone.rotateOnYAxis(Math.toRadians(location.getYaw() + 180));
for (Vector vector : clone.getPoints())
{
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, location.clone().add(vector), null, 0, 1, ViewDist.NORMAL);
}
}
}

View File

@ -0,0 +1,64 @@
package mineplex.core.common.shape;
import org.bukkit.util.Vector;
/**
* A simple grid shape which uses string inputs to define points
*/
public class ShapeGrid extends Shape
{
/**
* Each string in the array represents a layer on the XY-plane, meaning the layers moves towards positive Z.
* Each line in the string represents a line on parallel with the X-axis, where the first line is on the top of the shape.
* Use '#' for each point and anything else for each "non-point".
* The finished shape will then be centered afterwards.
*/
public ShapeGrid(String... input)
{
this(DEFAULT_DENSITY, '#', input);
}
/**
* Each string in the array represents a layer on the XY-plane, meaning the layers moves towards positive Z.
* Each line in the string represents a line on parallel with the X-axis, where the first line is on the top of the shape.
* Use the <code>read</code> char for each point and anything else for each "non-point".
* The finished shape will then be centered afterwards.
*/
public ShapeGrid(char read, String...input)
{
this(DEFAULT_DENSITY, read, input);
}
/**
* Each string in the array represents a layer on the XY-plane, meaning the layers moves towards positive Z.
* Each line in the string represents a line on parallel with the X-axis.
* Use the <code>read</code> char for each point and anything else for each "non-point".
* The finished shape will then be centered afterwards.
*/
public ShapeGrid(double density, char read, String...input)
{
int lx = 0;
int ly = 0;
int lz = 0;
for(int y = 0; y < input.length; y++)
{
String[] lines = input[y].split("\n");
for(int z = 0; z < lines.length; z++)
{
String line = lines[z];
for(int x = 0; x < line.length(); x++)
{
if(line.charAt(x) == read) addPoint(new Vector(-x,-y+input.length,-z).multiply(density));
if(x > lx) lx = x;
if(-y+input.length > ly) ly = -y+input.length;
if(z > lz) lz= z;
}
}
}
add(new Vector(-lx,ly,-lz).multiply(-0.5*density));
}
}

View File

@ -0,0 +1,38 @@
package mineplex.core.common.shape;
import java.util.Collection;
import org.bukkit.util.Vector;
/**
* A bag collection of several shapes. This will add all the points from the given shapes into a new shape
*/
public class ShapeMulti extends Shape
{
/**
* @param shapes Shapes which points will be added to this instance of a shape
*/
public ShapeMulti(Collection<Shape> shapes)
{
for(Shape shape : shapes) addShape(shape);
}
/**
* @param shapes Shapes which points will be added to this instance of a shape
*/
public ShapeMulti(Shape... shapes)
{
for(Shape shape : shapes) addShape(shape);
}
/**
* Add all the points from the given shape to this shape
* @param shape
*/
public void addShape(Shape shape) {
for(Vector v : shape._points) add(v);
}
}

View File

@ -0,0 +1,67 @@
package mineplex.core.common.shape;
import org.bukkit.util.Vector;
/**
* A simple sphere defined using vector points extending {@link Shape}
*/
public class ShapeSphere extends Shape
{
/**
* Define a sphere with radius r that is not hollow and using default density {@link Shape#DefaultDensity}
* @param r Radius for the sphere
*/
public ShapeSphere(double r)
{
this(r,r,r);
}
/**
* A sphere with different radiuses on different planes that is not hollow and using default density {@link Shape#DefaultDensity}
* @param x Radius in x direction
* @param y Radius in y direction
* @param z Radius in z direction
*/
public ShapeSphere(double x, double y, double z)
{
this(x, y, z, false, DEFAULT_DENSITY);
}
/**
* A sphere with different radiuses on different planes using default density {@link Shape#DefaultDensity}
* @param x Radius in x direction
* @param y Radius in y direction
* @param z Radius in z direction
* @param hollow If the sphere should be hollow or not
*/
public ShapeSphere(double x, double y, double z, boolean hollow)
{
this(x, y, z, hollow, DEFAULT_DENSITY);
}
/**
* A sphere with different radiuses on different planes
* @param x Radius in x direction
* @param y Radius in y direction
* @param z Radius in z direction
* @param hollow If the sphere should be hollow or not
* @param density Density between points
*/
public ShapeSphere(double x, double y, double z, boolean hollow, double density)
{
for(double px = -x; px <= x; x += Shape.getRoundFactor(2*x, density))
{
for(double py = -y; py <= y; y += Shape.getRoundFactor(2*y, density))
{
for(double pz = -z; pz <= z; z += Shape.getRoundFactor(2*z, density))
{
if( hollow && px*px/x*x + py*py/y*y + pz*pz/z*z == 1) _points.add(new Vector(px,py,pz));
else if(!hollow && px*px/x*x + py*py/y*y + pz*pz/z*z <= 1) _points.add(new Vector(px,py,pz));
}
}
}
}
}

View File

@ -0,0 +1,420 @@
package mineplex.core.common.shape;
import java.awt.Color;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
/**
* Some simple wing shapes implementing {@link CosmeticShape} storing additional particle information
*/
public class ShapeWings extends ShapeGrid implements CosmeticShape
{
public static final String[] ANGEL_WING_PATTERN = new String[]
{
"000$$0000000000$$000",
"00$##$00000000$##$00",
"0$####$000000$####$0",
"$#####$000000$#####$",
"$#####$000000$#####$",
"$######$0000$######$",
"$######$0000$######$",
"$######$0000$######$",
"$######$$$$$$######$",
"$##################$",
"0$################$0",
"00$####$$$$$$####$00",
"00$####$0000$####$00",
"000$##$000000$##$000",
"000$##$000000$##$000",
"000$#$00000000$#$000",
"00$#$0000000000$#$00",
"00$#$0000000000$#$00",
"000$000000000000$000",
};
public static final String[] SMALL_ANGEL_WING_PATTERN = new String[]
{
"00$0000$00",
"0$#$00$#$0",
"$##$00$##$",
"$###$$###$",
"$########$",
"$########$",
"$##$$$$##$",
"0$#$00$#$0",
"00$0000$00"
};
public static final String[] BUTTERFLY_WING_PATTERN = new String[]
{
"0$$000000000000000$$0",
"$##$0000000000000$##$",
"0$##$00000000000$##$0",
"00$##$000000000$##$00",
"00$###$0000000$###$00",
"000$###$$000$$###$000",
"0000$####$$$####$0000",
"0000$###########$0000",
"00000$#########$00000",
"00000$#########$00000",
"00000$###$$$###$00000",
"0000$###$000$###$0000",
"0000$##$00000$##$0000",
"00000$$0000000$$00000"
};
public static final String[] BEE_WING_PATTERN = new String[]
{
"00$$$000$$$00",
"0$###$0$###$0",
"$$$$$$$$$$$$$",
"$#####$#####$",
"$$$$$$$$$$$$$",
"0$#########$0",
"00$$$$$$$$$00",
"0$#########$0",
"$$$$$$$$$$$$$",
"$#####$#####$",
"$$$$$$$$$$$$$",
"0$###$0$###$0",
"00$$$000$$$00"
};
public static final String[] SMALL_BUTTERFLY_WING_PATTERN = new String[]
{
"0$$00000000$$0",
"$##$000000$##$",
"0$##$0000$##$0",
"00$##$$$$##$00",
"000$######$000",
"000$######$000",
"00$###$$###$00",
"000$#$00$#$000",
"0000$0000$0000"
};
public static final String[] HEART_WING_PATTERN = new String[]
{
"00$00000000000000000$00",
"0$%$000000000000000$%$0",
"$%%%$$00$$000$$00$$%%%$",
"$%%%%%$$##$0$##$$%%%%%$",
"$%%%%%$####$####$%%%%%$",
"0$%%%%$#########$%%%%$0",
"00$%%%$#########$%%%$00",
"000$%%$$#######$$%%$000",
"0000$$00$#####$00$$0000",
"000000000$###$000000000",
"0000000000$#$0000000000",
"00000000000$00000000000"
};
public static final String[] SMALL_HEART_WING_PATTERN = new String[]
{
"0$000000000$0",
"$%$0$$0$$0$%$",
"$%%$##$##$%%$",
"0$%$00000$%$0",
"00$0$###$0$00",
"00000$#$00000",
"000000$000000"
};
public static final String[] FOUR_LEAF_CLOVER = new String[]
{
"$$$$$$$$###$$$$$$$",
"$$$$$$##***#$$$$$$",
"$$$$##****%#$$$$$$",
"$$$#******%#$###$$",
"$$$#***%#%%##***#$",
"$$$$#**%#%#*****#$",
"$$$####*%%#*%%**#$",
"$##***#*%#**##**##",
"#***%%*###******%#",
"#**%##*%###%%%%%%#",
"#**#**%%#**######$",
"$#****%#*****#$$$$",
"$$#*%%%#******#$$$",
"$$#####**%#****#$$",
"$$$$$##**%#***%#$$",
"$$$$$###****%%%#$$",
"$$$$##$#%%%%%##$$$",
"$$$##$$$#####$$$$$",
"$###$$$$$$$$$$$$$$",
"$##$$$$$$$$$$$$$$$"
};
public static final String[] KINGS_CAPE = new String[]
{
"00000$00000",
"0000$#$0000",
"000$###$000",
"000$###$000",
"00$#####$00",
"00$#####$00",
"00$#####$00",
"00$#####$00",
"0$#######$0",
"$#########$"
};
public static final String[] MAPLE_LEAF = new String[]
{
"000000000000000000000000000$000000000000000000000000000",
"00000000000000000000000000$$$00000000000000000000000000",
"0000000000000000000000000$$#$$0000000000000000000000000",
"000000000000000000000000$$###$$000000000000000000000000",
"00000000000000000000000$$#####$$00000000000000000000000",
"0000000000000000$$$000$$#######$$000$$$0000000000000000",
"0000000000000000$#$$$$$#########$$$$$#$0000000000000000",
"0000000000000000$$###################$$0000000000000000",
"00000000000000000$###################$00000000000000000",
"00000000000$$0000$$#################$$0000$$00000000000",
"0$$$000000$$$$$000$#################$000$$$$$000000$$$0",
"00$$$$$$$$$###$$$0$$###############$$0$$$###$$$$$$$$$00",
"00$$############$$$$###############$$$$############$$00",
"000$$#############$$###############$$#############$$000",
"0000$$###########################################$$0000",
"00$$$#############################################$$$00",
"$$$#################################################$$$",
"00$$$$###########################################$$$$00",
"00000$$$#######################################$$$00000",
"00000000$$$$###############################$$$$00000000",
"00000000000$$$###########################$$$00000000000",
"0000000000000$$#########################$$0000000000000",
"0000000000000$$#########################$$0000000000000",
"0000000000000$##$$$$$$$$$$$#$$$$$$$$$$$##$0000000000000",
"000000000000$$$$$000000000$#$000000000$$$$$000000000000",
"00000000000000000000000000$#$00000000000000000000000000",
"00000000000000000000000000$#$00000000000000000000000000",
"00000000000000000000000000$#$00000000000000000000000000",
"00000000000000000000000000$#$00000000000000000000000000",
"00000000000000000000000000$$$00000000000000000000000000"
};
/**
* Default rotation to give the wings a little tilt when displayed on players for instance
*/
public static double DEFAULT_ROTATION = Math.PI/0.05;
/**
* Doesn't have any rotation, so it doesn't go inside the player
*/
public static double NO_ROTATION = 0;
private String _particle;
private Vector _offsetData;
private float _speed;
private int _count;
/**
* A simple non-edge wing shape using the default butterfly pattern {@link ShapeWings#BUTTERFLY_WING_PATTERN}
* and x-rotation {@link #DEFAULT_ROTATION}. It also uses default redstone dust particle with offset of 0, speed of 0 and count 1
*/
public ShapeWings()
{
this(ParticleType.RED_DUST.particleName);
}
/**
* A simple non-edge wing shape using the default butterfly pattern {@link ShapeWings#BUTTERFLY_WING_PATTERN}
* and x-rotation {@link #DEFAULT_ROTATION}
* @param particle The particle to display at each point in the wing shape. Using offset of 0, speed of 0 and count 1
*/
public ShapeWings(String particle)
{
this(particle, null, 0, 1);
}
/**
* A simple non-edge wing shape using the default butterfly pattern {@link ShapeWings#BUTTERFLY_WING_PATTERN}
* and x-rotation {@link #DEFAULT_ROTATION}
* @param particle The particle to display at each point in the wing shape
* @param offsetData Particle data
* @param speed Particle speed
* @param count Particle count
*/
public ShapeWings(String particle, Vector offsetData, float speed, int count)
{
this(particle, offsetData, speed, count, false);
}
/**
* A simple wing shape using the default butterfly pattern {@link ShapeWings#BUTTERFLY_WING_PATTERN}
* and x-rotation {@link #DEFAULT_ROTATION}
* @param particle The particle to display at each point in the wing shape
* @param offsetData Particle data
* @param speed Particle speed
* @param count Particle count
* @param edge If this is the edge of the wings or not
*/
public ShapeWings(String particle, Vector offsetData, float speed, int count, boolean edge)
{
this(particle, offsetData, speed, count, edge, DEFAULT_ROTATION);
}
/**
* A simple wing shape using the default butterfly pattern {@link ShapeWings#BUTTERFLY_WING_PATTERN}
* @param particle The particle to display at each point in the wing shape
* @param offsetData Particle data
* @param speed Particle speed
* @param count Particle count
* @param edge If this is the edge of the wings or not
* @param xRotation Rotation on the x axis
*/
public ShapeWings(String particle, Vector offsetData, float speed, int count, boolean edge, double xRotation)
{
this(particle, offsetData, speed, count, edge, xRotation, BUTTERFLY_WING_PATTERN);
}
/**
* A simple wing shape
* @param particle The particle to display at each point in the wing shape
* @param offsetData Particle data
* @param speed Particle speed
* @param count Particle count
* @param edge If this is the edge of the wings or not
* @param xRotation Rotation on the x axis
* @param pattern Pattern to use as wing shape
*/
public ShapeWings(String particle, Vector offsetData, float speed, int count, boolean edge, double xRotation, String... pattern)
{
super(0.15, edge? '$' : '#',
pattern
);
_particle = particle;
_offsetData = offsetData;
_speed = speed;
_count = count;
rotateOnXAxis(xRotation);
}
public ShapeWings(String particle, Vector offsetData, float speed, int count, char c, double xRotation, String... pattern)
{
super(0.15, c, pattern);
_particle = particle;
_offsetData = offsetData;
_speed = speed;
_count = count;
rotateOnXAxis(xRotation);
}
/**
* Displays the wing
* @param location The location to display the visual at
*/
@Override
public void display(Location location)
{
Shape clone = clone();
clone.rotateOnYAxis(Math.toRadians(location.getYaw()));
for (Vector v : clone.getPoints())
{
Location particleLocation = location.clone().add(v);
displayParticle(particleLocation);
}
}
/**
* Displays the wing for the given player
* @param location The location to display the visual at
* @param player The player
*/
public void display(Location location, Player player)
{
Shape clone = clone();
clone.rotateOnYAxis(Math.toRadians(location.getYaw()));
for (Vector v : clone.getPoints())
{
Location particleLocation = location.clone().add(v);
displayParticle(particleLocation, player);
}
}
/**
* Displays the colored wing
* @param location The location to display the visual at
* @param color The color of the particles
*/
public void displayColored(Location location, Color color)
{
Shape clone = clone();
clone.rotateOnYAxis(Math.toRadians(location.getYaw()));
for (Vector v : clone.getPoints())
{
Location particleLocation = location.clone().add(v);
displayColoredParticle(particleLocation, color);
}
}
/**
* Displays the colored wing for the given player
* @param location The location to display the visual at
* @param color The color of the particles
* @param player The player
*/
public void displayColored(Location location, Color color, Player player)
{
Shape clone = clone();
clone.rotateOnYAxis(Math.toRadians(location.getYaw()));
for (Vector v : clone.getPoints())
{
Location particleLocation = location.clone().add(v);
displayColoredParticle(particleLocation, color, player);
}
}
/**
* Display a single particle of the type provided to this shape at the given location.
* @param location The location
*/
public void displayParticle(Location location)
{
UtilParticle.PlayParticleToAll(_particle, location, _offsetData, _speed, _count, ViewDist.NORMAL);
}
/**
* Display a single particle of the type provided to this shape at the given location for the given player
* @param location The location
* @param player The player
*/
public void displayParticle(Location location, Player player)
{
UtilParticle.PlayParticle(_particle, location, (float) _offsetData.getX(), (float) _offsetData.getY(), (float) _offsetData.getZ(), _speed, _count, ViewDist.NORMAL, player);
}
/**
* Display a single colored particle of the type provided to this shape at the given location.
* @param location The location
* @param color The color
*/
public void displayColoredParticle(Location location, Color color)
{
ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST, new DustSpellColor(color), location);
coloredParticle.display(ViewDist.NORMAL);
}
/**
* Displays a single colored particle of the type provided to this shape at the given location for the given player
* @param location The location
* @param color The color
* @param player The player
*/
public void displayColoredParticle(Location location, Color color, Player player)
{
ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST, new DustSpellColor(color), location);
coloredParticle.display(ViewDist.NORMAL, player);
}
}

View File

@ -0,0 +1,212 @@
package mineplex.core.common.skin;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import com.google.common.collect.Maps;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.InsecureTextureException;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.properties.Property;
import mineplex.core.common.util.UtilPlayer;
public class SkinData
{
private static final Field PROFILE_FIELD;
static
{
try
{
PROFILE_FIELD = Class.forName("org.bukkit.craftbukkit.v1_8_R3.inventory.CraftMetaSkull").getDeclaredField("profile");
PROFILE_FIELD.setAccessible(true);
}
catch (ReflectiveOperationException ex)
{
throw new RuntimeException(ex);
}
}
private static long _nameCount = -99999999999999L;
public final static SkinData FREEDOM_CHEST = new SkinData("eyJ0aW1lc3RhbXAiOjE0NjY1NzA5NDAzODcsInByb2ZpbGVJZCI6IjQwZWQ5NzU1OWIzNTQ1M2Q4NjU1ZmMwMDM5OGRiNmI5IiwicHJvZmlsZU5hbWUiOiJTcG9vYm5jb29iciIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc4N2Q4OGNlYzNmOWI0M2RiNDg1YTU0Mjc2YTQ1MjQzNGFiZDI2ZDMzY2QzZmZhMTM2N2ZiMzVmOWUzODQifX19", "UgsQyW/HJ/jmDzfI1d7RWFbhKi8PeJAKBuAOk7ajS5dzH5od301KfcmiT2X3TU7cBbUswcKtDb2F/m7gNrg/t+pU7Bi9UKzyALEu9HRjd4s1uKbqGkBip1z5Qycp4fhkSyKvtvTnA2fhpP9oHtE5FxGXdMhZXyF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CQ+p7pB3VwWL6kMLFwDJOuReqJgxo5kIwpET5cKisO9iiCrFL9B++c0M2gcf4g785MpJnUmSc1ABXw2FdZXy7UQugK+HtYDN1vmmu+aGClKQ/GXTecnPeLLnl6X7XyJKAvPQ0NnKhunCxMuRtb1kdwQh+Mxn8cOihGimxCvIBzqonojeUr7SlIcBQ6DguzYDJ+mJoRX7skYnYECE=");
// Comments this out for now, so it doesn't load the player profile
// A better way to do this would check for the properties when getting the skull or the skin
// Might change on the next version
//public final static SkinData MOOSHROOM = new SkinData("eyJ0aW1lc3RhbXAiOjE0NDk4NzI0OTU0MTcsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIxOWJlYTU0Y2FkN2Q1OGFiNWRhNDA2YjBhOTJhYjNhODI0MjI1MjY2Nzc3ZTUzNGI3ZGI2YzM3MmRkZmY3ZiJ9fX0=","UoSif81+UyvkcaanU8KAMYBpw9mefAmWehE2liDUFvk+y0X/9NovsxTYVpIDCltTSpLW3sNgamvbj4Ybs+s6DbudPiEkvh0ER7Bv2v29UJw7RzIdr6/1g548X12zcnh5iPGz/P75uNRnSfTFQx0ed8P/GNkPIjWpDuJFxEj6KcPzrCAGMx+BVw1VwryBIYf9cCDHky8z0bxR89rjiIvPTBFI6MRhqI3vgpEBTySHDS+Ki0Hwl5oa3PwS6+jgYx/4RSfFsb+BawcvDk2Xpkt5UimvqZ5BceYLIfCt4KbShYipgLXLfYUZrntjPemd3SxthjxUuA07i44UxRdiC8uqy1twLT/HUS28gpk68lA/id9tKFwu1CUzshgcmvQPt3ghtNViNziR/2t7D/+5D31Vzmhf6n7Pnpdirt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vJ0VVvv5KsGmVbko2Jxo0SDCxUL2UTH2+eol53FxhkkC+m2geC14k1zsZQLHDF3BgAG9+kFJ4UEoYRKF2Gy1FxeDCJtjYNdrYR8fdaUKRMcpBgEs+ZGe2U9EVVS/ZcBCjB7S+1Ne2bPzPFzTQPuBoMgggo1xbxBmQ5NyhYo4gwgj/xjSLIhb+5h7ioN1URfSRcfYdVv6RRO9l/u9l09jEom8y/jGRviefpEr+/e9iAl5Dd/6nzQgosBQja3NSfqYZmyuet2eI9zu61CObDTpR6yaCbNgBe/lWofRfULdpJpgjb4UNTBom3q82FcCiOe02OekGPw4+YlilhICBhajF5JzN8FKAdqI1osDcX3KuJgikYIW3voNaOP5YN3GXgilJNdou20KFC8ICq68HglgX7/0rLrWKIEoswnINIM6HcJbQuXncVPwQhV6K34Hlt/Na60=");
private String _skinValue;
private String _skinSignature;
private Property _skinProperty = null;
public SkinData(String value, String signature)
{
_skinValue = value;
_skinSignature = signature;
//_skinProperty = new Property("textures", value, signature);
}
private SkinData(GameProfile profile)
{
_skinProperty = profile.getProperties().get("textures").iterator().next();
}
private void getSkinProperty()
{
_skinProperty = new Property("textures", _skinValue, _skinSignature);
}
public ItemStack getSkull()
{
ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
SkullMeta meta = (SkullMeta) item.getItemMeta();
GameProfile data = new GameProfile(UUID.randomUUID(), getUnusedSkullName());
data.getProperties().put("textures", getProperty());
try
{
PROFILE_FIELD.set(meta, data);
}
catch (ReflectiveOperationException t)
{
t.printStackTrace();
}
item.setItemMeta(meta);
return item;
}
public ItemStack getSkull(String name, List<String> lore)
{
ItemStack stack = getSkull();
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(name);
meta.setLore(lore);
stack.setItemMeta(meta);
return stack;
}
public Property getProperty()
{
if (_skinProperty == null)
{
getSkinProperty();
}
return new Property(_skinProperty.getName(), _skinProperty.getValue(), _skinProperty.getSignature());
}
public static String getUnusedSkullName()
{
_nameCount++;
return "_" + _nameCount;
}
/**
* Creates a {@link SkinData} from a given {@link GameProfile}.
* Will return null if the GameProfile does not have any texture data
*
* @param input The GameProfile to get textures from
* @param requireSecure Whether the SkinData should be signed
* @param useDefaultSkins Whether to substitute an Alex or Steve skin if no textures are present
*
* @return The SkinData, or null if no textures are present
*/
public static SkinData constructFromGameProfile(GameProfile input, boolean requireSecure, boolean useDefaultSkins)
{
final Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = Maps.<MinecraftProfileTexture.Type, MinecraftProfileTexture>newHashMap();
try
{
map.putAll(MinecraftServer.getServer().aD().getTextures(input, requireSecure));
}
catch (InsecureTextureException ignored)
{
}
if (map.containsKey(MinecraftProfileTexture.Type.SKIN))
{
return new SkinData(input);
}
if (useDefaultSkins)
{
return UtilPlayer.isSlimSkin(input.getId()) ? SkinData.ALEX : SkinData.STEVE;
}
return null;
}
}

View File

@ -0,0 +1,24 @@
package mineplex.core.common.structs;
import org.bukkit.Material;
public class ItemContainer
{
public Material Type;
public byte Data;
public String Name;
public ItemContainer(Material type, byte data, String name)
{
Type = type;
Data = data;
Name = name;
}
public ItemContainer(int id, byte data, String name)
{
Type = Material.getMaterial(id);
Data = data;
Name = name;
}
}

View File

@ -0,0 +1,30 @@
package mineplex.core.common.timing;
public class TimeData
{
public TimeData(String title, long time)
{
Title = title;
Started = time;
LastMarker = time;
Total = 0L;
}
public String Title;
public long Started;
public long LastMarker;
public long Total;
public int Count = 0;
public void addTime()
{
Total += System.currentTimeMillis() - LastMarker;
LastMarker = System.currentTimeMillis();
Count++;
}
public void printInfo()
{
System.out.println("]==[TIME DATA]==[ " + Count + " " + Title + " took " + Total + "ms in the last " + (System.currentTimeMillis() - Started) + "ms");
}
}

View File

@ -0,0 +1,114 @@
package mineplex.core.common.timing;
import java.util.Map.Entry;
import mineplex.core.common.util.NautHashMap;
public class TimingManager
{
private static NautHashMap<String, Long> _timingList = new NautHashMap<String, Long>();
private static NautHashMap<String, TimeData> _totalList = new NautHashMap<String, TimeData>();
private static Object _timingLock = new Object();
private static Object _totalLock = new Object();
public static boolean Debug = true;
public static void startTotal(String title)
{
if (!Debug)
return;
synchronized(_totalLock)
{
if (_totalList.containsKey(title))
{
TimeData data = _totalList.get(title);
data.LastMarker = System.currentTimeMillis();
_totalList.put(title, data);
}
else
{
TimeData data = new TimeData(title, System.currentTimeMillis());
_totalList.put(title, data);
}
}
}
public static void stopTotal(String title)
{
if (!Debug)
return;
synchronized(_totalLock)
{
if (_totalList.containsKey(title))
{
_totalList.get(title).addTime();
}
}
}
public static void printTotal(String title)
{
if (!Debug)
return;
synchronized(_totalLock)
{
_totalList.get(title).printInfo();
}
}
public static void endTotal(String title, boolean print)
{
if (!Debug)
return;
synchronized(_totalLock)
{
TimeData data = _totalList.remove(title);
if (data != null && print)
data.printInfo();
}
}
public static void printTotals()
{
if (!Debug)
return;
synchronized(_totalLock)
{
for (Entry<String, TimeData> entry : _totalList.entrySet())
{
entry.getValue().printInfo();
}
}
}
public static void start(String title)
{
if (!Debug)
return;
synchronized(_timingLock)
{
_timingList.put(title, System.currentTimeMillis());
}
}
public static void stop(String title)
{
if (!Debug)
return;
synchronized(_timingLock)
{
System.out.println("]==[TIMING]==[" + title + " took " + (System.currentTimeMillis() - _timingList.get(title)) + "ms");
_timingList.remove(title);
}
}
}

View File

@ -0,0 +1,126 @@
package mineplex.core.common.util;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
/**
* Utilities for interleaving Bukkit scheduler operations as
* intermediate and terminal operations in a {@link CompletionStage}
* pipeline.
* <p>
* Any {@link Function}s returned by methods are suitable for use
* in {@link CompletionStage#thenCompose(Function)}
*
* @see CompletableFuture#thenCompose(Function)
*/
public class BukkitFuture
{
private static final Plugin LOADING_PLUGIN = JavaPlugin.getProvidingPlugin(BukkitFuture.class);
private static void runBlocking(Runnable action)
{
Bukkit.getScheduler().runTask(LOADING_PLUGIN, action);
}
/**
* Finalize a {@link CompletionStage} by consuming its value
* on the main thread.
*
* @param action the {@link Consumer} to call on the main thread
* @return a {@link Function} to be passed as an argument to
* {@link CompletionStage#thenCompose(Function)}
* @see CompletableFuture#thenCompose(Function)
*/
public static <T> Function<T, CompletionStage<Void>> accept(Consumer<? super T> action)
{
return val ->
{
CompletableFuture<Void> future = new CompletableFuture<>();
runBlocking(() ->
{
action.accept(val);
future.complete(null);
});
return future;
};
}
/**
* Finalize a {@link CompletionStage} by executing code on the
* main thread after its completion.
*
* @param action the {@link Runnable} that will execute
* @return a {@link Function} to be passed as an argument to
* {@link CompletionStage#thenCompose(Function)}
* @see CompletableFuture#thenCompose(Function)
*/
public static <T> Function<T, CompletionStage<Void>> run(Runnable action)
{
return val ->
{
CompletableFuture<Void> future = new CompletableFuture<>();
runBlocking(() ->
{
action.run();
future.complete(null);
});
return future;
};
}
/**
* Transform a value contained within a {@link CompletionStage}
* by executing a mapping {@link Function} on the main thread.
*
* @param fn the {@link Function} used to transform the value
* @return a {@link Function} to be passed as an argument to
* {@link CompletionStage#thenCompose(Function)}
* @see CompletableFuture#thenCompose(Function)
*/
public static <T,U> Function<T, CompletionStage<U>> map(Function<? super T,? extends U> fn)
{
return val ->
{
CompletableFuture<U> future = new CompletableFuture<>();
runBlocking(() -> future.complete(fn.apply(val)));
return future;
};
}
/**
* Finalize a {@link CompletionStage} by executing code on the
* main thread after its normal or exceptional completion.
*
* @param action the {@link BiConsumer} that will execute
* @return a {@link BiConsumer} to be passed as an argument to
* {@link CompletionStage#whenComplete(BiConsumer)}
* @see CompletableFuture#whenComplete(BiConsumer)
*/
public static <T> BiConsumer<? super T,? super Throwable> complete(BiConsumer<? super T,? super Throwable> action)
{
return (val, throwable) -> runBlocking(() -> action.accept(val, throwable));
}
/**
* Create a {@link CompletionStage} from a supplier executed on the
* main thread.
*
* @param supplier the supplier to run on the main thread
* @return a {@link CompletionStage} whose value will be supplied
* during the next Minecraft tick
*/
public static <T> CompletionStage<T> supply(Supplier<T> supplier)
{
CompletableFuture<T> future = new CompletableFuture<>();
runBlocking(() -> future.complete(supplier.get()));
return future;
}
}

View File

@ -0,0 +1,62 @@
package mineplex.core.common.util;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class ColorFader {
private final int _loopsBetween;
private final List<RGBData> _colors;
private final LoopIterator<RGBData> _iterator;
private int _loopsSinceLast;
public ColorFader(int loopsBetweenColors, RGBData... colors)
{
this(loopsBetweenColors, Arrays.asList(colors));
}
public ColorFader(int loopsBetweenColors, List<RGBData> colors)
{
_loopsBetween = loopsBetweenColors;
_colors = new LinkedList<>(colors);
_iterator = new LoopIterator<>(_colors);
}
public RGBData next()
{
RGBData rgb;
if (_loopsSinceLast >= _loopsBetween)
{
rgb = _iterator.next();
_loopsSinceLast = 0;
}
else
{
int redStep = (_iterator.peekNext().getFullRed() - _iterator.current().getFullRed()) / _loopsBetween;
int greenStep = (_iterator.peekNext().getFullGreen() - _iterator.current().getFullGreen()) / _loopsBetween;
int blueStep = (_iterator.peekNext().getFullBlue() - _iterator.current().getFullBlue()) / _loopsBetween;
int red = _iterator.current().getFullRed();
int green = _iterator.current().getFullGreen();
int blue = _iterator.current().getFullBlue();
for (int i = 0; i < _loopsSinceLast; i++)
{
red += redStep;
green += greenStep;
blue += blueStep;
}
rgb = new RGBData(red, green, blue);
}
_loopsSinceLast++;
return rgb;
}
}

View File

@ -0,0 +1,50 @@
package mineplex.core.common.util;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.enchantments.EnchantmentWrapper;
import org.bukkit.inventory.ItemStack;
public class DullEnchantment extends EnchantmentWrapper
{
public DullEnchantment()
{
super(120);
}
@Override
public boolean canEnchantItem(ItemStack item)
{
return true;
}
@Override
public boolean conflictsWith(Enchantment other)
{
return false;
}
@Override
public EnchantmentTarget getItemTarget()
{
return null;
}
@Override
public int getMaxLevel()
{
return 10;
}
@Override
public String getName()
{
return "Glow";
}
@Override
public int getStartLevel()
{
return 1;
}
}

View File

@ -0,0 +1,31 @@
package mineplex.core.common.util;
public class EnclosedObject<T>
{
private T _value;
public EnclosedObject()
{
this((T) null);
}
public EnclosedObject(T t)
{
_value = t;
}
public T Get()
{
return _value;
}
public T Set(T value)
{
return _value = value;
}
public String toString()
{
return _value.toString();
}
}

View File

@ -0,0 +1,123 @@
package mineplex.core.common.util;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileUtil
{
public static void DeleteFolder(File folder)
{
if (!folder.exists())
{
System.out.println("Delete target does not exist: " + folder);
return;
}
File[] files = folder.listFiles();
if(files != null)
{
for(File f: files)
{
if(f.isDirectory())
DeleteFolder(f);
else
{
f.delete();
}
}
}
folder.delete();
}
public static void CopyToDirectory(File file, String outputDirectory)
{
FileInputStream fileInputStream = null;
FileOutputStream fileOutputStream = null;
BufferedOutputStream bufferedOutputStream = null;
BufferedInputStream bufferedInputStream = null;
try
{
fileInputStream = new FileInputStream(file);
bufferedInputStream = new BufferedInputStream(fileInputStream);
int size;
byte[] buffer = new byte[2048];
fileOutputStream = new FileOutputStream(outputDirectory + "\\" + file.getName());
bufferedOutputStream = new BufferedOutputStream(fileOutputStream, buffer.length);
while ((size = bufferedInputStream.read(buffer, 0, buffer.length)) != -1)
{
bufferedOutputStream.write(buffer, 0, size);
}
bufferedOutputStream.flush();
bufferedOutputStream.close();
fileOutputStream.flush();
fileOutputStream.close();
bufferedInputStream.close();
fileInputStream.close();
}
catch (IOException e)
{
e.printStackTrace();
if (fileInputStream != null)
{
try
{
fileInputStream.close();
}
catch (IOException e1)
{
e1.printStackTrace();
}
}
if (bufferedInputStream != null)
{
try
{
bufferedInputStream.close();
}
catch (IOException e1)
{
e1.printStackTrace();
}
}
if (fileOutputStream != null)
{
try
{
fileOutputStream.close();
}
catch (IOException e1)
{
e1.printStackTrace();
}
}
if (bufferedOutputStream != null)
{
try
{
bufferedOutputStream.close();
}
catch (IOException e1)
{
e1.printStackTrace();
}
}
}
}
}

View File

@ -0,0 +1,46 @@
package mineplex.core.common.util;
import org.apache.commons.lang.math.RandomUtils;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Builder;
import org.bukkit.Location;
import org.bukkit.entity.Firework;
import org.bukkit.inventory.meta.FireworkMeta;
public class FireworkUtil
{
public static Firework LaunchRandomFirework(Location location)
{
Builder builder = FireworkEffect.builder();
if (RandomUtils.nextInt(3) == 0)
{
builder.withTrail();
}
else if (RandomUtils.nextInt(2) == 0)
{
builder.withFlicker();
}
builder.with(FireworkEffect.Type.values()[RandomUtils.nextInt(FireworkEffect.Type.values().length)]);
int colorCount = 17;
builder.withColor(Color.fromRGB(RandomUtils.nextInt(255), RandomUtils.nextInt(255), RandomUtils.nextInt(255)));
while (RandomUtils.nextInt(colorCount) != 0)
{
builder.withColor(Color.fromRGB(RandomUtils.nextInt(255), RandomUtils.nextInt(255), RandomUtils.nextInt(255)));
colorCount--;
}
Firework firework = location.getWorld().spawn(location, Firework.class);
FireworkMeta data = (FireworkMeta) firework.getFireworkMeta();
data.addEffects(builder.build());
data.setPower(RandomUtils.nextInt(3));
firework.setFireworkMeta(data);
return firework;
}
}

View File

@ -0,0 +1,121 @@
package mineplex.core.common.util;
import java.util.HashMap;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory;
import org.bukkit.inventory.ItemStack;
public class InventoryUtil
{
public static HashMap<Integer, ItemStack> removeItem(CraftInventory inventory, int endingSlot, ItemStack... items)
{
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
if (endingSlot >= 54)
return leftover;
for (int i = 0; i < items.length; i++)
{
ItemStack item = items[i];
int toDelete = item.getAmount();
while (true)
{
int first = first(inventory, endingSlot, item, false);
if (first == -1)
{
item.setAmount(toDelete);
leftover.put(i, item);
break;
}
else
{
ItemStack itemStack = inventory.getItem(first);
int amount = itemStack.getAmount();
if (amount <= toDelete)
{
toDelete -= amount;
inventory.clear(first);
}
else
{
itemStack.setAmount(amount - toDelete);
inventory.setItem(first, itemStack);
toDelete = 0;
}
}
if (toDelete <= 0)
break;
}
}
return leftover;
}
public static int first(CraftInventory craftInventory, int endingSlot, ItemStack item, boolean withAmount)
{
if (endingSlot >= 54)
return -1;
ItemStack[] inventory = craftInventory.getContents();
for (int i = 0; i < endingSlot; i++)
{
if (inventory[i] == null)
{
if (item == null)
return i;
else
continue;
}
else if (item == null)
continue;
boolean equals = (item.getTypeId() == inventory[i].getTypeId() && item.getDurability() == inventory[i].getDurability() && item.getEnchantments().equals(inventory[i].getEnchantments()));
if (equals && withAmount)
{
equals = inventory[i].getAmount() >= item.getAmount();
}
if (equals)
{
return i;
}
}
return -1;
}
public static int getCountOfObjectsRemoved(CraftInventory getInventory, int i, ItemStack itemStack)
{
int count = 0;
while(getInventory.contains(itemStack.getType(), itemStack.getAmount()) && InventoryUtil.removeItem(getInventory, i, itemStack).size() == 0)
{
count++;
}
return count;
}
public static int GetCountOfObjectsRemovedInSlot(CraftInventory getInventory, int slot, ItemStack itemStack)
{
int count = 0;
ItemStack slotStack = getInventory.getItem(slot);
while(slotStack.getType() == itemStack.getType() && slotStack.getAmount() >= itemStack.getAmount())
{
slotStack.setAmount(slotStack.getAmount() - itemStack.getAmount());
count++;
}
if (slotStack.getAmount() == 0)
getInventory.setItem(slot, null);
return count;
}
}

View File

@ -0,0 +1,20 @@
package mineplex.core.common.util;
public enum LineFormat
{
LORE(220),
PUNISHMENT_UI(48),
CHAT(319);
private int _length;
private LineFormat(int length)
{
_length = length;
}
public int getLength()
{
return _length;
}
}

View File

@ -0,0 +1,83 @@
package mineplex.core.common.util;
import java.util.List;
public class LoopIterator<T>
{
private List<T> _list;
private int _pointer;
public LoopIterator(List<T> list)
{
_list = list;
}
public T next()
{
if (_list.isEmpty())
{
return null;
}
if (++_pointer == _list.size())
{
_pointer = 0;
}
return _list.get(_pointer);
}
public T peekNext()
{
if (_list.isEmpty())
{
return null;
}
int pointer = _pointer;
if (++pointer == _list.size())
{
pointer = 0;
}
return _list.get(pointer);
}
public T peekPrev()
{
if (_list.isEmpty())
{
return null;
}
int pointer = _pointer;
if (--pointer < 0)
{
pointer = _list.size() - 1;
}
return _list.get(pointer);
}
public T prev()
{
if (_list.isEmpty())
{
return null;
}
if (--_pointer < 0)
{
_pointer = _list.size() - 1;
}
return _list.get(_pointer);
}
public T current()
{
return _list.get(_pointer);
}
}

View File

@ -0,0 +1,306 @@
package mineplex.core.common.util;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.ChunkCoordIntPair;
import net.minecraft.server.v1_8_R3.ExceptionWorldConflict;
import net.minecraft.server.v1_8_R3.IBlockData;
import net.minecraft.server.v1_8_R3.IProgressUpdate;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.PacketPlayOutMultiBlockChange;
import net.minecraft.server.v1_8_R3.RegionFile;
import net.minecraft.server.v1_8_R3.RegionFileCache;
public class MapUtil
{
/*public static void ReplaceOreInChunk(Chunk chunk, Material replacee, Material replacer)
{
net.minecraft.server.v1_8_R3.Chunk c = ((CraftChunk) chunk).getHandle();
for (int x = 0; x < 16; x++)
{
for (int z = 0; z < 16; z++)
{
for (int y = 0; y < 18; y++)
{
int bX = c.locX << 4 | x & 0xF;
int bY = y & 0xFF;
int bZ = c.locZ << 4 | z & 0xF;
if (c.getTypeAbs(bX, bY, bZ).k() == replacee.getId())
{
c.b(bX & 0xF, bY, bZ & 0xF, replacer.getId());
}
}
}
}
c.initLighting();
}*/
public static void QuickChangeBlockAt(Location location, Material setTo)
{
QuickChangeBlockAt(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), setTo);
}
public static void QuickChangeBlockAt(Location location, Material setTo, byte data)
{
QuickChangeBlockAt(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), setTo, data);
}
public static void QuickChangeBlockAt(Location location, int id, byte data)
{
QuickChangeBlockAt(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), id,
data);
}
public static void QuickChangeBlockAt(World world, int x, int y, int z, Material setTo)
{
QuickChangeBlockAt(world, x, y, z, setTo, 0);
}
public static void QuickChangeBlockAt(World world, int x, int y, int z, Material setTo, int data)
{
QuickChangeBlockAt(world, x, y, z, setTo.getId(), data);
}
public static void QuickChangeBlockAt(World world, int x, int y, int z, int id, int data)
{
Chunk chunk = world.getChunkAt(x >> 4, z >> 4);
net.minecraft.server.v1_8_R3.Chunk c = ((CraftChunk) chunk).getHandle();
//c.a(x & 0xF, y, z & 0xF, Block.getById(id), data);
IBlockData blockData = CraftMagicNumbers.getBlock(id).fromLegacyData(data);
c.a(getBlockPos(x, y, z), blockData);
((CraftWorld) world).getHandle().notify(getBlockPos(x, y, z));
}
public static int GetHighestBlockInCircleAt(World world, int bx, int bz, int radius)
{
int count = 0;
int totalHeight = 0;
final double invRadiusX = 1 / radius;
final double invRadiusZ = 1 / radius;
final int ceilRadiusX = (int) Math.ceil(radius);
final int ceilRadiusZ = (int) Math.ceil(radius);
double nextXn = 0;
forX: for (int x = 0; x <= ceilRadiusX; ++x)
{
final double xn = nextXn;
nextXn = (x + 1) * invRadiusX;
double nextZn = 0;
forZ: for (int z = 0; z <= ceilRadiusZ; ++z)
{
final double zn = nextZn;
nextZn = (z + 1) * invRadiusZ;
double distanceSq = xn * xn + zn * zn;
if (distanceSq > 1)
{
if (z == 0)
{
break forX;
}
break forZ;
}
totalHeight += world.getHighestBlockAt(bx + x, bz + z).getY();
count++;
}
}
return totalHeight / count;
}
public static void ChunkBlockChange(Location location, int id, byte data, boolean notifyPlayers)
{
ChunkBlockChange(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), id,
data, notifyPlayers);
}
public static void ChunkBlockChange(World world, int x, int y, int z, int id, byte data, boolean notifyPlayers)
{
if (changeChunkBlock(x & 15, y, z & 15, ((CraftWorld) world).getHandle().getChunkAt(x >> 4, z >> 4),
Block.getById(id), data))
{
if (notifyPlayers)
((CraftWorld) world).getHandle().notify(getBlockPos(x, y, z));
}
}
public static void ChunkBlockSet(World world, int x, int y, int z, int id, byte data, boolean notifyPlayers)
{
world.getBlockAt(x, y, z).setTypeIdAndData(id, data, notifyPlayers);
}
private static boolean changeChunkBlock(int x, int y, int z, net.minecraft.server.v1_8_R3.Chunk chunk, Block block,
byte data)
{
chunk.a(getBlockPos(x, y, z), block.fromLegacyData(data));
return true; // todo?
// return chunk.a(x, y, z, block, data);
}
public static void SendChunkForPlayer(net.minecraft.server.v1_8_R3.Chunk chunk, Player player)
{
SendChunkForPlayer(chunk.locX, chunk.locZ, player);
}
@SuppressWarnings("unchecked")
public static void SendChunkForPlayer(int x, int z, Player player)
{
// System.out.println("Sending Chunk " + x + ", " + z);
((CraftPlayer) player).getHandle().chunkCoordIntPairQueue.add(new ChunkCoordIntPair(x, z));
}
@SuppressWarnings("unchecked")
public static void SendMultiBlockForPlayer(int x, int z, short[] dirtyBlocks, int dirtyCount, World world,
Player player)
{
// System.out.println("Sending MultiBlockChunk " + x + ", " + z);
UtilPlayer.sendPacket(player, new PacketPlayOutMultiBlockChange(dirtyCount, dirtyBlocks, ((CraftWorld) world).getHandle()
.getChunkAt(x, z)));
}
public static void UnloadWorld(JavaPlugin plugin, World world)
{
UnloadWorld(plugin, world, false);
}
public static void UnloadWorld(JavaPlugin plugin, World world, boolean save)
{
if (save)
{
try
{
((CraftWorld) world).getHandle().save(true, (IProgressUpdate) null);
}
catch (ExceptionWorldConflict e)
{
e.printStackTrace();
}
((CraftWorld) world).getHandle().saveLevel();
}
world.setAutoSave(save);
CraftServer server = (CraftServer) plugin.getServer();
CraftWorld craftWorld = (CraftWorld) world;
Bukkit.getPluginManager().callEvent(new WorldUnloadEvent(((CraftWorld) world).getHandle().getWorld()));
Iterator<net.minecraft.server.v1_8_R3.Chunk> chunkIterator = ((CraftWorld) world).getHandle().chunkProviderServer.chunks
.values().iterator();
for (Entity entity : world.getEntities())
{
entity.remove();
}
while (chunkIterator.hasNext())
{
net.minecraft.server.v1_8_R3.Chunk chunk = chunkIterator.next();
chunk.removeEntities();
}
((CraftWorld) world).getHandle().chunkProviderServer.chunks.clear();
((CraftWorld) world).getHandle().chunkProviderServer.unloadQueue.clear();
try
{
Field f = server.getClass().getDeclaredField("worlds");
f.setAccessible(true);
@SuppressWarnings("unchecked")
Map<String, World> worlds = (Map<String, World>) f.get(server);
worlds.remove(world.getName().toLowerCase());
f.setAccessible(false);
}
catch (IllegalAccessException ex)
{
System.out.println("Error removing world from bukkit master list: " + ex.getMessage());
}
catch (NoSuchFieldException ex)
{
System.out.println("Error removing world from bukkit master list: " + ex.getMessage());
}
MinecraftServer ms = server.getServer();
ms.worlds.remove(ms.worlds.indexOf(craftWorld.getHandle()));
}
@SuppressWarnings({ "rawtypes" })
public static boolean ClearWorldReferences(String worldName)
{
synchronized (RegionFileCache.class)
{
HashMap regionfiles = (HashMap) RegionFileCache.a;
try
{
for (Iterator<Object> iterator = regionfiles.entrySet().iterator(); iterator.hasNext(); )
{
Map.Entry e = (Map.Entry) iterator.next();
RegionFile file = (RegionFile) e.getValue();
try
{
file.c();
iterator.remove();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
catch (Exception ex)
{
System.out.println("Exception while removing world reference for '" + worldName + "'!");
ex.printStackTrace();
}
return true;
}
}
public static BlockPosition getBlockPos(Location loc)
{
return getBlockPos(loc.toVector());
}
public static BlockPosition getBlockPos(Vector v)
{
return getBlockPos(v.getBlockX(), v.getBlockY(), v.getBlockZ());
}
public static BlockPosition getBlockPos(int x, int y, int z)
{
return new BlockPosition(x, y, z);
}
}

View File

@ -0,0 +1,28 @@
package mineplex.core.common.util;
public class NumberFloater
{
private double _min;
private double _max;
private double _modifyPerCall;
private double _cur;
private boolean _up;
public NumberFloater(double min, double max, double modify)
{
_min = min;
_max = max;
_modifyPerCall = modify;
}
public double pulse()
{
if (_up && (_cur = UtilMath.clamp(_cur += _modifyPerCall, _min, _max)) >= _max)
_up = false;
else if ((_cur = UtilMath.clamp(_cur -= _modifyPerCall, _min, _max)) <= _min)
_up = true;
return _cur;
}
}

View File

@ -0,0 +1,26 @@
package mineplex.core.common.util;
import java.util.UUID;
public class PlayerInfo
{
private String _name;
private UUID _uuid;
public PlayerInfo(String name, UUID uuid)
{
_name = name;
_uuid = uuid;
}
public String getName()
{
return _name;
}
public UUID getUUID()
{
return _uuid;
}
}

View File

@ -0,0 +1,235 @@
package mineplex.core.common.util;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nonnull;
import org.apache.commons.lang3.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerMap<V> implements Map<UUID, V>
{
private static final Object LOCK = new Object();
private static final RemovalListener REMOVAL_LISTENER = new RemovalListener();
private static final Set<PlayerMap<?>> ALL_PLAYER_MAPS = Collections.newSetFromMap(new WeakHashMap<>());
static
{
UtilServer.RegisterEvents(REMOVAL_LISTENER);
}
private final Map<UUID, V> _backingMap;
private PlayerMap(Map<UUID, V> backingMap)
{
this._backingMap = backingMap;
synchronized (LOCK)
{
ALL_PLAYER_MAPS.add(this);
}
}
public static <V> PlayerMap<V> newMap()
{
return new PlayerMap<>(new HashMap<>());
}
public static <V> PlayerMap<V> newConcurrentMap()
{
return new PlayerMap<>(new ConcurrentHashMap<>());
}
@Override
public int size()
{
return _backingMap.size();
}
@Override
public boolean isEmpty()
{
return _backingMap.isEmpty();
}
@Override
@Deprecated
public boolean containsKey(Object key)
{
Validate.notNull(key, "Key cannot be null");
if (key instanceof Player)
{
return containsKey((Player) key);
}
else if (key instanceof UUID)
{
return containsKey((UUID) key);
}
throw new UnsupportedOperationException("Unknown key type: " + key.getClass().getName());
}
public boolean containsKey(Player key)
{
Validate.notNull(key, "Player cannot be null");
return _backingMap.containsKey(key.getUniqueId());
}
public boolean containsKey(UUID key)
{
return _backingMap.containsKey(key);
}
@Override
public boolean containsValue(Object value)
{
return _backingMap.containsValue(value);
}
@Override
@Deprecated
public V get(Object key)
{
Validate.notNull(key, "Key cannot be null");
if (key instanceof Player)
{
return get((Player) key);
}
else if (key instanceof UUID)
{
return get((UUID) key);
}
throw new UnsupportedOperationException("Unknown key type: " + key.getClass().getName());
}
public V get(Player key)
{
return _backingMap.get(key.getUniqueId());
}
public V get(UUID key)
{
return _backingMap.get(key);
}
@Override
public V put(UUID key, V value)
{
return _backingMap.put(key, value);
}
public V put(Player key, V value)
{
Validate.notNull(key, "Player cannot be null");
return put(key.getUniqueId(), value);
}
@Override
@Deprecated
public V remove(Object key)
{
Validate.notNull(key, "Key cannot be null");
if (key instanceof Player)
{
return remove((Player) key);
}
else if (key instanceof UUID)
{
return remove((UUID) key);
}
throw new UnsupportedOperationException("Unknown key type: " + key.getClass().getName());
}
public V remove(Player key)
{
return _backingMap.remove(key.getUniqueId());
}
public V remove(UUID key)
{
return _backingMap.remove(key);
}
@Override
public void putAll(@Nonnull Map<? extends UUID, ? extends V> m)
{
_backingMap.putAll(m);
}
@Override
public void clear()
{
_backingMap.clear();
}
@Override
@Nonnull
public Set<UUID> keySet()
{
return _backingMap.keySet();
}
@Override
@Nonnull
public Collection<V> values()
{
return _backingMap.values();
}
@Override
@Nonnull
public Set<Entry<UUID, V>> entrySet()
{
return _backingMap.entrySet();
}
@Override
public String toString()
{
return _backingMap.toString();
}
@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PlayerMap<?> playerMap = (PlayerMap<?>) o;
return _backingMap.equals(playerMap._backingMap);
}
@Override
public int hashCode()
{
return _backingMap.hashCode();
}
private static class RemovalListener implements Listener
{
@EventHandler (priority = EventPriority.MONITOR)
public void onQuit(PlayerQuitEvent event)
{
synchronized (LOCK)
{
for (PlayerMap<?> map : ALL_PLAYER_MAPS)
{
map.remove(event.getPlayer());
}
}
}
}
}

View File

@ -0,0 +1,122 @@
package mineplex.core.common.util;
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;
import java.util.UUID;
import java.util.logging.Level;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
public class ProfileLoader
{
private final String uuid;
private final String name;
private final String skinOwner;
public ProfileLoader(String uuid, String name)
{
this(uuid, name, name);
}
public ProfileLoader(String uuid, String name, String skinOwner)
{
this.uuid = uuid == null ? null : uuid.replaceAll("-", ""); // We add
// these
// later
String displayName = ChatColor.translateAlternateColorCodes('&', name);
this.name = ChatColor.stripColor(displayName);
this.skinOwner = skinOwner;
}
public GameProfile loadProfile()
{
UUID id = uuid == null ? parseUUID(getUUID(name)) : parseUUID(uuid);
GameProfile profile = new GameProfile(id, name);
addProperties(profile);
return profile;
}
public static boolean addProperties(GameProfile profile)
{
String uuid = profile.getId().toString().replaceAll("-", "");
try
{
// Get the name from SwordPVP
URL url = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false");
URLConnection uc = url.openConnection();
uc.setUseCaches(false);
uc.setDefaultUseCaches(false);
uc.addRequestProperty("User-Agent", "Mozilla/5.0");
uc.addRequestProperty("Cache-Control", "no-cache, no-store, must-revalidate");
uc.addRequestProperty("Pragma", "no-cache");
// Parse it
String json = new Scanner(uc.getInputStream(), "UTF-8").useDelimiter("\\A").next();
JSONParser parser = new JSONParser();
Object obj = parser.parse(json);
JSONArray properties = (JSONArray) ((JSONObject) obj).get("properties");
for (int i = 0; i < properties.size(); i++)
{
try
{
JSONObject property = (JSONObject) properties.get(i);
String name = (String) property.get("name");
String value = (String) property.get("value");
String signature = property.containsKey("signature") ? (String) property.get("signature") : null;
if (signature != null)
{
profile.getProperties().put(name, new Property(name, value, signature));
}
else
{
profile.getProperties().put(name, new Property(value, name));
}
}
catch (Exception e)
{
Bukkit.getLogger().log(Level.WARNING, "Failed to apply auth property", e);
}
}
return true;
}
catch (Exception e)
{
e.printStackTrace();
}
return false;
}
@SuppressWarnings("deprecation")
private String getUUID(String name)
{
return Bukkit.getOfflinePlayer(name).getUniqueId().toString().replaceAll("-", "");
}
private UUID parseUUID(String uuidStr)
{
// Split uuid in to 5 components
String[] uuidComponents = new String[] { uuidStr.substring(0, 8), uuidStr.substring(8, 12),
uuidStr.substring(12, 16), uuidStr.substring(16, 20), uuidStr.substring(20, uuidStr.length()) };
// Combine components with a dash
StringBuilder builder = new StringBuilder();
for (String component : uuidComponents)
{
builder.append(component).append('-');
}
// Correct uuid length, remove last dash
builder.setLength(builder.length() - 1);
return UUID.fromString(builder.toString());
}
}

View File

@ -0,0 +1,70 @@
package mineplex.core.common.util;
import org.bukkit.util.Vector;
public class RGBData
{
private double _red;
private double _green;
private double _blue;
public RGBData(int red, int green, int blue)
{
_red = UtilMath.clamp(((double) red) / 255.d, 0, 1);
_green = UtilMath.clamp(((double) green) / 255.d, 0, 1);
_blue = UtilMath.clamp(((double) blue) / 255.d, 0, 1);
}
public int getFullRed()
{
return (int) (_red * 255);
}
public int getFullGreen()
{
return (int) (_green * 255);
}
public int getFullBlue()
{
return (int) (_blue * 255);
}
public double getRed()
{
return _red;
}
public double getGreen()
{
return _green;
}
public double getBlue()
{
return _blue;
}
public String toString()
{
return "RGB["
+ "red=" + (int) (_red * 255) + ", "
+ "green=" + (int) (_green * 255) + ", "
+ "blue=" + (int) (_blue * 255) + "]";
}
public Vector ToVector()
{
return new Vector(Math.max(0.001, _red), _green, _blue);
}
public RGBData Darken()
{
return new RGBData(getFullRed() - 25, getFullGreen() - 25, getFullBlue() - 25);
}
public RGBData Lighten()
{
return new RGBData(getFullRed() + 25, getFullGreen() + 25, getFullBlue() + 25);
}
}

View File

@ -0,0 +1,38 @@
package mineplex.core.common.util;
import org.bukkit.Location;
public class RadarData
{
public Location Loc;
public String Text;
private double _bearing = 0;
public RadarData(Location loc, String text)
{
Loc = loc;
Text = text;
}
public void print()
{
System.out.println(Text + ": " + _bearing);
}
public void setBearing(double d)
{
while (d < -180)
d += 360;
while (d > 180)
d -= 360;
_bearing = d;
}
public double getBearing()
{
return _bearing;
}
}

View File

@ -0,0 +1,32 @@
package mineplex.core.common.util;
import com.google.common.base.Optional;
import net.minecraft.server.v1_8_R3.EntityTameableAnimal;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftTameableAnimal;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Tameable;
public class SpigotUtil
{
// Explanation:
// - Tameable animals (wolves, ocelots) keep track of their most
// recent owner.
// - When an animal is assigned a new owner, its data watcher is
// updated with the new owner's UUID
// - During this process, the old owner's UUID is checked against
// the new one
// - If the animal didn't have a previous owner, the old owner's
// UUID is the empty string.
// - UUID.fromString() is called on the empty string, and throws
// an exception.
//
// We can mitigate this issue by manually setting a previous owner
// UUID before we call Tameable#setOwner(AnimalTamer)
//
// (note: this does not apply to horses)
public static void setOldOwner_RemoveMeWhenSpigotFixesThis(Tameable tameable, AnimalTamer tamer)
{
((CraftTameableAnimal)tameable).getHandle().getDataWatcher().watch(17, tamer.getUniqueId().toString(), EntityTameableAnimal.META_OWNER, Optional.absent());
}
}

View File

@ -0,0 +1,9 @@
package mineplex.core.common.util;
public class TimeSpan
{
public static final long DAY = 86400000;
public static final long HOUR = 3600000;
public static final long MINUTE = 60000;
public static final long SECOND = 1000;
}

View File

@ -0,0 +1,103 @@
package mineplex.core.common.util;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.ByteBuffer;
import java.util.*;
public class UUIDFetcher
{
private static UUIDFetcher _instance = new UUIDFetcher();
private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
private final JSONParser _jsonParser = new JSONParser();
public UUID getPlayerUUID(String name)
{
UUID uuid = null;
List<String> nameList = new ArrayList<String>();
nameList.add(name);
try
{
HttpURLConnection connection = createConnection();
String body = JSONArray.toJSONString(nameList.subList(0, Math.min(100, 1)));
writeBody(connection, body);
JSONArray array = (JSONArray) _jsonParser.parse(new InputStreamReader(connection.getInputStream()));
for (Object profile : array)
{
JSONObject jsonProfile = (JSONObject) profile;
String id = (String) jsonProfile.get("id");
uuid = UUIDFetcher.getUUID(id);
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
return uuid;
}
private static void writeBody(HttpURLConnection connection, String body) throws Exception
{
OutputStream stream = connection.getOutputStream();
stream.write(body.getBytes());
stream.flush();
stream.close();
}
private static HttpURLConnection createConnection() throws Exception
{
URL url = new URL(PROFILE_URL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
return connection;
}
private static UUID getUUID(String id)
{
return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-"
+ id.substring(16, 20) + "-" + id.substring(20, 32));
}
public static byte[] toBytes(UUID uuid)
{
ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
byteBuffer.putLong(uuid.getMostSignificantBits());
byteBuffer.putLong(uuid.getLeastSignificantBits());
return byteBuffer.array();
}
public static UUID fromBytes(byte[] array)
{
if (array.length != 16)
{
throw new IllegalArgumentException("Illegal byte array length: " + array.length);
}
ByteBuffer byteBuffer = ByteBuffer.wrap(array);
long mostSignificant = byteBuffer.getLong();
long leastSignificant = byteBuffer.getLong();
return new UUID(mostSignificant, leastSignificant);
}
public static UUID getUUIDOf(String name)
{
if (_instance == null)
_instance = new UUIDFetcher();
return _instance.getPlayerUUID(name);
}
}

View File

@ -0,0 +1,102 @@
package mineplex.core.common.util;
import mineplex.core.common.events.EntityVelocityChangeEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class UtilAction
{
private static VelocityReceiver _velocityFix;
public static void registerVelocityFix(VelocityReceiver velocityFix)
{
_velocityFix = velocityFix;
}
public static void velocity(Entity ent, Vector vec)
{
velocity(ent, vec, vec.length(), false, 0, 0, vec.length(), false);
}
public static void velocity(Entity ent, double str, double yAdd, double yMax, boolean groundBoost)
{
velocity(ent, ent.getLocation().getDirection(), str, false, 0, yAdd, yMax, groundBoost);
}
public static void velocity(Entity ent, Vector vec, double str, boolean ySet, double yBase, double yAdd, double yMax, boolean groundBoost)
{
if (Double.isNaN(vec.getX()) || Double.isNaN(vec.getY()) || Double.isNaN(vec.getZ()) || vec.length() == 0)
{
zeroVelocity(ent);
return;
}
//YSet
if (ySet)
vec.setY(yBase);
//Modify
vec.normalize();
vec.multiply(str);
//YAdd
vec.setY(vec.getY() + yAdd);
//Limit
if (vec.getY() > yMax)
vec.setY(yMax);
if (groundBoost)
if (UtilEnt.isGrounded(ent))
vec.setY(vec.getY() + 0.2);
EntityVelocityChangeEvent event = new EntityVelocityChangeEvent(ent, vec);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
vec = event.getVelocity();
//Velocity
ent.setFallDistance(0);
//Store It!
if (ent instanceof Player && _velocityFix != null)
{
_velocityFix.setPlayerVelocity(((Player)ent), vec);
}
ent.setVelocity(vec);
}
public static void zeroVelocity(Entity ent)
{
Vector vec = new Vector(0,0,0);
EntityVelocityChangeEvent event = new EntityVelocityChangeEvent(ent, vec);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
vec = event.getVelocity();
ent.setFallDistance(0);
//Store It!
if (ent instanceof Player && _velocityFix != null)
{
_velocityFix.setPlayerVelocity(((Player)ent), vec);
}
ent.setVelocity(vec);
}
}

View File

@ -0,0 +1,702 @@
package mineplex.core.common.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.TrigMath;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
public class UtilAlg
{
public static TreeSet<String> sortKey(Set<String> toSort)
{
return sortSet(toSort, null);
}
public static <T> TreeSet<T> sortSet(Collection<T> toSort, Comparator<T> comparator)
{
TreeSet<T> sortedSet = new TreeSet<>(comparator);
sortedSet.addAll(toSort);
return sortedSet;
}
public static Location getMidpoint(Location a, Location b)
{
return a.clone().add(b.clone().subtract(a.clone()).multiply(0.5));
}
public static Vector getTrajectory(Entity from, Entity to)
{
return getTrajectory(from.getLocation().toVector(), to.getLocation().toVector());
}
public static Vector getTrajectory(Location from, Location to)
{
return getTrajectory(from.toVector(), to.toVector());
}
public static Vector getTrajectory(Vector from, Vector to)
{
return to.clone().subtract(from).normalize();
}
public static double[] getTrajectory(double srcx, double srcy, double srcz, double dstx, double dsty, double dstz)
{
double dx = dstx - srcx;
double dy = dsty - srcy;
double dz = dstz - srcz;
double len = Math.sqrt(dx * dx + dy * dy + dz * dz);
return new double[]{dx / len, dy / len, dz / len};
}
public static Vector getTrajectory2d(Entity from, Entity to)
{
return getTrajectory2d(from.getLocation().toVector(), to.getLocation().toVector());
}
public static Vector getTrajectory2d(Location from, Location to)
{
return getTrajectory2d(from.toVector(), to.toVector());
}
public static Vector getTrajectory2d(Vector from, Vector to)
{
return to.clone().subtract(from).setY(0).normalize();
}
public static boolean HasSight(Location from, Player to)
{
return HasSight(from, to.getLocation()) || HasSight(from, to.getEyeLocation());
}
public static boolean HasSight(Location from, Location to)
{
//Clone Location
Location cur = new Location(from.getWorld(), from.getX(), from.getY(), from.getZ());
double rate = 0.1;
Vector vec = getTrajectory(from, to).multiply(0.1);
while (UtilMath.offset(cur, to) > rate)
{
cur.add(vec);
if (!UtilBlock.airFoliage(cur.getBlock()))
return false;
}
return true;
}
public static Vector getTrajectory(float yaw, float pitch)
{
return new Location(null, 0, 0, 0, yaw, pitch).getDirection();
}
public static float GetPitch(Vector vec)
{
return GetPitch(vec.getX(), vec.getY(), vec.getZ());
}
public static float GetPitch(double[] vec)
{
return GetPitch(vec[0], vec[1], vec[2]);
}
public static float GetPitch(double x, double y, double z)
{
double xz = Math.sqrt((x * x) + (z * z));
double pitch = Math.toDegrees(TrigMath.atan(xz / y));
if (y <= 0) pitch += 90;
else pitch -= 90;
//Fix for two vectors at same Y giving 180
if (pitch == 180)
pitch = 0;
return (float) pitch;
}
public static float GetYaw(Vector vec)
{
return GetYaw(vec.getX(), vec.getY(), vec.getZ());
}
public static float GetYaw(double[] vec)
{
return GetYaw(vec[0], vec[1], vec[2]);
}
public static float GetYaw(double x, double y, double z)
{
double yaw = Math.toDegrees(TrigMath.atan((-x) / z));
if (z < 0) yaw += 180;
return (float) yaw;
}
public static Vector Normalize(Vector vec)
{
if (vec.length() > 0)
vec.normalize();
return vec;
}
public static <T> T Random(Set<T> set)
{
return Random(new ArrayList<>(set));
}
public static <T> T Random(List<T> list)
{
if (list == null || list.isEmpty())
{
return null;
}
return list.get(UtilMath.r(list.size()));
}
public static <T> T Random(List<T> list, List<T> exclude)
{
int attempts = 0;
T element;
do
{
element = Random(list);
attempts++;
}
while (element != null && exclude.contains(element) && attempts < 15);
return element;
}
public static <T> void shuffle(T[] array)
{
int size = array.length;
for (int from = 0; from < size; from++)
{
int to = UtilMath.r(size);
T temp = array[from];
array[from] = array[to];
array[to] = temp;
}
}
public static List<Block> getBox(Block cornerA, Block cornerB)
{
if (cornerA == null || cornerB == null || (cornerA.getWorld() != cornerB.getWorld()))
return Collections.emptyList();
ArrayList<Block> list = new ArrayList<>();
int minX = Math.min(cornerA.getX(), cornerB.getX());
int minY = Math.min(cornerA.getY(), cornerB.getY());
int minZ = Math.min(cornerA.getZ(), cornerB.getZ());
int maxX = Math.max(cornerA.getX(), cornerB.getX());
int maxY = Math.max(cornerA.getY(), cornerB.getY());
int maxZ = Math.max(cornerA.getZ(), cornerB.getZ());
for (int x = minX; x <= maxX; x++)
{
for (int y = minY; y <= maxY; y++)
{
for (int z = minZ; z <= maxZ; z++)
{
list.add(cornerA.getWorld().getBlockAt(x, y, z));
}
}
}
return list;
}
public static boolean inBoundingBox(Location loc, Location cornerA, Location cornerB)
{
if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false;
if (loc.getX() >= Math.max(cornerA.getX(), cornerB.getX())) return false;
if (cornerA.getY() != cornerB.getY())
{
if (loc.getY() <= Math.min(cornerA.getY(), cornerB.getY())) return false;
if (loc.getY() >= Math.max(cornerA.getY(), cornerB.getY())) return false;
}
if (loc.getZ() <= Math.min(cornerA.getZ(), cornerB.getZ())) return false;
if (loc.getZ() >= Math.max(cornerA.getZ(), cornerB.getZ())) return false;
return true;
}
public static boolean inBoundingBox(Location loc, Vector cornerA, Vector cornerB)
{
if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false;
if (loc.getX() >= Math.max(cornerA.getX(), cornerB.getX())) return false;
if (cornerA.getY() != cornerB.getY())
{
if (loc.getY() <= Math.min(cornerA.getY(), cornerB.getY())) return false;
if (loc.getY() >= Math.max(cornerA.getY(), cornerB.getY())) return false;
}
if (loc.getZ() <= Math.min(cornerA.getZ(), cornerB.getZ())) return false;
if (loc.getZ() >= Math.max(cornerA.getZ(), cornerB.getZ())) return false;
return true;
}
public static Vector cross(Vector a, Vector b)
{
double x = a.getY() * b.getZ() - a.getZ() * b.getY();
double y = a.getZ() * b.getX() - a.getX() * b.getZ();
double z = a.getX() * b.getY() - a.getY() * b.getX();
return new Vector(x, y, z).normalize();
}
public static Vector getRight(Vector vec)
{
return cross(vec.clone().normalize(), new Vector(0, 1, 0));
}
public static Vector getLeft(Vector vec)
{
return getRight(vec).multiply(-1);
}
public static Vector getBehind(Vector vec)
{
return vec.clone().multiply(-1);
}
public static Vector getUp(Vector vec)
{
return getDown(vec).multiply(-1);
}
public static Vector getDown(Vector vec)
{
return cross(vec, getRight(vec));
}
public static Location getAverageLocation(List<Location> locs)
{
if (locs.isEmpty())
return null;
Vector vec = new Vector(0, 0, 0);
double amount = 0;
for (Location loc : locs)
{
vec.add(loc.toVector());
amount++;
}
vec.multiply(1d / amount);
return vec.toLocation(locs.get(0).getWorld());
}
public static Location getAverageBlockLocation(List<Block> locs)
{
if (locs.isEmpty())
return null;
Vector vec = new Vector(0, 0, 0);
double amount = 0;
for (Block loc : locs)
{
vec.add(loc.getLocation().toVector());
amount++;
}
vec.multiply(1d / amount);
return vec.toLocation(locs.get(0).getWorld());
}
public static Vector getAverageBump(Location source, List<Location> locs)
{
if (locs.isEmpty())
return null;
Vector vec = new Vector(0, 0, 0);
double amount = 0;
for (Location loc : locs)
{
vec.add(UtilAlg.getTrajectory(loc, source));
amount++;
}
vec.multiply(1d / amount);
return vec;
}
public static Entity findClosest(Entity mid, Collection<Entity> locs)
{
Entity bestLoc = null;
double bestDist = 0;
for (Entity loc : locs)
{
double dist = UtilMath.offsetSquared(mid, loc);
if (bestLoc == null || dist < bestDist)
{
bestLoc = loc;
bestDist = dist;
}
}
return bestLoc;
}
public static Location findClosest(Location mid, Collection<Location> locs)
{
Location bestLoc = null;
double bestDist = 0;
for (Location loc : locs)
{
double dist = UtilMath.offsetSquared(mid, loc);
if (bestLoc == null || dist < bestDist)
{
bestLoc = loc;
bestDist = dist;
}
}
return bestLoc;
}
public static Location findFurthest(Location mid, Collection<Location> locs)
{
Location bestLoc = null;
double bestDist = 0;
for (Location loc : locs)
{
double dist = UtilMath.offsetSquared(mid, loc);
if (bestLoc == null || dist > bestDist)
{
bestLoc = loc;
bestDist = dist;
}
}
return bestLoc;
}
public static boolean isInPyramid(Vector a, Vector b, double angleLimit)
{
return (Math.abs(GetPitch(a) - GetPitch(b)) < angleLimit) && (Math.abs(GetYaw(a) - GetYaw(b)) < angleLimit);
}
public static boolean isTargetInPlayerPyramid(Player player, Player target, double angleLimit)
{
return isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getEyeLocation()), angleLimit) ||
isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getLocation()), angleLimit);
}
public static Location getLocationAwayFromPlayers(List<Location> locations, List<Player> players)
{
return getLocationAwayFromOtherLocations(locations, players.stream()
.map(Entity::getLocation)
.collect(Collectors.toList()));
}
public static Location getLocationAwayFromOtherLocations(List<Location> locations, List<Location> players)
{
Location bestLocation = null;
double bestDist = 0;
for (Location location : locations)
{
double closest = -1;
for (Location player : players)
{
//Different Worlds
if (!player.getWorld().equals(location.getWorld()))
{
continue;
}
double dist = UtilMath.offsetSquared(player, location);
if (closest == -1 || dist < closest)
{
closest = dist;
}
}
// if (closest == -1)
// {
// continue;
// }
if (bestLocation == null || closest > bestDist)
{
bestLocation = location;
bestDist = closest;
}
}
return bestLocation;
}
public static Location getLocationNearPlayers(List<Location> locs, ArrayList<Player> players, ArrayList<Player> dontOverlap)
{
Location bestLoc = null;
double bestDist = 0;
for (Location loc : locs)
{
double closest = -1;
boolean valid = true;
//Dont spawn on other players
for (Player player : dontOverlap)
{
if (!player.getWorld().equals(loc.getWorld()))
continue;
double dist = UtilMath.offsetSquared(player.getLocation(), loc);
if (dist < 0.8)
{
valid = false;
break;
}
}
if (!valid)
continue;
//Find closest player
for (Player player : players)
{
if (!player.getWorld().equals(loc.getWorld()))
continue;
double dist = UtilMath.offsetSquared(player.getLocation(), loc);
if (closest == -1 || dist < closest)
{
closest = dist;
}
}
if (closest == -1)
continue;
if (bestLoc == null || closest < bestDist)
{
bestLoc = loc;
bestDist = closest;
}
}
return bestLoc;
}
public static Vector calculateVelocity(Vector from, Vector to, double heightGain, Entity entity)
{
if (entity instanceof LivingEntity)
{
return calculateVelocity(from, to, heightGain, 1.15);
}
else
{
return calculateVelocity(from, to, heightGain, 0.115);
}
}
public static Vector calculateVelocity(Vector from, Vector to, double heightGain)
{
return calculateVelocity(from, to, heightGain, 0.115);
}
public static Vector calculateVelocity(Vector from, Vector to, double heightGain, double gravity)
{
// Block locations
int endGain = to.getBlockY() - from.getBlockY();
double dx1 = to.getBlockX() - from.getBlockX();
double dz1 = to.getBlockZ() - from.getBlockZ();
double horizDist = Math.sqrt(dx1 * dx1 + dz1 * dz1);
// Height gain
double maxGain = heightGain > (endGain + heightGain) ? heightGain : (endGain + heightGain);
// Solve quadratic equation for velocity
double a = -horizDist * horizDist / (4 * maxGain);
double b = horizDist;
double c = -endGain;
double slope = -b / (2 * a) - Math.sqrt(b * b - 4 * a * c) / (2 * a);
// Vertical velocity
double vy = Math.sqrt(maxGain * gravity);
// Horizontal velocity
double vh = vy / slope;
// Calculate horizontal direction
int dx = to.getBlockX() - from.getBlockX();
int dz = to.getBlockZ() - from.getBlockZ();
double mag = Math.sqrt(dx * dx + dz * dz);
double dirx = dx / mag;
double dirz = dz / mag;
// Horizontal velocity components
double vx = vh * dirx;
double vz = vh * dirz;
return new Vector(vx, vy, vz);
}
public static Location getNearestCornerLocation(Location near, Block block)
{
ArrayList<Location> corners = new ArrayList<Location>();
corners.add(block.getLocation().clone());
corners.add(block.getLocation().clone().add(.999, 0, 0));
corners.add(block.getLocation().clone().add(.999, 0, .999));
corners.add(block.getLocation().clone().add(0, 0, .999));
corners.add(block.getLocation().clone().add(0, .999, 0));
corners.add(block.getLocation().clone().add(.999, .999, 0));
corners.add(block.getLocation().clone().add(.999, .999, .999));
corners.add(block.getLocation().clone().add(0, .999, .999));
return UtilAlg.findClosest(near, corners);
}
public static boolean isSimilar(Location a, Location b)
{
return a.getWorld() == b.getWorld() && a.getX() == b.getX() && a.getY() == b.getY() && a.getZ() == b.getZ();
}
public static int randomMidpoint(int min, int max)
{
int variance = max - min;
int value = UtilMath.r(variance);
value += min;
return value;
}
public static EulerAngle vectorToEuler(Vector vector)
{
//JUST MAKE SURE THE ARMOR STAND ISNT ROTATED.
return new EulerAngle(
Math.toRadians(UtilAlg.GetPitch(vector)),
Math.toRadians(UtilAlg.GetYaw(vector)),
0);
}
public static AxisAlignedBB toBoundingBox(Location a, Location b)
{
return new AxisAlignedBB(a.getX(), a.getY(), a.getZ(), b.getX(), b.getY(), b.getZ());
}
public static Location moveForward(Location location, double strength, float yaw, boolean reverse)
{
double x = location.getX();
double z = location.getZ();
double rad = Math.toRadians(yaw);
x = reverse ? (x + strength * Math.sin(rad)) : (x - strength * Math.sin(rad));
z = reverse ? (z - strength * Math.cos(rad)) : (z + strength * Math.cos(rad));
return new Location(location.getWorld(), x, location.getY(), z, location.getYaw(), location.getPitch());
}
public static Location getRandomLocation(Location center, int radius)
{
Random r = new Random();
int x = r.nextInt(radius * 2) - radius;
int y = r.nextInt(radius * 2) - radius;
int z = r.nextInt(radius * 2) - radius;
return center.clone().add(x, y, z);
}
/**
* Gets a random location, with specific radius
*
* @param center The center location
* @param radiusX The X radius
* @param radiusY The Y radius
* @param radiusZ The Z radius
* @return A random location in that range
*/
public static Location getRandomLocation(Location center, double radiusX, double radiusY, double radiusZ)
{
double minX = radiusX * -1, minY = radiusY * -1, minZ = radiusZ * -1;
double x = minX + (UtilMath.random.nextDouble() * 2 * radiusX);
double y = minY + (UtilMath.random.nextDouble() * 2 * radiusY);
double z = minZ + (UtilMath.random.nextDouble() * 2 * radiusZ);
return center.clone().add((radiusX == 0) ? 0 : x, (radiusY == 0) ? 0 : y, (radiusZ == 0) ? 0 : z);
}
public static Location getRandomLocation(Location center, double radius)
{
return getRandomLocation(center, radius, radius, radius);
}
public static Vector rotateAroundXAxis(Vector vec, double angle)
{
double y = vec.getY(), z = vec.getZ(), sin = Math.sin(angle), cos = Math.cos(angle);
return vec.setY(y * cos - z * sin).setZ(y * sin + z * cos);
}
public static Vector rotateAroundYAxis(Vector vec, double angle)
{
double x = vec.getX(), z = vec.getZ(), sin = Math.sin(angle), cos = Math.cos(angle);
return vec.setX(x * cos - z * sin).setZ(x * sin + z * cos);
}
public static Vector rotateAroundZAxis(Vector vec, double angle)
{
double x = vec.getX(), y = vec.getY(), sin = Math.sin(angle), cos = Math.cos(angle);
return vec.setX(x * cos - y * sin).setZ(x * sin + y * cos);
}
/**
* Adjusts the yaw of a location to face the nearest location in the lookAt collection.
*
* @param location The location to adjust the yaw of
* @param lookAt The list of locations to look at
*/
public static void lookAtNearest(Location location, List<Location> lookAt)
{
location.setYaw(GetYaw(getTrajectory(location, findClosest(location, lookAt))));
}
}

View File

@ -0,0 +1,487 @@
package mineplex.core.common.util;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
public class UtilBlockText
{
public enum TextAlign
{
LEFT,
RIGHT,
CENTER
}
public static final Map<Character, int[][]> alphabet = new HashMap<>();
public static Collection<Block> MakeText(String string, Location loc, BlockFace face, int id, byte data, TextAlign align)
{
return MakeText(string, loc, face, id, data, align, true);
}
public static Collection<Block> MakeText(String string, Location loc, BlockFace face, int id, byte data, TextAlign align, boolean setAir)
{
Set<Block> changes = new HashSet<>();
if (alphabet.isEmpty())
PopulateAlphabet();
Block block = loc.getBlock();
//Get Width
int width = 0;
for (char c : string.toLowerCase().toCharArray())
{
int[][] letter = alphabet.get(c);
if (letter == null)
continue;
width += letter[0].length+1;
}
//Shift Blocks
if (align == TextAlign.CENTER || align == TextAlign.RIGHT)
{
int divisor = 1;
if (align == TextAlign.CENTER)
divisor = 2;
block = block.getRelative(face, (-1 * width/divisor) + 1);
}
//Clean
if (setAir)
{
World world = loc.getWorld();
int bX = loc.getBlockX();
int bY = loc.getBlockY();
int bZ = loc.getBlockZ();
for (int y=0 ; y<5 ; y++)
{
if (align == TextAlign.CENTER)
for (int i=-64 ; i<=64 ; i++)
{
MapUtil.QuickChangeBlockAt(world, bX + i * face.getModX(), bY + i * face.getModY(), bZ + i * face.getModZ(), Material.AIR);
}
if (align == TextAlign.LEFT)
for (int i=0 ; i<=128 ; i++)
{
MapUtil.QuickChangeBlockAt(world, bX + i * face.getModX(), bY + i * face.getModY(), bZ + i * face.getModZ(), Material.AIR);
}
if (align == TextAlign.RIGHT)
for (int i=-128 ; i<=0 ; i++)
{
MapUtil.QuickChangeBlockAt(world, bX + i * face.getModX(), bY + i * face.getModY(), bZ + i * face.getModZ(), Material.AIR);
}
bY -=1;
}
}
World world = block.getWorld();
int bX = block.getX();
int bY = block.getY();
int bZ = block.getZ();
//Make Blocks
for (char c : string.toLowerCase().toCharArray())
{
int[][] letter = alphabet.get(c);
if (letter == null)
continue;
for (int[] aLetter : letter)
{
for (int anALetter : aLetter)
{
if (anALetter == 1)
{
Block changed = world.getBlockAt(bX, bY, bZ);
changes.add(changed);
MapUtil.QuickChangeBlockAt(changed.getLocation(), id, data);
}
//Forward
bX += face.getModX();
bY += face.getModY();
bZ += face.getModZ();
}
//Back
bX += face.getModX() * -1 * aLetter.length;
bY += face.getModY() * -1 * aLetter.length;
bZ += face.getModZ() * -1 * aLetter.length;
//Down
bY--;
}
bY += 5;
bX += face.getModX() * (letter[0].length + 1);
bY += face.getModY() * (letter[0].length + 1);
bZ += face.getModZ() * (letter[0].length + 1);
}
return changes;
}
private static void PopulateAlphabet()
{
alphabet.put('0', new int[][] {
{1,1,1},
{1,0,1},
{1,0,1},
{1,0,1},
{1,1,1}
});
alphabet.put('1', new int[][] {
{1,1,0},
{0,1,0},
{0,1,0},
{0,1,0},
{1,1,1}
});
alphabet.put('2', new int[][] {
{1,1,1},
{0,0,1},
{1,1,1},
{1,0,0},
{1,1,1}
});
alphabet.put('3', new int[][] {
{1,1,1},
{0,0,1},
{1,1,1},
{0,0,1},
{1,1,1}
});
alphabet.put('4', new int[][] {
{1,0,1},
{1,0,1},
{1,1,1},
{0,0,1},
{0,0,1}
});
alphabet.put('5', new int[][] {
{1,1,1},
{1,0,0},
{1,1,1},
{0,0,1},
{1,1,1}
});
alphabet.put('6', new int[][] {
{1,1,1},
{1,0,0},
{1,1,1},
{1,0,1},
{1,1,1}
});
alphabet.put('7', new int[][] {
{1,1,1},
{0,0,1},
{0,0,1},
{0,0,1},
{0,0,1}
});
alphabet.put('8', new int[][] {
{1,1,1},
{1,0,1},
{1,1,1},
{1,0,1},
{1,1,1}
});
alphabet.put('9', new int[][] {
{1,1,1},
{1,0,1},
{1,1,1},
{0,0,1},
{1,1,1}
});
alphabet.put('.', new int[][] {
{0},
{0},
{0},
{0},
{1}
});
alphabet.put('!', new int[][] {
{1},
{1},
{1},
{0},
{1}
});
alphabet.put(' ', new int[][] {
{0,0},
{0,0},
{0,0},
{0,0},
{0,0}
});
alphabet.put('a', new int[][] {
{1,1,1,1},
{1,0,0,1},
{1,1,1,1},
{1,0,0,1},
{1,0,0,1}
});
alphabet.put('b', new int[][] {
{1,1,1,0},
{1,0,0,1},
{1,1,1,0},
{1,0,0,1},
{1,1,1,0}
});
alphabet.put('c', new int[][] {
{1,1,1,1},
{1,0,0,0},
{1,0,0,0},
{1,0,0,0},
{1,1,1,1}
});
alphabet.put('d', new int[][] {
{1,1,1,0},
{1,0,0,1},
{1,0,0,1},
{1,0,0,1},
{1,1,1,0}
});
alphabet.put('e', new int[][] {
{1,1,1,1},
{1,0,0,0},
{1,1,1,0},
{1,0,0,0},
{1,1,1,1}
});
alphabet.put('f', new int[][] {
{1,1,1,1},
{1,0,0,0},
{1,1,1,0},
{1,0,0,0},
{1,0,0,0}
});
alphabet.put('g', new int[][] {
{1,1,1,1},
{1,0,0,0},
{1,0,1,1},
{1,0,0,1},
{1,1,1,1}
});
alphabet.put('h', new int[][] {
{1,0,0,1},
{1,0,0,1},
{1,1,1,1},
{1,0,0,1},
{1,0,0,1}
});
alphabet.put('i', new int[][] {
{1,1,1},
{0,1,0},
{0,1,0},
{0,1,0},
{1,1,1}
});
alphabet.put('j', new int[][] {
{1,1,1,1},
{0,0,1,0},
{0,0,1,0},
{1,0,1,0},
{1,1,1,0}
});
alphabet.put('k', new int[][] {
{1,0,0,1},
{1,0,1,0},
{1,1,0,0},
{1,0,1,0},
{1,0,0,1}
});
alphabet.put('l', new int[][] {
{1,0,0,0},
{1,0,0,0},
{1,0,0,0},
{1,0,0,0},
{1,1,1,1}
});
alphabet.put('m', new int[][] {
{1,1,1,1,1},
{1,0,1,0,1},
{1,0,1,0,1},
{1,0,0,0,1},
{1,0,0,0,1}
});
alphabet.put('n', new int[][] {
{1,0,0,1},
{1,1,0,1},
{1,0,1,1},
{1,0,0,1},
{1,0,0,1}
});
alphabet.put('o', new int[][] {
{1,1,1,1},
{1,0,0,1},
{1,0,0,1},
{1,0,0,1},
{1,1,1,1}
});
alphabet.put('p', new int[][] {
{1,1,1,1},
{1,0,0,1},
{1,1,1,1},
{1,0,0,0},
{1,0,0,0}
});
alphabet.put('q', new int[][] {
{1,1,1,1},
{1,0,0,1},
{1,0,0,1},
{1,0,1,0},
{1,1,0,1}
});
alphabet.put('r', new int[][] {
{1,1,1,1},
{1,0,0,1},
{1,1,1,0},
{1,0,0,1},
{1,0,0,1}
});
alphabet.put('s', new int[][] {
{1,1,1,1},
{1,0,0,0},
{1,1,1,1},
{0,0,0,1},
{1,1,1,1}
});
alphabet.put('t', new int[][] {
{1,1,1,1,1},
{0,0,1,0,0},
{0,0,1,0,0},
{0,0,1,0,0},
{0,0,1,0,0}
});
alphabet.put('u', new int[][] {
{1,0,0,1},
{1,0,0,1},
{1,0,0,1},
{1,0,0,1},
{1,1,1,1}
});
alphabet.put('v', new int[][] {
{1,0,0,1},
{1,0,0,1},
{1,0,0,1},
{1,0,0,1},
{0,1,1,0}
});
alphabet.put('w', new int[][] {
{1,0,0,0,1},
{1,0,0,0,1},
{1,0,1,0,1},
{1,0,1,0,1},
{1,1,1,1,1}
});
alphabet.put('x', new int[][] {
{1,0,0,1},
{1,0,0,1},
{0,1,1,0},
{1,0,0,1},
{1,0,0,1}
});
alphabet.put('y', new int[][] {
{1,0,0,1},
{1,0,0,1},
{1,1,1,1},
{0,0,0,1},
{1,1,1,1}
});
alphabet.put('z', new int[][] {
{1,1,1,1},
{0,0,0,1},
{0,0,1,0},
{0,1,0,0},
{1,1,1,1}
});
alphabet.put(':', new int[][]
{
{0},
{1},
{0},
{1},
{0}
});
alphabet.put('=', new int[][]
{
{0,0,0},
{1,1,1},
{0,0,0},
{1,1,1},
{0,0,0}
});
// THIS IS A SINGLE SPACE
alphabet.put('|', new int[][]
{
{0},
{0},
{0},
{0},
{0}
});
}
}

View File

@ -0,0 +1,218 @@
package mineplex.core.common.util;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.util.Vector;
import javax.annotation.Nonnull;
/**
* Created by Shaun on 11/12/2014.
*/
public class UtilColor
{
public static final RGBData RgbRed = hexToRgb(0xee0100);
public static final RGBData RgbGold = hexToRgb(0xffd014);
public static final RGBData RgbLightBlue = hexToRgb(0x61fff7);
public static final RGBData RgbLightRed = hexToRgb(0xeb1c1c);
public static final RGBData RgbPurple = hexToRgb(0x9c17a3);
public static final Color DEFAULT_LEATHER_COLOR = Color.fromRGB(160, 101, 64);
public static byte chatColorToWoolData(ChatColor chatColor)
{
switch (chatColor)
{
// 0: white
// 1: orange
// 2: magenta
// 3: light blue
// 4: yellow
// 5: lime
// 6: pink
// 7: gray
// 8: light gray
// 9: cyan
// 10: purple
// 11: blue
// 12: brown
// 13: green
// 14: red
// 15: black
case BLACK:
return 1;
case DARK_BLUE:
return 11;
case DARK_GREEN:
return 13;
case DARK_AQUA:
return 9;
case DARK_RED:
return 12;
case DARK_PURPLE:
return 10;
case GOLD:
return 1;
case GRAY:
return 8;
case DARK_GRAY:
return 7;
case BLUE:
return 11;
case GREEN:
return 5;
case AQUA:
return 3;
case RED:
return 14;
case LIGHT_PURPLE:
return 2;
case YELLOW:
return 4;
default:
return 0;
}
}
public static ChatColor woolDataToChatColor(byte data)
{
switch (data)
{
case 0:
return ChatColor.WHITE;
case 1:
return ChatColor.GOLD;
case 2:
return ChatColor.DARK_PURPLE;
case 3:
return ChatColor.AQUA;
case 4:
return ChatColor.YELLOW;
case 5:
return ChatColor.GREEN;
case 6:
return ChatColor.LIGHT_PURPLE;
case 7:
return ChatColor.DARK_GRAY;
case 8:
return ChatColor.GRAY;
case 9:
return ChatColor.DARK_AQUA;
case 10:
return ChatColor.DARK_PURPLE;
case 11:
return ChatColor.DARK_BLUE;
case 12:
return ChatColor.DARK_RED;
case 13:
return ChatColor.DARK_GREEN;
case 14:
return ChatColor.RED;
case 15:
return ChatColor.BLACK;
default:
return ChatColor.WHITE;
}
}
public static String chatColorToJsonColor(ChatColor chatColor)
{
return chatColor.name().toLowerCase();
}
public static Vector colorToVector(Color color)
{
return new Vector(Math.max(color.getRed()/255.0, 0.00001f), color.getGreen()/255.0, color.getBlue()/255.0);
}
public static RGBData hexToRgb(int hex)
{
return new RGBData(hex >> 16, hex >> 8 & 0xFF, hex & 0xFF);
}
public static int rgbToHex(RGBData rgb)
{
return (rgb.getFullRed() << 16 | rgb.getFullGreen() << 8 | rgb.getFullBlue());
}
public static int rgbToHex(int red, int green, int blue)
{
return (red << 16 | green << 8 | blue);
}
public static RGBData rgb(int r, int g, int b)
{
return new RGBData(r, g, b);
}
public static Color getNextColor(Color original, Color finalColor, int increment)
{
int red = original.getRed(), green = original.getGreen(), blue = original.getBlue();
if (red > finalColor.getRed())
red -= increment;
else if (red < finalColor.getRed())
red += increment;
else if (green > finalColor.getGreen())
green -= increment;
else if (green < finalColor.getGreen())
green += increment;
else if (blue > finalColor.getBlue())
blue -= increment;
else if (blue < finalColor.getBlue())
blue += increment;
red = UtilMath.clamp(red, 0, 255);
green = UtilMath.clamp(green, 0, 255);
blue = UtilMath.clamp(blue, 0, 255);
return Color.fromRGB(red, green, blue);
}
/**
* Applies Color to a Leather armor
* @param itemStack
* @param color
* @return ItemStack with color applied
*/
public static ItemStack applyColor(@Nonnull ItemStack itemStack, Color color)
{
switch (itemStack.getType())
{
case LEATHER_HELMET:
case LEATHER_CHESTPLATE:
case LEATHER_LEGGINGS:
case LEATHER_BOOTS:
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) itemStack.getItemMeta();
leatherArmorMeta.setColor(color);
itemStack.setItemMeta(leatherArmorMeta);
return itemStack;
default:
return itemStack;
}
}
/**
* Gets color from Leather armor
* @param itemStack
* @return Color of the item
*/
public static Color getItemColor(@Nonnull ItemStack itemStack)
{
switch (itemStack.getType())
{
case LEATHER_HELMET:
case LEATHER_CHESTPLATE:
case LEATHER_LEGGINGS:
case LEATHER_BOOTS:
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) itemStack.getItemMeta();
return leatherArmorMeta.getColor();
default:
return DEFAULT_LEATHER_COLOR;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,53 @@
package mineplex.core.common.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class UtilFile
{
public static String read(File file)
{
try
{
return new String(readBytes(file));
}
catch (IOException e)
{
return null;
}
}
/**
* @param file
* @return
* @throws IOException
*/
public static byte[] readBytes(File file) throws IOException
{
FileInputStream stream = new FileInputStream(file);
byte[] bytes = new byte[stream.available() /* estimated bytes available */];
int pointer = 0;
while (true)
{
int read = stream.read();
if (read == -1)
{
break;
}
bytes = UtilCollections.ensureSize(bytes, bytes.length + 1);
bytes[pointer] = (byte) read;
++pointer;
}
stream.close();
return bytes;
}
}

View File

@ -0,0 +1,135 @@
package mineplex.core.common.util;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftFirework;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.util.Vector;
public class UtilFirework
{
public static void playFirework(Location loc, FireworkEffect fe)
{
Firework firework = loc.getWorld().spawn(loc, Firework.class);
FireworkMeta data = firework.getFireworkMeta();
data.clearEffects();
data.setPower(1);
data.addEffect(fe);
firework.setFireworkMeta(data);
((CraftFirework) firework).getHandle().expectedLifespan = 1;
// ((CraftWorld)loc.getWorld()).getHandle().broadcastEntityEffect(((CraftEntity)firework).getHandle(), (byte)17);
// firework.remove();
}
public static Firework launchFirework(Location loc, FireworkEffect fe, Vector dir, int power)
{
try
{
Firework fw = loc.getWorld().spawn(loc, Firework.class);
FireworkMeta data = fw.getFireworkMeta();
data.clearEffects();
data.setPower(power);
data.addEffect(fe);
fw.setFireworkMeta(data);
if (dir != null)
fw.setVelocity(dir);
return fw;
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
public void detonateFirework(Firework firework)
{
((CraftWorld)firework.getWorld()).getHandle().broadcastEntityEffect(((CraftEntity)firework).getHandle(), (byte)17);
firework.remove();
}
public static Firework launchFirework(Location loc, Type type, Color color, boolean flicker, boolean trail, Vector dir, int power)
{
return launchFirework(loc, FireworkEffect.builder().flicker(flicker).withColor(color).with(type).trail(trail).build(), dir, power);
}
public static void playFirework(Location loc, Type type, Color color, boolean flicker, boolean trail)
{
playFirework(loc, FireworkEffect.builder().flicker(flicker).withColor(color).with(type).trail(trail).build());
}
public static void packetPlayFirework(Player player, Location loc, Type type, Color color, boolean flicker, boolean trail)
{
Firework firework = loc.getWorld().spawn(loc, Firework.class);
FireworkEffect effect = FireworkEffect.builder().flicker(flicker).withColor(color).with(type).trail(trail).build();
FireworkMeta data = firework.getFireworkMeta();
data.clearEffects();
data.setPower(1);
data.addEffect(effect);
firework.setFireworkMeta(data);
((CraftFirework) firework).getHandle().expectedLifespan = 1;
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[]
{
firework.getEntityId()
});
for (Player viewing : UtilServer.getPlayers())
{
if (player == viewing)
continue;
UtilPlayer.sendPacket(viewing, packet);
}
}
public static void spawnRandomFirework(Location location)
{
playFirework(location,
Type.values()[UtilMath.r(Type.values().length)],
Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256)),
UtilMath.random.nextBoolean(),
UtilMath.random.nextBoolean()
);
}
public static void playFreedomFirework(Location location)
{
playFirework(location, FireworkEffect.builder().withColor(Color.RED).withColor(Color.BLUE)
.withColor(Color.WHITE).withFade(Color.RED).withFade(Color.BLUE).withFade(Color.WHITE).build());
}
public static FireworkEffect getRandomFireworkEffect(boolean fade, int maxColors, int maxFade)
{
FireworkEffect.Builder builder = FireworkEffect.builder().with(Type.values()[UtilMath.r(Type.values().length)])
.withColor(Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256))).flicker(UtilMath.random.nextBoolean()).trail(UtilMath.random.nextBoolean());
if (fade)
{
for (int i = 0; i < maxFade; i++)
{
builder.withFade(Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256)));
}
}
for (int i = 0; i < maxColors; i++)
{
builder.withColor(Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256)));
}
return builder.build();
}
}

View File

@ -0,0 +1,133 @@
package mineplex.core.common.util;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
public class UtilFuture
{
/**
* Returns a {@link CompletableFuture} which will complete when supplied futures have completed.
* This is a workaround for {@link CompletableFuture#anyOf(CompletableFuture[])} returning void.
*
* @param futures the futures to wait to complete
* @param <T> the type of item(s)
* @return a future which will complete when all supplied futures have completed
*/
public static <T> CompletableFuture<List<T>> sequence(Collection<CompletableFuture<T>> futures)
{
return sequence(futures, Collectors.toList());
}
/**
* Returns a {@link CompletableFuture} which will complete when supplied futures have completed.
* This is a workaround for {@link CompletableFuture#anyOf(CompletableFuture[])} returning void.
*
* @param futures the futures to wait to complete
* @param <R> the collection type
* @param <T> the type of the collection's items
* @return a future which will complete when all supplied futures have completed
*/
public static <R, T> CompletableFuture<R> sequence(Collection<CompletableFuture<T>> futures, Collector<T, ?, R> collector)
{
CompletableFuture<Void> futuresCompletedFuture =
CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()]));
return futuresCompletedFuture.thenApply(v ->
futures.stream().map(CompletableFuture::join).collect(collector));
}
/**
* Returns a {@link CompletableFuture} containing a {@link Multimap} with future values unwrapped.
*
* @param multimap the multimap to transform the values of
* @param <M> the multimap type, values must be a {@link Collection} of {@link CompletableFuture} object.
* @param <K> the multimap key type
* @param <V> the future return type
* @return a future which returns a multimap with unwrapped values
*/
public static <M extends Multimap<K, CompletableFuture<V>>, K, V> CompletableFuture<Multimap<K, V>> sequenceValues(M multimap)
{
CompletableFuture<Map<K, Collection<V>>> sequenced = sequenceValues(multimap.asMap());
return sequenced.thenApply(map ->
{
Multimap<K, V> sequencedMultiMap = HashMultimap.create();
map.forEach(sequencedMultiMap::putAll);
return sequencedMultiMap;
});
}
/**
* Returns a {@link CompletableFuture} containing a {@link Map} with future values unwrapped.
*
* @param map the map to transform the values of
* @param <M> the map type, values must be a {@link Collection} of {@link CompletableFuture} object.
* @param <K> the map key type
* @param <V> the future return type
* @return a future which returns a map with unwrapped values
*/
public static <M extends Map<K, Collection<CompletableFuture<V>>>, K, V> CompletableFuture<Map<K, Collection<V>>> sequenceValues(M map)
{
Map<K, CompletableFuture<List<V>>> seqValues =
map.keySet().stream().collect(Collectors.toMap(Function.identity(), key -> sequence(map.get(key))));
Collection<CompletableFuture<List<V>>> values = seqValues.values();
CompletableFuture<Void> futuresCompleted =
CompletableFuture.allOf(values.toArray(new CompletableFuture[values.size()]));
return futuresCompleted.thenApply(v ->
(Map<K, Collection<V>>) seqValues.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> (Collection<V>) entry.getValue().join())));
}
/**
* Filters a list using functions which return a {@link CompletableFuture}.
* The returned future is marked as complete once all items have been filtered.
*
* @param list the list of elements to filter
* @param futureFunction a function which returns a future containing whether an element should be filtered
* @param <T> the type of element
* @return a collection containing the filtered elements
*/
public static <T> CompletableFuture<List<T>> filter(List<T> list, Function<T, CompletableFuture<Boolean>> futureFunction)
{
return filter(list, futureFunction, Collectors.toList());
}
/**
* Filters a list using functions which return a {@link CompletableFuture}.
* The returned future is marked as complete once all items have been filtered.
*
* @param list the list of elements to filter
* @param futureFunction a function which returns a future containing whether an element should be filtered
* @param collector the collector used to collect the results
* @param <T> the type of element
* @param <R> the returned collection type
* @return a collection containing the filtered elements
*/
public static <T, R> CompletableFuture<R> filter(List<T> list, Function<T, CompletableFuture<Boolean>> futureFunction, Collector<T, ?, R> collector)
{
Map<T, CompletableFuture<Boolean>> elementFutureMap = list.stream()
.collect(Collectors.toMap(
Function.identity(),
futureFunction,
(u, v) -> { throw new IllegalStateException(String.format("Duplicate key %s", u)); },
LinkedHashMap::new));
Collection<CompletableFuture<Boolean>> futures = elementFutureMap.values();
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])).thenApply(aVoid ->
elementFutureMap.entrySet().stream()
.filter(entry -> entry.getValue().join()) // this doesn't block as all futures have completed
.map(Map.Entry::getKey)
.collect(collector));
}
}

View File

@ -0,0 +1,121 @@
package mineplex.core.common.util;
import java.util.HashSet;
public class UtilInput
{
//Valid Chars
protected static HashSet<Character> validSet = new HashSet<Character>();
protected static HashSet<String> filterSet = new HashSet<String>();
public static boolean valid(String input)
{
if (validSet.isEmpty())
addChars();
for (char cur : input.toCharArray())
if (!validSet.contains(cur))
return false;
return true;
}
public static String filter(String input)
{
if (filterSet.isEmpty())
addDictionary();
for (String cur : filterSet)
{
if (input.equalsIgnoreCase(cur))
{
String out = "" + input.charAt(0);
while (out.length() < input.length())
out += '*';
return out;
}
}
return input;
}
public static void addDictionary()
{
filterSet.add("fuck");
filterSet.add("shit");
filterSet.add("cunt");
filterSet.add("ass");
filterSet.add("asshole");
filterSet.add("faggot");
filterSet.add("fag");
filterSet.add("gay");
}
public static void addChars()
{
validSet.add('1');
validSet.add('2');
validSet.add('3');
validSet.add('4');
validSet.add('5');
validSet.add('6');
validSet.add('7');
validSet.add('8');
validSet.add('9');
validSet.add('0');
validSet.add('a');
validSet.add('b');
validSet.add('c');
validSet.add('d');
validSet.add('e');
validSet.add('f');
validSet.add('g');
validSet.add('h');
validSet.add('i');
validSet.add('j');
validSet.add('k');
validSet.add('l');
validSet.add('m');
validSet.add('n');
validSet.add('o');
validSet.add('p');
validSet.add('q');
validSet.add('r');
validSet.add('s');
validSet.add('t');
validSet.add('u');
validSet.add('v');
validSet.add('w');
validSet.add('x');
validSet.add('y');
validSet.add('z');
validSet.add('A');
validSet.add('B');
validSet.add('C');
validSet.add('D');
validSet.add('E');
validSet.add('F');
validSet.add('G');
validSet.add('H');
validSet.add('I');
validSet.add('J');
validSet.add('K');
validSet.add('L');
validSet.add('M');
validSet.add('N');
validSet.add('O');
validSet.add('P');
validSet.add('Q');
validSet.add('R');
validSet.add('S');
validSet.add('T');
validSet.add('U');
validSet.add('V');
validSet.add('W');
validSet.add('X');
validSet.add('Y');
validSet.add('Z');
}
}

Some files were not shown because too many files have changed in this diff Show More