-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
754 additions
and
14 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
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
66 changes: 66 additions & 0 deletions
66
src/main/java/me/lucko/luckperms/extension/rest/bind/ActionSerializer.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,66 @@ | ||
/* | ||
* This file is part of LuckPerms, licensed under the MIT License. | ||
* | ||
* Copyright (c) lucko (Luck) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package me.lucko.luckperms.extension.rest.bind; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import net.luckperms.api.actionlog.Action; | ||
|
||
import java.io.IOException; | ||
import java.util.UUID; | ||
|
||
public class ActionSerializer extends JsonSerializer<Action> { | ||
|
||
@Override | ||
public void serialize(Action value, JsonGenerator gen, SerializerProvider serializers) throws IOException { | ||
gen.writePOJO(Model.from(value)); | ||
} | ||
|
||
|
||
record Model(long timestamp, SourceModel source, TargetModel target, String description) { | ||
static Model from(Action action) { | ||
return new Model( | ||
action.getTimestamp().getEpochSecond(), | ||
SourceModel.from(action.getSource()), | ||
TargetModel.from(action.getTarget()), | ||
action.getDescription() | ||
); | ||
} | ||
} | ||
|
||
record SourceModel(UUID uniqueId, String name) { | ||
static SourceModel from(Action.Source source) { | ||
return new SourceModel(source.getUniqueId(), source.getName()); | ||
} | ||
} | ||
|
||
record TargetModel(UUID uniqueId, String name, Action.Target.Type type) { | ||
static TargetModel from(Action.Target action) { | ||
return new TargetModel(action.getUniqueId().orElse(null), action.getName(), action.getType()); | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/me/lucko/luckperms/extension/rest/bind/event/LogBroadcastEventSerializer.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,52 @@ | ||
/* | ||
* This file is part of LuckPerms, licensed under the MIT License. | ||
* | ||
* Copyright (c) lucko (Luck) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package me.lucko.luckperms.extension.rest.bind.event; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import net.luckperms.api.actionlog.Action; | ||
import net.luckperms.api.event.log.LogBroadcastEvent; | ||
|
||
import java.io.IOException; | ||
|
||
public class LogBroadcastEventSerializer extends JsonSerializer<LogBroadcastEvent> { | ||
|
||
@Override | ||
public void serialize(LogBroadcastEvent value, JsonGenerator gen, SerializerProvider serializers) throws IOException { | ||
gen.writePOJO(Model.from(value)); | ||
} | ||
|
||
record Model(Action entry, LogBroadcastEvent.Origin origin) { | ||
static Model from(LogBroadcastEvent event) { | ||
return new Model( | ||
event.getEntry(), | ||
event.getOrigin() | ||
); | ||
} | ||
} | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
...ain/java/me/lucko/luckperms/extension/rest/bind/event/PostNetworkSyncEventSerializer.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,57 @@ | ||
/* | ||
* This file is part of LuckPerms, licensed under the MIT License. | ||
* | ||
* Copyright (c) lucko (Luck) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package me.lucko.luckperms.extension.rest.bind.event; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import net.luckperms.api.actionlog.Action; | ||
import net.luckperms.api.event.log.LogBroadcastEvent; | ||
import net.luckperms.api.event.sync.PostNetworkSyncEvent; | ||
import net.luckperms.api.event.sync.SyncType; | ||
|
||
import java.io.IOException; | ||
import java.util.UUID; | ||
|
||
public class PostNetworkSyncEventSerializer extends JsonSerializer<PostNetworkSyncEvent> { | ||
|
||
@Override | ||
public void serialize(PostNetworkSyncEvent value, JsonGenerator gen, SerializerProvider serializers) throws IOException { | ||
gen.writePOJO(Model.from(value)); | ||
} | ||
|
||
record Model(UUID syncId, SyncType type, boolean didSyncOccur, UUID specificUserUniqueId) { | ||
static Model from(PostNetworkSyncEvent event) { | ||
return new Model( | ||
event.getSyncId(), | ||
event.getType(), | ||
event.didSyncOccur(), | ||
event.getSpecificUserUniqueId() | ||
); | ||
} | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/me/lucko/luckperms/extension/rest/bind/event/PostSyncEventSerializer.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,50 @@ | ||
/* | ||
* This file is part of LuckPerms, licensed under the MIT License. | ||
* | ||
* Copyright (c) lucko (Luck) <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package me.lucko.luckperms.extension.rest.bind.event; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import net.luckperms.api.actionlog.Action; | ||
import net.luckperms.api.event.log.LogBroadcastEvent; | ||
import net.luckperms.api.event.sync.PostSyncEvent; | ||
|
||
import java.io.IOException; | ||
|
||
public class PostSyncEventSerializer extends JsonSerializer<PostSyncEvent> { | ||
|
||
@Override | ||
public void serialize(PostSyncEvent value, JsonGenerator gen, SerializerProvider serializers) throws IOException { | ||
gen.writePOJO(Model.from(value)); | ||
} | ||
|
||
record Model() { | ||
static Model from(PostSyncEvent event) { | ||
return new Model(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.