Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-08 04:20:06 +01:00
Minor improvements to Sponge implementation
- Use SpongeGradle for setting plugin version from Gradle - Use Guice to manage configuration - Use event filter annotation for interact event - Set plugin description and URL - Remove some redundant parts in the Gradle config
Dieser Commit ist enthalten in:
Ursprung
fabd7045e7
Commit
fd0e400bcc
@ -1,68 +1,51 @@
|
|||||||
apply plugin: 'eclipse'
|
|
||||||
apply plugin: 'idea'
|
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url = "http://files.minecraftforge.net/maven" }
|
maven { url = "http://files.minecraftforge.net/maven" }
|
||||||
maven { url = "http://repo.minecrell.net/snapshots" }
|
maven { url = "http://repo.minecrell.net/releases" }
|
||||||
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
|
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'net.minecrell:VanillaGradle:2.0.3-SNAPSHOT'
|
classpath 'net.minecrell:VanillaGradle:2.0.3_1'
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id 'org.spongepowered.plugin' version '0.5.2'
|
||||||
|
}
|
||||||
|
|
||||||
apply plugin: 'net.minecrell.vanilla.server.library'
|
apply plugin: 'net.minecrell.vanilla.server.library'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':worldedit-core')
|
compile project(':worldedit-core')
|
||||||
compile 'org.spongepowered:spongeapi:4.1.0-SNAPSHOT'
|
compile 'org.spongepowered:spongeapi:4.1.0-SNAPSHOT'
|
||||||
compile 'ninja.leaping.configurate:configurate-hocon:3.1'
|
|
||||||
testCompile group: 'org.mockito', name: 'mockito-core', version:'1.9.0-rc1'
|
testCompile group: 'org.mockito', name: 'mockito-core', version:'1.9.0-rc1'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name = 'forge'
|
|
||||||
url = 'http://files.minecraftforge.net/maven'
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
name = "Sponge"
|
|
||||||
url = "https://repo.spongepowered.org/maven"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
|
sponge {
|
||||||
|
plugin {
|
||||||
|
id = 'worldedit'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = "1.8.9"
|
version = "1.8.9"
|
||||||
mappings = "stable_22"
|
mappings = "stable_22"
|
||||||
runDir = 'run'
|
runDir = 'run'
|
||||||
|
|
||||||
replaceIn "com/sk89q/worldedit/sponge/SpongeWorldEdit.java"
|
|
||||||
replace "%VERSION%", project.version
|
|
||||||
}
|
}
|
||||||
|
|
||||||
project.archivesBaseName = "${project.archivesBaseName}-mc${minecraft.version}"
|
project.archivesBaseName = "${project.archivesBaseName}-mc${minecraft.version}"
|
||||||
|
|
||||||
processResources {
|
|
||||||
from (sourceSets.main.resources.srcDirs) {
|
|
||||||
expand 'version': project.version,
|
|
||||||
'mcVersion': project.minecraft.version,
|
|
||||||
'internalVersion': project.internalVersion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes("Class-Path": "truezip.jar WorldEdit/truezip.jar js.jar WorldEdit/js.jar",
|
attributes("Class-Path": "truezip.jar WorldEdit/truezip.jar js.jar WorldEdit/js.jar",
|
||||||
"WorldEdit-Version": version,
|
"WorldEdit-Version": version)
|
||||||
"FMLAT": "worldedit_at.cfg")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,15 +32,15 @@ import com.sk89q.worldedit.sponge.config.SpongeConfiguration;
|
|||||||
import com.sk89q.worldedit.sponge.nms.NMSHelper;
|
import com.sk89q.worldedit.sponge.nms.NMSHelper;
|
||||||
import com.sk89q.worldedit.sponge.nms.SpongeNMSWorld;
|
import com.sk89q.worldedit.sponge.nms.SpongeNMSWorld;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.spongepowered.api.Sponge;
|
|
||||||
import org.spongepowered.api.block.BlockSnapshot;
|
import org.spongepowered.api.block.BlockSnapshot;
|
||||||
import org.spongepowered.api.block.BlockType;
|
import org.spongepowered.api.block.BlockType;
|
||||||
import org.spongepowered.api.block.BlockTypes;
|
import org.spongepowered.api.block.BlockTypes;
|
||||||
import org.spongepowered.api.command.CommandSource;
|
import org.spongepowered.api.command.CommandSource;
|
||||||
import org.spongepowered.api.config.ConfigManager;
|
import org.spongepowered.api.config.ConfigDir;
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
import org.spongepowered.api.event.Listener;
|
import org.spongepowered.api.event.Listener;
|
||||||
import org.spongepowered.api.event.block.InteractBlockEvent;
|
import org.spongepowered.api.event.block.InteractBlockEvent;
|
||||||
|
import org.spongepowered.api.event.filter.cause.Root;
|
||||||
import org.spongepowered.api.event.game.state.*;
|
import org.spongepowered.api.event.game.state.*;
|
||||||
import org.spongepowered.api.item.inventory.ItemStack;
|
import org.spongepowered.api.item.inventory.ItemStack;
|
||||||
import org.spongepowered.api.plugin.Plugin;
|
import org.spongepowered.api.plugin.Plugin;
|
||||||
@ -50,7 +50,6 @@ import org.spongepowered.api.world.Location;
|
|||||||
import org.spongepowered.api.world.World;
|
import org.spongepowered.api.world.World;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -59,7 +58,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
/**
|
/**
|
||||||
* The Sponge implementation of WorldEdit.
|
* The Sponge implementation of WorldEdit.
|
||||||
*/
|
*/
|
||||||
@Plugin(id = SpongeWorldEdit.MOD_ID, name = "WorldEdit", version = "%VERSION%")
|
@Plugin(id = SpongeWorldEdit.MOD_ID, name = "WorldEdit",
|
||||||
|
description = "WorldEdit is an easy-to-use in-game world editor for Minecraft",
|
||||||
|
url = "http://www.enginehub.org/worldedit")
|
||||||
public class SpongeWorldEdit {
|
public class SpongeWorldEdit {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -83,7 +84,11 @@ public class SpongeWorldEdit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SpongePlatform platform;
|
private SpongePlatform platform;
|
||||||
|
|
||||||
|
@Inject
|
||||||
private SpongeConfiguration config;
|
private SpongeConfiguration config;
|
||||||
|
|
||||||
|
@Inject @ConfigDir(sharedRoot = false)
|
||||||
private File workingDir;
|
private File workingDir;
|
||||||
|
|
||||||
public SpongeWorldEdit() {
|
public SpongeWorldEdit() {
|
||||||
@ -92,14 +97,7 @@ public class SpongeWorldEdit {
|
|||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void preInit(GamePreInitializationEvent event) {
|
public void preInit(GamePreInitializationEvent event) {
|
||||||
// Setup working directory
|
// Load configuration
|
||||||
ConfigManager service = Sponge.getGame().getConfigManager();
|
|
||||||
|
|
||||||
Path path = service.getPluginConfig(this).getDirectory();
|
|
||||||
workingDir = path.toFile();
|
|
||||||
workingDir.mkdir();
|
|
||||||
|
|
||||||
config = new SpongeConfiguration(service.getPluginConfig(this).getConfig(), logger);
|
|
||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
Task.builder().interval(30, TimeUnit.SECONDS).execute(ThreadSafeCache.getInstance()).submit(this);
|
Task.builder().interval(30, TimeUnit.SECONDS).execute(ThreadSafeCache.getInstance()).submit(this);
|
||||||
@ -141,7 +139,7 @@ public class SpongeWorldEdit {
|
|||||||
private boolean ignoreLeftClickAir = false;
|
private boolean ignoreLeftClickAir = false;
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onPlayerInteract(InteractBlockEvent event) {
|
public void onPlayerInteract(InteractBlockEvent event, @Root Player spongePlayer) {
|
||||||
if (platform == null) {
|
if (platform == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -149,12 +147,8 @@ public class SpongeWorldEdit {
|
|||||||
if (!platform.isHookingEvents()) return; // We have to be told to catch these events
|
if (!platform.isHookingEvents()) return; // We have to be told to catch these events
|
||||||
|
|
||||||
WorldEdit we = WorldEdit.getInstance();
|
WorldEdit we = WorldEdit.getInstance();
|
||||||
Object rootObj = event.getCause().root();
|
|
||||||
if (!(rootObj instanceof Player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SpongePlayer player = wrapPlayer((Player) rootObj);
|
SpongePlayer player = wrapPlayer(spongePlayer);
|
||||||
com.sk89q.worldedit.world.World world = player.getWorld();
|
com.sk89q.worldedit.world.World world = player.getWorld();
|
||||||
|
|
||||||
BlockSnapshot targetBlock = event.getTargetBlock();
|
BlockSnapshot targetBlock = event.getTargetBlock();
|
||||||
@ -297,7 +291,7 @@ public class SpongeWorldEdit {
|
|||||||
* @return a version string
|
* @return a version string
|
||||||
*/
|
*/
|
||||||
String getInternalVersion() {
|
String getInternalVersion() {
|
||||||
return SpongeWorldEdit.class.getAnnotation(Plugin.class).version();
|
return container.getVersion().orElse("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPermissionsProvider(SpongePermissionsProvider provider) {
|
public void setPermissionsProvider(SpongePermissionsProvider provider) {
|
||||||
|
@ -19,10 +19,12 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.sponge.config;
|
package com.sk89q.worldedit.sponge.config;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.sk89q.worldedit.sponge.SpongeWorldEdit;
|
import com.sk89q.worldedit.sponge.SpongeWorldEdit;
|
||||||
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
|
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
|
||||||
import ninja.leaping.configurate.loader.ConfigurationLoader;
|
import ninja.leaping.configurate.loader.ConfigurationLoader;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.spongepowered.api.config.DefaultConfig;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -32,7 +34,8 @@ public class SpongeConfiguration extends ConfigurateConfiguration {
|
|||||||
public boolean creativeEnable = false;
|
public boolean creativeEnable = false;
|
||||||
public boolean cheatMode = false;
|
public boolean cheatMode = false;
|
||||||
|
|
||||||
public SpongeConfiguration(ConfigurationLoader<CommentedConfigurationNode> config, Logger logger) {
|
@Inject
|
||||||
|
public SpongeConfiguration(@DefaultConfig(sharedRoot = false) ConfigurationLoader<CommentedConfigurationNode> config, Logger logger) {
|
||||||
super(config, logger);
|
super(config, logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren