-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow FarmControl to affect non-living entities with 'remove' Action.… (
#38)
- Loading branch information
Showing
21 changed files
with
129 additions
and
69 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
15 changes: 11 additions & 4 deletions
15
src/main/java/com/froobworld/farmcontrol/controller/action/DisableBreedingAction.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 |
---|---|---|
@@ -1,23 +1,30 @@ | ||
package com.froobworld.farmcontrol.controller.action; | ||
|
||
import com.froobworld.farmcontrol.controller.breeding.BreedingBlocker; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.Mob; | ||
|
||
public class DisableBreedingAction extends Action { | ||
private final BreedingBlocker breedingBlocker; | ||
|
||
public DisableBreedingAction(BreedingBlocker breedingBlocker) { | ||
super("disable-breeding", false, true, false); | ||
super("disable-breeding", Mob.class, false, true, false); | ||
this.breedingBlocker = breedingBlocker; | ||
} | ||
|
||
@Override | ||
public void doAction(Mob mob) { | ||
breedingBlocker.setBreedingDisabled(mob, true); | ||
public void doAction(Entity entity) { | ||
if (!(entity instanceof Mob)) { | ||
return; | ||
} | ||
breedingBlocker.setBreedingDisabled(entity, true); | ||
} | ||
|
||
@Override | ||
public void undoAction(Mob mob) { | ||
public void undoAction(Entity entity) { | ||
if (!(entity instanceof Mob mob)) { | ||
return; | ||
} | ||
breedingBlocker.setBreedingDisabled(mob, false); | ||
} | ||
} |
14 changes: 11 additions & 3 deletions
14
src/main/java/com/froobworld/farmcontrol/controller/action/DisableCollisionsAction.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 |
---|---|---|
@@ -1,20 +1,28 @@ | ||
package com.froobworld.farmcontrol.controller.action; | ||
|
||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.Mob; | ||
|
||
public class DisableCollisionsAction extends Action { | ||
|
||
public DisableCollisionsAction() { | ||
super("disable-collisions", false, false, true); | ||
super("disable-collisions", Mob.class, false, false, true); | ||
} | ||
|
||
@Override | ||
public void doAction(Mob mob) { | ||
public void doAction(Entity entity) { | ||
if (!(entity instanceof Mob mob)) { | ||
return; | ||
} | ||
|
||
mob.setCollidable(false); | ||
} | ||
|
||
@Override | ||
public void undoAction(Mob mob) { | ||
public void undoAction(Entity entity) { | ||
if (!(entity instanceof Mob mob)) { | ||
return; | ||
} | ||
mob.setCollidable(true); | ||
} | ||
} |
10 changes: 7 additions & 3 deletions
10
src/main/java/com/froobworld/farmcontrol/controller/action/KillAction.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 |
---|---|---|
@@ -1,18 +1,22 @@ | ||
package com.froobworld.farmcontrol.controller.action; | ||
|
||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.Mob; | ||
|
||
public class KillAction extends Action { | ||
|
||
public KillAction() { | ||
super("kill", true, false, false); | ||
super("kill", Mob.class, true, false, false); | ||
} | ||
|
||
@Override | ||
public void doAction(Mob mob) { | ||
public void doAction(Entity entity) { | ||
if (!(entity instanceof Mob mob)) { | ||
return; | ||
} | ||
mob.setHealth(0); | ||
} | ||
|
||
@Override | ||
public void undoAction(Mob mob) {} | ||
public void undoAction(Entity entity) {} | ||
} |
10 changes: 5 additions & 5 deletions
10
src/main/java/com/froobworld/farmcontrol/controller/action/RemoveAction.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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package com.froobworld.farmcontrol.controller.action; | ||
|
||
import org.bukkit.entity.Mob; | ||
import org.bukkit.entity.Entity; | ||
|
||
public class RemoveAction extends Action { | ||
|
||
public RemoveAction() { | ||
super("remove", true, false, false); | ||
super("remove", Entity.class, true, false, false); | ||
} | ||
|
||
@Override | ||
public void doAction(Mob mob) { | ||
mob.remove(); | ||
public void doAction(Entity entity) { | ||
entity.remove(); | ||
} | ||
|
||
@Override | ||
public void undoAction(Mob mob) {} | ||
public void undoAction(Entity entity) {} | ||
} |
13 changes: 10 additions & 3 deletions
13
src/main/java/com/froobworld/farmcontrol/controller/action/RemoveAiAction.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
13 changes: 10 additions & 3 deletions
13
src/main/java/com/froobworld/farmcontrol/controller/action/RemoveAwarenessAction.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 |
---|---|---|
@@ -1,20 +1,27 @@ | ||
package com.froobworld.farmcontrol.controller.action; | ||
|
||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.Mob; | ||
|
||
public class RemoveAwarenessAction extends Action { | ||
|
||
public RemoveAwarenessAction() { | ||
super("remove-awareness", false, true, true); | ||
super("remove-awareness", Mob.class, false, true, true); | ||
} | ||
|
||
@Override | ||
public void doAction(Mob mob) { | ||
public void doAction(Entity entity) { | ||
if (!(entity instanceof Mob mob)) { | ||
return; | ||
} | ||
mob.setAware(false); | ||
} | ||
|
||
@Override | ||
public void undoAction(Mob mob) { | ||
public void undoAction(Entity entity) { | ||
if (!(entity instanceof Mob mob)) { | ||
return; | ||
} | ||
mob.setAware(true); | ||
} | ||
} |
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.