Skip to content

Commit

Permalink
Merge branch 'master' into feature/internal-state-ids
Browse files Browse the repository at this point in the history
  • Loading branch information
octylFractal committed May 24, 2019
2 parents 3fe5184 + 7b47d9a commit 95b72e2
Show file tree
Hide file tree
Showing 70 changed files with 3,803 additions and 1,264 deletions.
197 changes: 0 additions & 197 deletions README.html

This file was deleted.

1 change: 1 addition & 0 deletions config/checkstyle/import-control.xml
Expand Up @@ -57,6 +57,7 @@
<allow pkg="io.netty.buffer"/>
<allow pkg="org.spongepowered.api" />
<allow pkg="com.mojang.brigadier" />
<allow pkg="com.mojang.datafixers" />
</subpackage>

<subpackage name="sponge">
Expand Down
11 changes: 5 additions & 6 deletions worldedit-bukkit/build.gradle
Expand Up @@ -26,14 +26,13 @@ dependencies {
}

processResources {
from (sourceSets.main.resources.srcDirs) {
filesMatching('plugin.yml') {
expand 'internalVersion': project.internalVersion
include 'plugin.yml'
}

from (sourceSets.main.resources.srcDirs) {
exclude 'plugin.yml'
}
from (zipTree('src/main/resources/worldedit-adapters.jar').matching {
exclude 'META-INF/'
})
exclude '**/worldedit-adapters.jar'
}

jar {
Expand Down
Expand Up @@ -28,6 +28,7 @@
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.MultiUserPlatform;
import com.sk89q.worldedit.extension.platform.Preference;
import com.sk89q.worldedit.world.DataFixer;
import com.sk89q.worldedit.world.registry.Registries;
import org.bukkit.Bukkit;
import org.bukkit.Server;
Expand Down Expand Up @@ -75,9 +76,20 @@ public int getDataVersion() {
return -1;
}

@Override
public DataFixer getDataFixer() {
if (plugin.getBukkitImplAdapter() != null) {
return plugin.getBukkitImplAdapter().getDataFixer();
}
return null;
}

@Override
public boolean isValidMobType(String type) {
final EntityType entityType = EntityType.fromName(type);
if (!type.startsWith("minecraft:")) {
return false;
}
final EntityType entityType = EntityType.fromName(type.substring(10));
return entityType != null && entityType.isAlive();
}

Expand Down
Expand Up @@ -21,7 +21,6 @@

package com.sk89q.worldedit.bukkit;

import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
Expand All @@ -33,7 +32,6 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerCommandSendEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
Expand All @@ -55,12 +53,6 @@ public class WorldEditListener implements Listener {

private WorldEditPlugin plugin;

/**
* Called when a player plays an animation, such as an arm swing
*
* @param event Relevant event details
*/

/**
* Construct the object;
*
Expand Down Expand Up @@ -112,12 +104,8 @@ public void onPlayerInteract(PlayerInteractEvent event) {
return;
}

try {
if (event.getHand() == EquipmentSlot.OFF_HAND) {
return; // TODO api needs to be able to get either hand depending on event
// for now just ignore all off hand interacts
}
} catch (NoSuchMethodError | NoSuchFieldError ignored) {
if (event.getHand() == EquipmentSlot.OFF_HAND) {
return;
}

final Player player = plugin.wrapPlayer(event.getPlayer());
Expand All @@ -143,7 +131,6 @@ public void onPlayerInteract(PlayerInteractEvent event) {
event.setCancelled(true);
}


} else if (action == Action.RIGHT_CLICK_BLOCK) {
final Block clickedBlock = event.getClickedBlock();
final Location pos = new Location(world, clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ());
Expand Down
Expand Up @@ -58,6 +58,10 @@
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -102,20 +106,13 @@ public void onLoad() {
// Setup platform
server = new BukkitServerInterface(this, getServer());
worldEdit.getPlatformManager().register(server);
loadAdapter(); // Need an adapter to work with special blocks with NBT data
setupRegistries();
worldEdit.loadMappings();

loadConfig(); // Load configuration
}

/**
* Called on plugin enable.
*/
@Override
public void onEnable() {
setupTags(); // these have to be done post-world since they rely on MC registries. the other ones just use Bukkit enums

PermissionsResolverManager.initialize(this); // Setup permission resolver

// Register CUI
Expand All @@ -125,10 +122,8 @@ public void onEnable() {
// Now we can register events
getServer().getPluginManager().registerEvents(new WorldEditListener(this), this);

// If we are on MCPC+/Cauldron, then Forge will have already loaded
// Forge WorldEdit and there's (probably) not going to be any other
// platforms to be worried about... at the current time of writing
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
// register this so we can load world-dependent data right as the first world is loading
getServer().getPluginManager().registerEvents(new WorldInitListener(), this);

// Enable metrics
new Metrics(this);
Expand Down Expand Up @@ -433,4 +428,20 @@ BukkitImplAdapter getBukkitImplAdapter() {
return bukkitAdapter;
}

private class WorldInitListener implements Listener {
private boolean loaded = false;
@EventHandler(priority = EventPriority.LOWEST)
public void onWorldInit(@SuppressWarnings("unused") WorldInitEvent event) {
if (loaded) return;
loaded = true;

loadAdapter(); // Need an adapter to work with special blocks with NBT data
setupRegistries();
WorldEdit.getInstance().loadMappings();
loadConfig(); // Load configuration
setupTags();

WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
}
}
}
Expand Up @@ -23,6 +23,7 @@
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.DataFixer;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
Expand All @@ -48,6 +49,14 @@ public interface BukkitImplAdapter {
*/
int getDataVersion();

/**
* Get a data fixer, or null if not supported
*
* @return the data fixer
*/
@Nullable
DataFixer getDataFixer();

/**
* Get the block at the given location.
*
Expand Down

0 comments on commit 95b72e2

Please sign in to comment.