2017-08-22 15:02:23 +02:00
|
|
|
package net.ME1312.SubServers.Sync.Event;
|
|
|
|
|
2019-05-14 04:02:38 +02:00
|
|
|
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
|
|
|
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
|
2020-06-12 07:45:49 +02:00
|
|
|
import net.ME1312.Galaxi.Library.Container.NamedContainer;
|
2017-08-22 15:02:23 +02:00
|
|
|
import net.ME1312.SubServers.Sync.Library.SubEvent;
|
2019-05-14 04:02:38 +02:00
|
|
|
import net.ME1312.Galaxi.Library.Util;
|
2017-08-22 15:02:23 +02:00
|
|
|
import net.md_5.bungee.api.plugin.Event;
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Server Edit Event
|
|
|
|
*/
|
|
|
|
public class SubEditServerEvent extends Event implements SubEvent {
|
|
|
|
private UUID player;
|
|
|
|
private String server;
|
2019-05-14 04:02:38 +02:00
|
|
|
private NamedContainer<String, ObjectMapValue<String>> edit;
|
2017-08-22 15:02:23 +02:00
|
|
|
private boolean perm;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Server Edit Event
|
|
|
|
*
|
|
|
|
* @param player Player Adding Server
|
|
|
|
* @param server Server to be Edited
|
|
|
|
* @param edit Edit to make
|
|
|
|
* @param permanent If the change is permanent
|
|
|
|
*/
|
|
|
|
public SubEditServerEvent(UUID player, String server, NamedContainer<String, ?> edit, boolean permanent) {
|
|
|
|
if (Util.isNull(server, edit)) throw new NullPointerException();
|
2019-05-14 04:02:38 +02:00
|
|
|
ObjectMap<String> section = new ObjectMap<String>();
|
2017-08-22 15:02:23 +02:00
|
|
|
section.set(".", edit.get());
|
|
|
|
this.player = player;
|
|
|
|
this.server = server;
|
2019-05-14 04:02:38 +02:00
|
|
|
this.edit = new NamedContainer<String, ObjectMapValue<String>>(edit.name(), section.get("."));
|
2017-08-22 15:02:23 +02:00
|
|
|
this.perm = permanent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the Server to be Edited
|
|
|
|
*
|
|
|
|
* @return The Server to be Edited
|
|
|
|
*/
|
|
|
|
public String getServer() { return server; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the player that triggered the Event
|
|
|
|
*
|
|
|
|
* @return The Player that triggered this Event or null if Console
|
|
|
|
*/
|
|
|
|
public UUID getPlayer() { return player; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the edit to be made
|
|
|
|
*
|
|
|
|
* @return Edit to be made
|
|
|
|
*/
|
2019-05-14 04:02:38 +02:00
|
|
|
public NamedContainer<String, ObjectMapValue<String>> getEdit() {
|
2017-08-22 15:02:23 +02:00
|
|
|
return edit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets if the edit is permanent
|
|
|
|
*
|
|
|
|
* @return Permanent Status
|
|
|
|
*/
|
|
|
|
public boolean isPermanent() {
|
|
|
|
return perm;
|
|
|
|
}
|
|
|
|
}
|