mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-25 10:37:35 +01:00
Minor change to Editor
This commit is contained in:
parent
0ef4192769
commit
164d7467ad
@ -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