package move

This commit is contained in:
kashike
2018-07-05 16:03:50 -07:00
committed by Matthew Miller
parent 70208c38fd
commit 40a665a509
15 changed files with 26 additions and 26 deletions

View File

@ -22,7 +22,7 @@ package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.registry.state.State;
import com.sk89q.worldedit.registry.state.State;
import java.util.Map;

View File

@ -26,8 +26,8 @@ import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.util.gson.VectorAdapter;
import com.sk89q.worldedit.world.registry.state.SimpleState;
import com.sk89q.worldedit.world.registry.state.State;
import com.sk89q.worldedit.registry.state.SimpleState;
import com.sk89q.worldedit.registry.state.State;
import javax.annotation.Nullable;
import java.io.IOException;

View File

@ -23,7 +23,7 @@ import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.state.State;
import com.sk89q.worldedit.registry.state.State;
import java.util.Map;

View File

@ -1,31 +0,0 @@
/*
* 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.sk89q.worldedit.world.registry.state;
import com.sk89q.worldedit.world.registry.state.value.DirectionalStateValue;
import java.util.List;
public class DirectionalState extends SimpleState<DirectionalStateValue> {
public DirectionalState(List<DirectionalStateValue> values) {
super(values);
}
}

View File

@ -1,66 +0,0 @@
/*
* 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.sk89q.worldedit.world.registry.state;
import com.sk89q.worldedit.world.registry.state.value.SimpleStateValue;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nullable;
public class SimpleState<T extends SimpleStateValue> implements State<T> {
private String name;
private List<T> values;
/**
* Creates a state with values
*
* @param values The values
*/
public SimpleState(List<T> values) {
this.name = "Unknown";
this.values = values;
}
/**
* Internal method for name setting post-deserialise. Do not use.
*/
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
@Override
public List<T> getValues() {
return Collections.unmodifiableList(values);
}
@Nullable
@Override
public T getValueFor(String string) {
return values.stream().filter(value -> Objects.equals(value.getData(), string)).findFirst().orElse(null);
}
}

View File

@ -1,58 +0,0 @@
/*
* 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.sk89q.worldedit.world.registry.state;
import com.sk89q.worldedit.world.registry.state.value.SimpleStateValue;
import java.util.List;
import javax.annotation.Nullable;
/**
* Describes a state property of a block.
*
* <p>Example states include "variant" (indicating material or type) and
* "facing" (indicating orientation).</p>
*/
public interface State<T extends SimpleStateValue> {
/**
* Returns the name of this state.
*
* @return The state name
*/
String getName();
/**
* Return a list of available values for this state.
*
* @return the list of state values
*/
List<T> getValues();
/**
* Gets the value for the given string, or null.
*
* @param string The string
* @return The value, or null
*/
@Nullable
T getValueFor(String string);
}

View File

@ -1,29 +0,0 @@
/*
* 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.sk89q.worldedit.world.registry.state.value;
import com.sk89q.worldedit.Vector;
public class DirectionalStateValue extends SimpleStateValue {
public Vector getDirection() {
return new Vector(); // TODO
}
}

View File

@ -1,52 +0,0 @@
/*
* 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.sk89q.worldedit.world.registry.state.value;
import java.util.Objects;
public class SimpleStateValue implements StateValue {
private String data;
@Override
public boolean isSet() {
return data != null;
}
@Override
public void set(String data) {
this.data = data;
}
@Override
public String getData() {
return this.data;
}
@Override
public boolean equals(Object obj) {
return obj instanceof StateValue && Objects.equals(((StateValue) obj).getData(), getData());
}
@Override
public int hashCode() {
return this.data.hashCode();
}
}

View File

@ -1,49 +0,0 @@
/*
* 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.sk89q.worldedit.world.registry.state.value;
import javax.annotation.Nullable;
/**
* Describes a possible value for a {@code State}.
*/
public interface StateValue {
/**
* Return whether this state is set on the given block.
*
* @return true if this value is set
*/
boolean isSet();
/**
* Set the state to the given value.
*/
void set(String data);
/**
* Returns the data associated with this value.
*
* @return The data, otherwise null
*/
@Nullable
String getData();
}