mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
Minor change to Editor
This commit is contained in:
parent
932c561a85
commit
0d3d667f19
@ -156,7 +156,7 @@ public class EventListen implements Listener {
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Editor.leaveEditor(event.getPlayer());
|
||||
Editor.leave(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -16,7 +16,7 @@ public abstract class Editor implements Listener {
|
||||
|
||||
public abstract void end();
|
||||
|
||||
public static void enterEditor(Player player, Editor editor) {
|
||||
public static void enter(Player player, Editor editor) {
|
||||
if (editing.containsKey(player.getName())) {
|
||||
Messaging.sendError(player, "You're already in an editor!");
|
||||
return;
|
||||
@ -26,7 +26,18 @@ public abstract class Editor implements Listener {
|
||||
editing.put(player.getName(), editor);
|
||||
}
|
||||
|
||||
public static void leaveEditor(Player player) {
|
||||
public static void enterOrLeave(Player player, Editor editor) {
|
||||
Editor edit = editing.get(player.getName());
|
||||
if (edit == null) {
|
||||
enter(player, editor);
|
||||
} else if (edit.getClass() == editor.getClass()) {
|
||||
leave(player);
|
||||
} else {
|
||||
Messaging.sendError(player, "You're already in an editor!");
|
||||
}
|
||||
}
|
||||
|
||||
public static void leave(Player player) {
|
||||
if (!editing.containsKey(player.getName()))
|
||||
return;
|
||||
Editor editor = editing.remove(player.getName());
|
||||
|
Loading…
Reference in New Issue
Block a user