2012-03-28 05:52:48 +00:00
|
|
|
/*
|
2014-04-04 22:03:18 +00:00
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
2012-03-28 05:52:48 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* 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
|
2012-03-28 05:52:48 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* 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.
|
2012-03-28 05:52:48 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2012-03-28 05:52:48 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.sk89q.worldedit.bukkit;
|
|
|
|
|
|
|
|
import com.sk89q.worldedit.LocalSession;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
|
|
|
|
|
|
|
import java.nio.charset.Charset;
|
2019-06-25 13:00:44 +00:00
|
|
|
import java.nio.charset.StandardCharsets;
|
2012-03-28 05:52:48 +00:00
|
|
|
|
|
|
|
/**
|
2014-07-29 18:04:04 +00:00
|
|
|
* Handles incoming WorldEditCui init message.
|
2012-03-28 05:52:48 +00:00
|
|
|
*/
|
|
|
|
public class CUIChannelListener implements PluginMessageListener {
|
2014-07-29 18:04:04 +00:00
|
|
|
|
2019-11-21 07:57:32 +00:00
|
|
|
public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
|
2012-03-28 05:52:48 +00:00
|
|
|
private final WorldEditPlugin plugin;
|
|
|
|
|
|
|
|
public CUIChannelListener(WorldEditPlugin plugin) {
|
|
|
|
this.plugin = plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
|
|
|
LocalSession session = plugin.getSession(player);
|
2012-08-05 03:22:55 +00:00
|
|
|
String text = new String(message, UTF_8_CHARSET);
|
2019-07-06 00:46:48 +00:00
|
|
|
final BukkitPlayer actor = plugin.wrapPlayer(player);
|
|
|
|
session.handleCUIInitializationMessage(text, actor);
|
|
|
|
session.describeCUI(actor);
|
2012-03-28 05:52:48 +00:00
|
|
|
}
|
2014-07-29 18:04:04 +00:00
|
|
|
|
2012-03-28 05:52:48 +00:00
|
|
|
}
|