-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-891 Fix removing catboy using butcher, remove catboy on server shu…
…tdown, add catboy config. (#891) * Fix removing catboy using butcher, remove catboy on server shutdown, add catboy config. Add catboy persistance. * GH-579 Add repository for language. Remove user settings. (#890) * Add repository for language. Remove user settings. * Simplify API * Provide catboy speed from config. * Create CatBoyEntityService --------- Co-authored-by: Norbert Dejlich <[email protected]>
- Loading branch information
Showing
12 changed files
with
182 additions
and
30 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...core-api/src/main/java/com/eternalcode/core/feature/butcher/ButcherEntityRemoveEvent.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 com.eternalcode.core.feature.butcher; | ||
|
||
import org.bukkit.entity.Entity; | ||
import org.bukkit.event.Cancellable; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
|
||
public class ButcherEntityRemoveEvent extends Event implements Cancellable { | ||
|
||
private static final HandlerList HANDLER_LIST = new HandlerList(); | ||
|
||
private boolean cancelled; | ||
private final Entity entity; | ||
|
||
public ButcherEntityRemoveEvent(Entity entity) { | ||
this.entity = entity; | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return cancelled; | ||
} | ||
|
||
@Override | ||
public void setCancelled(boolean cancelled) { | ||
this.cancelled = cancelled; | ||
} | ||
|
||
public Entity getEntity() { | ||
return entity; | ||
} | ||
|
||
@Override | ||
public HandlerList getHandlers() { | ||
return HANDLER_LIST; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return HANDLER_LIST; | ||
} | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...ature/essentials/mob/ButcherArgument.java → ...core/feature/butcher/ButcherArgument.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
2 changes: 1 addition & 1 deletion
2
...ore/feature/essentials/mob/MobEntity.java → ...lcode/core/feature/butcher/MobEntity.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
2 changes: 1 addition & 1 deletion
2
...ure/essentials/mob/MobEntityArgument.java → ...re/feature/butcher/MobEntityArgument.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
2 changes: 1 addition & 1 deletion
2
...ore/feature/essentials/mob/MobFilter.java → ...lcode/core/feature/butcher/MobFilter.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
2 changes: 1 addition & 1 deletion
2
.../core/feature/essentials/mob/MobType.java → ...nalcode/core/feature/butcher/MobType.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
40 changes: 40 additions & 0 deletions
40
eternalcore-core/src/main/java/com/eternalcode/core/feature/catboy/CatBoyEntityService.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,40 @@ | ||
package com.eternalcode.core.feature.catboy; | ||
|
||
import com.eternalcode.core.injector.annotations.Inject; | ||
import com.eternalcode.core.injector.annotations.component.Service; | ||
import org.bukkit.NamespacedKey; | ||
import org.bukkit.entity.Cat; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.persistence.PersistentDataContainer; | ||
import org.bukkit.persistence.PersistentDataType; | ||
import org.bukkit.plugin.Plugin; | ||
|
||
@Service | ||
class CatBoyEntityService { | ||
|
||
private final NamespacedKey catboyNamespacedKey; | ||
|
||
@Inject | ||
CatBoyEntityService(Plugin plugin) { | ||
this.catboyNamespacedKey = new NamespacedKey(plugin, "catboy"); | ||
} | ||
|
||
Cat createCatboyEntity(Player player, Cat.Type type) { | ||
Cat cat = (Cat) player.getWorld().spawnEntity(player.getLocation(), EntityType.CAT); | ||
cat.setInvulnerable(true); | ||
cat.setOwner(player); | ||
cat.setAI(false); | ||
cat.setCatType(type); | ||
|
||
PersistentDataContainer persistentDataContainer = cat.getPersistentDataContainer(); | ||
persistentDataContainer.set(catboyNamespacedKey, PersistentDataType.BOOLEAN, true); | ||
|
||
return cat; | ||
} | ||
|
||
boolean isCatboy(Cat cat) { | ||
return cat.getPersistentDataContainer().has(catboyNamespacedKey, PersistentDataType.BOOLEAN); | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
eternalcore-core/src/main/java/com/eternalcode/core/feature/catboy/CatBoySettings.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,7 @@ | ||
package com.eternalcode.core.feature.catboy; | ||
|
||
public interface CatBoySettings { | ||
|
||
float getCatboyWalkSpeed(); | ||
|
||
} |
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