2014-04-04 22:03:18 +00:00
|
|
|
/*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2012-03-05 06:05:17 +00:00
|
|
|
package com.sk89q.jnbt;
|
|
|
|
|
2014-07-15 03:36:27 +00:00
|
|
|
import static com.google.common.base.Preconditions.checkNotNull;
|
2012-03-05 06:05:17 +00:00
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
import java.util.Locale;
|
|
|
|
|
2019-11-19 21:23:47 +00:00
|
|
|
import java.util.Locale;
|
2012-03-05 06:05:17 +00:00
|
|
|
|
|
|
|
/**
|
2014-07-15 03:36:27 +00:00
|
|
|
* The {@code TAG_Int_Array} tag.
|
2012-03-05 06:05:17 +00:00
|
|
|
*/
|
|
|
|
public final class IntArrayTag extends Tag {
|
2019-11-20 03:40:52 +00:00
|
|
|
@Override
|
|
|
|
public String getTypeName() {
|
|
|
|
return "TAG_Int_Array";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getTypeCode() {
|
|
|
|
return NBTConstants.TYPE_INT_ARRAY;
|
|
|
|
}
|
2012-03-05 06:05:17 +00:00
|
|
|
|
2014-07-15 03:36:27 +00:00
|
|
|
private final int[] value;
|
|
|
|
|
2012-03-05 06:05:17 +00:00
|
|
|
/**
|
2014-07-15 03:36:27 +00:00
|
|
|
* Creates the tag with an empty name.
|
|
|
|
*
|
|
|
|
* @param value the value of the tag
|
2012-03-05 06:05:17 +00:00
|
|
|
*/
|
2014-07-15 03:36:27 +00:00
|
|
|
public IntArrayTag(int[] value) {
|
|
|
|
super();
|
|
|
|
checkNotNull(value);
|
|
|
|
this.value = value;
|
|
|
|
}
|
2012-03-05 06:05:17 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int[] getValue() {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
StringBuilder hex = new StringBuilder();
|
|
|
|
for (int b : value) {
|
2019-07-06 00:46:48 +00:00
|
|
|
String hexDigits = Integer.toHexString(b).toUpperCase(Locale.ROOT);
|
2012-03-05 06:05:17 +00:00
|
|
|
if (hexDigits.length() == 1) {
|
|
|
|
hex.append("0");
|
|
|
|
}
|
|
|
|
hex.append(hexDigits).append(" ");
|
|
|
|
}
|
2014-11-14 19:38:54 +00:00
|
|
|
return "TAG_Int_Array(" + hex + ")";
|
2012-03-05 06:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|