Fix fallback command registration (worldedit bug)
This commit is contained in:
parent
6b6f285972
commit
8c6e24a3e5
@ -30,6 +30,7 @@ import com.boydti.fawe.regions.FaweMaskManager;
|
|||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
|
import com.sk89q.bukkit.util.FallbackRegistrationListener;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.bukkit.EditSessionBlockChangeDelegate;
|
import com.sk89q.worldedit.bukkit.EditSessionBlockChangeDelegate;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
@ -76,6 +77,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
setupInjector();
|
setupInjector();
|
||||||
com.sk89q.worldedit.bukkit.BukkitPlayer.inject(); // Fixes
|
com.sk89q.worldedit.bukkit.BukkitPlayer.inject(); // Fixes
|
||||||
BukkitWorld.inject(); // Fixes
|
BukkitWorld.inject(); // Fixes
|
||||||
|
FallbackRegistrationListener.inject(); // Fixes
|
||||||
try {
|
try {
|
||||||
new BrushListener(plugin);
|
new BrushListener(plugin);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* 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.bukkit.util;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import org.bukkit.command.CommandMap;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
public class FallbackRegistrationListener implements Listener {
|
||||||
|
|
||||||
|
private final CommandMap commandRegistration;
|
||||||
|
|
||||||
|
public FallbackRegistrationListener(CommandMap commandRegistration) {
|
||||||
|
this.commandRegistration = commandRegistration;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
|
boolean doubleSlash = WorldEdit.getInstance().getConfiguration().noDoubleSlash;
|
||||||
|
String msg = event.getMessage();
|
||||||
|
if (doubleSlash || !msg.startsWith("/")) {
|
||||||
|
msg = "/" + msg;
|
||||||
|
}
|
||||||
|
if (commandRegistration.dispatch(event.getPlayer(), msg)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Class<?> inject() {
|
||||||
|
return FallbackRegistrationListener.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user