-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
16 changed files
with
234 additions
and
74 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
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
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
24 changes: 24 additions & 0 deletions
24
src/main/java/eu/pb4/graves/event/GraveValidPosCheckEvent.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,24 @@ | ||
package eu.pb4.graves.event; | ||
|
||
import eu.pb4.graves.other.GraveUtils; | ||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.util.math.BlockPos; | ||
|
||
public interface GraveValidPosCheckEvent { | ||
Event<GraveValidPosCheckEvent> EVENT = EventFactory.createArrayBacked(GraveValidPosCheckEvent.class, | ||
(listeners) -> (player, world, pos) -> { | ||
GraveUtils.BlockResult result = GraveUtils.BlockResult.ALLOW; | ||
for (GraveValidPosCheckEvent listener : listeners) { | ||
result = listener.isValid(player, world, pos); | ||
if (!result.canCreate()) { | ||
return result; | ||
} | ||
} | ||
return result; | ||
}); | ||
|
||
GraveUtils.BlockResult isValid(ServerPlayerEntity player, ServerWorld world, BlockPos pos); | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/eu/pb4/graves/event/PlayerGraveCreationEvent.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,41 @@ | ||
package eu.pb4.graves.event; | ||
|
||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.util.math.BlockPos; | ||
|
||
public interface PlayerGraveCreationEvent { | ||
Event<PlayerGraveCreationEvent> EVENT = EventFactory.createArrayBacked(PlayerGraveCreationEvent.class, | ||
(listeners) -> (player) -> { | ||
CreationResult result = CreationResult.ALLOW; | ||
for (PlayerGraveCreationEvent listener : listeners) { | ||
result = listener.shouldCreate(player); | ||
if (!result.allow) { | ||
return result; | ||
} | ||
} | ||
return result; | ||
}); | ||
|
||
CreationResult shouldCreate(ServerPlayerEntity player); | ||
|
||
enum CreationResult { | ||
ALLOW(true), | ||
BLOCK(false), | ||
BLOCK_PVP(false), | ||
BLOCK_CLAIM(false), | ||
BLOCK_SILENT(false); | ||
|
||
private final boolean allow; | ||
|
||
CreationResult(boolean allow) { | ||
this.allow = allow; | ||
} | ||
|
||
public boolean canCreate() { | ||
return this.allow; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../graves/compat/PlayerGraveItemsEvent.java → ...4/graves/event/PlayerGraveItemsEvent.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
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
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.