Skip to content
Permalink
Browse files

Re-do commits to avoid awful rebase

  • Loading branch information...
me4502 committed Jul 15, 2019
1 parent 50341ac commit ff3a76cf79f52127022c0f880585d8e9798817c6
Showing with 985 additions and 50 deletions.
  1. +4 −0 config/checkstyle/import-control.xml
  2. +1 −1 settings.gradle.kts
  3. +0 −6 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCategoryRegistry.java
  4. +0 −6 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitItemCategoryRegistry.java
  5. +31 −0 worldedit-cli/build.gradle.kts
  6. +36 −0 worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIBlockCategoryRegistry.java
  7. +67 −0 worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIBlockRegistry.java
  8. +158 −0 worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLICommandSender.java
  9. +45 −0 worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIConfiguration.java
  10. +36 −0 worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIItemCategoryRegistry.java
  11. +133 −0 worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIPlatform.java
  12. +64 −0 worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIRegistries.java
  13. +269 −0 worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIWorldEdit.java
  14. +77 −0 worldedit-cli/src/main/java/com/sk89q/worldedit/cli/data/FileRegistries.java
  15. +1 −0 worldedit-cli/src/main/resources/com/sk89q/worldedit/cli/data/1631.json
  16. +1 −0 worldedit-cli/src/main/resources/com/sk89q/worldedit/cli/data/1963.json
  17. +1 −0 worldedit-cli/src/main/resources/com/sk89q/worldedit/cli/data/1968.json
  18. +33 −0 worldedit-cli/src/main/resources/defaults/worldedit.properties
  19. +24 −0 worldedit-cli/src/main/resources/log4j2.xml
  20. +3 −1 worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/CategoryRegistry.java
  21. +0 −6 worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/NullBlockCategoryRegistry.java
  22. +0 −6 worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/NullItemCategoryRegistry.java
  23. +0 −6 worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricBlockCategoryRegistry.java
  24. +0 −6 worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricItemCategoryRegistry.java
  25. +0 −6 worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBlockCategoryRegistry.java
  26. +0 −6 worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemCategoryRegistry.java
  27. +1 −0 worldedit-libs/cli/build.gradle.kts
@@ -47,6 +47,10 @@
<allow pkg="io.papermc.lib"/>
</subpackage>

<subpackage name="cli">
<allow pkg="org.apache.logging.log4j"/>
</subpackage>

<subpackage name="forge">
<allow pkg="cpw"/>
<allow pkg="net.minecraft"/>
@@ -2,7 +2,7 @@ rootProject.name = "worldedit"

include("worldedit-libs")

listOf("bukkit", "core", "forge", "sponge", "fabric").forEach {
listOf("bukkit", "core", "forge", "sponge", "fabric", "cli").forEach {
include("worldedit-libs:$it")
include("worldedit-$it")
}
@@ -19,7 +19,6 @@

package com.sk89q.worldedit.bukkit;

import com.sk89q.worldedit.registry.Category;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BlockCategoryRegistry;
import org.bukkit.Bukkit;
@@ -44,9 +43,4 @@
Tag<Material> tag = Bukkit.getTag(Tag.REGISTRY_BLOCKS, new NamespacedKey(namespace, key), Material.class);
return getFromBukkitTag(tag);
}

@Override
public Set<BlockType> getAll(Category<BlockType> category) {
return getCategorisedByName(category.getId());
}
}
@@ -19,7 +19,6 @@

package com.sk89q.worldedit.bukkit;

import com.sk89q.worldedit.registry.Category;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.registry.ItemCategoryRegistry;
import org.bukkit.Bukkit;
@@ -44,9 +43,4 @@
Tag<Material> tag = Bukkit.getTag(Tag.REGISTRY_ITEMS, new NamespacedKey(namespace, key), Material.class);
return getFromBukkitTag(tag);
}

@Override
public Set<ItemType> getAll(Category<ItemType> category) {
return getCategorisedByName(category.getId());
}
}
@@ -0,0 +1,31 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

applyPlatformAndCoreConfiguration()
applyShadowConfiguration()

dependencies {
"compile"(project(":worldedit-core"))
"compile"("org.apache.logging.log4j:log4j-core:2.8.1")
"compile"( "org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
"compile"( "commons-cli:commons-cli:1.4")

"testCompile"("org.mockito:mockito-core:1.9.0-rc1")
}

tasks.named<Jar>("jar") {
manifest {
attributes("WorldEdit-Version" to project.version)
}
}

tasks.named<ShadowJar>("shadowJar") {
dependencies {
relocate("org.slf4j", "com.sk89q.worldedit.slf4j")
relocate("org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge")

include(dependency("org.slf4j:slf4j-api"))
include(dependency("commons-cli:commons-cli:1.4"))
include(dependency("org.apache.logging.log4j:log4j-core"))
include(dependency("org.apache.logging.log4j:log4j-slf4j-impl"))
}
}
@@ -0,0 +1,36 @@
/*
* 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.cli;

import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BlockCategoryRegistry;

import java.util.Set;
import java.util.stream.Collectors;

public class CLIBlockCategoryRegistry implements BlockCategoryRegistry {

@Override
public Set<BlockType> getCategorisedByName(String category) {
return CLIWorldEdit.inst.getFileRegistries().getDataFile().blocktags.get(category).stream()
.map(BlockType.REGISTRY::get)
.collect(Collectors.toSet());
}
}
@@ -0,0 +1,67 @@
/*
* 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.cli;

import com.sk89q.worldedit.cli.data.FileRegistries;
import com.sk89q.worldedit.registry.state.BooleanProperty;
import com.sk89q.worldedit.registry.state.DirectionalProperty;
import com.sk89q.worldedit.registry.state.EnumProperty;
import com.sk89q.worldedit.registry.state.IntegerProperty;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BundledBlockRegistry;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Nullable;

public class CLIBlockRegistry extends BundledBlockRegistry {

private Property<?> createProperty(String type, String key, List<?> values) {
switch (type) {
case "int":
return new IntegerProperty(key, (List<Integer>) values);
case "bool":
return new BooleanProperty(key, (List<Boolean>) values);
case "enum":
return new EnumProperty(key, (List<String>) values);
case "dir":
return new DirectionalProperty(key, (List<Direction>) values);
default:
throw new RuntimeException("Failed to create property");
}
}

@Nullable
@Override
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
Map<String, FileRegistries.BlockProperty> properties = CLIWorldEdit.inst.getFileRegistries().getDataFile().blocks.get(blockType.getId()).properties;
Map<String, Property<?>> worldEditProperties = new HashMap<>();

properties.forEach((name, prop) -> {
worldEditProperties.put(name, createProperty(prop.type, name, prop.values));
});

return worldEditProperties;
}
}
@@ -0,0 +1,158 @@
/*
* 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.cli;

import static com.google.common.base.Preconditions.checkNotNull;

import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.serializer.plain.PlainComponentSerializer;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.util.UUID;

public class CLICommandSender implements Actor {

/**
* One time generated ID.
*/
private static final UUID DEFAULT_ID = UUID.fromString("a233eb4b-4cab-42cd-9fd9-7e7b9a3f74be");

private CLIWorldEdit plugin;
private Logger sender;

public CLICommandSender(CLIWorldEdit plugin, Logger sender) {
checkNotNull(plugin);
checkNotNull(sender);

this.plugin = plugin;
this.sender = sender;
}

@Override
public UUID getUniqueId() {
return DEFAULT_ID;
}

@Override
public String getName() {
return "Console";
}

@Override
public void printRaw(String msg) {
for (String part : msg.split("\n")) {
sender.info(part);
}
}

@Override
public void print(String msg) {
for (String part : msg.split("\n")) {
sender.info("\u00A7d" + part);
}
}

@Override
public void printDebug(String msg) {
for (String part : msg.split("\n")) {
sender.debug("\u00A77" + part);
}
}

@Override
public void printError(String msg) {
for (String part : msg.split("\n")) {
sender.error("\u00A7c" + part);
}
}

@Override
public void print(Component component) {
print(PlainComponentSerializer.INSTANCE.serialize(component));
}

@Override
public boolean canDestroyBedrock() {
return true;
}

@Override
public String[] getGroups() {
return new String[0];
}

@Override
public boolean hasPermission(String perm) {
return true;
}

@Override
public void checkPermission(String permission) throws AuthorizationException {
}

@Override
public boolean isPlayer() {
return false;
}

@Override
public File openFileOpenDialog(String[] extensions) {
return null;
}

@Override
public File openFileSaveDialog(String[] extensions) {
return null;
}

@Override
public void dispatchCUIEvent(CUIEvent event) {
}

@Override
public SessionKey getSessionKey() {
return new SessionKey() {
@Override
public String getName() {
return "Console";
}

@Override
public boolean isActive() {
return true;
}

@Override
public boolean isPersistent() {
return true;
}

@Override
public UUID getUniqueId() {
return DEFAULT_ID;
}
};
}
}
@@ -0,0 +1,45 @@
/*
* 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.cli;

import com.sk89q.worldedit.util.PropertiesConfiguration;

import java.io.File;

public class CLIConfiguration extends PropertiesConfiguration {

public boolean creativeEnable = false;
public boolean cheatMode = false;

public CLIConfiguration(CLIWorldEdit mod) {
super(new File(mod.getWorkingDir() + File.separator + "worldedit.properties"));
}

@Override
protected void loadExtra() {
creativeEnable = getBool("use-in-creative", false);
cheatMode = getBool("cheat-mode", false);
}

@Override
public File getWorkingDirectory() {
return CLIWorldEdit.inst.getWorkingDir();
}
}

0 comments on commit ff3a76c

Please sign in to comment.
You can’t perform that action at this time.