Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ProfileCreatedEvent Added SPropertyAddEvent Added SPropertyRemoveEvent
- Loading branch information
1 parent
803fafe
commit 7a7ff89
Showing
9 changed files
with
318 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
core/src/main/java/com/georgev22/skinoverlay/event/events/profile/ProfileCreatedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.georgev22.skinoverlay.event.events.profile; | ||
|
||
import com.georgev22.library.maps.UnmodifiableObjectMap; | ||
import com.georgev22.skinoverlay.event.Event; | ||
import com.georgev22.skinoverlay.handler.SGameProfile; | ||
import com.georgev22.skinoverlay.handler.SProperty; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.UnmodifiableView; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* An event that is fired when a new SGameProfile is created. | ||
*/ | ||
public class ProfileCreatedEvent implements Event { | ||
|
||
private final String name; | ||
private final UUID uuid; | ||
private final UnmodifiableObjectMap<String, SProperty> properties; | ||
private final SGameProfile profile; | ||
private final boolean async; | ||
|
||
/** | ||
* Constructs a new ProfileCreatedEvent with the given SGameProfile and whether the event should be run asynchronously. | ||
* | ||
* @param sGameProfile the SGameProfile that was created | ||
* @param async whether the event should be run asynchronously | ||
*/ | ||
public ProfileCreatedEvent(@NotNull SGameProfile sGameProfile, boolean async) { | ||
this.name = sGameProfile.getName(); | ||
this.uuid = sGameProfile.getUUID(); | ||
this.properties = sGameProfile.getProperties(); | ||
this.profile = sGameProfile; | ||
this.async = async; | ||
} | ||
|
||
/** | ||
* Returns the name associated with the created profile. | ||
* | ||
* @return the name associated with the created profile | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** | ||
* Returns the UUID associated with the created profile. | ||
* | ||
* @return the UUID associated with the created profile | ||
*/ | ||
public UUID getUUID() { | ||
return uuid; | ||
} | ||
|
||
/** | ||
* Returns an unmodifiable view of the properties associated with the created profile. | ||
* | ||
* @return an unmodifiable view of the properties associated with the created profile | ||
*/ | ||
@UnmodifiableView | ||
public UnmodifiableObjectMap<String, SProperty> getProperties() { | ||
return properties; | ||
} | ||
|
||
/** | ||
* Returns the SGameProfile that was created. | ||
* | ||
* @return the SGameProfile that was created | ||
*/ | ||
public SGameProfile getProfile() { | ||
return profile; | ||
} | ||
|
||
/** | ||
* Returns whether this event should be run asynchronously. | ||
* | ||
* @return {@code true} if this event should be run asynchronously, {@code false} otherwise | ||
*/ | ||
@Override | ||
public boolean runAsync() { | ||
return async; | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
.../main/java/com/georgev22/skinoverlay/event/events/profile/property/SPropertyAddEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.georgev22.skinoverlay.event.events.profile.property; | ||
|
||
import com.georgev22.skinoverlay.event.Cancellable; | ||
import com.georgev22.skinoverlay.event.Event; | ||
import com.georgev22.skinoverlay.handler.SProperty; | ||
|
||
/** | ||
* An event that is fired when a SProperty is added. | ||
*/ | ||
public class SPropertyAddEvent implements Event, Cancellable { | ||
|
||
private String propertyName; | ||
private SProperty property; | ||
private final boolean async; | ||
private boolean cancelled; | ||
|
||
/** | ||
* Constructs a new SPropertyAddEvent with the given property name, SProperty, and whether the event should be run asynchronously. | ||
* | ||
* @param propertyName the name of the property that was added | ||
* @param property the SProperty that was added | ||
* @param async whether the event should be run asynchronously | ||
*/ | ||
public SPropertyAddEvent(String propertyName, SProperty property, boolean async) { | ||
this.propertyName = propertyName; | ||
this.property = property; | ||
this.async = async; | ||
} | ||
|
||
/** | ||
* Returns the name of the property that was added. | ||
* | ||
* @return the name of the property that was added | ||
*/ | ||
public String getPropertyName() { | ||
return propertyName; | ||
} | ||
|
||
/** | ||
* Returns the SProperty that was added. | ||
* | ||
* @return the SProperty that was added | ||
*/ | ||
public SProperty getProperty() { | ||
return property; | ||
} | ||
|
||
/** | ||
* Sets the name of the property that was added. | ||
* | ||
* @param propertyName the new name of the property that was added | ||
*/ | ||
public void setPropertyName(String propertyName) { | ||
this.propertyName = propertyName; | ||
} | ||
|
||
/** | ||
* Sets the SProperty that was added. | ||
* | ||
* @param property the new SProperty that was added | ||
*/ | ||
public void setProperty(SProperty property) { | ||
this.property = property; | ||
} | ||
|
||
/** | ||
* Cancels the event. | ||
* | ||
* @return {@code true} if the event was successfully cancelled, {@code false} otherwise | ||
*/ | ||
@Override | ||
public boolean cancel() { | ||
return cancelled = true; | ||
} | ||
|
||
/** | ||
* Returns whether the event has been cancelled. | ||
* | ||
* @return {@code true} if the event has been cancelled, {@code false} otherwise | ||
*/ | ||
@Override | ||
public boolean isCancelled() { | ||
return cancelled; | ||
} | ||
|
||
/** | ||
* Returns whether this event should be run asynchronously. | ||
* | ||
* @return {@code true} if this event should be run asynchronously, {@code false} otherwise | ||
*/ | ||
@Override | ||
public boolean runAsync() { | ||
return async; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...in/java/com/georgev22/skinoverlay/event/events/profile/property/SPropertyRemoveEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.georgev22.skinoverlay.event.events.profile.property; | ||
|
||
import com.georgev22.skinoverlay.event.Cancellable; | ||
import com.georgev22.skinoverlay.event.Event; | ||
import com.georgev22.skinoverlay.handler.SProperty; | ||
|
||
/** | ||
* An event that is fired when a SProperty is removed. | ||
*/ | ||
public class SPropertyRemoveEvent implements Event, Cancellable { | ||
|
||
private final String propertyName; | ||
private final SProperty property; | ||
private final boolean async; | ||
private boolean cancelled; | ||
|
||
/** | ||
* Constructs a new SPropertyRemoveEvent with the given property name, SProperty, and whether the event should be run asynchronously. | ||
* | ||
* @param propertyName the name of the property that was removed | ||
* @param property the SProperty that was removed | ||
* @param async whether the event should be run asynchronously | ||
*/ | ||
public SPropertyRemoveEvent(String propertyName, SProperty property, boolean async) { | ||
this.propertyName = propertyName; | ||
this.property = property; | ||
this.async = async; | ||
} | ||
|
||
/** | ||
* Returns the name of the property that was removed. | ||
* | ||
* @return the name of the property that was removed | ||
*/ | ||
public String getPropertyName() { | ||
return propertyName; | ||
} | ||
|
||
/** | ||
* Returns the SProperty that was removed. | ||
* | ||
* @return the SProperty that was removed | ||
*/ | ||
public SProperty getProperty() { | ||
return property; | ||
} | ||
|
||
/** | ||
* Cancels the event. | ||
* | ||
* @return {@code true} if the event was successfully cancelled, {@code false} otherwise | ||
*/ | ||
@Override | ||
public boolean cancel() { | ||
return cancelled = true; | ||
} | ||
|
||
/** | ||
* Returns whether the event has been cancelled. | ||
* | ||
* @return {@code true} if the event has been cancelled, {@code false} otherwise | ||
*/ | ||
@Override | ||
public boolean isCancelled() { | ||
return cancelled; | ||
} | ||
|
||
/** | ||
* Returns whether this event should be run asynchronously. | ||
* | ||
* @return {@code true} if this event should be run asynchronously, {@code false} otherwise | ||
*/ | ||
@Override | ||
public boolean runAsync() { | ||
return async; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.